diff --git a/app_state.py b/app_state.py index fef3937..93959c9 100644 --- a/app_state.py +++ b/app_state.py @@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it. import configparser import os -VERSION = "0.0.0.174" +VERSION = "0.0.0.175" PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties") DEFAULT_GRID_SIZE = 10 DEFAULT_ADD_TIMESTAMP = True @@ -41,6 +41,9 @@ status_label = None # the window's bottom status bar # colour wherever the change was made. DIRTY_TINT = "#ffe6e6" CLEAN_TINT = "white" +# The wiresheet canvas around the sheet itself, clean and with unsaved changes. +OFF_SHEET_TINT = "#f3f3f3" +OFF_SHEET_DIRTY_TINT = "#f0dcdc" # The file name on the tree's root row turns this colour while anything is unwritten, # which is the one place a file name appears on screen -- a Tk window title cannot be @@ -239,8 +242,7 @@ def mark_dirty(): global is_dirty if not is_dirty: is_dirty = True - if canvas is not None: - canvas.config(bg=DIRTY_TINT) + paint_sheet_tint() refresh_dirty_display() @@ -248,11 +250,26 @@ def mark_clean(): """Clears the unsaved-state marker after a successful save or a fresh load.""" global is_dirty is_dirty = False - if canvas is not None: - canvas.config(bg=CLEAN_TINT) + paint_sheet_tint() refresh_dirty_display() +def sheet_tints(): + """(sheet, off-sheet) colours for the wiresheet in the current saved/unsaved state.""" + if is_dirty: + return DIRTY_TINT, OFF_SHEET_DIRTY_TINT + return CLEAN_TINT, OFF_SHEET_TINT + + +def paint_sheet_tint(): + """Recolours the sheet (the "sheet_bg" rectangle) and the canvas around it.""" + if canvas is None: + return + sheet, off_sheet = sheet_tints() + canvas.config(bg=off_sheet) + canvas.itemconfig("sheet_bg", fill=sheet) + + # ── Live device connection state ──────────────────────────────── live_mode = False device_session = None # device_session.DeviceSession instance diff --git a/main.py b/main.py index 7654012..0f88f63 100644 --- a/main.py +++ b/main.py @@ -3743,7 +3743,7 @@ canvas_hscroll.pack(side=tk.BOTTOM, fill=tk.X) canvas = tk.Canvas( frame_editor, - bg=wiresheet.OFF_SHEET_COLOUR, + bg=app_state.OFF_SHEET_TINT, highlightthickness=0, xscrollcommand=canvas_hscroll.set, yscrollcommand=canvas_vscroll.set, diff --git a/wiresheet.py b/wiresheet.py index 667a660..1cec58c 100644 --- a/wiresheet.py +++ b/wiresheet.py @@ -123,7 +123,6 @@ FIT_PADDING = 20 # as a grey wash rather than a grid, so the grid is left off instead. MIN_GRID_STEP = 3 SHEET_MARGIN_GRIDS = 3 # grid squares of grey kept past anything that overflows the sheet -OFF_SHEET_COLOUR = "#f3f3f3" # canvas outside the area a box's origin can be stored in def snap_up(value, grid_size): @@ -240,16 +239,18 @@ def measure_box(comp, fonts, linked_slot_index): def draw_grid(): - """Paints the sheet white and grids it; the canvas around it stays OFF_SHEET_COLOUR. + """Paints the sheet and grids it; the canvas around it is the off-sheet tint. Drawn at the sheet's zoom, so a box still lands on a line at every scale. """ canvas = app_state.canvas canvas.delete("grid") - x1, y1 = 0, 0 + # The sheet starts past the margin strip no box may enter, which stays grey too. + x1 = y1 = layout_margin(app_state.meta_scale) * app_state.zoom x2, y2 = (coord * app_state.zoom for coord in sheet_extent()) - canvas.create_rectangle(x1, y1, x2, y2, fill="white", outline="#c8c8c8", tags="grid") + canvas.create_rectangle(x1, y1, x2, y2, outline="#c8c8c8", tags=("grid", "sheet_bg")) + app_state.paint_sheet_tint() # white or pink by saved state, grey or pink around it step = app_state.GRID_SIZE * app_state.zoom if step >= MIN_GRID_STEP: