summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-07-21 10:06:38 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-07-21 10:11:53 -0300
commit124e3591a5b17e0fd4e50540dd909bed94792f32 (patch)
treec9f5b88a50be0c57b804f82b8891a403f53d9d6b /tools
parentad55c63918bee55c84c2be9aff27f348c267d93e (diff)
Some optimizations and limits for extreme zoom in and out in editor, fixes #5820
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index ec5ac8592b..02a24f8ddb 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -41,6 +41,11 @@
#include "tools/editor/plugins/animation_player_editor_plugin.h"
#include "scene/resources/packed_scene.h"
+
+#define MIN_ZOOM 0.01
+#define MAX_ZOOM 100
+
+
class SnapDialog : public ConfirmationDialog {
OBJ_TYPE(SnapDialog,ConfirmationDialog);
@@ -1062,6 +1067,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
if (b.button_index==BUTTON_WHEEL_DOWN) {
+ if (zoom<MIN_ZOOM)
+ return;
+
float prev_zoom=zoom;
zoom=zoom*0.95;
{
@@ -1077,6 +1085,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
if (b.button_index==BUTTON_WHEEL_UP) {
+ if (zoom>MAX_ZOOM)
+ return;
+
float prev_zoom=zoom;
zoom=zoom*(1.0/0.95);
{
@@ -2526,12 +2537,17 @@ void CanvasItemEditor::_popup_callback(int p_op) {
snap_dialog->popup_centered(Size2(220,160));
} break;
case ZOOM_IN: {
+ if (zoom>MAX_ZOOM)
+ return;
zoom=zoom*(1.0/0.5);
_update_scroll(0);
viewport->update();
return;
} break;
case ZOOM_OUT: {
+ if (zoom<MIN_ZOOM)
+ return;
+
zoom=zoom*0.5;
_update_scroll(0);
viewport->update();