mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-09 10:56:20 +00:00
Render status bar
Co-Authored-By: Antonio <me@as-cii.com>
This commit is contained in:
parent
803d2b6710
commit
8f0f5a9ba1
3 changed files with 53 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::{status_bar::StatusItemView, Axis, Workspace};
|
||||
use gpui2::{
|
||||
Action, AnyView, AppContext, Div, Entity, EntityId, EventEmitter, Render, Subscription, View,
|
||||
ViewContext, WeakView, WindowContext,
|
||||
div, Action, AnyView, AppContext, Div, Entity, EntityId, EventEmitter, ParentElement, Render,
|
||||
Subscription, View, ViewContext, WeakView, WindowContext,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -605,8 +605,13 @@ impl EventEmitter for PanelButtons {
|
|||
impl Render for PanelButtons {
|
||||
type Element = Div<Self>;
|
||||
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
todo!()
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
let dock = self.dock.read(cx);
|
||||
div().children(
|
||||
dock.panel_entries
|
||||
.iter()
|
||||
.map(|panel| panel.panel.persistent_name(cx)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
use std::any::TypeId;
|
||||
|
||||
use crate::{ItemHandle, Pane};
|
||||
use gpui2::{AnyView, Render, Subscription, View, ViewContext, WindowContext};
|
||||
use gpui2::{
|
||||
div, AnyView, Component, Div, Element, ParentElement, Render, Styled, Subscription, View,
|
||||
ViewContext, WindowContext,
|
||||
};
|
||||
use theme2::ActiveTheme;
|
||||
use util::ResultExt;
|
||||
|
||||
pub trait StatusItemView: Render {
|
||||
|
@ -29,6 +33,41 @@ pub struct StatusBar {
|
|||
_observe_active_pane: Subscription,
|
||||
}
|
||||
|
||||
impl Render for StatusBar {
|
||||
type Element = Div<Self>;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
div()
|
||||
.py_0p5()
|
||||
.px_1()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_between()
|
||||
.w_full()
|
||||
.bg(cx.theme().colors().status_bar)
|
||||
.child(self.render_left_tools(cx))
|
||||
.child(self.render_right_tools(cx))
|
||||
}
|
||||
}
|
||||
|
||||
impl StatusBar {
|
||||
fn render_left_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_1()
|
||||
.children(self.left_items.iter().map(|item| item.to_any()))
|
||||
}
|
||||
|
||||
fn render_right_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.children(self.right_items.iter().map(|item| item.to_any()))
|
||||
}
|
||||
}
|
||||
|
||||
// todo!()
|
||||
// impl View for StatusBar {
|
||||
// fn ui_name() -> &'static str {
|
||||
|
|
|
@ -555,7 +555,7 @@ pub struct Workspace {
|
|||
active_pane: View<Pane>,
|
||||
last_active_center_pane: Option<WeakView<Pane>>,
|
||||
last_active_view_id: Option<proto::ViewId>,
|
||||
// status_bar: View<StatusBar>,
|
||||
status_bar: View<StatusBar>,
|
||||
// titlebar_item: Option<AnyViewHandle>,
|
||||
notifications: Vec<(TypeId, usize, Box<dyn NotificationHandle>)>,
|
||||
project: Model<Project>,
|
||||
|
@ -704,7 +704,7 @@ impl Workspace {
|
|||
cx.build_view(|cx| PanelButtons::new(bottom_dock.clone(), weak_handle.clone(), cx));
|
||||
let right_dock_buttons =
|
||||
cx.build_view(|cx| PanelButtons::new(right_dock.clone(), weak_handle.clone(), cx));
|
||||
let _status_bar = cx.build_view(|cx| {
|
||||
let status_bar = cx.build_view(|cx| {
|
||||
let mut status_bar = StatusBar::new(¢er_pane.clone(), cx);
|
||||
status_bar.add_left_item(left_dock_buttons, cx);
|
||||
status_bar.add_right_item(right_dock_buttons, cx);
|
||||
|
@ -771,7 +771,7 @@ impl Workspace {
|
|||
active_pane: center_pane.clone(),
|
||||
last_active_center_pane: Some(center_pane.downgrade()),
|
||||
last_active_view_id: None,
|
||||
// status_bar,
|
||||
status_bar,
|
||||
// titlebar_item: None,
|
||||
notifications: Default::default(),
|
||||
left_dock,
|
||||
|
@ -3856,7 +3856,7 @@ impl Render for Workspace {
|
|||
// .filter(|_| self.is_assistant_panel_open()),
|
||||
// ),
|
||||
)
|
||||
// .child(StatusBar::new())
|
||||
.child(self.status_bar.clone())
|
||||
// .when(self.debug.show_toast, |this| {
|
||||
// this.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast")))
|
||||
// })
|
||||
|
|
Loading…
Reference in a new issue