mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Merge remote-tracking branch 'upstream/main' into fix/zoom-tool-context-menu
This commit is contained in:
commit
2f45dd691f
15 files changed
+507
-58
No files matched your search
Generated
+14
-27
@@ -1406,17 +1406,17 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docpath"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
|
||||
[[package]]
|
||||
name = "craft-fonts-build"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
|
||||
[[package]]
|
||||
name = "craft-i18n"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"fixed_decimal",
|
||||
"icu_decimal",
|
||||
@@ -1439,7 +1439,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jpeg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1457,7 +1457,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pdf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"hayro",
|
||||
@@ -1469,7 +1469,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-print"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"craft-winprint-gdi",
|
||||
"log",
|
||||
@@ -1483,7 +1483,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"craft-fonts-build",
|
||||
"craft-i18n",
|
||||
@@ -1504,7 +1504,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-update"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"dunce",
|
||||
@@ -1530,7 +1530,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-winprint-gdi"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/winprint.rs?rev=417ac3c4d14d3da5485a99c7d5ce8f05664ec312#417ac3c4d14d3da5485a99c7d5ce8f05664ec312"
|
||||
source = "git+https://github.com/storytold/winprint.rs?rev=64e7afd4d1483512385012c340ecaaaf0f3beb7f#64e7afd4d1483512385012c340ecaaaf0f3beb7f"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
@@ -2964,7 +2964,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro"
|
||||
version = "0.7.1"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"hayro-interpret",
|
||||
@@ -2994,7 +2994,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
@@ -3012,7 +3012,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-jbig2"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"fearless_simd",
|
||||
"hayro-ccitt",
|
||||
@@ -3036,7 +3036,7 @@ checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f"
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.7.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-ccitt",
|
||||
@@ -9473,7 +9473,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "winprint"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/storytold/winprint.rs?rev=5f80b9baf6b58937c401656634e42d33f00ddf49#5f80b9baf6b58937c401656634e42d33f00ddf49"
|
||||
source = "git+https://github.com/storytold/winprint.rs?rev=51934db382f225454cf152a8657eb03789be63c4#51934db382f225454cf152a8657eb03789be63c4"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"fmt-derive",
|
||||
@@ -10006,7 +10006,6 @@ dependencies = [
|
||||
"nix",
|
||||
"typed-path",
|
||||
"windows-sys 0.61.2",
|
||||
"zopfli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -10021,18 +10020,6 @@ version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
||||
|
||||
[[package]]
|
||||
name = "zopfli"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aaf7fc5d30c28483d93805c4a5e12b05bbb52407fa67c5f8bd552374cd01fb11"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"crc32fast",
|
||||
"log",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zune-core"
|
||||
version = "0.4.12"
|
||||
|
||||
+10
-10
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
|
||||
rust-version = "1.95"
|
||||
|
||||
[workspace.dependencies]
|
||||
craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["serde"] }
|
||||
craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["serde"] }
|
||||
# internal
|
||||
photocraft-geom = { path = "crates/geom" }
|
||||
photocraft-color = { path = "crates/color" }
|
||||
@@ -39,13 +39,13 @@ photocraft-tablet = { path = "crates/tablet" }
|
||||
photocraft-ipp = { path = "crates/ipp" }
|
||||
|
||||
# external
|
||||
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["raster"] }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" }
|
||||
craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" }
|
||||
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["raster"] }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "b8f7d93b00dfb8f172938f3d2d796ae62dcfe123" }
|
||||
# craft-update: app-specific pretend versions apply to startup and manual checks.
|
||||
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["egui"] }
|
||||
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["egui"] }
|
||||
thiserror = "2"
|
||||
serde = { version = "1", features = ["derive", "rc"] }
|
||||
serde_json = "1"
|
||||
@@ -205,7 +205,7 @@ egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "6d518fc7
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
|
||||
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
|
||||
# craft-pdf's vendored Hayro trees: consumers patch the same craft-libs revision (crates/pdf README).
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
@@ -763,6 +763,7 @@ pub fn native(automation: Option<photocraft_automation::AuthorizedWorkspace>) ->
|
||||
open_url: Some(Box::new(|url: &str| open::that(url).map_err(|e| e.to_string()))),
|
||||
beep: Some(platform_beep),
|
||||
check_updates: Some(crate::updates::service()),
|
||||
last_update: Some(crate::updates::last_update),
|
||||
clipboard_set_image: Some({
|
||||
let clip = clip.clone();
|
||||
guarded_clipboard_set(move |w: u32, h: u32, px: &[u8]| {
|
||||
|
||||
@@ -218,7 +218,9 @@ fn open_filters_keep_literal_extensions_on_windows_and_macos() {
|
||||
|
||||
#[test]
|
||||
fn native_services_provide_update_transport() {
|
||||
assert!(native(None).check_updates.is_some());
|
||||
let services = native(None);
|
||||
assert!(services.check_updates.is_some());
|
||||
assert!(services.last_update.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -20,6 +20,19 @@ pub fn service() -> CheckFn {
|
||||
})
|
||||
}
|
||||
|
||||
/// What the last self-update came to, once: `craft-update` removes its records as it reads them.
|
||||
pub fn last_update() -> Option<Result<String, String>> {
|
||||
use craft_update::self_update::{Outcome, current_version, take_outcome};
|
||||
let app = &photocraft_ui_egui::UPDATE_APP;
|
||||
let paths = craft_update::Paths::for_app(app).ok()?;
|
||||
let version = photocraft_engine::build_info::VERSION;
|
||||
let running = current_version(app, version).map_or_else(|| version.to_string(), |v| v.to_string());
|
||||
match take_outcome(&paths, &running)? {
|
||||
Outcome::Installed(installed) => Some(Ok(installed.to_string())),
|
||||
Outcome::Failed(reason) => Some(Err(reason)),
|
||||
}
|
||||
}
|
||||
|
||||
fn check() -> CheckResult {
|
||||
let http = craft_update::Http::new("PhotoCraft/Update")?;
|
||||
let found = craft_update::check_for_update(&photocraft_ui_egui::UPDATE_APP, &http, photocraft_engine::build_info::VERSION)?;
|
||||
|
||||
@@ -71,6 +71,8 @@ pub mod contour_lib_cmds;
|
||||
mod count_delete_group_tests;
|
||||
#[cfg(test)]
|
||||
mod count_history_names_tests;
|
||||
#[cfg(test)]
|
||||
mod count_record_label_tests;
|
||||
pub mod cutout_cmds;
|
||||
pub mod distort_cmds;
|
||||
pub mod document_preset_cmds;
|
||||
|
||||
@@ -1099,7 +1099,9 @@ fn record(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
other => return Err(bad(CMD, format!("unknown source `{other}` (auto|selection|ruler|count)"))),
|
||||
};
|
||||
// Numbered only once the rows exist, so a failed measurement does not use up a label.
|
||||
let label = format!("Measurement {}", s.analysis.next_measurement + 1);
|
||||
// A count's row is "Count N" (#11775); the number is the shared one.
|
||||
let word = if source == "count" { "Count" } else { "Measurement" };
|
||||
let label = format!("{word} {}", s.analysis.next_measurement + 1);
|
||||
let now = p.get("dateTime").and_then(Value::as_str).map(str::to_string).unwrap_or_else(now_iso);
|
||||
let factor = d.measurement.scale.factor();
|
||||
let mut rows: Vec<Map<String, Value>> = Vec::new();
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
//! #11775: Record Measurements labels a Count tool row "Count N"; selection and ruler rows keep
|
||||
//! their labels, and N is the number the row gets today (the shared counter).
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::Session;
|
||||
|
||||
fn five_counts() -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 100, "height": 100})).unwrap();
|
||||
for i in 0..5 {
|
||||
s.execute("count.add", json!({"x": 10 + 10 * i, "y": 10})).unwrap();
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
fn record(s: &mut Session, source: &str) -> Value {
|
||||
let r = s.execute("image.analysis.recordMeasurements", json!({"source": source})).unwrap();
|
||||
let rows = r["rows"].as_array().unwrap();
|
||||
assert_eq!(rows.len(), 1, "{source}: {r}");
|
||||
rows[0]["values"].clone()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_count_row_is_labelled_count_n() {
|
||||
for source in ["count", "auto"] {
|
||||
let mut s = five_counts();
|
||||
let row = record(&mut s, source);
|
||||
assert_eq!(row["label"], json!("Count 1"), "{source}: {row}");
|
||||
assert_eq!(row["count"], json!(5), "{source}: {row}");
|
||||
assert_eq!(row["source"], json!("Count Tool"), "{source}: {row}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn other_rows_keep_their_labels_and_the_counter_is_shared() {
|
||||
let mut s = five_counts();
|
||||
s.execute("select.rect", json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap();
|
||||
let selection = record(&mut s, "selection");
|
||||
assert_eq!(selection["label"], json!("Measurement 1"), "{selection}");
|
||||
let count = record(&mut s, "count");
|
||||
assert_eq!(count["label"], json!("Count 2"), "{count}");
|
||||
// `auto` picks the selection over the counts, and keeps its label.
|
||||
let auto = record(&mut s, "auto");
|
||||
assert_eq!(auto["source"], json!("Selection"), "{auto}");
|
||||
assert_eq!(auto["label"], json!("Measurement 3"), "{auto}");
|
||||
s.execute("image.analysis.rulerTool", json!({"start": [0, 0], "end": [3, 4]})).unwrap();
|
||||
let ruler = record(&mut s, "ruler");
|
||||
assert_eq!(ruler["label"], json!("Measurement 4"), "{ruler}");
|
||||
let count = record(&mut s, "count");
|
||||
assert_eq!(count["label"], json!("Count 5"), "{count}");
|
||||
}
|
||||
@@ -47,7 +47,7 @@ use gradient_map::gradient_map;
|
||||
pub use gradient_map::{gradient_presets, is_gray, swatches};
|
||||
use hue_saturation::hue_saturation;
|
||||
#[cfg(test)]
|
||||
use hue_saturation::{lightness_track, move_hue_range_handle, saturation_track};
|
||||
use hue_saturation::{hue_range_handle_at, hue_range_zone, lightness_track, move_hue_range_handle, move_hue_range_zone, saturation_track};
|
||||
use levels::levels;
|
||||
pub(crate) use levels::levels_drag;
|
||||
pub use levels::{auto_levels, gamma_from_pos, gamma_pos};
|
||||
@@ -273,6 +273,53 @@ mod tests {
|
||||
assert_eq!(track_stops(&cx(false), &stops), None);
|
||||
}
|
||||
|
||||
/// #9272 review: at the narrowest Properties panel (a 230-point bar) a 30° zone is ~19 points
|
||||
/// wide; a press in its middle grabs the zone, not a handle, while each handle stays grabbable.
|
||||
#[test]
|
||||
fn hue_range_zones_stay_selectable_on_a_narrow_bar() {
|
||||
let w = 230.0;
|
||||
let xs = [75.0f32, 105.0, 135.0, 165.0].map(|d| d / 360.0 * w);
|
||||
for (a, z) in [(0, 1), (1, 2), (2, 3)] {
|
||||
assert_eq!(hue_range_handle_at(xs, (xs[a] + xs[z]) / 2.0, w), None, "the middle of zone {a}..{z} is the zone's");
|
||||
}
|
||||
for (k, x) in xs.iter().enumerate() {
|
||||
assert_eq!(hue_range_handle_at(xs, *x + 1.0, w), Some(k as u8), "handle {k}");
|
||||
}
|
||||
assert_eq!(hue_range_handle_at(xs, xs[0] - 9.0, w), Some(0), "the full reach outside the range");
|
||||
let stacked = [50.0, 50.0, 80.0, 120.0];
|
||||
assert!(hue_range_handle_at(stacked, 51.0, w).is_some(), "coinciding handles stay grabbable");
|
||||
// Reds (315/345…15\45): its fully-on zone crosses the seam, ~9.6 points from each edge.
|
||||
let reds = [315.0f32, 345.0, 15.0, 45.0].map(|d| d / 360.0 * w);
|
||||
for x in [w - 1.0, w - 3.0, 0.5, 2.5] {
|
||||
assert_eq!(hue_range_handle_at(reds, x, w), None, "x {x}: Reds' fully-on zone across the seam");
|
||||
}
|
||||
assert_eq!(hue_range_handle_at(reds, reds[1] + 1.0, w), Some(1));
|
||||
assert_eq!(hue_range_handle_at(reds, reds[2] - 1.0, w), Some(2));
|
||||
}
|
||||
|
||||
/// #9252: Photoshop 2025's zone drags on a colour range (measured on Reds): the fully-on span
|
||||
/// moves all four handles, each fade its own two; a side stops at the other and the range
|
||||
/// never passes a turn.
|
||||
#[test]
|
||||
fn hue_range_zones_move_their_handles() {
|
||||
let reds = [-45.0, -15.0, 15.0, 45.0];
|
||||
assert_eq!(hue_range_zone(reds, 345.0 - 15.0), Some(0));
|
||||
assert_eq!(hue_range_zone(reds, 0.0), Some(1));
|
||||
assert_eq!(hue_range_zone(reds, 30.0), Some(2));
|
||||
assert_eq!(hue_range_zone(reds, 180.0), None);
|
||||
let centre = move_hue_range_zone(reds, 1, 37.0);
|
||||
assert_eq!(centre, [-8.0, 22.0, 52.0, 82.0], "all four, as Photoshop's 315/345…15\\45 → 352/21…52\\81");
|
||||
let left = move_hue_range_zone(centre, 0, -19.0);
|
||||
assert_eq!(left, [-27.0, 3.0, 52.0, 82.0], "the left two only");
|
||||
let right = move_hue_range_zone(left, 2, 19.0);
|
||||
assert_eq!(right, [-27.0, 3.0, 71.0, 101.0], "the right two only");
|
||||
assert_eq!(move_hue_range_zone(reds, 0, 100.0), [-15.0, 15.0, 15.0, 45.0], "the left side stops at the right");
|
||||
assert_eq!(move_hue_range_zone(reds, 2, -100.0), [-45.0, -15.0, -15.0, 15.0], "and the right at the left");
|
||||
let wide = move_hue_range_zone(reds, 2, 500.0);
|
||||
assert!(wide[3] - wide[0] <= 359.0 + 1e-3, "{wide:?}");
|
||||
assert_eq!(move_hue_range_zone(reds, 1, f32::NAN), reds);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hue_range_drag_canonicalizes_bounds_before_clamping() {
|
||||
let moved = move_hue_range_handle([0.0, 350.0, 100.0, 200.0], 2, 354.0);
|
||||
|
||||
@@ -38,6 +38,62 @@ pub(super) fn move_hue_range_handle(bounds: [f32; 4], k: usize, deg: f32) -> [f3
|
||||
b
|
||||
}
|
||||
|
||||
/// The range handle a press at `x` grabs, given the four handles' x positions on a bar `w` wide:
|
||||
/// the nearest within 10 points, or within a third of the gap to the next handle on that side, so
|
||||
/// the middle third of a narrow zone still drags the zone (at least 3 points, for handles that
|
||||
/// coincide). The bar is a hue circle: the next handle past an edge is the first from the other.
|
||||
pub(super) fn hue_range_handle_at(xs: [f32; 4], x: f32, w: f32) -> Option<u8> {
|
||||
let k = nearest(&xs, x)?;
|
||||
let (xk, d) = (xs[k as usize], x - xs[k as usize]);
|
||||
let gap = xs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|&(j, _)| j != k as usize)
|
||||
.map(|(_, &o)| if d >= 0.0 { (o - xk).rem_euclid(w) } else { (xk - o).rem_euclid(w) })
|
||||
.fold(f32::INFINITY, f32::min);
|
||||
(d.abs() < (gap / 3.0).clamp(3.0, 10.0)).then_some(k)
|
||||
}
|
||||
|
||||
/// Which zone of a colour range a hue `deg` falls in, between its handles: 0 = the left fade
|
||||
/// (between the first two), 1 = the fully-on span, 2 = the right fade; `None` outside the range.
|
||||
pub(super) fn hue_range_zone(bounds: [f32; 4], deg: f32) -> Option<u8> {
|
||||
let b = HueRange::canonical_bounds(bounds);
|
||||
let rel = (deg - b[0]).rem_euclid(360.0);
|
||||
let (one, two, three) = (b[1] - b[0], b[2] - b[0], b[3] - b[0]);
|
||||
if rel <= one {
|
||||
Some(0)
|
||||
} else if rel <= two {
|
||||
Some(1)
|
||||
} else if rel <= three {
|
||||
Some(2)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// A drag of `delta` degrees on a zone of a colour range (#9252), as in Photoshop: the left fade
|
||||
/// moves the two left handles, the fully-on span all four, the right fade the two right handles;
|
||||
/// a side never crosses the other or grows the range past a turn.
|
||||
pub(super) fn move_hue_range_zone(start: [f32; 4], zone: u8, delta: f32) -> [f32; 4] {
|
||||
let b = HueRange::canonical_bounds(start);
|
||||
if !delta.is_finite() {
|
||||
return b;
|
||||
}
|
||||
let moved = match zone {
|
||||
0 => {
|
||||
let d = delta.min(b[2] - b[1]).max(b[3] - 359.0 - b[0]);
|
||||
[b[0] + d, b[1] + d, b[2], b[3]]
|
||||
}
|
||||
1 => b.map(|v| v + delta),
|
||||
2 => {
|
||||
let d = delta.max(b[1] - b[2]).min(b[0] + 359.0 - b[3]);
|
||||
[b[0], b[1], b[2] + d, b[3] + d]
|
||||
}
|
||||
_ => b,
|
||||
};
|
||||
HueRange::canonical_bounds(moved)
|
||||
}
|
||||
|
||||
/// The spectrum bar after the adjustment (what each hue becomes), sampled at `n` hues.
|
||||
fn adjusted_spectrum(v: &Value, n: usize) -> Vec<Color32> {
|
||||
let adj = photocraft_engine::commands::adjustment_from_params("hueSaturation", v);
|
||||
@@ -177,17 +233,44 @@ pub(super) fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) ->
|
||||
p.rect_filled(Rect::from_center_size(pos2(x, mid), vec2(5.0, 12.0)), 1.0, fill);
|
||||
p.rect_stroke(Rect::from_center_size(pos2(x, mid), vec2(5.0, 12.0)), 1.0, Stroke::new(1.0, t.text_dim), StrokeKind::Inside);
|
||||
}
|
||||
ui.data_mut(|d| d.insert_temp(cx.mem.with("hs-range-bars"), bars));
|
||||
let drag_id = cx.mem.with("hs-range-drag");
|
||||
let zone_id = cx.mem.with("hs-range-zone");
|
||||
let mut which: Option<u8> = ui.data(|d| d.get_temp(drag_id)).flatten();
|
||||
// A press between the handles drags a zone (#9252): its zone, the bounds and x it began at.
|
||||
let mut zone: Option<(u8, [f32; 4], f32)> = ui.data(|d| d.get_temp(zone_id)).flatten();
|
||||
if bresp.is_pointer_button_down_on()
|
||||
&& ui.input(|i| i.pointer.primary_pressed())
|
||||
&& let Some(pos) = ui.input(|i| i.pointer.press_origin())
|
||||
{
|
||||
which = nearest(&b.map(xof), pos.x).filter(|k| (xof(b[*k as usize]) - pos.x).abs() < 10.0);
|
||||
which = hue_range_handle_at(b.map(xof), pos.x, w);
|
||||
zone = if which.is_none() { hue_range_zone(b, deg_of(pos.x)).map(|z| (z, b, pos.x)) } else { None };
|
||||
}
|
||||
if bresp.is_pointer_button_down_on()
|
||||
&& let (Some(k), Some(pos)) = (which, ui.input(|i| i.pointer.interact_pos()))
|
||||
{
|
||||
// The release frame applies its position too: a move and a release that land in one frame
|
||||
// would otherwise commit the bounds from before the move. It ends where the button let go,
|
||||
// not where the pointer went after that in the same frame.
|
||||
let released_at = ui.input(|i| {
|
||||
i.events.iter().find_map(|e| match e {
|
||||
egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, .. } => Some(*pos),
|
||||
_ => None,
|
||||
})
|
||||
});
|
||||
let live = bresp.is_pointer_button_down_on() || released_at.is_some();
|
||||
let drag_pos = released_at.or_else(|| ui.input(|i| i.pointer.interact_pos()));
|
||||
if live && let (Some((z, start, x0)), Some(pos)) = (zone, drag_pos) {
|
||||
let before = b;
|
||||
b = move_hue_range_zone(start, z, (pos.x - x0) / w * 360.0);
|
||||
if b != before {
|
||||
v[key]["range"] = json!(b.map(|x| x.round()));
|
||||
e.changed = true;
|
||||
}
|
||||
}
|
||||
if zone.is_some() && !bresp.is_pointer_button_down_on() {
|
||||
zone = None;
|
||||
e.commit = true;
|
||||
}
|
||||
ui.data_mut(|d| d.insert_temp(zone_id, zone));
|
||||
if live && let (Some(k), Some(pos)) = (which, drag_pos) {
|
||||
let k = k as usize;
|
||||
let deg = deg_of(pos.x);
|
||||
let before = b;
|
||||
|
||||
@@ -1148,6 +1148,138 @@ fn gradient_map_stop_picker_closed_without_a_colour_changes_nothing() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #9252: in a Hue/Saturation layer's Properties, dragging the zones between the range handles
|
||||
/// moves them as Photoshop does: the fully-on span all four, a fade its own two; one history step
|
||||
/// per drag.
|
||||
#[test]
|
||||
fn hue_saturation_range_zones_drag_their_handles() {
|
||||
let mut h = app_harness("hueSaturation", "rgb", 8);
|
||||
let (id, _) = layer(&h);
|
||||
let mem = crate::adjust_editors::layer_mem(id);
|
||||
h.ctx.data_mut(|d| d.insert_temp(mem.with("hs-range"), 3usize)); // Greens: 75/105…135\165
|
||||
h.run_steps(3);
|
||||
let bars: Rect = h.ctx.data(|d| d.get_temp(mem.with("hs-range-bars"))).expect("the range bars");
|
||||
let x = |deg: f32| bars.left() + deg / 360.0 * bars.width();
|
||||
let y = bars.center().y;
|
||||
let greens = |h: &Harness<'_, PhotocraftApp>| match layer(h).1 {
|
||||
Adjustment::HueSaturation { ranges, .. } => ranges[2].bounds,
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
let steps = h.state().session.active().unwrap().history.past_len();
|
||||
drag(&mut h, Pos2::new(x(120.0), y), Pos2::new(x(156.0), y));
|
||||
let b = greens(&h);
|
||||
assert!((b[0] - 111.0).abs() <= 1.0 && (b[3] - 201.0).abs() <= 1.0 && (b[1] - b[0] - 30.0).abs() < 0.5, "all four moved ~36°: {b:?}");
|
||||
assert_eq!(h.state().session.active().unwrap().history.past_len(), steps + 1, "one step");
|
||||
let before = greens(&h);
|
||||
drag(&mut h, Pos2::new(x((before[0] + before[1]) / 2.0), y), Pos2::new(x((before[0] + before[1]) / 2.0 - 18.0), y));
|
||||
let b = greens(&h);
|
||||
assert!((b[0] - (before[0] - 18.0)).abs() <= 1.0 && (b[1] - (before[1] - 18.0)).abs() <= 1.0, "left two moved: {before:?} → {b:?}");
|
||||
assert_eq!([b[2], b[3]], [before[2], before[3]], "right two stay");
|
||||
}
|
||||
|
||||
/// CodeRabbit on #9272: a move and release that land in the same frame still move the zone; the
|
||||
/// release frame applies its position before the drag commits.
|
||||
#[test]
|
||||
fn a_zone_drag_released_in_the_frame_it_moves_still_moves() {
|
||||
let mut h = app_harness("hueSaturation", "rgb", 8);
|
||||
let (id, _) = layer(&h);
|
||||
let mem = crate::adjust_editors::layer_mem(id);
|
||||
h.ctx.data_mut(|d| d.insert_temp(mem.with("hs-range"), 3usize)); // Greens: 75/105…135\165
|
||||
h.run_steps(3);
|
||||
let bars: Rect = h.ctx.data(|d| d.get_temp(mem.with("hs-range-bars"))).expect("the range bars");
|
||||
let x = |deg: f32| bars.left() + deg / 360.0 * bars.width();
|
||||
let y = bars.center().y;
|
||||
let steps = h.state().session.active().unwrap().history.past_len();
|
||||
let (from, to) = (Pos2::new(x(120.0), y), Pos2::new(x(156.0), y));
|
||||
h.hover_at(from);
|
||||
h.run_steps(1);
|
||||
h.drag_at(from);
|
||||
h.run_steps(1);
|
||||
// One frame: the pointer moves and lets go (the harness's queued events take a frame each,
|
||||
// so both go straight into the next frame's input).
|
||||
let events = &mut h.input_mut().events;
|
||||
events.push(egui::Event::PointerMoved(to));
|
||||
events.push(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.run_steps(3);
|
||||
let b = match layer(&h).1 {
|
||||
Adjustment::HueSaturation { ranges, .. } => ranges[2].bounds,
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
assert!((b[0] - 111.0).abs() <= 1.0 && (b[3] - 201.0).abs() <= 1.0, "all four moved ~36°: {b:?}");
|
||||
assert_eq!(h.state().session.active().unwrap().history.past_len(), steps + 1, "one step");
|
||||
// A handle released in the frame it moves lands there too.
|
||||
let (from, to) = (Pos2::new(x(b[3]), y), Pos2::new(x(b[3] + 20.0), y));
|
||||
h.hover_at(from);
|
||||
h.run_steps(1);
|
||||
h.drag_at(from);
|
||||
h.run_steps(1);
|
||||
let events = &mut h.input_mut().events;
|
||||
events.push(egui::Event::PointerMoved(to));
|
||||
events.push(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.run_steps(3);
|
||||
let after = match layer(&h).1 {
|
||||
Adjustment::HueSaturation { ranges, .. } => ranges[2].bounds,
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
assert!((after[3] - (b[3] + 20.0)).abs() <= 1.0 && after[..3] == b[..3], "the right handle moved 20°: {b:?} → {after:?}");
|
||||
// A release followed by more movement in one frame ends where the button let go.
|
||||
let b = after;
|
||||
let (from, to) = (Pos2::new(x((b[1] + b[2]) / 2.0), y), Pos2::new(x((b[1] + b[2]) / 2.0 + 10.0), y));
|
||||
h.hover_at(from);
|
||||
h.run_steps(1);
|
||||
h.drag_at(from);
|
||||
h.run_steps(1);
|
||||
let events = &mut h.input_mut().events;
|
||||
events.push(egui::Event::PointerMoved(to));
|
||||
events.push(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
events.push(egui::Event::PointerMoved(Pos2::new(x(b[3] + 60.0), y)));
|
||||
h.run_steps(3);
|
||||
let last = match layer(&h).1 {
|
||||
Adjustment::HueSaturation { ranges, .. } => ranges[2].bounds,
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
assert!(last.iter().zip(&b).all(|(l, b)| (l - (b + 10.0)).abs() <= 1.0), "moved 10° to the release, not past it: {b:?} → {last:?}");
|
||||
}
|
||||
|
||||
/// FredApps review on #9272: a zone drag across the 0/360 seam. Reds' fully-on span sits on both
|
||||
/// ends of the bar; a drag from its middle third at either end (nearer a handle grabs the handle)
|
||||
/// moves the whole range intact, and the handles that pass the seam come out at the other end.
|
||||
#[test]
|
||||
fn hue_saturation_range_zone_drags_across_the_seam() {
|
||||
let mut h = app_harness("hueSaturation", "rgb", 8);
|
||||
let (id, _) = layer(&h);
|
||||
let mem = crate::adjust_editors::layer_mem(id);
|
||||
h.ctx.data_mut(|d| d.insert_temp(mem.with("hs-range"), 1usize)); // Reds: 315/345…15\45
|
||||
h.run_steps(3);
|
||||
let bars: Rect = h.ctx.data(|d| d.get_temp(mem.with("hs-range-bars"))).expect("the range bars");
|
||||
let x = |deg: f32| bars.left() + deg / 360.0 * bars.width();
|
||||
let y = bars.center().y;
|
||||
let reds = |h: &Harness<'_, PhotocraftApp>| match layer(h).1 {
|
||||
Adjustment::HueSaturation { ranges, .. } => ranges[0].bounds,
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
let on_circle = |b: [f32; 4]| b.map(|d| d.rem_euclid(360.0).round());
|
||||
let widths = |b: [f32; 4]| [b[1] - b[0], b[2] - b[1], b[3] - b[2]];
|
||||
let mut steps = h.state().session.active().unwrap().history.past_len();
|
||||
// (press, release, where the four handles land on the circle)
|
||||
for (from, to, want) in [
|
||||
// The span's right end, dragged left: 15\45 cross the seam to the right end.
|
||||
(358.0, 298.0, [255.0, 285.0, 315.0, 345.0]),
|
||||
// Back right from its middle: 315\345 cross the seam to the left end.
|
||||
(300.0, 360.0, [315.0, 345.0, 15.0, 45.0]),
|
||||
// The span's left end, dragged right: 315/345 cross the seam to the left end.
|
||||
(2.0, 62.0, [15.0, 45.0, 75.0, 105.0]),
|
||||
] {
|
||||
let before = reds(&h);
|
||||
drag(&mut h, Pos2::new(x(from), y), Pos2::new(x(to), y));
|
||||
let b = reds(&h);
|
||||
assert!(on_circle(b).iter().zip(&want).all(|(d, w)| (d - w).abs() <= 1.0), "{from}° → {to}°: {before:?} → {b:?}, want {want:?}");
|
||||
assert_eq!(widths(b), widths(before), "{from}° → {to}°: the range moves intact");
|
||||
steps += 1;
|
||||
assert_eq!(h.state().session.active().unwrap().history.past_len(), steps, "{from}° → {to}°: one step");
|
||||
}
|
||||
}
|
||||
|
||||
/// Selective Color in Properties: the Colors dropdown's choice lives in editor memory, so
|
||||
/// switching colour commits nothing, and each colour keeps its own row.
|
||||
#[test]
|
||||
|
||||
@@ -263,8 +263,8 @@ pub use services::{
|
||||
AdoptAutosaveFn, AppendTextFn, AutomationCommandFn, AutomationOpenPcraftFn, AutomationReadFn, AutomationWriteFn, AutosaveFn, AutosaveResultsFn, CapsLockFn,
|
||||
CaptionStyleFn, ClipboardGetFn, ClipboardGetSvgFn, ClipboardSetFn, ClipboardUnreadableFn, CursorPosFn, DiscardAutosaveFn, EncodePngFn, ExportFn,
|
||||
ExportSettings, ExternalSvgEditor, ExternalSvgSession, ExternalVectorSave, ExternalVectorSource, FileStamp, FileStampFn, FormatChoices, ImportFn, Inbox,
|
||||
LoadTextFn, OpenExternalSvgFn, OpenUrlFn, OsEventsFn, PenEndFn, PhotoshopShortcutsFn, PlaceInbox, QuitFn, RecoverFn, Recoverable, RightButtonDownFn,
|
||||
SameFileFn, SaveFileFn, SaveTextFn, Services, SystemThemeFn, TabletPollFn, WindowFrameFn, WriteFn,
|
||||
LastUpdateFn, LoadTextFn, OpenExternalSvgFn, OpenUrlFn, OsEventsFn, PenEndFn, PhotoshopShortcutsFn, PlaceInbox, QuitFn, RecoverFn, Recoverable,
|
||||
RightButtonDownFn, SameFileFn, SaveFileFn, SaveTextFn, Services, SystemThemeFn, TabletPollFn, WindowFrameFn, WriteFn,
|
||||
};
|
||||
pub use text::bidi_text;
|
||||
pub use text::cjk_fonts;
|
||||
|
||||
@@ -429,6 +429,10 @@ pub type PenEndFn = Box<dyn Fn() -> Option<bool> + Send + Sync>;
|
||||
/// whether the app window is focused (to re-assert WinTab overlap priority on activation).
|
||||
pub type TabletPollFn = Box<dyn FnMut(bool)>;
|
||||
|
||||
/// What the last self-update came to: `Ok` with the version it installed, `Err` with the reason it
|
||||
/// could not be installed, `None` when there is nothing to report ([`Services::last_update`]).
|
||||
pub type LastUpdateFn = fn() -> Option<Result<String, String>>;
|
||||
|
||||
/// Platform services injected by the app binary (file dialogs, codecs), keeping this crate free of
|
||||
/// I/O dependencies.
|
||||
#[derive(Default)]
|
||||
@@ -486,6 +490,9 @@ pub struct Services {
|
||||
pub alert: Option<fn()>,
|
||||
/// Starts a background check for published releases (desktop, outside Flatpak).
|
||||
pub check_updates: Option<photocraft_engine::updates_cmds::CheckFn>,
|
||||
/// What the last self-update came to, read once at the first frame: `Ok` with the version it
|
||||
/// installed, `Err` with the reason it could not be installed (desktop).
|
||||
pub last_update: Option<LastUpdateFn>,
|
||||
/// Files delivered asynchronously (web drag-and-drop): drained every frame and opened as
|
||||
/// documents.
|
||||
pub inbox: Option<Inbox>,
|
||||
|
||||
@@ -11,6 +11,12 @@ pub(crate) struct Runtime {
|
||||
/// The startup prompt and the self-update behind it (desktop).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
updater: craft_update::updater::Updater,
|
||||
/// What the last self-update came to, shown in the result window until it is closed.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
last_update: craft_update::updater::Status,
|
||||
/// The check running was asked for with Help ▸ Check for Updates.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
requested: bool,
|
||||
}
|
||||
|
||||
impl Default for Runtime {
|
||||
@@ -20,6 +26,10 @@ impl Default for Runtime {
|
||||
notified_version: None,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
updater: craft_update::updater::Updater::new(&crate::UPDATE_APP, photocraft_engine::build_info::VERSION),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
last_update: craft_update::updater::Status::Idle,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
requested: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,11 +61,33 @@ pub(crate) fn check(app: &mut PhotocraftApp, _ctx: &egui::Context, params: Value
|
||||
app.updates_rt.startup_checked = true;
|
||||
// A release the user dismissed is offered again by a manual check.
|
||||
app.updates_rt.notified_version = None;
|
||||
// The window shows this check from now on.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
app.updates_rt.requested = true;
|
||||
app.updates_rt.updater.dismiss_status();
|
||||
app.updates_rt.last_update = craft_update::updater::Status::Idle;
|
||||
// A check made before the first frame leaves the last self-update's records for the
|
||||
// next start.
|
||||
app.services.last_update = None;
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
pub(crate) fn tick(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if let Some(read) = app.services.last_update.take() {
|
||||
use craft_update::updater::Status as Shown;
|
||||
app.updates_rt.last_update = match read() {
|
||||
Some(Ok(version)) => Shown::Updated(version),
|
||||
Some(Err(reason)) => Shown::InstallFailed(reason),
|
||||
None => Shown::Idle,
|
||||
};
|
||||
if app.updates_rt.last_update != Shown::Idle {
|
||||
app.ui.updates_open = true;
|
||||
}
|
||||
}
|
||||
// `updates.status` also polls (automation may consume the result before this frame).
|
||||
app.session.updates.poll();
|
||||
if let Status::Available { release } = &app.session.updates.status
|
||||
@@ -64,7 +96,19 @@ pub(crate) fn tick(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
app.updates_rt.notified_version = Some(release.version.clone());
|
||||
app.ui.updates_open = true;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
app.updates_rt.updater.offer(release_of(release));
|
||||
{
|
||||
let updater = &mut app.updates_rt.updater;
|
||||
updater.offer(release_of(release));
|
||||
// While an update installs or waits for the app to close, or while the launcher keeps
|
||||
// this version, no prompt opens: a manual check reports that state in the result window.
|
||||
if std::mem::take(&mut app.updates_rt.requested) && !updater.prompt_open() {
|
||||
updater.check_now(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if !matches!(app.session.updates.status, Status::Checking) {
|
||||
app.updates_rt.requested = false;
|
||||
}
|
||||
if app.session.updates.check.is_none() {
|
||||
return;
|
||||
@@ -89,7 +133,7 @@ pub(crate) fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
{
|
||||
let was_open = app.updates_rt.updater.prompt_open();
|
||||
app.updates_rt.updater.tick(ctx);
|
||||
// The restart helper is scheduled before the app closes, so no update starts over unsaved work.
|
||||
// An update starts, and a ready one asks the app to close, only while no work is unsaved.
|
||||
let clean = !app.has_unsaved_work();
|
||||
match app.updates_rt.updater.show_if(ctx, clean) {
|
||||
craft_update::updater::Action::None => {}
|
||||
@@ -98,8 +142,9 @@ pub(crate) fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
// relaunches once the process exits.
|
||||
craft_update::updater::Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close),
|
||||
}
|
||||
// The last self-update's outcome, hidden while the prompt showed, is still shown after it.
|
||||
if was_open && !app.updates_rt.updater.prompt_open() {
|
||||
app.ui.updates_open = false;
|
||||
app.ui.updates_open = app.updates_rt.last_update != craft_update::updater::Status::Idle;
|
||||
}
|
||||
}
|
||||
if let Some(url) = download {
|
||||
@@ -108,15 +153,37 @@ pub(crate) fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
if app.updates_rt.updater.prompt_open() {
|
||||
return;
|
||||
}
|
||||
if app.ui.updates_open {
|
||||
let dialog = craft_update::CheckResultDialog::new(&crate::UPDATE_APP, photocraft_engine::build_info::VERSION);
|
||||
match dialog.show(ctx, &check_status(&app.session.updates.status)) {
|
||||
craft_update::CheckResultResponse::None => {}
|
||||
craft_update::CheckResultResponse::Close => app.ui.updates_open = false,
|
||||
craft_update::CheckResultResponse::CheckAgain => {
|
||||
let _ = check(app, ctx, serde_json::json!({}));
|
||||
}
|
||||
let status = shown_status(app);
|
||||
let dialog = craft_update::CheckResultDialog::new(&crate::UPDATE_APP, photocraft_engine::build_info::VERSION);
|
||||
match dialog.show(ctx, &status) {
|
||||
craft_update::CheckResultResponse::None => {}
|
||||
craft_update::CheckResultResponse::Close => {
|
||||
app.ui.updates_open = false;
|
||||
app.updates_rt.updater.dismiss_status();
|
||||
app.updates_rt.last_update = craft_update::updater::Status::Idle;
|
||||
}
|
||||
craft_update::CheckResultResponse::CheckAgain => {
|
||||
let _ = check(app, ctx, serde_json::json!({}));
|
||||
}
|
||||
craft_update::CheckResultResponse::RestartToUpdate => app.updates_rt.updater.restart_to_update(),
|
||||
}
|
||||
}
|
||||
|
||||
/// What the open result window shows: the updater's answer to a manual check (an update installing
|
||||
/// or ready, or a version the launcher keeps), else the last self-update's outcome, else the
|
||||
/// engine's check.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn shown_status(app: &PhotocraftApp) -> craft_update::updater::Status {
|
||||
use craft_update::updater::Status as Shown;
|
||||
let updater = app.updates_rt.updater.status();
|
||||
if !app.ui.updates_open {
|
||||
Shown::Idle
|
||||
} else if *updater != Shown::Idle {
|
||||
updater.clone()
|
||||
} else if app.updates_rt.last_update != Shown::Idle {
|
||||
app.updates_rt.last_update.clone()
|
||||
} else {
|
||||
check_status(&app.session.updates.status)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +337,59 @@ mod tests {
|
||||
assert!(app.updates_rt.updater.prompt_open());
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn press_escape(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
let escape = egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE };
|
||||
let mut output = ctx.run_ui(egui::RawInput { events: vec![escape], ..Default::default() }, |ui| show(app, ui.ctx()));
|
||||
output.textures_delta.clear();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn the_last_update_opens_the_result_window_once_until_it_is_closed() {
|
||||
use craft_update::updater::Status as Shown;
|
||||
let (mut app, _, _) = app();
|
||||
app.services.last_update = Some(|| Some(Ok("99.0.0".into())));
|
||||
let ctx = egui::Context::default();
|
||||
at(&mut app, &ctx, 0.0);
|
||||
assert!(app.ui.updates_open);
|
||||
assert_eq!(shown_status(&app), Shown::Updated("99.0.0".into()));
|
||||
assert!(app.services.last_update.is_none(), "read once");
|
||||
at(&mut app, &ctx, 1.0);
|
||||
assert_eq!(shown_status(&app), Shown::Updated("99.0.0".into()), "shown until closed");
|
||||
press_escape(&mut app, &ctx);
|
||||
assert!(!app.ui.updates_open);
|
||||
assert_eq!(app.updates_rt.last_update, Shown::Idle);
|
||||
assert_eq!(shown_status(&app), Shown::Idle);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn a_failed_update_is_reported_until_a_manual_check_replaces_it() {
|
||||
use craft_update::updater::Status as Shown;
|
||||
let (mut app, calls, _) = app();
|
||||
app.services.last_update = Some(|| Some(Err("the installer exited with code 1603".into())));
|
||||
app.session.edit_prefs(|p| p.general.automatically_check_updates = false);
|
||||
let ctx = egui::Context::default();
|
||||
at(&mut app, &ctx, 0.0);
|
||||
assert_eq!(shown_status(&app), Shown::InstallFailed("the installer exited with code 1603".into()));
|
||||
menus::invoke(&mut app, &ctx, "help.checkForUpdates", serde_json::json!({})).unwrap();
|
||||
assert_eq!(*calls.lock().unwrap(), 1);
|
||||
assert_eq!(shown_status(&app), Shown::Checking, "the window shows the new check");
|
||||
|
||||
let (mut early, _, _) = self::app();
|
||||
early.services.last_update = Some(|| Some(Err("unread".into())));
|
||||
menus::invoke(&mut early, &ctx, "help.checkForUpdates", serde_json::json!({})).unwrap();
|
||||
at(&mut early, &ctx, 0.0);
|
||||
assert_eq!(shown_status(&early), Shown::Checking, "a check before the first frame is not replaced by the last update");
|
||||
assert!(early.services.last_update.is_none());
|
||||
|
||||
let (mut quiet, _, _) = self::app();
|
||||
quiet.services.last_update = Some(|| None);
|
||||
at(&mut quiet, &ctx, 0.0);
|
||||
assert!(!quiet.ui.updates_open, "nothing to report opens nothing");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_manual_check_that_fails_to_start_opens_the_status_window() {
|
||||
let mut app =
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
# UI parity: tools, handles, modifiers and feel
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-08 · **Change:** minor (a click on the image centres a filter dialog's preview window, #9648; a gradient stop dragged off the bar is removed in every stop editor, Gradient Map and Layer Style included, #10742; Image › Adjustments › Photo Filter… keeps Preserve Luminosity from its last OK and opens at Warming Filter (85), 25 %, as the reference application does, #9879; foreground/background swatches and exact CMYK picks restored across launches, #8485; Layer ▸ Smart Objects ▸ Reset Transform and the Layers panel row-menu item for a smart object layer: 100 % again in place with the Warp cleared and centred on the corners' average, #11662; each toolbar slot and tool key keeps its last tool across launches, #3569; Image › Adjustments › Selective Color keeps each colour's own values and applies all nine, #11463; History Options snapshot options, #3634; Channels panel menu: New Channel…, Duplicate Channel, Delete Channel, New Spot Channel…, Merge Spot Channel, Channel Options…, Split Channels, Merge Channels…, #11451; a Color Picker for another dialog's colour or the Crop shield shows the picked colour there before OK, #9886; Edit › Transform › Distort side handles move their edge, Perspective side handles skew, #10085; Ctrl + Alt + wheel zooms the canvas like ⌥ + wheel on Windows and Linux, where winit reports a held Ctrl as both ctrl and command, #10488; Layers panel filter by Color, #5898; 11 of 183 preferences do nothing: startup reads Graphics Adapter through the typed Performance section, so the scorecard audit sees it; Shape Fill/Stroke popover as Photoshop's, every colour swatch opens the full Color Picker with a live preview; the text and gradient stop Color Pickers show the picked colour on the canvas before OK, #5530; selected colour sets edit drawing, tone and supported filters; geometry remains open; a paragraph box that can't hold its text enlarges its lower-right handle and shows a black + in it, as the reference application; Free Transform of several selected layers, #6501; Path Operations fixes: the first component keeps combining, a hidden component selection is left alone, a dragged live shape stays live, a refused Pen draft ends once; Pen, Freeform Pen, Curvature Pen and Path Selection Path Operations menu, which changes selected components, `+` / `-` keys, #1397; the Pen carries on an open shape or vector mask path; selection-aware font controls, pending caret fonts and focused commit, plus direct font-name editing with a compact no-match message, #9338; New Group dialog and button modifiers; new layers go into an open active group and join a clipping mask, except that type, shapes, pastes and placed files go above a group whose lock would refuse them; Color panel Hue and Brightness Cube show the out-of-gamut ⚠ and nearest printable colour when the field is at least 53 pt tall, #8672; Art History Brush in the History group of the Y flyout, partial, TOOL-213-20, #1610; Histogram panel: Compact / Expanded / All Channels views, Luminosity and Colors channels, Source, range statistics, Uncached Refresh, live adjustment overlay, Cache Levels preference; the font menu opens on the current family, marked in the recent group when it is a recent one, #9160; Type options bar alignment and direction follow the target paragraph; a swatch click recolours selected type and shape layers with any tool, #9238; UI scale presets done: 105–120% steps, #3222; ⇧⌥ blend mode letters; painting tool Mode menus; ⌥ + an adjustment's shortcut reopens it at its last settings, ⌥⌘L / ⌥⌘M, #8900; Crop default mode: moving the image under the box snaps the frame's edges and centre, #8580; View › Extras hides the Move transform controls, #6699; adjustment clipping stays visible in compact Properties, #5231; Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; a picked colour recolours the selected type and shapes; Hand tool ⌘ / ⌥ are Zoom In / Zoom Out while held, #6434; the wheel steps value fields, #5473; a dragged guide shows its X or Y beside the pointer, #7680; Type options bar "T" icon scrubs the font size, #6437; Move tool: dragged selected pixels take their own outline as the selection, #7538; artboard backgrounds remain below child Free Transform previews; ⌫/Delete removes the selected smart filter, #4751; Object Finder foreground/background discrimination (#6548); rounded triangle, polygon and star corners; shape Fill/Stroke popovers accept hex RGB values, #6176; a guide let go over either ruler is removed, #6286; Crop rows corrected: saved crop presets and Delete Cropped Pixels off are done, #6562; marching ants in device pixels, #7489; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; Line truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-08 · **Change:** minor (Hue/Saturation range zones drag, #9252; a click on the image centres a filter dialog's preview window, #9648; a gradient stop dragged off the bar is removed in every stop editor, Gradient Map and Layer Style included, #10742; Image › Adjustments › Photo Filter… keeps Preserve Luminosity from its last OK and opens at Warming Filter (85), 25 %, as the reference application does, #9879; foreground/background swatches and exact CMYK picks restored across launches, #8485; Layer ▸ Smart Objects ▸ Reset Transform and the Layers panel row-menu item for a smart object layer: 100 % again in place with the Warp cleared and centred on the corners' average, #11662; each toolbar slot and tool key keeps its last tool across launches, #3569; Image › Adjustments › Selective Color keeps each colour's own values and applies all nine, #11463; History Options snapshot options, #3634; Channels panel menu: New Channel…, Duplicate Channel, Delete Channel, New Spot Channel…, Merge Spot Channel, Channel Options…, Split Channels, Merge Channels…, #11451; a Color Picker for another dialog's colour or the Crop shield shows the picked colour there before OK, #9886; Edit › Transform › Distort side handles move their edge, Perspective side handles skew, #10085; Ctrl + Alt + wheel zooms the canvas like ⌥ + wheel on Windows and Linux, where winit reports a held Ctrl as both ctrl and command, #10488; Layers panel filter by Color, #5898; 11 of 183 preferences do nothing: startup reads Graphics Adapter through the typed Performance section, so the scorecard audit sees it; Shape Fill/Stroke popover as Photoshop's, every colour swatch opens the full Color Picker with a live preview; the text and gradient stop Color Pickers show the picked colour on the canvas before OK, #5530; selected colour sets edit drawing, tone and supported filters; geometry remains open; a paragraph box that can't hold its text enlarges its lower-right handle and shows a black + in it, as the reference application; Free Transform of several selected layers, #6501; Path Operations fixes: the first component keeps combining, a hidden component selection is left alone, a dragged live shape stays live, a refused Pen draft ends once; Pen, Freeform Pen, Curvature Pen and Path Selection Path Operations menu, which changes selected components, `+` / `-` keys, #1397; the Pen carries on an open shape or vector mask path; selection-aware font controls, pending caret fonts and focused commit, plus direct font-name editing with a compact no-match message, #9338; New Group dialog and button modifiers; new layers go into an open active group and join a clipping mask, except that type, shapes, pastes and placed files go above a group whose lock would refuse them; Color panel Hue and Brightness Cube show the out-of-gamut ⚠ and nearest printable colour when the field is at least 53 pt tall, #8672; Art History Brush in the History group of the Y flyout, partial, TOOL-213-20, #1610; Histogram panel: Compact / Expanded / All Channels views, Luminosity and Colors channels, Source, range statistics, Uncached Refresh, live adjustment overlay, Cache Levels preference; the font menu opens on the current family, marked in the recent group when it is a recent one, #9160; Type options bar alignment and direction follow the target paragraph; a swatch click recolours selected type and shape layers with any tool, #9238; UI scale presets done: 105–120% steps, #3222; ⇧⌥ blend mode letters; painting tool Mode menus; ⌥ + an adjustment's shortcut reopens it at its last settings, ⌥⌘L / ⌥⌘M, #8900; Crop default mode: moving the image under the box snaps the frame's edges and centre, #8580; View › Extras hides the Move transform controls, #6699; adjustment clipping stays visible in compact Properties, #5231; Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; a picked colour recolours the selected type and shapes; Hand tool ⌘ / ⌥ are Zoom In / Zoom Out while held, #6434; the wheel steps value fields, #5473; a dragged guide shows its X or Y beside the pointer, #7680; Type options bar "T" icon scrubs the font size, #6437; Move tool: dragged selected pixels take their own outline as the selection, #7538; artboard backgrounds remain below child Free Transform previews; ⌫/Delete removes the selected smart filter, #4751; Object Finder foreground/background discrimination (#6548); rounded triangle, polygon and star corners; shape Fill/Stroke popovers accept hex RGB values, #6176; a guide let go over either ruler is removed, #6286; Crop rows corrected: saved crop presets and Delete Cropped Pixels off are done, #6562; marching ants in device pixels, #7489; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames everyLine truncated
|
||||
|
||||
How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, the
|
||||
handles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,
|
||||
@@ -295,6 +295,7 @@ Paragraph; the rest open as in-app floating windows.
|
||||
| 2026-10-24 | minor | Path Selection selects path components and has the Path Operations menu; the menu and `+` / `-` change the selected components' operation (`path.setOperation`); the Pen carries on an open shape layer or vector mask path from its endpoint (#1397 feedback); row stays partial until the Shape tools have the menu; no percentage changed |
|
||||
| 2026-10-25 | minor | Every preference takes effect: 12 of 178 do nothing, the scorecard's count (it still said 46 of 149) |
|
||||
| 2026-10-25 | minor | Art History Brush is in the History group of the Y flyout (partial, TOOL-213-20, #1610) |
|
||||
| 2026-10-24 | minor | Hue/Saturation: dragging between a colour range's handles moves them as Photoshop 2025 does: the fully-on span moves all four, each fade its own two (#9252). Scores unchanged. |
|
||||
| 2026-10-24 | minor | Color panel: Hue Cube and Brightness Cube show Photoshop's out-of-gamut ⚠ and the nearest printable colour under the chips when the field is at least 53 pt tall, as the slider modes did; a click takes it (#8672). No percentage changed |
|
||||
| 2026-10-24 | minor | Swatches: a click recolours the selected type layers and shape fills whatever the tool, as Photoshop 2025 does (measured with the Move and Brush tools); the Color panel still recolours them only with a Type, shape or Pen tool (#9238). Scores unchanged. |
|
||||
| 2026-10-24 | minor | Type options bar: the alignment and paragraph-direction buttons show the edited or selected type layer's paragraph instead of the tool defaults, as Photoshop's bar does. Scores unchanged. |
|
||||
|
||||
Reference in new issue
Block a user