Introduce a Render trait, make views implement it

Don't pass a render function separately from the view.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Antonio <as-cii@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-10-30 15:19:40 -07:00
parent 0128079de0
commit 30dffbb409
49 changed files with 616 additions and 612 deletions

View file

@ -1,4 +1,4 @@
use gpui2::{hsla, red, AnyElement, ElementId, ExternalPaths, Hsla, Length, Size};
use gpui2::{hsla, red, AnyElement, ElementId, ExternalPaths, Hsla, Length, Size, View};
use smallvec::SmallVec;
use crate::prelude::*;
@ -18,13 +18,6 @@ pub struct Pane<V: 'static> {
children: SmallVec<[AnyElement<V>; 2]>,
}
// impl<V: 'static> IntoAnyElement<V> for Pane<V> {
// fn into_any(self) -> AnyElement<V> {
// (move |view_state: &mut V, cx: &mut ViewContext<'_, '_, V>| self.render(view_state, cx))
// .into_any()
// }
// }
impl<V: 'static> Pane<V> {
pub fn new(id: impl Into<ElementId>, size: Size<Length>) -> Self {
// Fill is only here for debugging purposes, remove before release
@ -57,8 +50,8 @@ impl<V: 'static> Pane<V> {
.z_index(1)
.id("drag-target")
.drag_over::<ExternalPaths>(|d| d.bg(red()))
.on_drop(|_, files: ExternalPaths, _| {
dbg!("dropped files!", files);
.on_drop(|_, files: View<ExternalPaths>, cx| {
dbg!("dropped files!", files.read(cx));
})
.absolute()
.inset_0(),