Skip to content

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

Options bar: the Gradient tool's controls show in every theme (#3601) (#3607)

Valentin Kleinc7c60312544b
diff --git a/crates/ui-egui/src/move_auto_select_tests.rs b/crates/ui-egui/src/move_auto_select_tests.rs
index 10dc5532f..03ad1c21e 100644
--- a/crates/ui-egui/src/move_auto_select_tests.rs
+++ b/crates/ui-egui/src/move_auto_select_tests.rs
@@ -182,3 +182,31 @@ fn every_theme_shows_the_type_options() {
assert!(combos.iter().any(|c| c.contains(&font)), "{theme:?}: the font picker shows {font:?}; combo boxes: {combos:?}");
}
}
+
+#[test]
+fn every_theme_shows_the_gradient_options() {
+ // #3601: the Studio themes' options bar was only the hint "Drag to draw a gradient", with no
+ // mode, style, blend mode or opacity control.
+ use egui_kittest::Harness;
+ use egui_kittest::kittest::{NodeT, Queryable};
+ for theme in crate::theme::ThemeKind::ALL {
+ let (mut app, _, _) = app();
+ app.ui.tool = Tool::Gradient;
+ let mut h = Harness::builder().with_size(egui::vec2(1600.0, 60.0)).build_ui_state(
+ |ui, app: &mut PhotocraftApp| {
+ if !ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {
+ return;
+ }
+ crate::panels::options_bar(app, ui);
+ },
+ app,
+ );
+ PhotocraftApp::setup_context(&h.ctx, theme);
+ h.run_steps(4);
+ let combos: Vec<String> = h
+ .query_all_by_role(egui::accesskit::Role::ComboBox)
+ .map(|n| format!("{:?} {:?}", n.accesskit_node().label(), n.accesskit_node().value()))
+ .collect();
+ assert!(combos.iter().any(|c| c.contains("Normal")), "{theme:?}: the blend mode picker shows; combo boxes: {combos:?}");
+ }
+}
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs
index 22c5aac26..ad543786e 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -1157,7 +1157,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous"));
widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("All Layers"));
}
- Tool::Gradient if t.pro => {
+ Tool::Gradient => {
// Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels).
let mut classic = app.ui.tool_options.gradient_classic;
if widgets::dropdown(ui, "gradient-mode", &mut classic, &[(false, "Gradient"), (true, "Classic gradient")], 118.0) {
@@ -1412,7 +1412,6 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
&[("commit", &crate::shortcuts::pretty("Enter"))],
),
),
- Tool::Gradient => hint(ui, tl!("Drag to draw a gradient")),
Tool::PaintBucket => hint(ui, tl!("Click to fill similar colours")),
// Retouching and smart-selection tools draw their bar in `retouch_ui::options_bar`.
_ => {}