From 6fb0a63de278c392d616d6b37615526f796638c4 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 7 Oct 2024 19:53:16 -0600 Subject: [PATCH] Click on empty space in row to clear highlight Resolves #116 --- objdiff-gui/src/views/function_diff.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/objdiff-gui/src/views/function_diff.rs b/objdiff-gui/src/views/function_diff.rs index 8ff85fe..07c430d 100644 --- a/objdiff-gui/src/views/function_diff.rs +++ b/objdiff-gui/src/views/function_diff.rs @@ -65,6 +65,11 @@ impl FunctionViewState { } } } + + fn clear_highlight(&mut self) { + self.left_highlight = HighlightKind::None; + self.right_highlight = HighlightKind::None; + } } fn ins_hover_ui( @@ -397,6 +402,7 @@ fn asm_table_ui( }; table.body(|body| { body.rows(appearance.code_font.size, instructions_len, |mut row| { + row.set_hovered(false); // Disable row hover effect if let (Some(left_obj), Some(left_symbol_ref)) = (left_obj, left_symbol) { asm_col_ui( &mut row, @@ -421,6 +427,9 @@ fn asm_table_ui( } else { empty_col_ui(&mut row); } + if row.response().clicked() { + ins_view_state.clear_highlight(); + } }); }); Some(()) @@ -559,7 +568,8 @@ pub fn function_diff_ui(ui: &mut egui::Ui, state: &mut DiffViewState, appearance .columns(Column::exact(column_width).clip(true), 2) .resizable(false) .auto_shrink([false, false]) - .min_scrolled_height(available_height); + .min_scrolled_height(available_height) + .sense(Sense::click()); asm_table_ui( table, result.first_obj.as_ref(),