summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/editor/view2d.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/editor/view2d.cpp b/src/editor/view2d.cpp
index 1445cfc..faff736 100644
--- a/src/editor/view2d.cpp
+++ b/src/editor/view2d.cpp
@@ -727,12 +727,26 @@ void gui_editor_2dview_input_scroll( GUI_EDITOR_2DVIEW* view ) {
U8 scroll = gui_mbutton_down( GUI_MBTNSCROLL );
gui_capture_scroll();
+ F32 zoom_factor = 1.f;
if( scroll == (U8)-1 && view->scale > 0.5f ) {
- view->scale *= 0.75f;
+ zoom_factor = 0.75f;
}
else if( scroll == 1 && view->scale < 16.f ) {
- view->scale *= 1.25f;
+ zoom_factor = 1.25f;
}
+
+ if( zoom_factor == 1.f )
+ return;
+
+ I32 mx, my;
+ gui_cursor_pos( &mx, &my );
+ VEC2 world_before = gui_editor_2dview_screen_to_world( view, mx, my );
+
+ view->scale *= zoom_factor;
+
+ VEC2 world_after = gui_editor_2dview_screen_to_world( view, mx, my );
+ view->posx += world_before.x - world_after.x;
+ view->posy += world_before.y - world_after.y;
}
void gui_editor_2dview_input_tool_wall( GUI_EDITOR_2DVIEW* view ) {