diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-01-06 15:48:36 -0500 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-01-06 15:49:44 -0500 |
| commit | 3cd61b8ff9baa5ee76070ffa19580f6f2729a78a (patch) | |
| tree | e24f32e13f32cfb327ad832d1d1790faaa69ff2c /embroider_simulate.py | |
| parent | ece8f15edaa6efcc617cc91508ac3ba6227a6254 (diff) | |
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.
Diffstat (limited to 'embroider_simulate.py')
| -rw-r--r-- | embroider_simulate.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/embroider_simulate.py b/embroider_simulate.py index 6ec35bd1..f10f39f0 100644 --- a/embroider_simulate.py +++ b/embroider_simulate.py @@ -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() |
