Mainline GPUI2 UI work (#3079)
This PR mainlines the current state of new GPUI2-based UI from the `gpui2-ui` branch. Release Notes: - N/A --------- Co-authored-by: Nate Butler <iamnbutler@gmail.com> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Nate <nate@zed.dev>
This commit is contained in:
parent
08361eb84e
commit
9e1f7c4c18
39 changed files with 1047 additions and 399 deletions
|
@ -1,17 +1,15 @@
|
|||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
static_project_panel_project_items, static_project_panel_single_items, theme, Input, List,
|
||||
ListHeader, Panel, PanelSide, Theme,
|
||||
ListHeader,
|
||||
};
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct ProjectPanel<V: 'static> {
|
||||
view_type: PhantomData<V>,
|
||||
scroll_state: ScrollState,
|
||||
current_side: PanelSide,
|
||||
}
|
||||
|
||||
impl<V: 'static> ProjectPanel<V> {
|
||||
|
@ -19,69 +17,42 @@ impl<V: 'static> ProjectPanel<V> {
|
|||
Self {
|
||||
view_type: PhantomData,
|
||||
scroll_state,
|
||||
current_side: PanelSide::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn side(mut self, side: PanelSide) -> Self {
|
||||
self.current_side = side;
|
||||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
||||
struct PanelPayload {
|
||||
pub theme: Arc<Theme>,
|
||||
pub scroll_state: ScrollState,
|
||||
}
|
||||
let theme = theme(cx);
|
||||
|
||||
Panel::new(
|
||||
self.scroll_state.clone(),
|
||||
|_, payload| {
|
||||
let payload = payload.downcast_ref::<PanelPayload>().unwrap();
|
||||
|
||||
let theme = payload.theme.clone();
|
||||
|
||||
vec![div()
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.w_full()
|
||||
.h_full()
|
||||
.px_2()
|
||||
.fill(theme.middle.base.default.background)
|
||||
.child(
|
||||
div()
|
||||
.w_56()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.w_56()
|
||||
.h_full()
|
||||
.px_2()
|
||||
.fill(theme.middle.base.default.background)
|
||||
.overflow_y_scroll(ScrollState::default())
|
||||
.child(
|
||||
div()
|
||||
.w_56()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.overflow_y_scroll(payload.scroll_state.clone())
|
||||
.child(
|
||||
List::new(static_project_panel_single_items())
|
||||
.header(
|
||||
ListHeader::new("FILES").set_toggle(ToggleState::Toggled),
|
||||
)
|
||||
.empty_message("No files in directory")
|
||||
.set_toggle(ToggleState::Toggled),
|
||||
)
|
||||
.child(
|
||||
List::new(static_project_panel_project_items())
|
||||
.header(
|
||||
ListHeader::new("PROJECT").set_toggle(ToggleState::Toggled),
|
||||
)
|
||||
.empty_message("No folders in directory")
|
||||
.set_toggle(ToggleState::Toggled),
|
||||
),
|
||||
List::new(static_project_panel_single_items())
|
||||
.header(ListHeader::new("FILES").set_toggle(ToggleState::Toggled))
|
||||
.empty_message("No files in directory")
|
||||
.set_toggle(ToggleState::Toggled),
|
||||
)
|
||||
.child(
|
||||
Input::new("Find something...")
|
||||
.value("buffe".to_string())
|
||||
.state(InteractionState::Focused),
|
||||
)
|
||||
.into_any()]
|
||||
},
|
||||
Box::new(PanelPayload {
|
||||
theme: theme(cx),
|
||||
scroll_state: self.scroll_state.clone(),
|
||||
}),
|
||||
)
|
||||
List::new(static_project_panel_project_items())
|
||||
.header(ListHeader::new("PROJECT").set_toggle(ToggleState::Toggled))
|
||||
.empty_message("No folders in directory")
|
||||
.set_toggle(ToggleState::Toggled),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
Input::new("Find something...")
|
||||
.value("buffe".to_string())
|
||||
.state(InteractionState::Focused),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue