diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-02-19 21:35:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-19 21:35:11 +0100 |
commit | f163b0e4b4da163de121503ca93aad212f053be4 (patch) | |
tree | b0cb95a6fa85211bb744c57de56de8e902c66738 /editor/code_editor.cpp | |
parent | 3564895b63c50c2c903750df63b6f39bf0c35d37 (diff) | |
parent | 1ca122c771e1dceb9452c768948ffbf378892406 (diff) | |
download | redot-engine-f163b0e4b4da163de121503ca93aad212f053be4.tar.gz |
Merge pull request #16241 from Chaosus/zoomlabel
Added zoom label to code editor
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r-- | editor/code_editor.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 6d4d8658c1..9ae9ab1501 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -666,6 +666,7 @@ void CodeTextEditor::_reset_zoom() { if (font.is_valid()) { EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14); font->set_size(14); + zoom_nb->set_text("100%"); } } @@ -727,6 +728,9 @@ bool CodeTextEditor::_add_font_size(int p_delta) { if (font.is_valid()) { int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE); + + zoom_nb->set_text(itos(100 * new_size / 14) + "%"); + if (new_size != font->get_size()) { EditorSettings::get_singleton()->set("interface/editor/code_font_size", new_size / EDSCALE); font->set_size(new_size); @@ -886,6 +890,24 @@ CodeTextEditor::CodeTextEditor() { status_bar->add_child(memnew(Label)); //to keep the height if the other labels are not visible + Label *zoom_txt = memnew(Label); + status_bar->add_child(zoom_txt); + zoom_txt->set_align(Label::ALIGN_RIGHT); + zoom_txt->set_valign(Label::VALIGN_CENTER); + zoom_txt->set_v_size_flags(SIZE_FILL); + zoom_txt->set_text(TTR("Zoom:")); + zoom_txt->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); + + zoom_nb = memnew(Label); + status_bar->add_child(zoom_nb); + zoom_nb->set_valign(Label::VALIGN_CENTER); + zoom_nb->set_v_size_flags(SIZE_FILL); + zoom_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch + zoom_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch + zoom_nb->set_custom_minimum_size(Size2(60, 1) * EDSCALE); + zoom_nb->set_align(Label::ALIGN_RIGHT); + zoom_nb->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); + Label *line_txt = memnew(Label); status_bar->add_child(line_txt); line_txt->set_align(Label::ALIGN_RIGHT); @@ -939,7 +961,8 @@ CodeTextEditor::CodeTextEditor() { code_complete_timer->connect("timeout", this, "_code_complete_timer_timeout"); font_resize_val = 0; - font_size = -1; + font_size = EditorSettings::get_singleton()->get("interface/editor/code_font_size"); + zoom_nb->set_text(itos(100 * font_size / 14) + "%"); font_resize_timer = memnew(Timer); add_child(font_resize_timer); font_resize_timer->set_one_shot(true); |