Levels and Curves show the point picker row first, above the Channel select

This commit is contained in:
aiongg
2026-11-16 16:34:53 +00:00
parent 63a4811416
commit a2a7f492a2
2 changed files with 48 additions and 47 deletions
+24 -23
View File
@@ -1,5 +1,5 @@
//! [`CurvesPanel`]: the Curves adjustment around the [`CurveEditor`]: the Channel select, the mode
//! icons (points, pencil), Smooth, the point pickers, the other channels overlaid on the composite
//! [`CurvesPanel`]: the Curves adjustment around the [`CurveEditor`]: the point pickers, the Channel
//! select, the mode icons (points, pencil), Smooth, the other channels overlaid on the composite
//! and the hint line; and the ⌘/Ctrl-click-on-the-image helper
//! ([`CurvesPanel::add_point_from_sample`]).
@@ -139,15 +139,15 @@ type SamplerFn<'a> = Box<dyn Fn(&[[f32; 2]]) -> Vec<f32> + 'a>;
/// The Curves adjustment: Image › Adjustments › Curves and a Curves layer's Properties panel.
///
/// Top to bottom:
/// 1. The Channel select ([`ToneChannels`]); an isolated channel is the only entry, its name shown exactly as the
/// Top to bottom (PhotoCraft's order):
/// 1. With [`pickers`](Self::pickers), the point picker row.
/// 2. The Channel select ([`ToneChannels`]); an isolated channel is the only entry, its name shown exactly as the
/// host gave it.
/// 2. The mode row: two icon-only toggle buttons ("Edit points to modify the curve", "Draw to modify the curve", the
/// 3. The mode row: two icon-only toggle buttons ("Edit points to modify the curve", "Draw to modify the curve", the
/// current one pressed) and Smooth (enabled in pencil mode only).
/// 3. The [`CurveEditor`] for the shown channel: in its colour, over its histogram, in pencil mode for a drawn curve,
/// 4. The [`CurveEditor`] for the shown channel: in its colour, over its histogram, in pencil mode for a drawn curve,
/// and, on a composite only, the other channels' curves as overlays (Photoshop; none for an isolated channel).
/// 4. The hint line, with the key names from the platform's shortcut words.
/// 5. With [`pickers`](Self::pickers), the point picker row.
/// 5. The hint line, with the key names from the platform's shortcut words.
///
/// - **Smooth** replaces the shown map with its moving average over 7 levels (radius 3, shrunk at the ends so the
/// first and last levels keep their values: PhotoCraft's `smooth_curve_map`), as one `Set`.
@@ -168,7 +168,7 @@ pub struct CurvesPanel<'a> {
/// The host's interpolation of point curves ([`CurveEditor::sampler`]).
#[prop(boxed = "Fn(&[[f32; 2]]) -> Vec<f32> + 'a")]
sampler: Option<SamplerFn<'a>>,
/// The armed point picker; the picker row shows when it is given.
/// The armed point picker; the picker row shows, first, when it is given.
#[prop]
pickers: Option<Bind<'a, Option<TonePicker>>>,
/// The document canvas the ⌘/Ctrl-click and the eyedroppers reach under the dialog.
@@ -313,6 +313,21 @@ impl<'a> CurvesPanel<'a> {
// Alt+2…Alt+6 pick the Channel select's entry in a dialog; Properties has no such keys.
let stack = if context.is_dialog() { stack.command_scope(ToneChannelCommands::SCOPE) } else { stack };
let group = stack.show(ui, |ui, cx| {
if let Some(armed) = pickers.as_mut() {
let mut row = TonePickerRow::new(armed.reborrowed());
if pickers_unavailable {
row = row.unavailable();
}
if let Some(canvas) = canvas {
row = row.canvas(canvas);
}
for each in TonePicker::ALL {
let usable = picker_enabled[each as usize] && !(each == TonePicker::Gray && (channels.is_gray() || context.is_gray()));
row = row.enabled_picker(each, usable);
}
picker = row.show(ui).change;
}
let value = match curves.reborrow().read(cx) {
Some(Mixed::Same(value)) => value,
_ => ToneCurves::identity(&channels),
@@ -406,20 +421,6 @@ impl<'a> CurvesPanel<'a> {
}
edit = events;
if let Some(armed) = pickers.as_mut() {
let mut row = TonePickerRow::new(armed.reborrowed());
if pickers_unavailable {
row = row.unavailable();
}
if let Some(canvas) = canvas {
row = row.canvas(canvas);
}
for each in TonePicker::ALL {
let usable = picker_enabled[each as usize] && !(each == TonePicker::Gray && (channels.is_gray() || context.is_gray()));
row = row.enabled_picker(each, usable);
}
picker = row.show(ui).change;
}
// An edit belongs to the channel it was drawn for; a switch shows from the next pass, with no selection.
shown_channel = if picked == channel || !edit.is_empty() { channel } else { picked };
write_shown(&mut channel_bind, cx, stored, shown_channel);
+24 -24
View File
@@ -1,5 +1,5 @@
//! [`LevelsPanel`]: the Levels adjustment around the [`LevelsEditor`]: the Channel select, Auto,
//! the editor over the shown channel's histogram and the point pickers.
//! [`LevelsPanel`]: the Levels adjustment around the [`LevelsEditor`]: the point pickers, the
//! Channel select, Auto and the editor over the shown channel's histogram.
#[cfg(feature = "screen-testing")]
mod stories;
@@ -78,20 +78,19 @@ impl Outcome for LevelsPanelOutput {
/// The Levels adjustment: Image › Adjustments › Levels and a Levels layer's Properties panel
/// (the same call with [`AdjustContext::properties`]).
///
/// Top to bottom (PhotoCraft's and Photoshop's order):
/// 1. The Channel select ([`ToneChannels`]; an isolated channel is the only entry, named as given)
/// Top to bottom (PhotoCraft's order):
/// 1. With [`pickers`](Self::pickers), the [`TonePickerRow`]: Set Black, Neutral Gray, White Point.
/// 2. The Channel select ([`ToneChannels`]; an isolated channel is the only entry, named as given)
/// and Auto. Picking a channel shows that channel's levels and histogram; the choice is the
/// panel's own state, reported as [`LevelsPanelOutput::channel`].
/// 2. The [`LevelsEditor`] for the shown channel, over its histogram drawn in the channel's colour;
/// 3. The [`LevelsEditor`] for the shown channel, over its histogram drawn in the channel's colour;
/// a [`stale`](Self::stale) histogram shows the stale mark.
/// 3. With [`pickers`](Self::pickers), the [`TonePickerRow`] below: Set Black, Neutral Gray, White
/// Point.
///
/// - **Auto** sets the shown channel to [`Levels::auto`] of its histogram as one `Set`; without a
/// histogram it is disabled.
/// - **Edits**: the editor's events pass through for the shown channel, mapped onto the per-channel
/// values.
/// - **Keyboard**: Tab visits the Channel select, Auto, the editor, then the pickers.
/// - **Keyboard**: Tab visits the pickers, the Channel select, Auto, then the editor.
#[must_use = "show the panel with `show`"]
#[derive(Pattern, Props)]
pub struct LevelsPanel<'a> {
@@ -105,7 +104,7 @@ pub struct LevelsPanel<'a> {
/// The histograms are being recounted.
#[prop]
stale: bool,
/// The armed point picker; the picker row shows when it is given.
/// The armed point picker; the picker row shows, first, when it is given.
#[prop]
pickers: Option<Bind<'a, Option<TonePicker>>>,
/// The document canvas the armed picker samples.
@@ -178,6 +177,22 @@ impl<'a> LevelsPanel<'a> {
// Alt+2…Alt+6 pick the Channel select's entry in a dialog; Properties has no such keys.
let stack = if context.is_dialog() { stack.command_scope(ToneChannelCommands::SCOPE) } else { stack };
let group = stack.show(ui, |ui, cx| {
if let Some(armed) = pickers.as_mut() {
let mut row = TonePickerRow::new(armed.reborrowed());
if pickers_unavailable {
row = row.unavailable();
}
if let Some(canvas) = canvas {
row = row.canvas(canvas);
}
for each in TonePicker::ALL {
// A grey document has no Neutral Gray point.
let usable = picker_enabled[each as usize] && !(each == TonePicker::Gray && (channels.is_gray() || context.is_gray()));
row = row.enabled_picker(each, usable);
}
picker = row.show(ui).change;
}
let all: Vec<Levels> = match levels.reborrow().read(cx) {
Some(Mixed::Same(all)) => all,
_ => Vec::new(),
@@ -232,21 +247,6 @@ impl<'a> LevelsPanel<'a> {
}
edit = events;
if let Some(armed) = pickers.as_mut() {
let mut row = TonePickerRow::new(armed.reborrowed());
if pickers_unavailable {
row = row.unavailable();
}
if let Some(canvas) = canvas {
row = row.canvas(canvas);
}
for each in TonePicker::ALL {
// A grey document has no Neutral Gray point.
let usable = picker_enabled[each as usize] && !(each == TonePicker::Gray && (channels.is_gray() || context.is_gray()));
row = row.enabled_picker(each, usable);
}
picker = row.show(ui).change;
}
// An edit belongs to the channel it was drawn for; a switch shows from the next pass.
shown = if picked == channel || !edit.is_empty() { channel } else { picked };
write_shown(&mut channel_bind, cx, stored, shown);