Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LR-PREF-GENERAL: Keep the Settings window in place when switching tabs

Michael Anderson8283ae1687e9
diff --git a/crates/ui-egui/src/headless.rs b/crates/ui-egui/src/headless.rs
index 0507ab31f..3af6f50a0 100644
--- a/crates/ui-egui/src/headless.rs
+++ b/crates/ui-egui/src/headless.rs
@@ -2948,6 +2948,29 @@ mod tests {
let _ = std::fs::remove_dir_all(&dir);
}
+ /// Switching Settings tabs keeps the window's top edge (and its tab row) where it is and never makes it
+ /// narrower, though the tabs are of different heights and widths.
+ #[test]
+ fn settings_tabs_keep_the_window_in_place() {
+ let mut h = demo([1300.0, 820.0]);
+ let t = Duration::from_secs(10);
+ let window = |h: &Headless| h.app.widgets.iter().find(|(w, _)| w == "dialog:window").map(|(_, r)| *r).expect("the dialog");
+ let r = h.request("engine.execute", json!({"command": "app.settings", "params": {"tab": "general"}}), t);
+ assert_eq!(r["ok"], true, "{r}");
+ h.settle(SETTLE);
+ let first = window(&h);
+ let mut heights = Vec::new();
+ for tab in ["display", "import", "performance", "general", "interface", "display"] {
+ h.request("ui.clickWidget", json!({"id": format!("button:settingsTab-{tab}")}), t);
+ h.settle(SETTLE);
+ let now = window(&h);
+ assert!((now.top() - first.top()).abs() < 1.0, "{tab}: top {} → {}", first.top(), now.top());
+ assert!(now.width() >= first.width() - 1.0, "{tab}: width {} → {}", first.width(), now.width());
+ heights.push(now.height());
+ }
+ assert!(heights.iter().any(|h| (h - first.height()).abs() > 20.0), "the tabs differ in height: {heights:?}");
+ }
+
/// The folder scan runs in the background: the request returns at once and the review opens
/// when the scan finishes (a folder on a network share must not freeze the window).
/// Clicking the folder being read again keeps the running read (and its progress).
diff --git a/crates/ui-egui/src/panels/dialogs.rs b/crates/ui-egui/src/panels/dialogs.rs
index a79261fdc..a76795d58 100644
--- a/crates/ui-egui/src/panels/dialogs.rs
+++ b/crates/ui-egui/src/panels/dialogs.rs
@@ -276,7 +276,16 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
// previous frame (a guess on the first one).
let chrome_id = window_id.with("chrome");
let chrome = ctx.data(|d| d.get_temp::<f32>(chrome_id)).unwrap_or(DIALOG_CHROME_GUESS);
- let body_max = (screen.height() - 2.0 * DIALOG_SCREEN_MARGIN - chrome).max(DIALOG_MIN_BODY);
+ // Settings keeps its top edge, and the widest it has been, while tabs of different sizes are shown, so its tab
+ // row stays where it is (centred like the others, the row jumped with each tab's height)
+ let settings = matches!(dlg, Dialog::Settings { .. });
+ let top = (screen.height() * 0.08).clamp(DIALOG_SCREEN_MARGIN, 96.0);
+ let body_max =
+ if settings { screen.height() - top - DIALOG_SCREEN_MARGIN - chrome } else { screen.height() - 2.0 * DIALOG_SCREEN_MARGIN - chrome }
+ .max(DIALOG_MIN_BODY);
+ let widest_id = window_id.with("widest");
+ let widest = if settings { ctx.data(|d| d.get_temp::<f32>(widest_id)).unwrap_or(0.0).min(screen.width() * 0.9) } else { 0.0 };
+ let mut content_w = 0.0f32;
let mut body_h = None;
let shown = egui::Window::new(crate::i18n::tr(&title)).id(window_id)
.collapsible(false)
@@ -284,7 +293,8 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
.vscroll(import)
.resize(|r| if import { r.default_height(crate::import::DIALOG_SIZE[1]) } else { r })
.frame(frame)
- .anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
+ .anchor(if settings { egui::Align2::CENTER_TOP } else { egui::Align2::CENTER_CENTER }, [0.0, if settings { top } else { 0.0 }])
+ .min_width(widest)
.default_width(match dlg {
Dialog::Import { .. } => crate::import::DIALOG_SIZE[0],
Dialog::SmartRules { .. } => 680.0,
@@ -1273,7 +1283,11 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
if import {
crate::import::note_dialog_bottom(ui);
}
+ content_w = ui.min_rect().width();
});
+ if settings && content_w > widest + 0.5 {
+ ctx.data_mut(|d| d.insert_temp(widest_id, content_w));
+ }
if let Some(w) = shown {
ctx.memory_mut(|m| m.set_modal_layer(w.response.layer_id));
if let Some(body_h) = body_h {
diff --git a/docs/whats-new.md b/docs/whats-new.md
index 1bf44c3f4..891f72748 100644
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@ -2,6 +2,10 @@
## 2026-10-14
+### Settings stays put when you change tabs
+- The Settings window keeps its top edge and width when you switch tabs, so the tab row no longer jumps around
+ under the pointer. It used to be centred, so every tab of a different height moved it.
+
### Hard-edged Heal and Clone spots
- A spot with Feather at 0 no longer draws black pixels exactly on its radius. This also fixes spots at 0% Opacity
changing pixels along their edge. The hard edge now leaves pixels on the radius unchanged.