Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

fix(ui): restore extras when showing the grid (#8962)

skylar taylor-barrick2d9640bb0b34
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 709a42583..e9721b765 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -546,6 +546,10 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id:
};
*slot = !*slot;
let on = *slot;
+ if id == "view.show.grid" && on {
+ // Like the other Show items, enabling Grid also restores hidden Extras.
+ app.ui.view.extras = true;
+ }
if id == "view.rulers" {
crate::prefs_ui::remember_rulers(app, on);
}
@@ -1646,6 +1650,27 @@ pub fn apply_workspace(app: &mut PhotocraftApp) {
mod tests {
use super::*;
+ #[test]
+ fn showing_grid_restores_hidden_extras() {
+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());
+ let ctx = egui::Context::default();
+ app.ui.extras.grid = false;
+ app.ui.view.extras = false;
+
+ assert_eq!(invoke(&mut app, &ctx, "view.show.grid", json!({})).unwrap(), json!(true));
+ assert_eq!(checked(&app, "view.show.grid"), Some(true));
+ assert!(app.ui.view.extras, "showing Grid must make the overlay visible when Extras was hidden");
+
+ assert_eq!(invoke(&mut app, &ctx, "view.show.grid", json!({})).unwrap(), json!(false));
+ assert!(!app.ui.extras.grid);
+ assert!(app.ui.view.extras);
+
+ app.ui.extras.grid = true;
+ app.ui.view.extras = false;
+ assert_eq!(invoke(&mut app, &ctx, "view.show.grid", json!({})).unwrap(), json!(false));
+ assert!(!app.ui.view.extras, "hiding Grid must leave hidden Extras alone");
+ }
+
#[test]
fn sync_with_system_menu_keeps_saved_slots_and_its_checkmark_across_palettes() {
use photocraft_engine::prefs::{AppearanceMode, DarkTheme, LightTheme};