diff --git a/crates/ui-patterns/src/patterns/panels/palette.rs b/crates/ui-patterns/src/patterns/panels/palette.rs index 4141a22ba..01c419839 100644 --- a/crates/ui-patterns/src/patterns/panels/palette.rs +++ b/crates/ui-patterns/src/patterns/panels/palette.rs @@ -230,7 +230,7 @@ impl RowData { /// One line: the label, then the menu path, which drops out when the label would get too narrow, and the chord /// at the end. fn row(&self) -> ListRow<'static> { - let row = ListRow::new(self.label.clone()).option().enabled(self.enabled); + let row = ListRow::new(self.label.clone()).option().command().enabled(self.enabled); // The first trailing item is the outermost: the chord ends the row and the path sits before it. let row = match &self.chord { Some(chord) => row.trailing(chord.clone()), diff --git a/crates/ui-widgets/src/list/row.rs b/crates/ui-widgets/src/list/row.rs index bda6f8fd0..5b15566b0 100644 --- a/crates/ui-widgets/src/list/row.rs +++ b/crates/ui-widgets/src/list/row.rs @@ -247,6 +247,11 @@ pub struct ListRow<'a> { #[style_key] #[prop(flag)] pub(super) option: bool, + /// On an option that runs a command (a command palette's row): the lead row is the command highlight, as a menu's, + /// and no edge outlines the lead or the chosen row. + #[style_key] + #[prop(flag)] + pub(super) command: bool, /// On an option of a list that picks a value: the row keeps a mark column, with the check mark when `true`. #[prop] pub(super) check: Option, @@ -314,6 +319,7 @@ impl<'a> ListRow<'a> { group: None, disclosure_by_host: false, option: false, + command: false, check: None, event: None, open: None, diff --git a/crates/ui-widgets/src/list/row/show.rs b/crates/ui-widgets/src/list/row/show.rs index 0163e1b5d..29bc2feec 100644 --- a/crates/ui-widgets/src/list/row/show.rs +++ b/crates/ui-widgets/src/list/row/show.rs @@ -59,7 +59,11 @@ impl Component for ListRow<'_> { let text = &colors.text; let clear = Rgba::TRANSPARENT; let c = |rgba: Rgba| cx.color(rgba); - let form = if key.option { RowForm::Option } else { RowForm::List }; + let form = match () { + _ if key.option && key.command => RowForm::Command, + _ if key.option => RowForm::Option, + _ => RowForm::List, + }; let fill = fill_of(cx, FillKey { striped: key.striped, layer: key.layer, form }); // An option sits inset in its popup with rounded corners whatever the theme's row form. let rounded = key.option || tokens.shape.rows == RowStyle::Rounded; @@ -68,7 +72,7 @@ impl Component for ListRow<'_> { if key.layer { surface = surface.border(Stateful::new(c(clear)).when(Flags::SELECTED, c(selected_outline(cx))), tokens.stroke.thin); } - if key.option { + if form == RowForm::Option { let edge = Stateful::new(c(clear)).when(Flags::SELECTED, c(colors.accent.text)).when(Flags::LEAD, c(colors.line.control_edge)); surface = surface.border(edge, tokens.stroke.thin); } diff --git a/crates/ui-widgets/src/list/row/style.rs b/crates/ui-widgets/src/list/row/style.rs index 3d0427028..7c88e8cd9 100644 --- a/crates/ui-widgets/src/list/row/style.rs +++ b/crates/ui-widgets/src/list/row/style.rs @@ -46,7 +46,7 @@ pub struct ListRowStyle { pub(super) enum RowForm { /// An item of a list. List, - /// A row of a menu: the lead row is the command highlight. + /// A row of a menu, or an option that runs a command: the lead row is the command highlight. Command, /// An option of a listbox: the chosen row keeps the selected fill, the lead row the hover fill. Option,