summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2025-03-29 05:23:49 +0000
committerGitHub <noreply@github.com>2025-03-29 06:23:49 +0100
commitdd63ef093562b8ece48ff215c038e42120a9817e (patch)
tree2d8e018b569f7cd26c93c36bc1a7eb7a272076c9
parentfdd308fde104cc019d64d5b1a02f0ab88d926e0a (diff)
simulator: add button to toggle crosshair (#3616)
-rw-r--r--icons/cursor.pngbin0 -> 1529 bytes
-rw-r--r--icons/cursor.svg64
-rw-r--r--icons/cursor_dark.pngbin0 -> 1480 bytes
-rw-r--r--lib/gui/simulator/drawing_panel.py2
-rw-r--r--lib/gui/simulator/view_panel.py12
-rw-r--r--lib/utils/settings.py1
6 files changed, 78 insertions, 1 deletions
diff --git a/icons/cursor.png b/icons/cursor.png
new file mode 100644
index 00000000..e0c5f879
--- /dev/null
+++ b/icons/cursor.png
Binary files differ
diff --git a/icons/cursor.svg b/icons/cursor.svg
new file mode 100644
index 00000000..b5118a75
--- /dev/null
+++ b/icons/cursor.svg
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ width="256"
+ height="256"
+ viewBox="0 0 256 256"
+ id="svg8375"
+ version="1.1"
+ inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
+ sodipodi:docname="cursor.svg"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <defs
+ id="defs8377" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.1965384"
+ inkscape:cx="154.56138"
+ inkscape:cy="137.94432"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="mm"
+ inkscape:window-width="1920"
+ inkscape:window-height="1131"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:showpageshadow="2"
+ inkscape:pagecheckerboard="0"
+ inkscape:deskcolor="#d1d1d1" />
+ <metadata
+ id="metadata8380">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ d="M 210.6054,116.73562 Q 216.02899,116.73562 216.02899,122.1592 V 137.17837 Q 216.02899,142.60196 210.6054,142.60196 H 143.01916 Q 140.93317,142.60196 140.93317,144.68795 V 210.60539 Q 140.93317,216.02898 135.50958,216.02898 H 120.49042 Q 115.06683,216.02898 115.06683,210.60539 V 144.68795 Q 115.06683,142.60196 112.98084,142.60196 H 45.394597 Q 39.97101,142.60196 39.97101,137.17837 V 122.1592 Q 39.97101,116.73562 45.394597,116.73562 H 112.98084 Q 115.06683,116.73562 115.06683,114.64962 V 45.394588 Q 115.06683,39.971 120.49042,39.971 H 135.50958 Q 140.93317,39.971 140.93317,45.394588 V 114.64962 Q 140.93317,116.73562 143.01916,116.73562 Z"
+ id="text1"
+ style="font-size:417.199px;font-family:Barlow;-inkscape-font-specification:Barlow;text-align:center;letter-spacing:2.03385px;word-spacing:0px;text-anchor:middle;stroke-width:2.13543;stroke-linejoin:round"
+ aria-label="+" />
+ </g>
+</svg>
diff --git a/icons/cursor_dark.png b/icons/cursor_dark.png
new file mode 100644
index 00000000..010e65f6
--- /dev/null
+++ b/icons/cursor_dark.png
Binary files differ
diff --git a/lib/gui/simulator/drawing_panel.py b/lib/gui/simulator/drawing_panel.py
index 6954f17d..1ffdfaa4 100644
--- a/lib/gui/simulator/drawing_panel.py
+++ b/lib/gui/simulator/drawing_panel.py
@@ -200,7 +200,7 @@ class DrawingPanel(wx.Panel):
last_stitch = stitches[-1]
break
- if last_stitch:
+ if last_stitch and self.view_panel.btnCursor.GetValue():
self.draw_crosshair(last_stitch[0], last_stitch[1], canvas, transform)
canvas.EndLayer()
diff --git a/lib/gui/simulator/view_panel.py b/lib/gui/simulator/view_panel.py
index c18c75b2..b73d6a4c 100644
--- a/lib/gui/simulator/view_panel.py
+++ b/lib/gui/simulator/view_panel.py
@@ -33,6 +33,7 @@ class ViewPanel(ScrolledPanel):
self.stop_button_status = global_settings['stop_button_status']
self.color_change_button_status = global_settings['color_change_button_status']
self.toggle_page_button_status = global_settings['toggle_page_button_status']
+ self.display_crosshair_status = global_settings['display_crosshair']
self.btnNpp = wx.BitmapToggleButton(self, -1, style=self.button_style)
self.btnNpp.SetBitmap(self.control_panel.load_icon('npp'))
@@ -77,6 +78,12 @@ class ViewPanel(ScrolledPanel):
self.btnBackgroundColor.SetToolTip(_("Change background color"))
self.btnBackgroundColor.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_update_background_color)
+ self.btnCursor = wx.BitmapToggleButton(self, -1, style=self.button_style)
+ self.btnCursor.SetToolTip(_('Show crosshair'))
+ self.btnCursor.SetBitmap(self.control_panel.load_icon('cursor'))
+ self.btnCursor.SetValue(self.display_crosshair_status)
+ self.btnCursor.Bind(wx.EVT_TOGGLEBUTTON, self.on_cursor_button)
+
if not self.detach_callback:
self.btnPage = wx.BitmapToggleButton(self, -1, style=self.button_style)
self.btnPage.Bind(wx.EVT_TOGGLEBUTTON, self.toggle_page)
@@ -122,6 +129,7 @@ class ViewPanel(ScrolledPanel):
settings_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Settings")), wx.VERTICAL)
settings_inner_sizer = wx.BoxSizer(wx.VERTICAL)
settings_inner_sizer.Add(self.btnBackgroundColor, 0, wx.EXPAND | wx.ALL, 2)
+ settings_inner_sizer.Add(self.btnCursor, 0, wx.EXPAND | wx.ALL, 2)
if not self.detach_callback:
settings_inner_sizer.Add(self.btnPage, 0, wx.EXPAND | wx.ALL, 2)
settings_inner_sizer.Add(self.btnSettings, 0, wx.EXPAND | wx.ALL, 2)
@@ -152,6 +160,10 @@ class ViewPanel(ScrolledPanel):
self.drawing_panel.Refresh()
global_settings['npp_button_status'] = self.btnNpp.GetValue()
+ def on_cursor_button(self, event):
+ self.drawing_panel.Refresh()
+ global_settings['display_crosshair'] = self.btnCursor.GetValue()
+
def toggle_page(self, event):
debug.log("toggle page")
value = self.btnPage.GetValue()
diff --git a/lib/utils/settings.py b/lib/utils/settings.py
index cb330a23..42e6b233 100644
--- a/lib/utils/settings.py
+++ b/lib/utils/settings.py
@@ -26,6 +26,7 @@ DEFAULT_SETTINGS = {
"stop_button_status": False,
"color_change_button_status": False,
"toggle_page_button_status": True,
+ "display_crosshair": True,
# apply palette
"last_applied_palette": "",
# sew stack editor