1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! The Edit sub-tab's resizable-dock/collapsible-section layout: applying the
//! persisted values to `EditorModel` at startup ([`apply_editor_layout_from_settings`])
//! and writing them back on every change ([`setup_editor_layout_callbacks`]). Split out
//! of `gui::mod`/`gui::startup_settings` purely to keep this one layout-persistence
//! concern in its own file -- the same reasoning `window_sizing` and `startup_settings`
//! themselves already document.
//!
//! `EditorModel` itself is a plain Slint global, always compiled in.
use crate::;
use ComponentHandle;
use Arc;
/// Raised floor for the inspector's height while the user has never touched the Edit
/// sub-tab's layout -- taller than `AppSettings::DEFAULT_EDITOR_INSPECTOR_HEIGHT`
/// (340px) so the Tier tab's `ScrollView` fold holds the title plus the Angle, Meets,
/// Name and Indices rows: the Save/Add Tier row is pinned OUTSIDE that `ScrollView`, so
/// it costs the fold roughly 36px on top of the tab header and metrics strip. Applied
/// in [`apply_editor_layout_from_settings`] only while `editor_layout_touched` is
/// `false`; once a user has ever dragged the table|inspector split themselves (or a
/// smaller screen has narrowed it, see `window_sizing`), their own value is trusted
/// verbatim and never raised.
const FIRST_RUN_INSPECTOR_HEIGHT: f32 = 380.0;
/// Applies the Edit sub-tab's persisted dock width / inspector height / section
/// collapsed-states to `EditorModel`. Called once at startup, right after
/// `startup_settings::apply_loaded_settings` and before
/// [`setup_editor_layout_callbacks`] wires `on_layout_changed`.
///
/// This does NOT keep this initial push from racing a save of the very values it
/// is restoring -- it does, whenever [`FIRST_RUN_INSPECTOR_HEIGHT`] actually
/// raises `inspector_height` above the on-disk value (a fresh settings file):
/// the assignments below only QUEUE `EditorModel`'s own `changed` handlers, so the resulting
/// `EditorModel.layout_changed()` does not actually fire until the main window's
/// first `show()`/tree flush, indistinguishable, from `on_layout_changed`'s own
/// point of view, from the cutter dragging a split handle in the first instant
/// the window was visible. [`setup_editor_layout_callbacks`] guards against this
/// directly (see its own doc comment) rather than relying on call order here.
pub
/// Wires `EditorModel.layout_changed` (fired by `ui/models/editor.slint` on every
/// change to `dock_width`/`inspector_height`/`settings_collapsed`/
/// `inspector_collapsed`/`tier_table_collapsed`/`remap_collapsed`) to persist all six through the same
/// debounced writer every other durable setting in `gui::mod::build_main_window` goes
/// through -- the same shape as that function's own `on_panel_collapsed_changed`.
///
/// Also marks `AppSettings::editor_layout_touched`, so `window_sizing`'s per-screen
/// inspector-collapse default never overrides a layout the user has ever adjusted
/// themselves -- once touched, it stays touched (nothing in this crate ever resets it
/// back to `false`).
///
/// Skips this entirely the FIRST time `on_layout_changed` fires: that first firing
/// is always the flush of [`apply_editor_layout_from_settings`]'s own startup push
/// (see that function's own doc comment), never a real user action -- no user
/// input reaches this window before its first `show()`, and that flush is
/// guaranteed to happen at or before it. Without this, a from-disk
/// `editor_layout_touched: false` (a fresh install, or one that has never had its
/// layout touched) would flip permanently `true` on every single launch, purely
/// because [`FIRST_RUN_INSPECTOR_HEIGHT`] differs from the compiled default --
/// never recording a real user action, but persisting as if it had, and
/// permanently defeating `window_sizing`'s small-screen default from the second
/// launch on.
pub