summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-05-29 14:38:17 +0200
committerGitHub <noreply@github.com>2024-05-29 14:38:17 +0200
commit1f57763e797b933d0616495a32051ec74ec516bd (patch)
treebcf3db627572205c4589f5c41b6add349e8c807a
parent1f47f4762e48aba7dfe49e42e86de732ff366986 (diff)
add help tab to lettering (#2948)
-rw-r--r--lib/extensions/satin_multicolor.py2
-rw-r--r--lib/gui/__init__.py1
-rw-r--r--lib/gui/lettering/__init__.py8
-rw-r--r--lib/gui/lettering/help_panel.py51
-rw-r--r--lib/gui/lettering/main_panel.py (renamed from lib/gui/lettering.py)253
-rw-r--r--lib/gui/lettering/option_panel.py105
-rw-r--r--lib/gui/satin_multicolor/__init__.py8
-rw-r--r--lib/gui/satin_multicolor/colorize_panel.py (renamed from lib/gui/satin_multicolor/colorize.py)0
-rw-r--r--lib/gui/satin_multicolor/main_panel.py3
9 files changed, 253 insertions, 178 deletions
diff --git a/lib/extensions/satin_multicolor.py b/lib/extensions/satin_multicolor.py
index 5657bdbf..a6c1983e 100644
--- a/lib/extensions/satin_multicolor.py
+++ b/lib/extensions/satin_multicolor.py
@@ -10,7 +10,7 @@ import wx.adv
from inkex import errormsg
from ..elements import SatinColumn
-from ..gui import MultiColorSatinPanel
+from ..gui.satin_multicolor import MultiColorSatinPanel
from ..gui.simulator import SplitSimulatorWindow
from ..i18n import _
from ..utils.svg_data import get_pagecolor
diff --git a/lib/gui/__init__.py b/lib/gui/__init__.py
index 53fb7e65..09f5d3bb 100644
--- a/lib/gui/__init__.py
+++ b/lib/gui/__init__.py
@@ -7,4 +7,3 @@ from .dialogs import confirm_dialog, info_dialog
from .presets import PresetsPanel
from .simulator import PreviewRenderer
from .warnings import WarningPanel
-from .satin_multicolor.main_panel import MultiColorSatinPanel
diff --git a/lib/gui/lettering/__init__.py b/lib/gui/lettering/__init__.py
new file mode 100644
index 00000000..970ebca8
--- /dev/null
+++ b/lib/gui/lettering/__init__.py
@@ -0,0 +1,8 @@
+# Authors: see git history
+#
+# Copyright (c) 2024 Authors
+# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+
+from .help_panel import LetteringHelpPanel
+from .option_panel import LetteringOptionsPanel
+from .main_panel import LetteringPanel
diff --git a/lib/gui/lettering/help_panel.py b/lib/gui/lettering/help_panel.py
new file mode 100644
index 00000000..648da180
--- /dev/null
+++ b/lib/gui/lettering/help_panel.py
@@ -0,0 +1,51 @@
+# Authors: see git history
+#
+# Copyright (c) 2024 Authors
+# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+
+import wx
+
+from ...i18n import _
+
+
+class LetteringHelpPanel(wx.Panel):
+ def __init__(self, parent):
+ wx.Panel.__init__(self, parent)
+ help_sizer = wx.BoxSizer(wx.VERTICAL)
+
+ help_text = wx.StaticText(
+ self,
+ wx.ID_ANY,
+ _("Add text to your design."),
+ style=wx.ALIGN_LEFT
+ )
+ help_text.Wrap(500)
+ help_sizer.Add(help_text, 0, wx.ALL, 8)
+
+ website_link = wx.adv.HyperlinkCtrl(
+ self,
+ wx.ID_ANY,
+ _("https://inkstitch.org/docs/lettering/#lettering-tool"),
+ _("https://inkstitch.org/docs/lettering/#lettering-tool")
+ )
+ website_link.Bind(wx.adv.EVT_HYPERLINK, self.on_link_clicked)
+ help_sizer.Add(website_link, 0, wx.ALL, 8)
+
+ help_sizer.Add((20, 20), 0, 0, 0)
+
+ website_info = wx.StaticText(self, wx.ID_ANY, _("A font library with full description and embroidered examples can be found on our website:"))
+ help_sizer.Add(website_info, 0, wx.ALL, 8)
+
+ fontlibrary_link = wx.adv.HyperlinkCtrl(
+ self,
+ wx.ID_ANY,
+ _("https://inkstitch.org/fonts/font-library/"),
+ _("https://inkstitch.org/fonts/font-library/")
+ )
+ fontlibrary_link.Bind(wx.adv.EVT_HYPERLINK, self.on_link_clicked)
+ help_sizer.Add(fontlibrary_link, 0, wx.ALL, 8)
+
+ self.SetSizer(help_sizer)
+
+ def on_link_clicked(self, event):
+ event.Skip()
diff --git a/lib/gui/lettering.py b/lib/gui/lettering/main_panel.py
index bce39ff8..eb3d61a4 100644
--- a/lib/gui/lettering.py
+++ b/lib/gui/lettering/main_panel.py
@@ -9,17 +9,17 @@ from base64 import b64decode
import inkex
import wx
import wx.adv
-import wx.lib.agw.floatspin as fs
-from ..elements import nodes_to_elements
-from ..i18n import _
-from ..lettering import FontError, get_font_list
-from ..lettering.categories import FONT_CATEGORIES, FontCategory
-from ..stitch_plan import stitch_groups_to_stitch_plan
-from ..svg.tags import INKSCAPE_LABEL, INKSTITCH_LETTERING, SVG_PATH_TAG
-from ..utils import DotDict, cache
-from ..utils.threading import ExitThread, check_stop_flag
-from . import PresetsPanel, PreviewRenderer, info_dialog
+from ...elements import nodes_to_elements
+from ...i18n import _
+from ...lettering import FontError, get_font_list
+from ...lettering.categories import FONT_CATEGORIES
+from ...stitch_plan import stitch_groups_to_stitch_plan
+from ...svg.tags import INKSCAPE_LABEL, INKSTITCH_LETTERING, SVG_PATH_TAG
+from ...utils import DotDict, cache
+from ...utils.threading import ExitThread, check_stop_flag
+from .. import PresetsPanel, PreviewRenderer, info_dialog
+from . import LetteringHelpPanel, LetteringOptionsPanel
class LetteringPanel(wx.Panel):
@@ -36,76 +36,47 @@ class LetteringPanel(wx.Panel):
self.SetWindowStyle(wx.FRAME_FLOAT_ON_PARENT | wx.DEFAULT_FRAME_STYLE)
- self.preview_renderer = PreviewRenderer(self.render_stitch_plan, self.on_stitch_plan_rendered)
- self.presets_panel = PresetsPanel(self)
-
- # font
- self.font_selector_box = wx.StaticBox(self, wx.ID_ANY, label=_("Font"))
-
- self.font_chooser = wx.adv.BitmapComboBox(self, wx.ID_ANY, style=wx.CB_READONLY | wx.CB_SORT)
- self.font_chooser.Bind(wx.EVT_COMBOBOX, self.on_font_changed)
-
- self.font_size_filter = fs.FloatSpin(self, min_val=0, max_val=None, increment=1, value="0")
- self.font_size_filter.SetFormat("%f")
- self.font_size_filter.SetDigits(2)
- self.font_size_filter.Bind(fs.EVT_FLOATSPIN, self.on_filter_changed)
- self.font_size_filter.SetToolTip(_("Font size filter (mm). 0 for all sizes."))
-
- self.font_glyph_filter = wx.CheckBox(self, label=_("Glyphs"))
- self.font_glyph_filter.Bind(wx.EVT_CHECKBOX, self.on_filter_changed)
- self.font_glyph_filter.SetToolTip(_("Filter fonts by available glyphs."))
-
- self.font_category_filter = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN | wx.CB_READONLY)
- unfiltered = FontCategory('unfiltered', "---")
- self.font_category_filter.Append(unfiltered.name, unfiltered)
- for category in FONT_CATEGORIES:
- self.font_category_filter.Append(category.name, category)
- self.font_category_filter.SetToolTip(_("Filter fonts by category."))
- self.font_category_filter.SetSelection(0)
- self.font_category_filter.Bind(wx.EVT_COMBOBOX, self.on_filter_changed)
-
- # font details
- self.font_description = wx.StaticText(self, wx.ID_ANY)
- self.Bind(wx.EVT_SIZE, self.resize)
-
- # font filter
- self.filter_box = wx.StaticBox(self, wx.ID_ANY, label=_("Font Filter"))
-
- # options
- self.options_box = wx.StaticBox(self, wx.ID_ANY, label=_("Options"))
-
- self.scale_spinner = wx.SpinCtrl(self, wx.ID_ANY, min=0, max=1000, initial=100)
- self.scale_spinner.Bind(wx.EVT_SPINCTRL, lambda event: self.on_change("scale", event))
-
- 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.on_change("back_and_forth", event))
-
- self.trim_option_choice = wx.Choice(self, choices=[_("Never"), _("after each line"), _("after each word"), _("after each letter")],
- name=_("Add trim command"))
- self.trim_option_choice.Bind(wx.EVT_CHOICE, lambda event: self.on_trim_option_change(event))
+ outer_sizer = wx.BoxSizer(wx.VERTICAL)
- self.use_trim_symbols = wx.CheckBox(self, label=_("Use command symbols"))
- self.use_trim_symbols.Bind(wx.EVT_CHECKBOX, lambda event: self.on_change("use_trim_symbols", event))
- self.use_trim_symbols.SetToolTip(_('Uses command symbols if enabled. When disabled inserts trim commands as params.'))
+ self.preview_renderer = PreviewRenderer(self.render_stitch_plan, self.on_stitch_plan_rendered)
- # text editor
- self.text_input_box = wx.StaticBox(self, wx.ID_ANY, label=_("Text"))
+ # notebook
+ self.notebook = wx.Notebook(self, wx.ID_ANY)
+ self.options_panel = LetteringOptionsPanel(self.notebook, self)
+ self.notebook.AddPage(self.options_panel, _("Options"))
+ help_panel = LetteringHelpPanel(self.notebook)
+ self.notebook.AddPage(help_panel, _("Help"))
+ outer_sizer.Add(self.notebook, 1, wx.EXPAND | wx.ALL, 10)
- self.text_editor = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_DONTWRAP)
- self.text_editor.Bind(wx.EVT_TEXT, lambda event: self.on_change("text", event))
+ # presets
+ self.presets_panel = PresetsPanel(self)
+ outer_sizer.Add(self.presets_panel, 0, wx.EXPAND | wx.ALL, 10)
+ # buttons
+ self.apply_button = wx.Button(self, wx.ID_ANY, _("Apply and Quit"))
+ self.apply_button.Bind(wx.EVT_BUTTON, self.apply)
self.cancel_button = wx.Button(self, wx.ID_ANY, _("Cancel"))
self.cancel_button.Bind(wx.EVT_BUTTON, self.cancel)
self.Bind(wx.EVT_CLOSE, self.cancel)
-
- self.apply_button = wx.Button(self, wx.ID_ANY, _("Apply and Quit"))
- self.apply_button.Bind(wx.EVT_BUTTON, self.apply)
+ buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ buttons_sizer.Add(self.cancel_button, 0, wx.RIGHT, 10)
+ buttons_sizer.Add(self.apply_button, 0, wx.RIGHT | wx.BOTTOM, 10)
+ outer_sizer.Add(buttons_sizer, 0, wx.ALIGN_RIGHT, 10)
# set font list
self.update_font_list()
self.set_font_list()
- self.__do_layout()
+ self.SetSizer(outer_sizer)
+ self.Layout()
+
+ # SetSizerAndFit determined the minimum size that fits all the controls
+ # and set the window's minimum size so that the user can't make it
+ # smaller. It also set the window to that size. We'd like to give the
+ # user a bit more room for text, so we'll add some height.
+ size = self.options_panel.GetSize()
+ size.height = size.height + 200
+ self.options_panel.SetSize(size)
self.load_settings()
self.apply_settings()
@@ -136,11 +107,11 @@ class LetteringPanel(wx.Panel):
def apply_settings(self):
"""Make the settings in self.settings visible in the UI."""
- self.back_and_forth_checkbox.SetValue(bool(self.settings.back_and_forth))
- self.trim_option_choice.SetSelection(self.settings.trim_option)
- self.use_trim_symbols.SetValue(bool(self.settings.use_trim_symbols))
- self.text_editor.SetValue(self.settings.text)
- self.scale_spinner.SetValue(self.settings.scale)
+ 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))
+ self.options_panel.text_editor.SetValue(self.settings.text)
+ self.options_panel.scale_spinner.SetValue(self.settings.scale)
self.set_initial_font(self.settings.font)
def save_settings(self):
@@ -157,12 +128,12 @@ class LetteringPanel(wx.Panel):
self.fonts_by_id = {}
# font size filter value
- filter_size = self.font_size_filter.GetValue()
- filter_glyph = self.font_glyph_filter.GetValue()
- filter_category = self.font_category_filter.GetSelection() - 1
+ filter_size = self.options_panel.font_size_filter.GetValue()
+ filter_glyph = self.options_panel.font_glyph_filter.GetValue()
+ filter_category = self.options_panel.font_category_filter.GetSelection() - 1
# glyph filter string without spaces
- glyphs = [*self.text_editor.GetValue().replace(" ", "").replace("\n", "")]
+ glyphs = [*self.options_panel.text_editor.GetValue().replace(" ", "").replace("\n", "")]
for font in self.font_list:
if filter_glyph and glyphs and not set(glyphs).issubset(font.available_glyphs):
@@ -180,7 +151,7 @@ class LetteringPanel(wx.Panel):
self.fonts_by_id[font.marked_custom_font_id] = font
def set_font_list(self):
- self.font_chooser.Clear()
+ self.options_panel.font_chooser.Clear()
for font in self.fonts.values():
image = font.preview_image
@@ -199,9 +170,9 @@ class LetteringPanel(wx.Panel):
"""
# Windows requires all images to have the exact same size
image.Rescale(300, 20, quality=wx.IMAGE_QUALITY_HIGH)
- self.font_chooser.Append(font.marked_custom_font_name, wx.Bitmap(image))
+ self.options_panel.font_chooser.Append(font.marked_custom_font_name, wx.Bitmap(image))
else:
- self.font_chooser.Append(font.marked_custom_font_name)
+ self.options_panel.font_chooser.Append(font.marked_custom_font_name)
def get_font_descriptions(self):
return {font.name: font.description for font in self.fonts.values()}
@@ -216,7 +187,7 @@ class LetteringPanel(wx.Panel):
font = self.fonts_by_id[font_id].marked_custom_font_name
except KeyError:
font = self.default_font.marked_custom_font_name
- self.font_chooser.SetValue(font)
+ self.options_panel.font_chooser.SetValue(font)
self.on_font_changed()
@@ -229,23 +200,23 @@ class LetteringPanel(wx.Panel):
def on_change(self, attribute, event):
self.settings[attribute] = event.GetEventObject().GetValue()
- if attribute == "text" and self.font_glyph_filter.GetValue() is True:
+ if attribute == "text" and self.options_panel.font_glyph_filter.GetValue() is True:
self.on_filter_changed()
self.preview_renderer.update()
def on_trim_option_change(self, event=None):
- self.settings.trim_option = self.trim_option_choice.GetCurrentSelection()
+ self.settings.trim_option = self.options_panel.trim_option_choice.GetCurrentSelection()
self.preview_renderer.update()
def on_font_changed(self, event=None):
- font = self.fonts.get(self.font_chooser.GetValue(), self.default_font)
+ font = self.fonts.get(self.options_panel.font_chooser.GetValue(), self.default_font)
self.settings.font = font.marked_custom_font_id
- filter_size = self.font_size_filter.GetValue()
- self.scale_spinner.SetRange(int(font.min_scale * 100), int(font.max_scale * 100))
+ filter_size = self.options_panel.font_size_filter.GetValue()
+ self.options_panel.scale_spinner.SetRange(int(font.min_scale * 100), int(font.max_scale * 100))
if filter_size != 0:
- self.scale_spinner.SetValue(int(filter_size / font.size * 100))
- self.settings['scale'] = self.scale_spinner.GetValue()
+ self.options_panel.scale_spinner.SetValue(int(filter_size / font.size * 100))
+ self.settings['scale'] = self.options_panel.scale_spinner.GetValue()
font_variants = []
try:
@@ -259,17 +230,17 @@ class LetteringPanel(wx.Panel):
if len(font_variants) == 0:
color = (255, 0, 0)
description = _('This font has no available font variant. Please update or remove the font.')
- self.font_description.SetLabel(description)
- self.font_description.SetForegroundColour(color)
- self.font_description.Wrap(self.GetSize().width - 35)
+ self.options_panel.font_description.SetLabel(description)
+ self.options_panel.font_description.SetForegroundColour(color)
+ self.options_panel.font_description.Wrap(self.options_panel.GetSize().width - 50)
if font.reversible:
- self.back_and_forth_checkbox.Enable()
- self.back_and_forth_checkbox.SetValue(bool(self.settings.back_and_forth))
+ self.options_panel.back_and_forth_checkbox.Enable()
+ self.options_panel.back_and_forth_checkbox.SetValue(bool(self.settings.back_and_forth))
else:
# The creator of the font banned the possibility of writing in reverse with json file: "reversible": false
- self.back_and_forth_checkbox.Disable()
- self.back_and_forth_checkbox.SetValue(False)
+ self.options_panel.back_and_forth_checkbox.Disable()
+ self.options_panel.back_and_forth_checkbox.SetValue(False)
self.update_preview()
self.Layout()
@@ -279,27 +250,27 @@ class LetteringPanel(wx.Panel):
if not self.fonts:
# No fonts for filtered size
- self.font_chooser.Clear()
- self.filter_box.SetForegroundColour("red")
+ self.options_panel.font_chooser.Clear()
+ self.options_panel.filter_box.SetForegroundColour("red")
return
else:
- self.filter_box.SetForegroundColour(wx.NullColour)
+ self.options_panel.filter_box.SetForegroundColour(wx.NullColour)
- filter_size = self.font_size_filter.GetValue()
- previous_font = self.font_chooser.GetValue()
+ filter_size = self.options_panel.font_size_filter.GetValue()
+ previous_font = self.options_panel.font_chooser.GetValue()
self.set_font_list()
font = self.fonts.get(previous_font, self.default_font)
- self.font_chooser.SetValue(font.marked_custom_font_name)
+ self.options_panel.font_chooser.SetValue(font.marked_custom_font_name)
if font.marked_custom_font_name != previous_font:
self.on_font_changed()
elif filter_size != 0:
- self.scale_spinner.SetValue(int(filter_size / font.size * 100))
- self.settings['scale'] = self.scale_spinner.GetValue()
+ self.options_panel.scale_spinner.SetValue(int(filter_size / font.size * 100))
+ self.settings['scale'] = self.options_panel.scale_spinner.GetValue()
def resize(self, event=None):
- description = self.font_description.GetLabel().replace("\n", " ")
- self.font_description.SetLabel(description)
- self.font_description.Wrap(self.GetSize().width - 35)
+ description = self.options_panel.font_description.GetLabel().replace("\n", " ")
+ self.options_panel.font_description.SetLabel(description)
+ self.options_panel.font_description.Wrap(self.options_panel.GetSize().width - 50)
self.Layout()
def update_preview(self, event=None):
@@ -307,7 +278,7 @@ class LetteringPanel(wx.Panel):
def update_lettering(self, raise_error=False):
# return if there is no font in the font list (possibly due to a font size filter)
- if not self.font_chooser.GetValue():
+ if not self.options_panel.font_chooser.GetValue():
return
del self.group[:]
@@ -323,7 +294,7 @@ class LetteringPanel(wx.Panel):
})
self.group.append(destination_group)
- font = self.fonts.get(self.font_chooser.GetValue(), self.default_font)
+ font = self.fonts.get(self.options_panel.font_chooser.GetValue(), self.default_font)
try:
font.render_text(self.settings.text, destination_group, back_and_forth=self.settings.back_and_forth,
trim_option=self.settings.trim_option, use_trim_symbols=self.settings.use_trim_symbols)
@@ -402,69 +373,3 @@ class LetteringPanel(wx.Panel):
def cancel(self, event):
self.simulator.stop()
wx.CallAfter(self.GetTopLevelParent().cancel)
-
- def __do_layout(self):
- outer_sizer = wx.BoxSizer(wx.VERTICAL)
-
- # font selection
- font_selector_sizer = wx.StaticBoxSizer(self.font_selector_box, wx.VERTICAL)
- font_selector_box = wx.BoxSizer(wx.HORIZONTAL)
- font_selector_box.Add(self.font_chooser, 4, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.RIGHT, 10)
- font_selector_sizer.Add(font_selector_box, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
- font_selector_sizer.Add(self.font_description, 1, wx.EXPAND | wx.ALL, 10)
- outer_sizer.Add(font_selector_sizer, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
-
- # filter fon list
- filter_sizer = wx.StaticBoxSizer(self.filter_box, wx.HORIZONTAL)
- filter_size_label = wx.StaticText(self, wx.ID_ANY, _("Size"))
- filter_sizer.Add(filter_size_label, 0, wx.LEFT | wx.TOP | wx.BOTTOM, 10)
- filter_sizer.AddSpacer(5)
- filter_sizer.Add(self.font_size_filter, 1, wx.RIGHT | wx.TOP | wx.BOTTOM, 10)
- filter_sizer.AddSpacer(5)
- filter_sizer.Add(self.font_glyph_filter, 1, wx.RIGHT | wx.TOP | wx.BOTTOM, 10)
- filter_sizer.Add(self.font_category_filter, 1, wx.RIGHT | wx.TOP | wx.BOTTOM, 10)
- outer_sizer.Add(filter_sizer, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
-
- # options
- left_option_sizer = wx.BoxSizer(wx.VERTICAL)
- left_option_sizer.Add(self.back_and_forth_checkbox, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
-
- trim_option_sizer = wx.BoxSizer(wx.HORIZONTAL)
- trim_option_sizer.Add(wx.StaticText(self, wx.ID_ANY, _("Add trims")), 0, wx.LEFT | wx.ALIGN_TOP, 5)
- trim_option_sizer.Add(self.trim_option_choice, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
- trim_option_sizer.Add(self.use_trim_symbols, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
- left_option_sizer.Add(trim_option_sizer, 0, wx.ALIGN_LEFT, 5)
-
- font_scale_sizer = wx.BoxSizer(wx.HORIZONTAL)
- font_scale_sizer.Add(wx.StaticText(self, wx.ID_ANY, _("Scale")), 0, wx.LEFT | wx.ALIGN_CENTRE_VERTICAL, 0)
- font_scale_sizer.Add(self.scale_spinner, 0, wx.LEFT, 10)
- font_scale_sizer.Add(wx.StaticText(self, wx.ID_ANY, "%"), 0, wx.LEFT | wx.ALIGN_CENTRE_VERTICAL, 3)
-
- options_sizer = wx.StaticBoxSizer(self.options_box, wx.HORIZONTAL)
- options_sizer.Add(left_option_sizer, 1, wx.EXPAND, 10)
- options_sizer.Add(font_scale_sizer, 0, wx.RIGHT, 10)
-
- outer_sizer.Add(options_sizer, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
-
- # text input
- text_input_sizer = wx.StaticBoxSizer(self.text_input_box, wx.VERTICAL)
- text_input_sizer.Add(self.text_editor, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)
- outer_sizer.Add(text_input_sizer, 2, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
-
- # presets
- outer_sizer.Add(self.presets_panel, 0, wx.EXPAND | wx.EXPAND | wx.ALL, 10)
- buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
- buttons_sizer.Add(self.cancel_button, 0, wx.RIGHT, 10)
- buttons_sizer.Add(self.apply_button, 0, wx.RIGHT | wx.BOTTOM, 10)
- outer_sizer.Add(buttons_sizer, 0, wx.ALIGN_RIGHT, 10)
-
- self.SetSizerAndFit(outer_sizer)
- self.Layout()
-
- # SetSizerAndFit determined the minimum size that fits all the controls
- # and set the window's minimum size so that the user can't make it
- # smaller. It also set the window to that size. We'd like to give the
- # user a bit more room for text, so we'll add some height.
- size = self.GetSize()
- size.height = size.height + 200
- self.SetSize(size)
diff --git a/lib/gui/lettering/option_panel.py b/lib/gui/lettering/option_panel.py
new file mode 100644
index 00000000..ab123f83
--- /dev/null
+++ b/lib/gui/lettering/option_panel.py
@@ -0,0 +1,105 @@
+import wx
+
+from ...i18n import _
+from ...lettering.categories import FONT_CATEGORIES, FontCategory
+
+
+class LetteringOptionsPanel(wx.Panel):
+ def __init__(self, parent, panel):
+ self.panel = panel
+ wx.Panel.__init__(self, parent)
+
+ outer_sizer = wx.BoxSizer(wx.VERTICAL)
+
+ # font selection
+ self.font_chooser = wx.adv.BitmapComboBox(self, wx.ID_ANY, style=wx.CB_READONLY | wx.CB_SORT)
+ self.font_chooser.Bind(wx.EVT_COMBOBOX, self.panel.on_font_changed)
+
+ self.font_description = wx.StaticText(self, wx.ID_ANY)
+ self.panel.Bind(wx.EVT_SIZE, self.panel.resize)
+
+ self.font_selector_box = wx.StaticBox(self, wx.ID_ANY, label=_("Font"))
+ font_selector_sizer = wx.StaticBoxSizer(self.font_selector_box, wx.VERTICAL)
+ font_selector_box = wx.BoxSizer(wx.HORIZONTAL)
+ font_selector_box.Add(self.font_chooser, 4, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.RIGHT, 10)
+ font_selector_sizer.Add(font_selector_box, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
+ font_selector_sizer.Add(self.font_description, 1, wx.EXPAND | wx.ALL, 10)
+ outer_sizer.Add(font_selector_sizer, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
+
+ # filter font list
+ self.font_size_filter = wx.SpinCtrlDouble(self, min=0, max=100, inc=0.1, initial=0, style=wx.SP_WRAP)
+ self.font_size_filter.SetDigits(2)
+ self.font_size_filter.Bind(wx.EVT_SPINCTRLDOUBLE, self.panel.on_filter_changed)
+ self.font_size_filter.SetToolTip(_("Font size filter (mm). 0 for all sizes."))
+
+ self.font_glyph_filter = wx.CheckBox(self, label=_("Glyphs"))
+ self.font_glyph_filter.Bind(wx.EVT_CHECKBOX, self.panel.on_filter_changed)
+ self.font_glyph_filter.SetToolTip(_("Filter fonts by available glyphs."))
+
+ self.font_category_filter = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN | wx.CB_READONLY)
+ unfiltered = FontCategory('unfiltered', "---")
+ self.font_category_filter.Append(unfiltered.name, unfiltered)
+ for category in FONT_CATEGORIES:
+ self.font_category_filter.Append(category.name, category)
+ self.font_category_filter.SetToolTip(_("Filter fonts by category."))
+ self.font_category_filter.SetSelection(0)
+ self.font_category_filter.Bind(wx.EVT_COMBOBOX, self.panel.on_filter_changed)
+
+ self.filter_box = wx.StaticBox(self, wx.ID_ANY, label=_("Font Filter"))
+ filter_sizer = wx.StaticBoxSizer(self.filter_box, wx.HORIZONTAL)
+ filter_size_label = wx.StaticText(self, wx.ID_ANY, _("Size"))
+ filter_sizer.Add(filter_size_label, 0, wx.LEFT | wx.TOP | wx.BOTTOM, 10)
+ filter_sizer.AddSpacer(5)
+ filter_sizer.Add(self.font_size_filter, 1, wx.RIGHT | wx.TOP | wx.BOTTOM, 10)
+ filter_sizer.AddSpacer(5)
+ filter_sizer.Add(self.font_glyph_filter, 1, wx.RIGHT | wx.TOP | wx.BOTTOM, 10)
+ filter_sizer.Add(self.font_category_filter, 1, wx.RIGHT | wx.TOP | wx.BOTTOM, 10)
+ outer_sizer.Add(filter_sizer, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
+
+ # options
+ self.options_box = wx.StaticBox(self, wx.ID_ANY, label=_("Options"))
+
+ self.scale_spinner = wx.SpinCtrl(self, wx.ID_ANY, min=0, max=1000, initial=100)
+ self.scale_spinner.Bind(wx.EVT_SPINCTRL, lambda event: self.panel.on_change("scale", event))
+
+ 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.trim_option_choice = wx.Choice(self, choices=[_("Never"), _("after each line"), _("after each word"), _("after each letter")],
+ name=_("Add trim command"))
+ self.trim_option_choice.Bind(wx.EVT_CHOICE, lambda event: self.panel.on_trim_option_change(event))
+
+ self.use_trim_symbols = wx.CheckBox(self, label=_("Use command symbols"))
+ self.use_trim_symbols.Bind(wx.EVT_CHECKBOX, lambda event: self.panel.on_change("use_trim_symbols", event))
+ self.use_trim_symbols.SetToolTip(_('Uses command symbols if enabled. When disabled inserts trim commands as params.'))
+
+ left_option_sizer = wx.BoxSizer(wx.VERTICAL)
+ left_option_sizer.Add(self.back_and_forth_checkbox, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
+
+ trim_option_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ trim_option_sizer.Add(wx.StaticText(self, wx.ID_ANY, _("Add trims")), 0, wx.LEFT | wx.ALIGN_TOP, 5)
+ trim_option_sizer.Add(self.trim_option_choice, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
+ trim_option_sizer.Add(self.use_trim_symbols, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
+ left_option_sizer.Add(trim_option_sizer, 0, wx.ALIGN_LEFT, 5)
+
+ font_scale_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ font_scale_sizer.Add(wx.StaticText(self, wx.ID_ANY, _("Scale")), 0, wx.LEFT | wx.ALIGN_CENTRE_VERTICAL, 0)
+ font_scale_sizer.Add(self.scale_spinner, 0, wx.LEFT, 10)
+ font_scale_sizer.Add(wx.StaticText(self, wx.ID_ANY, "%"), 0, wx.LEFT | wx.ALIGN_CENTRE_VERTICAL, 3)
+
+ options_sizer = wx.StaticBoxSizer(self.options_box, wx.HORIZONTAL)
+ options_sizer.Add(left_option_sizer, 1, wx.EXPAND, 10)
+ options_sizer.Add(font_scale_sizer, 0, wx.RIGHT, 10)
+ outer_sizer.Add(options_sizer, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
+
+ # text input
+ self.text_input_box = wx.StaticBox(self, wx.ID_ANY, label=_("Text"))
+ self.text_editor = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_DONTWRAP)
+ self.text_editor.Bind(wx.EVT_TEXT, lambda event: self.panel.on_change("text", event))
+
+ text_input_sizer = wx.StaticBoxSizer(self.text_input_box, wx.VERTICAL)
+ text_input_sizer.Add(self.text_editor, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)
+ outer_sizer.Add(text_input_sizer, 2, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10)
+
+ # set panel sizer
+ self.SetSizer(outer_sizer)
diff --git a/lib/gui/satin_multicolor/__init__.py b/lib/gui/satin_multicolor/__init__.py
new file mode 100644
index 00000000..84406f22
--- /dev/null
+++ b/lib/gui/satin_multicolor/__init__.py
@@ -0,0 +1,8 @@
+# Authors: see git history
+#
+# Copyright (c) 2024 Authors
+# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+
+from .colorize_panel import ColorizePanel
+from .help_panel import HelpPanel
+from .main_panel import MultiColorSatinPanel
diff --git a/lib/gui/satin_multicolor/colorize.py b/lib/gui/satin_multicolor/colorize_panel.py
index 87243145..87243145 100644
--- a/lib/gui/satin_multicolor/colorize.py
+++ b/lib/gui/satin_multicolor/colorize_panel.py
diff --git a/lib/gui/satin_multicolor/main_panel.py b/lib/gui/satin_multicolor/main_panel.py
index 0ceebb4f..49c819fd 100644
--- a/lib/gui/satin_multicolor/main_panel.py
+++ b/lib/gui/satin_multicolor/main_panel.py
@@ -15,8 +15,7 @@ from ...i18n import _
from ...stitch_plan import stitch_groups_to_stitch_plan
from ...utils.threading import ExitThread, check_stop_flag
from .. import PreviewRenderer, WarningPanel
-from .colorize import ColorizePanel
-from .help_panel import HelpPanel
+from . import ColorizePanel, HelpPanel
class MultiColorSatinPanel(wx.Panel):