Properties view: every slot of a component, edited in the editor pane

Right-click a component on the wiresheet or in the tree and Properties takes
over the editor pane, listing every slot the manifest declares rather than the
handful a box paints. Config slots that are not @readonly are white and
editable; everything else is grey.

Rows are built from the slot's facets, read against SedonaDoc/niagara.html:
@trueText/@falseText, @range, @precision, @unit, and @min/@max, which bound
what Save accepts. Three facets it had wrong:

  - null is a value, not an absence. control::WriteFloat pairs 'in' with a
    setNull action and the sample app stores val="null" on four of them, so
    null now shows, parses back, and reads as @nullText where declared.
  - @min/@max on a Buf count characters. TcpDevice.ipAddr is a Buf(17) with
    @max 16; a longer string is refused rather than overrunning the device.
  - an int's implicit range is noise. [-2147483648 - 2147483647] said no more
    than "a whole number", so only byte and short print a range they did not
    declare.

meta gets a row of its own: the '>>' opens its user groups as checkboxes and
its position as x and y, since typing 822411269 into a field sets neither.

Save writes only the rows that moved, as one undoable SlotValueCommand, and
refuses the lot if any row fails its range check. An edited field paints the
view in the canvas's own dirty tint, and every way of leaving asks before
discarding.

The file name on the tree's root row goes red while anything is unwritten,
counting both a dirty document and unsaved fields. Two things this needed:
the nav tree runs on its own style, because a themed Treeview's selected
foreground beats a row tag's; and the tag is added to or removed from the row
rather than recoloured, because reconfiguring a tag does not repaint rows that
are already drawn.

Also fixes a latent hazard the panel exposed: Del and Backspace are bound
application-wide, so they now stand down while a text field has focus rather
than deleting the component behind it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-05 23:38:03 +03:00
co-authored by Claude Opus 5
parent 5fde6473a0
commit 2db230dec1
8 changed files with 1675 additions and 15 deletions
+31 -1
View File
@@ -8,7 +8,7 @@ import graph free of cycles (sax_file and wiresheet both push commands here).
import app_state
import palette
import schema
from sax_dom import restore_children, update_meta_property
from sax_dom import remove_prop, restore_children, set_prop_value, update_meta_property
_undo_stack = []
_redo_stack = []
@@ -137,6 +137,36 @@ class MetaMoveCommand:
update_meta_property(element, old_val, new_x, new_y)
class SlotValueCommand:
"""One Save from the Properties dialog: every slot it changed, as one undoable step.
A change is recorded as the <prop>'s value before and after, with None standing for
"the file had no such prop". Undoing back to None removes the prop again rather than
writing the default out, so a component that only ever carried the props the file
shipped with still carries exactly those.
"""
def __init__(self, changes, label="edit properties"):
# changes: list of (element, prop_name, old_val_or_None, new_val_or_None)
self.changes = changes
self.label = label
def _apply(self, value_index):
for change in self.changes:
element, prop_name = change[0], change[1]
value = change[value_index]
if value is None:
remove_prop(element, prop_name)
else:
set_prop_value(element, prop_name, value)
def undo(self):
self._apply(2)
def redo(self):
self._apply(3)
class AddComponentCommand:
"""Placing a component.