From 6a7cfd0d657a23baa09289c89a0612a1c3324a5f Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sun, 3 Mar 2024 17:48:11 +0100 Subject: [PATCH] Implement canvas zoom --- canvas.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/canvas.py b/canvas.py index ccf62f3..53ea01d 100644 --- a/canvas.py +++ b/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("",self.handle_draw) self.bind("",self.handle_move_start) self.bind("",self.handle_move) + if platform.system()=="Windows" or platform.system()=="Darwin": + self.bind("",lambda event: self.handle_zoom(event.delta)) + else: + # This will probably work only on X11 + self.bind("",lambda _: self.handle_zoom(1)) + self.bind("",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):