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)
|
||||
except Exception:
|
||||
pass
|
||||
accent = self._exclusion_preview_colour()
|
||||
self._stroke_preview_id = self.canvas_orig.create_line(
|
||||
x,
|
||||
y,
|
||||
x,
|
||||
y,
|
||||
fill="yellow",
|
||||
fill=accent,
|
||||
width=2,
|
||||
smooth=True,
|
||||
capstyle="round",
|
||||
|
|
@ -39,7 +40,8 @@ class ExclusionMixin:
|
|||
self.canvas_orig.delete(self._rubber_id)
|
||||
except Exception:
|
||||
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):
|
||||
mode = getattr(self, "exclude_mode", "rect")
|
||||
|
|
@ -153,6 +155,7 @@ class ExclusionMixin:
|
|||
next_mode = "free" if current == "rect" else "rect"
|
||||
self.exclude_mode = next_mode
|
||||
self._current_stroke = None
|
||||
accent = self._exclusion_preview_colour()
|
||||
if next_mode == "free":
|
||||
if self._rubber_id:
|
||||
try:
|
||||
|
|
@ -168,6 +171,7 @@ class ExclusionMixin:
|
|||
except Exception:
|
||||
pass
|
||||
self._stroke_preview_id = None
|
||||
self._rubber_id = None
|
||||
message_key = "status.free_draw_enabled" if next_mode == "free" else "status.free_draw_disabled"
|
||||
if hasattr(self, "status"):
|
||||
try:
|
||||
|
|
@ -186,6 +190,10 @@ class ExclusionMixin:
|
|||
compressed.append(point)
|
||||
return compressed
|
||||
|
||||
def _exclusion_preview_colour(self) -> str:
|
||||
is_dark = getattr(self, "theme", "light") == "dark"
|
||||
return "#ffd700" if is_dark else "#c56217"
|
||||
|
||||
@staticmethod
|
||||
def _close_polygon(points: list[tuple[int, int]]) -> list[tuple[int, int]]:
|
||||
"""Ensure the polygon is closed by repeating the start if necessary."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue