From 7241bbde08f3b1bb81de1de61fa77e26c89c69cc Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sat, 8 Jun 2024 13:56:08 +0200 Subject: update pan_and_zoom on simulator resize (#2974) --- lib/gui/simulator.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/gui/simulator.py') diff --git a/lib/gui/simulator.py b/lib/gui/simulator.py index ee418841..006d0e57 100644 --- a/lib/gui/simulator.py +++ b/lib/gui/simulator.py @@ -508,13 +508,12 @@ class DrawingPanel(wx.Panel): self.Bind(wx.EVT_MOUSEWHEEL, self.on_mouse_wheel) self.Bind(wx.EVT_SIZE, self.on_resize) - self.SetMinSize((400, 400)) - # wait for layouts so that panel size is set if self.stitch_plan: wx.CallLater(50, self.load, self.stitch_plan) def on_resize(self, event): + self.choose_zoom_and_pan() self.Refresh() def clamp_current_stitch(self): @@ -686,7 +685,7 @@ class DrawingPanel(wx.Panel): # add some padding to make stitches at the edge more visible width_ratio = panel_width / float(self.width + 10) height_ratio = panel_height / float(self.height + 10) - self.zoom = min(width_ratio, height_ratio) + self.zoom = max(min(width_ratio, height_ratio), 0.01) # center the design self.pan = ((panel_width - self.zoom * self.width) / 2.0, @@ -1171,6 +1170,8 @@ class SplitSimulatorWindow(wx.Frame): self.SetWindowStyle(wx.FRAME_FLOAT_ON_PARENT | wx.DEFAULT_FRAME_STYLE) + self.statusbar = self.CreateStatusBar(2) + self.detached_simulator_frame = None self.splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) background_color = kwargs.pop('background_color', 'white') @@ -1189,8 +1190,6 @@ class SplitSimulatorWindow(wx.Frame): icon = wx.Icon(os.path.join(get_resource_dir("icons"), "inkstitch256x256.png")) self.SetIcon(icon) - self.statusbar = self.CreateStatusBar(2) - self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.splitter, 1, wx.EXPAND) self.SetSizer(self.sizer) -- cgit v1.2.3