Skip to content

Commit 5b02ed3

Browse files
committed
BaseNode: allow negative node IDs in self-reporting
Change the geometry reporting guard from `node-id > 0` to `node-id != 0`. The guard exists to skip reporting during Slint's default initialization (node-id defaults to 0 before the parent binds the real ID). Negative IDs are valid for viewport-anchored nodes like edge ports, which previously couldn't self-report and required manual Rust-side position seeding.
1 parent 5057b03 commit 5b02ed3

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

node-editor-building-blocks.slint

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,15 +509,17 @@ export component BaseNode inherits Rectangle {
509509
background: transparent;
510510
clip: false;
511511

512-
// Report rect on changes (in WORLD coordinates - without offset)
512+
// Report rect on changes (in WORLD coordinates - without offset).
513+
// Guard against node-id == 0 (Slint default before parent binds the real ID).
514+
// Negative IDs are valid (e.g. viewport-anchored edge ports).
513515
init => {
514-
if (node-id > 0) {
516+
if (node-id != 0) {
515517
NodeEditorInternalCallbacks.report-node-rect(node-id, world-pos-x, world-pos-y, node-width, node-height);
516518
}
517519
}
518520

519521
changed node-id => {
520-
if (node-id > 0) {
522+
if (node-id != 0) {
521523
NodeEditorInternalCallbacks.report-node-rect(node-id, world-pos-x, world-pos-y, node-width, node-height);
522524
}
523525
}
@@ -534,24 +536,24 @@ export component BaseNode inherits Rectangle {
534536
}
535537
}
536538
changed node-width => {
537-
if (node-id > 0) {
539+
if (node-id != 0) {
538540
NodeEditorInternalCallbacks.report-node-rect(node-id, world-pos-x, world-pos-y, node-width, node-height);
539541
}
540542
}
541543
changed node-height => {
542-
if (node-id > 0) {
544+
if (node-id != 0) {
543545
NodeEditorInternalCallbacks.report-node-rect(node-id, world-pos-x, world-pos-y, node-width, node-height);
544546
}
545547
}
546-
548+
547549
// Watch world-pos-x/y for live link updates during multi-node drag
548550
changed world-pos-x => {
549-
if (node-id > 0) {
551+
if (node-id != 0) {
550552
NodeEditorInternalCallbacks.report-node-rect(node-id, world-pos-x, world-pos-y, node-width, node-height);
551553
}
552554
}
553555
changed world-pos-y => {
554-
if (node-id > 0) {
556+
if (node-id != 0) {
555557
NodeEditorInternalCallbacks.report-node-rect(node-id, world-pos-x, world-pos-y, node-width, node-height);
556558
}
557559
}

0 commit comments

Comments
 (0)