diff --git a/crates/ui-egui/src/dock_tests.rs b/crates/ui-egui/src/dock_tests.rs index eababef2be6..a7718ddccfe 100644 --- a/crates/ui-egui/src/dock_tests.rs +++ b/crates/ui-egui/src/dock_tests.rs @@ -566,3 +566,35 @@ fn dock_strips_fit_and_the_chevron_menu_switches_tabs() { h.run_steps(3); assert_eq!(*h.state(), 3, "Patterns chosen from the chevron menu"); } + +#[test] +fn tab_hides_all_panels_and_shift_tab_only_the_dock() { + // #1313: Photoshop's Tab hides the Tools panel, the options bar and the panel dock (Tab again + // brings back what it hid); ⇧Tab hides and shows the dock alone. + let (mut app, _, _) = app_with_layers(); + let ctx = egui::Context::default(); + let run = |app: &mut PhotocraftApp, id: &str| crate::menus::invoke(app, &ctx, id, json!({})).unwrap(); + app.ui.panels.options_bar = false; + run(&mut app, "window.togglePanels"); + let p = &app.ui.panels; + assert!(!p.toolbar && !p.options_bar && !p.dock); + run(&mut app, "window.togglePanels"); + let p = &app.ui.panels; + assert!(p.toolbar && !p.options_bar && p.dock, "Tab brings back only what it hid"); + run(&mut app, "window.toggle.dock"); + assert!(!app.ui.panels.dock && app.ui.panels.toolbar, "⇧Tab hides only the dock"); + run(&mut app, "window.toggle.dock"); + assert!(app.ui.panels.dock); + // Everything hidden by hand: Tab shows it all. + (app.ui.panels.toolbar, app.ui.panels.options_bar, app.ui.panels.dock) = (false, false, false); + run(&mut app, "window.togglePanels"); + assert!(app.ui.panels.toolbar && app.ui.panels.options_bar && app.ui.panels.dock); + // The keys are Photoshop's. + let bound = |key: &str| crate::shortcut_dispatch::bindings(&app).into_iter().find(|(_, sc)| Some(*sc) == crate::shortcuts::parse(key)).map(|(id, _)| id); + assert_eq!(bound("Tab").as_deref(), Some("window.togglePanels")); + assert_eq!(bound("Shift+Tab").as_deref(), Some("window.toggle.dock")); + // An older saved UI state without the field shows the dock. + let mut v = serde_json::to_value(crate::state::Panels::default()).unwrap(); + v.as_object_mut().unwrap().remove("dock"); + assert!(serde_json::from_value::(v).unwrap().dock); +} diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 0e95bc5ac77..eca6a939f77 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -2163,6 +2163,8 @@ cameraRaw Color Barvy Channels: Kanály: Knockout Vyřazení Apply At Canvas Bounds Použít efekt na hranicích plátna + Show/Hide All Panels Zobrazit/skrýt všechny panely + Show/Hide Panels Zobrazit/skrýt panely Could not open Nelze otevřít {path}: the path is not valid Unicode; rename the file and open it again. {path}: cesta není platný Unicode; přejmenujte soubor a otevřete jej znovu. diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 3e41e5d9e30..400dd0c5860 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2203,6 +2203,8 @@ Channels: Kanäle: Knockout Aussparung Apply At Canvas Bounds Effekt an Arbeitsflächenbegrenzungen anwenden + Show/Hide All Panels Alle Bedienfelder ein-/ausblenden + Show/Hide Panels Bedienfelder ein-/ausblenden Could not open Öffnen nicht möglich {path}: the path is not valid Unicode; rename the file and open it again. {path}: Der Pfad ist kein gültiges Unicode; benennen Sie die Datei um und öffnen Sie sie erneut. diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 840ff8304b1..f967e48aa68 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2234,6 +2234,8 @@ cameraRaw Amount Cantidad Channels: Canales: Knockout Cobertura Apply At Canvas Bounds Aplicar efecto en los límites del lienzo + Show/Hide All Panels Mostrar/ocultar todos los paneles + Show/Hide Panels Mostrar/ocultar paneles Could not open No se pudo abrir {path}: the path is not valid Unicode; rename the file and open it again. {path}: la ruta no es Unicode válido; cambia el nombre del archivo y vuelve a abrirlo. diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index a37c383d9d4..7fb027b2314 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2594,6 +2594,8 @@ cameraRaw Blending Fusion Channels: Couches : Knockout Masquage Apply At Canvas Bounds Appliquer l’effet aux limites de la zone de travail + Show/Hide All Panels Afficher/masquer tous les panneaux + Show/Hide Panels Afficher/masquer les panneaux Could not open Impossible d’ouvrir {path}: the path is not valid Unicode; rename the file and open it again. {path} : le chemin n’est pas un Unicode valide ; renommez le fichier puis rouvrez-le. diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index af653b21f30..5b76c883d28 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -2581,6 +2581,8 @@ cameraRaw Blending Pembauran Channels: Channel: Knockout Knockout Apply At Canvas Bounds Terapkan efek di batas kanvas + Show/Hide All Panels Tampilkan/Sembunyikan Semua Panel + Show/Hide Panels Tampilkan/Sembunyikan Panel Could not open Tidak dapat membuka {path}: the path is not valid Unicode; rename the file and open it again. {path}: jalur bukan Unicode yang valid; ganti nama file lalu buka lagi. diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 69ae7fa53a8..4cfaf759dc7 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2237,6 +2237,8 @@ cameraRaw Amount Quantità Add to Swatches Aggiungi ai campioni Convert to Layers Converti in livelli Apply At Canvas Bounds Applica effetto ai limiti dell’area di lavoro + Show/Hide All Panels Mostra/nascondi tutti i pannelli + Show/Hide Panels Mostra/nascondi pannelli Could not open Impossibile aprire {path}: the path is not valid Unicode; rename the file and open it again. {path}: il percorso non è Unicode valido; rinomina il file e riaprilo. diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index c9f725d63d8..54680ac2721 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -2146,6 +2146,8 @@ cameraRaw Color カラー Channels: チャンネル: Knockout ノックアウト Apply At Canvas Bounds カンバスの境界に効果を適用 + Show/Hide All Panels すべてのパネルを表示/非表示 + Show/Hide Panels パネルを表示/非表示 Could not open 開けませんでした {path}: the path is not valid Unicode; rename the file and open it again. {path}: パスが有効な Unicode ではありません。ファイル名を変更してから開き直してください。 diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 1cf49d392b2..242b3e4b346 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -2753,6 +2753,8 @@ cameraRaw Color 색상 Channels: 채널: Knockout 녹아웃 Apply At Canvas Bounds 캔버스 경계에 효과 적용 + Show/Hide All Panels 모든 패널 표시/숨기기 + Show/Hide Panels 패널 표시/숨기기 Could not open 열 수 없음 {path}: the path is not valid Unicode; rename the file and open it again. {path}: 경로가 올바른 유니코드가 아닙니다. 파일 이름을 바꾼 뒤 다시 여세요. Good 좋음 diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 25c29649420..401fa245f6d 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3194,6 +3194,8 @@ cameraRaw Roughness Chropowatość More documents Więcej dokumentów Developing {name} Wywoływanie {name} Camera Raw ({name}) Camera Raw ({name}) + Show/Hide All Panels Pokaż/ukryj wszystkie panele + Show/Hide Panels Pokaż/ukryj panele Could not open Nie można otworzyć {path}: the path is not valid Unicode; rename the file and open it again. {path}: ścieżka nie jest prawidłowym Unicode; zmień nazwę pliku i otwórz go ponownie. Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Natywne przeciąganie i upuszczanie plików nie jest jeszcze obsługiwane w Wayland. Użyj Plik › Otwórz albo skopiuj obraz w menedżerze plików i wklej go za pomocą {paste}. diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 4111d3250df..03d21052999 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2601,6 +2601,8 @@ cameraRaw Whites Brancos Channels: Canais: Knockout Vazado Apply At Canvas Bounds Aplicar efeito nos limites da tela + Show/Hide All Panels Mostrar/ocultar todos os painéis + Show/Hide Panels Mostrar/ocultar painéis Could not open Não foi possível abrir {path}: the path is not valid Unicode; rename the file and open it again. {path}: o caminho não é Unicode válido; renomeie o arquivo e abra-o novamente. diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 8dae0f1af5c..c43191e1d96 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2440,6 +2440,8 @@ cameraRaw Roughness Неровность Channels: Каналы: Knockout Просвечивание Apply At Canvas Bounds Применить эффект на границах холста + Show/Hide All Panels Показать/скрыть все панели + Show/Hide Panels Показать/скрыть панели Could not open Не удалось открыть {path}: the path is not valid Unicode; rename the file and open it again. {path}: путь не является допустимым Unicode; переименуйте файл и откройте его снова. diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 84f1a0ca85e..8d5be1c4a7e 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2171,6 +2171,8 @@ cameraRaw Blending 混合 Channels: 通道: Knockout 挖空 Apply At Canvas Bounds 应用画布边界的效果 + Show/Hide All Panels 显示/隐藏所有面板 + Show/Hide Panels 显示/隐藏面板 Could not open 无法打开 {path}: the path is not valid Unicode; rename the file and open it again. {path}:路径不是有效的 Unicode;请重命名文件后再打开。 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 285ec44075f..0285902e967 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2140,6 +2140,8 @@ cameraRaw Blending 混合 Channels: 色版: Knockout 去底色 Apply At Canvas Bounds 套用效果至版面邊界 + Show/Hide All Panels 顯示/隱藏所有面板 + Show/Hide Panels 顯示/隱藏面板 Could not open 無法開啟 {path}: the path is not valid Unicode; rename the file and open it again. {path}:路徑不是有效的 Unicode;請重新命名檔案後再開啟。 diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 106b061ce3a..371f9d8c8ad 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1101,7 +1101,7 @@ impl eframe::App for PhotocraftApp { if chrome && self.ui.panels.toolbar { panels::toolbar(self, ui); } - if chrome { + if chrome && self.ui.panels.dock { panels::right_dock(self, ui); } let t = theme::Tokens::get(&ctx); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 6915ad9431a..fdbd7dcb2f8 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -45,6 +45,9 @@ pub const UI_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[ ("window.toggle.brushSettings", "Brush Settings", &["Window"], Some("F5")), ("window.toggle.navigator", "Navigator", &["Window"], None), ("window.toggle.toolbar", "Tools", &["Window"], None), + // Photoshop's Tab and ⇧Tab: all panels (Tools, options bar and the dock), or only the dock. + ("window.togglePanels", "Show/Hide All Panels", &[], Some("Tab")), + ("window.toggle.dock", "Show/Hide Panels", &[], Some("Shift+Tab")), ("window.toggle.options", "Options", &["Window"], None), ("window.theme.toggle", "Next Theme", &["Window"], None), ("window.theme.pro", "Pro Theme", &["Window", "Theme"], None), @@ -429,6 +432,21 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id: a if crate::adjust_dialog::has_dialog(a) && params.as_object().is_none_or(|o| o.is_empty()) => { Ok(json!({"dialog": crate::adjust_dialog::open(app, a).ok_or("no document")?})) } + "window.togglePanels" => { + // Tab hides the Tools panel, the options bar and the dock; Tab again shows what it hid. + let p = &mut app.ui.panels; + match p.hidden_by_tab.take() { + Some([toolbar, options, dock]) if !(p.toolbar || p.options_bar || p.dock) => { + (p.toolbar, p.options_bar, p.dock) = (toolbar, options, dock); + } + _ if p.toolbar || p.options_bar || p.dock => { + p.hidden_by_tab = Some([p.toolbar, p.options_bar, p.dock]); + (p.toolbar, p.options_bar, p.dock) = (false, false, false); + } + _ => (p.toolbar, p.options_bar, p.dock) = (true, true, true), + } + Ok(Value::Null) + } t if t.starts_with("window.toggle.") => { // A shown but collapsed dock group is expanded rather than hidden (#129). if let Some(g) = crate::dock::Group::from_key(&t["window.toggle.".len()..]).filter(|g| g.shown(&app.ui.panels) && app.ui.dock.is_collapsed(*g)) { @@ -445,6 +463,7 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id: "toolbar" => &mut p.toolbar, "options" => &mut p.options_bar, "brushSettings" => &mut p.brush_settings, + "dock" => &mut p.dock, _ => return Err(format!("unknown panel in {t}")), }; *slot = !*slot; @@ -500,6 +519,7 @@ pub fn is_enabled(app: &PhotocraftApp, id: &str) -> bool { app.session.active().is_some() && app.services.export.is_some() } i if i.starts_with("window.toggle.") => true, + "window.togglePanels" => true, i if panel_alias(i).is_some() || workspace_name(i).is_some() => true, i if proof_preset(i).is_some() => app.session.active().is_some(), // "Custom…" is the full Proof Setup dialog. @@ -614,6 +634,8 @@ fn checked(app: &PhotocraftApp, id: &str) -> Option { "window.toggle.color" => p.color, "window.toggle.navigator" => p.navigator, "window.toggle.toolbar" => p.toolbar, + "window.toggle.dock" => p.dock, + "window.togglePanels" => p.toolbar || p.options_bar || p.dock, "window.toggle.options" => p.options_bar, "window.toggle.brushSettings" => p.brush_settings, _ => return None, diff --git a/crates/ui-egui/src/shortcut_dispatch.rs b/crates/ui-egui/src/shortcut_dispatch.rs index f304a1659c4..24171701c6c 100644 --- a/crates/ui-egui/src/shortcut_dispatch.rs +++ b/crates/ui-egui/src/shortcut_dispatch.rs @@ -192,17 +192,24 @@ pub fn dispatch_pressed(app: &mut PhotocraftApp, ctx: &egui::Context, focus: Foc let table: Vec<(String, KeyboardShortcut)> = bindings(app).into_iter().filter(|(id, sc)| focus.allows(sc) && !(editing && TEXT_OWNED.contains(&id.as_str()))).collect(); let command = |e: &egui::Event| match e { - egui::Event::Key { key, pressed: true, modifiers, .. } => table.iter().find(|(_, sc)| key_matches(sc, *key, *modifiers)).map(|(id, _)| id.clone()), + egui::Event::Key { key, pressed: true, modifiers, .. } => { + table.iter().find(|(_, sc)| key_matches(sc, *key, *modifiers)).map(|(id, _)| (id.clone(), *key == Key::Tab)) + } _ => None, }; let mut ran = false; loop { let next = ctx.input_mut(|i| { - let (at, id) = i.events.iter().enumerate().find_map(|(at, e)| Some((at, command(e)?)))?; + let (at, hit) = i.events.iter().enumerate().find_map(|(at, e)| Some((at, command(e)?)))?; i.events.remove(at); - Some(id) + Some(hit) }); - let Some(id) = next else { break }; + let Some((id, tab)) = next else { break }; + if tab { + // egui already read this Tab as "focus the next widget" (Photoshop's Tab hides the + // panels instead, #1313): the shortcut took it, so cancel that move. + ctx.memory_mut(|m| m.move_focus(egui::FocusDirection::None)); + } let id = delete_key_command(app, id); let owner = key_owner(app, ctx); dispatch(app, ctx, &id); diff --git a/crates/ui-egui/src/shortcut_dispatch/tests.rs b/crates/ui-egui/src/shortcut_dispatch/tests.rs index 62b321e80b9..bcd6c76b00d 100644 --- a/crates/ui-egui/src/shortcut_dispatch/tests.rs +++ b/crates/ui-egui/src/shortcut_dispatch/tests.rs @@ -3,7 +3,7 @@ //! realistic layered document, from the places focus usually is. use egui::accesskit::Role; -use egui::{Key, Modifiers, PointerButton, Pos2, vec2}; +use egui::{Modifiers, PointerButton, Pos2, vec2}; use egui_kittest::Harness; use egui_kittest::kittest::Queryable; use photocraft_doc::LayerContent; @@ -91,7 +91,8 @@ enum Place { LayersRow, /// Just after clicking into the Layers panel's Opacity field (a text field now). OpacityField, - /// A non-text widget focused (Tab from nothing focuses the first one, as egui does). + /// A non-text widget focused (a Layers panel row, through accessibility focus: Tab from + /// nothing focused is Photoshop's Show/Hide All Panels, #1313). FocusedWidget, } @@ -123,9 +124,11 @@ fn put_focus(h: &mut Harness<'_, PhotocraftApp>, place: Place) { assert_eq!(Focus::of(&h.ctx), Focus::Text, "clicking a value field edits it"); } Place::FocusedWidget => { - h.event(egui::Event::Key { key: Key::Tab, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE }); + h.get_by_role_and_label(Role::Button, "paint").scroll_to_me(); + h.run_steps(4); + h.get_by_role_and_label(Role::Button, "paint").focus(); h.run_steps(2); - assert_eq!(Focus::of(&h.ctx), Focus::Widget, "Tab focused a widget"); + assert_eq!(Focus::of(&h.ctx), Focus::Widget, "a widget is focused"); } } take_log(&h.ctx); diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 12706fb7556..b8e26271f39 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -325,6 +325,12 @@ pub struct Panels { /// The toolbar's header chevron: two columns even when one fits (#1197). #[serde(default)] pub toolbar_double: bool, + /// The right-hand panel dock. ⇧Tab hides and shows it, as in Photoshop (#1313). + #[serde(default = "yes")] + pub dock: bool, + /// What Tab hid (toolbar, options bar, dock), so a second Tab brings back just those. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hidden_by_tab: Option<[bool; 3]>, } impl Default for Panels { @@ -341,6 +347,8 @@ impl Default for Panels { brush_settings: false, character: false, toolbar_double: false, + dock: true, + hidden_by_tab: None, } } }