mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Reset the Black & White preset label at default weights
This commit is contained in:
1 parent
aec5cee320
commit
0146460e38
4 files changed
+32
-13
No files matched your search
@@ -35,7 +35,7 @@ use serde_json::{Value, json};
|
||||
|
||||
use crate::PhotocraftApp;
|
||||
|
||||
mod black_white_presets;
|
||||
pub(crate) mod black_white_presets;
|
||||
mod session;
|
||||
pub mod values;
|
||||
|
||||
|
||||
@@ -53,6 +53,11 @@ fn manual_id(ui: &Ui) -> egui::Id {
|
||||
ui.make_persistent_id("black-white-manual-value")
|
||||
}
|
||||
|
||||
pub(crate) fn clear_custom(ui: &Ui) {
|
||||
ui.data_mut(|d| d.remove::<ManualValue>(manual_id(ui)));
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
|
||||
/// The Properties host applies accepted Color Picker colors and Auto outside the editor's pass.
|
||||
pub(super) fn mark_custom(ui: &Ui, value: &AdjustValue) {
|
||||
if let AdjustValue::BlackWhite { value } = value {
|
||||
|
||||
@@ -554,19 +554,22 @@ fn black_white_presets_distinguish_manual_edits_from_named_choices() {
|
||||
let (id, defaults) = layer(&h);
|
||||
let Adjustment::BlackWhite { weights, .. } = &defaults else { panic!("{defaults:?}") };
|
||||
let red = weights[0];
|
||||
h.state_mut().run("layer.setAdjustment", json!({"layer": id.0, "reds": red + 7.0})).unwrap();
|
||||
h.run_steps(4);
|
||||
assert_black_white_preset(&h, "Custom");
|
||||
let type_default = |h: &mut Harness<'_, Box<PhotocraftApp>>| {
|
||||
h.state_mut().run("layer.setAdjustment", json!({"layer": id.0, "reds": red + 7.0})).unwrap();
|
||||
h.run_steps(4);
|
||||
assert_black_white_preset(h, "Custom");
|
||||
h.get_by_role_and_label(Role::SpinButton, "Reds").click();
|
||||
h.run_steps(1);
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);
|
||||
h.event(egui::Event::Text(red.to_string()));
|
||||
h.run_steps(1);
|
||||
h.key_press(egui::Key::Tab);
|
||||
h.run_steps(4);
|
||||
assert_eq!(layer(h).1, defaults);
|
||||
assert_black_white_preset(h, "Custom");
|
||||
};
|
||||
|
||||
h.get_by_role_and_label(Role::SpinButton, "Reds").click();
|
||||
h.run_steps(1);
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);
|
||||
h.event(egui::Event::Text(red.to_string()));
|
||||
h.run_steps(1);
|
||||
h.key_press(egui::Key::Tab);
|
||||
h.run_steps(4);
|
||||
assert_eq!(layer(&h).1, defaults);
|
||||
assert_black_white_preset(&h, "Custom");
|
||||
type_default(&mut h);
|
||||
|
||||
h.state_mut().run("layer.newAdjustmentLayer.blackWhite", json!({})).unwrap();
|
||||
h.run_steps(4);
|
||||
@@ -583,4 +586,12 @@ fn black_white_presets_distinguish_manual_edits_from_named_choices() {
|
||||
assert_black_white_preset(&h, "Default");
|
||||
assert_eq!(layer(&h).1, defaults);
|
||||
assert_eq!(history_len(&h), history);
|
||||
|
||||
type_default(&mut h);
|
||||
h.get_by_role_and_label(Role::Button, "Reset to defaults").scroll_to_me();
|
||||
h.run_steps(2);
|
||||
h.get_by_role_and_label(Role::Button, "Reset to defaults").click();
|
||||
h.run_steps(4);
|
||||
assert_black_white_preset(&h, "Default");
|
||||
assert_eq!(layer(&h).1, defaults);
|
||||
}
|
||||
@@ -156,6 +156,9 @@ fn adjustment_controls(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: LayerId,
|
||||
let params = crate::adjust_editors::layer_reset(app, id, adj);
|
||||
let _ = app.run("layer.setAdjustment", params);
|
||||
app.live_adjust = None;
|
||||
if matches!(adj, photocraft_doc::Adjustment::BlackWhite { .. }) {
|
||||
crate::adjust_editors::black_white_presets::clear_custom(ui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user