Click on empty space in row to clear highlight

Resolves #116
This commit is contained in:
Luke Street 2024-10-07 19:53:16 -06:00
parent ab2e84a2c6
commit 6fb0a63de2
1 changed files with 11 additions and 1 deletions

View File

@ -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( fn ins_hover_ui(
@ -397,6 +402,7 @@ fn asm_table_ui(
}; };
table.body(|body| { table.body(|body| {
body.rows(appearance.code_font.size, instructions_len, |mut row| { 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) { if let (Some(left_obj), Some(left_symbol_ref)) = (left_obj, left_symbol) {
asm_col_ui( asm_col_ui(
&mut row, &mut row,
@ -421,6 +427,9 @@ fn asm_table_ui(
} else { } else {
empty_col_ui(&mut row); empty_col_ui(&mut row);
} }
if row.response().clicked() {
ins_view_state.clear_highlight();
}
}); });
}); });
Some(()) 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) .columns(Column::exact(column_width).clip(true), 2)
.resizable(false) .resizable(false)
.auto_shrink([false, false]) .auto_shrink([false, false])
.min_scrolled_height(available_height); .min_scrolled_height(available_height)
.sense(Sense::click());
asm_table_ui( asm_table_ui(
table, table,
result.first_obj.as_ref(), result.first_obj.as_ref(),