modular-ui: use boxes where it makes sense
This commit is contained in:
@@ -172,7 +172,7 @@ pub struct ButtonData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn modular_button_init(button: &mut ModularControl, data: &ButtonData) {
|
pub fn modular_button_init(button: &mut ModularControl, data: &ButtonData) {
|
||||||
button.state = Some(ModularData::Button(data.clone()));
|
button.state = Some(ModularData::Button(Box::new(data.clone())));
|
||||||
button.on_press = Some(modular_button_dn);
|
button.on_press = Some(modular_button_dn);
|
||||||
button.on_release = Some(modular_button_up);
|
button.on_release = Some(modular_button_up);
|
||||||
button.on_scroll = Some(modular_button_scroll);
|
button.on_scroll = Some(modular_button_scroll);
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ pub fn modular_label_init(label: &mut ModularControl, content: &LabelContent) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(state) = state {
|
if let Some(state) = state {
|
||||||
label.state = Some(ModularData::Label(state));
|
label.state = Some(ModularData::Label(Box::new(state)));
|
||||||
label.on_update = Some(label_update);
|
label.on_update = Some(label_update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ pub(super) fn label_update(control: &mut ModularControl, _: &mut (), app: &mut A
|
|||||||
let ModularData::Label(data) = control.state.as_mut().unwrap() else {
|
let ModularData::Label(data) = control.state.as_mut().unwrap() else {
|
||||||
panic!("Label control has no state");
|
panic!("Label control has no state");
|
||||||
};
|
};
|
||||||
match data {
|
match data.as_mut() {
|
||||||
LabelData::Battery {
|
LabelData::Battery {
|
||||||
device,
|
device,
|
||||||
low_threshold,
|
low_threshold,
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ pub enum ModularElement {
|
|||||||
bg_color: Arc<str>,
|
bg_color: Arc<str>,
|
||||||
text: Arc<str>,
|
text: Arc<str>,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
data: ButtonData,
|
data: Box<ButtonData>,
|
||||||
},
|
},
|
||||||
/// Convenience type to save you from having to create a bunch of labels
|
/// Convenience type to save you from having to create a bunch of labels
|
||||||
BatteryList {
|
BatteryList {
|
||||||
@@ -90,7 +90,7 @@ pub enum ModularElement {
|
|||||||
bg_color: Arc<str>,
|
bg_color: Arc<str>,
|
||||||
layout: ListLayout,
|
layout: ListLayout,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
template: OverlayListTemplate,
|
template: Box<OverlayListTemplate>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +107,8 @@ pub enum ListLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum ModularData {
|
pub enum ModularData {
|
||||||
Label(LabelData),
|
Label(Box<LabelData>),
|
||||||
Button(ButtonData),
|
Button(Box<ButtonData>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modular_canvas(
|
pub fn modular_canvas(
|
||||||
|
|||||||
Reference in New Issue
Block a user