feat: current progress - connect panel layout, manual checkbox, serial enum

This commit is contained in:
lennlouisgeek
2026-05-19 23:44:09 +08:00
parent 83faa0be1e
commit a7b617419d
11 changed files with 788 additions and 46 deletions

View File

@@ -2,22 +2,30 @@ use std::time::Instant;
use eframe::{egui, egui_wgpu};
use crate::theme::{ENGINEERING_DARK, apply_theme};
use crate::theme::{ENGINEERING_DARK, apply_fonts, apply_theme};
use crate::{
matrix::{MATRIX_COLS, MATRIX_ROWS},
render::{BackgroundRenderResources, WgpuBackgroundCallback},
ui::{FloatingPanelState, draw_config_panel, draw_scene_panel, draw_stats_panel},
ui::{
ConfigPanelState, ConnectPanelState, FloatingPanelState, draw_config_panel,
draw_connect_panel, draw_scene_panel, draw_stats_panel,
},
};
pub struct EskinDesktopApp {
connect_panel: FloatingPanelState,
connect_state: ConnectPanelState,
scene_panel: FloatingPanelState,
config_panel: FloatingPanelState,
config_state: ConfigPanelState,
stats_panel: FloatingPanelState,
started_at: Instant,
}
impl EskinDesktopApp {
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
egui_extras::install_image_loaders(&cc.egui_ctx);
apply_fonts(&cc.egui_ctx);
apply_theme(&cc.egui_ctx, &ENGINEERING_DARK);
let wgpu_state = cc
@@ -36,8 +44,11 @@ impl EskinDesktopApp {
));
Self {
connect_panel: FloatingPanelState::new([0.0, 0.0], [0.0, 0.0]),
connect_state: ConnectPanelState::default(),
scene_panel: FloatingPanelState::new([16.0, 48.0], [16.0, 48.0]),
config_panel: FloatingPanelState::new([840.0, 48.0], [128.0, 48.0]),
config_state: ConfigPanelState::default(),
stats_panel: FloatingPanelState::new([16.0, 520.0], [240.0, 48.0]),
started_at: Instant::now(),
}
@@ -61,16 +72,18 @@ impl EskinDesktopApp {
fn draw_toolbar(&mut self, ui: &mut egui::Ui) {
egui::Panel::top("main_menu").show_inside(ui, |ui| {
ui.horizontal(|ui| {
ui.checkbox(&mut self.scene_panel.visible, "Scene");
ui.checkbox(&mut self.config_panel.visible, "Config");
ui.checkbox(&mut self.stats_panel.visible, "Stats");
ui.checkbox(&mut self.connect_panel.visible, "连接");
ui.checkbox(&mut self.scene_panel.visible, "场景");
ui.checkbox(&mut self.config_panel.visible, "配置");
ui.checkbox(&mut self.stats_panel.visible, "统计");
});
});
}
fn draw_floating_panels(&mut self, ctx: &egui::Context) {
draw_connect_panel(ctx, &mut self.connect_panel, &mut self.connect_state);
draw_scene_panel(ctx, &mut self.scene_panel);
draw_config_panel(ctx, &mut self.config_panel);
draw_config_panel(ctx, &mut self.config_panel, &mut self.config_state);
draw_stats_panel(ctx, &mut self.stats_panel);
}
}