menu bar (// tab template)
This commit is contained in:
parent
acc35f78fa
commit
1dc272097c
2 changed files with 38 additions and 8 deletions
31
src/app.rs
31
src/app.rs
|
@ -1,20 +1,39 @@
|
|||
use derive_new::new;
|
||||
use eframe::egui;
|
||||
use egui_dock::{DockArea, DockState, Style};
|
||||
use eframe::egui::{self, menu, CentralPanel, Frame};
|
||||
use egui_dock::{DockArea, DockState};
|
||||
|
||||
mod tabs;
|
||||
use tabs::{chefs_dish, Tab, TabViewer};
|
||||
|
||||
use self::tabs::TabKind;
|
||||
|
||||
#[derive(new)]
|
||||
pub(super) struct App {
|
||||
tree: DockState<Tab>,
|
||||
open_summary: bool,
|
||||
}
|
||||
|
||||
impl eframe::App for App {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
DockArea::new(&mut self.tree)
|
||||
.style(Style::from_egui(ctx.style().as_ref()))
|
||||
.show(ctx, &mut TabViewer::new());
|
||||
CentralPanel::default()
|
||||
.frame(Frame::central_panel(&ctx.style()))
|
||||
.show(ctx, |ui| {
|
||||
menu::bar(ui, |ui| {
|
||||
ui.menu_button("Tabs", |ui| {
|
||||
if ui.checkbox(&mut self.open_summary, "Summary").changed() {
|
||||
match self.open_summary {
|
||||
true => self.tree.push_to_focused_leaf(Tab::new(TabKind::Summary)),
|
||||
false => {
|
||||
self.tree = self
|
||||
.tree
|
||||
.filter_tabs(|tab| !matches!(tab.kind, TabKind::Summary))
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
DockArea::new(&mut self.tree).show_inside(ui, &mut TabViewer::new());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +41,6 @@ impl Default for App {
|
|||
fn default() -> Self {
|
||||
let tree = DockState::new(chefs_dish());
|
||||
|
||||
Self::new(tree)
|
||||
Self::new(tree, false)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use eframe::egui::{Ui, WidgetText};
|
|||
use strum::{AsRefStr, EnumIter, IntoEnumIterator};
|
||||
|
||||
#[derive(Clone, AsRefStr, PartialEq, EnumIter)]
|
||||
enum TabKind {
|
||||
pub(super) enum TabKind {
|
||||
Input,
|
||||
Decode,
|
||||
Process,
|
||||
|
@ -13,7 +13,7 @@ enum TabKind {
|
|||
Help,
|
||||
}
|
||||
|
||||
#[derive(new)]
|
||||
#[derive(new, Clone)]
|
||||
pub(super) struct Tab {
|
||||
#[allow(private_interfaces)]
|
||||
pub(super) kind: TabKind,
|
||||
|
@ -50,6 +50,17 @@ impl egui_dock::TabViewer for TabViewer {
|
|||
|
||||
fn ui(&mut self, ui: &mut Ui, tab: &mut Self::Tab) {
|
||||
ui.heading(tab.kind.as_ref());
|
||||
// match tab.kind {
|
||||
// TabKind::Input => {
|
||||
// ui.
|
||||
// },
|
||||
// TabKind::Decode => todo!(),
|
||||
// TabKind::Process => todo!(),
|
||||
// TabKind::Encode => todo!(),
|
||||
// TabKind::Output => todo!(),
|
||||
// TabKind::Summary => todo!(),
|
||||
// TabKind::Help => todo!(),
|
||||
// }
|
||||
}
|
||||
|
||||
fn allowed_in_windows(&self, tab: &mut Self::Tab) -> bool {
|
||||
|
|
Loading…
Reference in a new issue