FastWave2.0/frontend/src/main.rs

55 lines
1.6 KiB
Rust
Raw Normal View History

2024-05-27 19:24:46 +00:00
use zoon::*;
2024-06-07 21:18:06 +00:00
use std::rc::Rc;
2024-05-27 19:24:46 +00:00
2024-06-01 17:39:19 +00:00
mod platform;
2024-05-27 19:24:46 +00:00
mod controls_panel;
use controls_panel::ControlsPanel;
mod waveform_panel;
use waveform_panel::WaveformPanel;
2024-05-30 23:35:05 +00:00
#[derive(Clone, Copy, Default)]
enum Layout {
Tree,
#[default]
Columns,
}
2024-05-27 19:24:46 +00:00
fn main() {
start_app("app", root);
Task::start(async {
// https://github.com/tauri-apps/tauri/issues/5170
Timer::sleep(100).await;
2024-06-01 17:39:19 +00:00
platform::show_window().await;
2024-05-27 19:24:46 +00:00
});
}
fn root() -> impl Element {
2024-06-07 21:18:06 +00:00
let hierarchy: Mutable<Option<Rc<wellen::Hierarchy>>> = <_>::default();
2024-05-27 19:24:46 +00:00
let selected_var_refs: MutableVec<wellen::VarRef> = <_>::default();
2024-05-30 23:35:05 +00:00
let layout: Mutable<Layout> = <_>::default();
Column::new()
2024-05-27 19:24:46 +00:00
.s(Height::fill())
2024-05-30 23:35:05 +00:00
.s(Scrollbars::y_and_clip_x())
2024-05-27 19:24:46 +00:00
.s(Font::new().color(color!("Lavender")))
2024-05-30 23:35:05 +00:00
.item(
Row::new()
.s(Height::fill())
.s(Gap::new().x(15))
.item(ControlsPanel::new(
2024-06-07 21:18:06 +00:00
hierarchy.clone(),
2024-05-30 23:35:05 +00:00
selected_var_refs.clone(),
layout.clone(),
))
2024-06-07 21:18:06 +00:00
.item_signal(layout.signal().map(|layout| matches!(layout, Layout::Tree)).map_true(clone!((hierarchy, selected_var_refs) move || WaveformPanel::new(
hierarchy.clone(),
2024-05-30 23:35:05 +00:00
selected_var_refs.clone(),
))))
)
.item_signal(layout.signal().map(|layout| matches!(layout, Layout::Columns)).map_true(move || WaveformPanel::new(
2024-06-07 21:18:06 +00:00
hierarchy.clone(),
2024-05-27 19:24:46 +00:00
selected_var_refs.clone(),
2024-05-30 23:35:05 +00:00
)))
2024-05-27 19:24:46 +00:00
}