agent: Show delete thread icon buttons on hover/focus (#30370)
This PR's main goal is to show the delete thread button when the list item is either focused or hovered. In order to do that, we ended up refactoring (i.e., merging) the `PastThread` and `PastContext` elements into a single `HistoryElementEntry` that already matches to the entry type (i.e., context or thread). Release Notes: - agent: Simplify the UI by showing the delete thread icon button only on hover or focus. --------- Co-authored-by: Agus Zubiaga <hi@aguz.me>
This commit is contained in:
co-authored by
Agus Zubiaga
parent
49c01c60b7
commit
00292450e0
@@ -33,6 +33,7 @@ pub struct ListItem {
|
||||
toggle: Option<bool>,
|
||||
inset: bool,
|
||||
on_click: Option<Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>>,
|
||||
on_hover: Option<Box<dyn Fn(&bool, &mut Window, &mut App) + 'static>>,
|
||||
on_toggle: Option<Arc<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>>,
|
||||
tooltip: Option<Box<dyn Fn(&mut Window, &mut App) -> AnyView + 'static>>,
|
||||
on_secondary_mouse_down: Option<Box<dyn Fn(&MouseDownEvent, &mut Window, &mut App) + 'static>>,
|
||||
@@ -63,6 +64,7 @@ impl ListItem {
|
||||
on_click: None,
|
||||
on_secondary_mouse_down: None,
|
||||
on_toggle: None,
|
||||
on_hover: None,
|
||||
tooltip: None,
|
||||
children: SmallVec::new(),
|
||||
selectable: true,
|
||||
@@ -102,6 +104,11 @@ impl ListItem {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn on_hover(mut self, handler: impl Fn(&bool, &mut Window, &mut App) + 'static) -> Self {
|
||||
self.on_hover = Some(Box::new(handler));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn on_secondary_mouse_down(
|
||||
mut self,
|
||||
handler: impl Fn(&MouseDownEvent, &mut Window, &mut App) + 'static,
|
||||
@@ -233,6 +240,7 @@ impl RenderOnce for ListItem {
|
||||
})
|
||||
})
|
||||
.when(self.rounded, |this| this.rounded_sm())
|
||||
.when_some(self.on_hover, |this, on_hover| this.on_hover(on_hover))
|
||||
.child(
|
||||
h_flex()
|
||||
.id("inner_list_item")
|
||||
|
||||
Reference in New Issue
Block a user