automatically scale simulation window

The simulation window is scaled to fill the available space on the screen.  In
the Params dialog, the simulation window sits to the right of the Params window
and fills the remaining space.
pull/12/merge
Lex Neva 2018-01-06 15:48:36 -05:00
rodzic ece8f15eda
commit 3cd61b8ff9
2 zmienionych plików z 25 dodań i 5 usunięć

Wyświetl plik

@ -400,8 +400,19 @@ class SettingsFrame(wx.Frame):
simulator_pos = my_rect.GetTopRight()
simulator_pos.x += 5
screen_rect = wx.Display(0).ClientArea
max_width = screen_rect.GetWidth() - my_rect.GetWidth()
max_height = screen_rect.GetHeight()
try:
self.simulate_window = EmbroiderySimulator(None, -1, "Embroidery Simulator", simulator_pos, size=(300, 300), patches=patches, on_close=self.simulate_window_closed, target_duration=5)
self.simulate_window = EmbroiderySimulator(None, -1, "Embroidery Simulator",
simulator_pos,
size=(300, 300),
patches=patches,
on_close=self.simulate_window_closed,
target_duration=5,
max_width=max_width,
max_height=max_height)
except:
error = traceback.format_exc()

Wyświetl plik

@ -16,7 +16,11 @@ class EmbroiderySimulator(wx.Frame):
self.frame_period = kwargs.pop('frame_period', 80)
self.stitches_per_frame = kwargs.pop('stitches_per_frame', 1)
self.target_duration = kwargs.pop('target_duration', None)
self.scale = 3
screen_rect = wx.Display(0).ClientArea
self.max_width = kwargs.pop('max_width', screen_rect.GetWidth())
self.max_height = kwargs.pop('max_height', screen_rect.GetHeight())
self.scale = 1
wx.Frame.__init__(self, *args, **kwargs)
@ -56,7 +60,7 @@ class EmbroiderySimulator(wx.Frame):
return
self.trim_margins()
self.width, self.height = self.get_dimensions()
self.calculate_dimensions()
def adjust_speed(self, duration):
self.frame_period = 1000 * float(duration) / len(self.segments)
@ -218,7 +222,7 @@ class EmbroiderySimulator(wx.Frame):
self.segments = new_segments
def get_dimensions(self):
def calculate_dimensions(self):
width = 0
height = 0
@ -226,7 +230,12 @@ class EmbroiderySimulator(wx.Frame):
width = max(width, x)
height = max(height, y)
return width, height
self.width = width
self.height = height
self.scale = min(float(self.max_width) / width, float(self.max_height) / height)
# make room for decorations and a bit of a margin
self.scale *= 0.95
def go(self):
self.clear()