Checkpoint
This commit is contained in:
parent
8ad7ebf02f
commit
a3dcaf21cb
20 changed files with 183 additions and 152 deletions
|
@ -25,7 +25,8 @@ impl KitchenSinkStory {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.overflow_y_scroll(ScrollState::default())
|
.id("kitchen-sink")
|
||||||
|
.overflow_y_scroll()
|
||||||
.child(Story::title(cx, "Kitchen Sink"))
|
.child(Story::title(cx, "Kitchen Sink"))
|
||||||
.child(Story::label(cx, "Elements"))
|
.child(Story::label(cx, "Elements"))
|
||||||
.child(div().flex().flex_col().children(element_stories))
|
.child(div().flex().flex_col().children(element_stories))
|
||||||
|
|
|
@ -7,16 +7,16 @@ use crate::{Icon, IconButton, Label, Panel, PanelSide};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct AssistantPanel<S: 'static + Send + Sync + Clone> {
|
pub struct AssistantPanel<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
current_side: PanelSide,
|
current_side: PanelSide,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> AssistantPanel<S> {
|
impl<S: 'static + Send + Sync + Clone> AssistantPanel<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state: ScrollState::default(),
|
|
||||||
current_side: PanelSide::default(),
|
current_side: PanelSide::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ impl<S: 'static + Send + Sync + Clone> AssistantPanel<S> {
|
||||||
fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||||
let color = ThemeColor::new(cx);
|
let color = ThemeColor::new(cx);
|
||||||
|
|
||||||
Panel::new(cx)
|
Panel::new(self.id.clone(), cx)
|
||||||
.children(vec![div()
|
.children(vec![div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
|
@ -63,11 +63,12 @@ impl<S: 'static + Send + Sync + Clone> AssistantPanel<S> {
|
||||||
// Chat Body
|
// Chat Body
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
|
.id("chat-body")
|
||||||
.w_full()
|
.w_full()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.gap_3()
|
.gap_3()
|
||||||
.overflow_y_scroll(self.scroll_state.clone())
|
.overflow_y_scroll()
|
||||||
.child(Label::new("Is this thing on?")),
|
.child(Label::new("Is this thing on?")),
|
||||||
)
|
)
|
||||||
.into_any()])
|
.into_any()])
|
||||||
|
@ -105,7 +106,7 @@ mod stories {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, AssistantPanel<S>>(cx))
|
.child(Story::title_for::<_, AssistantPanel<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(AssistantPanel::new())
|
.child(AssistantPanel::new("assistant-panel"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,8 @@ impl BufferRow {
|
||||||
|
|
||||||
#[derive(Element, Clone)]
|
#[derive(Element, Clone)]
|
||||||
pub struct Buffer<S: 'static + Send + Sync + Clone> {
|
pub struct Buffer<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
rows: Option<BufferRows>,
|
rows: Option<BufferRows>,
|
||||||
readonly: bool,
|
readonly: bool,
|
||||||
language: Option<String>,
|
language: Option<String>,
|
||||||
|
@ -121,10 +121,10 @@ pub struct Buffer<S: 'static + Send + Sync + Clone> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state: ScrollState::default(),
|
|
||||||
rows: Some(BufferRows::default()),
|
rows: Some(BufferRows::default()),
|
||||||
readonly: false,
|
readonly: false,
|
||||||
language: None,
|
language: None,
|
||||||
|
@ -133,10 +133,6 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind_scroll_state(&mut self, scroll_state: ScrollState) {
|
|
||||||
self.scroll_state = scroll_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_title<T: Into<Option<String>>>(mut self, title: T) -> Self {
|
pub fn set_title<T: Into<Option<String>>>(mut self, title: T) -> Self {
|
||||||
self.title = title.into();
|
self.title = title.into();
|
||||||
self
|
self
|
||||||
|
|
|
@ -7,14 +7,14 @@ use crate::{Icon, IconButton, Input, Label, LabelColor};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct ChatPanel<S: 'static + Send + Sync + Clone> {
|
pub struct ChatPanel<S: 'static + Send + Sync + Clone> {
|
||||||
scroll_state: ScrollState,
|
element_id: ElementId,
|
||||||
messages: Vec<ChatMessage<S>>,
|
messages: Vec<ChatMessage<S>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> ChatPanel<S> {
|
impl<S: 'static + Send + Sync + Clone> ChatPanel<S> {
|
||||||
pub fn new(scroll_state: ScrollState) -> Self {
|
pub fn new(element_id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
scroll_state,
|
element_id: element_id.into(),
|
||||||
messages: Vec::new(),
|
messages: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ impl<S: 'static + Send + Sync + Clone> ChatPanel<S> {
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||||
div()
|
div()
|
||||||
|
.id(self.element_id.clone())
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.justify_between()
|
.justify_between()
|
||||||
|
@ -55,11 +56,12 @@ impl<S: 'static + Send + Sync + Clone> ChatPanel<S> {
|
||||||
// Chat Body
|
// Chat Body
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
|
.id("chat-body")
|
||||||
.w_full()
|
.w_full()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.gap_3()
|
.gap_3()
|
||||||
.overflow_y_scroll(self.scroll_state.clone())
|
.overflow_y_scroll()
|
||||||
.children(self.messages.clone()),
|
.children(self.messages.clone()),
|
||||||
)
|
)
|
||||||
// Composer
|
// Composer
|
||||||
|
@ -135,10 +137,13 @@ mod stories {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ChatPanel<S>>(cx))
|
.child(Story::title_for::<_, ChatPanel<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Panel::new(cx).child(ChatPanel::new(ScrollState::default())))
|
|
||||||
.child(Story::label(cx, "With Mesages"))
|
|
||||||
.child(
|
.child(
|
||||||
Panel::new(cx).child(ChatPanel::new(ScrollState::default()).messages(vec![
|
Panel::new("chat-panel-1-outer", cx)
|
||||||
|
.child(ChatPanel::new("chat-panel-1-inner")),
|
||||||
|
)
|
||||||
|
.child(Story::label(cx, "With Mesages"))
|
||||||
|
.child(Panel::new("chat-panel-2-outer", cx).child(
|
||||||
|
ChatPanel::new("chat-panel-2-inner").messages(vec![
|
||||||
ChatMessage::new(
|
ChatMessage::new(
|
||||||
"osiewicz".to_string(),
|
"osiewicz".to_string(),
|
||||||
"is this thing on?".to_string(),
|
"is this thing on?".to_string(),
|
||||||
|
@ -153,8 +158,8 @@ mod stories {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.naive_local(),
|
.naive_local(),
|
||||||
),
|
),
|
||||||
])),
|
]),
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,15 +8,15 @@ use std::marker::PhantomData;
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct CollabPanel<S: 'static + Send + Sync + Clone> {
|
pub struct CollabPanel<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> CollabPanel<S> {
|
impl<S: 'static + Send + Sync + Clone> CollabPanel<S> {
|
||||||
pub fn new(scroll_state: ScrollState) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +25,14 @@ impl<S: 'static + Send + Sync + Clone> CollabPanel<S> {
|
||||||
let color = ThemeColor::new(cx);
|
let color = ThemeColor::new(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
.id(self.id.clone())
|
||||||
.h_full()
|
.h_full()
|
||||||
.bg(color.surface)
|
.bg(color.surface)
|
||||||
.child(
|
.child(
|
||||||
v_stack()
|
v_stack()
|
||||||
|
.id("crdb")
|
||||||
.w_full()
|
.w_full()
|
||||||
.overflow_y_scroll(self.scroll_state.clone())
|
.overflow_y_scroll()
|
||||||
.child(
|
.child(
|
||||||
div().pb_1().border_color(color.border).border_b().child(
|
div().pb_1().border_color(color.border).border_b().child(
|
||||||
List::new(static_collab_panel_current_call())
|
List::new(static_collab_panel_current_call())
|
||||||
|
@ -43,7 +45,7 @@ impl<S: 'static + Send + Sync + Clone> CollabPanel<S> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_stack().py_1().child(
|
v_stack().id("channels").py_1().child(
|
||||||
List::new(static_collab_panel_channels())
|
List::new(static_collab_panel_channels())
|
||||||
.header(
|
.header(
|
||||||
ListHeader::new("CHANNELS").set_toggle(ToggleState::Toggled),
|
ListHeader::new("CHANNELS").set_toggle(ToggleState::Toggled),
|
||||||
|
@ -53,7 +55,7 @@ impl<S: 'static + Send + Sync + Clone> CollabPanel<S> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_stack().py_1().child(
|
v_stack().id("contacts-online").py_1().child(
|
||||||
List::new(static_collab_panel_current_call())
|
List::new(static_collab_panel_current_call())
|
||||||
.header(
|
.header(
|
||||||
ListHeader::new("CONTACTS – ONLINE")
|
ListHeader::new("CONTACTS – ONLINE")
|
||||||
|
@ -63,7 +65,7 @@ impl<S: 'static + Send + Sync + Clone> CollabPanel<S> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_stack().py_1().child(
|
v_stack().id("contacts-offline").py_1().child(
|
||||||
List::new(static_collab_panel_current_call())
|
List::new(static_collab_panel_current_call())
|
||||||
.header(
|
.header(
|
||||||
ListHeader::new("CONTACTS – OFFLINE")
|
ListHeader::new("CONTACTS – OFFLINE")
|
||||||
|
@ -182,7 +184,7 @@ mod stories {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, CollabPanel<S>>(cx))
|
.child(Story::title_for::<_, CollabPanel<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(CollabPanel::new(ScrollState::default()))
|
.child(CollabPanel::new("collab-panel"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,21 +5,21 @@ use crate::{example_editor_actions, OrderMethod, Palette};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct CommandPalette<S: 'static + Send + Sync + Clone> {
|
pub struct CommandPalette<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> CommandPalette<S> {
|
impl<S: 'static + Send + Sync + Clone> CommandPalette<S> {
|
||||||
pub fn new(scroll_state: ScrollState) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||||
div().child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new(self.scroll_state.clone())
|
Palette::new("palette")
|
||||||
.items(example_editor_actions())
|
.items(example_editor_actions())
|
||||||
.placeholder("Execute a command...")
|
.placeholder("Execute a command...")
|
||||||
.empty_string("No items found.")
|
.empty_string("No items found.")
|
||||||
|
@ -49,11 +49,15 @@ mod stories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(
|
||||||
|
&mut self,
|
||||||
|
_view: &mut S,
|
||||||
|
cx: &mut ViewContext<S>,
|
||||||
|
) -> impl Element<ViewState = S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, CommandPalette<S>>(cx))
|
.child(Story::title_for::<_, CommandPalette<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(CommandPalette::new(ScrollState::default()))
|
.child(CommandPalette::new("command-palette"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl EditorPane {
|
||||||
.w_full()
|
.w_full()
|
||||||
.h_full()
|
.h_full()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
.child(TabBar::new(self.tabs.clone()).can_navigate((false, true)))
|
.child(TabBar::new("editor-pane-tabs", self.tabs.clone()).can_navigate((false, true)))
|
||||||
.child(
|
.child(
|
||||||
Toolbar::new()
|
Toolbar::new()
|
||||||
.left_item(Breadcrumb::new(self.path.clone(), self.symbols.clone()))
|
.left_item(Breadcrumb::new(self.path.clone(), self.symbols.clone()))
|
||||||
|
|
|
@ -5,21 +5,21 @@ use crate::{OrderMethod, Palette, PaletteItem};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct LanguageSelector<S: 'static + Send + Sync + Clone> {
|
pub struct LanguageSelector<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> LanguageSelector<S> {
|
impl<S: 'static + Send + Sync + Clone> LanguageSelector<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state: ScrollState::default(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||||
div().child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new(self.scroll_state.clone())
|
Palette::new("palette")
|
||||||
.items(vec![
|
.items(vec![
|
||||||
PaletteItem::new("C"),
|
PaletteItem::new("C"),
|
||||||
PaletteItem::new("C++"),
|
PaletteItem::new("C++"),
|
||||||
|
@ -60,11 +60,15 @@ mod stories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(
|
||||||
|
&mut self,
|
||||||
|
_view: &mut S,
|
||||||
|
cx: &mut ViewContext<S>,
|
||||||
|
) -> impl Element<ViewState = S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, LanguageSelector<S>>(cx))
|
.child(Story::title_for::<_, LanguageSelector<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(LanguageSelector::new())
|
.child(LanguageSelector::new("language-selector"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@ use crate::{List, ListHeader};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct NotificationsPanel<S: 'static + Send + Sync + Clone> {
|
pub struct NotificationsPanel<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> NotificationsPanel<S> {
|
impl<S: 'static + Send + Sync + Clone> NotificationsPanel<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +21,7 @@ impl<S: 'static + Send + Sync + Clone> NotificationsPanel<S> {
|
||||||
let color = ThemeColor::new(cx);
|
let color = ThemeColor::new(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
.id(self.id.clone())
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.w_full()
|
.w_full()
|
||||||
|
@ -26,10 +29,11 @@ impl<S: 'static + Send + Sync + Clone> NotificationsPanel<S> {
|
||||||
.bg(color.surface)
|
.bg(color.surface)
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
|
.id("header")
|
||||||
.w_full()
|
.w_full()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.overflow_y_scroll(ScrollState::default())
|
.overflow_y_scroll()
|
||||||
.child(
|
.child(
|
||||||
List::new(static_new_notification_items())
|
List::new(static_new_notification_items())
|
||||||
.header(ListHeader::new("NEW").set_toggle(ToggleState::Toggled))
|
.header(ListHeader::new("NEW").set_toggle(ToggleState::Toggled))
|
||||||
|
@ -74,7 +78,9 @@ mod stories {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, NotificationsPanel<S>>(cx))
|
.child(Story::title_for::<_, NotificationsPanel<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Panel::new(cx).child(NotificationsPanel::new()))
|
.child(
|
||||||
|
Panel::new("panel", cx).child(NotificationsPanel::new("notifications_panel")),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ use crate::{h_stack, v_stack, Keybinding, Label, LabelColor};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct Palette<S: 'static + Send + Sync + Clone> {
|
pub struct Palette<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
input_placeholder: SharedString,
|
input_placeholder: SharedString,
|
||||||
empty_string: SharedString,
|
empty_string: SharedString,
|
||||||
items: Vec<PaletteItem<S>>,
|
items: Vec<PaletteItem<S>>,
|
||||||
|
@ -14,10 +14,10 @@ pub struct Palette<S: 'static + Send + Sync + Clone> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> Palette<S> {
|
impl<S: 'static + Send + Sync + Clone> Palette<S> {
|
||||||
pub fn new(scroll_state: ScrollState) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state,
|
|
||||||
input_placeholder: "Find something...".into(),
|
input_placeholder: "Find something...".into(),
|
||||||
empty_string: "No items found.".into(),
|
empty_string: "No items found.".into(),
|
||||||
items: vec![],
|
items: vec![],
|
||||||
|
@ -50,6 +50,7 @@ impl<S: 'static + Send + Sync + Clone> Palette<S> {
|
||||||
let color = ThemeColor::new(cx);
|
let color = ThemeColor::new(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
.id(self.id.clone())
|
||||||
.w_96()
|
.w_96()
|
||||||
.rounded_lg()
|
.rounded_lg()
|
||||||
.bg(color.elevated_surface)
|
.bg(color.elevated_surface)
|
||||||
|
@ -64,11 +65,12 @@ impl<S: 'static + Send + Sync + Clone> Palette<S> {
|
||||||
.child(div().h_px().w_full().bg(color.filled_element))
|
.child(div().h_px().w_full().bg(color.filled_element))
|
||||||
.child(
|
.child(
|
||||||
v_stack()
|
v_stack()
|
||||||
|
.id("items")
|
||||||
.py_0p5()
|
.py_0p5()
|
||||||
.px_1()
|
.px_1()
|
||||||
.grow()
|
.grow()
|
||||||
.max_h_96()
|
.max_h_96()
|
||||||
.overflow_y_scroll(self.scroll_state.clone())
|
.overflow_y_scroll()
|
||||||
.children(
|
.children(
|
||||||
vec![if self.items.is_empty() {
|
vec![if self.items.is_empty() {
|
||||||
Some(
|
Some(
|
||||||
|
@ -150,6 +152,7 @@ impl<S: 'static + Send + Sync + Clone> PaletteItem<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use gpui3::ElementId;
|
||||||
#[cfg(feature = "stories")]
|
#[cfg(feature = "stories")]
|
||||||
pub use stories::*;
|
pub use stories::*;
|
||||||
|
|
||||||
|
@ -179,10 +182,10 @@ mod stories {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Palette<S>>(cx))
|
.child(Story::title_for::<_, Palette<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Palette::new(ScrollState::default()))
|
.child(Palette::new("palette-1"))
|
||||||
.child(Story::label(cx, "With Items"))
|
.child(Story::label(cx, "With Items"))
|
||||||
.child(
|
.child(
|
||||||
Palette::new(ScrollState::default())
|
Palette::new("palette-2")
|
||||||
.placeholder("Execute a command...")
|
.placeholder("Execute a command...")
|
||||||
.items(vec![
|
.items(vec![
|
||||||
PaletteItem::new("theme selector: toggle").keybinding(
|
PaletteItem::new("theme selector: toggle").keybinding(
|
||||||
|
|
|
@ -42,8 +42,8 @@ use std::collections::HashSet;
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct Panel<S: 'static + Send + Sync> {
|
pub struct Panel<S: 'static + Send + Sync> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
current_side: PanelSide,
|
current_side: PanelSide,
|
||||||
/// Defaults to PanelAllowedSides::LeftAndRight
|
/// Defaults to PanelAllowedSides::LeftAndRight
|
||||||
allowed_sides: PanelAllowedSides,
|
allowed_sides: PanelAllowedSides,
|
||||||
|
@ -53,12 +53,12 @@ pub struct Panel<S: 'static + Send + Sync> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Panel<S> {
|
impl<S: 'static + Send + Sync> Panel<S> {
|
||||||
pub fn new(cx: &mut WindowContext) -> Self {
|
pub fn new(id: impl Into<ElementId>, cx: &mut WindowContext) -> Self {
|
||||||
let settings = user_settings(cx);
|
let settings = user_settings(cx);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state: ScrollState::default(),
|
|
||||||
current_side: PanelSide::default(),
|
current_side: PanelSide::default(),
|
||||||
allowed_sides: PanelAllowedSides::default(),
|
allowed_sides: PanelAllowedSides::default(),
|
||||||
initial_width: *settings.default_panel_size,
|
initial_width: *settings.default_panel_size,
|
||||||
|
@ -102,6 +102,7 @@ impl<S: 'static + Send + Sync> Panel<S> {
|
||||||
let current_size = self.width.unwrap_or(self.initial_width);
|
let current_size = self.width.unwrap_or(self.initial_width);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
.id(self.id.clone())
|
||||||
.flex_initial()
|
.flex_initial()
|
||||||
.when(
|
.when(
|
||||||
self.current_side == PanelSide::Left || self.current_side == PanelSide::Right,
|
self.current_side == PanelSide::Left || self.current_side == PanelSide::Right,
|
||||||
|
@ -156,9 +157,10 @@ mod stories {
|
||||||
.child(Story::title_for::<_, Panel<S>>(cx))
|
.child(Story::title_for::<_, Panel<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(
|
.child(
|
||||||
Panel::new(cx).child(
|
Panel::new("panel", cx).child(
|
||||||
div()
|
div()
|
||||||
.overflow_y_scroll(ScrollState::default())
|
.id("panel-contents")
|
||||||
|
.overflow_y_scroll()
|
||||||
.children((0..100).map(|ix| Label::new(format!("Item {}", ix + 1)))),
|
.children((0..100).map(|ix| Label::new(format!("Item {}", ix + 1)))),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use gpui3::{hsla, AnyElement, Hsla, Length, Size};
|
use gpui3::{hsla, AnyElement, ElementId, Hsla, Length, Size};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
@ -14,21 +14,21 @@ pub enum SplitDirection {
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct Pane<S: 'static + Send + Sync> {
|
pub struct Pane<S: 'static + Send + Sync> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
size: Size<Length>,
|
size: Size<Length>,
|
||||||
fill: Hsla,
|
fill: Hsla,
|
||||||
children: SmallVec<[AnyElement<S>; 2]>,
|
children: SmallVec<[AnyElement<S>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Pane<S> {
|
impl<S: 'static + Send + Sync> Pane<S> {
|
||||||
pub fn new(scroll_state: ScrollState, size: Size<Length>) -> Self {
|
pub fn new(id: impl Into<ElementId>, size: Size<Length>) -> Self {
|
||||||
// Fill is only here for debugging purposes, remove before release
|
// Fill is only here for debugging purposes, remove before release
|
||||||
let system_color = SystemColor::new();
|
let system_color = SystemColor::new();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state,
|
|
||||||
size,
|
size,
|
||||||
fill: hsla(0.3, 0.3, 0.3, 1.),
|
fill: hsla(0.3, 0.3, 0.3, 1.),
|
||||||
// fill: system_color.transparent,
|
// fill: system_color.transparent,
|
||||||
|
@ -45,12 +45,13 @@ impl<S: 'static + Send + Sync> Pane<S> {
|
||||||
let color = ThemeColor::new(cx);
|
let color = ThemeColor::new(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
.id(self.id.clone())
|
||||||
.flex()
|
.flex()
|
||||||
.flex_initial()
|
.flex_initial()
|
||||||
.bg(self.fill)
|
.bg(self.fill)
|
||||||
.w(self.size.width)
|
.w(self.size.width)
|
||||||
.h(self.size.height)
|
.h(self.size.height)
|
||||||
.overflow_y_scroll(self.scroll_state.clone())
|
.overflow_y_scroll()
|
||||||
.children(self.children.drain(..))
|
.children(self.children.drain(..))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,15 @@ use crate::{
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct ProjectPanel<S: 'static + Send + Sync + Clone> {
|
pub struct ProjectPanel<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> ProjectPanel<S> {
|
impl<S: 'static + Send + Sync + Clone> ProjectPanel<S> {
|
||||||
pub fn new(scroll_state: ScrollState) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ impl<S: 'static + Send + Sync + Clone> ProjectPanel<S> {
|
||||||
let color = ThemeColor::new(cx);
|
let color = ThemeColor::new(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
.id(self.id.clone())
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.w_full()
|
.w_full()
|
||||||
|
@ -31,10 +32,11 @@ impl<S: 'static + Send + Sync + Clone> ProjectPanel<S> {
|
||||||
.bg(color.surface)
|
.bg(color.surface)
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
|
.id("project-panel-contents")
|
||||||
.w_full()
|
.w_full()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.overflow_y_scroll(ScrollState::default())
|
.overflow_y_scroll()
|
||||||
.child(
|
.child(
|
||||||
List::new(static_project_panel_single_items())
|
List::new(static_project_panel_single_items())
|
||||||
.header(ListHeader::new("FILES").set_toggle(ToggleState::Toggled))
|
.header(ListHeader::new("FILES").set_toggle(ToggleState::Toggled))
|
||||||
|
@ -56,6 +58,7 @@ impl<S: 'static + Send + Sync + Clone> ProjectPanel<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use gpui3::ElementId;
|
||||||
#[cfg(feature = "stories")]
|
#[cfg(feature = "stories")]
|
||||||
pub use stories::*;
|
pub use stories::*;
|
||||||
|
|
||||||
|
@ -86,8 +89,8 @@ mod stories {
|
||||||
.child(Story::title_for::<_, ProjectPanel<S>>(cx))
|
.child(Story::title_for::<_, ProjectPanel<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(
|
.child(
|
||||||
Panel::new(cx)
|
Panel::new("project-panel-outer", cx)
|
||||||
.child(ProjectPanel::new(ScrollState::default())),
|
.child(ProjectPanel::new("project-panel-inner")),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,21 +5,21 @@ use crate::{OrderMethod, Palette, PaletteItem};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct RecentProjects<S: 'static + Send + Sync + Clone> {
|
pub struct RecentProjects<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> RecentProjects<S> {
|
impl<S: 'static + Send + Sync + Clone> RecentProjects<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state: ScrollState::default(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||||
div().child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new(self.scroll_state.clone())
|
Palette::new("palette")
|
||||||
.items(vec![
|
.items(vec![
|
||||||
PaletteItem::new("zed").sublabel(SharedString::from("~/projects/zed")),
|
PaletteItem::new("zed").sublabel(SharedString::from("~/projects/zed")),
|
||||||
PaletteItem::new("saga").sublabel(SharedString::from("~/projects/saga")),
|
PaletteItem::new("saga").sublabel(SharedString::from("~/projects/saga")),
|
||||||
|
@ -64,7 +64,7 @@ mod stories {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, RecentProjects<S>>(cx))
|
.child(Story::title_for::<_, RecentProjects<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(RecentProjects::new())
|
.child(RecentProjects::new("recent-projects"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,27 +5,23 @@ use crate::{Icon, IconButton, Tab};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct TabBar<S: 'static + Send + Sync + Clone> {
|
pub struct TabBar<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
/// Backwards, Forwards
|
/// Backwards, Forwards
|
||||||
can_navigate: (bool, bool),
|
can_navigate: (bool, bool),
|
||||||
tabs: Vec<Tab<S>>,
|
tabs: Vec<Tab<S>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
||||||
pub fn new(tabs: Vec<Tab<S>>) -> Self {
|
pub fn new(id: impl Into<ElementId>, tabs: Vec<Tab<S>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state: ScrollState::default(),
|
|
||||||
can_navigate: (false, false),
|
can_navigate: (false, false),
|
||||||
tabs,
|
tabs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind_scroll_state(&mut self, scroll_state: ScrollState) {
|
|
||||||
self.scroll_state = scroll_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn can_navigate(mut self, can_navigate: (bool, bool)) -> Self {
|
pub fn can_navigate(mut self, can_navigate: (bool, bool)) -> Self {
|
||||||
self.can_navigate = can_navigate;
|
self.can_navigate = can_navigate;
|
||||||
self
|
self
|
||||||
|
@ -37,6 +33,7 @@ impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
||||||
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
.id(self.id.clone())
|
||||||
.w_full()
|
.w_full()
|
||||||
.flex()
|
.flex()
|
||||||
.bg(color.tab_bar)
|
.bg(color.tab_bar)
|
||||||
|
@ -67,8 +64,9 @@ impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
||||||
.child(
|
.child(
|
||||||
div().w_0().flex_1().h_full().child(
|
div().w_0().flex_1().h_full().child(
|
||||||
div()
|
div()
|
||||||
|
.id("tabs")
|
||||||
.flex()
|
.flex()
|
||||||
.overflow_x_scroll(self.scroll_state.clone())
|
.overflow_x_scroll()
|
||||||
.children(self.tabs.clone()),
|
.children(self.tabs.clone()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -92,6 +90,7 @@ impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use gpui3::ElementId;
|
||||||
#[cfg(feature = "stories")]
|
#[cfg(feature = "stories")]
|
||||||
pub use stories::*;
|
pub use stories::*;
|
||||||
|
|
||||||
|
@ -121,7 +120,9 @@ mod stories {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, TabBar<S>>(cx))
|
.child(Story::title_for::<_, TabBar<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(TabBar::new(vec![
|
.child(TabBar::new(
|
||||||
|
"tab-bar",
|
||||||
|
vec![
|
||||||
Tab::new(1)
|
Tab::new(1)
|
||||||
.title("Cargo.toml".to_string())
|
.title("Cargo.toml".to_string())
|
||||||
.current(false)
|
.current(false)
|
||||||
|
@ -151,7 +152,8 @@ mod stories {
|
||||||
Tab::new(9)
|
Tab::new(9)
|
||||||
.title("styleable_helpers.rs".to_string())
|
.title("styleable_helpers.rs".to_string())
|
||||||
.current(false),
|
.current(false),
|
||||||
]))
|
],
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl<S: 'static + Send + Sync + Clone> Terminal<S> {
|
||||||
// Terminal Pane.
|
// Terminal Pane.
|
||||||
.child(
|
.child(
|
||||||
Pane::new(
|
Pane::new(
|
||||||
ScrollState::default(),
|
"terminal",
|
||||||
Size {
|
Size {
|
||||||
width: relative(1.).into(),
|
width: relative(1.).into(),
|
||||||
height: rems(36.).into(),
|
height: rems(36.).into(),
|
||||||
|
|
|
@ -5,21 +5,21 @@ use crate::{OrderMethod, Palette, PaletteItem};
|
||||||
|
|
||||||
#[derive(Element)]
|
#[derive(Element)]
|
||||||
pub struct ThemeSelector<S: 'static + Send + Sync + Clone> {
|
pub struct ThemeSelector<S: 'static + Send + Sync + Clone> {
|
||||||
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
state_type: PhantomData<S>,
|
||||||
scroll_state: ScrollState,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> ThemeSelector<S> {
|
impl<S: 'static + Send + Sync + Clone> ThemeSelector<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
scroll_state: ScrollState::default(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||||
div().child(
|
div().child(
|
||||||
Palette::new(self.scroll_state.clone())
|
Palette::new(self.id.clone())
|
||||||
.items(vec![
|
.items(vec![
|
||||||
PaletteItem::new("One Dark"),
|
PaletteItem::new("One Dark"),
|
||||||
PaletteItem::new("Rosé Pine"),
|
PaletteItem::new("Rosé Pine"),
|
||||||
|
@ -61,11 +61,15 @@ mod stories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(
|
||||||
|
&mut self,
|
||||||
|
_view: &mut S,
|
||||||
|
cx: &mut ViewContext<S>,
|
||||||
|
) -> impl Element<ViewState = S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ThemeSelector<S>>(cx))
|
.child(Story::title_for::<_, ThemeSelector<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(ThemeSelector::new())
|
.child(ThemeSelector::new("theme-selector"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use gpui3::{px, relative, rems, view, Context, Size, View};
|
use gpui3::{px, relative, rems, view, Context, Size, View};
|
||||||
|
|
||||||
use crate::{prelude::*, NotificationToast, NotificationsPanel};
|
use crate::{prelude::*, NotificationsPanel};
|
||||||
use crate::{
|
use crate::{
|
||||||
static_livestream, theme, user_settings_mut, v_stack, AssistantPanel, Button, ChatMessage,
|
static_livestream, theme, user_settings_mut, v_stack, AssistantPanel, Button, ChatMessage,
|
||||||
ChatPanel, CollabPanel, EditorPane, FakeSettings, Label, LanguageSelector, Pane, PaneGroup,
|
ChatPanel, CollabPanel, EditorPane, FakeSettings, Label, LanguageSelector, Pane, PaneGroup,
|
||||||
|
@ -40,10 +40,6 @@ pub struct Workspace {
|
||||||
show_terminal: bool,
|
show_terminal: bool,
|
||||||
show_debug: bool,
|
show_debug: bool,
|
||||||
show_language_selector: bool,
|
show_language_selector: bool,
|
||||||
left_panel_scroll_state: ScrollState,
|
|
||||||
right_panel_scroll_state: ScrollState,
|
|
||||||
tab_bar_scroll_state: ScrollState,
|
|
||||||
bottom_panel_scroll_state: ScrollState,
|
|
||||||
debug: Gpui2UiDebug,
|
debug: Gpui2UiDebug,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,10 +56,6 @@ impl Workspace {
|
||||||
show_language_selector: false,
|
show_language_selector: false,
|
||||||
show_debug: false,
|
show_debug: false,
|
||||||
show_notifications_panel: true,
|
show_notifications_panel: true,
|
||||||
left_panel_scroll_state: ScrollState::default(),
|
|
||||||
right_panel_scroll_state: ScrollState::default(),
|
|
||||||
tab_bar_scroll_state: ScrollState::default(),
|
|
||||||
bottom_panel_scroll_state: ScrollState::default(),
|
|
||||||
debug: Gpui2UiDebug::default(),
|
debug: Gpui2UiDebug::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +193,7 @@ impl Workspace {
|
||||||
|
|
||||||
let root_group = PaneGroup::new_panes(
|
let root_group = PaneGroup::new_panes(
|
||||||
vec![Pane::new(
|
vec![Pane::new(
|
||||||
ScrollState::default(),
|
"pane-0",
|
||||||
Size {
|
Size {
|
||||||
width: relative(1.).into(),
|
width: relative(1.).into(),
|
||||||
height: relative(1.).into(),
|
height: relative(1.).into(),
|
||||||
|
@ -235,16 +227,16 @@ impl Workspace {
|
||||||
.border_color(theme.lowest.base.default.border)
|
.border_color(theme.lowest.base.default.border)
|
||||||
.children(
|
.children(
|
||||||
Some(
|
Some(
|
||||||
Panel::new(cx)
|
Panel::new("project-panel-outer", cx)
|
||||||
.side(PanelSide::Left)
|
.side(PanelSide::Left)
|
||||||
.child(ProjectPanel::new(ScrollState::default())),
|
.child(ProjectPanel::new("project-panel-inner")),
|
||||||
)
|
)
|
||||||
.filter(|_| self.is_project_panel_open()),
|
.filter(|_| self.is_project_panel_open()),
|
||||||
)
|
)
|
||||||
.children(
|
.children(
|
||||||
Some(
|
Some(
|
||||||
Panel::new(cx)
|
Panel::new("collab-panel-outer", cx)
|
||||||
.child(CollabPanel::new(ScrollState::default()))
|
.child(CollabPanel::new("collab-panel-inner"))
|
||||||
.side(PanelSide::Left),
|
.side(PanelSide::Left),
|
||||||
)
|
)
|
||||||
.filter(|_| self.is_collab_panel_open()),
|
.filter(|_| self.is_collab_panel_open()),
|
||||||
|
@ -259,7 +251,7 @@ impl Workspace {
|
||||||
.child(div().flex().flex_1().child(root_group))
|
.child(div().flex().flex_1().child(root_group))
|
||||||
.children(
|
.children(
|
||||||
Some(
|
Some(
|
||||||
Panel::new(cx)
|
Panel::new("terminal-panel", cx)
|
||||||
.child(Terminal::new())
|
.child(Terminal::new())
|
||||||
.allowed_sides(PanelAllowedSides::BottomOnly)
|
.allowed_sides(PanelAllowedSides::BottomOnly)
|
||||||
.side(PanelSide::Bottom),
|
.side(PanelSide::Bottom),
|
||||||
|
@ -268,8 +260,10 @@ impl Workspace {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.children(
|
.children(
|
||||||
Some(Panel::new(cx).side(PanelSide::Right).child(
|
Some(
|
||||||
ChatPanel::new(ScrollState::default()).messages(vec![
|
Panel::new("chat-panel-outer", cx)
|
||||||
|
.side(PanelSide::Right)
|
||||||
|
.child(ChatPanel::new("chat-panel-inner").messages(vec![
|
||||||
ChatMessage::new(
|
ChatMessage::new(
|
||||||
"osiewicz".to_string(),
|
"osiewicz".to_string(),
|
||||||
"is this thing on?".to_string(),
|
"is this thing on?".to_string(),
|
||||||
|
@ -284,20 +278,23 @@ impl Workspace {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.naive_local(),
|
.naive_local(),
|
||||||
),
|
),
|
||||||
]),
|
])),
|
||||||
))
|
)
|
||||||
.filter(|_| self.is_chat_panel_open()),
|
.filter(|_| self.is_chat_panel_open()),
|
||||||
)
|
)
|
||||||
.children(
|
.children(
|
||||||
Some(
|
Some(
|
||||||
Panel::new(cx)
|
Panel::new("notifications-panel-outer", cx)
|
||||||
.side(PanelSide::Right)
|
.side(PanelSide::Right)
|
||||||
.child(NotificationsPanel::new()),
|
.child(NotificationsPanel::new("notifications-panel-inner")),
|
||||||
)
|
)
|
||||||
.filter(|_| self.is_notifications_panel_open()),
|
.filter(|_| self.is_notifications_panel_open()),
|
||||||
)
|
)
|
||||||
.children(
|
.children(
|
||||||
Some(Panel::new(cx).child(AssistantPanel::new()))
|
Some(
|
||||||
|
Panel::new("assistant-panel-outer", cx)
|
||||||
|
.child(AssistantPanel::new("assistant-panel-inner")),
|
||||||
|
)
|
||||||
.filter(|_| self.is_assistant_panel_open()),
|
.filter(|_| self.is_assistant_panel_open()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -312,7 +309,7 @@ impl Workspace {
|
||||||
.top(px(50.))
|
.top(px(50.))
|
||||||
.left(px(640.))
|
.left(px(640.))
|
||||||
.z_index(8)
|
.z_index(8)
|
||||||
.child(LanguageSelector::new()),
|
.child(LanguageSelector::new("language-selector")),
|
||||||
)
|
)
|
||||||
.filter(|_| self.is_language_selector_open()),
|
.filter(|_| self.is_language_selector_open()),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
pub use gpui3::{
|
pub use gpui3::{
|
||||||
div, Element, IntoAnyElement, ParentElement, ScrollState, SharedString, StatefulInteractive,
|
div, Element, ElementId, IntoAnyElement, ParentElement, SharedString, StatefulInteractive,
|
||||||
StatelessInteractive, Styled, ViewContext, WindowContext,
|
StatelessInteractive, Styled, ViewContext, WindowContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -638,7 +638,7 @@ pub fn empty_editor_example(cx: &mut WindowContext) -> EditorPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn empty_buffer_example<S: 'static + Send + Sync + Clone>() -> Buffer<S> {
|
pub fn empty_buffer_example<S: 'static + Send + Sync + Clone>() -> Buffer<S> {
|
||||||
Buffer::new().set_rows(Some(BufferRows::default()))
|
Buffer::new("empty-buffer").set_rows(Some(BufferRows::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hello_world_rust_editor_example(cx: &mut WindowContext) -> EditorPane {
|
pub fn hello_world_rust_editor_example(cx: &mut WindowContext) -> EditorPane {
|
||||||
|
@ -665,7 +665,7 @@ pub fn hello_world_rust_editor_example(cx: &mut WindowContext) -> EditorPane {
|
||||||
pub fn hello_world_rust_buffer_example<S: 'static + Send + Sync + Clone>(
|
pub fn hello_world_rust_buffer_example<S: 'static + Send + Sync + Clone>(
|
||||||
color: &ThemeColor,
|
color: &ThemeColor,
|
||||||
) -> Buffer<S> {
|
) -> Buffer<S> {
|
||||||
Buffer::new()
|
Buffer::new("hello-world-rust-buffer")
|
||||||
.set_title("hello_world.rs".to_string())
|
.set_title("hello_world.rs".to_string())
|
||||||
.set_path("src/hello_world.rs".to_string())
|
.set_path("src/hello_world.rs".to_string())
|
||||||
.set_language("rust".to_string())
|
.set_language("rust".to_string())
|
||||||
|
@ -806,7 +806,7 @@ pub fn hello_world_rust_editor_with_status_example(cx: &mut WindowContext) -> Ed
|
||||||
pub fn hello_world_rust_buffer_with_status_example<S: 'static + Send + Sync + Clone>(
|
pub fn hello_world_rust_buffer_with_status_example<S: 'static + Send + Sync + Clone>(
|
||||||
color: &ThemeColor,
|
color: &ThemeColor,
|
||||||
) -> Buffer<S> {
|
) -> Buffer<S> {
|
||||||
Buffer::new()
|
Buffer::new("hello-world-rust-buffer-with-status")
|
||||||
.set_title("hello_world.rs".to_string())
|
.set_title("hello_world.rs".to_string())
|
||||||
.set_path("src/hello_world.rs".to_string())
|
.set_path("src/hello_world.rs".to_string())
|
||||||
.set_language("rust".to_string())
|
.set_language("rust".to_string())
|
||||||
|
@ -952,7 +952,7 @@ pub fn hello_world_rust_with_status_buffer_rows(color: &ThemeColor) -> Vec<Buffe
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn terminal_buffer<S: 'static + Send + Sync + Clone>(color: &ThemeColor) -> Buffer<S> {
|
pub fn terminal_buffer<S: 'static + Send + Sync + Clone>(color: &ThemeColor) -> Buffer<S> {
|
||||||
Buffer::new()
|
Buffer::new("terminal")
|
||||||
.set_title("zed — fish".to_string())
|
.set_title("zed — fish".to_string())
|
||||||
.set_rows(Some(BufferRows {
|
.set_rows(Some(BufferRows {
|
||||||
show_line_numbers: false,
|
show_line_numbers: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue