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:
+30
-10
@@ -40,7 +40,7 @@ use slint::ComponentHandle;
|
||||
|
||||
use crate::develop::DevelopSession;
|
||||
use crate::preset_store::PresetStore;
|
||||
use crate::{library, library_ui, settings_ui, AppWindow, ParamRow, ScopeKind};
|
||||
use crate::{library, library_ui, settings_ui, AppWindow, ParamRow, ScopeKind, Steps, Transfer};
|
||||
|
||||
/// Where the develop view's current edit is stored.
|
||||
///
|
||||
@@ -502,8 +502,8 @@ fn refresh_thumbnail_for(
|
||||
session: &Rc<RefCell<Option<DevelopSession>>>,
|
||||
library: &Rc<library_ui::LibraryController>,
|
||||
) {
|
||||
let worth_it =
|
||||
window.get_can_undo() || session.borrow().as_ref().is_some_and(|s| !s.is_neutral());
|
||||
let worth_it = window.global::<Steps>().get_can_undo()
|
||||
|| session.borrow().as_ref().is_some_and(|s| !s.is_neutral());
|
||||
if !worth_it {
|
||||
return;
|
||||
}
|
||||
@@ -557,12 +557,13 @@ pub fn render(
|
||||
settings: &Rc<settings_ui::SettingsController>,
|
||||
) {
|
||||
let scope = scope_for(&settings.snapshot());
|
||||
window.set_settings_armed(clipboard.is_armed());
|
||||
window.set_settings_summary(clipboard.describe(scope).into());
|
||||
let transfer = window.global::<Transfer>();
|
||||
transfer.set_armed(clipboard.is_armed());
|
||||
transfer.set_summary(clipboard.describe(scope).into());
|
||||
// Only worth saying when it is actually true of *this* copy: a clipboard
|
||||
// holding no crop loses nothing to the setting, and saying so anyway would
|
||||
// train the user to ignore the line.
|
||||
window.set_settings_framing_withheld(
|
||||
transfer.set_framing_withheld(
|
||||
clipboard.holds_framing() && !scope.has(dr_pipeline::Attribute::Compose),
|
||||
);
|
||||
}
|
||||
@@ -603,7 +604,7 @@ pub fn wire(
|
||||
let clipboard = clipboard.clone();
|
||||
let session = session.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_copy_settings(move || {
|
||||
window.global::<Transfer>().on_copy(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
if let Some(s) = session.borrow().as_ref() {
|
||||
clipboard.copy_from(s);
|
||||
@@ -622,7 +623,7 @@ pub fn wire(
|
||||
let redraw = redraw.clone();
|
||||
let open = open.clone();
|
||||
let library = library.clone();
|
||||
window.on_paste_settings(move || {
|
||||
window.global::<Transfer>().on_paste(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(preset) = clipboard.peek() else {
|
||||
return;
|
||||
@@ -933,11 +934,22 @@ pub fn wire_named(
|
||||
});
|
||||
}
|
||||
|
||||
// --- what saving would capture ----------------------------------------
|
||||
// --- opening the sheet over the open photograph -----------------------
|
||||
//
|
||||
// The develop column's "Presets…" button, and everything opening the sheet
|
||||
// from there means. It used to be four lines inside the panel's
|
||||
// instantiation in `app.slint`, which is exactly the sort of behaviour a
|
||||
// second drawing of that panel would have had to copy; `Transfer` is a
|
||||
// global and a global cannot bind the window's own state, so it lands
|
||||
// here instead — where the summary it also has to compute already lived.
|
||||
//
|
||||
// The grid opens the same sheet with its own count and no capture summary,
|
||||
// still from `app.slint`: nothing there is worth saving, so `can-save` is
|
||||
// false and the summary would describe an edit that is not in hand.
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let session = session.clone();
|
||||
window.on_presets_opened(move || {
|
||||
window.global::<Transfer>().on_open_presets(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
// At the scope a save would use, which is full: a preset keeps
|
||||
// the framing it was captured with and drops it at apply time.
|
||||
@@ -947,6 +959,14 @@ pub fn wire_named(
|
||||
.map(|s| describe(&s.copy_settings(), Scope::everything()))
|
||||
.unwrap_or_default();
|
||||
w.set_preset_capture_summary(summary.into());
|
||||
// Opened with no count, which is what tells the apply handler this
|
||||
// means the open photograph rather than a selection.
|
||||
w.set_preset_apply_count(0);
|
||||
// `crate::Develop` spelled out: this module has a `Develop` of its
|
||||
// own, and it is the bundle of session handles below, not the
|
||||
// interface global.
|
||||
w.set_preset_can_save(w.global::<crate::Develop>().get_enabled());
|
||||
w.set_presets_open(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user