Skip to content

Commit 17a6197

Browse files
committed
refactor spacings
1 parent f5654ef commit 17a6197

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/gui.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,20 @@ impl MyApp {
301301

302302
fn draw_central_panel(&mut self, ctx: &egui::Context) {
303303
egui::CentralPanel::default().show(ctx, |ui| {
304-
let border = 10.0;
304+
let left_border = 10.0;
305305

306306
let panel_height = ui.available_size().y;
307307
let height = ui.available_size().y * self.plot_serial_display_ratio;
308308
let plots_height = height;
309309
// need to subtract 12.0, this seems to be the height of the separator of two adjacent plots
310310
let plot_height =
311311
plots_height / (self.serial_devices.number_of_plots[self.device_idx] as f32) - 12.0;
312-
let spacing = 5.0;
313-
let width = ui.available_size().x - 2.0 * border - RIGHT_PANEL_WIDTH;
312+
let top_spacing = 5.0;
313+
let width = ui.available_size().x - 2.0 * left_border - RIGHT_PANEL_WIDTH;
314314

315-
ui.add_space(spacing);
315+
ui.add_space(top_spacing);
316316
ui.horizontal(|ui| {
317-
ui.add_space(border);
317+
ui.add_space(left_border);
318318
ui.vertical(|ui| {
319319
if let Ok(read_guard) = self.data_lock.read() {
320320
self.data = read_guard.clone();
@@ -387,11 +387,13 @@ impl MyApp {
387387
+ resize_y / panel_height)
388388
.clamp(0.1, 0.9);
389389

390-
ui.add_space(spacing);
390+
ui.add_space(top_spacing);
391391
});
392392

393-
let serial_height =
394-
panel_height - plots_ui.response.rect.height() - border * 2.0 - spacing;
393+
let serial_height = panel_height
394+
- plots_ui.response.rect.height()
395+
- left_border * 2.0
396+
- top_spacing;
395397

396398
let num_rows = self.data.raw_traffic.len();
397399
let row_height = ui.text_style_height(&egui::TextStyle::Body);
@@ -407,8 +409,8 @@ impl MyApp {
407409
.auto_shrink([false; 2])
408410
.stick_to_bottom(true)
409411
.enable_scrolling(true)
410-
.max_height(serial_height - spacing)
411-
.min_scrolled_height(serial_height - spacing)
412+
.max_height(serial_height - top_spacing)
413+
.min_scrolled_height(serial_height - top_spacing)
412414
.max_width(width)
413415
.show_rows(ui, row_height, num_rows, |ui, row_range| {
414416
let content: String = row_range
@@ -429,7 +431,7 @@ impl MyApp {
429431
.desired_width(width),
430432
);
431433
});
432-
ui.add_space(spacing / 2.0);
434+
ui.add_space(top_spacing / 2.0);
433435
ui.horizontal(|ui| {
434436
let cmd_line = ui.add(
435437
egui::TextEdit::singleline(&mut self.command)
@@ -470,7 +472,7 @@ impl MyApp {
470472

471473
ctx.request_repaint()
472474
});
473-
ui.add_space(border);
475+
ui.add_space(left_border);
474476
});
475477
});
476478
}

0 commit comments

Comments
 (0)