Animate Zeta button while generating completions (#22899)

Release Notes:

- N/A

Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
Antonio Scandurra 2025-01-09 16:24:35 +01:00 committed by GitHub
parent 7d905d0791
commit e64a56ffad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 106 additions and 29 deletions

View file

@ -22,6 +22,7 @@ pub struct IconButton {
icon_size: IconSize,
icon_color: Color,
selected_icon: Option<IconName>,
alpha: Option<f32>,
}
impl IconButton {
@ -33,6 +34,7 @@ impl IconButton {
icon_size: IconSize::default(),
icon_color: Color::Default,
selected_icon: None,
alpha: None,
};
this.base.base = this.base.base.debug_selector(|| format!("ICON-{:?}", icon));
this
@ -53,6 +55,11 @@ impl IconButton {
self
}
pub fn alpha(mut self, alpha: f32) -> Self {
self.alpha = Some(alpha);
self
}
pub fn selected_icon(mut self, icon: impl Into<Option<IconName>>) -> Self {
self.selected_icon = icon.into();
self
@ -146,6 +153,7 @@ impl RenderOnce for IconButton {
let is_selected = self.base.selected;
let selected_style = self.base.selected_style;
let color = self.icon_color.color(cx).opacity(self.alpha.unwrap_or(1.0));
self.base
.map(|this| match self.shape {
IconButtonShape::Square => {
@ -161,7 +169,7 @@ impl RenderOnce for IconButton {
.selected_icon(self.selected_icon)
.when_some(selected_style, |this, style| this.selected_style(style))
.size(self.icon_size)
.color(self.icon_color),
.color(Color::Custom(color)),
)
}
}

View file

@ -15,6 +15,28 @@ pub trait PopoverTrigger: IntoElement + Clickable + Toggleable + 'static {}
impl<T: IntoElement + Clickable + Toggleable + 'static> PopoverTrigger for T {}
impl<T: Clickable> Clickable for gpui::AnimationElement<T>
where
T: Clickable + 'static,
{
fn on_click(self, handler: impl Fn(&gpui::ClickEvent, &mut WindowContext) + 'static) -> Self {
self.map_element(|e| e.on_click(handler))
}
fn cursor_style(self, cursor_style: gpui::CursorStyle) -> Self {
self.map_element(|e| e.cursor_style(cursor_style))
}
}
impl<T: Toggleable> Toggleable for gpui::AnimationElement<T>
where
T: Toggleable + 'static,
{
fn toggle_state(self, selected: bool) -> Self {
self.map_element(|e| e.toggle_state(selected))
}
}
pub struct PopoverMenuHandle<M>(Rc<RefCell<Option<PopoverMenuHandleState<M>>>>);
impl<M> Clone for PopoverMenuHandle<M> {