From 2e581946d5936df7d6493a367c73621fef63a0f4 Mon Sep 17 00:00:00 2001
From: RickiNano <81099017+RickiNano@users.noreply.github.com>
Date: Sun, 22 Nov 2026 14:49:19 +0100
Subject: [PATCH 1/5] fix(ui-egui): Fill and Stroke Opacity takes 1 to 100 with
the range alert (#14649)
The Opacity row Edit > Fill and Edit > Stroke share now takes whole
percents from 1 to 100, so a typed 0 is clamped to 1 with the framework's
range alert, titled after the dialog, as 150 and 12.3 already were for
100. New Layer's own Opacity row keeps 0 to 100. Scripts are unchanged.
---
crates/ui-egui/src/dialogs/blend_options.rs | 5 +-
crates/ui-egui/src/dialogs/fill_ui.rs | 3 +
.../dialogs/fill_ui/opacity_alert_tests.rs | 111 ++++++++++++++++++
3 files changed, 117 insertions(+), 2 deletions(-)
create mode 100644 crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
diff --git a/crates/ui-egui/src/dialogs/blend_options.rs b/crates/ui-egui/src/dialogs/blend_options.rs
index 6d48c6ec82..955be98b05 100644
--- a/crates/ui-egui/src/dialogs/blend_options.rs
+++ b/crates/ui-egui/src/dialogs/blend_options.rs
@@ -2,7 +2,7 @@
//! Layers panel's, so a mode has one key and one shortcut everywhere.
use craft::ui::patterns::form_dialogs::{DialogFields, Param, ParamKind};
-use craft::ui::runtime::env::Label;
+use craft::ui::runtime::env::{Label, UnitKind};
use photocraft_color::BlendMode;
use serde_json::{Map, Value, json};
@@ -25,7 +25,8 @@ pub(crate) fn blending_rows() -> Vec {
vec![
Param::section(tl!("Blending")),
blend_param("mode", tl!("Mode:"), false, BlendMode::Normal),
- super::new_layer_ui::opacity_param(),
+ // Whole percents from 1 (New Layer's row starts at 0): a typed 0 is clamped to 1 with the range alert (#14649).
+ Param::new("opacity", tl!("Opacity:"), ParamKind::number(Some(1.0), Some(100.0), 100.0, 1.0, 0)).unit(UnitKind::Percent),
Param::new("preserveTransparency", tl!("Preserve Transparency"), ParamKind::bool(false)),
]
}
diff --git a/crates/ui-egui/src/dialogs/fill_ui.rs b/crates/ui-egui/src/dialogs/fill_ui.rs
index 7b460e473a..c8de3238f3 100644
--- a/crates/ui-egui/src/dialogs/fill_ui.rs
+++ b/crates/ui-egui/src/dialogs/fill_ui.rs
@@ -148,5 +148,8 @@ pub(crate) fn run(app: &mut PhotocraftApp, ctx: &egui::Context, result: ParamRes
}
}
+#[cfg(test)]
+mod opacity_alert_tests;
+
#[cfg(test)]
mod tests;
diff --git a/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs b/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
new file mode 100644
index 0000000000..52d7fa585f
--- /dev/null
+++ b/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
@@ -0,0 +1,111 @@
+//! #14649: the Opacity row that Edit › Fill and Edit › Stroke share takes whole percents from 1 to 100. A typed value
+//! past them is clamped, once the field is left, with the range alert titled after the dialog; letters restore the
+//! previous value without one.
+
+use egui::accesskit::Role;
+use egui::vec2;
+use egui_kittest::Harness;
+use egui_kittest::kittest::{NodeT, Queryable};
+use serde_json::json;
+
+use crate::PhotocraftApp;
+
+type H = Harness<'static, Box>;
+
+/// A document with a selection and the dialog `open` opens, hosted with its alerts.
+fn dialog(open: fn(&mut PhotocraftApp)) -> H {
+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"width": 40, "height": 30})).unwrap();
+ app.run("select.rect", json!({"x": 5, "y": 5, "width": 10, "height": 10})).unwrap();
+ crate::theme::install_fonts(app.ctx());
+ crate::theme::apply(app.ctx(), &crate::theme::AppTheme::pro());
+ open(&mut app);
+ let mut h = Harness::builder()
+ .with_context(app.ctx().clone())
+ .with_size(vec2(1200.0, 900.0))
+ .with_step_dt(1.0 / 60.0)
+ .build_ui_state(|ui, app: &mut Box| crate::dialogs::run(app, ui), app);
+ h.run_steps(4);
+ h
+}
+
+fn fill(app: &mut PhotocraftApp) {
+ super::open(app);
+}
+
+fn stroke(app: &mut PhotocraftApp) {
+ crate::dialogs::stroke_ui::open(app);
+}
+
+fn opacity<'a>(h: &'a H) -> egui_kittest::Node<'a> {
+ h.query_all_by_role(Role::SpinButton).find(|n| n.accesskit_node().label().is_some_and(|l| l.trim_end_matches(':') == "Opacity")).expect("the Opacity field")
+}
+
+fn value(h: &H) -> Option {
+ opacity(h).accesskit_node().numeric_value()
+}
+
+/// Types `text` over Opacity and leaves the field with Tab.
+fn type_and_tab(h: &mut H, text: &str) {
+ let at = opacity(h).rect().center();
+ h.hover_at(at);
+ h.run_steps(1);
+ for pressed in [true, false] {
+ h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() });
+ h.run_steps(1);
+ }
+ h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);
+ h.event(egui::Event::Text(text.into()));
+ h.run_steps(1);
+ h.key_press(egui::Key::Tab);
+ h.run_steps(4);
+}
+
+/// The message of the open alert, if any.
+fn alert(h: &H) -> Option {
+ let dialogs = h.state().framework.dialogs.open_dialogs();
+ dialogs.iter().find(|d| d.key.as_deref() == Some("alert")).and_then(|d| d.fields.as_ref()?.get("message")?.as_str().map(str::to_string))
+}
+
+/// Answers the open alert, leaving the dialog `command` open.
+fn dismiss(h: &mut H, command: &str) {
+ let dialogs = h.state().framework.dialogs.open_dialogs();
+ for id in dialogs.iter().filter(|d| d.key.as_deref() != Some(command)).map(|d| d.id) {
+ h.state_mut().framework.dialogs.close_by_id(id);
+ }
+ h.run_steps(3);
+}
+
+fn titles(h: &H) -> Vec {
+ h.query_all_by_role(Role::Dialog).chain(h.query_all_by_role(Role::AlertDialog)).filter_map(|n| n.accesskit_node().label()).collect()
+}
+
+fn check(open: fn(&mut PhotocraftApp), command: &str, title: &str) {
+ let mut h = dialog(open);
+ for (typed, kept) in [("0", 1.0), ("150", 100.0), ("50", 50.0), ("12.3", 100.0)] {
+ type_and_tab(&mut h, typed);
+ assert_eq!(value(&h), Some(kept), "{title}: typed {typed}");
+ if kept == 50.0 {
+ assert_eq!(alert(&h), None, "{title}: {typed} is in range");
+ continue;
+ }
+ let message = alert(&h).unwrap_or_else(|| panic!("{title}: {typed} raises the range alert"));
+ assert!(message.contains("integer between 1") && message.contains("100"), "{title}: {message}");
+ assert!(titles(&h).iter().all(|t| t == title), "{title}: the alert is titled after the dialog: {:?}", titles(&h));
+ dismiss(&mut h, command);
+ }
+ type_and_tab(&mut h, "42");
+ type_and_tab(&mut h, "abc");
+ assert_eq!(value(&h), Some(42.0), "{title}: letters restore the previous value");
+ assert_eq!(alert(&h), None, "{title}: letters raise no alert");
+}
+
+#[test]
+fn fill_opacity_takes_1_to_100_with_the_range_alert() {
+ check(fill, super::COMMAND, "Fill");
+}
+
+#[test]
+fn stroke_opacity_takes_1_to_100_with_the_range_alert() {
+ check(stroke, crate::dialogs::stroke_ui::COMMAND, "Stroke");
+}
From 72c5986acecba22b8d39f2bb579476bb9e9c1106 Mon Sep 17 00:00:00 2001
From: RickiNano <81099017+RickiNano@users.noreply.github.com>
Date: Sun, 22 Nov 2026 15:26:47 +0100
Subject: [PATCH 2/5] test(ui-egui): leave the locale-dependent 12.3 case out
of the Fill opacity test (#14649)
The framework reads a typed 12.3 with the system's decimal separator: on a
comma system it reads 123 and is clamped to 100, on a dot system it is kept
as 12.3. That case needs craft-libs, so the test no longer asserts it.
---
crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs b/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
index 52d7fa585f..7dc9c7398d 100644
--- a/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
+++ b/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
@@ -1,6 +1,6 @@
//! #14649: the Opacity row that Edit › Fill and Edit › Stroke share takes whole percents from 1 to 100. A typed value
//! past them is clamped, once the field is left, with the range alert titled after the dialog; letters restore the
-//! previous value without one.
+//! previous value without one. A typed fraction (the reference drops the dot) is left to craft-libs.
use egui::accesskit::Role;
use egui::vec2;
@@ -82,7 +82,8 @@ fn titles(h: &H) -> Vec {
fn check(open: fn(&mut PhotocraftApp), command: &str, title: &str) {
let mut h = dialog(open);
- for (typed, kept) in [("0", 1.0), ("150", 100.0), ("50", 50.0), ("12.3", 100.0)] {
+ // Not `12.3`: the framework reads it with the system's decimal separator, so the result depends on the machine.
+ for (typed, kept) in [("0", 1.0), ("150", 100.0), ("50", 50.0)] {
type_and_tab(&mut h, typed);
assert_eq!(value(&h), Some(kept), "{title}: typed {typed}");
if kept == 50.0 {
From ffe56740a236fad68c4c58da98e540d8ab8d441f Mon Sep 17 00:00:00 2001
From: RickiNano <81099017+RickiNano@users.noreply.github.com>
Date: Sun, 22 Nov 2026 16:16:07 +0100
Subject: [PATCH 3/5] test(ui-egui): the Fill opacity alert test fails on an
unnamed dialog window (#14649)
---
crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs b/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
index 7dc9c7398d..99473e18cc 100644
--- a/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
+++ b/crates/ui-egui/src/dialogs/fill_ui/opacity_alert_tests.rs
@@ -76,8 +76,9 @@ fn dismiss(h: &mut H, command: &str) {
h.run_steps(3);
}
-fn titles(h: &H) -> Vec {
- h.query_all_by_role(Role::Dialog).chain(h.query_all_by_role(Role::AlertDialog)).filter_map(|n| n.accesskit_node().label()).collect()
+/// The names of the open dialog windows, unnamed ones included.
+fn titles(h: &H) -> Vec