Use themed preview accents
Apply the theme-specific accent colour to exclusion previews so new shapes match the final outline in both light and dark modes.
This commit is contained in:
parent
4fc0182798
commit
987c2e9e4a
|
|
@ -20,12 +20,13 @@ class ExclusionMixin:
|
||||||
self.canvas_orig.delete(preview_id)
|
self.canvas_orig.delete(preview_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
accent = self._exclusion_preview_colour()
|
||||||
self._stroke_preview_id = self.canvas_orig.create_line(
|
self._stroke_preview_id = self.canvas_orig.create_line(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
fill="yellow",
|
fill=accent,
|
||||||
width=2,
|
width=2,
|
||||||
smooth=True,
|
smooth=True,
|
||||||
capstyle="round",
|
capstyle="round",
|
||||||
|
|
@ -39,7 +40,8 @@ class ExclusionMixin:
|
||||||
self.canvas_orig.delete(self._rubber_id)
|
self.canvas_orig.delete(self._rubber_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self._rubber_id = self.canvas_orig.create_rectangle(x, y, x, y, outline="yellow", width=2)
|
accent = self._exclusion_preview_colour()
|
||||||
|
self._rubber_id = self.canvas_orig.create_rectangle(x, y, x, y, outline=accent, width=2)
|
||||||
|
|
||||||
def _exclude_drag(self, event):
|
def _exclude_drag(self, event):
|
||||||
mode = getattr(self, "exclude_mode", "rect")
|
mode = getattr(self, "exclude_mode", "rect")
|
||||||
|
|
@ -153,6 +155,7 @@ class ExclusionMixin:
|
||||||
next_mode = "free" if current == "rect" else "rect"
|
next_mode = "free" if current == "rect" else "rect"
|
||||||
self.exclude_mode = next_mode
|
self.exclude_mode = next_mode
|
||||||
self._current_stroke = None
|
self._current_stroke = None
|
||||||
|
accent = self._exclusion_preview_colour()
|
||||||
if next_mode == "free":
|
if next_mode == "free":
|
||||||
if self._rubber_id:
|
if self._rubber_id:
|
||||||
try:
|
try:
|
||||||
|
|
@ -168,6 +171,7 @@ class ExclusionMixin:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self._stroke_preview_id = None
|
self._stroke_preview_id = None
|
||||||
|
self._rubber_id = None
|
||||||
message_key = "status.free_draw_enabled" if next_mode == "free" else "status.free_draw_disabled"
|
message_key = "status.free_draw_enabled" if next_mode == "free" else "status.free_draw_disabled"
|
||||||
if hasattr(self, "status"):
|
if hasattr(self, "status"):
|
||||||
try:
|
try:
|
||||||
|
|
@ -186,6 +190,10 @@ class ExclusionMixin:
|
||||||
compressed.append(point)
|
compressed.append(point)
|
||||||
return compressed
|
return compressed
|
||||||
|
|
||||||
|
def _exclusion_preview_colour(self) -> str:
|
||||||
|
is_dark = getattr(self, "theme", "light") == "dark"
|
||||||
|
return "#ffd700" if is_dark else "#c56217"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _close_polygon(points: list[tuple[int, int]]) -> list[tuple[int, int]]:
|
def _close_polygon(points: list[tuple[int, int]]) -> list[tuple[int, int]]:
|
||||||
"""Ensure the polygon is closed by repeating the start if necessary."""
|
"""Ensure the polygon is closed by repeating the start if necessary."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue