voelin-gpui: a disabled icon button keeps its tooltip
The Slint IconButton shows its tooltip while disabled too, which is how the voice page's stage button says why it is off in a window too short for the larger stage. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d2267e55e7
commit
373805984c
1 file changed
+7
-6
@@ -232,7 +232,7 @@ type Handler = Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>;
|
||||
|
||||
/// A button that is an icon: 36 pixels (or `size`) square, round or with
|
||||
/// rounded corners, with a tooltip. Without a handler or disabled it draws
|
||||
/// dimmed and does nothing.
|
||||
/// dimmed and does nothing, and keeps its tooltip.
|
||||
#[derive(IntoElement)]
|
||||
pub struct IconButton {
|
||||
id: ElementId,
|
||||
@@ -354,14 +354,15 @@ impl RenderOnce for IconButton {
|
||||
if self.filled {
|
||||
button = button.border_1().border_color(hsla(ink));
|
||||
}
|
||||
// The tooltip is there while the button is off too: it says why (the voice
|
||||
// page's stage button in a window too short for the larger stage).
|
||||
button = button.tooltip(move |window, cx| {
|
||||
gpui_kit::component::tooltip::Tooltip::new(label.clone()).build(window, cx)
|
||||
});
|
||||
if !self.enabled {
|
||||
return button.opacity(0.4).into_any_element();
|
||||
}
|
||||
button = button.cursor_pointer().hover(move |style| style.bg(hsla(hover))).tooltip(
|
||||
move |window, cx| {
|
||||
gpui_kit::component::tooltip::Tooltip::new(label.clone()).build(window, cx)
|
||||
},
|
||||
);
|
||||
button = button.cursor_pointer().hover(move |style| style.bg(hsla(hover)));
|
||||
match self.on_click {
|
||||
Some(handler) => button.on_click(move |event, window, cx| handler(event, window, cx)),
|
||||
None => button,
|
||||
|
||||
Reference in new issue
Block a user