Tint Page Editor canvas while the document has unsaved changes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 10:06:22 +03:00
co-authored by Claude Opus 5.5
parent 26f9abb0dd
commit 7ca029e3ea
3 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it.
import configparser import configparser
import os import os
VERSION = "0.0.0.125" VERSION = "0.0.0.126"
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties") PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
DEFAULT_GRID_SIZE = 10 DEFAULT_GRID_SIZE = 10
DEFAULT_ADD_TIMESTAMP = True DEFAULT_ADD_TIMESTAMP = True
+3
View File
@@ -163,6 +163,9 @@ def refresh_dirty_display():
only turned red on the paths that happened to rebuild the tree -- a Properties Save only turned red on the paths that happened to rebuild the tree -- a Properties Save
did, dragging a box did not. did, dragging a box did not.
""" """
if ox_page_panel is not None:
ox_page_panel.refresh_dirty_tint()
tree = app_state.tree tree = app_state.tree
if tree is None: if tree is None:
return return
+11 -1
View File
@@ -143,6 +143,9 @@ def _get_widget_children(page_comp):
return [c for c in page_comp if c.tag == "comp" and _is_ox_widget(c)] return [c for c in page_comp if c.tag == "comp" and _is_ox_widget(c)]
CANVAS_BG = "#e0e0e0"
class OxPageViewPanel: class OxPageViewPanel:
def __init__(self, parent, comp, on_change=None, on_close=None): def __init__(self, parent, comp, on_change=None, on_close=None):
@@ -256,7 +259,7 @@ class OxPageViewPanel:
hscroll.pack(side=tk.BOTTOM, fill=tk.X) hscroll.pack(side=tk.BOTTOM, fill=tk.X)
self._canvas = tk.Canvas( self._canvas = tk.Canvas(
parent, bg="#e0e0e0", highlightthickness=0, parent, bg=self._background(), highlightthickness=0,
xscrollcommand=hscroll.set, yscrollcommand=vscroll.set, xscrollcommand=hscroll.set, yscrollcommand=vscroll.set,
scrollregion=(0, 0, int(self._canvas_w * self._zoom), int(self._canvas_h * self._zoom)), scrollregion=(0, 0, int(self._canvas_w * self._zoom), int(self._canvas_h * self._zoom)),
) )
@@ -604,6 +607,13 @@ class OxPageViewPanel:
def refresh(self): def refresh(self):
self._render_page() self._render_page()
def _background(self):
return app_state.DIRTY_TINT if app_state.is_dirty else CANVAS_BG
def refresh_dirty_tint(self):
"""Wears the wiresheet's unsaved-state tint while the document has unwritten changes."""
self._canvas.config(bg=self._background())
def close(self): def close(self):
if self.on_close is not None: if self.on_close is not None:
self.on_close() self.on_close()