mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Hide the favourite themes preference now that nothing lists them
The top bar's appearance button menu was the only place that listed the favourite themes. With the button gone, the star badges on the Preferences theme swatches saved a list nothing read, and the prefs audit failed. Drop the badges, hide interface.favoriteThemes (kept in the model so older settings files still load) and regenerate docs/scorecard.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
a926d5d8c5
commit
dc831fd223
5 files changed
+14
-81
No files matched your search
@@ -44,6 +44,9 @@ pub const HIDDEN_UNTIL_IMPLEMENTED: &[&str] = &[
|
||||
"plugIns.allowScriptsToConnect",
|
||||
"type.textEngine",
|
||||
"enhancedControls.scrubbySliderAcceleration",
|
||||
// Only the top bar's appearance button menu listed the favourite themes, and the top bar no
|
||||
// longer has that button (#13577). Kept in the model so older settings files still load.
|
||||
"interface.favoriteThemes",
|
||||
];
|
||||
|
||||
/// Is the preference at `path` (`"section.key"`) hidden from the Preferences dialog?
|
||||
|
||||
@@ -14,7 +14,7 @@ use photocraft_doc::DocId;
|
||||
use photocraft_engine::jobs::{JobEvent, JobId, JobOutcome, Started};
|
||||
#[cfg(test)]
|
||||
use photocraft_engine::prefs::Theme;
|
||||
use photocraft_engine::prefs::{self, AppearanceMode, DarkTheme, LightTheme, SECTIONS, Theme as SavedTheme};
|
||||
use photocraft_engine::prefs::{self, AppearanceMode, DarkTheme, LightTheme, SECTIONS};
|
||||
use photocraft_engine::snap::{SnapLine, SnapOptions, SnapTargets};
|
||||
use serde_json::{Map, Value, json};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::fields::{choice_label, color_of, preference_matches};
|
||||
use super::{AppearanceMode, Color32, DarkTheme, LightTheme, Map, PhotocraftApp, RichText, SavedTheme, Sense, ThemeKind, Tokens, Value, json, prefs, vec2};
|
||||
use super::{AppearanceMode, Color32, DarkTheme, LightTheme, Map, PhotocraftApp, RichText, Sense, ThemeKind, Tokens, Value, json, prefs, vec2};
|
||||
|
||||
/// The GPU canvas colours from Preferences › Transparency & Gamut.
|
||||
pub fn canvas_style(app: &PhotocraftApp) -> crate::gpu_canvas::CanvasStyle {
|
||||
@@ -161,11 +161,8 @@ pub(crate) fn sync_appearance(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
}
|
||||
|
||||
/// One theme as a Color Theme swatch: its panel colour under a chrome strip with an accent dot,
|
||||
/// outlined when chosen. The name is the tooltip and the accessible label. A star badge on its
|
||||
/// corner adds the theme to (or removes it from) the favourites listed by the appearance
|
||||
/// button's menu; it shows while the swatch is hovered, and stays for a favourite.
|
||||
fn theme_swatch(ui: &mut egui::Ui, kind: ThemeKind, id: &str, selected: &mut String, favorites: &mut Vec<SavedTheme>) {
|
||||
const BADGE: f32 = 7.0;
|
||||
/// outlined when chosen. The name is the tooltip and the accessible label.
|
||||
fn theme_swatch(ui: &mut egui::Ui, kind: ThemeKind, id: &str, selected: &mut String) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let p = Tokens::for_kind(kind);
|
||||
let label = tl!(&choice_label(id)).to_string();
|
||||
@@ -188,40 +185,16 @@ fn theme_swatch(ui: &mut egui::Ui, kind: ThemeKind, id: &str, selected: &mut Str
|
||||
if resp.on_hover_text(&label).clicked() {
|
||||
*selected = id.to_string();
|
||||
}
|
||||
let Some(theme) = SavedTheme::parse(id) else { return };
|
||||
let favorite = favorites.contains(&theme);
|
||||
let center = rect.right_top() + vec2(-3.0, 3.0);
|
||||
let badge = egui::Rect::from_center_size(center, vec2(BADGE * 2.0, BADGE * 2.0));
|
||||
if !(favorite || ui.rect_contains_pointer(rect.union(badge))) {
|
||||
return;
|
||||
}
|
||||
ui.painter().circle(center, BADGE, t.card, egui::Stroke::new(1.0, t.card_border));
|
||||
let (icon, tint) = if favorite { ("star-filled", t.accent) } else { ("star", t.text_dim) };
|
||||
let action = if favorite { tl!("Remove from favorites") } else { tl!("Add to favorites") };
|
||||
// Interact and paint without allocating: a widget placed at `badge` would grow the row by the
|
||||
// 4 px the badge overhangs the swatch, re-centring the swatches after this one whenever the
|
||||
// pointer arrives, and oscillating when that moves the swatch out from under it.
|
||||
let response = ui.interact(badge, ui.scope_id().with((id, "favorite")), Sense::click()).on_hover_text(action);
|
||||
crate::icons::paint(ui, badge, icon, 10.0, tint);
|
||||
response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, format!("{action}: {label}")));
|
||||
if response.clicked() {
|
||||
if favorite {
|
||||
favorites.retain(|saved| *saved != theme);
|
||||
} else {
|
||||
favorites.push(theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A grid row of theme swatches, marked Active when the appearance mode shows this family.
|
||||
fn theme_row(ui: &mut egui::Ui, title: &str, active: bool, selected: &mut String, favorites: &mut Vec<SavedTheme>, options: &[(&str, ThemeKind)]) {
|
||||
fn theme_row(ui: &mut egui::Ui, title: &str, active: bool, selected: &mut String, options: &[(&str, ThemeKind)]) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
ui.label(RichText::new(tl!(title)).color(t.text_dim));
|
||||
ui.horizontal(|ui| {
|
||||
// Room for the favourite star badges on the swatch corners.
|
||||
ui.spacing_mut().item_spacing.x = 6.0;
|
||||
for (id, kind) in options {
|
||||
theme_swatch(ui, *kind, id, selected, favorites);
|
||||
theme_swatch(ui, *kind, id, selected);
|
||||
}
|
||||
if active {
|
||||
ui.add_space(6.0);
|
||||
@@ -266,14 +239,12 @@ pub(super) fn appearance_rows(ui: &mut egui::Ui, obj: &mut Map<String, Value>, s
|
||||
obj.insert("appearanceMode".into(), json!(mode));
|
||||
let mut light = obj.get("lightTheme").and_then(Value::as_str).unwrap_or("studioLight").to_string();
|
||||
let mut dark = obj.get("darkTheme").and_then(Value::as_str).unwrap_or("proMedium").to_string();
|
||||
let mut favorites: Vec<SavedTheme> = obj.get("favoriteThemes").cloned().and_then(|v| serde_json::from_value(v).ok()).unwrap_or_default();
|
||||
if rows.light {
|
||||
theme_row(ui, "Light Theme", light_active, &mut light, &mut favorites, LIGHT_THEME_OPTIONS);
|
||||
theme_row(ui, "Light Theme", light_active, &mut light, LIGHT_THEME_OPTIONS);
|
||||
}
|
||||
if rows.dark {
|
||||
theme_row(ui, "Dark Theme", !light_active, &mut dark, &mut favorites, DARK_THEME_OPTIONS);
|
||||
theme_row(ui, "Dark Theme", !light_active, &mut dark, DARK_THEME_OPTIONS);
|
||||
}
|
||||
obj.insert("lightTheme".into(), json!(light));
|
||||
obj.insert("darkTheme".into(), json!(dark));
|
||||
obj.insert("favoriteThemes".into(), json!(favorites));
|
||||
}
|
||||
@@ -493,47 +493,6 @@ fn preferences_interface_offers_and_applies_sync_with_system() {
|
||||
assert_eq!(reloaded.lock().unwrap().as_ref(), Some(&saved));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn theme_star_saves_favorite() {
|
||||
use egui_kittest::{Harness, kittest::Queryable};
|
||||
let (mut app, _) = app_with_store();
|
||||
open_preferences(&mut app, "interface");
|
||||
let mut h = Harness::builder().with_size(vec2(1280.0, 800.0)).build_eframe(move |cc| {
|
||||
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
|
||||
app
|
||||
});
|
||||
h.run_steps(4);
|
||||
h.get_by_label("Classic").hover();
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Add to favorites: Classic").click();
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Apply").click();
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().session.prefs().interface.favorite_themes, vec![SavedTheme::Classic]);
|
||||
assert!(h.query_by_label("Remove from favorites: Classic").is_some());
|
||||
}
|
||||
|
||||
/// The favourite star badge overhangs its swatch; showing it on hover must not move the swatches
|
||||
/// after it, or the row would shift under the pointer.
|
||||
#[test]
|
||||
fn theme_star_badge_on_hover_does_not_move_the_next_swatch() {
|
||||
use egui_kittest::{Harness, kittest::Queryable};
|
||||
let (mut app, _) = app_with_store();
|
||||
open_preferences(&mut app, "interface");
|
||||
let mut h = Harness::builder().with_size(vec2(1280.0, 800.0)).build_eframe(move |cc| {
|
||||
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
|
||||
app
|
||||
});
|
||||
h.run_steps(4);
|
||||
let first = h.get_by_label("Classic").rect();
|
||||
let next = h.get_by_label("Adwaita").rect();
|
||||
h.hover_at(first.right_top() + vec2(-3.0, 3.0));
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label("Add to favorites: Classic").is_some(), "the badge shows while the swatch is hovered");
|
||||
assert_eq!(h.get_by_label("Classic").rect(), first);
|
||||
assert_eq!(h.get_by_label("Adwaita").rect(), next);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preferences_interface_shows_language_without_scrolling() {
|
||||
// #2532: in a small window the theme cards filled the page and Language sat out of view
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
|
||||
| [Performance](#performance) | 3 | 22 | 56 | 90 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 52 not run, 4 not measurable yet (baseline 2026-10-05) |
|
||||
| [File compatibility](#file-compatibility) | 11 | 14 | 2 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 190/258, round trip ≥ 258/258 |
|
||||
| [Tools](#tools) | 36 | 9 | 0 | |
|
||||
| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 8 of 199 (target 0) |
|
||||
| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 9 of 199 (target 0) |
|
||||
| [Type](#type) | 5 | 5 | 0 | |
|
||||
| [Automation](#automation) | 5 | 4 | 2 | 664 of 664 menu items live (100.0%) |
|
||||
| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present |
|
||||
@@ -214,9 +214,9 @@ Corpus floors (`crates/io/tests/it/corpus.rs`): the enforced minimums; the corpu
|
||||
|
||||
## Workspace and UI
|
||||
|
||||
**Settings that do nothing: 8 of 199** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
|
||||
**Settings that do nothing: 9 of 199** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
|
||||
|
||||
Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `performance.legacy_compositing`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`.
|
||||
Unread: `general.color_picker`, `interface.favorite_themes`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `performance.legacy_compositing`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`.
|
||||
|
||||
| Id | Target | Status | Issue | Note |
|
||||
|---|---|---|---|---|
|
||||
|
||||
Reference in new issue
Block a user