Wire the develop panels through globals, so a second copy is one line

Every panel in the develop column declared its inputs and its callbacks and
had `app.slint` bind each one to a property or a callback on the window root.
That is fine while a panel is drawn once. N9 draws them a second time, in the
portrait dock, and the wiring is what would have to be copied: `MaskPanel`
alone ran to forty lines of forwarding, and a callback added to one copy and
not the other compiles, renders, and simply does nothing on the layout nobody
was looking at.

So the wiring moved to Slint globals. A panel reads the global and calls the
global; Rust hooks the global instead of the window; and the instantiation in
the column is now the panel's name and a pair of braces — every one of the ten
children of the column, with no property that differs by placement left to
supply.

There is a global per panel family rather than one for all of them, and the
reason is an import cycle. Each panel's model struct — `ParamRow`, `MaskRow`,
`HistogramView` — is declared in the panel's own file, so a single global
holding `[MaskRow]` and `[ParamRow]` would have to live in a file importing
`masks.slint` and `adjust.slint` while both imported the global back, which
Slint rejects. Breaking that needs six model declarations relocated, which is a
change to the data model and not to the plumbing this is about. A global beside
the panel it serves also lets each name drop the prefix it was carrying only
because the window root is one flat namespace: `root.spot-radius` is
`Repair.radius`, and `root.peaking-on` is `Peaking.showing`.

`session.slint` is new and holds the two facts every family needs and none of
them owns: whether there is an open photograph to edit, and which mode the view
is in, with the three readings of the mode derived once instead of at each of
the dozen places that tested one. `ViewMode` moves there from `adjust.slint`,
where it was only ever a lodger.

Nothing on screen changes. What is not here: the tool rail and the status strip
still take their properties at the instantiation, because they are drawn once
and N9 does not copy them; the preset sheet's own state stays on the window,
because the library grid opens the same sheet and a global cannot bind the
window's state — which is why `Transfer.open-presets` is handled in
`presets.rs`, beside the summary it already had to compute.
This commit is contained in:
2026-09-07 20:01:01 +02:00
parent dd14243dba
commit 0a5eab0487
17 changed files with 1245 additions and 1341 deletions
+32 -16
View File
@@ -18,6 +18,7 @@
// rather than decorative.
import { Theme } from "theme.slint";
import { Develop } from "session.slint";
import { PanelHeading, Caption, Label, Value, Button } from "widgets.slint";
// One step, flattened for Slint's model system.
@@ -88,9 +89,22 @@ component StepRow inherits Rectangle {
}
}
export component HistoryPanel inherits Rectangle {
/// TRACES: FR-DEV-5
/// The edit as a stack of steps, and the two ways of moving through it.
///
/// A global rather than five properties and three callbacks on the panel — see
/// `session.slint` for the argument. The status strip and the keyboard reach
/// the same two actions; before this all three spellings went through the
/// window root and had to be kept in step by hand.
///
/// Rust owns whether there is anywhere to step, because "anywhere" is a
/// position in a stack of snapshots this side never sees. A whole drag is one
/// step; the coalescing that makes it so lives in `dr-pipeline`.
export global Steps {
/// Every step, newest first. Rust owns the order and stamps each row with
/// its own position in the stack, so nothing here does arithmetic to turn
/// a row back into a step.
in property <[HistoryRow]> rows;
in property <bool> enabled: true;
in property <bool> can-undo: false;
in property <bool> can-redo: false;
/// What undo would take back, already resolved. Empty when there is
@@ -101,7 +115,9 @@ export component HistoryPanel inherits Rectangle {
callback redo();
/// A row's own `index`, not its position in `rows`.
callback picked(int);
}
export component HistoryPanel inherits Rectangle {
background: Theme.surface;
// **Flat, deliberately** — `MaskPanel` carries the long version of this
@@ -127,32 +143,32 @@ export component HistoryPanel inherits Rectangle {
HorizontalLayout {
PanelHeading { text: "HISTORY"; }
Rectangle { horizontal-stretch: 1; }
if root.enabled && root.rows.length > 1: Value {
text: root.rows.length - 1 + (root.rows.length == 2 ? " step" : " steps");
if Develop.enabled && Steps.rows.length > 1: Value {
text: Steps.rows.length - 1 + (Steps.rows.length == 2 ? " step" : " steps");
}
}
if !root.enabled: Caption { text: "No image"; }
if !Develop.enabled: Caption { text: "No image"; }
// The pair, here as well as in the status strip. The strip's copy is
// the one that survives the column being put away; this one sits
// against the list that says what it will do, which is the pairing
// that makes either of them legible.
if root.enabled: HorizontalLayout {
if Develop.enabled: HorizontalLayout {
spacing: Theme.gap-sm;
Button {
text: "Undo";
enabled: root.can-undo;
enabled: Steps.can-undo;
horizontal-stretch: 1;
clicked => { root.undo(); }
clicked => { Steps.undo(); }
}
Button {
text: "Redo";
enabled: root.can-redo;
enabled: Steps.can-redo;
horizontal-stretch: 1;
clicked => { root.redo(); }
clicked => { Steps.redo(); }
}
}
@@ -168,12 +184,12 @@ export component HistoryPanel inherits Rectangle {
// the one the photographer is standing on and stopped tracking after a
// run of small adjustments, which is the moment they are least willing
// to press a button to find out.
if root.enabled && root.can-undo: Caption {
text: "Undo: " + root.undo-label;
if Develop.enabled && Steps.can-undo: Caption {
text: "Undo: " + Steps.undo-label;
overflow: elide;
}
if root.enabled && root.rows.length > 0: Rectangle {
if Develop.enabled && Steps.rows.length > 0: Rectangle {
height: 1px;
background: Theme.rule;
}
@@ -183,10 +199,10 @@ export component HistoryPanel inherits Rectangle {
// `dr_catalog::trash` settled on for the same question — and it keeps
// the end being worked at against the heading rather than sixty-four
// rows below it.
for row in root.rows: StepRow {
for row in Steps.rows: StepRow {
data: row;
enabled: root.enabled;
picked => { root.picked(row.index); }
enabled: Develop.enabled;
picked => { Steps.picked(row.index); }
}
}
}