Skip to content

Commit 3b7195e

Browse files
committed
Add buttons to expand/collapse all sections to symbol list view
1 parent c65e87c commit 3b7195e

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

objdiff-gui/src/views/function_diff.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ fn asm_table_ui(
512512
SymbolFilter::Mapping(right_symbol_ref),
513513
appearance,
514514
column,
515+
None,
515516
) {
516517
match action {
517518
DiffViewAction::Navigate(DiffViewNavigation {
@@ -570,6 +571,7 @@ fn asm_table_ui(
570571
SymbolFilter::Mapping(left_symbol_ref),
571572
appearance,
572573
column,
574+
None,
573575
) {
574576
match action {
575577
DiffViewAction::Navigate(DiffViewNavigation {

objdiff-gui/src/views/symbol_diff.rs

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::{collections::BTreeMap, mem::take, ops::Bound};
22

33
use egui::{
4-
style::ScrollAnimation, text::LayoutJob, CollapsingHeader, Color32, Id, OpenUrl, ScrollArea,
5-
SelectableLabel, TextEdit, Ui, Widget,
4+
style::ScrollAnimation, text::LayoutJob, CollapsingHeader, Color32, Id, Layout, OpenUrl,
5+
ScrollArea, SelectableLabel, TextEdit, Ui, Widget,
66
};
77
use objdiff_core::{
88
arch::ObjArch,
@@ -605,6 +605,7 @@ pub enum SymbolFilter<'a> {
605605
}
606606

607607
#[must_use]
608+
#[expect(clippy::too_many_arguments)]
608609
pub fn symbol_list_ui(
609610
ui: &mut Ui,
610611
ctx: SymbolDiffContext<'_>,
@@ -613,6 +614,7 @@ pub fn symbol_list_ui(
613614
filter: SymbolFilter<'_>,
614615
appearance: &Appearance,
615616
column: usize,
617+
open_sections: Option<bool>,
616618
) -> Option<DiffViewAction> {
617619
let mut ret = None;
618620
ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| {
@@ -766,6 +768,7 @@ pub fn symbol_list_ui(
766768
CollapsingHeader::new(header)
767769
.id_salt(Id::new(section.name.clone()).with(section.orig_index))
768770
.default_open(true)
771+
.open(open_sections)
769772
.show(ui, |ui| {
770773
if section.kind == ObjSectionKind::Code && state.reverse_fn_order {
771774
for (symbol, symbol_diff) in mapping
@@ -873,6 +876,7 @@ pub fn symbol_diff_ui(
873876

874877
// Header
875878
let available_width = ui.available_width();
879+
let mut open_sections = (None, None);
876880
render_header(ui, available_width, 2, |ui, column| {
877881
if column == 0 {
878882
// Left column
@@ -891,14 +895,25 @@ pub fn symbol_diff_ui(
891895
}
892896
});
893897

894-
let mut search = state.search.clone();
895-
let response = TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui);
896-
if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) {
897-
response.request_focus();
898-
}
899-
if response.changed() {
900-
ret = Some(DiffViewAction::SetSearch(search));
901-
}
898+
ui.horizontal(|ui| {
899+
let mut search = state.search.clone();
900+
let response = TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui);
901+
if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) {
902+
response.request_focus();
903+
}
904+
if response.changed() {
905+
ret = Some(DiffViewAction::SetSearch(search));
906+
}
907+
908+
ui.with_layout(Layout::right_to_left(egui::Align::TOP), |ui| {
909+
if ui.small_button("⏷").on_hover_text_at_pointer("Expand all").clicked() {
910+
open_sections.0 = Some(true);
911+
}
912+
if ui.small_button("⏶").on_hover_text_at_pointer("Collapse all").clicked() {
913+
open_sections.0 = Some(false);
914+
}
915+
})
916+
});
902917
} else if column == 1 {
903918
// Right column
904919
ui.horizontal(|ui| {
@@ -930,9 +945,20 @@ pub fn symbol_diff_ui(
930945
}
931946
});
932947

933-
if ui.add_enabled(!state.build_running, egui::Button::new("Build")).clicked() {
934-
ret = Some(DiffViewAction::Build);
935-
}
948+
ui.horizontal(|ui| {
949+
if ui.add_enabled(!state.build_running, egui::Button::new("Build")).clicked() {
950+
ret = Some(DiffViewAction::Build);
951+
}
952+
953+
ui.with_layout(Layout::right_to_left(egui::Align::TOP), |ui| {
954+
if ui.small_button("⏷").on_hover_text_at_pointer("Expand all").clicked() {
955+
open_sections.1 = Some(true);
956+
}
957+
if ui.small_button("⏶").on_hover_text_at_pointer("Collapse all").clicked() {
958+
open_sections.1 = Some(false);
959+
}
960+
})
961+
});
936962
}
937963
});
938964

@@ -957,6 +983,7 @@ pub fn symbol_diff_ui(
957983
filter,
958984
appearance,
959985
column,
986+
open_sections.0,
960987
) {
961988
ret = Some(result);
962989
}
@@ -981,6 +1008,7 @@ pub fn symbol_diff_ui(
9811008
filter,
9821009
appearance,
9831010
column,
1011+
open_sections.1,
9841012
) {
9851013
ret = Some(result);
9861014
}

0 commit comments

Comments
 (0)