aboutsummaryrefslogtreecommitdiff
path: root/utility
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-09-22 21:04:00 +0200
committerAdrian Kummerlaender2019-09-22 21:04:00 +0200
commit10393d2c27ea60e3fa8e7b76ecf9abe06832b726 (patch)
treefe5c4a79cb91b6376cfad33d3f986389cb461e65 /utility
parentab930a71ca076480f78a6a5f42ac2ff5cef24d08 (diff)
downloadsymlbm_playground-10393d2c27ea60e3fa8e7b76ecf9abe06832b726.tar
symlbm_playground-10393d2c27ea60e3fa8e7b76ecf9abe06832b726.tar.gz
symlbm_playground-10393d2c27ea60e3fa8e7b76ecf9abe06832b726.tar.bz2
symlbm_playground-10393d2c27ea60e3fa8e7b76ecf9abe06832b726.tar.lz
symlbm_playground-10393d2c27ea60e3fa8e7b76ecf9abe06832b726.tar.xz
symlbm_playground-10393d2c27ea60e3fa8e7b76ecf9abe06832b726.tar.zst
symlbm_playground-10393d2c27ea60e3fa8e7b76ecf9abe06832b726.zip
Extract projection, add zoom support
Diffstat (limited to 'utility')
-rw-r--r--utility/mouse.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/utility/mouse.py b/utility/mouse.py
index c36d7e8..29d660d 100644
--- a/utility/mouse.py
+++ b/utility/mouse.py
@@ -1,10 +1,11 @@
from OpenGL.GLUT import *
class MouseDragMonitor:
- def __init__(self, button, callback):
+ def __init__(self, button, drag_callback, zoom_callback):
self.button = button
- self.callback = callback
self.active = False
+ self.drag_callback = drag_callback
+ self.zoom_callback = zoom_callback
def on_mouse(self, button, state, x, y):
if button == self.button:
@@ -12,10 +13,15 @@ class MouseDragMonitor:
self.last_x = x
self.last_y = y
+ if button == 3:
+ self.zoom_callback(-1.0)
+ elif button == 4:
+ self.zoom_callback(1.0)
+
def on_mouse_move(self, x, y):
if self.active:
delta_x = self.last_x - x
delta_y = y - self.last_y
self.last_x = x
self.last_y = y
- self.callback(delta_x, delta_y)
+ self.drag_callback(delta_x, delta_y)