control-center: add in-process control center
This commit is contained in:
parent
008e8a671a
commit
186d5b694b
28 changed files with 859 additions and 14 deletions
48
src/control_center/cc_sidebar.rs
Normal file
48
src/control_center/cc_sidebar.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
use {
|
||||
crate::control_center::{ControlCenterInner, Pane},
|
||||
egui::{Align, Layout, ScrollArea, Ui, ViewportCommand},
|
||||
egui_tiles::Tree,
|
||||
linearize::{Linearize, LinearizeExt},
|
||||
std::{rc::Rc, sync::LazyLock},
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, Linearize)]
|
||||
enum PaneName {}
|
||||
|
||||
impl PaneName {
|
||||
fn name(self) -> &'static str {
|
||||
match self {}
|
||||
}
|
||||
}
|
||||
|
||||
static TYPES: LazyLock<Vec<PaneName>> = LazyLock::new(|| {
|
||||
let mut res: Vec<_> = PaneName::variants().collect();
|
||||
res.sort_by_key(|t| t.name());
|
||||
res
|
||||
});
|
||||
|
||||
impl ControlCenterInner {
|
||||
pub fn show_sidebar(self: &Rc<Self>, tree: &mut Tree<Pane>, ui: &mut Ui) {
|
||||
ui.with_layout(
|
||||
Layout::top_down(Align::Center).with_cross_justify(true),
|
||||
|ui| {
|
||||
ui.add_space(6.0);
|
||||
if ui.button("Close").clicked() {
|
||||
ui.ctx().send_viewport_cmd(ViewportCommand::Close);
|
||||
}
|
||||
ui.separator();
|
||||
ScrollArea::vertical().show(ui, |ui| {
|
||||
for &ty in &*TYPES {
|
||||
if ui.button(ty.name()).clicked() {
|
||||
let _ty = match ty {};
|
||||
#[expect(unreachable_code)]
|
||||
self.open(tree, _ty);
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
}
|
||||
ui.add_space(3.0);
|
||||
})
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue