1use super::{Element, Handle, Layout, LayoutId, Result, SharedString, ViewContext};
2use std::marker::PhantomData;
3
4pub fn field<S>(editor: Handle<Editor>) -> EditorElement<S> {
5 EditorElement {
6 editor,
7 field: true,
8 placeholder_text: None,
9 parent_state: PhantomData,
10 }
11}
12
13pub struct EditorElement<S> {
14 editor: Handle<Editor>,
15 field: bool,
16 placeholder_text: Option<SharedString>,
17 parent_state: PhantomData<S>,
18}
19
20impl<S> EditorElement<S> {
21 pub fn field(mut self) -> Self {
22 self.field = true;
23 self
24 }
25
26 pub fn placeholder_text(mut self, text: impl Into<SharedString>) -> Self {
27 self.placeholder_text = Some(text.into());
28 self
29 }
30}
31
32impl<S: 'static> Element for EditorElement<S> {
33 type State = S;
34 type FrameState = ();
35
36 fn layout(
37 &mut self,
38 _: &mut Self::State,
39 cx: &mut ViewContext<Self::State>,
40 ) -> Result<(LayoutId, Self::FrameState)> {
41 self.editor.update(cx, |_editor, _cx| todo!())
42 }
43
44 fn paint(
45 &mut self,
46 _layout: Layout,
47 _state: &mut Self::State,
48 _frame_state: &mut Self::FrameState,
49 cx: &mut ViewContext<Self::State>,
50 ) -> Result<()> {
51 self.editor.update(cx, |_editor, _cx| todo!())
52 }
53}
54
55pub struct Editor {}
56
57impl Editor {
58 pub fn new(_: &mut ViewContext<Self>) -> Self {
59 Editor {}
60 }
61}