feat: ipd label
This commit is contained in:
@@ -38,6 +38,7 @@ pub enum LabelContent {
|
||||
low_color: Arc<str>,
|
||||
charging_color: Arc<str>,
|
||||
},
|
||||
Ipd,
|
||||
}
|
||||
|
||||
pub enum LabelData {
|
||||
@@ -62,6 +63,9 @@ pub enum LabelData {
|
||||
command: Vec<Arc<str>>,
|
||||
child: Option<process::Child>,
|
||||
},
|
||||
Ipd {
|
||||
last_ipd: f32,
|
||||
},
|
||||
}
|
||||
|
||||
pub fn modular_label_init(label: &mut ModularControl, content: &LabelContent) {
|
||||
@@ -106,6 +110,7 @@ pub fn modular_label_init(label: &mut ModularControl, content: &LabelContent) {
|
||||
label.set_text(text);
|
||||
None
|
||||
}
|
||||
LabelContent::Ipd => Some(LabelData::Ipd { last_ipd: 0. }),
|
||||
};
|
||||
|
||||
if let Some(state) = state {
|
||||
@@ -238,5 +243,11 @@ pub(super) fn label_update(control: &mut ModularControl, _: &mut (), app: &mut A
|
||||
};
|
||||
}
|
||||
}
|
||||
LabelData::Ipd { last_ipd } => {
|
||||
if (app.input_state.ipd - *last_ipd).abs() > 0.05 {
|
||||
*last_ipd = app.input_state.ipd;
|
||||
control.set_text(&format!("{:.1}", app.input_state.ipd));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user