-
-
Notifications
You must be signed in to change notification settings - Fork 22.5k
Make Editor Help text possible to be zoomed in/out #37196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Great work 🙂 I noticed the "Inherits"/"Inherited By" link text at the top isn't affected by the font size changes. Do you know why that happens? Also, would it be possible to apply line spacing changes earlier so the text doesn't appear broken for a short duration? |
Heh, I knew it someone will notice that - and I was thinking about that too - actually - strangely - the font, that SHOULD be used to affect that part is being 'poped out' from the stack, just before those links are being rendered. I was afraid - it might be done that way for any particular reason, but now, as I have your blessing to modify it - it's not a problem to adjust them as well :) EDIT: fixed, updated, new GIF 😄
EDIT2: The weird issue with text not layouting correct instantly is not introduced by me - it's just how RichTextLabel takes much time to re-layout itself - I am just changing it's font size. Even if you go into Editor Settings and try to change TextEditor/Help - one of those 3 fonts - either with fast clicking or slow - it doesn't matter, as Editor waits a bit to redraw everything, and only then - renders correct layout. EDIT3: IDK whether it would help, but I've mirrored the same functionality as in regular Code Editor - so basically there is a timer underneath, with very small timeout, which is being triggered when no other updates are requested - for me it smoothes zooming process a little, but - still - bbcode is the problem here (or maybe rebuilding fonts for every change?) - but those are internals of RichTextLabel |
c6168c0
to
93e68a2
Compare
93e68a2
to
edacef3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature looks good to me, but make sure to update the code style to follow the latest master
branch.
In the future, we should simplify the editor help font size settings to only have a single "base" setting and compute all other values (title and source) automatically. This will make editor settings easier to adjust for people.
@@ -168,6 +169,121 @@ void EditorHelp::_class_desc_select(const String &p_select) { | |||
} | |||
|
|||
void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref<InputEventMouseButton> mb = p_input; | ||
|
||
if (mb.is_valid()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
Ref<InputEventMagnifyGesture> magnify_gesture = p_input; | ||
if (magnify_gesture.is_valid()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref<InputEventKey> k = p_input; | ||
|
||
if (k.is_valid()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (font_resize_timer->get_time_left() == 0) | ||
font_resize_timer->start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (font_resize_timer->get_time_left() == 0) | |
font_resize_timer->start(); | |
if (font_resize_timer->get_time_left() == 0) { | |
font_resize_timer->start(); | |
} |
|
||
int new_font_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE); | ||
if (new_font_size != font->get_size()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref<DynamicFont> font = get_font(p_name, "EditorFonts"); | ||
|
||
if (font.is_valid()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_set_dafault_doc_font_size("doc", "text_editor/help/help_font_size", 15); | ||
_set_dafault_doc_font_size("doc_bold", "text_editor/help/help_font_size", 15); | ||
_set_dafault_doc_font_size("doc_title", "text_editor/help/help_title_font_size", 23); | ||
_set_dafault_doc_font_size("doc_source", "text_editor/help/help_source_font_size", 14); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo:
_set_dafault_doc_font_size("doc", "text_editor/help/help_font_size", 15); | |
_set_dafault_doc_font_size("doc_bold", "text_editor/help/help_font_size", 15); | |
_set_dafault_doc_font_size("doc_title", "text_editor/help/help_title_font_size", 23); | |
_set_dafault_doc_font_size("doc_source", "text_editor/help/help_source_font_size", 14); | |
_set_default_doc_font_size("doc", "text_editor/help/help_font_size", 15); | |
_set_default_doc_font_size("doc_bold", "text_editor/help/help_font_size", 15); | |
_set_default_doc_font_size("doc_title", "text_editor/help/help_title_font_size", 23); | |
_set_default_doc_font_size("doc_source", "text_editor/help/help_source_font_size", 14); |
void _zoom_out(); | ||
void _reset_zoom(); | ||
void _zoom_changed(); | ||
void _set_dafault_doc_font_size(const String &p_name, const String &p_config_path, int size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo:
void _set_dafault_doc_font_size(const String &p_name, const String &p_config_path, int size); | |
void _set_default_doc_font_size(const String &p_name, const String &p_config_path, int size); |
font_resize_timer->start(); | ||
} | ||
|
||
void EditorHelp::_set_dafault_doc_font_size(const String &p_name, const String &p_config_path, int size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo:
void EditorHelp::_set_dafault_doc_font_size(const String &p_name, const String &p_config_path, int size) { | |
void EditorHelp::_set_default_doc_font_size(const String &p_name, const String &p_config_path, int size) { |
This needs to be updated to address review comment, and maybe the implementation might differ now in 4.0. It would make sense to leave the editor settings unchanged, and instead save a zoom ratio in editor metadata to scale the font size. This zoom should also be displayed somewhere (like in the 2D/3D viewports) so it can be easily reset when non default. |
While regular code editor has posibility of text zooming in/out, help tabs didn't have similar functionality.
It is possible to change its size (for 3 different 'categories'/sections in help text area) - but only by going into editor properties, adjusting it manually, saving and observing how documentation text would look like.
With following PR, it's possible to use regular mouse scroll gestures (CTRL + whell up/down), keyboard shortcuts (CTRL + plus, CTRL + minus, CTRL + zero), and magnify gesture to control text size of documentation/help area