handle window size and target duration

pull/284/head
Lex Neva 2018-08-26 15:02:51 -04:00
rodzic 79e8ad5b31
commit a355af2874
4 zmienionych plików z 58 dodań i 45 usunięć

Wyświetl plik

@ -440,19 +440,16 @@ class SettingsFrame(wx.Frame):
display = wx.Display(current_screen)
screen_rect = display.GetClientArea()
max_width = screen_rect.GetWidth() - params_rect.GetWidth()
max_height = screen_rect.GetHeight()
width = screen_rect.GetWidth() - params_rect.GetWidth()
height = screen_rect.GetHeight()
try:
self.simulate_window = EmbroiderySimulator(None, -1, _("Preview"),
simulator_pos,
size=(300, 300),
x_position=simulator_pos.x,
size=(width, height),
stitch_plan=stitch_plan,
on_close=self.simulate_window_closed,
target_duration=5,
max_width=max_width,
max_height=max_height)
target_duration=5)
except:
error = traceback.format_exc()

Wyświetl plik

@ -25,8 +25,10 @@ class Simulate(InkstitchExtension):
screen_rect = display.GetClientArea()
simulator_pos = (screen_rect[0], screen_rect[1])
width = screen_rect[2]
height = screen_rect[3]
frame = EmbroiderySimulator(None, -1, _("Embroidery Simulation"), pos=simulator_pos, size=(1000, 1000), stitch_plan=stitch_plan)
frame = EmbroiderySimulator(None, -1, _("Embroidery Simulation"), pos=simulator_pos, size=(width, height), stitch_plan=stitch_plan)
app.SetTopWindow(frame)
frame.Show()
wx.CallAfter(frame.go)

Wyświetl plik

@ -14,6 +14,8 @@ class ControlPanel(wx.Panel):
self.parent = parent
self.drawing_panel = kwargs.pop('drawing_panel')
self.stitch_plan = kwargs.pop('stitch_plan')
stitches_per_second = kwargs.pop('stitches_per_second')
target_duration = kwargs.pop('target_duration')
kwargs['style'] = wx.BORDER_SUNKEN
wx.Panel.__init__(self, parent, *args, **kwargs)
@ -93,10 +95,17 @@ class ControlPanel(wx.Panel):
self.SetAcceleratorTable(accel_table)
self.current_stitch = 1
self.set_speed(16)
self.choose_speed(stitches_per_second, target_duration)
self.SetFocus()
def choose_speed(self, stitches_per_second, target_duration):
if target_duration:
self.set_speed(int(self.num_stitches / float(target_duration)))
else:
self.set_speed(stitches_per_second)
def animation_forward(self, event=None):
self.direction.SetLabel(">>")
self.drawing_panel.forward()
@ -370,11 +379,17 @@ class SimulatorPanel(wx.Panel):
""""""
self.parent = parent
stitch_plan = kwargs.pop('stitch_plan')
target_duration = kwargs.pop('target_duration')
stitches_per_second = kwargs.pop('stitches_per_second')
kwargs['style'] = wx.BORDER_SUNKEN
wx.Panel.__init__(self, parent, *args, **kwargs)
self.dp = DrawingPanel(self, stitch_plan=stitch_plan)
self.cp = ControlPanel(self, stitch_plan=stitch_plan, drawing_panel=self.dp)
self.cp = ControlPanel(self,
stitch_plan=stitch_plan,
drawing_panel=self.dp,
stitches_per_second=stitches_per_second,
target_duration=target_duration)
self.dp.set_control_panel(self.cp)
vbSizer = wx.BoxSizer(wx.VERTICAL)
@ -393,20 +408,19 @@ class SimulatorPanel(wx.Panel):
class EmbroiderySimulator(wx.Frame):
def __init__(self, *args, **kwargs):
stitch_plan = kwargs.pop('stitch_plan', None)
self.x_position = kwargs.pop('x_position', None)
self.on_close_hook = kwargs.pop('on_close', None)
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.max_height = kwargs.pop('max_height', None)
self.max_width = kwargs.pop('max_width', None)
stitch_plan = kwargs.pop('stitch_plan', None)
stitches_per_second = kwargs.pop('stitches_per_second', 16)
target_duration = kwargs.pop('target_duration', None)
wx.Frame.__init__(self, *args, **kwargs)
# self.status_bar = self.CreateStatusBar()
# self.status_bar.SetStatusText(text)
self.simulator_panel = SimulatorPanel(self, stitch_plan=stitch_plan)
self.simulator_panel = SimulatorPanel(self,
stitch_plan=stitch_plan,
target_duration=target_duration,
stitches_per_second=stitches_per_second)
self.Bind(wx.EVT_CLOSE, self.on_close)
def quit(self):

