feat(ui-gpui): custom Element with direct paint_quad() for zero-overhead pulse
This commit is contained in:
parent
713b53ba0c
commit
3383334821
2 changed files with 90 additions and 68 deletions
|
|
@ -10,7 +10,7 @@ use gpui::*;
|
|||
|
||||
use crate::state::{AgentStatus, Project, ProjectTab};
|
||||
use crate::theme;
|
||||
use crate::components::pulsing_dot::{PulsingDot, DotStatus};
|
||||
use crate::components::pulsing_dot::{PulsingDotElement, DotStatus};
|
||||
|
||||
// ── Accent Colors by Index ──────────────────────────────────────────
|
||||
|
||||
|
|
@ -72,8 +72,7 @@ pub struct ProjectBox {
|
|||
pub agent_pane: Option<Entity<crate::components::agent_pane::AgentPane>>,
|
||||
/// Entity handle for the embedded terminal (Model tab)
|
||||
pub terminal_view: Option<Entity<crate::terminal::renderer::TerminalView>>,
|
||||
/// Animated status dot
|
||||
pub status_dot: Option<Entity<PulsingDot>>,
|
||||
_status_dot_placeholder: (), // PulsingDotElement is created inline during render
|
||||
}
|
||||
|
||||
impl ProjectBox {
|
||||
|
|
@ -82,27 +81,13 @@ impl ProjectBox {
|
|||
project,
|
||||
agent_pane: None,
|
||||
terminal_view: None,
|
||||
status_dot: None,
|
||||
_status_dot_placeholder: (),
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize sub-views. Must be called after the ProjectBox entity is created.
|
||||
pub fn init_subviews(&mut self, cx: &mut Context<Self>) {
|
||||
eprintln!("[ProjectBox] init_subviews for {}", self.project.name);
|
||||
// Create pulsing status dot
|
||||
let dot_status = match self.project.agent.status {
|
||||
AgentStatus::Running => DotStatus::Running,
|
||||
AgentStatus::Idle => DotStatus::Idle,
|
||||
AgentStatus::Done => DotStatus::Done,
|
||||
AgentStatus::Error => DotStatus::Error,
|
||||
};
|
||||
let status_dot = cx.new(|cx: &mut Context<PulsingDot>| {
|
||||
let dot = PulsingDot::new(dot_status, 8.0);
|
||||
dot.start_throttled_animation(cx);
|
||||
dot
|
||||
});
|
||||
self.status_dot = Some(status_dot);
|
||||
|
||||
// Create agent pane with demo messages
|
||||
let agent_pane = cx.new(|_cx| {
|
||||
crate::components::agent_pane::AgentPane::with_demo_messages()
|
||||
|
|
@ -253,8 +238,16 @@ impl Render for ProjectBox {
|
|||
.rounded(px(2.0))
|
||||
.bg(accent),
|
||||
)
|
||||
// Animated status dot
|
||||
.children(self.status_dot.clone())
|
||||
// Animated status dot — custom Element, paints directly to GPU
|
||||
.child({
|
||||
let dot_status = match status {
|
||||
AgentStatus::Running => DotStatus::Running,
|
||||
AgentStatus::Idle => DotStatus::Idle,
|
||||
AgentStatus::Done => DotStatus::Done,
|
||||
AgentStatus::Error => DotStatus::Error,
|
||||
};
|
||||
PulsingDotElement::new(dot_status, 8.0)
|
||||
})
|
||||
// Project name
|
||||
.child(
|
||||
div()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue