2024-06-17 16:06:36 +00:00
|
|
|
use std::sync::Arc;
|
2024-06-08 21:51:30 +00:00
|
|
|
use zoon::*;
|
2024-05-27 19:24:46 +00:00
|
|
|
|
2024-06-01 17:39:19 +00:00
|
|
|
mod platform;
|
2024-06-15 21:15:28 +00:00
|
|
|
mod script_bridge;
|
2024-05-27 19:24:46 +00:00
|
|
|
|
|
|
|
mod controls_panel;
|
|
|
|
use controls_panel::ControlsPanel;
|
|
|
|
|
|
|
|
mod waveform_panel;
|
2024-07-08 00:23:48 +00:00
|
|
|
use waveform_panel::{PixiController, WaveformPanel};
|
2024-05-27 19:24:46 +00:00
|
|
|
|
2024-06-17 08:15:05 +00:00
|
|
|
mod header_panel;
|
|
|
|
use header_panel::HeaderPanel;
|
|
|
|
|
2024-09-14 17:48:09 +00:00
|
|
|
mod command_panel;
|
|
|
|
use command_panel::CommandPanel;
|
|
|
|
|
2024-09-14 16:51:03 +00:00
|
|
|
pub mod theme;
|
2024-09-14 14:31:46 +00:00
|
|
|
use theme::*;
|
|
|
|
|
2024-05-30 23:35:05 +00:00
|
|
|
#[derive(Clone, Copy, Default)]
|
|
|
|
enum Layout {
|
|
|
|
Tree,
|
|
|
|
#[default]
|
|
|
|
Columns,
|
|
|
|
}
|
|
|
|
|
2024-06-17 08:15:05 +00:00
|
|
|
type Filename = String;
|
|
|
|
|
2024-06-16 16:29:25 +00:00
|
|
|
#[derive(Default)]
|
|
|
|
struct Store {
|
|
|
|
selected_var_refs: MutableVec<wellen::VarRef>,
|
2024-06-17 16:06:36 +00:00
|
|
|
hierarchy: Mutable<Option<Arc<wellen::Hierarchy>>>,
|
2024-06-17 17:36:44 +00:00
|
|
|
loaded_filename: Mutable<Option<Filename>>,
|
2024-07-08 00:23:48 +00:00
|
|
|
canvas_controller: Mutable<Mutable<Option<SendWrapper<PixiController>>>>,
|
2024-06-16 16:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static STORE: Lazy<Store> = lazy::default();
|
|
|
|
|
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-17 16:06:36 +00:00
|
|
|
let hierarchy = STORE.hierarchy.clone();
|
2024-06-16 16:29:25 +00:00
|
|
|
let selected_var_refs = STORE.selected_var_refs.clone();
|
2024-05-30 23:35:05 +00:00
|
|
|
let layout: Mutable<Layout> = <_>::default();
|
2024-06-17 17:36:44 +00:00
|
|
|
let loaded_filename = STORE.loaded_filename.clone();
|
2024-07-08 00:23:48 +00:00
|
|
|
let canvas_controller = STORE.canvas_controller.clone();
|
2024-05-30 23:35:05 +00:00
|
|
|
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-09-14 16:51:03 +00:00
|
|
|
.s(Font::new().color(COLOR_LAVENDER))
|
2024-06-17 08:15:05 +00:00
|
|
|
.item(HeaderPanel::new(
|
|
|
|
hierarchy.clone(),
|
|
|
|
layout.clone(),
|
|
|
|
loaded_filename.clone(),
|
|
|
|
))
|
2024-05-30 23:35:05 +00:00
|
|
|
.item(
|
|
|
|
Row::new()
|
2024-06-17 09:35:13 +00:00
|
|
|
.s(Scrollbars::y_and_clip_x())
|
2024-05-30 23:35:05 +00:00
|
|
|
.s(Gap::new().x(15))
|
2024-06-17 09:35:13 +00:00
|
|
|
.s(Height::growable().min(150))
|
2024-05-30 23:35:05 +00:00
|
|
|
.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-18 23:43:31 +00:00
|
|
|
loaded_filename.clone(),
|
2024-05-30 23:35:05 +00:00
|
|
|
))
|
2024-06-18 17:56:03 +00:00
|
|
|
.item_signal({
|
|
|
|
let hierarchy = hierarchy.clone();
|
|
|
|
let selected_var_refs = selected_var_refs.clone();
|
2024-06-18 23:43:31 +00:00
|
|
|
let loaded_filename = loaded_filename.clone();
|
2024-07-08 00:23:48 +00:00
|
|
|
let canvas_controller = canvas_controller.clone();
|
2024-06-18 17:56:03 +00:00
|
|
|
map_ref!{
|
|
|
|
let layout = layout.signal(),
|
|
|
|
let hierarchy_is_some = hierarchy.signal_ref(Option::is_some) => {
|
2024-07-08 00:23:48 +00:00
|
|
|
(*hierarchy_is_some && matches!(layout, Layout::Tree)).then(clone!((hierarchy, selected_var_refs, loaded_filename, canvas_controller) move || WaveformPanel::new(
|
2024-06-08 21:51:30 +00:00
|
|
|
hierarchy.clone(),
|
|
|
|
selected_var_refs.clone(),
|
2024-06-18 23:43:31 +00:00
|
|
|
loaded_filename.clone(),
|
2024-07-08 00:23:48 +00:00
|
|
|
canvas_controller.clone(),
|
2024-06-18 17:56:03 +00:00
|
|
|
)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
2024-06-08 21:51:30 +00:00
|
|
|
)
|
|
|
|
.item_signal(
|
2024-06-18 17:56:03 +00:00
|
|
|
map_ref!{
|
|
|
|
let layout = layout.signal(),
|
|
|
|
let hierarchy_is_some = hierarchy.signal_ref(Option::is_some) => {
|
2024-07-08 00:23:48 +00:00
|
|
|
(*hierarchy_is_some && matches!(layout, Layout::Columns)).then(clone!((hierarchy, selected_var_refs, loaded_filename, canvas_controller) move || WaveformPanel::new(
|
2024-06-18 17:56:03 +00:00
|
|
|
hierarchy.clone(),
|
|
|
|
selected_var_refs.clone(),
|
2024-06-18 23:43:31 +00:00
|
|
|
loaded_filename.clone(),
|
2024-07-08 00:23:48 +00:00
|
|
|
canvas_controller.clone(),
|
2024-06-18 17:56:03 +00:00
|
|
|
)))
|
|
|
|
}
|
|
|
|
}
|
2024-05-30 23:35:05 +00:00
|
|
|
)
|
2024-09-14 17:48:09 +00:00
|
|
|
.item(CommandPanel::new())
|
2024-05-27 19:24:46 +00:00
|
|
|
}
|