Wyświetl plik

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2018-08-26 14:43-0400\n"
"POT-Creation-Date: 2018-08-26 15:02-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -612,25 +612,25 @@ msgstr ""
msgid "Preview"
msgstr ""
#: lib/extensions/params.py:466
#: lib/extensions/params.py:463
msgid "Internal Error"
msgstr ""
#: lib/extensions/params.py:519
#: lib/extensions/params.py:516
msgid "Please enter or select a preset name first."
msgstr ""
#: lib/extensions/params.py:519 lib/extensions/params.py:525
#: lib/extensions/params.py:553
#: lib/extensions/params.py:516 lib/extensions/params.py:522
#: lib/extensions/params.py:550
msgid "Preset"
msgstr ""
#: lib/extensions/params.py:525
#: lib/extensions/params.py:522
#, python-format
msgid "Preset \"%s\" not found."
msgstr ""
#: lib/extensions/params.py:553
#: lib/extensions/params.py:550
#, python-format
msgid ""
"Preset \"%s\" already exists. Please use another name or press "
@ -659,7 +659,7 @@ msgstr ""
msgid "Ink/Stitch Print"
msgstr ""
#: lib/extensions/simulate.py:29
#: lib/extensions/simulate.py:31
msgid "Embroidery Simulation"
msgstr ""
@ -674,79 +674,79 @@ msgstr ""
msgid "Generate INX files"
msgstr ""
#: lib/simulator.py:463
#: lib/simulator.py:477
msgid "<<"
msgstr ""
#: lib/simulator.py:463
#: lib/simulator.py:477
msgid "Play reverse (arrow left)"
msgstr ""
#: lib/simulator.py:464
#: lib/simulator.py:478
msgid "-"
msgstr ""
#: lib/simulator.py:464
#: lib/simulator.py:478
msgid "Play one frame backward (+)"
msgstr ""
#: lib/simulator.py:465
#: lib/simulator.py:479
msgid "+"
msgstr ""
#: lib/simulator.py:465
#: lib/simulator.py:479
msgid "Play one frame forward (+)"
msgstr ""
#: lib/simulator.py:466
#: lib/simulator.py:480
msgid ">>"
msgstr ""
#: lib/simulator.py:466
#: lib/simulator.py:480
msgid "Play forward (arrow right)"
msgstr ""
#: lib/simulator.py:467
#: lib/simulator.py:481
msgid "^"
msgstr ""
#: lib/simulator.py:467
#: lib/simulator.py:481
msgid "Speed up (arrow up)"
msgstr ""
#: lib/simulator.py:468
#: lib/simulator.py:482
msgid "v"
msgstr ""
#: lib/simulator.py:468
#: lib/simulator.py:482
msgid "Slow down (arrow down)"
msgstr ""
#: lib/simulator.py:469
#: lib/simulator.py:483
msgid "Pause"
msgstr ""
#: lib/simulator.py:469
#: lib/simulator.py:483
msgid "Pause (P)"
msgstr ""
#: lib/simulator.py:470
#: lib/simulator.py:484
msgid "Restart"
msgstr ""
#: lib/simulator.py:470
#: lib/simulator.py:484
msgid "Restart (R)"
msgstr ""
#: lib/simulator.py:471
#: lib/simulator.py:485
msgid "Quit"
msgstr ""
#: lib/simulator.py:471
#: lib/simulator.py:485
msgid "Close (Q)"
msgstr ""
#: lib/simulator.py:649
#: lib/simulator.py:663
msgid "Stitch # "
msgstr ""