Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions objdiff-gui/src/views/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct Appearance {
pub diff_colors: Vec<Color32>,
pub diff_bg_color: Option<Color32>,
pub theme: egui::Theme,
pub show_symbol_sizes: ShowSymbolSizeState,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s put this in SymbolViewState instead!


// Applied by theme
#[serde(skip)]
Expand Down Expand Up @@ -43,6 +44,12 @@ pub struct Appearance {
pub next_code_font: Option<FontId>,
}

#[derive(serde::Deserialize, serde::Serialize, PartialEq, Debug)]
pub enum ShowSymbolSizeState {
Off,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can derive(Default) and put #[default] on Off

Decimal,
Hex,
}
pub struct FontState {
definitions: egui::FontDefinitions,
source: font_kit::source::SystemSource,
Expand All @@ -60,6 +67,7 @@ impl Default for Appearance {
code_font: DEFAULT_CODE_FONT,
diff_colors: DEFAULT_COLOR_ROTATION.to_vec(),
theme: egui::Theme::Dark,
show_symbol_sizes: ShowSymbolSizeState::Off,
text_color: Color32::GRAY,
emphasized_text_color: Color32::LIGHT_GRAY,
deemphasized_text_color: Color32::DARK_GRAY,
Expand Down Expand Up @@ -302,6 +310,26 @@ pub fn appearance_window(ctx: &egui::Context, show: &mut bool, appearance: &mut
appearance,
);
ui.separator();
egui::ComboBox::from_label("Show symbol sizes")
.selected_text(format!("{:?}", appearance.show_symbol_sizes))
.show_ui(ui, |ui| {
ui.selectable_value(
&mut appearance.show_symbol_sizes,
ShowSymbolSizeState::Off,
"Off",
);
ui.selectable_value(
&mut appearance.show_symbol_sizes,
ShowSymbolSizeState::Decimal,
"Decimal",
);
ui.selectable_value(
&mut appearance.show_symbol_sizes,
ShowSymbolSizeState::Hex,
"Hex",
);
});
ui.separator();
ui.horizontal(|ui| {
ui.label("Diff fill color:");
let mut diff_bg_color =
Expand Down
17 changes: 16 additions & 1 deletion objdiff-gui/src/views/symbol_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
hotkeys,
jobs::{is_create_scratch_available, start_create_scratch},
views::{
appearance::Appearance,
appearance::{Appearance, ShowSymbolSizeState},
diff::{context_menu_items_ui, hover_items_ui},
function_diff::FunctionViewState,
write_text,
Expand Down Expand Up @@ -572,6 +572,21 @@ fn symbol_ui(
write_text(") ", appearance.text_color, &mut job, appearance.code_font.clone());
}
write_text(name, appearance.highlight_color, &mut job, appearance.code_font.clone());
if appearance.show_symbol_sizes == ShowSymbolSizeState::Decimal {
write_text(
&format!(" (size={})", symbol.size),
appearance.deemphasized_text_color,
&mut job,
appearance.code_font.clone(),
);
} else if appearance.show_symbol_sizes == ShowSymbolSizeState::Hex {
write_text(
&format!(" (size={:x})", symbol.size),
appearance.deemphasized_text_color,
&mut job,
appearance.code_font.clone(),
);
}
let response = egui::Button::selectable(selected, job)
.ui(ui)
.on_hover_ui_at_pointer(|ui| symbol_hover_ui(ui, ctx, symbol_idx, appearance));
Expand Down
Loading