Map card and dock controls
Browse files at this commit1fa9758d2c61d6a71323397a09f9a71fa5dbb8f8Parent: 7f7f103- feat
- map card and dock controls
3 changed files +46 -3
- crates/app/src/ui/cards.rs +25 -3
- crates/app/src/ui/dock_stance.rs +18 -0
- crates/app/src/ui/hitmap.rs +3 -0
crates/app/src/ui/cards.rsmodified+25 -3
| @@ -181,8 +181,21 @@ fn dark_step_glyph( | |||
| 181 | plus: bool, | 181 | plus: bool, |
| 182 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | 182 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, |
| 183 | ) -> impl IntoElement { | 183 | ) -> impl IntoElement { |
| 184 | + let id = id.into(); | ||
| 185 | + let hitmap = hitmap::enabled().then(|| { | ||
| 186 | + let id = id.to_string(); | ||
| 187 | + hitmap::dynamic( | ||
| 188 | + move || { | ||
| 189 | + ( | ||
| 190 | + format!("card.{id}"), | ||
| 191 | + if plus { "Increase" } else { "Decrease" }.into(), | ||
| 192 | + ) | ||
| 193 | + }, | ||
| 194 | + true, | ||
| 195 | + ) | ||
| 196 | + }); | ||
| 184 | div() | 197 | div() |
| 185 | - .id(id.into()) | 198 | + .id(id) |
| 186 | .flex_none() | 199 | .flex_none() |
| 187 | .w(px(HIT_MIN)) | 200 | .w(px(HIT_MIN)) |
| 188 | .h(px(KEYS_ROW_H)) | 201 | .h(px(KEYS_ROW_H)) |
| @@ -193,6 +206,7 @@ fn dark_step_glyph( | |||
| 193 | .cursor_pointer() | 206 | .cursor_pointer() |
| 194 | .hover(|s| s.bg(rgb(DARK_RAISED()))) | 207 | .hover(|s| s.bg(rgb(DARK_RAISED()))) |
| 195 | .on_click(on_click) | 208 | .on_click(on_click) |
| 209 | + .children(hitmap.flatten()) | ||
| 196 | .child(dark_row_value(if plus { "+" } else { "−" })) | 210 | .child(dark_row_value(if plus { "+" } else { "−" })) |
| 197 | } | 211 | } |
| 198 | 212 | ||
| @@ -203,8 +217,15 @@ fn dark_ghost_button( | |||
| 203 | active: bool, | 217 | active: bool, |
| 204 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | 218 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, |
| 205 | ) -> impl IntoElement { | 219 | ) -> impl IntoElement { |
| 220 | + let id = id.into(); | ||
| 221 | + let text: SharedString = text.into(); | ||
| 222 | + let hitmap = hitmap::enabled().then(|| { | ||
| 223 | + let id = id.to_string(); | ||
| 224 | + let label = text.clone(); | ||
| 225 | + hitmap::dynamic(move || (format!("card.{id}"), label.to_string()), true) | ||
| 226 | + }); | ||
| 206 | div() | 227 | div() |
| 207 | - .id(id.into()) | 228 | + .id(id) |
| 208 | .flex_1() | 229 | .flex_1() |
| 209 | .flex() | 230 | .flex() |
| 210 | .h(px(CONTROL_H)) | 231 | .h(px(CONTROL_H)) |
| @@ -216,6 +237,7 @@ fn dark_ghost_button( | |||
| 216 | .cursor_pointer() | 237 | .cursor_pointer() |
| 217 | .hover(|s| s.bg(rgb(DARK_RAISED()))) | 238 | .hover(|s| s.bg(rgb(DARK_RAISED()))) |
| 218 | .on_click(on_click) | 239 | .on_click(on_click) |
| 240 | + .children(hitmap.flatten()) | ||
| 219 | .child( | 241 | .child( |
| 220 | div() | 242 | div() |
| 221 | .type_style(type_scale::label( | 243 | .type_style(type_scale::label( |
| @@ -223,7 +245,7 @@ fn dark_ghost_button( | |||
| 223 | gpui::FontWeight::MEDIUM, | 245 | gpui::FontWeight::MEDIUM, |
| 224 | )) | 246 | )) |
| 225 | .text_color(rgb(if active { INK1() } else { INK2() })) | 247 | .text_color(rgb(if active { INK1() } else { INK2() })) |
| 226 | - .child(text.into()), | 248 | + .child(text), |
| 227 | ) | 249 | ) |
| 228 | .when(!chord.is_empty(), |d| { | 250 | .when(!chord.is_empty(), |d| { |
| 229 | d.child( | 251 | d.child( |
crates/app/src/ui/dock_stance.rsmodified+18 -0
| @@ -861,6 +861,15 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 861 | this.library_tab = tab; | 861 | this.library_tab = tab; |
| 862 | cx.notify(); | 862 | cx.notify(); |
| 863 | })) | 863 | })) |
| 864 | + .children(hitmap::dynamic( | ||
| 865 | + move || { | ||
| 866 | + ( | ||
| 867 | + format!("dock.filter.{}", tab.label()), | ||
| 868 | + format!("Filter {}", tab.label()), | ||
| 869 | + ) | ||
| 870 | + }, | ||
| 871 | + true, | ||
| 872 | + )) | ||
| 864 | .child(tab.label()) | 873 | .child(tab.label()) |
| 865 | })), | 874 | })), |
| 866 | ) | 875 | ) |
| @@ -888,6 +897,15 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 888 | this.dock_sort = sort; | 897 | this.dock_sort = sort; |
| 889 | cx.notify(); | 898 | cx.notify(); |
| 890 | })) | 899 | })) |
| 900 | + .children(hitmap::dynamic( | ||
| 901 | + move || { | ||
| 902 | + ( | ||
| 903 | + format!("dock.sort.{}", sort.label()), | ||
| 904 | + format!("Sort {}", sort.label()), | ||
| 905 | + ) | ||
| 906 | + }, | ||
| 907 | + true, | ||
| 908 | + )) | ||
| 891 | .child(sort.label()) | 909 | .child(sort.label()) |
| 892 | })), | 910 | })), |
| 893 | ) | 911 | ) |
crates/app/src/ui/hitmap.rsmodified+3 -0
| @@ -35,6 +35,9 @@ fn output_path() -> Option<&'static Path> { | |||
| 35 | LazyLock::new(|| std::env::var_os("EDITH_HITMAP").map(PathBuf::from)); | 35 | LazyLock::new(|| std::env::var_os("EDITH_HITMAP").map(PathBuf::from)); |
| 36 | PATH.as_deref() | 36 | PATH.as_deref() |
| 37 | } | 37 | } |
| 38 | +pub(crate) fn enabled() -> bool { | ||
| 39 | + output_path().is_some() | ||
| 40 | +} | ||
| 38 | 41 | ||
| 39 | /// Clears the current-frame controls before descendants record their laid-out | 42 | /// Clears the current-frame controls before descendants record their laid-out |
| 40 | /// bounds, then writes the completed frame after all descendants prepaint. | 43 | /// bounds, then writes the completed frame after all descendants prepaint. |