mirror of
https://github.com/godotengine/godot.git
synced 2025-02-07 19:30:52 +00:00
Added code editor zoom shortcuts
This commit is contained in:
parent
3e2c7bf797
commit
e6eae244d3
@ -985,39 +985,50 @@ void CodeTextEditor::_text_editor_input_event(const InputEvent& p_event) {
|
|||||||
if (mb.pressed && mb.mod.command) {
|
if (mb.pressed && mb.mod.command) {
|
||||||
|
|
||||||
if (mb.button_index==BUTTON_WHEEL_UP) {
|
if (mb.button_index==BUTTON_WHEEL_UP) {
|
||||||
|
_zoom_in();
|
||||||
font_resize_val+=1;
|
|
||||||
|
|
||||||
if (font_resize_timer->get_time_left()==0)
|
|
||||||
font_resize_timer->start();
|
|
||||||
|
|
||||||
} else if (mb.button_index==BUTTON_WHEEL_DOWN) {
|
} else if (mb.button_index==BUTTON_WHEEL_DOWN) {
|
||||||
|
_zoom_out();
|
||||||
font_resize_val-=1;
|
|
||||||
|
|
||||||
if (font_resize_timer->get_time_left()==0)
|
|
||||||
font_resize_timer->start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (p_event.type==InputEvent::KEY) {
|
} 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)) {
|
||||||
if (k.pressed && k.mod.command) {
|
_zoom_in();
|
||||||
|
}
|
||||||
if (k.scancode==KEY_0) { // reset source font size to default
|
if (ED_IS_SHORTCUT("script_editor/zoom_out", p_event)) {
|
||||||
|
_zoom_out();
|
||||||
Ref<DynamicFont> font = text_editor->get_font("font");
|
}
|
||||||
|
if (ED_IS_SHORTCUT("script_editor/reset_zoom", p_event)) {
|
||||||
if (font.is_valid()) {
|
_reset_zoom();
|
||||||
EditorSettings::get_singleton()->set("global/source_font_size",14);
|
|
||||||
font->set_size(14);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeTextEditor::_zoom_in() {
|
||||||
|
font_resize_val+=1;
|
||||||
|
|
||||||
|
if (font_resize_timer->get_time_left()==0)
|
||||||
|
font_resize_timer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeTextEditor::_zoom_out() {
|
||||||
|
font_resize_val-=1;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CodeTextEditor::_line_col_changed() {
|
void CodeTextEditor::_line_col_changed() {
|
||||||
|
|
||||||
String text = String()+TTR("Line:")+" "+itos(text_editor->cursor_get_line()+1)+", "+TTR("Col:")+" "+itos(text_editor->cursor_get_column());
|
String text = String()+TTR("Line:")+" "+itos(text_editor->cursor_get_line()+1)+", "+TTR("Col:")+" "+itos(text_editor->cursor_get_column());
|
||||||
@ -1150,6 +1161,10 @@ void CodeTextEditor::_bind_methods() {
|
|||||||
|
|
||||||
CodeTextEditor::CodeTextEditor() {
|
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 );
|
find_replace_bar = memnew( FindReplaceBar );
|
||||||
add_child(find_replace_bar);
|
add_child(find_replace_bar);
|
||||||
find_replace_bar->set_h_size_flags(SIZE_EXPAND_FILL);
|
find_replace_bar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
@ -214,6 +214,9 @@ class CodeTextEditor : public VBoxContainer {
|
|||||||
void _font_resize_timeout();
|
void _font_resize_timeout();
|
||||||
|
|
||||||
void _text_editor_input_event(const InputEvent& p_event);
|
void _text_editor_input_event(const InputEvent& p_event);
|
||||||
|
void _zoom_in();
|
||||||
|
void _zoom_out();
|
||||||
|
void _reset_zoom();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user