mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-24 09:57:08 -06:00
* fix(ui): make clickable tab and radio labels non-selectable with pointing hand cursor (#3972) * test(ui): verify New Document preset tabs show pointing hand cursor instead of text caret (#3972)
This commit is contained in:
@@ -390,7 +390,9 @@ fn radio(ui: &mut egui::Ui, on: bool, label: &str) -> egui::Response {
|
||||
if on {
|
||||
ui.painter().circle_filled(r.center(), 3.0, t.accent);
|
||||
}
|
||||
let l = ui.add(egui::Label::new(egui::RichText::new(tl!(&label)).color(t.text_dim)).sense(Sense::click()));
|
||||
let l = ui
|
||||
.add(egui::Label::new(egui::RichText::new(tl!(&label)).color(t.text_dim)).selectable(false).sense(Sense::click()))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
resp.union(l)
|
||||
})
|
||||
.inner
|
||||
|
||||
@@ -609,7 +609,8 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
let r = ui.horizontal(|ui| {
|
||||
let (ir, _) = ui.allocate_exact_size(vec2(16.0, 16.0), Sense::hover());
|
||||
crate::icons::paint(ui, ir, icon, 14.0, t.icon);
|
||||
ui.add(egui::Label::new(egui::RichText::new(tl!(*cat)).color(t.text)).sense(Sense::click()))
|
||||
ui.add(egui::Label::new(egui::RichText::new(tl!(*cat)).color(t.text)).selectable(false).sense(Sense::click()))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand)
|
||||
});
|
||||
if r.inner.clicked() {
|
||||
d.open[ci] = !d.open[ci];
|
||||
|
||||
@@ -450,7 +450,9 @@ pub fn body(app: &mut crate::PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<Strin
|
||||
for name in CATEGORIES.iter().map(|c| c.0).chain(["Saved"]) {
|
||||
let on = cat == name;
|
||||
let label = if name == "Saved" { tl!("Saved") } else { tl!(name) };
|
||||
let r = ui.add(egui::Label::new(RichText::new(label).size(13.0).color(if on { t.text } else { t.text_dim })).sense(Sense::click()));
|
||||
let r = ui
|
||||
.add(egui::Label::new(RichText::new(label).size(13.0).color(if on { t.text } else { t.text_dim })).selectable(false).sense(Sense::click()))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
if on {
|
||||
ui.painter().line_segment([r.rect.left_bottom() + vec2(0.0, 3.0), r.rect.right_bottom() + vec2(0.0, 3.0)], Stroke::new(2.0, t.text));
|
||||
}
|
||||
@@ -1317,5 +1319,20 @@ mod tests {
|
||||
enter(&mut h);
|
||||
assert_eq!(created(&h), (256, 512, 72.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hovering_preset_tabs_shows_pointing_hand_not_text_cursor() {
|
||||
let mut h = harness();
|
||||
for tab in ["Recent", "Saved", "Photo", "Print", "Art & Illustration", "Web", "Mobile", "Film & Video"] {
|
||||
let rect = h.get_by_label(tab).rect();
|
||||
h.hover_at(rect.center());
|
||||
h.run_steps(2);
|
||||
assert_eq!(
|
||||
h.output().platform_output.cursor_icon,
|
||||
egui::CursorIcon::PointingHand,
|
||||
"hovering preset tab {tab:?} must show PointingHand instead of text caret"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user