commit ec7de41cc3385cb9a263a26e998b2a614ce1c753
parent 23d65898aaf879213ed765bc5d685c50ce7f8f0a
Author: kernelkind <kernelkind@gmail.com>
Date: Mon, 13 Jan 2025 15:53:30 -0500
toggle move tooltip on button press
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git 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<usize> {
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::<bool>(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::<bool>(cur_id) {
+ if val {
+ d.remove_temp::<bool>(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
+}