Skip to content

Commit d26a152

Browse files
committed
configs for show symbol size
1 parent 7b9a2c9 commit d26a152

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

objdiff-gui/src/views/appearance.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct Appearance {
1313
pub diff_colors: Vec<Color32>,
1414
pub diff_bg_color: Option<Color32>,
1515
pub theme: egui::Theme,
16+
pub show_symbol_sizes: ShowSymbolSizeState,
1617

1718
// Applied by theme
1819
#[serde(skip)]
@@ -43,6 +44,12 @@ pub struct Appearance {
4344
pub next_code_font: Option<FontId>,
4445
}
4546

47+
#[derive(serde::Deserialize, serde::Serialize, PartialEq, Debug)]
48+
pub enum ShowSymbolSizeState {
49+
Off,
50+
Decimal,
51+
Hex,
52+
}
4653
pub struct FontState {
4754
definitions: egui::FontDefinitions,
4855
source: font_kit::source::SystemSource,
@@ -60,6 +67,7 @@ impl Default for Appearance {
6067
code_font: DEFAULT_CODE_FONT,
6168
diff_colors: DEFAULT_COLOR_ROTATION.to_vec(),
6269
theme: egui::Theme::Dark,
70+
show_symbol_sizes: ShowSymbolSizeState::Off,
6371
text_color: Color32::GRAY,
6472
emphasized_text_color: Color32::LIGHT_GRAY,
6573
deemphasized_text_color: Color32::DARK_GRAY,
@@ -302,6 +310,14 @@ pub fn appearance_window(ctx: &egui::Context, show: &mut bool, appearance: &mut
302310
appearance,
303311
);
304312
ui.separator();
313+
egui::ComboBox::from_label("Show symbol sizes")
314+
.selected_text(format!("{:?}", appearance.show_symbol_sizes))
315+
.show_ui(ui, |ui| {
316+
ui.selectable_value(&mut appearance.show_symbol_sizes, ShowSymbolSizeState::Off, "Off");
317+
ui.selectable_value(&mut appearance.show_symbol_sizes, ShowSymbolSizeState::Decimal, "Decimal");
318+
ui.selectable_value(&mut appearance.show_symbol_sizes, ShowSymbolSizeState::Hex, "Hex");
319+
});
320+
ui.separator();
305321
ui.horizontal(|ui| {
306322
ui.label("Diff fill color:");
307323
let mut diff_bg_color =

objdiff-gui/src/views/symbol_diff.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
hotkeys,
2323
jobs::{is_create_scratch_available, start_create_scratch},
2424
views::{
25-
appearance::Appearance,
25+
appearance::{Appearance, ShowSymbolSizeState},
2626
diff::{context_menu_items_ui, hover_items_ui},
2727
function_diff::FunctionViewState,
2828
write_text,
@@ -572,12 +572,21 @@ fn symbol_ui(
572572
write_text(") ", appearance.text_color, &mut job, appearance.code_font.clone());
573573
}
574574
write_text(name, appearance.highlight_color, &mut job, appearance.code_font.clone());
575-
write_text(
576-
&format!(" (size={})", symbol.size),
577-
appearance.deemphasized_text_color,
578-
&mut job,
579-
appearance.code_font.clone(),
580-
);
575+
if appearance.show_symbol_sizes == ShowSymbolSizeState::Decimal {
576+
write_text(
577+
&format!(" (size={})", symbol.size),
578+
appearance.deemphasized_text_color,
579+
&mut job,
580+
appearance.code_font.clone(),
581+
);
582+
} else if appearance.show_symbol_sizes == ShowSymbolSizeState::Hex {
583+
write_text(
584+
&format!(" (size={:x})", symbol.size),
585+
appearance.deemphasized_text_color,
586+
&mut job,
587+
appearance.code_font.clone(),
588+
);
589+
}
581590
let response = egui::Button::selectable(selected, job)
582591
.ui(ui)
583592
.on_hover_ui_at_pointer(|ui| symbol_hover_ui(ui, ctx, symbol_idx, appearance));

0 commit comments

Comments
 (0)