summaryrefslogtreecommitdiff
path: root/lib/gui
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-12-29 11:38:59 +0100
committerGitHub <noreply@github.com>2024-12-29 11:38:59 +0100
commit9ff48f27198e65794610b820d6691531b931bb52 (patch)
tree987678ea8aee7949e203f67c45beb9633139c4bb /lib/gui
parentf76db86222b00892f1b6d389954dfb308ae3da1f (diff)
lettering: color sort options (#3381)
Diffstat (limited to 'lib/gui')
-rw-r--r--lib/gui/lettering/main_panel.py23
-rw-r--r--lib/gui/lettering/option_panel.py18
2 files changed, 26 insertions, 15 deletions
diff --git a/lib/gui/lettering/main_panel.py b/lib/gui/lettering/main_panel.py
index 3d0f65ba..f47e6db5 100644
--- a/lib/gui/lettering/main_panel.py
+++ b/lib/gui/lettering/main_panel.py
@@ -82,7 +82,7 @@ class LetteringPanel(wx.Panel):
"scale": 100,
"trim_option": 0,
"use_trim_symbols": False,
- "color_sort": False
+ "color_sort": 0
})
if INKSTITCH_LETTERING in self.group.attrib:
@@ -99,7 +99,7 @@ class LetteringPanel(wx.Panel):
def apply_settings(self):
"""Make the settings in self.settings visible in the UI."""
- self.options_panel.color_sort_checkbox.SetValue(bool(self.settings.color_sort))
+ self.options_panel.color_sort_choice.SetSelection(self.settings.color_sort)
self.options_panel.back_and_forth_checkbox.SetValue(bool(self.settings.back_and_forth))
self.options_panel.trim_option_choice.SetSelection(self.settings.trim_option)
self.options_panel.use_trim_symbols.SetValue(bool(self.settings.use_trim_symbols))
@@ -192,11 +192,18 @@ class LetteringPanel(wx.Panel):
self.settings[attribute] = event.GetEventObject().GetValue()
if attribute == "text" and self.options_panel.font_glyph_filter.GetValue() is True:
self.on_filter_changed()
- self.preview_renderer.update()
+ self.update_preview()
+
+ def on_color_sort_change(self, event=None):
+ if self.options_panel.color_sort_choice.IsEnabled():
+ self.settings.color_sort = self.options_panel.color_sort_choice.GetCurrentSelection()
+ else:
+ self.settings.color_sort = 0
+ self.update_preview()
def on_trim_option_change(self, event=None):
self.settings.trim_option = self.options_panel.trim_option_choice.GetCurrentSelection()
- self.preview_renderer.update()
+ self.update_preview()
def on_font_changed(self, event=None):
font = self.fonts.get(self.options_panel.font_chooser.GetValue(), self.default_font)
@@ -236,12 +243,10 @@ class LetteringPanel(wx.Panel):
self.options_panel.back_and_forth_checkbox.SetValue(False)
if font.sortable:
- # The creator of the font allowed color sorting: "sortable": false
- self.options_panel.color_sort_checkbox.Enable()
- self.options_panel.color_sort_checkbox.SetValue(bool(self.settings.color_sort))
+ # The creator of the font allowed color sorting: "sortable": true
+ self.options_panel.color_sort_choice.Enable()
else:
- self.options_panel.color_sort_checkbox.Disable()
- self.options_panel.color_sort_checkbox.SetValue(False)
+ self.options_panel.color_sort_choice.Disable()
self.options_panel.Layout()
self.update_preview()
diff --git a/lib/gui/lettering/option_panel.py b/lib/gui/lettering/option_panel.py
index d972b4a3..542408d6 100644
--- a/lib/gui/lettering/option_panel.py
+++ b/lib/gui/lettering/option_panel.py
@@ -83,9 +83,11 @@ class LetteringOptionsPanel(wx.Panel):
self.back_and_forth_checkbox = wx.CheckBox(self, label=_("Stitch lines of text back and forth"))
self.back_and_forth_checkbox.Bind(wx.EVT_CHECKBOX, lambda event: self.panel.on_change("back_and_forth", event))
- self.color_sort_checkbox = wx.CheckBox(self, label=_("Color sort"))
- self.color_sort_checkbox.Bind(wx.EVT_CHECKBOX, lambda event: self.panel.on_change("color_sort", event))
- self.color_sort_checkbox.SetToolTip(_("Sort multicolor fonts. Unifies tartan patterns."))
+ color_sort_label = wx.StaticText(self, wx.ID_ANY, _("Color sort"))
+ color_sort_label.SetToolTip(_("Sort multicolor fonts. Unifies tartan patterns."))
+ self.color_sort_choice = wx.Choice(self, choices=[_("Off"), _("Whole text"), _("Line"), _("Word")], name=_("Color sort"))
+ self.color_sort_choice.SetToolTip(_("Sort multicolor fonts. Unifies tartan patterns."))
+ self.color_sort_choice.Bind(wx.EVT_CHOICE, self.panel.on_color_sort_change)
self.trim_option_choice = wx.Choice(self, choices=[_("Never"), _("after each line"), _("after each word"), _("after each letter")],
name=_("Add trim command"))
@@ -104,13 +106,17 @@ class LetteringOptionsPanel(wx.Panel):
left_option_sizer.Add(font_scale_sizer, 0, wx.ALIGN_LEFT, 5)
left_option_sizer.Add(self.back_and_forth_checkbox, 1, wx.LEFT | wx.TOP | wx.RIGHT, 5)
- left_option_sizer.Add(self.color_sort_checkbox, 1, wx.LEFT | wx.TOP | wx.RIGHT, 5)
+
+ color_sort_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ color_sort_sizer.Add(color_sort_label, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
+ color_sort_sizer.Add(self.color_sort_choice, 1, wx.ALL, 5)
+ left_option_sizer.Add(color_sort_sizer, 0, wx.ALIGN_LEFT, 5)
right_option_sizer = wx.BoxSizer(wx.VERTICAL)
right_option_sizer.Add(wx.StaticText(self, wx.ID_ANY, _("Add trims")), 0, wx.LEFT | wx.ALIGN_TOP, 5)
- right_option_sizer.Add(self.trim_option_choice, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
- right_option_sizer.Add(self.use_trim_symbols, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
+ right_option_sizer.Add(self.trim_option_choice, 1, wx.EXPAND | wx.ALL, 5)
+ right_option_sizer.Add(self.use_trim_symbols, 1, wx.EXPAND | wx.ALL, 5)
self.options_box = wx.StaticBox(self, wx.ID_ANY, label=_("Options"))
options_sizer = wx.StaticBoxSizer(self.options_box, wx.HORIZONTAL)