Show Channel: grayscale and colorized of one channel replace each other
Alt+1 after Alt+Shift+1 shows the red channel in grayscale instead of going back to RGB (and the other way round). The same key again is still RGB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dfff9ba2dc
commit
498dbc0c71
|
|
@ -127,8 +127,10 @@ fn snapping_options(s: &mut Session, p: &Value) -> Result<Value> {
|
|||
fn channel(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let name = str_p(p, "channel").unwrap_or("rgb");
|
||||
let c = Channel::from_name(name).ok_or_else(|| bad("view.channel", format!("unknown channel `{name}` (rgb|red|green|blue|alpha|rgbStraight)")))?;
|
||||
// Choosing the active single channel again returns to RGB, as in After Effects.
|
||||
let c = if c == s.state.viewer.channel && c != Channel::Rgb && b_p(p, "toggle").unwrap_or(false) { Channel::Rgb } else { c };
|
||||
// Choosing the active single channel again returns to RGB; not when that changes it between
|
||||
// grayscale and colorized.
|
||||
let same = c == s.state.viewer.channel && b_p(p, "colorized").is_none_or(|v| v == s.state.viewer.colorized);
|
||||
let c = if same && c != Channel::Rgb && b_p(p, "toggle").unwrap_or(false) { Channel::Rgb } else { c };
|
||||
s.state.viewer.channel = c;
|
||||
if let Some(v) = b_p(p, "colorized") {
|
||||
s.state.viewer.colorized = v;
|
||||
|
|
|
|||
|
|
@ -408,6 +408,14 @@ fn fast_previews_and_show_channel_modes_have_default_keys() {
|
|||
assert_eq!((s.state.viewer.channel.id(), s.state.viewer.colorized), ("green", false));
|
||||
s.execute("view.channel.green", json!({})).unwrap();
|
||||
assert_eq!(s.state.viewer.channel.id(), "rgb");
|
||||
// Grayscale and colorized of one channel replace each other; the same again is RGB.
|
||||
s.execute("view.channel.redColorized", json!({})).unwrap();
|
||||
s.execute("view.channel.red", json!({})).unwrap();
|
||||
assert_eq!((s.state.viewer.channel.id(), s.state.viewer.colorized), ("red", false));
|
||||
s.execute("view.channel.redColorized", json!({})).unwrap();
|
||||
assert_eq!((s.state.viewer.channel.id(), s.state.viewer.colorized), ("red", true));
|
||||
s.execute("view.channel.redColorized", json!({})).unwrap();
|
||||
assert_eq!(s.state.viewer.channel.id(), "rgb");
|
||||
}
|
||||
|
||||
/// Default keys for commands and menu entries that had none.
|
||||
|
|
|
|||
Loading…
Reference in New Issue