47 lines
1.0 KiB
Rust
47 lines
1.0 KiB
Rust
use makepad_widgets::{Cx, Texture, TextureFormat};
|
|
use mp_core::data::RadarGridData;
|
|
|
|
pub enum Data {
|
|
GridData(GridData),
|
|
}
|
|
pub struct GridData {
|
|
texture: Texture,
|
|
clear_buffer: bool,
|
|
shape: Option<Vec<u32>>,
|
|
}
|
|
|
|
impl GridData {
|
|
pub fn new(cx: &mut Cx) -> Self {
|
|
let mut texture = Texture::new_with_format(cx, TextureFormat::Unknown);
|
|
|
|
texture.texture_id();
|
|
|
|
GridData {
|
|
texture,
|
|
clear_buffer: true,
|
|
shape: None,
|
|
}
|
|
}
|
|
|
|
pub fn update(&mut self, cx: &mut Cx, data: &RadarGridData) {
|
|
let data = data.data.cast_to::<f32>();
|
|
self.clear_buffer = false;
|
|
// self.shape = Some(data.dim().into());
|
|
// self.texture.put_back_vec_f32(cx, data.into(), None);
|
|
}
|
|
|
|
pub fn clear(&mut self) {
|
|
self.clear_buffer = true;
|
|
}
|
|
|
|
pub fn texture(&self) -> &Texture {
|
|
&self.texture
|
|
}
|
|
}
|
|
|
|
impl From<GridData> for Data {
|
|
fn from(data: GridData) -> Self {
|
|
Data::GridData(data)
|
|
}
|
|
}
|