Implement canvas zoom
This commit is contained in:
parent
dfde12daa6
commit
6a7cfd0d65
14
canvas.py
14
canvas.py
@ -1,4 +1,5 @@
|
||||
import base64
|
||||
import platform
|
||||
import tkinter
|
||||
|
||||
GRID_COLOR = "#808080"
|
||||
@ -22,6 +23,12 @@ class EditorCanvas(tkinter.Canvas):
|
||||
self.bind("<Button-1>",self.handle_draw)
|
||||
self.bind("<Button-3>",self.handle_move_start)
|
||||
self.bind("<B3-Motion>",self.handle_move)
|
||||
if platform.system()=="Windows" or platform.system()=="Darwin":
|
||||
self.bind("<MouseWheel>",lambda event: self.handle_zoom(event.delta))
|
||||
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):
|
||||
@ -68,6 +75,13 @@ class EditorCanvas(tkinter.Canvas):
|
||||
self.draw()
|
||||
|
||||
|
||||
def handle_zoom(self,delta):
|
||||
self.grid_size+=delta
|
||||
self.width=self.project.char_res[0]*self.grid_size
|
||||
self.height=self.project.char_res[1]*self.grid_size
|
||||
self.draw()
|
||||
|
||||
|
||||
def load_char(self):
|
||||
self.current_char_modified=False
|
||||
if not self.project.does_char_exist(self.current_char):
|
||||
|
Loading…
Reference in New Issue
Block a user