Wire up hacky children for Panel
This commit is contained in:
parent
aae4f00a4b
commit
4b793f44ef
4 changed files with 44 additions and 11 deletions
|
@ -39,6 +39,31 @@ pub trait ParentElement<S> {
|
||||||
.extend(iter.into_iter().map(|item| item.into_any()));
|
.extend(iter.into_iter().map(|item| item.into_any()));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HACK: This is a temporary hack to get children working for the purposes
|
||||||
|
// of building UI on top of the current version of gpui2.
|
||||||
|
//
|
||||||
|
// We'll (hopefully) be moving away from this in the future.
|
||||||
|
fn children_any<I>(mut self, children: I) -> Self
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = AnyElement<S>>,
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
self.children_mut().extend(children.into_iter());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
// HACK: This is a temporary hack to get children working for the purposes
|
||||||
|
// of building UI on top of the current version of gpui2.
|
||||||
|
//
|
||||||
|
// We'll (hopefully) be moving away from this in the future.
|
||||||
|
fn child_any(mut self, children: AnyElement<S>) -> Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
self.children_mut().push(children);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ElementObject<S> {
|
trait ElementObject<S> {
|
||||||
|
|
|
@ -48,15 +48,15 @@ pub struct Panel<S: 'static + Send + Sync> {
|
||||||
allowed_sides: PanelAllowedSides,
|
allowed_sides: PanelAllowedSides,
|
||||||
initial_width: AbsoluteLength,
|
initial_width: AbsoluteLength,
|
||||||
width: Option<AbsoluteLength>,
|
width: Option<AbsoluteLength>,
|
||||||
// children: HackyChildren<V>,
|
children: HackyChildren<S>,
|
||||||
// payload: HackyChildrenPayload,
|
payload: HackyChildrenPayload,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Panel<S> {
|
impl<S: 'static + Send + Sync> Panel<S> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
scroll_state: ScrollState,
|
scroll_state: ScrollState,
|
||||||
// children: HackyChildren<S>,
|
children: HackyChildren<S>,
|
||||||
// payload: HackyChildrenPayload,
|
payload: HackyChildrenPayload,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let token = token();
|
let token = token();
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ impl<S: 'static + Send + Sync> Panel<S> {
|
||||||
allowed_sides: PanelAllowedSides::default(),
|
allowed_sides: PanelAllowedSides::default(),
|
||||||
initial_width: token.default_panel_size,
|
initial_width: token.default_panel_size,
|
||||||
width: None,
|
width: None,
|
||||||
// children,
|
children,
|
||||||
// payload,
|
payload,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +141,6 @@ impl<S: 'static + Send + Sync> Panel<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
panel_base
|
panel_base.children_any((self.children)(cx, self.payload.as_ref()))
|
||||||
|
|
||||||
// panel_base.children_any((self.children)(cx, self.payload.as_ref()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
pub use gpui3::{Element, ScrollState, StyleHelpers, ViewContext};
|
pub use gpui3::{Element, IntoAnyElement, ParentElement, ScrollState, StyleHelpers, ViewContext};
|
||||||
|
|
||||||
pub use crate::ui::{HackyChildren, HackyChildrenPayload};
|
pub use crate::ui::{HackyChildren, HackyChildrenPayload};
|
||||||
|
|
|
@ -35,7 +35,17 @@ impl Workspace {
|
||||||
.size_full()
|
.size_full()
|
||||||
.v_stack()
|
.v_stack()
|
||||||
.fill(theme.lowest.base.default.background)
|
.fill(theme.lowest.base.default.background)
|
||||||
.child(Panel::new(ScrollState::default()))
|
.child(Panel::new(
|
||||||
|
ScrollState::default(),
|
||||||
|
|_, _| {
|
||||||
|
vec![div()
|
||||||
|
.font("Courier")
|
||||||
|
.text_color(gpui3::hsla(1., 1., 1., 1.))
|
||||||
|
.child("Hello world")
|
||||||
|
.into_any()]
|
||||||
|
},
|
||||||
|
Box::new(()),
|
||||||
|
))
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.size_full()
|
.size_full()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue