Move zooming to View menu in menubar and use mouse scroll for changing glyphs

This commit is contained in:
2024-03-08 18:38:17 +01:00
parent 8413f98f4c
commit d2d28b0782
2 changed files with 29 additions and 9 deletions

View File

@@ -1,5 +1,4 @@
import base64
import platform
import tkinter
GRID_COLOR = "#808080"
@@ -25,12 +24,6 @@ class EditorCanvas(tkinter.Canvas):
self.bind("<B2-Motion>",self.handle_move)
self.bind("<Button-3>",self.handle_erase)
self.bind("<B3-Motion>",self.handle_erase)
if platform.system()=="Windows" or platform.system()=="Darwin":
self.bind("<MouseWheel>",lambda event: self.handle_zoom(event.delta//120))
else:
# This will probably work only on X11
self.bind("<Button-4>",lambda _: self.handle_zoom(1))
self.bind("<Button-5>",lambda _: self.handle_zoom(-1))
def draw(self):
@@ -88,8 +81,12 @@ class EditorCanvas(tkinter.Canvas):
self.draw()
def handle_zoom(self,delta):
self.grid_size+=delta
def zoom_by(self,amount):
self.grid_size+=amount
if self.grid_size<12:
self.grid_size=12
elif self.grid_size>102:
self.grid_size=102
self.width=self.project.char_res[0]*self.grid_size
self.height=self.project.char_res[1]*self.grid_size
self.draw()