From ec7de41cc3385cb9a263a26e998b2a614ce1c753 Mon Sep 17 00:00:00 2001 From: kernelkind Date: Mon, 13 Jan 2025 15:53:30 -0500 Subject: [PATCH] toggle move tooltip on button press Signed-off-by: kernelkind --- .../notedeck_columns/src/ui/column/header.rs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/notedeck_columns/src/ui/column/header.rs b/crates/notedeck_columns/src/ui/column/header.rs index 7f97b4c4..3e89bb0e 100644 --- a/crates/notedeck_columns/src/ui/column/header.rs +++ b/crates/notedeck_columns/src/ui/column/header.rs @@ -204,9 +204,25 @@ impl<'a> NavTitle<'a> { // returns the column index to switch to, if any fn move_button_section(&mut self, ui: &mut egui::Ui) -> Option { let cur_id = ui.id().with("move"); - let move_resp = ui.add(grab_button()); + let mut move_resp = ui.add(grab_button()); + + // showing the hover text while showing the move tooltip causes some weird visuals + if ui.data(|d| d.get_temp::(cur_id).is_none()) { + move_resp = move_resp.on_hover_text("Moves this column to another positon"); + } + if move_resp.clicked() { - ui.data_mut(|d| d.insert_temp(cur_id, true)); + ui.data_mut(|d| { + if let Some(val) = d.get_temp::(cur_id) { + if val { + d.remove_temp::(cur_id); + } else { + d.insert_temp(cur_id, true); + } + } else { + d.insert_temp(cur_id, true); + } + }); } ui.data(|d| d.get_temp(cur_id)).and_then(|val| { @@ -568,4 +584,4 @@ fn grab_button() -> impl egui::Widget { helper.take_animation_response() } -} \ No newline at end of file +}