Remove Clone
bound from Keybinding
This commit is contained in:
parent
a0996c1807
commit
d9a030157e
2 changed files with 11 additions and 11 deletions
|
@ -5,8 +5,8 @@ use strum::{EnumIter, IntoEnumIterator};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(Element, Clone)]
|
#[derive(Element)]
|
||||||
pub struct Keybinding<S: 'static + Send + Sync + Clone> {
|
pub struct Keybinding<S: 'static + Send + Sync> {
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
|
|
||||||
/// A keybinding consists of a key and a set of modifier keys.
|
/// A keybinding consists of a key and a set of modifier keys.
|
||||||
|
@ -16,7 +16,7 @@ pub struct Keybinding<S: 'static + Send + Sync + Clone> {
|
||||||
keybinding: Vec<(String, ModifierKeys)>,
|
keybinding: Vec<(String, ModifierKeys)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> Keybinding<S> {
|
impl<S: 'static + Send + Sync> Keybinding<S> {
|
||||||
pub fn new(key: String, modifiers: ModifierKeys) -> Self {
|
pub fn new(key: String, modifiers: ModifierKeys) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::prelude::*;
|
||||||
use crate::{h_stack, v_stack, Keybinding, Label, LabelColor};
|
use crate::{h_stack, v_stack, Keybinding, Label, LabelColor};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct Palette<S: 'static + Send + Sync + Clone> {
|
pub struct Palette<S: 'static + Send + Sync> {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
input_placeholder: SharedString,
|
input_placeholder: SharedString,
|
||||||
|
@ -13,7 +13,7 @@ pub struct Palette<S: 'static + Send + Sync + Clone> {
|
||||||
default_order: OrderMethod,
|
default_order: OrderMethod,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> Palette<S> {
|
impl<S: 'static + Send + Sync> Palette<S> {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
|
@ -85,7 +85,7 @@ impl<S: 'static + Send + Sync + Clone> Palette<S> {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten(),
|
.flatten(),
|
||||||
)
|
)
|
||||||
.children(self.items.iter().enumerate().map(|(index, item)| {
|
.children(self.items.drain(..).enumerate().map(|(index, item)| {
|
||||||
h_stack()
|
h_stack()
|
||||||
.id(index)
|
.id(index)
|
||||||
.justify_between()
|
.justify_between()
|
||||||
|
@ -94,21 +94,21 @@ impl<S: 'static + Send + Sync + Clone> Palette<S> {
|
||||||
.rounded_lg()
|
.rounded_lg()
|
||||||
.hover(|style| style.bg(color.ghost_element_hover))
|
.hover(|style| style.bg(color.ghost_element_hover))
|
||||||
.active(|style| style.bg(color.ghost_element_active))
|
.active(|style| style.bg(color.ghost_element_active))
|
||||||
.child(item.clone())
|
.child(item)
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Element, Clone)]
|
#[derive(Element)]
|
||||||
pub struct PaletteItem<S: 'static + Send + Sync + Clone> {
|
pub struct PaletteItem<S: 'static + Send + Sync> {
|
||||||
pub label: SharedString,
|
pub label: SharedString,
|
||||||
pub sublabel: Option<SharedString>,
|
pub sublabel: Option<SharedString>,
|
||||||
pub keybinding: Option<Keybinding<S>>,
|
pub keybinding: Option<Keybinding<S>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> PaletteItem<S> {
|
impl<S: 'static + Send + Sync> PaletteItem<S> {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
|
@ -148,7 +148,7 @@ impl<S: 'static + Send + Sync + Clone> PaletteItem<S> {
|
||||||
.child(Label::new(self.label.clone()))
|
.child(Label::new(self.label.clone()))
|
||||||
.children(self.sublabel.clone().map(|sublabel| Label::new(sublabel))),
|
.children(self.sublabel.clone().map(|sublabel| Label::new(sublabel))),
|
||||||
)
|
)
|
||||||
.children(self.keybinding.clone())
|
.children(self.keybinding.take())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue