Wiresheet: grey margin strip, saved-state tint on and off the sheet
- The top/left margin no box may enter is grey and ungridded, so the white sheet starts where boxes can actually be placed. - Saving/unsaved state no longer resets the canvas to white: the sheet goes white/pink and the area around it grey/greyish pink. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+22
-5
@@ -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.174"
|
VERSION = "0.0.0.175"
|
||||||
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
|
||||||
@@ -41,6 +41,9 @@ status_label = None # the window's bottom status bar
|
|||||||
# colour wherever the change was made.
|
# colour wherever the change was made.
|
||||||
DIRTY_TINT = "#ffe6e6"
|
DIRTY_TINT = "#ffe6e6"
|
||||||
CLEAN_TINT = "white"
|
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,
|
# 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
|
# 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
|
global is_dirty
|
||||||
if not is_dirty:
|
if not is_dirty:
|
||||||
is_dirty = True
|
is_dirty = True
|
||||||
if canvas is not None:
|
paint_sheet_tint()
|
||||||
canvas.config(bg=DIRTY_TINT)
|
|
||||||
refresh_dirty_display()
|
refresh_dirty_display()
|
||||||
|
|
||||||
|
|
||||||
@@ -248,11 +250,26 @@ def mark_clean():
|
|||||||
"""Clears the unsaved-state marker after a successful save or a fresh load."""
|
"""Clears the unsaved-state marker after a successful save or a fresh load."""
|
||||||
global is_dirty
|
global is_dirty
|
||||||
is_dirty = False
|
is_dirty = False
|
||||||
if canvas is not None:
|
paint_sheet_tint()
|
||||||
canvas.config(bg=CLEAN_TINT)
|
|
||||||
refresh_dirty_display()
|
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 device connection state ────────────────────────────────
|
||||||
live_mode = False
|
live_mode = False
|
||||||
device_session = None # device_session.DeviceSession instance
|
device_session = None # device_session.DeviceSession instance
|
||||||
|
|||||||
@@ -3743,7 +3743,7 @@ canvas_hscroll.pack(side=tk.BOTTOM, fill=tk.X)
|
|||||||
|
|
||||||
canvas = tk.Canvas(
|
canvas = tk.Canvas(
|
||||||
frame_editor,
|
frame_editor,
|
||||||
bg=wiresheet.OFF_SHEET_COLOUR,
|
bg=app_state.OFF_SHEET_TINT,
|
||||||
highlightthickness=0,
|
highlightthickness=0,
|
||||||
xscrollcommand=canvas_hscroll.set,
|
xscrollcommand=canvas_hscroll.set,
|
||||||
yscrollcommand=canvas_vscroll.set,
|
yscrollcommand=canvas_vscroll.set,
|
||||||
|
|||||||
+5
-4
@@ -123,7 +123,6 @@ FIT_PADDING = 20
|
|||||||
# as a grey wash rather than a grid, so the grid is left off instead.
|
# as a grey wash rather than a grid, so the grid is left off instead.
|
||||||
MIN_GRID_STEP = 3
|
MIN_GRID_STEP = 3
|
||||||
SHEET_MARGIN_GRIDS = 3 # grid squares of grey kept past anything that overflows the sheet
|
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):
|
def snap_up(value, grid_size):
|
||||||
@@ -240,16 +239,18 @@ def measure_box(comp, fonts, linked_slot_index):
|
|||||||
|
|
||||||
|
|
||||||
def draw_grid():
|
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.
|
Drawn at the sheet's zoom, so a box still lands on a line at every scale.
|
||||||
"""
|
"""
|
||||||
canvas = app_state.canvas
|
canvas = app_state.canvas
|
||||||
canvas.delete("grid")
|
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())
|
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
|
step = app_state.GRID_SIZE * app_state.zoom
|
||||||
if step >= MIN_GRID_STEP:
|
if step >= MIN_GRID_STEP:
|
||||||
|
|||||||
Reference in New Issue
Block a user