WIP: Lots of errors, starting on resurrecting derive Element
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
use gpui::img;
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Component)]
|
||||
#[derive(Element)]
|
||||
pub struct Avatar {
|
||||
src: SharedString,
|
||||
shape: Shape,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::prelude::*;
|
||||
use gpui::Element;
|
||||
use gpui::{prelude::*, AnyElement};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
@@ -21,40 +22,41 @@ pub enum ToastOrigin {
|
||||
/// they are actively showing the a process in progress.
|
||||
///
|
||||
/// Only one toast may be visible at a time.
|
||||
#[derive(Element)]
|
||||
pub struct Toast<V: 'static> {
|
||||
origin: ToastOrigin,
|
||||
children: SmallVec<[AnyElement<V>; 2]>,
|
||||
}
|
||||
|
||||
impl<V: 'static> Element<V> for Toast<V> {
|
||||
type State = Option<AnyElement<V>>;
|
||||
// impl<V: 'static> Element<V> for Toast<V> {
|
||||
// type State = Option<AnyElement<V>>;
|
||||
|
||||
fn element_id(&self) -> Option<ElementId> {
|
||||
None
|
||||
}
|
||||
// fn element_id(&self) -> Option<ElementId> {
|
||||
// None
|
||||
// }
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
view_state: &mut V,
|
||||
_element_state: Option<Self::State>,
|
||||
cx: &mut ViewContext<V>,
|
||||
) -> (gpui::LayoutId, Self::State) {
|
||||
let mut element = self.render(view_state, cx).into_any();
|
||||
let layout_id = element.layout(view_state, cx);
|
||||
(layout_id, Some(element))
|
||||
}
|
||||
// fn layout(
|
||||
// &mut self,
|
||||
// view_state: &mut V,
|
||||
// _element_state: Option<Self::State>,
|
||||
// cx: &mut ViewContext<V>,
|
||||
// ) -> (gpui::LayoutId, Self::State) {
|
||||
// let mut element = self.render(view_state, cx).into_any();
|
||||
// let layout_id = element.layout(view_state, cx);
|
||||
// (layout_id, Some(element))
|
||||
// }
|
||||
|
||||
fn paint(
|
||||
self,
|
||||
bounds: gpui::Bounds<gpui::Pixels>,
|
||||
view_state: &mut V,
|
||||
element: &mut Self::State,
|
||||
cx: &mut ViewContext<V>,
|
||||
) {
|
||||
let element = element.take().unwrap();
|
||||
element.paint(view_state, cx);
|
||||
}
|
||||
}
|
||||
// fn paint(
|
||||
// self,
|
||||
// bounds: gpui::Bounds<gpui::Pixels>,
|
||||
// view_state: &mut V,
|
||||
// element: &mut Self::State,
|
||||
// cx: &mut ViewContext<V>,
|
||||
// ) {
|
||||
// let element = element.take().unwrap();
|
||||
// element.paint(view_state, cx);
|
||||
// }
|
||||
// }
|
||||
|
||||
impl<V: 'static> Toast<V> {
|
||||
pub fn new(origin: ToastOrigin) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user