mirror of
https://github.com/encounter/objdiff.git
synced 2025-06-07 23:23:34 +00:00
Add buttons to collapse or expand all sections in the symbol list view for an object simultaneously (#149)
* Add buttons to expand/collapse all sections to symbol list view * Add buttons to expand/collapse all sections to the split view
This commit is contained in:
parent
dcafe51eda
commit
9ab246367b
@ -1,6 +1,6 @@
|
|||||||
use std::{cmp::Ordering, default::Default};
|
use std::{cmp::Ordering, default::Default};
|
||||||
|
|
||||||
use egui::{text::LayoutJob, Id, Label, Response, RichText, Sense, Widget};
|
use egui::{text::LayoutJob, Id, Label, Layout, Response, RichText, Sense, Widget};
|
||||||
use egui_extras::TableRow;
|
use egui_extras::TableRow;
|
||||||
use objdiff_core::{
|
use objdiff_core::{
|
||||||
diff::{
|
diff::{
|
||||||
@ -414,6 +414,7 @@ fn asm_col_ui(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[expect(clippy::too_many_arguments)]
|
||||||
fn asm_table_ui(
|
fn asm_table_ui(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
available_width: f32,
|
available_width: f32,
|
||||||
@ -422,6 +423,7 @@ fn asm_table_ui(
|
|||||||
appearance: &Appearance,
|
appearance: &Appearance,
|
||||||
ins_view_state: &FunctionViewState,
|
ins_view_state: &FunctionViewState,
|
||||||
symbol_state: &SymbolViewState,
|
symbol_state: &SymbolViewState,
|
||||||
|
open_sections: (Option<bool>, Option<bool>),
|
||||||
) -> Option<DiffViewAction> {
|
) -> Option<DiffViewAction> {
|
||||||
let mut ret = None;
|
let mut ret = None;
|
||||||
let left_len = left_ctx.and_then(|ctx| {
|
let left_len = left_ctx.and_then(|ctx| {
|
||||||
@ -512,6 +514,7 @@ fn asm_table_ui(
|
|||||||
SymbolFilter::Mapping(right_symbol_ref),
|
SymbolFilter::Mapping(right_symbol_ref),
|
||||||
appearance,
|
appearance,
|
||||||
column,
|
column,
|
||||||
|
open_sections.0,
|
||||||
) {
|
) {
|
||||||
match action {
|
match action {
|
||||||
DiffViewAction::Navigate(DiffViewNavigation {
|
DiffViewAction::Navigate(DiffViewNavigation {
|
||||||
@ -570,6 +573,7 @@ fn asm_table_ui(
|
|||||||
SymbolFilter::Mapping(left_symbol_ref),
|
SymbolFilter::Mapping(left_symbol_ref),
|
||||||
appearance,
|
appearance,
|
||||||
column,
|
column,
|
||||||
|
open_sections.1,
|
||||||
) {
|
) {
|
||||||
match action {
|
match action {
|
||||||
DiffViewAction::Navigate(DiffViewNavigation {
|
DiffViewAction::Navigate(DiffViewNavigation {
|
||||||
@ -683,6 +687,7 @@ pub fn function_diff_ui(
|
|||||||
|
|
||||||
// Header
|
// Header
|
||||||
let available_width = ui.available_width();
|
let available_width = ui.available_width();
|
||||||
|
let mut open_sections = (None, None);
|
||||||
render_header(ui, available_width, 2, |ui, column| {
|
render_header(ui, available_width, 2, |ui, column| {
|
||||||
if column == 0 {
|
if column == 0 {
|
||||||
// Left column
|
// Left column
|
||||||
@ -736,11 +741,24 @@ pub fn function_diff_ui(
|
|||||||
.font(appearance.code_font.clone())
|
.font(appearance.code_font.clone())
|
||||||
.color(appearance.replace_color),
|
.color(appearance.replace_color),
|
||||||
);
|
);
|
||||||
ui.label(
|
|
||||||
RichText::new("Choose target symbol")
|
ui.horizontal(|ui| {
|
||||||
.font(appearance.code_font.clone())
|
ui.label(
|
||||||
.color(appearance.highlight_color),
|
RichText::new("Choose target symbol")
|
||||||
);
|
.font(appearance.code_font.clone())
|
||||||
|
.color(appearance.highlight_color),
|
||||||
|
);
|
||||||
|
|
||||||
|
ui.with_layout(Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||||
|
if ui.small_button("⏷").on_hover_text_at_pointer("Expand all").clicked() {
|
||||||
|
open_sections.0 = Some(true);
|
||||||
|
}
|
||||||
|
if ui.small_button("⏶").on_hover_text_at_pointer("Collapse all").clicked()
|
||||||
|
{
|
||||||
|
open_sections.0 = Some(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if column == 1 {
|
} else if column == 1 {
|
||||||
// Right column
|
// Right column
|
||||||
@ -812,11 +830,24 @@ pub fn function_diff_ui(
|
|||||||
.font(appearance.code_font.clone())
|
.font(appearance.code_font.clone())
|
||||||
.color(appearance.replace_color),
|
.color(appearance.replace_color),
|
||||||
);
|
);
|
||||||
ui.label(
|
|
||||||
RichText::new("Choose base symbol")
|
ui.horizontal(|ui| {
|
||||||
.font(appearance.code_font.clone())
|
ui.label(
|
||||||
.color(appearance.highlight_color),
|
RichText::new("Choose base symbol")
|
||||||
);
|
.font(appearance.code_font.clone())
|
||||||
|
.color(appearance.highlight_color),
|
||||||
|
);
|
||||||
|
|
||||||
|
ui.with_layout(Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||||
|
if ui.small_button("⏷").on_hover_text_at_pointer("Expand all").clicked() {
|
||||||
|
open_sections.1 = Some(true);
|
||||||
|
}
|
||||||
|
if ui.small_button("⏶").on_hover_text_at_pointer("Collapse all").clicked()
|
||||||
|
{
|
||||||
|
open_sections.1 = Some(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -834,6 +865,7 @@ pub fn function_diff_ui(
|
|||||||
appearance,
|
appearance,
|
||||||
&state.function_state,
|
&state.function_state,
|
||||||
&state.symbol_state,
|
&state.symbol_state,
|
||||||
|
open_sections,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.inner
|
.inner
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::{collections::BTreeMap, mem::take, ops::Bound};
|
use std::{collections::BTreeMap, mem::take, ops::Bound};
|
||||||
|
|
||||||
use egui::{
|
use egui::{
|
||||||
style::ScrollAnimation, text::LayoutJob, CollapsingHeader, Color32, Id, OpenUrl, ScrollArea,
|
style::ScrollAnimation, text::LayoutJob, CollapsingHeader, Color32, Id, Layout, OpenUrl,
|
||||||
SelectableLabel, TextEdit, Ui, Widget,
|
ScrollArea, SelectableLabel, TextEdit, Ui, Widget,
|
||||||
};
|
};
|
||||||
use objdiff_core::{
|
use objdiff_core::{
|
||||||
arch::ObjArch,
|
arch::ObjArch,
|
||||||
@ -605,6 +605,7 @@ pub enum SymbolFilter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[expect(clippy::too_many_arguments)]
|
||||||
pub fn symbol_list_ui(
|
pub fn symbol_list_ui(
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
ctx: SymbolDiffContext<'_>,
|
ctx: SymbolDiffContext<'_>,
|
||||||
@ -613,6 +614,7 @@ pub fn symbol_list_ui(
|
|||||||
filter: SymbolFilter<'_>,
|
filter: SymbolFilter<'_>,
|
||||||
appearance: &Appearance,
|
appearance: &Appearance,
|
||||||
column: usize,
|
column: usize,
|
||||||
|
open_sections: Option<bool>,
|
||||||
) -> Option<DiffViewAction> {
|
) -> Option<DiffViewAction> {
|
||||||
let mut ret = None;
|
let mut ret = None;
|
||||||
ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| {
|
ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| {
|
||||||
@ -766,6 +768,7 @@ pub fn symbol_list_ui(
|
|||||||
CollapsingHeader::new(header)
|
CollapsingHeader::new(header)
|
||||||
.id_salt(Id::new(section.name.clone()).with(section.orig_index))
|
.id_salt(Id::new(section.name.clone()).with(section.orig_index))
|
||||||
.default_open(true)
|
.default_open(true)
|
||||||
|
.open(open_sections)
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
if section.kind == ObjSectionKind::Code && state.reverse_fn_order {
|
if section.kind == ObjSectionKind::Code && state.reverse_fn_order {
|
||||||
for (symbol, symbol_diff) in mapping
|
for (symbol, symbol_diff) in mapping
|
||||||
@ -873,6 +876,7 @@ pub fn symbol_diff_ui(
|
|||||||
|
|
||||||
// Header
|
// Header
|
||||||
let available_width = ui.available_width();
|
let available_width = ui.available_width();
|
||||||
|
let mut open_sections = (None, None);
|
||||||
render_header(ui, available_width, 2, |ui, column| {
|
render_header(ui, available_width, 2, |ui, column| {
|
||||||
if column == 0 {
|
if column == 0 {
|
||||||
// Left column
|
// Left column
|
||||||
@ -891,14 +895,25 @@ pub fn symbol_diff_ui(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut search = state.search.clone();
|
ui.horizontal(|ui| {
|
||||||
let response = TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui);
|
let mut search = state.search.clone();
|
||||||
if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) {
|
let response = TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui);
|
||||||
response.request_focus();
|
if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) {
|
||||||
}
|
response.request_focus();
|
||||||
if response.changed() {
|
}
|
||||||
ret = Some(DiffViewAction::SetSearch(search));
|
if response.changed() {
|
||||||
}
|
ret = Some(DiffViewAction::SetSearch(search));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.with_layout(Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||||
|
if ui.small_button("⏷").on_hover_text_at_pointer("Expand all").clicked() {
|
||||||
|
open_sections.0 = Some(true);
|
||||||
|
}
|
||||||
|
if ui.small_button("⏶").on_hover_text_at_pointer("Collapse all").clicked() {
|
||||||
|
open_sections.0 = Some(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
} else if column == 1 {
|
} else if column == 1 {
|
||||||
// Right column
|
// Right column
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
@ -930,9 +945,20 @@ pub fn symbol_diff_ui(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ui.add_enabled(!state.build_running, egui::Button::new("Build")).clicked() {
|
ui.horizontal(|ui| {
|
||||||
ret = Some(DiffViewAction::Build);
|
if ui.add_enabled(!state.build_running, egui::Button::new("Build")).clicked() {
|
||||||
}
|
ret = Some(DiffViewAction::Build);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.with_layout(Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||||
|
if ui.small_button("⏷").on_hover_text_at_pointer("Expand all").clicked() {
|
||||||
|
open_sections.1 = Some(true);
|
||||||
|
}
|
||||||
|
if ui.small_button("⏶").on_hover_text_at_pointer("Collapse all").clicked() {
|
||||||
|
open_sections.1 = Some(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -957,6 +983,7 @@ pub fn symbol_diff_ui(
|
|||||||
filter,
|
filter,
|
||||||
appearance,
|
appearance,
|
||||||
column,
|
column,
|
||||||
|
open_sections.0,
|
||||||
) {
|
) {
|
||||||
ret = Some(result);
|
ret = Some(result);
|
||||||
}
|
}
|
||||||
@ -981,6 +1008,7 @@ pub fn symbol_diff_ui(
|
|||||||
filter,
|
filter,
|
||||||
appearance,
|
appearance,
|
||||||
column,
|
column,
|
||||||
|
open_sections.1,
|
||||||
) {
|
) {
|
||||||
ret = Some(result);
|
ret = Some(result);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user