diff --git a/crates/ui2/src/components/keybinding.rs b/crates/ui2/src/components/keybinding.rs index 46768a6ddcc3f9e67cc8426079896a8dc789aed5..081b4d907ed7627c185be77dc4bce34dc0230c6b 100644 --- a/crates/ui2/src/components/keybinding.rs +++ b/crates/ui2/src/components/keybinding.rs @@ -5,8 +5,8 @@ use strum::{EnumIter, IntoEnumIterator}; use crate::prelude::*; -#[derive(Element, Clone)] -pub struct Keybinding { +#[derive(Element)] +pub struct Keybinding { state_type: PhantomData, /// A keybinding consists of a key and a set of modifier keys. @@ -16,7 +16,7 @@ pub struct Keybinding { keybinding: Vec<(String, ModifierKeys)>, } -impl Keybinding { +impl Keybinding { pub fn new(key: String, modifiers: ModifierKeys) -> Self { Self { state_type: PhantomData, diff --git a/crates/ui2/src/components/palette.rs b/crates/ui2/src/components/palette.rs index 1d85f293a7f90efec31983d446bcd4a49b338907..c931a2b4cc57bf258ced741304902878a7f0f26a 100644 --- a/crates/ui2/src/components/palette.rs +++ b/crates/ui2/src/components/palette.rs @@ -4,7 +4,7 @@ use crate::prelude::*; use crate::{h_stack, v_stack, Keybinding, Label, LabelColor}; #[derive(Element)] -pub struct Palette { +pub struct Palette { id: ElementId, state_type: PhantomData, input_placeholder: SharedString, @@ -13,7 +13,7 @@ pub struct Palette { default_order: OrderMethod, } -impl Palette { +impl Palette { pub fn new(id: impl Into) -> Self { Self { id: id.into(), @@ -85,7 +85,7 @@ impl Palette { .into_iter() .flatten(), ) - .children(self.items.iter().enumerate().map(|(index, item)| { + .children(self.items.drain(..).enumerate().map(|(index, item)| { h_stack() .id(index) .justify_between() @@ -94,21 +94,21 @@ impl Palette { .rounded_lg() .hover(|style| style.bg(color.ghost_element_hover)) .active(|style| style.bg(color.ghost_element_active)) - .child(item.clone()) + .child(item) })), ), ) } } -#[derive(Element, Clone)] -pub struct PaletteItem { +#[derive(Element)] +pub struct PaletteItem { pub label: SharedString, pub sublabel: Option, pub keybinding: Option>, } -impl PaletteItem { +impl PaletteItem { pub fn new(label: impl Into) -> Self { Self { label: label.into(), @@ -148,7 +148,7 @@ impl PaletteItem { .child(Label::new(self.label.clone())) .children(self.sublabel.clone().map(|sublabel| Label::new(sublabel))), ) - .children(self.keybinding.clone()) + .children(self.keybinding.take()) } }