From 913c2700d1486284dba0583ae1b280b1aa237570 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 29 Jan 2025 12:04:07 -0500 Subject: Sew Stack first steps (#3133) * handle more recursive cases * scaffolding for stitch layers * scaffolding for SewStack * always use DotDict when parsing json params * add DefaultDotDict + DotDict fixes * first working SewStack (no UI yet) * ignore inkstitch_debug.log and .svg * refactor * early WIP: property grid display temporarily in stitch plan preview * start of sew stack editor extension * add layer properties panel and splitter * spacing and better icon * handle checkbox * add layer action buttons * show selected property help text in an HtmlWindow * rename * rephrase help text for tolerance * refactor into separate file * simplify structure * better property type handling * add randomization button * add random seed re-roll button * simulator preview * update preview in a few more cases * always DotDict * avoid ridiculously slow simulations * preview selected layer or all layers * edit multiple objects and save only modified properties into the SVG * better preview handling * add reverse and jitter * add stitch path jitter * fix types * fix random shuffle button * fixes * fix repeats * type hinting to please pycharm * show layer description * avoid exception in properties with multiple values * fix typing * fix new layer * draw a box around property grid and help box * confirm before closing * rename properties and fix seed * fix close/cancel logic * add buttons to undo changes and reset to default value * set not modified if default is original setting * fix invisible icon * more space for properties * fix random properties * better regulation of simulator rendering speed * Fixed timer being passed a float * fix get_json_param() default handling * fix tests * add checkbox for sew stack only * fix property help * adjustable stitch layer editor help box size, with persistence * repeat exact stitches * "fix" style * adjust for new next_element stuff --------- Co-authored-by: CapellanCitizen --- lib/gui/windows.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/gui/windows.py (limited to 'lib/gui/windows.py') diff --git a/lib/gui/windows.py b/lib/gui/windows.py new file mode 100644 index 00000000..42c34cc8 --- /dev/null +++ b/lib/gui/windows.py @@ -0,0 +1,41 @@ +import wx + + +class SimpleBox(wx.Panel): + """Draw a box around one window. + + Usage: + + window = SomeWindow(your_window_or_panel, wx.ID_ANY) + box = SimpleBox(your_window_or_panel, window) + some_sizer.Add(box, ...) + + """ + + def __init__(self, parent, window, *args, width=1, radius=2, **kwargs): + super().__init__(parent, wx.ID_ANY, *args, **kwargs) + + window.Reparent(self) + self.window = window + self.sizer = wx.BoxSizer(wx.VERTICAL) + self.sizer.Add(window, 1, wx.EXPAND | wx.ALL, 2) + self.SetSizer(self.sizer) + + self.width = width + self.radius = radius + + self.Bind(wx.EVT_ERASE_BACKGROUND, self.on_erase_background) + + def on_erase_background(self, event): + dc = event.GetDC() + if not dc: + dc = wx.ClientDC(self) + size = self.GetClientSize() + + if wx.SystemSettings().GetAppearance().IsDark(): + dc.SetPen(wx.Pen(wx.Colour(32, 32, 32), width=self.width)) + else: + dc.SetPen(wx.Pen(wx.Colour(128, 128, 128), width=self.width)) + + dc.SetBrush(wx.NullBrush) + dc.DrawRoundedRectangle(0, 0, size.x, size.y, self.radius) -- cgit v1.2.3