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:
+11
-1
@@ -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)]
|
||||
|
||||
|
||||
CANVAS_BG = "#e0e0e0"
|
||||
|
||||
|
||||
class OxPageViewPanel:
|
||||
|
||||
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)
|
||||
|
||||
self._canvas = tk.Canvas(
|
||||
parent, bg="#e0e0e0", highlightthickness=0,
|
||||
parent, bg=self._background(), highlightthickness=0,
|
||||
xscrollcommand=hscroll.set, yscrollcommand=vscroll.set,
|
||||
scrollregion=(0, 0, int(self._canvas_w * self._zoom), int(self._canvas_h * self._zoom)),
|
||||
)
|
||||
@@ -604,6 +607,13 @@ class OxPageViewPanel:
|
||||
def refresh(self):
|
||||
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):
|
||||
if self.on_close is not None:
|
||||
self.on_close()
|
||||
|
||||
Reference in New Issue
Block a user