Animate Zeta button while generating completions (#22899)
Release Notes: - N/A Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
parent
7d905d0791
commit
e64a56ffad
10 changed files with 106 additions and 29 deletions
|
@ -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)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue