Skip to content

Commit 9596051

Browse files
committed
Allow collapsing sidebar in symbols view
1 parent a5d9d82 commit 9596051

File tree

1 file changed

+52
-19
lines changed

1 file changed

+52
-19
lines changed

objdiff-gui/src/app.rs

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use crate::{
4646
},
4747
};
4848

49-
#[derive(Default)]
5049
pub struct ViewState {
5150
pub jobs: JobQueue,
5251
pub config_state: ConfigViewState,
@@ -63,6 +62,30 @@ pub struct ViewState {
6362
pub show_debug: bool,
6463
pub show_graphics: bool,
6564
pub show_jobs: bool,
65+
pub show_side_panel: bool,
66+
}
67+
68+
impl Default for ViewState {
69+
fn default() -> Self {
70+
Self {
71+
jobs: Default::default(),
72+
config_state: Default::default(),
73+
demangle_state: Default::default(),
74+
rlwinm_decode_state: Default::default(),
75+
diff_state: Default::default(),
76+
graphics_state: Default::default(),
77+
frame_history: Default::default(),
78+
show_appearance_config: false,
79+
show_demangle: false,
80+
show_rlwinm_decode: false,
81+
show_project_config: false,
82+
show_arch_config: false,
83+
show_debug: false,
84+
show_graphics: false,
85+
show_jobs: false,
86+
show_side_panel: true,
87+
}
88+
}
6689
}
6790

6891
/// The configuration for a single object file.
@@ -485,12 +508,26 @@ impl eframe::App for App {
485508
show_debug,
486509
show_graphics,
487510
show_jobs,
511+
show_side_panel,
488512
} = view_state;
489513

490514
frame_history.on_new_frame(ctx.input(|i| i.time), frame.info().cpu_usage);
491515

516+
let side_panel_available = diff_state.current_view == View::SymbolDiff;
517+
492518
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
493519
egui::menu::bar(ui, |ui| {
520+
if ui
521+
.add_enabled(
522+
side_panel_available,
523+
egui::Button::new(if *show_side_panel { "⏴" } else { "⏵" }),
524+
)
525+
.on_hover_text("Toggle side panel")
526+
.clicked()
527+
{
528+
*show_side_panel = !*show_side_panel;
529+
}
530+
ui.separator();
494531
ui.menu_button("File", |ui| {
495532
#[cfg(debug_assertions)]
496533
if ui.button("Debug…").clicked() {
@@ -607,30 +644,26 @@ impl eframe::App for App {
607644
});
608645
});
609646

610-
let build_success = matches!(&diff_state.build, Some(b) if b.first_status.success && b.second_status.success);
611-
if diff_state.current_view == View::FunctionDiff && build_success {
612-
egui::CentralPanel::default().show(ctx, |ui| {
613-
function_diff_ui(ui, diff_state, appearance);
614-
});
615-
} else if diff_state.current_view == View::DataDiff && build_success {
616-
egui::CentralPanel::default().show(ctx, |ui| {
617-
data_diff_ui(ui, diff_state, appearance);
618-
});
619-
} else if diff_state.current_view == View::ExtabDiff && build_success {
620-
egui::CentralPanel::default().show(ctx, |ui| {
621-
extab_diff_ui(ui, diff_state, appearance);
622-
});
623-
} else {
624-
egui::SidePanel::left("side_panel").show(ctx, |ui| {
647+
if side_panel_available {
648+
egui::SidePanel::left("side_panel").show_animated(ctx, *show_side_panel, |ui| {
625649
egui::ScrollArea::both().show(ui, |ui| {
626650
config_ui(ui, state, show_project_config, config_state, appearance);
627651
});
628652
});
653+
}
629654

630-
egui::CentralPanel::default().show(ctx, |ui| {
655+
egui::CentralPanel::default().show(ctx, |ui| {
656+
let build_success = matches!(&diff_state.build, Some(b) if b.first_status.success && b.second_status.success);
657+
if diff_state.current_view == View::FunctionDiff && build_success {
658+
function_diff_ui(ui, diff_state, appearance);
659+
} else if diff_state.current_view == View::DataDiff && build_success {
660+
data_diff_ui(ui, diff_state, appearance);
661+
} else if diff_state.current_view == View::ExtabDiff && build_success {
662+
extab_diff_ui(ui, diff_state, appearance);
663+
} else {
631664
symbol_diff_ui(ui, diff_state, appearance);
632-
});
633-
}
665+
}
666+
});
634667

635668
project_window(ctx, state, show_project_config, config_state, appearance);
636669
appearance_window(ctx, show_appearance_config, appearance);

0 commit comments

Comments
 (0)