From 1fa9758d2c61d6a71323397a09f9a71fa5dbb8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 21 Aug 2026 20:45:16 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20map=20card=20and=20dock=20c?= =?UTF-8?q?ontrols?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/app/src/ui/cards.rs | 28 +++++++++++++++++++++++++--- crates/app/src/ui/dock_stance.rs | 18 ++++++++++++++++++ crates/app/src/ui/hitmap.rs | 3 +++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/crates/app/src/ui/cards.rs b/crates/app/src/ui/cards.rs index 1df4f1f..58b8e16 100644 --- a/crates/app/src/ui/cards.rs +++ b/crates/app/src/ui/cards.rs @@ -181,8 +181,21 @@ fn dark_step_glyph( plus: bool, on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, ) -> impl IntoElement { + let id = id.into(); + let hitmap = hitmap::enabled().then(|| { + let id = id.to_string(); + hitmap::dynamic( + move || { + ( + format!("card.{id}"), + if plus { "Increase" } else { "Decrease" }.into(), + ) + }, + true, + ) + }); div() - .id(id.into()) + .id(id) .flex_none() .w(px(HIT_MIN)) .h(px(KEYS_ROW_H)) @@ -193,6 +206,7 @@ fn dark_step_glyph( .cursor_pointer() .hover(|s| s.bg(rgb(DARK_RAISED()))) .on_click(on_click) + .children(hitmap.flatten()) .child(dark_row_value(if plus { "+" } else { "−" })) } @@ -203,8 +217,15 @@ fn dark_ghost_button( active: bool, on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, ) -> impl IntoElement { + let id = id.into(); + let text: SharedString = text.into(); + let hitmap = hitmap::enabled().then(|| { + let id = id.to_string(); + let label = text.clone(); + hitmap::dynamic(move || (format!("card.{id}"), label.to_string()), true) + }); div() - .id(id.into()) + .id(id) .flex_1() .flex() .h(px(CONTROL_H)) @@ -216,6 +237,7 @@ fn dark_ghost_button( .cursor_pointer() .hover(|s| s.bg(rgb(DARK_RAISED()))) .on_click(on_click) + .children(hitmap.flatten()) .child( div() .type_style(type_scale::label( @@ -223,7 +245,7 @@ fn dark_ghost_button( gpui::FontWeight::MEDIUM, )) .text_color(rgb(if active { INK1() } else { INK2() })) - .child(text.into()), + .child(text), ) .when(!chord.is_empty(), |d| { d.child( diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index f245e75..5129a40 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -861,6 +861,15 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { this.library_tab = tab; cx.notify(); })) + .children(hitmap::dynamic( + move || { + ( + format!("dock.filter.{}", tab.label()), + format!("Filter {}", tab.label()), + ) + }, + true, + )) .child(tab.label()) })), ) @@ -888,6 +897,15 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { this.dock_sort = sort; cx.notify(); })) + .children(hitmap::dynamic( + move || { + ( + format!("dock.sort.{}", sort.label()), + format!("Sort {}", sort.label()), + ) + }, + true, + )) .child(sort.label()) })), ) diff --git a/crates/app/src/ui/hitmap.rs b/crates/app/src/ui/hitmap.rs index 5d538d6..6c03ec0 100644 --- a/crates/app/src/ui/hitmap.rs +++ b/crates/app/src/ui/hitmap.rs @@ -35,6 +35,9 @@ fn output_path() -> Option<&'static Path> { LazyLock::new(|| std::env::var_os("EDITH_HITMAP").map(PathBuf::from)); PATH.as_deref() } +pub(crate) fn enabled() -> bool { + output_path().is_some() +} /// Clears the current-frame controls before descendants record their laid-out /// bounds, then writes the completed frame after all descendants prepaint.