Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dreamsComeTrue
Copy link
Contributor

@dreamsComeTrue dreamsComeTrue commented Mar 20, 2020

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

help-scroll

@Calinou
Copy link
Member

Calinou commented Mar 20, 2020

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?

@dreamsComeTrue
Copy link
Contributor Author

dreamsComeTrue commented Mar 20, 2020

Great work slightly_smiling_face

I noticed the "Inherits"/"Inherited By" link text at the top isn't affected. Is it possible to fix that?

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 😄

Also, would it be possible to apply line spacing changes earlier so the text doesn't appear broken for a short duration?

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.
I believe, if we're using scroll wheel, and doing rapid movements - Godot can't keep up with rebuilding bbcode inside of RichTextLabel resulting in half-second of gibberish..

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

@dreamsComeTrue dreamsComeTrue force-pushed the help-zoom-text branch 2 times, most recently from c6168c0 to 93e68a2 Compare March 21, 2020 00:15
@Calinou Calinou added this to the 4.0 milestone Jan 5, 2021
Copy link
Member

@Calinou Calinou left a 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) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Ref<InputEventMouseButton> mb = p_input;

if (mb.is_valid()) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


Ref<InputEventMagnifyGesture> magnify_gesture = p_input;
if (magnify_gesture.is_valid()) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Ref<InputEventKey> k = p_input;

if (k.is_valid()) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +245 to +246
if (font_resize_timer->get_time_left() == 0)
font_resize_timer->start();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Ref<DynamicFont> font = get_font(p_name, "EditorFonts");

if (font.is_valid()) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +238 to +241
_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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
_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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
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) {

@YuriSizov YuriSizov requested a review from a team August 24, 2021 23:00
@akien-mga akien-mga modified the milestones: 4.0, 4.x Jul 28, 2022
@akien-mga
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to change font size/zoom level in the Editor help with a shortcut (Ctrl + Mouse Wheel)
3 participants