Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

editor: Fix integer zoom in 2D editor

Stuart Carnie59db1b56b4ed
diff --git a/editor/gui/editor_zoom_widget.cpp b/editor/gui/editor_zoom_widget.cpp
index c7c9b300a29..d17aeb601df 100644
--- a/editor/gui/editor_zoom_widget.cpp
+++ b/editor/gui/editor_zoom_widget.cpp
@@ -56,19 +56,24 @@ void EditorZoomWidget::_update_zoom_label() {
zoom_reset->set_text(zoom_text);
}
-void EditorZoomWidget::_button_zoom_minus() {
- set_zoom_by_increments(-6, Input::get_singleton()->is_key_pressed(Key::ALT));
+void EditorZoomWidget::_button_zoom_by(int p_direction) {
+ bool by_integer = Input::get_singleton()->is_key_pressed(Key::ALT);
+ // Integer mode steps one scaling factor at a time.
+ set_zoom_by_increments(p_direction * (by_integer ? 1 : 6), by_integer);
emit_signal(SNAME("zoom_changed"), zoom);
}
+void EditorZoomWidget::_button_zoom_minus() {
+ _button_zoom_by(-1);
+}
+
void EditorZoomWidget::_button_zoom_reset() {
set_zoom(1.0 * MAX(1, EDSCALE));
emit_signal(SNAME("zoom_changed"), zoom);
}
void EditorZoomWidget::_button_zoom_plus() {
- set_zoom_by_increments(6, Input::get_singleton()->is_key_pressed(Key::ALT));
- emit_signal(SNAME("zoom_changed"), zoom);
+ _button_zoom_by(1);
}
float EditorZoomWidget::get_zoom() {
diff --git a/editor/gui/editor_zoom_widget.h b/editor/gui/editor_zoom_widget.h
index c1b2f2beb18..a827dac94f0 100644
--- a/editor/gui/editor_zoom_widget.h
+++ b/editor/gui/editor_zoom_widget.h
@@ -44,6 +44,7 @@ class EditorZoomWidget : public HBoxContainer {
float min_zoom = 1.0 / 128;
float max_zoom = 128.0;
void _update_zoom_label();
+ void _button_zoom_by(int p_direction);
void _button_zoom_minus();
void _button_zoom_reset();
void _button_zoom_plus();