diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index e3a50f6894..37f96d60b2 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -377,12 +377,17 @@ pub(crate) fn ok() -> Result { /// Parse a colour param: `"#RRGGBB"`, `"accent1"`…, or `{"scheme":"accent2","lumMod":75000}`. /// A preset or system colour keeps its base: `{"preset":"red"}`, -/// `{"system":"windowText","last":"#000000"}`. +/// `{"system":"windowText","last":"#000000"}`. `"mods"` lists transforms in order: +/// `{"preset":"red","mods":[{"op":"inv"},{"op":"inv"}]}`. A color whose keyed and listed transforms +/// together number more than [`MAX_COLOR_MODS`] is invalid. pub(crate) fn color_param(p: &Value, key: &str) -> Option { let v = p.get(key)?; color_value(v) } +/// Most transforms a color param may hold, keyed transforms and the `"mods"` list together. +pub(crate) const MAX_COLOR_MODS: usize = 256; + pub(crate) fn color_value(v: &Value) -> Option { use deckcraft_model::ColorRef; match v { @@ -417,12 +422,62 @@ pub(crate) fn color_value(v: &Value) -> Option { c.mods.push(t); } } + // `mods` lists transforms in order, repeats included: `[{"op":"inv"},{"op":"lumMod","val":50000}]`. + if let Some(list) = o.get("mods") { + let list = list.as_array()?; + if c.mods.len() + list.len() > MAX_COLOR_MODS { + return None; + } + for m in list { + c.mods.push(::deserialize(m).ok()?); + } + } Some(c) } _ => None, } } +/// A colour as a command colour parameter, including transforms: the form [`color_value`] reads back +/// into the same colour. +pub fn color_command_value(c: &deckcraft_model::ColorRef) -> Value { + use deckcraft_model::ColorBase; + let mut o = serde_json::Map::new(); + // An ordered list, so the order of the transforms and repeated ones such as `[inv, inv]` are kept. + if !c.mods.is_empty() { + o.insert("mods".into(), serde_json::json!(c.mods)); + } + // `#RRGGBB`, or `#RRGGBBAA` for a color that is not opaque. + let hex = |c: &deckcraft_color::Rgba| if c.a == 255 { format!("#{}", c.hex()) } else { format!("#{}{:02X}", c.hex(), c.a) }; + // A preset or system name that `color_value` does not know (kept from an opened file) is given as + // the color it is drawn with, so OK does not reject it. + let base = match &c.base { + ColorBase::Preset { name } if !deckcraft_color::is_preset_name(name) => ColorBase::Rgb { rgb: deckcraft_color::Rgba::BLACK }, + ColorBase::System { name, last } if !deckcraft_color::is_system_name(name) => ColorBase::Rgb { rgb: *last }, + b => b.clone(), + }; + match &base { + ColorBase::Rgb { rgb } if o.is_empty() => Value::String(hex(rgb)), + ColorBase::Rgb { rgb } => { + o.insert("rgb".into(), Value::String(hex(rgb))); + Value::Object(o) + } + ColorBase::Scheme { slot } => { + o.insert("scheme".into(), Value::String(slot.xml_name().to_string())); + Value::Object(o) + } + ColorBase::Preset { name } => { + o.insert("preset".into(), Value::String(name.clone())); + Value::Object(o) + } + ColorBase::System { name, last } => { + o.insert("system".into(), Value::String(name.clone())); + o.insert("last".into(), Value::String(hex(last))); + Value::Object(o) + } + } +} + /// Look a shape up by id in the edited tree. pub(crate) fn shape_of(s: &Session, id: ShapeId) -> Result { s.doc()?.shape(id).cloned().ok_or_else(|| EngineError::Other(format!("no shape {id}"))) @@ -692,5 +747,53 @@ mod tests { assert!(color_value(&json!({"preset": name})).is_some(), "{name}"); } assert!(color_value(&json!({"system": "3dDkShadow", "last": "#000000"})).is_some()); + let listed = color_value(&json!({"preset": "red", "mods": [{"op": "inv"}, {"op": "lumOff", "val": 20_000}, {"op": "inv"}]})); + let mods = vec![ColorTransform::Inv, ColorTransform::LumOff(20_000), ColorTransform::Inv]; + assert_eq!(listed, Some(ColorRef { base: ColorBase::Preset { name: "red".into() }, mods })); + assert_eq!(color_value(&json!({"preset": "red", "mods": [{"op": "notATransform"}]})), None); + } + + #[test] + fn color_mods_lists_follow_keyed_transforms() { + use deckcraft_color::{ColorTransform, SchemeSlot}; + use deckcraft_model::{ColorBase, ColorRef}; + use serde_json::json; + let red = ColorRef { base: ColorBase::Preset { name: "red".into() }, mods: vec![] }; + assert_eq!(color_value(&json!({"preset": "red", "mods": []})), Some(red.clone()), "an empty list adds no transforms"); + let two = color_value(&json!({"preset": "red", "mods": [{"op": "lumMod", "val": 75_000}, {"op": "lumOff", "val": 10_000}]})); + assert_eq!(two, Some(red.with(ColorTransform::LumMod(75_000)).with(ColorTransform::LumOff(10_000)))); + // The keyed `lumMod` comes first, then the list in order. + let both = + color_value(&json!({"scheme": "accent2", "lumMod": 75_000, "mods": [{"op": "lumOff", "val": 10_000}, {"op": "lumMod", "val": 50_000}]})); + let want = ColorRef::scheme(SchemeSlot::Accent2) + .with(ColorTransform::LumMod(75_000)) + .with(ColorTransform::LumOff(10_000)) + .with(ColorTransform::LumMod(50_000)); + assert_eq!(both, Some(want)); + // An unknown op anywhere in the list, or a `mods` value that is not a list, makes the color invalid. + assert_eq!(color_value(&json!({"scheme": "accent2", "lumMod": 75_000, "mods": [{"op": "lumOff", "val": 10_000}, {"op": "sparkle"}]})), None); + assert_eq!(color_value(&json!({"preset": "red", "mods": {"op": "inv"}})), None); + } + + #[test] + fn color_mods_lists_longer_than_the_cap_are_invalid() { + use deckcraft_color::ColorTransform; + use serde_json::json; + let at_cap = color_value(&json!({"preset": "red", "mods": vec![json!({"op": "inv"}); MAX_COLOR_MODS]})); + assert_eq!(at_cap.map(|c| c.mods), Some(vec![ColorTransform::Inv; MAX_COLOR_MODS])); + assert_eq!(color_value(&json!({"preset": "red", "mods": vec![json!({"op": "inv"}); MAX_COLOR_MODS + 1]})), None); + } + + #[test] + fn color_mods_cap_counts_keyed_transforms_and_survives_a_round_trip() { + use deckcraft_color::ColorTransform; + use serde_json::json; + // One keyed transform plus a full list is 257 transforms, which the cap rejects. + assert_eq!(color_value(&json!({"preset": "red", "inv": true, "mods": vec![json!({"op": "inv"}); MAX_COLOR_MODS]})), None); + // A keyed transform plus a list that totals the cap is accepted and reads back unchanged. + let mixed = color_value(&json!({"preset": "red", "inv": true, "mods": vec![json!({"op": "inv"}); MAX_COLOR_MODS - 1]})); + let mixed = mixed.unwrap_or_else(|| panic!("a color at the cap is valid")); + assert_eq!(mixed.mods, vec![ColorTransform::Inv; MAX_COLOR_MODS]); + assert_eq!(color_value(&color_command_value(&mixed)), Some(mixed)); } } diff --git a/crates/engine/src/cmd/format.rs b/crates/engine/src/cmd/format.rs index 4e273dc1c9..620d24cde3 100644 --- a/crates/engine/src/cmd/format.rs +++ b/crates/engine/src/cmd/format.rs @@ -397,6 +397,79 @@ mod tests { assert!(r.size.is_none() && r.fill.is_none()); } + #[test] + fn font_dialog_ok_keeps_the_text_color() { + use deckcraft_color::Rgba; + let preset = ColorRef { base: ColorBase::Preset { name: "red".into() }, mods: vec![] }.with(ColorTransform::LumMod(50_000)); + let system = ColorRef { base: ColorBase::System { name: "windowText".into(), last: Rgba::rgb(0x12, 0x34, 0x56) }, mods: vec![] } + .with(ColorTransform::Alpha(60_000)); + // A transform without a value, and a color that is not opaque. + let inverted = ColorRef { base: ColorBase::Preset { name: "red".into() }, mods: vec![] }.with(ColorTransform::Inv); + let translucent = ColorRef { base: ColorBase::System { name: "windowText".into(), last: Rgba::rgba(0x12, 0x34, 0x56, 0x80) }, mods: vec![] }; + let rgb = ColorRef::rgb(Rgba::rgba(0x12, 0x34, 0x56, 0x80)); + // A repeated transform, and two transforms in an order that is not alphabetical. + let twice = inverted.clone().with(ColorTransform::Inv); + let ordered = ColorRef::scheme(SchemeSlot::Accent2).with(ColorTransform::LumOff(20_000)).with(ColorTransform::LumMod(50_000)); + for color in [preset, system, inverted, translucent, rgb, twice, ordered] { + let mut s = shape(); + let fill = Fill::Solid { color: color.clone() }; + format_run(&mut s, &|r| r.fill = Some(fill.clone())).unwrap(); + s.ui_requests.clear(); + s.execute("format.fontDialog", &json!({})).unwrap(); + let Some(UiRequest::Dialog { params, .. }) = s.ui_requests.last().cloned() else { panic!("dialog request") }; + s.execute("format.fontDialog", &json!({"color": params["color"]})).unwrap(); + assert_eq!(props(&s).fill, Some(Fill::Solid { color }), "{}", params["color"]); + } + } + + #[test] + fn font_dialog_ok_accepts_preset_and_system_names_it_does_not_know() { + use deckcraft_color::Rgba; + let last = Rgba::rgb(0x12, 0x34, 0x56); + let preset = ColorRef { base: ColorBase::Preset { name: "notAColor".into() }, mods: vec![] }.with(ColorTransform::LumMod(50_000)); + let system = ColorRef { base: ColorBase::System { name: "notAColor".into(), last }, mods: vec![] }; + for (color, drawn) in [(preset, ColorRef::rgb(Rgba::BLACK).with(ColorTransform::LumMod(50_000))), (system, ColorRef::rgb(last))] { + let mut s = shape(); + let fill = Fill::Solid { color }; + format_run(&mut s, &|r| r.fill = Some(fill.clone())).unwrap(); + s.ui_requests.clear(); + s.execute("format.fontDialog", &json!({})).unwrap(); + let Some(UiRequest::Dialog { params, .. }) = s.ui_requests.last().cloned() else { panic!("dialog request") }; + s.execute("format.fontDialog", &json!({"color": params["color"], "size": 20.0})).unwrap(); + assert_eq!(props(&s).fill, Some(Fill::Solid { color: drawn }), "{}", params["color"]); + } + } + + #[test] + fn font_dialog_color_mods_round_trip_and_unknown_ops_are_errors() { + let two = ColorRef { base: ColorBase::Preset { name: "red".into() }, mods: vec![] } + .with(ColorTransform::LumMod(75_000)) + .with(ColorTransform::LumOff(10_000)); + let mut s = shape(); + let fill = Fill::Solid { color: two.clone() }; + format_run(&mut s, &|r| r.fill = Some(fill.clone())).unwrap(); + s.ui_requests.clear(); + s.execute("format.fontDialog", &json!({})).unwrap(); + let Some(UiRequest::Dialog { params, .. }) = s.ui_requests.last().cloned() else { panic!("dialog request") }; + assert_eq!(params["color"], json!({"preset": "red", "mods": [{"op": "lumMod", "val": 75_000}, {"op": "lumOff", "val": 10_000}]})); + s.execute("format.fontDialog", &json!({"color": params["color"]})).unwrap(); + assert_eq!(props(&s).fill, Some(Fill::Solid { color: two.clone() })); + // An unknown op is an error, and the run keeps its color. + let n = s.doc().unwrap().history.undo.len(); + let err = s.execute("format.fontDialog", &json!({"color": {"preset": "red", "mods": [{"op": "sparkle"}]}})).unwrap_err(); + assert!(err.to_string().contains("color"), "{err}"); + assert_eq!(s.doc().unwrap().history.undo.len(), n); + assert_eq!(props(&s).fill, Some(Fill::Solid { color: two })); + // An empty list gives the color with no transforms. + s.execute("format.fontDialog", &json!({"color": {"preset": "red", "mods": []}})).unwrap(); + assert_eq!(props(&s).fill, Some(Fill::Solid { color: ColorRef { base: ColorBase::Preset { name: "red".into() }, mods: vec![] } })); + // A scheme color with a keyed `lumMod` and a list keeps both, the keyed one first. + s.execute("format.fontDialog", &json!({"color": {"scheme": "accent2", "lumMod": 75_000, "mods": [{"op": "lumOff", "val": 10_000}]}})) + .unwrap(); + let scheme = ColorRef::scheme(SchemeSlot::Accent2).with(ColorTransform::LumMod(75_000)).with(ColorTransform::LumOff(10_000)); + assert_eq!(props(&s).fill, Some(Fill::Solid { color: scheme })); + } + #[test] fn font_dialog_with_no_fields_asks_the_ui_to_open() { let mut s = shape(); diff --git a/crates/engine/src/cmd/format/font.rs b/crates/engine/src/cmd/format/font.rs index d9c2c78b4f..f11aad862f 100644 --- a/crates/engine/src/cmd/format/font.rs +++ b/crates/engine/src/cmd/format/font.rs @@ -407,30 +407,6 @@ fn font_edits(p: &Value) -> Result { Ok(FontEdits { family, size, bold: font_bool(p, "bold")?, italic: font_bool(p, "italic")?, underline, color, strike, baseline, caps, spacing }) } -/// A colour as a `format.fontDialog` / `format.color` parameter, including transforms. -fn color_command_value(c: &deckcraft_model::ColorRef) -> Value { - use deckcraft_model::ColorBase; - let mut o = serde_json::Map::new(); - for m in &c.mods { - if let Some(v) = m.value() { - o.insert(m.xml_name().to_string(), json!(v)); - } - } - match &c.base { - ColorBase::Rgb { rgb } if o.is_empty() => json!(format!("#{}", rgb.hex())), - ColorBase::Rgb { rgb } => { - o.insert("rgb".into(), json!(format!("#{}", rgb.hex()))); - Value::Object(o) - } - ColorBase::Scheme { slot } => { - o.insert("scheme".into(), json!(slot.xml_name())); - Value::Object(o) - } - ColorBase::Preset { name } => json!(name), - ColorBase::System { last, .. } => json!(format!("#{}", last.hex())), - } -} - fn font_dialog_params(s: &Session) -> Value { let r = current_run(s); let family = @@ -456,7 +432,7 @@ fn font_dialog_params(s: &Session) -> Value { "spacing": r.spacing.unwrap_or(0.0), }); if let Some(Fill::Solid { color }) = &r.fill { - v["color"] = color_command_value(color); + v["color"] = crate::cmd::color_command_value(color); } v } diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index ed33b9cd68..6b24bc7418 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -252,7 +252,7 @@ fn json_text(v: Option<&Value>, default: &str) -> String { fn color_label(v: &Value) -> String { match v { Value::String(s) => s.clone(), - Value::Object(o) => o.get("scheme").or_else(|| o.get("rgb")).and_then(Value::as_str).unwrap_or("").to_string(), + Value::Object(o) => ["scheme", "rgb", "preset", "last"].iter().find_map(|k| o.get(*k)).and_then(Value::as_str).unwrap_or("").to_string(), _ => String::new(), } } diff --git a/crates/ui-egui/src/dialogs/font_dialog_tests.rs b/crates/ui-egui/src/dialogs/font_dialog_tests.rs index 06ccfc024e..60b18f02d7 100644 --- a/crates/ui-egui/src/dialogs/font_dialog_tests.rs +++ b/crates/ui-egui/src/dialogs/font_dialog_tests.rs @@ -63,3 +63,36 @@ fn command_t_opens_the_font_dialog_and_cancel_keeps_the_text() { assert!(h.state().dialog.is_none()); assert_eq!(bold_of(&h), None); } + +#[test] +fn preset_and_system_colors_show_in_the_dialog_and_ok_keeps_them() { + for (color, shown) in [ + (json!({"preset": "red", "lumMod": 50000}), "red"), + (json!({"system": "windowText", "last": "#123456", "alpha": 60000}), "#123456"), + (json!({"preset": "red", "mods": [{"op": "inv"}, {"op": "inv"}]}), "red"), + (json!({"scheme": "accent2", "mods": [{"op": "lumOff", "val": 20000}, {"op": "lumMod", "val": 50000}]}), "accent2"), + ] { + let mut h = harness(); + h.state_mut().session.execute("format.fontDialog", &json!({ "color": color })).unwrap(); + let before = fill_of(&h); + assert!(before.is_some()); + h.get_by_label("Font…").click(); + h.run_steps(2); + let d = h.state().dialog.as_ref().expect("font dialog"); + assert_eq!(d.fields.get("color").map(String::as_str), Some(shown)); + h.get_by_label("OK").click_accesskit(); + h.run_steps(1); + assert!(h.state().dialog.is_none(), "status {:?}", h.state().status); + assert_eq!(fill_of(&h), before, "{shown}"); + } +} + +fn fill_of(h: &Harness<'_, SlideApp>) -> Option { + let st = h.state().session.active().unwrap(); + st.selected_shapes() + .first() + .and_then(|sh| sh.text.as_ref()) + .and_then(|t| t.paragraphs.first()) + .and_then(|p| p.runs.first()) + .and_then(|r| r.props.fill.clone()) +} diff --git a/crates/ui-egui/src/panels/fillui.rs b/crates/ui-egui/src/panels/fillui.rs index d1f807ae79..bfe2510835 100644 --- a/crates/ui-egui/src/panels/fillui.rs +++ b/crates/ui-egui/src/panels/fillui.rs @@ -529,4 +529,82 @@ mod tests { }; assert_eq!(gradient_json(&gradient).get("flip"), Some(&json!("xy"))); } + + /// Colors whose transforms an object-key form loses: one without a value, a repeated one, two in + /// an order that is not alphabetical, and a system color that is not opaque. + fn transformed_colors() -> Vec { + let preset = |name: &str| ColorRef { base: deckcraft_model::ColorBase::Preset { name: name.into() }, mods: vec![] }; + vec![ + preset("red").with(ColorTransform::Inv), + preset("red").with(ColorTransform::Inv).with(ColorTransform::Inv), + ColorRef::scheme(SchemeSlot::Accent2).with(ColorTransform::LumOff(20_000)).with(ColorTransform::LumMod(50_000)), + ColorRef { + base: deckcraft_model::ColorBase::System { name: "window".into(), last: deckcraft_color::Rgba::rgba(0xF0, 0xF0, 0xF0, 0x80) }, + mods: vec![], + }, + ] + } + + fn deck_with_shape() -> (deckcraft_engine::Session, deckcraft_model::ShapeId) { + let mut s = deckcraft_engine::Session::with_new(); + let r = s.execute("shape.insert", &json!({"preset": "rect", "rect": [80.0, 80.0, 200.0, 120.0]})).unwrap(); + let id = r.get("id").and_then(Value::as_u64).unwrap(); + s.execute("edit.select", &json!({"ids": [id]})).unwrap(); + (s, deckcraft_model::ShapeId(u32::try_from(id).unwrap())) + } + + fn shape_fill(s: &deckcraft_engine::Session, id: deckcraft_model::ShapeId) -> deckcraft_model::Fill { + s.active().unwrap().shape(id).unwrap().fill.clone().unwrap() + } + + fn background_fill(s: &deckcraft_engine::Session) -> deckcraft_model::Fill { + match &s.active().unwrap().doc.slides[0].background { + Some(deckcraft_model::Background::Fill { fill }) => fill.clone(), + other => panic!("expected a fill background, got {other:?}"), + } + } + + #[test] + fn gradient_json_keeps_the_transforms_of_every_stop_color() { + for color in transformed_colors() { + let g = Gradient { + stops: vec![GradientStop { pos: 0.0, color: color.clone() }, GradientStop { pos: 1.0, color: ColorRef::scheme(SchemeSlot::Bg1) }], + shape: GradientShape::Linear { angle: 90.0, scaled: false }, + flip: None, + rotate_with_shape: true, + tile: [0.0; 4], + }; + let (mut s, id) = deck_with_shape(); + s.execute("shape.fill", &json!({"gradient": gradient_json(&g)})).unwrap(); + let deckcraft_model::Fill::Gradient(on_shape) = shape_fill(&s, id) else { panic!("gradient fill") }; + assert_eq!(on_shape.stops[0].color, color, "shape: {}", gradient_json(&g)); + s.execute("design.background", &json!({"gradient": gradient_json(&g)})).unwrap(); + let deckcraft_model::Fill::Gradient(on_slide) = background_fill(&s) else { panic!("gradient background") }; + assert_eq!(on_slide.stops[0].color, color, "background: {}", gradient_json(&g)); + } + } + + #[test] + fn pattern_json_keeps_the_transforms_of_both_colors() { + let colors = transformed_colors(); + for pair in colors.windows(2) { + let pt = PatternFill { preset: "pct25".into(), fg: pair[0].clone(), bg: pair[1].clone() }; + let (mut s, id) = deck_with_shape(); + s.execute("shape.fill", &json!({"pattern": pattern_json(&pt)})).unwrap(); + assert_eq!(shape_fill(&s, id), deckcraft_model::Fill::Pattern(pt.clone()), "shape: {}", pattern_json(&pt)); + s.execute("design.background", &json!({"pattern": pattern_json(&pt)})).unwrap(); + assert_eq!(background_fill(&s), deckcraft_model::Fill::Pattern(pt.clone()), "background: {}", pattern_json(&pt)); + } + } + + #[test] + fn cref_param_keeps_the_transforms_of_a_solid_background_and_fill() { + for color in transformed_colors() { + let (mut s, id) = deck_with_shape(); + s.execute("design.background", &json!({"color": cref_param(&color)})).unwrap(); + assert_eq!(background_fill(&s), deckcraft_model::Fill::solid(color.clone()), "background: {}", cref_param(&color)); + s.execute("shape.fill", &json!({"color": cref_param(&color)})).unwrap(); + assert_eq!(shape_fill(&s, id), deckcraft_model::Fill::solid(color.clone()), "shape: {}", cref_param(&color)); + } + } } diff --git a/crates/ui-egui/src/ribbon/galleries.rs b/crates/ui-egui/src/ribbon/galleries.rs index 41291062fd..54d009f3f6 100644 --- a/crates/ui-egui/src/ribbon/galleries.rs +++ b/crates/ui-egui/src/ribbon/galleries.rs @@ -2,50 +2,7 @@ use super::{Align2, Color32, CornerRadius, Rect, Sense, SlideApp, Stroke, Tokens /// A ColorRef as a command colour parameter. pub fn cref_param(c: &deckcraft_model::ColorRef) -> Value { - match &c.base { - deckcraft_model::ColorBase::Scheme { slot } => { - let mut o = serde_json::Map::new(); - o.insert("scheme".into(), json!(slot.xml_name())); - for m in &c.mods { - if let Some(v) = m.value() { - o.insert(m.xml_name().into(), json!(v)); - } - } - Value::Object(o) - } - deckcraft_model::ColorBase::Rgb { rgb } if c.mods.is_empty() => json!(format!("#{}", rgb.hex())), - deckcraft_model::ColorBase::Rgb { rgb } => { - let mut o = serde_json::Map::new(); - o.insert("rgb".into(), json!(format!("#{}", rgb.hex()))); - for m in &c.mods { - if let Some(v) = m.value() { - o.insert(m.xml_name().into(), json!(v)); - } - } - Value::Object(o) - } - deckcraft_model::ColorBase::Preset { name } => { - let mut o = serde_json::Map::new(); - o.insert("preset".into(), json!(name)); - for m in &c.mods { - if let Some(v) = m.value() { - o.insert(m.xml_name().into(), json!(v)); - } - } - Value::Object(o) - } - deckcraft_model::ColorBase::System { name, last } => { - let mut o = serde_json::Map::new(); - o.insert("system".into(), json!(name)); - o.insert("last".into(), json!(format!("#{}", last.hex()))); - for m in &c.mods { - if let Some(v) = m.value() { - o.insert(m.xml_name().into(), json!(v)); - } - } - Value::Object(o) - } - } + deckcraft_engine::cmd::color_command_value(c) } /// Convert to SmartArt: the layouts by category, three to a row; a click converts the selected