Wiresheet: keep off-sheet input knobs on the sheet
A box with a link arriving from another sheet draws a knob on its left edge. Tidy Layout moves the first column one grid step in when any of its boxes has one, and dragging and arrow nudges stop such a box one step inside the margin, so the knob never sits out in the grey. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2135,14 +2135,17 @@ def on_canvas_drag(event):
|
||||
dy = cy - app_state.drag_data["y"]
|
||||
xs = [entry["origin"][0] for entry in group]
|
||||
ys = [entry["origin"][1] for entry in group]
|
||||
dx = min(limit - max(xs), max(margin - min(xs), dx))
|
||||
# A box with an off-sheet input stops a step further in, keeping its knob on the sheet.
|
||||
left = wiresheet.box_left_limits([entry["tag"] for entry in group], margin, step)
|
||||
dx = min(limit - max(xs),
|
||||
max(max(left[e["tag"]] - e["origin"][0] for e in group), dx))
|
||||
dy = min(limit - max(ys), max(margin - min(ys), dy))
|
||||
|
||||
shifted = False
|
||||
for entry in group:
|
||||
# Land each box on a step every step of the way.
|
||||
start_x, start_y = entry["origin"]
|
||||
target_x = min(limit, max(margin, round((start_x + dx) / step) * step))
|
||||
target_x = min(limit, max(left[entry["tag"]], round((start_x + dx) / step) * step))
|
||||
target_y = min(limit, max(margin, round((start_y + dy) / step) * step))
|
||||
origin = wiresheet.get_box_origin(entry["tag"])
|
||||
if origin is None:
|
||||
@@ -2178,6 +2181,7 @@ def on_canvas_release(event):
|
||||
|
||||
changes = []
|
||||
failed = []
|
||||
left = wiresheet.box_left_limits([entry["tag"] for entry in group], margin, step)
|
||||
for entry in group:
|
||||
group_tag = entry["tag"]
|
||||
origin = wiresheet.get_box_origin(group_tag)
|
||||
@@ -2185,7 +2189,7 @@ def on_canvas_release(event):
|
||||
continue
|
||||
current_x, current_y = origin
|
||||
|
||||
snapped_x = min(limit, max(margin, round(current_x / step) * step))
|
||||
snapped_x = min(limit, max(left[group_tag], round(current_x / step) * step))
|
||||
snapped_y = min(limit, max(margin, round(current_y / step) * step))
|
||||
|
||||
shift_x = snapped_x - current_x
|
||||
@@ -2255,9 +2259,11 @@ def nudge_selected_boxes(dx, dy):
|
||||
origins = {t: wiresheet.get_box_origin(t) for t in tags}
|
||||
if any(o is None for o in origins.values()):
|
||||
return "break"
|
||||
# The group stops as one at the margin strip and the sheet's far edge.
|
||||
# The group stops as one at the margin strip and the sheet's far edge; a box with an
|
||||
# off-sheet input stops a step further in, keeping its knob on the sheet.
|
||||
left = wiresheet.box_left_limits(tags, margin, step)
|
||||
shift_x = min(limit - max(o[0] for o in origins.values()),
|
||||
max(margin - min(o[0] for o in origins.values()), dx * step))
|
||||
max(max(left[t] - o[0] for t, o in origins.items()), dx * step))
|
||||
shift_y = min(limit - max(o[1] for o in origins.values()),
|
||||
max(margin - min(o[1] for o in origins.values()), dy * step))
|
||||
if not shift_x and not shift_y:
|
||||
|
||||
Reference in New Issue
Block a user