summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2016-07-15 13:28:20 +0200
committerGitHub <noreply@github.com>2016-07-15 13:28:20 +0200
commit4c4ab140b4569f2700517a13b20127eb7542b3ec (patch)
treee8a03c2fb061dd59d5af8e772725fc971a20ed76 /tools
parenteaeee58b9ef95f708728161296a66743f45501d3 (diff)
parente6eae244d3835addb87ed31f8325f590521c73aa (diff)
Merge pull request #5702 from Paulb23/zoom_shortcuts
Added code editor zoom shortcuts
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/code_editor.cpp57
-rw-r--r--tools/editor/code_editor.h3
2 files changed, 39 insertions, 21 deletions
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index 21de122cee..71ae171dfe 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -985,36 +985,47 @@ void CodeTextEditor::_text_editor_input_event(const InputEvent& p_event) {
if (mb.pressed && mb.mod.command) {
if (mb.button_index==BUTTON_WHEEL_UP) {
-
- font_resize_val+=1;
-
- if (font_resize_timer->get_time_left()==0)
- font_resize_timer->start();
-
+ _zoom_in();
} else if (mb.button_index==BUTTON_WHEEL_DOWN) {
-
- font_resize_val-=1;
-
- if (font_resize_timer->get_time_left()==0)
- font_resize_timer->start();
+ _zoom_out();
}
}
} else if (p_event.type==InputEvent::KEY) {
- const InputEventKey& k=p_event.key;
+ if (p_event.key.pressed) {
+ if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) {
+ _zoom_in();
+ }
+ if (ED_IS_SHORTCUT("script_editor/zoom_out", p_event)) {
+ _zoom_out();
+ }
+ if (ED_IS_SHORTCUT("script_editor/reset_zoom", p_event)) {
+ _reset_zoom();
+ }
+ }
+ }
+}
- if (k.pressed && k.mod.command) {
+void CodeTextEditor::_zoom_in() {
+ font_resize_val+=1;
- if (k.scancode==KEY_0) { // reset source font size to default
+ if (font_resize_timer->get_time_left()==0)
+ font_resize_timer->start();
+}
- Ref<DynamicFont> font = text_editor->get_font("font");
+void CodeTextEditor::_zoom_out() {
+ font_resize_val-=1;
- if (font.is_valid()) {
- EditorSettings::get_singleton()->set("global/source_font_size",14);
- font->set_size(14);
- }
- }
- }
+ if (font_resize_timer->get_time_left()==0)
+ font_resize_timer->start();
+}
+
+void CodeTextEditor::_reset_zoom() {
+ Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default
+
+ if (font.is_valid()) {
+ EditorSettings::get_singleton()->set("global/source_font_size",14);
+ font->set_size(14);
}
}
@@ -1150,6 +1161,10 @@ void CodeTextEditor::_bind_methods() {
CodeTextEditor::CodeTextEditor() {
+ ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD|KEY_EQUAL);
+ ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD|KEY_MINUS);
+ ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD|KEY_0);
+
find_replace_bar = memnew( FindReplaceBar );
add_child(find_replace_bar);
find_replace_bar->set_h_size_flags(SIZE_EXPAND_FILL);
diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h
index bdfd295ded..7983c46f7a 100644
--- a/tools/editor/code_editor.h
+++ b/tools/editor/code_editor.h
@@ -214,6 +214,9 @@ class CodeTextEditor : public VBoxContainer {
void _font_resize_timeout();
void _text_editor_input_event(const InputEvent& p_event);
+ void _zoom_in();
+ void _zoom_out();
+ void _reset_zoom();
protected: