summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-05-16 04:54:14 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2015-05-16 04:54:14 +0300
commitf0ab75e3016f10dce01f6543ae99955a8492e9a8 (patch)
tree91ed63f30287674a387d33fecce2797c31683378
parent661193de60e542a80e88019d59342f345f10a1ae (diff)
Add zoom on CTRL + Mouse Wheel
-rw-r--r--lekha/app.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/lekha/app.py b/lekha/app.py
index 519b63e..c130612 100644
--- a/lekha/app.py
+++ b/lekha/app.py
@@ -127,18 +127,36 @@ class AppWindow(StandardWindow):
127 main_box.show() 127 main_box.show()
128 128
129 def _event_handler(self, obj, src, tp, ev): 129 def _event_handler(self, obj, src, tp, ev):
130 if tp == EVAS_CALLBACK_KEY_UP: 130 if tp == EVAS_CALLBACK_MOUSE_WHEEL:
131 if ev.direction == 0:
132 if (
133 self.tabs.currentContent and
134 self.tabs.currentContent.scroll_freeze_get()):
135 if ev.z == 1:
136 self.tabs.currentContent.zoom_out()
137 else:
138 self.tabs.currentContent.zoom_in()
139 elif tp == EVAS_CALLBACK_KEY_UP:
131 key = ev.key 140 key = ev.key
132 if key == "plus": 141 if key == "plus":
133 self.tabs.currentContent.zoom_in() 142 if self.tabs.currentContent:
143 self.tabs.currentContent.zoom_in()
134 elif key == "minus": 144 elif key == "minus":
135 self.tabs.currentContent.zoom_out() 145 if self.tabs.currentContent:
146 self.tabs.currentContent.zoom_out()
136 elif key == "Escape": 147 elif key == "Escape":
137 if self.fullscreen: 148 if self.fullscreen:
138 self.fullscreen = False 149 self.fullscreen = False
139 elif key == "F11": 150 elif key == "F11":
140 self.fullscreen = not self.fullscreen 151 self.fullscreen = not self.fullscreen
141 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD 152 elif key == "Control_L" or key == "Control_R":
153 self.tabs.currentContent.scroll_thaw()
154 elif tp == EVAS_CALLBACK_KEY_DOWN:
155 key = ev.key
156 if key == "Control_L" or key == "Control_R":
157 self.tabs.currentContent.scroll_freeze()
158
159 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD
142 160
143 @staticmethod 161 @staticmethod
144 def _fullscreen_cb(win): 162 def _fullscreen_cb(win):
@@ -545,6 +563,15 @@ class Document(Table):
545 def _scrolled(self, scr): 563 def _scrolled(self, scr):
546 self.doc_pos = scr.region 564 self.doc_pos = scr.region
547 565
566 def scroll_freeze(self):
567 self.scr.scroll_freeze_push()
568
569 def scroll_thaw(self):
570 self.scr.scroll_freeze_pop()
571
572 def scroll_freeze_get(self):
573 return self.scr.scroll_freeze
574
548 575
549class PageSmart(Smart): 576class PageSmart(Smart):
550 577