diff --git a/crates/gpui3/src/elements/div.rs b/crates/gpui3/src/elements/div.rs index feeea51d8bfea82ea7a3dd1e19f26e6091f84c0e..f8867b1238e06c1cd140098028e75bcc11e0a1cf 100644 --- a/crates/gpui3/src/elements/div.rs +++ b/crates/gpui3/src/elements/div.rs @@ -196,7 +196,7 @@ impl Styled for Div IdentifiedElement for Div {} -impl Interactive for Div { +impl Interactive for Div { fn listeners(&mut self) -> &mut MouseEventListeners { &mut self.listeners } diff --git a/crates/gpui3_macros/src/derive_element.rs b/crates/gpui3_macros/src/derive_element.rs index 6c57f6c966de844ac75857898c20505260324c4a..8e73507baf598b665e0b4036c5dfc7fdf55606cf 100644 --- a/crates/gpui3_macros/src/derive_element.rs +++ b/crates/gpui3_macros/src/derive_element.rs @@ -6,12 +6,35 @@ pub fn derive_element(input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as DeriveInput); let type_name = ast.ident; + let mut logme = false; let mut state_type = quote! { () }; for param in &ast.generics.params { if let GenericParam::Type(type_param) = param { let type_ident = &type_param.ident; state_type = quote! {#type_ident}; + break; + } + } + + let attrs = &ast.attrs; + for attr in attrs { + if attr.path.is_ident("element") { + match attr.parse_meta() { + Ok(syn::Meta::List(i)) => { + for nested_meta in i.nested { + if let syn::NestedMeta::Meta(syn::Meta::NameValue(nv)) = nested_meta { + if nv.path.is_ident("view_state") { + if let syn::Lit::Str(lit_str) = nv.lit { + state_type = lit_str.value().parse().unwrap(); + logme = true; + } + } + } + } + } + _ => (), + } } } @@ -30,29 +53,32 @@ pub fn derive_element(input: TokenStream) -> TokenStream { fn layout( &mut self, - state: &mut #state_type, + view_state: &mut Self::ViewState, element_state: Option, cx: &mut gpui3::ViewContext, ) -> (gpui3::LayoutId, Self::ElementState) { use gpui3::IntoAnyElement; - let mut rendered_element = self.render(cx).into_any(); - let layout_id = rendered_element.layout(state, cx); + let mut rendered_element = self.render(view_state, cx).into_any(); + let layout_id = rendered_element.layout(view_state, cx); (layout_id, rendered_element) } fn paint( &mut self, bounds: gpui3::Bounds, - state: &mut Self::ViewState, + view_state: &mut Self::ViewState, element_state: &mut Self::ElementState, cx: &mut gpui3::ViewContext, ) { - // TODO: Where do we get the `offset` from? - element_state.paint(state, None, cx) + element_state.paint(view_state, None, cx) } } }; + if logme { + println!(">>>>>>>>>>>>>>>>>>>>>>\n{}", gen); + } + gen.into() } diff --git a/crates/gpui3_macros/src/gpui3_macros.rs b/crates/gpui3_macros/src/gpui3_macros.rs index 3340ee7923bb4bf10518eeb1eb78f4572021a849..7fd8d5ea36e39dcecf2899467721a0c08a1cc665 100644 --- a/crates/gpui3_macros/src/gpui3_macros.rs +++ b/crates/gpui3_macros/src/gpui3_macros.rs @@ -8,7 +8,7 @@ pub fn style_helpers(args: TokenStream) -> TokenStream { style_helpers::style_helpers(args) } -#[proc_macro_derive(Element, attributes(element_crate))] +#[proc_macro_derive(Element, attributes(element))] pub fn derive_element(input: TokenStream) -> TokenStream { derive_element::derive_element(input) } diff --git a/crates/storybook2/src/stories/kitchen_sink.rs b/crates/storybook2/src/stories/kitchen_sink.rs index 91e34d3c690c1aa2ddd39fe74774204c428c50f8..74e620fc31f0d108f0798edbd1e781fb6c3fd7eb 100644 --- a/crates/storybook2/src/stories/kitchen_sink.rs +++ b/crates/storybook2/src/stories/kitchen_sink.rs @@ -18,9 +18,9 @@ impl KitchenSinkStory { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let element_stories = ElementStory::iter().map(|selector| selector.story()); - let component_stories = ComponentStory::iter().map(|selector| selector.story()); + let component_stories = ComponentStory::iter().map(|selector| selector.story(cx)); Story::container(cx) .overflow_y_scroll(ScrollState::default()) diff --git a/crates/storybook2/src/stories/z_index.rs b/crates/storybook2/src/stories/z_index.rs index 4824386d8a32673196ebadf5b529699ef0d92c70..074d523e25aa0254b9d0dc527e769d40dd07daff 100644 --- a/crates/storybook2/src/stories/z_index.rs +++ b/crates/storybook2/src/stories/z_index.rs @@ -19,7 +19,7 @@ impl ZIndexStory { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title(cx, "z-index")) .child( @@ -103,7 +103,7 @@ impl ZIndexExample { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { div() .relative() .size_full() diff --git a/crates/storybook2/src/story_selector.rs b/crates/storybook2/src/story_selector.rs index 63a3b43c10cdbe1f6e6a4975fde4aaf09ae95b3d..bf169b72da280d03e1f0d2c4b8543cbca14f3bd2 100644 --- a/crates/storybook2/src/story_selector.rs +++ b/crates/storybook2/src/story_selector.rs @@ -65,7 +65,7 @@ pub enum ComponentStory { } impl ComponentStory { - pub fn story(&self) -> AnyElement { + pub fn story(&self, cx: &mut WindowContext) -> AnyElement { match self { Self::AssistantPanel => ui::AssistantPanelStory::new().into_any(), Self::Buffer => ui::BufferStory::new().into_any(), @@ -90,7 +90,7 @@ impl ComponentStory { Self::Toast => ui::ToastStory::new().into_any(), Self::Toolbar => ui::ToolbarStory::new().into_any(), Self::TrafficLights => ui::TrafficLightsStory::new().into_any(), - Self::Workspace => ui::WorkspaceStory::new().into_any(), + Self::Workspace => ui::workspace_story(cx).into_any().into_any(), } } } @@ -131,10 +131,10 @@ impl FromStr for StorySelector { } impl StorySelector { - pub fn story(&self) -> AnyElement { + pub fn story(&self, cx: &mut WindowContext) -> AnyElement { match self { Self::Element(element_story) => element_story.story(), - Self::Component(component_story) => component_story.story(), + Self::Component(component_story) => component_story.story(cx), Self::KitchenSink => crate::stories::kitchen_sink::KitchenSinkStory::new().into_any(), } } diff --git a/crates/ui2/src/components/assistant_panel.rs b/crates/ui2/src/components/assistant_panel.rs index 00562519597f382796571ac61e838759a2e67ac2..18707fd29e9092470697dabacbc267d10300dcb2 100644 --- a/crates/ui2/src/components/assistant_panel.rs +++ b/crates/ui2/src/components/assistant_panel.rs @@ -26,7 +26,7 @@ impl AssistantPanel { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); struct PanelPayload { @@ -110,7 +110,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, AssistantPanel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/breadcrumb.rs b/crates/ui2/src/components/breadcrumb.rs index 207142cd35c2d674182cc8b9ba39c5692bdf80a3..aa1327b7acd3d3d870da3af07d05472ced0f296a 100644 --- a/crates/ui2/src/components/breadcrumb.rs +++ b/crates/ui2/src/components/breadcrumb.rs @@ -31,7 +31,7 @@ impl Breadcrumb { .text_color(HighlightColor::Default.hsla(theme)) } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, view_state: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let symbols_len = self.symbols.len(); @@ -99,7 +99,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, view_state: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); Story::container(cx) diff --git a/crates/ui2/src/components/buffer.rs b/crates/ui2/src/components/buffer.rs index aadacd950bc4b21081cc435acf2abf6bf7ddaa82..f01726f086c2a3b1e67651d5e058dd9112828144 100644 --- a/crates/ui2/src/components/buffer.rs +++ b/crates/ui2/src/components/buffer.rs @@ -224,7 +224,7 @@ impl Buffer { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let rows = self.render_rows(cx); @@ -263,7 +263,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); Story::container(cx) diff --git a/crates/ui2/src/components/chat_panel.rs b/crates/ui2/src/components/chat_panel.rs index c603576c787a94d49b5b6843e96d274df8628390..d6fe01ce8ecfed732bf2521bd71bef31964bc5e1 100644 --- a/crates/ui2/src/components/chat_panel.rs +++ b/crates/ui2/src/components/chat_panel.rs @@ -25,7 +25,7 @@ impl ChatPanel { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -89,7 +89,7 @@ impl ChatMessage { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { div() .flex() .flex_col() @@ -130,7 +130,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, ChatPanel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/collab_panel.rs b/crates/ui2/src/components/collab_panel.rs index 22a41af12f5ddf29d9619c2805333779c7f829d3..86d5d12aaad41314376974802989a5bc09ccf527 100644 --- a/crates/ui2/src/components/collab_panel.rs +++ b/crates/ui2/src/components/collab_panel.rs @@ -23,7 +23,7 @@ impl CollabPanel { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let color = ThemeColor::new(cx); @@ -180,7 +180,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, CollabPanel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/command_palette.rs b/crates/ui2/src/components/command_palette.rs index 2d96d35df2eddacd0bc2b5b184ee40513f3920f7..28de48606f6a2d591fccdf27e5c0d1121b0e7c1b 100644 --- a/crates/ui2/src/components/command_palette.rs +++ b/crates/ui2/src/components/command_palette.rs @@ -17,7 +17,7 @@ impl CommandPalette { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { div().child( Palette::new(self.scroll_state.clone()) .items(example_editor_actions()) @@ -49,7 +49,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, CommandPalette>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rs index 895ea71ea35c4023b14f402b6733c7b1de1e05dc..ec9e821cbbda4b5273005ca9c15978b297deafb1 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -43,7 +43,7 @@ impl ContextMenu { items: items.into_iter().collect(), } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); v_stack() @@ -87,7 +87,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, ContextMenu>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/editor_pane.rs b/crates/ui2/src/components/editor_pane.rs index bb9c5c262357e6bc9002241dcfd871bdc299a049..426af3d204155fab7d089bd5e57d06e975b59d30 100644 --- a/crates/ui2/src/components/editor_pane.rs +++ b/crates/ui2/src/components/editor_pane.rs @@ -20,7 +20,7 @@ impl EditorPane { Self { editor } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { struct LeftItemsPayload { path: PathBuf, symbols: Vec, diff --git a/crates/ui2/src/components/facepile.rs b/crates/ui2/src/components/facepile.rs index 77fc95bc1499616fdcd059c882e7a8e489d0d9e5..4f76c505da14db679c1b89fbbfd7267c40804e15 100644 --- a/crates/ui2/src/components/facepile.rs +++ b/crates/ui2/src/components/facepile.rs @@ -17,7 +17,7 @@ impl Facepile { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let player_count = self.players.len(); let player_list = self.players.iter().enumerate().map(|(ix, player)| { @@ -52,7 +52,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let players = static_players(); Story::container(cx) diff --git a/crates/ui2/src/components/icon_button.rs b/crates/ui2/src/components/icon_button.rs index 1562dcd791f222237c240b8412a26822ddff81e3..cf8110e1e451b4af52efa7274890666b0287760f 100644 --- a/crates/ui2/src/components/icon_button.rs +++ b/crates/ui2/src/components/icon_button.rs @@ -66,7 +66,7 @@ impl IconButton { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let icon_color = match (self.state, self.color) { @@ -80,9 +80,9 @@ impl IconButton { } if let Some(click_handler) = self.handlers.click.clone() { - // div = div.on_click(MouseButton::Left, move |state, event, cx| { - // click_handler(state, cx); - // }); + div = div.on_mouse_down(MouseButton::Left, move |state, event, cx| { + click_handler(state, cx); + }); } div.w_7() diff --git a/crates/ui2/src/components/keybinding.rs b/crates/ui2/src/components/keybinding.rs index 67124a94143b32120e9f3896f7cece654ffb22c2..40718b733302af4f4fe5dfcb31c2e28c9527f23a 100644 --- a/crates/ui2/src/components/keybinding.rs +++ b/crates/ui2/src/components/keybinding.rs @@ -35,7 +35,7 @@ impl Keybinding { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { div() .flex() .gap_2() @@ -72,7 +72,7 @@ impl Key { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -189,7 +189,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let all_modifier_permutations = ModifierKey::iter().permutations(2); Story::container(cx) diff --git a/crates/ui2/src/components/language_selector.rs b/crates/ui2/src/components/language_selector.rs index 6b6d16f4af822c7afe715248ee0dafa8e3e22140..1b3c1a5477698509e61103cecc3b3aa492a42c7e 100644 --- a/crates/ui2/src/components/language_selector.rs +++ b/crates/ui2/src/components/language_selector.rs @@ -17,7 +17,7 @@ impl LanguageSelector { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { div().child( Palette::new(self.scroll_state.clone()) .items(vec![ @@ -60,7 +60,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, LanguageSelector>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index a9cc070272b5d18bdef4b719e32c602ad0556276..b2c41afb29d651b702d623af9e998ac675c0055a 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -92,7 +92,7 @@ impl ListHeader { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); let system_color = SystemColor::new(); @@ -164,7 +164,7 @@ impl ListSubHeader { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); @@ -237,11 +237,11 @@ impl From> for ListItem { } impl ListItem { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, view: &mut S, cx: &mut ViewContext) -> impl Element { match self { - ListItem::Entry(entry) => div().child(entry.render(cx)), - ListItem::Separator(separator) => div().child(separator.render(cx)), - ListItem::Header(header) => div().child(header.render(cx)), + ListItem::Entry(entry) => div().child(entry.render(view, cx)), + ListItem::Separator(separator) => div().child(separator.render(view, cx)), + ListItem::Header(header) => div().child(header.render(view, cx)), } } @@ -346,7 +346,10 @@ impl ListEntry { } } - fn disclosure_control(&mut self, cx: &mut ViewContext) -> Option> { + fn disclosure_control( + &mut self, + cx: &mut ViewContext, + ) -> Option> { let theme = theme(cx); let token = token(); @@ -369,7 +372,7 @@ impl ListEntry { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); let system_color = SystemColor::new(); @@ -437,7 +440,7 @@ impl ListSeparator { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let color = ThemeColor::new(cx); div().h_px().w_full().fill(color.border) @@ -477,7 +480,7 @@ impl List { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); let is_toggleable = self.toggleable != Toggleable::NotToggleable; diff --git a/crates/ui2/src/components/multi_buffer.rs b/crates/ui2/src/components/multi_buffer.rs index 8ab399732c8decf8e3b0f19e52e7e72650864379..b18e85caeae951814f22d46d3f0fe972ae3ffdce 100644 --- a/crates/ui2/src/components/multi_buffer.rs +++ b/crates/ui2/src/components/multi_buffer.rs @@ -17,7 +17,7 @@ impl MultiBuffer { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); v_stack() @@ -62,7 +62,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); Story::container(cx) diff --git a/crates/ui2/src/components/palette.rs b/crates/ui2/src/components/palette.rs index d498fb53aa6e92cf66c028716abe9ad6e7ff425b..dad7ef06c3c55f9d34b192f5eb7b1ff7f35461c2 100644 --- a/crates/ui2/src/components/palette.rs +++ b/crates/ui2/src/components/palette.rs @@ -47,7 +47,7 @@ impl Palette { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); v_stack() @@ -134,7 +134,7 @@ impl PaletteItem { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -172,7 +172,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Palette>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/panel.rs b/crates/ui2/src/components/panel.rs index 7c796aac4f31c446fd4cdf2b82a2ff9f4748c662..edb74c01d29c9322c5f0aea7524d8d96394d973e 100644 --- a/crates/ui2/src/components/panel.rs +++ b/crates/ui2/src/components/panel.rs @@ -100,7 +100,7 @@ impl Panel { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let token = token(); let theme = theme(cx); @@ -165,7 +165,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Panel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/panes.rs b/crates/ui2/src/components/panes.rs index ddad72348b9a17170729bf7f944f8642828f1fbf..ffb0f0491fa34f7abfb954b43bafdbbcb35479c1 100644 --- a/crates/ui2/src/components/panes.rs +++ b/crates/ui2/src/components/panes.rs @@ -48,7 +48,7 @@ impl Pane { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -89,7 +89,7 @@ impl PaneGroup { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); if !self.panes.is_empty() { @@ -100,7 +100,7 @@ impl PaneGroup { .w_full() .h_full() .fill(theme.lowest.base.default.background) - .children(self.panes.iter_mut().map(|pane| pane.render(cx))); + .children(self.panes.iter_mut().map(|pane| pane.render(view, cx))); if self.split_direction == SplitDirection::Horizontal { return el; @@ -117,7 +117,7 @@ impl PaneGroup { .w_full() .h_full() .fill(theme.lowest.base.default.background) - .children(self.groups.iter_mut().map(|group| group.render(cx))); + .children(self.groups.iter_mut().map(|group| group.render(view, cx))); if self.split_direction == SplitDirection::Horizontal { return el; diff --git a/crates/ui2/src/components/player_stack.rs b/crates/ui2/src/components/player_stack.rs index 37c0db5fec243f9aca1110c3ae3f5370ea78db4b..d664c7c0c736b03fa0125ccd5fa4104459c9faf0 100644 --- a/crates/ui2/src/components/player_stack.rs +++ b/crates/ui2/src/components/player_stack.rs @@ -17,7 +17,7 @@ impl PlayerStack { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let system_color = SystemColor::new(); let player = self.player_with_call_status.get_player(); self.player_with_call_status.get_call_status(); diff --git a/crates/ui2/src/components/project_panel.rs b/crates/ui2/src/components/project_panel.rs index 07e8f120586c1bcf3deb80e0478acd484e77cd51..0961bc907bb458567534e02e72ec089d1d80268d 100644 --- a/crates/ui2/src/components/project_panel.rs +++ b/crates/ui2/src/components/project_panel.rs @@ -20,7 +20,7 @@ impl ProjectPanel { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let color = ThemeColor::new(cx); @@ -78,7 +78,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, ProjectPanel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/recent_projects.rs b/crates/ui2/src/components/recent_projects.rs index 4e28cbd80d2e9c007e85960837d88e0059535fc9..c38337c57cdc9469b6e02cfbabbaa4e332a01caf 100644 --- a/crates/ui2/src/components/recent_projects.rs +++ b/crates/ui2/src/components/recent_projects.rs @@ -17,7 +17,7 @@ impl RecentProjects { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { div().child( Palette::new(self.scroll_state.clone()) .items(vec![ @@ -56,7 +56,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, RecentProjects>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/status_bar.rs b/crates/ui2/src/components/status_bar.rs index 43cfed88d9d9a0a1299bcdd5dfa73a91a68a952a..9f6c10f4eba43eed708084abe7efc62c825c4385 100644 --- a/crates/ui2/src/components/status_bar.rs +++ b/crates/ui2/src/components/status_bar.rs @@ -1,8 +1,7 @@ -use std::marker::PhantomData; use std::sync::Arc; -use crate::prelude::*; use crate::{get_workspace_state, Button, Icon, IconButton, IconColor, ToolDivider}; +use crate::{prelude::*, Workspace}; #[derive(Default, PartialEq)] pub enum Tool { @@ -30,17 +29,17 @@ impl Default for ToolGroup { } #[derive(Element)] -pub struct StatusBar { - state_type: PhantomData, +#[element(view_state = "Workspace")] +pub struct StatusBar { left_tools: Option, right_tools: Option, bottom_tools: Option, } -impl StatusBar { +impl StatusBar { pub fn new() -> Self { Self { - state_type: PhantomData, + // state_type: PhantomData, left_tools: None, right_tools: None, bottom_tools: None, @@ -83,7 +82,11 @@ impl StatusBar { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render( + &mut self, + view: &mut Workspace, + cx: &mut ViewContext, + ) -> impl Element { let theme = theme(cx); div() @@ -94,34 +97,35 @@ impl StatusBar { .justify_between() .w_full() .fill(theme.lowest.base.default.background) - .child(self.left_tools(&theme)) + .child(self.left_tools(view, &theme)) .child(self.right_tools(&theme)) } - fn left_tools(&self, theme: &Theme) -> impl Element { - let workspace_state = get_workspace_state(); - - div() + fn left_tools( + &self, + workspace: &mut Workspace, + theme: &Theme, + ) -> impl Element { + div::() .flex() .items_center() .gap_1() .child( - IconButton::new(Icon::FileTree) - .when(workspace_state.is_project_panel_open(), |this| { + IconButton::::new(Icon::FileTree) + .when(workspace.is_project_panel_open(), |this| { this.color(IconColor::Accent) }) - .on_click(|_, cx| { - workspace_state.toggle_project_panel(); - cx.notify(); + .on_click(|workspace, cx| { + workspace.toggle_project_panel(cx); }), ) .child( - IconButton::new(Icon::Hash) - .when(workspace_state.is_collab_panel_open(), |this| { + IconButton::::new(Icon::Hash) + .when(workspace.is_collab_panel_open(), |this| { this.color(IconColor::Accent) }) - .on_click(|_, cx| { - workspace_state.toggle_collab_panel(); + .on_click(|workspace, cx| { + workspace.toggle_collab_panel(); cx.notify(); }), ) @@ -129,7 +133,7 @@ impl StatusBar { .child(IconButton::new(Icon::XCircle)) } - fn right_tools(&self, theme: &Theme) -> impl Element { + fn right_tools(&self, theme: &Theme) -> impl Element { let workspace_state = get_workspace_state(); div() diff --git a/crates/ui2/src/components/tab.rs b/crates/ui2/src/components/tab.rs index 4757b243018ce6fe741b7fafb837e3c14350d113..7624b37272cf66343f92b8354b8a13e639efb1b1 100644 --- a/crates/ui2/src/components/tab.rs +++ b/crates/ui2/src/components/tab.rs @@ -74,7 +74,7 @@ impl Tab { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let has_fs_conflict = self.fs_status == FileSystemStatus::Conflict; let is_deleted = self.fs_status == FileSystemStatus::Deleted; @@ -157,7 +157,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let git_statuses = GitStatus::iter(); let fs_statuses = FileSystemStatus::iter(); diff --git a/crates/ui2/src/components/tab_bar.rs b/crates/ui2/src/components/tab_bar.rs index da958b5f403a565bb8a46e218352c847ef959947..b5324243a477eb19d21cf92bb17e4ac318debef5 100644 --- a/crates/ui2/src/components/tab_bar.rs +++ b/crates/ui2/src/components/tab_bar.rs @@ -23,7 +23,7 @@ impl TabBar { self.scroll_state = scroll_state; } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let can_navigate_back = true; let can_navigate_forward = false; @@ -105,7 +105,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, TabBar>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/terminal.rs b/crates/ui2/src/components/terminal.rs index d7cd12a00a54885ac83458f83d34bd2ecaecef75..08b47e70ad04442046f7a547d8271ea439d2cc5d 100644 --- a/crates/ui2/src/components/terminal.rs +++ b/crates/ui2/src/components/terminal.rs @@ -18,7 +18,7 @@ impl Terminal { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let can_navigate_back = true; @@ -109,7 +109,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Terminal>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/theme_selector.rs b/crates/ui2/src/components/theme_selector.rs index d25f1ac8d258fec9a8db131c9cc041cdf1f79bd2..ded264555e06153a3c271f235e99bb82a4446260 100644 --- a/crates/ui2/src/components/theme_selector.rs +++ b/crates/ui2/src/components/theme_selector.rs @@ -17,7 +17,7 @@ impl ThemeSelector { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { div().child( Palette::new(self.scroll_state.clone()) .items(vec![ @@ -61,7 +61,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, ThemeSelector>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/title_bar.rs b/crates/ui2/src/components/title_bar.rs index 0b9f57d37850a6dcca13fdfddfdc2ec823d4d58c..5b15e9db08c8e2e3e0820e5b602580ad772bab3b 100644 --- a/crates/ui2/src/components/title_bar.rs +++ b/crates/ui2/src/components/title_bar.rs @@ -46,7 +46,7 @@ impl TitleBar { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); // let has_focus = cx.window_is_active(); let has_focus = true; @@ -139,7 +139,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, TitleBar>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/toast.rs b/crates/ui2/src/components/toast.rs index ea7f9a1f1086096104b82452b3f7823ef4af1603..385b4a928c2edae5bfefe19daf9c18c0881aad14 100644 --- a/crates/ui2/src/components/toast.rs +++ b/crates/ui2/src/components/toast.rs @@ -41,7 +41,7 @@ impl Toast { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let color = ThemeColor::new(cx); let mut div = div(); @@ -89,7 +89,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Toast>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/toolbar.rs b/crates/ui2/src/components/toolbar.rs index 6ab85ae8156059e673941fa07599ff1965f73a00..9681288fddaef24cde009b737a986db6a52797da 100644 --- a/crates/ui2/src/components/toolbar.rs +++ b/crates/ui2/src/components/toolbar.rs @@ -27,7 +27,7 @@ impl Toolbar { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -74,7 +74,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); struct LeftItemsPayload { diff --git a/crates/ui2/src/components/traffic_lights.rs b/crates/ui2/src/components/traffic_lights.rs index 0e6bca2bd13df5392287ed103442b4af2cc87f45..753f9389c029f45ee576ff8afc86bf025be8e1c4 100644 --- a/crates/ui2/src/components/traffic_lights.rs +++ b/crates/ui2/src/components/traffic_lights.rs @@ -26,7 +26,7 @@ impl TrafficLight { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let system_color = SystemColor::new(); @@ -60,7 +60,7 @@ impl TrafficLights { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); @@ -104,7 +104,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, TrafficLights>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/workspace.rs b/crates/ui2/src/components/workspace.rs index 49045e3725517b30cec774622214e13755992608..4ffdacd00e4cad86d56927ecb5175c8c8d98ba29 100644 --- a/crates/ui2/src/components/workspace.rs +++ b/crates/ui2/src/components/workspace.rs @@ -3,7 +3,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, OnceLock}; use chrono::DateTime; -use gpui3::{px, relative, rems, Size}; +use gpui3::{px, relative, rems, view, Context, Size, View}; use crate::prelude::*; use crate::{ @@ -105,19 +105,26 @@ pub fn get_workspace_state() -> &'static WorkspaceState { state } -#[derive(Element)] -pub struct WorkspaceElement { - state_type: PhantomData, +// #[derive(Element)] +#[derive(Clone)] +pub struct Workspace { + show_project_panel: bool, + show_collab_panel: bool, left_panel_scroll_state: ScrollState, right_panel_scroll_state: ScrollState, tab_bar_scroll_state: ScrollState, bottom_panel_scroll_state: ScrollState, } -impl WorkspaceElement { +fn workspace(cx: &mut WindowContext) -> View { + view(cx.entity(|cx| Workspace::new()), Workspace::render) +} + +impl Workspace { pub fn new() -> Self { Self { - state_type: PhantomData, + show_project_panel: true, + show_collab_panel: false, left_panel_scroll_state: ScrollState::default(), right_panel_scroll_state: ScrollState::default(), tab_bar_scroll_state: ScrollState::default(), @@ -125,7 +132,31 @@ impl WorkspaceElement { } } - pub fn render(&mut self, cx: &mut ViewContext) -> impl Element { + pub fn is_project_panel_open(&self) -> bool { + dbg!(self.show_project_panel) + } + + pub fn toggle_project_panel(&mut self, cx: &mut ViewContext) { + self.show_project_panel = !self.show_project_panel; + + self.show_collab_panel = false; + + dbg!(self.show_project_panel); + + cx.notify(); + } + + pub fn is_collab_panel_open(&self) -> bool { + self.show_collab_panel + } + + pub fn toggle_collab_panel(&mut self) { + self.show_collab_panel = !self.show_collab_panel; + + self.show_project_panel = false; + } + + pub fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx).clone(); let workspace_state = get_workspace_state(); @@ -341,21 +372,23 @@ pub use stories::*; mod stories { use super::*; - #[derive(Element)] - pub struct WorkspaceStory { - state_type: PhantomData, - } + // #[derive(Element)] + // pub struct WorkspaceStory { + // state_type: PhantomData, + // } - impl WorkspaceStory { - pub fn new() -> Self { - Self { - state_type: PhantomData, - } - } + pub struct WorkspaceStory

{ + workspace: View, + } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { - // Just render the workspace without any story boilerplate. - WorkspaceElement::new() - } + pub fn workspace_story(cx: &mut WindowContext) -> View, P> { + todo!() + // let workspace = workspace::

(cx); + // view( + // cx.entity(|cx| WorkspaceStory { + // workspace, + // }), + // |view, cx| view.workspace.clone(), + // ) } } diff --git a/crates/ui2/src/element_ext.rs b/crates/ui2/src/element_ext.rs index 82bad3496a9d06389aea051cb6ec0e2fee434db0..a328b1e78fe6ff2f19fb604be681da2f107b49cc 100644 --- a/crates/ui2/src/element_ext.rs +++ b/crates/ui2/src/element_ext.rs @@ -13,6 +13,16 @@ pub trait ElementExt: Element { } self } + + // fn when_some(mut self, option: Option, then: impl FnOnce(Self, T) -> U) -> U + // where + // Self: Sized, + // { + // if let Some(value) = option { + // self = then(self, value); + // } + // self + // } } impl> ElementExt for E {} diff --git a/crates/ui2/src/elements/avatar.rs b/crates/ui2/src/elements/avatar.rs index 3f6031ece11419f57b302a303279a3a12b13ec7b..eb541d35de3f8a59ad883904f36bd93435e3c5a9 100644 --- a/crates/ui2/src/elements/avatar.rs +++ b/crates/ui2/src/elements/avatar.rs @@ -26,7 +26,7 @@ impl Avatar { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let mut img = img(); @@ -64,7 +64,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Avatar>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/elements/button.rs b/crates/ui2/src/elements/button.rs index ae72f6be50a4d19d77b6743fd676d9776adf8deb..532a4624b6d9054ae1162cafa878ddab163816c0 100644 --- a/crates/ui2/src/elements/button.rs +++ b/crates/ui2/src/elements/button.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use std::sync::Arc; -use gpui3::{DefiniteLength, Hsla, Interactive, MouseButton, WindowContext}; +use gpui3::{DefiniteLength, Hsla, WindowContext}; use crate::prelude::*; use crate::{h_stack, theme, Icon, IconColor, IconElement, Label, LabelColor, LabelSize}; @@ -160,7 +160,7 @@ impl Button { self.icon.map(|i| IconElement::new(i).color(icon_color)) } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let icon_color = self.icon_color(); let system_color = SystemColor::new(); @@ -195,11 +195,20 @@ impl Button { el = el.w(width).justify_center(); } - if let Some(click_handler) = self.handlers.click.clone() { - // el = el.on_click(MouseButton::Left, move |state, event, cx| { - // click_handler(state, cx); - // }); - } + // el.when_some(self.handlers.click.clone(), |el, click_handler| { + // el.id(0) + // .on_click(MouseButton::Left, move |state, event, cx| { + // click_handler(state, cx); + // }) + // }); + + // if let Some(click_handler) = self.handlers.click.clone() { + // el = el + // .id(0) + // .on_click(MouseButton::Left, move |state, event, cx| { + // click_handler(state, cx); + // }); + // } el } @@ -229,7 +238,11 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render( + &mut self, + _view: &mut S, + cx: &mut ViewContext, + ) -> impl Element { let states = InteractionState::iter(); Story::container(cx) diff --git a/crates/ui2/src/elements/details.rs b/crates/ui2/src/elements/details.rs index 22fa45319843fcfb3c3d8f1d917ab80915c60186..94e213ffbfd27129c6e0386a094630850fa5503e 100644 --- a/crates/ui2/src/elements/details.rs +++ b/crates/ui2/src/elements/details.rs @@ -24,7 +24,7 @@ impl Details { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -60,7 +60,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Details>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/elements/icon.rs b/crates/ui2/src/elements/icon.rs index 4ea9b8c57b437f48e549ea8fa7193684a4e4faf3..bad5e7e2f4223f369e350ba98f189e5f11438488 100644 --- a/crates/ui2/src/elements/icon.rs +++ b/crates/ui2/src/elements/icon.rs @@ -170,7 +170,7 @@ impl IconElement { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let fill = self.color.color(theme); @@ -206,7 +206,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let icons = Icon::iter(); Story::container(cx) diff --git a/crates/ui2/src/elements/input.rs b/crates/ui2/src/elements/input.rs index 9040f4847c0c67edb7aade9a2a2d95bfa51a48f9..8586eeb7e2954acb7d5df27c3dd0962ce6b619b5 100644 --- a/crates/ui2/src/elements/input.rs +++ b/crates/ui2/src/elements/input.rs @@ -45,7 +45,7 @@ impl Input { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let text_el; @@ -128,7 +128,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Input>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/elements/label.rs b/crates/ui2/src/elements/label.rs index e63cef7d21a423126958b1679fe7b9c6e0aeb05e..46edeeadbee7b39aabbefeb289e7bb12de1f637a 100644 --- a/crates/ui2/src/elements/label.rs +++ b/crates/ui2/src/elements/label.rs @@ -90,7 +90,7 @@ impl Label { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let highlight_color = theme.lowest.accent.default.foreground; @@ -185,7 +185,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Label>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/elements/tool_divider.rs b/crates/ui2/src/elements/tool_divider.rs index 215a5676095b93c30cdc2ce7094679d66adf0883..0569ac01d5545088b572d02ad5c4ab628f17f320 100644 --- a/crates/ui2/src/elements/tool_divider.rs +++ b/crates/ui2/src/elements/tool_divider.rs @@ -15,7 +15,7 @@ impl ToolDivider { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div().w_px().h_3().fill(theme.lowest.base.default.border)