Improve simulator dark theme (#2969)

* add simulator dark theme buttons
* refresh simulator drawing panel on resize (important for windows)
pull/2974/head
Kaalleen 2024-06-07 10:33:45 +02:00 zatwierdzone przez GitHub
rodzic 1592e011b9
commit ee2506147e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
20 zmienionych plików z 23 dodań i 5 usunięć

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.0 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.4 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.3 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.6 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.3 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.2 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.1 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.3 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.0 KiB

BIN
icons/jump_dark.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 7.7 KiB

BIN
icons/npp_dark.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.9 KiB

BIN
icons/play_dark.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.9 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 6.1 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.3 KiB

BIN
icons/stop_dark.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

BIN
icons/trim_dark.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 8.0 KiB

Wyświetl plik

@ -86,8 +86,11 @@ class ParamsTab(ScrolledPanel):
self.pencil_icon = wx.Image(os.path.join(get_resource_dir(
"icons"), "pencil_20x20.png")).ConvertToBitmap()
self.randomize_icon = wx.Image(os.path.join(get_resource_dir(
"icons"), "randomize_20x20.png")).ConvertToBitmap()
randomize_icon = 'randomize_20x20.png'
if wx.SystemSettings().GetAppearance().IsDark():
randomize_icon = 'randomize_20x20_dark.png'
self.randomize_icon = wx.Image(
os.path.join(get_resource_dir("icons"), randomize_icon)).ConvertToBitmap()
self.__set_properties()
self.__do_layout()

Wyświetl plik

@ -288,8 +288,14 @@ class ControlPanel(wx.Panel):
elif stitch.color_change:
self.slider.add_marker("color_change", stitch_num)
def is_dark_theme(self):
return wx.SystemSettings().GetAppearance().IsDark()
def load_icon(self, icon_name):
icon = wx.Image(os.path.join(self.icons_dir, f"{icon_name}.png"))
if self.is_dark_theme():
icon = wx.Image(os.path.join(self.icons_dir, f"{icon_name}_dark.png"))
else:
icon = wx.Image(os.path.join(self.icons_dir, f"{icon_name}.png"))
icon.Rescale(self.button_size, self.button_size, wx.IMAGE_QUALITY_HIGH)
return icon.ConvertToBitmap()
@ -500,6 +506,7 @@ class DrawingPanel(wx.Panel):
self.Bind(wx.EVT_SIZE, self.choose_zoom_and_pan)
self.Bind(wx.EVT_LEFT_DOWN, self.on_left_mouse_button_down)
self.Bind(wx.EVT_MOUSEWHEEL, self.on_mouse_wheel)
self.Bind(wx.EVT_SIZE, self.on_resize)
self.SetMinSize((400, 400))
@ -507,6 +514,9 @@ class DrawingPanel(wx.Panel):
if self.stitch_plan:
wx.CallLater(50, self.load, self.stitch_plan)
def on_resize(self, event):
self.Refresh()
def clamp_current_stitch(self):
if self.current_stitch < 1:
self.current_stitch = 1
@ -876,6 +886,7 @@ class SimulatorSlider(wx.Panel):
def __init__(self, parent, id=wx.ID_ANY, minValue=1, maxValue=2, **kwargs):
super().__init__(parent, id)
self.control_panel = parent
kwargs['style'] = wx.SL_HORIZONTAL | wx.SL_VALUE_LABEL | wx.SL_TOP | wx.ALIGN_TOP
@ -988,8 +999,12 @@ class SimulatorSlider(wx.Panel):
gc.DrawRectangle(start_x, height * self.color_bar_start,
end_x - start_x, height * self.color_bar_thickness)
gc.SetPen(wx.Pen(wx.Colour(255, 255, 255), 1))
gc.SetBrush(wx.Brush(wx.Colour(0, 0, 0)))
if self.control_panel.is_dark_theme():
gc.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1))
gc.SetBrush(wx.Brush(wx.Colour(255, 255, 255)))
else:
gc.SetPen(wx.Pen(wx.Colour(255, 255, 255), 1))
gc.SetBrush(wx.Brush(wx.Colour(0, 0, 0)))
value_x = _value_to_x(self._value)
tab_height = self.tab_height * height