diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index c256200fc9e..9b63b963374 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3753,6 +3753,10 @@ navigator Zoom Zvětšení Sent to {printer} Odesláno do {printer} set in Print Settings… nastavuje se v nastavení tisku… ICO is limited to 256 × 256 pixels ICO je omezen na 256 × 256 pixelů + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Ztmavit rozhraní + Lighten Interface Zesvětlit rozhraní # Bevel & Emboss Technique. Technique Technika Chisel Hard Tvrdé tesání diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 7e403a49835..42bbbc9936d 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3143,6 +3143,10 @@ curves Smooth Glätten Sent to {printer} An {printer} gesendet set in Print Settings… in den Druckeinstellungen festlegen… ICO is limited to 256 × 256 pixels ICO ist auf 256 × 256 Pixel begrenzt + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Benutzeroberfläche abdunkeln + Lighten Interface Benutzeroberfläche aufhellen # Bevel & Emboss Technique. Technique Technik Chisel Hard Meißeln hart diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 0b53fe2b7de..a7d6b6f87de 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3843,6 +3843,10 @@ curves Smooth Εξομάλυνση Sent to {printer} Στάλθηκε στον {printer} set in Print Settings… ορίζεται στις ρυθμίσεις εκτύπωσης… ICO is limited to 256 × 256 pixels Το ICO περιορίζεται σε 256 × 256 εικονοστοιχεία + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Σκουρότερο περιβάλλον + Lighten Interface Φωτεινότερο περιβάλλον # Bevel & Emboss Technique. Technique Τεχνική Chisel Hard Σκληρή σμίλευση diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index f3a9df7e220..3fa7655182d 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2830,6 +2830,10 @@ curves Smooth Suavizar Sent to {printer} Enviado a {printer} set in Print Settings… se establece en Ajustes de impresión… ICO is limited to 256 × 256 pixels ICO está limitado a 256 × 256 píxeles + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Oscurecer interfaz + Lighten Interface Aclarar interfaz # Bevel & Emboss Technique. Technique Técnica Chisel Hard Cincelar duro diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8d54a8cdcde..f1d11f19a58 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3147,6 +3147,10 @@ curves Smooth Lisser Sent to {printer} Envoyé à {printer} set in Print Settings… défini dans les paramètres d’impression… ICO is limited to 256 × 256 pixels Le format ICO est limité à 256 × 256 pixels + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Assombrir l'interface + Lighten Interface Éclaircir l'interface # Bevel & Emboss Technique. Technique Technique Chisel Hard Ciselage dur diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 78a66134619..e3f42792161 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -4066,6 +4066,10 @@ cameraRaw Yellow Sárga Ink Characteristics Festék jellemzői Solidity: Fedőképesség: Redrawing Újrarajzolás + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Felület sötétítése + Lighten Interface Felület világosítása # Bevel & Emboss Technique. Technique Technika Chisel Hard Kemény vésés diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 6497616c439..6b7aca6ff11 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3134,6 +3134,10 @@ curves Smooth Haluskan Sent to {printer} Dikirim ke {printer} set in Print Settings… diatur di Pengaturan Cetak… ICO is limited to 256 × 256 pixels ICO dibatasi hingga 256 × 256 piksel + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Gelapkan Antarmuka + Lighten Interface Cerahkan Antarmuka # Bevel & Emboss Technique. Technique Teknik Chisel Hard Pahat Keras diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index bea1a0867f8..06efc8d9f50 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4108,6 +4108,9 @@ navigator Zoom Zoom Sent to {printer} Inviato a {printer} set in Print Settings… impostato nelle impostazioni di stampa… ICO is limited to 256 × 256 pixels ICO è limitato a 256 × 256 pixel +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Scurisci interfaccia + Lighten Interface Schiarisci interfaccia # Bevel & Emboss Technique. Technique Tecnica Chisel Hard Cesello duro diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 901549c7577..7890c916f72 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3822,6 +3822,9 @@ curves Smooth スムーズ Reset All Locked Settings ロックされた設定をすべて初期化 Copy Texture to Other Tools テクスチャを他のツールにコピー ICO is limited to 256 × 256 pixels ICO は 256 × 256 ピクセルまでです +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface インターフェイスを暗くする + Lighten Interface インターフェイスを明るくする # Bevel & Emboss Technique. Technique テクニック Chisel Hard チゼルハード diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 79cc195b753..0ed7c3c6773 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3320,6 +3320,10 @@ curves Smooth 매끄럽게 Sent to {printer} {printer}(으)로 전송됨 set in Print Settings… 인쇄 설정에서 지정… ICO is limited to 256 × 256 pixels ICO는 256 × 256픽셀로 제한됩니다 + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface 인터페이스 어둡게 + Lighten Interface 인터페이스 밝게 # Bevel & Emboss Technique. Technique 기법 Chisel Hard 단단하게 조각 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index dce4d092010..0ea0ce04745 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3905,6 +3905,10 @@ curves Smooth Vloeiend maken Sent to {printer} Verzonden naar {printer} set in Print Settings… instellen in de afdrukinstellingen… ICO is limited to 256 × 256 pixels ICO is beperkt tot 256 × 256 pixels + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Interface donkerder maken + Lighten Interface Interface lichter maken # Bevel & Emboss Technique. Technique Techniek Chisel Hard Beitel hard diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 9a8f7709843..7d22a6ae7a8 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3743,6 +3743,10 @@ curves Smooth Wygładź Sent to {printer} Wysłano do {printer} set in Print Settings… ustawiane w ustawieniach druku… ICO is limited to 256 × 256 pixels ICO jest ograniczony do 256 × 256 pikseli + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Przyciemnij interfejs + Lighten Interface Rozjaśnij interfejs # Bevel & Emboss Technique. Technique Technika Chisel Hard Dłuto twarde diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index f89e09eb0e7..a36fb9561a2 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -3935,6 +3935,10 @@ layerLabel No Color Sem cor Sent to {printer} Enviado para {printer} set in Print Settings… definido nas configurações de impressão… ICO is limited to 256 × 256 pixels ICO é limitado a 256 × 256 pixels + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Escurecer interface + Lighten Interface Clarear interface # Bevel & Emboss Technique. Technique Técnica Chisel Hard Cinzel duro diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index e32e5114b9e..3f7bd752490 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3111,6 +3111,10 @@ curves Smooth Сгладить Gray Value (Median) Уровень серого (медиана) Integrated Density Интегральная плотность Length Длина + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Сделать интерфейс темнее + Lighten Interface Сделать интерфейс светлее # Bevel & Emboss Technique. Technique Метод Chisel Hard Жесткая огранка diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv index 8365404d7ee..bdca953615e 100644 --- a/crates/ui-egui/src/i18n/sr.tsv +++ b/crates/ui-egui/src/i18n/sr.tsv @@ -4219,6 +4219,10 @@ shape Appearance Izgled Ink Characteristics Karakteristike mastila Solidity: Punoća: Redrawing Ponovno iscrtavanje + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Zatamni interfejs + Lighten Interface Posvetli interfejs # Bevel & Emboss Technique. Technique Tehnika Chisel Hard Tvrdo klesanje diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index eaa32fcbbe4..4fcf00c6b02 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3877,6 +3877,10 @@ cameraData Lens Lens Ink Characteristics Mürekkep Özellikleri Solidity: Doluluk: Redrawing Yeniden çiziliyor + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Arayüzü koyulaştır + Lighten Interface Arayüzü açıklaştır # Bevel & Emboss Technique. Technique Teknik Chisel Hard Sert Keski diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index c6212c5d048..353e97c3bae 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3844,6 +3844,10 @@ curves Smooth Згладити Sent to {printer} Надіслано на {printer} set in Print Settings… задається в параметрах друку… ICO is limited to 256 × 256 pixels ICO обмежено розміром 256 × 256 пікселів + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Зробити інтерфейс темнішим + Lighten Interface Зробити інтерфейс світлішим # Bevel & Emboss Technique. Technique Метод Chisel Hard Жорстке різьблення diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 9208112bf5f..41c7b7c0b0d 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3632,6 +3632,10 @@ curves Smooth Làm mượt Sent to {printer} Đã gửi tới {printer} set in Print Settings… đặt trong thiết lập in… ICO is limited to 256 × 256 pixels ICO giới hạn ở 256 × 256 pixel + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface Làm tối giao diện + Lighten Interface Làm sáng giao diện # Bevel & Emboss Technique. Technique Kỹ thuật Chisel Hard Đục cứng diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 2ebc4c71c04..c420d748c13 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2755,6 +2755,10 @@ curves Smooth 平滑 Sent to {printer} 已发送到 {printer} set in Print Settings… 在打印设置中设置… ICO is limited to 256 × 256 pixels ICO 最大为 256 × 256 像素 + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface 界面变暗 + Lighten Interface 界面变亮 # Bevel & Emboss Technique. Technique 方法 Chisel Hard 雕刻清晰 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 92302285c84..c4f9f4098b4 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2740,6 +2740,10 @@ curves Smooth 平滑 Sent to {printer} 已傳送至 {printer} set in Print Settings… 在列印設定中設定… ICO is limited to 256 × 256 pixels ICO 最大為 256 × 256 像素 + +# Darken / Lighten Interface (⇧⌘F1 / ⇧⌘F2) + Darken Interface 介面變暗 + Lighten Interface 介面變亮 # Bevel & Emboss Technique. Technique 方法 Chisel Hard 雕刻清晰 diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index c20967b16ec..592acbc627e 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -53,6 +53,9 @@ pub const UI_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[ ("view.extras", "Extras", &["View"], Some("Cmd+H")), ("view.show.targetPath", "Target Path", &["View", "Show"], Some("Cmd+Shift+H")), ("view.screenMode.cycle", "Cycle Screen Mode", &[], Some("F")), + // Photoshop's interface brightness shortcuts: step through the four Pro themes. + ("view.darkenInterface", "Darken Interface", &[], Some("Cmd+Shift+F1")), + ("view.lightenInterface", "Lighten Interface", &[], Some("Cmd+Shift+F2")), ("edit.freeTransformCopy", "Free Transform a Copy", &[], Some("Cmd+Alt+T")), ("type.editText", "Edit Type", &[], None), ("view.zoomIn", "Zoom In", &["View"], Some("Cmd+=")), @@ -376,6 +379,10 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id: crate::prefs_ui::cycle_appearance(app, ctx); Ok(Value::Null) } + "view.darkenInterface" | "view.lightenInterface" => { + crate::prefs_ui::step_brightness(app, ctx, id == "view.lightenInterface")?; + Ok(json!({"theme": app.ui.theme.id()})) + } "window.theme.system" => { app.run("prefs.set", json!({"path": "interface.appearanceMode", "value": "auto"}))?; crate::prefs_ui::sync_appearance(app, ctx); @@ -752,6 +759,8 @@ pub fn is_enabled(app: &PhotocraftApp, id: &str) -> bool { i if i.starts_with(DOCUMENT_ITEM) => true, i if crate::links::url_for(i).is_some() => true, i if i.starts_with("window.theme.") => true, + // Interface brightness works with or without a document, as in Photoshop. + "view.darkenInterface" | "view.lightenInterface" => true, "file.save" | "file.saveAs" | "file.export.exportAs" | "file.export.quickExportAsPng" => { app.session.active().is_some() && app.services.export.is_some() } diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index 513b2570125..7dd2ce2ea5a 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -128,6 +128,26 @@ pub(crate) fn cycle_appearance(app: &mut PhotocraftApp, ctx: &egui::Context) { } } +/// Photoshop's four interface brightnesses, darkest first. +const BRIGHTNESSES: [ThemeKind; 4] = [ThemeKind::Pro, ThemeKind::ProMedium, ThemeKind::ProLightGray, ThemeKind::ProLight]; + +/// Darken Interface (⇧⌘F1, `lighter` false) and Lighten Interface (⇧⌘F2): the next of +/// Photoshop's four brightnesses from the theme on screen, stopping at either end, as in +/// Photoshop. Another theme steps from the nearest brightness: Medium Gray for a dark one, Light +/// Gray for a light one. The choice is saved like picking it in Preferences › Interface. +pub(crate) fn step_brightness(app: &mut PhotocraftApp, ctx: &egui::Context, lighter: bool) -> Result<(), String> { + let current = app.ui.theme; + let at = BRIGHTNESSES.iter().position(|k| *k == current).unwrap_or(if crate::theme::Tokens::for_kind(current).dark() { 1 } else { 2 }); + let next = if lighter { (at + 1).min(BRIGHTNESSES.len() - 1) } else { at.saturating_sub(1) }; + let Some(&kind) = BRIGHTNESSES.get(next) else { return Ok(()) }; + if kind == current { + return Ok(()); + } + app.run("prefs.set", json!({"path": "interface.theme", "value": kind.id()}))?; + sync_appearance(app, ctx); + Ok(()) +} + const LIGHT_THEME_OPTIONS: &[(&str, ThemeKind)] = &[ ("proLight", ThemeKind::ProLight), ("proLightGray", ThemeKind::ProLightGray), @@ -2169,6 +2189,65 @@ mod tests { } } + #[test] + fn darken_and_lighten_interface_step_through_photoshops_brightnesses_and_stop_at_the_ends() { + let ctx = egui::Context::default(); + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + sync_appearance(&mut app, &ctx); + assert_eq!(app.ui.theme, ThemeKind::ProMedium, "Photoshop's default brightness"); + let press = |app: &mut PhotocraftApp, id: &str| crate::menus::invoke(app, &ctx, id, json!({})).unwrap(); + for expected in [ThemeKind::ProLightGray, ThemeKind::ProLight, ThemeKind::ProLight] { + press(&mut app, "view.lightenInterface"); + assert_eq!(app.ui.theme, expected); + } + // Saved like a choice in Preferences › Interface: the light slot and the Light appearance. + let i = &app.session.prefs().interface; + assert_eq!((i.appearance_mode, i.light_theme), (AppearanceMode::Light, LightTheme::ProLight)); + for expected in [ThemeKind::ProLightGray, ThemeKind::ProMedium, ThemeKind::Pro, ThemeKind::Pro] { + press(&mut app, "view.darkenInterface"); + assert_eq!(app.ui.theme, expected); + } + let i = &app.session.prefs().interface; + assert_eq!((i.appearance_mode, i.dark_theme), (AppearanceMode::Dark, DarkTheme::Pro)); + // Another theme steps from the nearest brightness. + for (theme, id, expected) in [ + ("studio", "view.darkenInterface", ThemeKind::Pro), + ("studio", "view.lightenInterface", ThemeKind::ProLightGray), + ("classic", "view.darkenInterface", ThemeKind::ProMedium), + ("classic", "view.lightenInterface", ThemeKind::ProLight), + ] { + app.run("prefs.set", json!({"path": "interface.theme", "value": theme})).unwrap(); + sync_appearance(&mut app, &ctx); + press(&mut app, id); + assert_eq!(app.ui.theme, expected, "{theme} {id}"); + } + } + + #[test] + fn ctrl_shift_f1_and_f2_darken_and_lighten_the_interface() { + for (id, shortcut) in [("view.darkenInterface", "Cmd+Shift+F1"), ("view.lightenInterface", "Cmd+Shift+F2")] { + assert_eq!(crate::shortcuts::default_shortcut(id).as_deref(), Some(shortcut), "{id}"); + } + let ctx = egui::Context::default(); + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + sync_appearance(&mut app, &ctx); + let press = |app: &mut PhotocraftApp, key| { + let modifiers = egui::Modifiers::COMMAND | egui::Modifiers::SHIFT; + let raw = egui::RawInput { + events: vec![egui::Event::ModifiersChanged(modifiers), egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers }], + ..Default::default() + }; + ctx.begin_pass(raw); + crate::shortcuts::handle(app, &ctx); + ctx.end_pass().textures_delta.clear(); + }; + press(&mut app, egui::Key::F1); + assert_eq!(app.ui.theme, ThemeKind::Pro); + press(&mut app, egui::Key::F2); + press(&mut app, egui::Key::F2); + assert_eq!(app.ui.theme, ThemeKind::ProLightGray); + } + fn appearance_frame(app: &mut PhotocraftApp, ctx: &egui::Context, appearance: Option) { ctx.run_ui(egui::RawInput { system_theme: appearance, ..Default::default() }, |ui| tick(app, ui.ctx())).textures_delta.clear(); }