Skip to content

Commit a8c2514

Browse files
committed
Changes for egui/object upgrades
1 parent 4b58f69 commit a8c2514

File tree

5 files changed

+285
-256
lines changed

5 files changed

+285
-256
lines changed

src/obj/elf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ fn relocations_by_section(
250250
};
251251
// println!("Reloc: {:?}, symbol: {:?}", reloc, symbol);
252252
let target = match symbol.kind() {
253-
SymbolKind::Text | SymbolKind::Data | SymbolKind::Unknown => {
253+
SymbolKind::Text | SymbolKind::Data | SymbolKind::Label | SymbolKind::Unknown => {
254254
to_obj_symbol(obj_file, &symbol, reloc.addend())
255255
}
256256
SymbolKind::Section => {
@@ -305,7 +305,7 @@ fn line_info(obj_file: &File<'_>) -> Result<Option<BTreeMap<u32, u32>>> {
305305
let address_delta = reader.read_u32::<BigEndian>()?;
306306
map.insert(base_address + address_delta, line_number);
307307
}
308-
println!("Line info: {:#X?}", map);
308+
println!("Line info: {map:#X?}");
309309
return Ok(Some(map));
310310
}
311311
Ok(None)

src/views/data_diff.rs

Lines changed: 79 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{cmp::min, default::Default, mem::take};
22

3-
use egui::{text::LayoutJob, Color32, Label, Sense};
4-
use egui_extras::{Size, StripBuilder, TableBuilder};
3+
use egui::{text::LayoutJob, Align, Color32, Label, Layout, Sense, Vec2};
4+
use egui_extras::{Column, TableBuilder};
55
use time::format_description;
66

77
use crate::{
@@ -166,88 +166,89 @@ pub fn data_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
166166
let (Some(result), Some(selected_symbol)) = (&view_state.build, &view_state.selected_symbol) else {
167167
return rebuild;
168168
};
169-
StripBuilder::new(ui)
170-
.size(Size::exact(20.0))
171-
.size(Size::exact(40.0))
172-
.size(Size::remainder())
173-
.vertical(|mut strip| {
174-
strip.strip(|builder| {
175-
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
176-
strip.cell(|ui| {
177-
ui.horizontal(|ui| {
178-
if ui.button("Back").clicked() {
179-
view_state.current_view = View::SymbolDiff;
180-
}
181-
});
182-
});
183-
strip.cell(|ui| {
184-
ui.horizontal(|ui| {
185-
if ui.button("Build").clicked() {
186-
rebuild = true;
187-
}
188-
ui.scope(|ui| {
189-
ui.style_mut().override_text_style =
190-
Some(egui::TextStyle::Monospace);
191-
ui.style_mut().wrap = Some(false);
192-
if view_state.jobs.iter().any(|job| job.job_type == Job::ObjDiff) {
193-
ui.label("Building...");
194-
} else {
195-
ui.label("Last built:");
196-
let format =
197-
format_description::parse("[hour]:[minute]:[second]")
198-
.unwrap();
199-
ui.label(
200-
result
201-
.time
202-
.to_offset(view_state.utc_offset)
203-
.format(&format)
204-
.unwrap(),
205-
);
206-
}
207-
});
208-
});
169+
170+
// Header
171+
let available_width = ui.available_width();
172+
let column_width = available_width / 2.0;
173+
ui.allocate_ui_with_layout(
174+
Vec2 { x: available_width, y: 100.0 },
175+
Layout::left_to_right(Align::Min),
176+
|ui| {
177+
// Left column
178+
ui.allocate_ui_with_layout(
179+
Vec2 { x: column_width, y: 100.0 },
180+
Layout::top_down(Align::Min),
181+
|ui| {
182+
ui.set_width(column_width);
183+
184+
if ui.button("Back").clicked() {
185+
view_state.current_view = View::SymbolDiff;
186+
}
187+
188+
ui.scope(|ui| {
189+
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
190+
ui.style_mut().wrap = Some(false);
191+
ui.colored_label(Color32::WHITE, &selected_symbol.symbol_name);
192+
ui.label("Diff target:");
209193
});
210-
});
211-
});
212-
strip.strip(|builder| {
213-
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
214-
strip.cell(|ui| {
194+
},
195+
);
196+
197+
// Right column
198+
ui.allocate_ui_with_layout(
199+
Vec2 { x: column_width, y: 100.0 },
200+
Layout::top_down(Align::Min),
201+
|ui| {
202+
ui.set_width(column_width);
203+
204+
ui.horizontal(|ui| {
205+
if ui.button("Build").clicked() {
206+
rebuild = true;
207+
}
215208
ui.scope(|ui| {
216209
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
217210
ui.style_mut().wrap = Some(false);
218-
ui.colored_label(Color32::WHITE, &selected_symbol.symbol_name);
219-
ui.label("Diff target:");
220-
ui.separator();
211+
if view_state.jobs.iter().any(|job| job.job_type == Job::ObjDiff) {
212+
ui.label("Building...");
213+
} else {
214+
ui.label("Last built:");
215+
let format =
216+
format_description::parse("[hour]:[minute]:[second]").unwrap();
217+
ui.label(
218+
result
219+
.time
220+
.to_offset(view_state.utc_offset)
221+
.format(&format)
222+
.unwrap(),
223+
);
224+
}
221225
});
222226
});
223-
strip.cell(|ui| {
224-
ui.scope(|ui| {
225-
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
226-
ui.style_mut().wrap = Some(false);
227-
ui.label("");
228-
ui.label("Diff base:");
229-
ui.separator();
230-
});
227+
228+
ui.scope(|ui| {
229+
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
230+
ui.style_mut().wrap = Some(false);
231+
ui.label("");
232+
ui.label("Diff base:");
231233
});
232-
});
233-
});
234-
strip.cell(|ui| {
235-
if let (Some(left_obj), Some(right_obj)) = (&result.first_obj, &result.second_obj) {
236-
let table = TableBuilder::new(ui)
237-
.striped(false)
238-
.cell_layout(egui::Layout::left_to_right(egui::Align::Min))
239-
.column(Size::relative(0.5))
240-
.column(Size::relative(0.5))
241-
.resizable(false);
242-
data_table_ui(
243-
table,
244-
left_obj,
245-
right_obj,
246-
selected_symbol,
247-
&view_state.view_config,
248-
);
249-
}
250-
});
251-
});
234+
},
235+
);
236+
},
237+
);
238+
ui.separator();
239+
240+
// Table
241+
if let (Some(left_obj), Some(right_obj)) = (&result.first_obj, &result.second_obj) {
242+
let available_height = ui.available_height();
243+
let table = TableBuilder::new(ui)
244+
.striped(false)
245+
.cell_layout(Layout::left_to_right(Align::Min))
246+
.columns(Column::exact(column_width).clip(true), 2)
247+
.resizable(false)
248+
.auto_shrink([false, false])
249+
.min_scrolled_height(available_height);
250+
data_table_ui(table, left_obj, right_obj, selected_symbol, &view_state.view_config);
251+
}
252+
252253
rebuild
253254
}

0 commit comments

Comments
 (0)