use gpui_kit::base::dock::{Panel as BasePanel, PanelEvent};
use gpui_kit::component::dock::Panel;
use gpui_kit::{div, App, Context, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement as _, IntoElement, ParentElement as _, Render, Styled as _, WeakEntity, Window};
use crate::screens::explore::explore_screen::ExploreView;
use crate::screens::pipeline::PipelineView;
pub struct PipelinePanel {
pipeline: Entity<PipelineView>,
explore: WeakEntity<ExploreView>,
focus: FocusHandle,
}
impl PipelinePanel {
pub fn new(pipeline: Entity<PipelineView>, explore: WeakEntity<ExploreView>, cx: &mut Context<Self>) -> Self {
Self { pipeline, explore, focus: cx.focus_handle() }
}
}
impl Render for PipelinePanel {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
div().size_full().bg(crate::ui::theme::color::panel()).track_focus(&self.focus).child(self.pipeline.clone())
}
}
impl EventEmitter<PanelEvent> for PipelinePanel {}
impl Focusable for PipelinePanel {
fn focus_handle(&self, _: &App) -> FocusHandle {
self.focus.clone()
}
}
impl BasePanel for PipelinePanel {
fn panel_name(&self) -> &'static str {
"dspk-app.pipeline"
}
fn on_removed(&mut self, _: &mut Window, cx: &mut Context<Self>) {
let ex = self.explore.clone();
cx.defer(move |cx| {
if let Some(ex) = ex.upgrade() {
ex.update(cx, |e, cx| e.pipeline_closed(cx));
}
});
}
}
impl Panel for PipelinePanel {
fn title(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
"Pipeline"
}
}