diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index dbcbaf6072..eadc322165 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -1218,7 +1218,7 @@ impl CollabTitlebarItem { style } - fn render_face( + fn render_face( avatar: Arc, avatar_style: AvatarStyle, background_color: Color, diff --git a/crates/collab_ui/src/notifications.rs b/crates/collab_ui/src/notifications.rs index cbd072fe89..d38258ce63 100644 --- a/crates/collab_ui/src/notifications.rs +++ b/crates/collab_ui/src/notifications.rs @@ -2,14 +2,14 @@ use client::User; use gpui::{ elements::*, platform::{CursorStyle, MouseButton}, - AnyElement, Element, View, ViewContext, + AnyElement, Element, ViewContext, }; use std::sync::Arc; enum Dismiss {} enum Button {} -pub fn render_user_notification( +pub fn render_user_notification( user: Arc, title: &'static str, body: Option<&'static str>, @@ -19,7 +19,6 @@ pub fn render_user_notification( ) -> AnyElement where F: 'static + Fn(&mut V, &mut ViewContext), - V: View, { let theme = theme::current(cx).clone(); let theme = &theme.contact_notification; diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 16a7340fae..0e5b714f09 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -538,7 +538,7 @@ impl ProjectDiagnosticsEditor { } impl Item for ProjectDiagnosticsEditor { - fn tab_content( + fn tab_content( &self, _detail: Option, style: &theme::Tab, @@ -735,7 +735,7 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock { }) } -pub(crate) fn render_summary( +pub(crate) fn render_summary( summary: &DiagnosticSummary, text_style: &TextStyle, theme: &theme::ProjectDiagnostics, diff --git a/crates/drag_and_drop/src/drag_and_drop.rs b/crates/drag_and_drop/src/drag_and_drop.rs index ddfed0c858..28b876504c 100644 --- a/crates/drag_and_drop/src/drag_and_drop.rs +++ b/crates/drag_and_drop/src/drag_and_drop.rs @@ -11,7 +11,7 @@ use gpui::{ const DEAD_ZONE: f32 = 4.; -enum State { +enum State { Down { region_offset: Vector2F, region: RectF, @@ -31,7 +31,7 @@ enum State { Canceled, } -impl Clone for State { +impl Clone for State { fn clone(&self) -> Self { match self { &State::Down { @@ -68,12 +68,12 @@ impl Clone for State { } } -pub struct DragAndDrop { +pub struct DragAndDrop { containers: HashSet>, currently_dragged: Option>, } -impl Default for DragAndDrop { +impl Default for DragAndDrop { fn default() -> Self { Self { containers: Default::default(), @@ -82,7 +82,7 @@ impl Default for DragAndDrop { } } -impl DragAndDrop { +impl DragAndDrop { pub fn register_container(&mut self, handle: WeakViewHandle) { self.containers.insert(handle); } @@ -291,7 +291,7 @@ impl DragAndDrop { } } -pub trait Draggable { +pub trait Draggable { fn as_draggable( self, payload: P, @@ -301,7 +301,7 @@ pub trait Draggable { Self: Sized; } -impl Draggable for MouseEventHandler { +impl Draggable for MouseEventHandler { fn as_draggable( self, payload: P, diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index b99977a60e..b98b54fe44 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -561,7 +561,7 @@ impl Item for Editor { } } - fn tab_content( + fn tab_content( &self, detail: Option, style: &theme::Tab, diff --git a/crates/feedback/src/feedback_editor.rs b/crates/feedback/src/feedback_editor.rs index 47cb90875a..a717223f6d 100644 --- a/crates/feedback/src/feedback_editor.rs +++ b/crates/feedback/src/feedback_editor.rs @@ -268,7 +268,7 @@ impl Item for FeedbackEditor { Some("Send Feedback".into()) } - fn tab_content( + fn tab_content( &self, _: Option, style: &theme::Tab, diff --git a/crates/gpui/playground/src/playground.rs b/crates/gpui/playground/src/playground.rs index 699ec7eaeb..e65277cf03 100644 --- a/crates/gpui/playground/src/playground.rs +++ b/crates/gpui/playground/src/playground.rs @@ -1,11 +1,17 @@ -use std::ops::{Deref, DerefMut}; - use gpui::{ platform::{TitlebarOptions, WindowOptions}, AnyElement, Element, Entity, View, }; use log::LevelFilter; use simplelog::SimpleLogger; +use std::ops::{Deref, DerefMut}; + +// dymod! { +// #[path = "../ui/src/playground_ui.rs"] +// pub mod ui { +// // fn workspace(theme: &ThemeColors) -> impl Element; +// } +// } fn main() { SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger"); diff --git a/crates/gpui/playground/ui/src/editor_layout_demo.rs b/crates/gpui/playground/ui/src/editor_layout_demo.rs index eea17cad93..c51ca0ba92 100644 --- a/crates/gpui/playground/ui/src/editor_layout_demo.rs +++ b/crates/gpui/playground/ui/src/editor_layout_demo.rs @@ -1,11 +1,11 @@ use gpui::{AnyElement, Element, LayoutContext, View, ViewContext}; #[derive(Element, Clone, Default)] -pub struct Playground(PhantomData); +pub struct Playground(PhantomData); // example layout design here: https://www.figma.com/file/5QLTmxjO0xQpDD3CD4hR6T/Untitled?type=design&node-id=0%3A1&mode=design&t=SoJieVVIvDDDKagv-1 -impl Playground { +impl Playground { pub fn render(&mut self, _: &mut V, _: &mut gpui::ViewContext) -> impl Element { col() // fullscreen container with header and main in it .width(flex(1.)) diff --git a/crates/gpui/playground/ui/src/frame.rs b/crates/gpui/playground/ui/src/frame.rs index e6481fd861..6f33613578 100644 --- a/crates/gpui/playground/ui/src/frame.rs +++ b/crates/gpui/playground/ui/src/frame.rs @@ -24,18 +24,18 @@ use std::{any::Any, borrow::Cow, f32, ops::Range, sync::Arc}; use crate::color::Rgba; -pub struct Frame { +pub struct Frame { style: FrameStyle, children: Vec>, id: Option>, before_paint: Option)>>, } -pub fn column() -> Frame { +pub fn column() -> Frame { Frame::default() } -pub fn row() -> Frame { +pub fn row() -> Frame { Frame { style: FrameStyle { axis: Axis3d::X, @@ -45,7 +45,7 @@ pub fn row() -> Frame { } } -pub fn stack() -> Frame { +pub fn stack() -> Frame { Frame { style: FrameStyle { axis: Axis3d::Z, @@ -55,7 +55,7 @@ pub fn stack() -> Frame { } } -impl Default for Frame { +impl Default for Frame { fn default() -> Self { Self { style: Default::default(), @@ -66,7 +66,7 @@ impl Default for Frame { } } -impl Element for Frame { +impl Element for Frame { type LayoutState = FrameLayout; type PaintState = (); @@ -217,7 +217,7 @@ impl Element for Frame { } } -impl Frame { +impl Frame { pub fn id(mut self, id: impl Into>) -> Self { self.id = Some(id.into()); self @@ -1150,7 +1150,7 @@ pub struct Text { )>, } -pub fn text(text: impl Into>) -> Frame { +pub fn text(text: impl Into>) -> Frame { row().child(Text { text: text.into(), ..Default::default() @@ -1165,7 +1165,7 @@ pub struct FrameLayout { margins: Edges, } -impl Element for Text { +impl Element for Text { type LayoutState = TextLayout; type PaintState = (); @@ -1477,7 +1477,7 @@ impl Vector2FExt for Vector2F { } } -trait ElementExt { +trait ElementExt { fn margin_left(self, margin_left: impl Into) -> Frame where Self: Element + Sized, @@ -1488,7 +1488,7 @@ trait ElementExt { impl ElementExt for E where - V: View, + V: 'static, E: Element, { fn margin_left(self, margin_left: impl Into) -> Frame diff --git a/crates/gpui/playground/ui/src/playground_ui.rs b/crates/gpui/playground/ui/src/playground_ui.rs index 2976d59cd7..3686b00c65 100644 --- a/crates/gpui/playground/ui/src/playground_ui.rs +++ b/crates/gpui/playground/ui/src/playground_ui.rs @@ -1,7 +1,7 @@ #![allow(dead_code, unused_variables)] use frame::{length::auto, *}; -use gpui::{AnyElement, Element, LayoutContext, View, ViewContext}; +use gpui::{AnyElement, Element, LayoutContext, ViewContext}; use std::{borrow::Cow, cell::RefCell, marker::PhantomData, rc::Rc}; use themes::{rose_pine, ThemeColors}; use tokens::{margin::m4, text::lg}; @@ -12,17 +12,17 @@ mod themes; mod tokens; #[derive(Element, Clone, Default)] -pub struct Playground(PhantomData); +pub struct Playground(PhantomData); -impl Frame {} +impl Frame {} -impl Playground { +impl Playground { pub fn render(&mut self, _: &mut V, _: &mut gpui::ViewContext) -> impl Element { workspace(&rose_pine::dawn()) } } -fn workspace(theme: &ThemeColors) -> impl Element { +fn workspace(theme: &ThemeColors) -> impl Element { column() .size(auto()) .fill(theme.base(0.1)) @@ -31,24 +31,24 @@ fn workspace(theme: &ThemeColors) -> impl Element { .child(status_bar(theme)) } -fn title_bar(theme: &ThemeColors) -> impl Element { +fn title_bar(theme: &ThemeColors) -> impl Element { row().fill(theme.surface(1.0)) } -fn stage(theme: &ThemeColors) -> impl Element { +fn stage(theme: &ThemeColors) -> impl Element { row().fill(theme.surface(0.9)) } -fn status_bar(theme: &ThemeColors) -> impl Element { +fn status_bar(theme: &ThemeColors) -> impl Element { row().fill(theme.surface(0.1)) } -pub trait DialogDelegate: 'static {} +pub trait DialogDelegate: 'static {} -impl DialogDelegate for () {} +impl DialogDelegate for () {} #[derive(Element)] -pub struct Dialog> { +pub struct Dialog> { title: Cow<'static, str>, description: Cow<'static, str>, delegate: Option>>, @@ -56,7 +56,7 @@ pub struct Dialog> { view_type: PhantomData, } -pub fn dialog( +pub fn dialog( title: impl Into>, description: impl Into>, ) -> Dialog { @@ -69,7 +69,7 @@ pub fn dialog( } } -impl> Dialog { +impl> Dialog { pub fn delegate(mut self, delegate: D) -> Dialog { let old_delegate = self.delegate.replace(Rc::new(RefCell::new(delegate))); debug_assert!(old_delegate.is_none(), "delegate already set"); @@ -91,7 +91,7 @@ impl> Dialog { } #[derive(Element)] -struct Button> { +struct Button> { label: Cow<'static, str>, click_handler: Option, data: Option, @@ -102,7 +102,7 @@ pub trait ClickHandler: 'static { fn handle(&self, view: &mut V, data: &D, cx: &mut ViewContext); } -impl)> ClickHandler for F { +impl)> ClickHandler for F { fn handle(&self, view: &mut V, data: &M, cx: &mut ViewContext) { self(view, data, cx) } @@ -112,10 +112,7 @@ impl ClickHandler for () { fn handle(&self, view: &mut V, data: &D, cx: &mut ViewContext) {} } -fn button(label: impl Into>) -> Button -where - V: View, -{ +fn button(label: impl Into>) -> Button { Button { label: label.into(), click_handler: None, @@ -126,7 +123,6 @@ where impl Button where - V: View, F: ClickHandler, { fn render(&mut self, _: &mut V, _: &mut LayoutContext) -> AnyElement { @@ -137,7 +133,7 @@ where // impl Button // where -// V: View, +// V, // F: ClickHandler, // { // fn render(&mut self, _: &mut V, _: &mut LayoutContext) -> impl Element { @@ -154,7 +150,7 @@ where // impl Tab // where -// V: View, +// V, // { // fn tab(&mut self, _: &mut V, _: &mut LayoutContext) -> impl Element { // let theme = todo!(); @@ -165,7 +161,7 @@ where // } // } -impl Button { +impl Button { fn data(self, data: D) -> Button where D: 'static, @@ -179,7 +175,7 @@ impl Button { } } -impl Button { +impl Button { fn click(self, handler: H) -> Button where H: 'static + ClickHandler, @@ -193,7 +189,7 @@ impl Button { } } -impl> Dialog { +impl> Dialog { pub fn render(&mut self, _: &mut V, _: &mut gpui::ViewContext) -> AnyElement { column() .child(text(self.title.clone()).text_size(lg())) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index ba909e56fc..571f42456f 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -7,42 +7,6 @@ pub mod test_app_context; pub(crate) mod window; mod window_input_handler; -use std::{ - any::{type_name, Any, TypeId}, - cell::RefCell, - fmt::{self, Debug}, - hash::{Hash, Hasher}, - marker::PhantomData, - mem, - ops::{Deref, DerefMut, Range}, - path::{Path, PathBuf}, - pin::Pin, - rc::{self, Rc}, - sync::{Arc, Weak}, - time::Duration, -}; - -use anyhow::{anyhow, Context, Result}; - -use derive_more::Deref; -use parking_lot::Mutex; -use postage::oneshot; -use smallvec::SmallVec; -use smol::prelude::*; -use util::ResultExt; -use uuid::Uuid; - -pub use action::*; -use callback_collection::CallbackCollection; -use collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque}; -pub use menu::*; -use platform::Event; -#[cfg(any(test, feature = "test-support"))] -use ref_counts::LeakDetector; -#[cfg(any(test, feature = "test-support"))] -pub use test_app_context::{ContextHandle, TestAppContext}; -use window_input_handler::WindowInputHandler; - use crate::{ elements::{AnyElement, AnyRootElement, RootElement}, executor::{self, Task}, @@ -57,8 +21,39 @@ use crate::{ window::{Window, WindowContext}, AssetCache, AssetSource, ClipboardItem, FontCache, MouseRegionId, }; - -use self::ref_counts::RefCounts; +pub use action::*; +use anyhow::{anyhow, Context, Result}; +use callback_collection::CallbackCollection; +use collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque}; +use derive_more::Deref; +pub use menu::*; +use parking_lot::Mutex; +use platform::Event; +use postage::oneshot; +#[cfg(any(test, feature = "test-support"))] +use ref_counts::LeakDetector; +use ref_counts::RefCounts; +use smallvec::SmallVec; +use smol::prelude::*; +use std::{ + any::{type_name, Any, TypeId}, + cell::RefCell, + fmt::{self, Debug}, + hash::{Hash, Hasher}, + marker::PhantomData, + mem, + ops::{Deref, DerefMut, Range}, + path::{Path, PathBuf}, + pin::Pin, + rc::{self, Rc}, + sync::{Arc, Weak}, + time::Duration, +}; +#[cfg(any(test, feature = "test-support"))] +pub use test_app_context::{ContextHandle, TestAppContext}; +use util::ResultExt; +use uuid::Uuid; +use window_input_handler::WindowInputHandler; pub trait Entity: 'static { type Event; @@ -634,7 +629,7 @@ impl AppContext { pub fn add_action(&mut self, handler: F) where A: Action, - V: View, + V: 'static, F: 'static + FnMut(&mut V, &A, &mut ViewContext) -> R, { self.add_action_internal(handler, false) @@ -643,7 +638,7 @@ impl AppContext { pub fn capture_action(&mut self, handler: F) where A: Action, - V: View, + V: 'static, F: 'static + FnMut(&mut V, &A, &mut ViewContext), { self.add_action_internal(handler, true) @@ -652,7 +647,7 @@ impl AppContext { fn add_action_internal(&mut self, mut handler: F, capture: bool) where A: Action, - V: View, + V: 'static, F: 'static + FnMut(&mut V, &A, &mut ViewContext) -> R, { let handler = Box::new( @@ -693,7 +688,7 @@ impl AppContext { pub fn add_async_action(&mut self, mut handler: F) where A: Action, - V: View, + V: 'static, F: 'static + FnMut(&mut V, &A, &mut ViewContext) -> Option>>, { self.add_action(move |view, action, cx| { @@ -892,8 +887,8 @@ impl AppContext { fn observe_focus(&mut self, handle: &ViewHandle, mut callback: F) -> Subscription where + V: 'static, F: 'static + FnMut(ViewHandle, bool, &mut WindowContext) -> bool, - V: View, { let subscription_id = post_inc(&mut self.next_subscription_id); let observed = handle.downgrade(); @@ -1376,15 +1371,15 @@ impl AppContext { self.windows.keys().copied() } - pub fn read_view(&self, handle: &ViewHandle) -> &T { + pub fn read_view(&self, handle: &ViewHandle) -> &V { if let Some(view) = self.views.get(&(handle.window, handle.view_id)) { view.as_any().downcast_ref().expect("downcast is type safe") } else { - panic!("circular view reference for type {}", type_name::()); + panic!("circular view reference for type {}", type_name::()); } } - fn upgrade_view_handle(&self, handle: &WeakViewHandle) -> Option> { + fn upgrade_view_handle(&self, handle: &WeakViewHandle) -> Option> { if self.ref_counts.lock().is_entity_alive(handle.view_id) { Some(ViewHandle::new( handle.window, @@ -2537,10 +2532,7 @@ pub trait AnyView { } } -impl AnyView for V -where - V: View, -{ +impl AnyView for V { fn as_any(&self) -> &dyn Any { self } @@ -2872,7 +2864,7 @@ pub struct ViewContext<'a, 'b, T: ?Sized> { view_type: PhantomData, } -impl<'a, 'b, T: View> Deref for ViewContext<'a, 'b, T> { +impl<'a, 'b, V> Deref for ViewContext<'a, 'b, V> { type Target = WindowContext<'a>; fn deref(&self) -> &Self::Target { @@ -2880,13 +2872,13 @@ impl<'a, 'b, T: View> Deref for ViewContext<'a, 'b, T> { } } -impl DerefMut for ViewContext<'_, '_, T> { +impl<'a, 'b, V> DerefMut for ViewContext<'a, 'b, V> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.window_context } } -impl<'a, 'b, V: View> ViewContext<'a, 'b, V> { +impl<'a, 'b, V: 'static> ViewContext<'a, 'b, V> { pub(crate) fn mutable(window_context: &'b mut WindowContext<'a>, view_id: usize) -> Self { Self { window_context: Reference::Mutable(window_context), @@ -2907,6 +2899,12 @@ impl<'a, 'b, V: View> ViewContext<'a, 'b, V> { &mut self.window_context } + pub fn notify(&mut self) { + let window = self.window_handle; + let view_id = self.view_id; + self.window_context.notify_view(window, view_id); + } + pub fn handle(&self) -> ViewHandle { ViewHandle::new( self.window_handle, @@ -3220,21 +3218,6 @@ impl<'a, 'b, V: View> ViewContext<'a, 'b, V> { }) } - pub fn emit(&mut self, payload: V::Event) { - self.window_context - .pending_effects - .push_back(Effect::Event { - entity_id: self.view_id, - payload: Box::new(payload), - }); - } - - pub fn notify(&mut self) { - let window = self.window_handle; - let view_id = self.view_id; - self.window_context.notify_view(window, view_id); - } - pub fn defer(&mut self, callback: impl 'static + FnOnce(&mut V, &mut ViewContext)) { let handle = self.handle(); self.window_context @@ -3327,6 +3310,17 @@ impl<'a, 'b, V: View> ViewContext<'a, 'b, V> { } } +impl ViewContext<'_, '_, V> { + pub fn emit(&mut self, payload: V::Event) { + self.window_context + .pending_effects + .push_back(Effect::Event { + entity_id: self.view_id, + payload: Box::new(payload), + }); + } +} + impl BorrowAppContext for ViewContext<'_, '_, V> { fn read_with T>(&self, f: F) -> T { BorrowAppContext::read_with(&*self.window_context, f) @@ -3375,7 +3369,7 @@ pub struct LayoutContext<'a, 'b, 'c, V> { pub refreshing: bool, } -impl<'a, 'b, 'c, V: View> LayoutContext<'a, 'b, 'c, V> { +impl<'a, 'b, 'c, V> LayoutContext<'a, 'b, 'c, V> { pub fn new( view_context: &'c mut ViewContext<'a, 'b, V>, new_parents: &'c mut HashMap, @@ -3458,7 +3452,7 @@ impl<'a, 'b, 'c, V: View> LayoutContext<'a, 'b, 'c, V> { } } -impl<'a, 'b, 'c, V: View> Deref for LayoutContext<'a, 'b, 'c, V> { +impl<'a, 'b, 'c, V> Deref for LayoutContext<'a, 'b, 'c, V> { type Target = ViewContext<'a, 'b, V>; fn deref(&self) -> &Self::Target { @@ -3466,13 +3460,13 @@ impl<'a, 'b, 'c, V: View> Deref for LayoutContext<'a, 'b, 'c, V> { } } -impl DerefMut for LayoutContext<'_, '_, '_, V> { +impl DerefMut for LayoutContext<'_, '_, '_, V> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.view_context } } -impl BorrowAppContext for LayoutContext<'_, '_, '_, V> { +impl BorrowAppContext for LayoutContext<'_, '_, '_, V> { fn read_with T>(&self, f: F) -> T { BorrowAppContext::read_with(&*self.view_context, f) } @@ -3482,7 +3476,7 @@ impl BorrowAppContext for LayoutContext<'_, '_, '_, V> { } } -impl BorrowWindowContext for LayoutContext<'_, '_, '_, V> { +impl BorrowWindowContext for LayoutContext<'_, '_, '_, V> { type Result = T; fn read_window T>(&self, window: AnyWindowHandle, f: F) -> T { @@ -3512,12 +3506,12 @@ impl BorrowWindowContext for LayoutContext<'_, '_, '_, V> { } } -pub struct PaintContext<'a, 'b, 'c, V: View> { +pub struct PaintContext<'a, 'b, 'c, V> { view_context: &'c mut ViewContext<'a, 'b, V>, text_style_stack: Vec>, } -impl<'a, 'b, 'c, V: View> PaintContext<'a, 'b, 'c, V> { +impl<'a, 'b, 'c, V> PaintContext<'a, 'b, 'c, V> { pub fn new(view_context: &'c mut ViewContext<'a, 'b, V>) -> Self { Self { view_context, @@ -3544,7 +3538,7 @@ impl<'a, 'b, 'c, V: View> PaintContext<'a, 'b, 'c, V> { } } -impl<'a, 'b, 'c, V: View> Deref for PaintContext<'a, 'b, 'c, V> { +impl<'a, 'b, 'c, V> Deref for PaintContext<'a, 'b, 'c, V> { type Target = ViewContext<'a, 'b, V>; fn deref(&self) -> &Self::Target { @@ -3552,13 +3546,13 @@ impl<'a, 'b, 'c, V: View> Deref for PaintContext<'a, 'b, 'c, V> { } } -impl DerefMut for PaintContext<'_, '_, '_, V> { +impl DerefMut for PaintContext<'_, '_, '_, V> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.view_context } } -impl BorrowAppContext for PaintContext<'_, '_, '_, V> { +impl BorrowAppContext for PaintContext<'_, '_, '_, V> { fn read_with T>(&self, f: F) -> T { BorrowAppContext::read_with(&*self.view_context, f) } @@ -3568,7 +3562,7 @@ impl BorrowAppContext for PaintContext<'_, '_, '_, V> { } } -impl BorrowWindowContext for PaintContext<'_, '_, '_, V> { +impl BorrowWindowContext for PaintContext<'_, '_, '_, V> { type Result = T; fn read_window(&self, window: AnyWindowHandle, f: F) -> Self::Result @@ -3600,12 +3594,12 @@ impl BorrowWindowContext for PaintContext<'_, '_, '_, V> { } } -pub struct EventContext<'a, 'b, 'c, V: View> { +pub struct EventContext<'a, 'b, 'c, V> { view_context: &'c mut ViewContext<'a, 'b, V>, pub(crate) handled: bool, } -impl<'a, 'b, 'c, V: View> EventContext<'a, 'b, 'c, V> { +impl<'a, 'b, 'c, V> EventContext<'a, 'b, 'c, V> { pub(crate) fn new(view_context: &'c mut ViewContext<'a, 'b, V>) -> Self { EventContext { view_context, @@ -3618,7 +3612,7 @@ impl<'a, 'b, 'c, V: View> EventContext<'a, 'b, 'c, V> { } } -impl<'a, 'b, 'c, V: View> Deref for EventContext<'a, 'b, 'c, V> { +impl<'a, 'b, 'c, V> Deref for EventContext<'a, 'b, 'c, V> { type Target = ViewContext<'a, 'b, V>; fn deref(&self) -> &Self::Target { @@ -3626,13 +3620,13 @@ impl<'a, 'b, 'c, V: View> Deref for EventContext<'a, 'b, 'c, V> { } } -impl DerefMut for EventContext<'_, '_, '_, V> { +impl DerefMut for EventContext<'_, '_, '_, V> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.view_context } } -impl BorrowAppContext for EventContext<'_, '_, '_, V> { +impl BorrowAppContext for EventContext<'_, '_, '_, V> { fn read_with T>(&self, f: F) -> T { BorrowAppContext::read_with(&*self.view_context, f) } @@ -3642,7 +3636,7 @@ impl BorrowAppContext for EventContext<'_, '_, '_, V> { } } -impl BorrowWindowContext for EventContext<'_, '_, '_, V> { +impl BorrowWindowContext for EventContext<'_, '_, '_, V> { type Result = T; fn read_window T>(&self, window: AnyWindowHandle, f: F) -> T { @@ -3970,7 +3964,7 @@ impl Clone for WindowHandle { impl Copy for WindowHandle {} -impl WindowHandle { +impl WindowHandle { fn new(window_id: usize) -> Self { WindowHandle { any_handle: AnyWindowHandle::new(window_id, TypeId::of::()), @@ -4008,7 +4002,9 @@ impl WindowHandle { .update(cx, update) }) } +} +impl WindowHandle { pub fn replace_root(&self, cx: &mut C, build_root: F) -> C::Result> where C: BorrowWindowContext, @@ -4088,7 +4084,7 @@ impl AnyWindowHandle { self.update(cx, |cx| cx.add_view(build_view)) } - pub fn downcast(self) -> Option> { + pub fn downcast(self) -> Option> { if self.root_view_type == TypeId::of::() { Some(WindowHandle { any_handle: self, @@ -4099,7 +4095,7 @@ impl AnyWindowHandle { } } - pub fn root_is(&self) -> bool { + pub fn root_is(&self) -> bool { self.root_view_type == TypeId::of::() } @@ -4177,9 +4173,9 @@ impl AnyWindowHandle { } #[repr(transparent)] -pub struct ViewHandle { +pub struct ViewHandle { any_handle: AnyViewHandle, - view_type: PhantomData, + view_type: PhantomData, } impl Deref for ViewHandle { @@ -4190,15 +4186,15 @@ impl Deref for ViewHandle { } } -impl ViewHandle { +impl ViewHandle { fn new(window: AnyWindowHandle, view_id: usize, ref_counts: &Arc>) -> Self { Self { - any_handle: AnyViewHandle::new(window, view_id, TypeId::of::(), ref_counts.clone()), + any_handle: AnyViewHandle::new(window, view_id, TypeId::of::(), ref_counts.clone()), view_type: PhantomData, } } - pub fn downgrade(&self) -> WeakViewHandle { + pub fn downgrade(&self) -> WeakViewHandle { WeakViewHandle::new(self.window, self.view_id) } @@ -4214,14 +4210,14 @@ impl ViewHandle { self.view_id } - pub fn read<'a>(&self, cx: &'a AppContext) -> &'a T { + pub fn read<'a>(&self, cx: &'a AppContext) -> &'a V { cx.read_view(self) } pub fn read_with(&self, cx: &C, read: F) -> C::Result where C: BorrowWindowContext, - F: FnOnce(&T, &ViewContext) -> S, + F: FnOnce(&V, &ViewContext) -> S, { cx.read_window(self.window, |cx| { let cx = ViewContext::immutable(cx, self.view_id); @@ -4232,7 +4228,7 @@ impl ViewHandle { pub fn update(&self, cx: &mut C, update: F) -> C::Result where C: BorrowWindowContext, - F: FnOnce(&mut T, &mut ViewContext) -> S, + F: FnOnce(&mut V, &mut ViewContext) -> S, { let mut update = Some(update); @@ -4368,8 +4364,8 @@ impl AnyViewHandle { TypeId::of::() == self.view_type } - pub fn downcast(self) -> Option> { - if self.is::() { + pub fn downcast(self) -> Option> { + if self.is::() { Some(ViewHandle { any_handle: self, view_type: PhantomData, @@ -4379,8 +4375,8 @@ impl AnyViewHandle { } } - pub fn downcast_ref(&self) -> Option<&ViewHandle> { - if self.is::() { + pub fn downcast_ref(&self) -> Option<&ViewHandle> { + if self.is::() { Some(unsafe { mem::transmute(self) }) } else { None @@ -4579,7 +4575,7 @@ impl WeakHandle for WeakViewHandle { } } -impl WeakViewHandle { +impl WeakViewHandle { fn new(window: AnyWindowHandle, view_id: usize) -> Self { Self { any_handle: AnyWeakViewHandle { @@ -4619,7 +4615,7 @@ impl WeakViewHandle { cx.read(|cx| { let handle = cx .upgrade_view_handle(self) - .ok_or_else(|| anyhow!("view {} was dropped", V::ui_name()))?; + .ok_or_else(|| anyhow!("view was dropped"))?; cx.read_window(self.window, |cx| handle.read_with(cx, read)) .ok_or_else(|| anyhow!("window was removed")) }) @@ -4633,14 +4629,14 @@ impl WeakViewHandle { cx.update(|cx| { let handle = cx .upgrade_view_handle(self) - .ok_or_else(|| anyhow!("view {} was dropped", V::ui_name()))?; + .ok_or_else(|| anyhow!("view was dropped"))?; cx.update_window(self.window, |cx| handle.update(cx, update)) .ok_or_else(|| anyhow!("window was removed")) }) } } -impl Deref for WeakViewHandle { +impl Deref for WeakViewHandle { type Target = AnyWeakViewHandle; fn deref(&self) -> &Self::Target { @@ -4648,7 +4644,7 @@ impl Deref for WeakViewHandle { } } -impl Clone for WeakViewHandle { +impl Clone for WeakViewHandle { fn clone(&self) -> Self { Self { any_handle: self.any_handle.clone(), diff --git a/crates/gpui/src/app/window.rs b/crates/gpui/src/app/window.rs index 29b97e81b7..a1805006e7 100644 --- a/crates/gpui/src/app/window.rs +++ b/crates/gpui/src/app/window.rs @@ -67,8 +67,8 @@ impl Window { build_view: F, ) -> Self where - F: FnOnce(&mut ViewContext) -> V, V: View, + F: FnOnce(&mut ViewContext) -> V, { let titlebar_height = platform_window.titlebar_height(); let appearance = platform_window.appearance(); @@ -242,14 +242,11 @@ impl<'a> WindowContext<'a> { Some(result) } - pub(crate) fn update_view( + pub(crate) fn update_view( &mut self, - handle: &ViewHandle, - update: &mut dyn FnMut(&mut T, &mut ViewContext) -> S, - ) -> S - where - T: View, - { + handle: &ViewHandle, + update: &mut dyn FnMut(&mut V, &mut ViewContext) -> S, + ) -> S { self.update_any_view(handle.view_id, |view, cx| { let mut cx = ViewContext::mutable(cx, handle.view_id); update( @@ -1412,7 +1409,7 @@ impl ChildView { } } -impl Element for ChildView { +impl Element for ChildView { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements.rs b/crates/gpui/src/elements.rs index 1ef9fcd833..e603b6a1e2 100644 --- a/crates/gpui/src/elements.rs +++ b/crates/gpui/src/elements.rs @@ -43,7 +43,7 @@ use json::ToJson; use smallvec::SmallVec; use std::{any::Any, borrow::Cow, mem, ops::Range}; -pub trait Element: 'static { +pub trait Element: 'static { type LayoutState; type PaintState; @@ -232,7 +232,7 @@ trait AnyElementState { fn metadata(&self) -> Option<&dyn Any>; } -enum ElementState> { +enum ElementState> { Empty, Init { element: E, @@ -253,7 +253,7 @@ enum ElementState> { }, } -impl> AnyElementState for ElementState { +impl> AnyElementState for ElementState { fn layout( &mut self, constraint: SizeConstraint, @@ -427,18 +427,18 @@ impl> AnyElementState for ElementState { } } -impl> Default for ElementState { +impl> Default for ElementState { fn default() -> Self { Self::Empty } } -pub struct AnyElement { +pub struct AnyElement { state: Box>, name: Option>, } -impl AnyElement { +impl AnyElement { pub fn name(&self) -> Option<&str> { self.name.as_deref() } @@ -506,7 +506,7 @@ impl AnyElement { } } -impl Element for AnyElement { +impl Element for AnyElement { type LayoutState = (); type PaintState = (); @@ -564,12 +564,12 @@ impl Element for AnyElement { } } -pub struct RootElement { +pub struct RootElement { element: AnyElement, view: WeakViewHandle, } -impl RootElement { +impl RootElement { pub fn new(element: AnyElement, view: WeakViewHandle) -> Self { Self { element, view } } @@ -677,7 +677,7 @@ impl AnyRootElement for RootElement { } } -pub trait ParentElement<'a, V: View>: Extend> + Sized { +pub trait ParentElement<'a, V: 'static>: Extend> + Sized { fn add_children>(&mut self, children: impl IntoIterator) { self.extend(children.into_iter().map(|child| child.into_any())); } @@ -697,7 +697,12 @@ pub trait ParentElement<'a, V: View>: Extend> + Sized { } } -impl<'a, V: View, T> ParentElement<'a, V> for T where T: Extend> {} +impl<'a, V, T> ParentElement<'a, V> for T +where + V: 'static, + T: Extend>, +{ +} pub fn constrain_size_preserving_aspect_ratio(max_size: Vector2F, size: Vector2F) -> Vector2F { if max_size.x().is_infinite() && max_size.y().is_infinite() { diff --git a/crates/gpui/src/elements/align.rs b/crates/gpui/src/elements/align.rs index e60c1ff907..1312c336fb 100644 --- a/crates/gpui/src/elements/align.rs +++ b/crates/gpui/src/elements/align.rs @@ -1,18 +1,18 @@ use crate::{ geometry::{rect::RectF, vector::Vector2F}, - json, AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, View, + json, AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, ViewContext, }; use json::ToJson; use serde_json::json; -pub struct Align { +pub struct Align { child: AnyElement, alignment: Vector2F, } -impl Align { +impl Align { pub fn new(child: AnyElement) -> Self { Self { child, @@ -41,7 +41,7 @@ impl Align { } } -impl Element for Align { +impl Element for Align { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/canvas.rs b/crates/gpui/src/elements/canvas.rs index 2d33ba45e5..d169efb3d9 100644 --- a/crates/gpui/src/elements/canvas.rs +++ b/crates/gpui/src/elements/canvas.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use super::Element; use crate::{ json::{self, json}, - PaintContext, SceneBuilder, View, ViewContext, + PaintContext, SceneBuilder, ViewContext, }; use json::ToJson; use pathfinder_geometry::{ @@ -15,7 +15,6 @@ pub struct Canvas(F, PhantomData); impl Canvas where - V: View, F: FnMut(&mut SceneBuilder, RectF, RectF, &mut V, &mut ViewContext), { pub fn new(f: F) -> Self { @@ -23,7 +22,7 @@ where } } -impl Element for Canvas +impl Element for Canvas where F: 'static + FnMut(&mut SceneBuilder, RectF, RectF, &mut V, &mut ViewContext), { diff --git a/crates/gpui/src/elements/clipped.rs b/crates/gpui/src/elements/clipped.rs index 4e8cd4bc15..64f22515b3 100644 --- a/crates/gpui/src/elements/clipped.rs +++ b/crates/gpui/src/elements/clipped.rs @@ -4,21 +4,21 @@ use pathfinder_geometry::{rect::RectF, vector::Vector2F}; use serde_json::json; use crate::{ - json, AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, View, + json, AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, ViewContext, }; -pub struct Clipped { +pub struct Clipped { child: AnyElement, } -impl Clipped { +impl Clipped { pub fn new(child: AnyElement) -> Self { Self { child } } } -impl Element for Clipped { +impl Element for Clipped { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/constrained_box.rs b/crates/gpui/src/elements/constrained_box.rs index 0d540a47b4..495b6c69dc 100644 --- a/crates/gpui/src/elements/constrained_box.rs +++ b/crates/gpui/src/elements/constrained_box.rs @@ -5,21 +5,21 @@ use serde_json::json; use crate::{ geometry::{rect::RectF, vector::Vector2F}, - json, AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, View, + json, AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, ViewContext, }; -pub struct ConstrainedBox { +pub struct ConstrainedBox { child: AnyElement, constraint: Constraint, } -pub enum Constraint { +pub enum Constraint { Static(SizeConstraint), Dynamic(Box) -> SizeConstraint>), } -impl ToJson for Constraint { +impl ToJson for Constraint { fn to_json(&self) -> serde_json::Value { match self { Constraint::Static(constraint) => constraint.to_json(), @@ -28,7 +28,7 @@ impl ToJson for Constraint { } } -impl ConstrainedBox { +impl ConstrainedBox { pub fn new(child: impl Element) -> Self { Self { child: child.into_any(), @@ -132,7 +132,7 @@ impl ConstrainedBox { } } -impl Element for ConstrainedBox { +impl Element for ConstrainedBox { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/container.rs b/crates/gpui/src/elements/container.rs index f1e199b652..f07e425d4b 100644 --- a/crates/gpui/src/elements/container.rs +++ b/crates/gpui/src/elements/container.rs @@ -10,8 +10,7 @@ use crate::{ json::ToJson, platform::CursorStyle, scene::{self, Border, CursorRegion, Quad}, - AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, View, - ViewContext, + AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, ViewContext, }; use schemars::JsonSchema; use serde::Deserialize; @@ -37,12 +36,12 @@ pub struct ContainerStyle { pub cursor: Option, } -pub struct Container { +pub struct Container { child: AnyElement, style: ContainerStyle, } -impl Container { +impl Container { pub fn new(child: AnyElement) -> Self { Self { child, @@ -186,7 +185,7 @@ impl Container { } } -impl Element for Container { +impl Element for Container { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/empty.rs b/crates/gpui/src/elements/empty.rs index 7058068453..04b1c70213 100644 --- a/crates/gpui/src/elements/empty.rs +++ b/crates/gpui/src/elements/empty.rs @@ -6,7 +6,7 @@ use crate::{ vector::{vec2f, Vector2F}, }, json::{json, ToJson}, - LayoutContext, PaintContext, SceneBuilder, View, ViewContext, + LayoutContext, PaintContext, SceneBuilder, ViewContext, }; use crate::{Element, SizeConstraint}; @@ -26,7 +26,7 @@ impl Empty { } } -impl Element for Empty { +impl Element for Empty { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/expanded.rs b/crates/gpui/src/elements/expanded.rs index 1f4f2f40a1..ad6682d2a9 100644 --- a/crates/gpui/src/elements/expanded.rs +++ b/crates/gpui/src/elements/expanded.rs @@ -2,18 +2,18 @@ use std::ops::Range; use crate::{ geometry::{rect::RectF, vector::Vector2F}, - json, AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, View, + json, AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, ViewContext, }; use serde_json::json; -pub struct Expanded { +pub struct Expanded { child: AnyElement, full_width: bool, full_height: bool, } -impl Expanded { +impl Expanded { pub fn new(child: impl Element) -> Self { Self { child: child.into_any(), @@ -35,7 +35,7 @@ impl Expanded { } } -impl Element for Expanded { +impl Element for Expanded { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/flex.rs b/crates/gpui/src/elements/flex.rs index 3000b9575d..d9c43ca4c8 100644 --- a/crates/gpui/src/elements/flex.rs +++ b/crates/gpui/src/elements/flex.rs @@ -3,7 +3,7 @@ use std::{any::Any, cell::Cell, f32::INFINITY, ops::Range, rc::Rc}; use crate::{ json::{self, ToJson, Value}, AnyElement, Axis, Element, ElementStateHandle, LayoutContext, PaintContext, SceneBuilder, - SizeConstraint, Vector2FExt, View, ViewContext, + SizeConstraint, Vector2FExt, ViewContext, }; use pathfinder_geometry::{ rect::RectF, @@ -17,14 +17,14 @@ struct ScrollState { scroll_position: Cell, } -pub struct Flex { +pub struct Flex { axis: Axis, children: Vec>, scroll_state: Option<(ElementStateHandle>, usize)>, child_alignment: f32, } -impl Flex { +impl Flex { pub fn new(axis: Axis) -> Self { Self { axis, @@ -115,13 +115,13 @@ impl Flex { } } -impl Extend> for Flex { +impl Extend> for Flex { fn extend>>(&mut self, children: T) { self.children.extend(children); } } -impl Element for Flex { +impl Element for Flex { type LayoutState = f32; type PaintState = (); @@ -401,12 +401,12 @@ struct FlexParentData { float: bool, } -pub struct FlexItem { +pub struct FlexItem { metadata: FlexParentData, child: AnyElement, } -impl FlexItem { +impl FlexItem { pub fn new(child: impl Element) -> Self { FlexItem { metadata: FlexParentData { @@ -428,7 +428,7 @@ impl FlexItem { } } -impl Element for FlexItem { +impl Element for FlexItem { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/hook.rs b/crates/gpui/src/elements/hook.rs index 7ac6c95f3e..579c2b682f 100644 --- a/crates/gpui/src/elements/hook.rs +++ b/crates/gpui/src/elements/hook.rs @@ -3,16 +3,15 @@ use std::ops::Range; use crate::{ geometry::{rect::RectF, vector::Vector2F}, json::json, - AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, View, - ViewContext, + AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, ViewContext, }; -pub struct Hook { +pub struct Hook { child: AnyElement, after_layout: Option)>>, } -impl Hook { +impl Hook { pub fn new(child: impl Element) -> Self { Self { child: child.into_any(), @@ -29,7 +28,7 @@ impl Hook { } } -impl Element for Hook { +impl Element for Hook { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/image.rs b/crates/gpui/src/elements/image.rs index e87c065917..339ece4764 100644 --- a/crates/gpui/src/elements/image.rs +++ b/crates/gpui/src/elements/image.rs @@ -6,7 +6,7 @@ use crate::{ }, json::{json, ToJson}, scene, Border, Element, ImageData, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, - View, ViewContext, + ViewContext, }; use schemars::JsonSchema; use serde::Deserialize; @@ -57,7 +57,7 @@ impl Image { } } -impl Element for Image { +impl Element for Image { type LayoutState = Option>; type PaintState = (); diff --git a/crates/gpui/src/elements/keystroke_label.rs b/crates/gpui/src/elements/keystroke_label.rs index 268f3ccb1c..48a3971658 100644 --- a/crates/gpui/src/elements/keystroke_label.rs +++ b/crates/gpui/src/elements/keystroke_label.rs @@ -31,7 +31,7 @@ impl KeystrokeLabel { } } -impl Element for KeystrokeLabel { +impl Element for KeystrokeLabel { type LayoutState = AnyElement; type PaintState = (); diff --git a/crates/gpui/src/elements/label.rs b/crates/gpui/src/elements/label.rs index 80555c7442..281c2ce9b8 100644 --- a/crates/gpui/src/elements/label.rs +++ b/crates/gpui/src/elements/label.rs @@ -8,7 +8,7 @@ use crate::{ }, json::{ToJson, Value}, text_layout::{Line, RunStyle}, - Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, View, ViewContext, + Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, ViewContext, }; use schemars::JsonSchema; use serde::Deserialize; @@ -128,7 +128,7 @@ impl Label { } } -impl Element for Label { +impl Element for Label { type LayoutState = Line; type PaintState = (); diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rs index 5454519905..fd035891a1 100644 --- a/crates/gpui/src/elements/list.rs +++ b/crates/gpui/src/elements/list.rs @@ -5,16 +5,16 @@ use crate::{ }, json::json, AnyElement, Element, LayoutContext, MouseRegion, PaintContext, SceneBuilder, SizeConstraint, - View, ViewContext, + ViewContext, }; use std::{cell::RefCell, collections::VecDeque, fmt::Debug, ops::Range, rc::Rc}; use sum_tree::{Bias, SumTree}; -pub struct List { +pub struct List { state: ListState, } -pub struct ListState(Rc>>); +pub struct ListState(Rc>>); #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum Orientation { @@ -22,7 +22,7 @@ pub enum Orientation { Bottom, } -struct StateInner { +struct StateInner { last_layout_width: Option, render_item: Box) -> AnyElement>, rendered_range: Range, @@ -40,13 +40,13 @@ pub struct ListOffset { pub offset_in_item: f32, } -enum ListItem { +enum ListItem { Unrendered, Rendered(Rc>>), Removed(f32), } -impl Clone for ListItem { +impl Clone for ListItem { fn clone(&self) -> Self { match self { Self::Unrendered => Self::Unrendered, @@ -56,7 +56,7 @@ impl Clone for ListItem { } } -impl Debug for ListItem { +impl Debug for ListItem { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Unrendered => write!(f, "Unrendered"), @@ -86,13 +86,13 @@ struct UnrenderedCount(usize); #[derive(Clone, Debug, Default)] struct Height(f32); -impl List { +impl List { pub fn new(state: ListState) -> Self { Self { state } } } -impl Element for List { +impl Element for List { type LayoutState = ListOffset; type PaintState = (); @@ -347,7 +347,7 @@ impl Element for List { } } -impl ListState { +impl ListState { pub fn new( element_count: usize, orientation: Orientation, @@ -440,13 +440,13 @@ impl ListState { } } -impl Clone for ListState { +impl Clone for ListState { fn clone(&self) -> Self { Self(self.0.clone()) } } -impl StateInner { +impl StateInner { fn render_item( &mut self, ix: usize, @@ -560,7 +560,7 @@ impl StateInner { } } -impl ListItem { +impl ListItem { fn remove(&self) -> Self { match self { ListItem::Unrendered => ListItem::Unrendered, @@ -570,7 +570,7 @@ impl ListItem { } } -impl sum_tree::Item for ListItem { +impl sum_tree::Item for ListItem { type Summary = ListItemSummary; fn summary(&self) -> Self::Summary { @@ -944,7 +944,7 @@ mod tests { type Event = (); } - impl View for TestView { + impl crate::View for TestView { fn ui_name() -> &'static str { "TestView" } @@ -968,7 +968,7 @@ mod tests { } } - impl Element for TestElement { + impl Element for TestElement { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/mouse_event_handler.rs b/crates/gpui/src/elements/mouse_event_handler.rs index 6005277f73..be773fd4b1 100644 --- a/crates/gpui/src/elements/mouse_event_handler.rs +++ b/crates/gpui/src/elements/mouse_event_handler.rs @@ -11,12 +11,12 @@ use crate::{ MouseHover, MouseMove, MouseMoveOut, MouseScrollWheel, MouseUp, MouseUpOut, }, AnyElement, Element, EventContext, LayoutContext, MouseRegion, MouseState, PaintContext, - SceneBuilder, SizeConstraint, View, ViewContext, + SceneBuilder, SizeConstraint, ViewContext, }; use serde_json::json; use std::{marker::PhantomData, ops::Range}; -pub struct MouseEventHandler { +pub struct MouseEventHandler { child: AnyElement, region_id: usize, cursor_style: Option, @@ -31,7 +31,7 @@ pub struct MouseEventHandler { /// Element which provides a render_child callback with a MouseState and paints a mouse /// region under (or above) it for easy mouse event handling. -impl MouseEventHandler { +impl MouseEventHandler { pub fn for_child(child: impl Element, region_id: usize) -> Self { Self { child: child.into_any(), @@ -236,7 +236,7 @@ impl MouseEventHandler { } } -impl Element for MouseEventHandler { +impl Element for MouseEventHandler { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/overlay.rs b/crates/gpui/src/elements/overlay.rs index 56e3d10de3..14d19e802c 100644 --- a/crates/gpui/src/elements/overlay.rs +++ b/crates/gpui/src/elements/overlay.rs @@ -4,11 +4,11 @@ use crate::{ geometry::{rect::RectF, vector::Vector2F}, json::ToJson, AnyElement, Axis, Element, LayoutContext, MouseRegion, PaintContext, SceneBuilder, - SizeConstraint, View, ViewContext, + SizeConstraint, ViewContext, }; use serde_json::json; -pub struct Overlay { +pub struct Overlay { child: AnyElement, anchor_position: Option, anchor_corner: AnchorCorner, @@ -73,7 +73,7 @@ impl AnchorCorner { } } -impl Overlay { +impl Overlay { pub fn new(child: impl Element) -> Self { Self { child: child.into_any(), @@ -117,7 +117,7 @@ impl Overlay { } } -impl Element for Overlay { +impl Element for Overlay { type LayoutState = Vector2F; type PaintState = (); diff --git a/crates/gpui/src/elements/resizable.rs b/crates/gpui/src/elements/resizable.rs index 0b1d94f8f8..00b0bb1e69 100644 --- a/crates/gpui/src/elements/resizable.rs +++ b/crates/gpui/src/elements/resizable.rs @@ -8,7 +8,7 @@ use crate::{ platform::{CursorStyle, MouseButton}, scene::MouseDrag, AnyElement, Axis, Element, LayoutContext, MouseRegion, PaintContext, SceneBuilder, - SizeConstraint, View, ViewContext, + SizeConstraint, ViewContext, }; #[derive(Copy, Clone, Debug)] @@ -69,7 +69,7 @@ impl HandleSide { } } -pub struct Resizable { +pub struct Resizable { child: AnyElement, handle_side: HandleSide, handle_size: f32, @@ -78,7 +78,7 @@ pub struct Resizable { const DEFAULT_HANDLE_SIZE: f32 = 4.0; -impl Resizable { +impl Resizable { pub fn new( child: AnyElement, handle_side: HandleSide, @@ -105,7 +105,7 @@ impl Resizable { } } -impl Element for Resizable { +impl Element for Resizable { type LayoutState = SizeConstraint; type PaintState = (); diff --git a/crates/gpui/src/elements/stack.rs b/crates/gpui/src/elements/stack.rs index 8f9d1e4d05..e73e2f0b40 100644 --- a/crates/gpui/src/elements/stack.rs +++ b/crates/gpui/src/elements/stack.rs @@ -3,17 +3,16 @@ use std::ops::Range; use crate::{ geometry::{rect::RectF, vector::Vector2F}, json::{self, json, ToJson}, - AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, View, - ViewContext, + AnyElement, Element, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, ViewContext, }; /// Element which renders it's children in a stack on top of each other. /// The first child determines the size of the others. -pub struct Stack { +pub struct Stack { children: Vec>, } -impl Default for Stack { +impl Default for Stack { fn default() -> Self { Self { children: Vec::new(), @@ -21,13 +20,13 @@ impl Default for Stack { } } -impl Stack { +impl Stack { pub fn new() -> Self { Self::default() } } -impl Element for Stack { +impl Element for Stack { type LayoutState = (); type PaintState = (); @@ -99,7 +98,7 @@ impl Element for Stack { } } -impl Extend> for Stack { +impl Extend> for Stack { fn extend>>(&mut self, children: T) { self.children.extend(children) } diff --git a/crates/gpui/src/elements/svg.rs b/crates/gpui/src/elements/svg.rs index c4d58cd7a7..0d5bcd59e4 100644 --- a/crates/gpui/src/elements/svg.rs +++ b/crates/gpui/src/elements/svg.rs @@ -7,7 +7,7 @@ use crate::{ rect::RectF, vector::{vec2f, Vector2F}, }, - scene, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, + scene, Element, LayoutContext, SceneBuilder, SizeConstraint, ViewContext, }; use schemars::JsonSchema; use serde_derive::Deserialize; @@ -27,7 +27,7 @@ impl Svg { } } - pub fn for_style(style: SvgStyle) -> impl Element { + pub fn for_style(style: SvgStyle) -> impl Element { Self::new(style.asset) .with_color(style.color) .constrained() @@ -41,7 +41,7 @@ impl Svg { } } -impl Element for Svg { +impl Element for Svg { type LayoutState = Option; type PaintState = (); diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs index 62722ccb18..38aa75a9ed 100644 --- a/crates/gpui/src/elements/text.rs +++ b/crates/gpui/src/elements/text.rs @@ -8,7 +8,7 @@ use crate::{ json::{ToJson, Value}, text_layout::{Line, RunStyle, ShapedBoundary}, AppContext, Element, FontCache, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, - TextLayoutCache, View, ViewContext, + TextLayoutCache, ViewContext, }; use log::warn; use serde_json::json; @@ -70,7 +70,7 @@ impl Text { } } -impl Element for Text { +impl Element for Text { type LayoutState = LayoutState; type PaintState = (); diff --git a/crates/gpui/src/elements/tooltip.rs b/crates/gpui/src/elements/tooltip.rs index 0510baa9e4..9189d6da0e 100644 --- a/crates/gpui/src/elements/tooltip.rs +++ b/crates/gpui/src/elements/tooltip.rs @@ -7,7 +7,7 @@ use crate::{ geometry::{rect::RectF, vector::Vector2F}, json::json, Action, Axis, ElementStateHandle, LayoutContext, PaintContext, SceneBuilder, SizeConstraint, - Task, View, ViewContext, + Task, ViewContext, }; use schemars::JsonSchema; use serde::Deserialize; @@ -21,7 +21,7 @@ use util::ResultExt; const DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(500); -pub struct Tooltip { +pub struct Tooltip { child: AnyElement, tooltip: Option>, _state: ElementStateHandle>, @@ -51,8 +51,8 @@ pub struct KeystrokeStyle { text: TextStyle, } -impl Tooltip { - pub fn new( +impl Tooltip { + pub fn new( id: usize, text: String, action: Option>, @@ -166,7 +166,7 @@ impl Tooltip { } } -impl Element for Tooltip { +impl Element for Tooltip { type LayoutState = (); type PaintState = (); diff --git a/crates/gpui/src/elements/uniform_list.rs b/crates/gpui/src/elements/uniform_list.rs index b9bfadb17f..c7279d6389 100644 --- a/crates/gpui/src/elements/uniform_list.rs +++ b/crates/gpui/src/elements/uniform_list.rs @@ -6,7 +6,7 @@ use crate::{ }, json::{self, json}, platform::ScrollWheelEvent, - AnyElement, LayoutContext, MouseRegion, PaintContext, SceneBuilder, View, ViewContext, + AnyElement, LayoutContext, MouseRegion, PaintContext, SceneBuilder, ViewContext, }; use json::ToJson; use std::{cell::RefCell, cmp, ops::Range, rc::Rc}; @@ -36,13 +36,13 @@ struct StateInner { scroll_to: Option, } -pub struct UniformListLayoutState { +pub struct UniformListLayoutState { scroll_max: f32, item_height: f32, items: Vec>, } -pub struct UniformList { +pub struct UniformList { state: UniformListState, item_count: usize, #[allow(clippy::type_complexity)] @@ -53,7 +53,7 @@ pub struct UniformList { view_id: usize, } -impl UniformList { +impl UniformList { pub fn new( state: UniformListState, item_count: usize, @@ -61,7 +61,6 @@ impl UniformList { append_items: F, ) -> Self where - V: View, F: 'static + Fn(&mut V, Range, &mut Vec>, &mut ViewContext), { Self { @@ -151,7 +150,7 @@ impl UniformList { } } -impl Element for UniformList { +impl Element for UniformList { type LayoutState = UniformListLayoutState; type PaintState = (); diff --git a/crates/gpui/src/scene/mouse_region.rs b/crates/gpui/src/scene/mouse_region.rs index ca2cc04b9d..a02199cdcb 100644 --- a/crates/gpui/src/scene/mouse_region.rs +++ b/crates/gpui/src/scene/mouse_region.rs @@ -1,4 +1,4 @@ -use crate::{platform::MouseButton, window::WindowContext, EventContext, View, ViewContext}; +use crate::{platform::MouseButton, window::WindowContext, EventContext, ViewContext}; use collections::HashMap; use pathfinder_geometry::rect::RectF; use smallvec::SmallVec; @@ -64,7 +64,7 @@ impl MouseRegion { pub fn on_down(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseDown, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_down(button, handler); @@ -73,7 +73,7 @@ impl MouseRegion { pub fn on_up(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseUp, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_up(button, handler); @@ -82,7 +82,7 @@ impl MouseRegion { pub fn on_click(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseClick, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_click(button, handler); @@ -91,7 +91,7 @@ impl MouseRegion { pub fn on_click_out(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseClickOut, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_click_out(button, handler); @@ -100,7 +100,7 @@ impl MouseRegion { pub fn on_down_out(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseDownOut, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_down_out(button, handler); @@ -109,7 +109,7 @@ impl MouseRegion { pub fn on_up_out(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseUpOut, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_up_out(button, handler); @@ -118,7 +118,7 @@ impl MouseRegion { pub fn on_drag(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseDrag, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_drag(button, handler); @@ -127,7 +127,7 @@ impl MouseRegion { pub fn on_hover(mut self, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseHover, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_hover(handler); @@ -136,7 +136,7 @@ impl MouseRegion { pub fn on_move(mut self, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseMove, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_move(handler); @@ -145,7 +145,7 @@ impl MouseRegion { pub fn on_move_out(mut self, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseMoveOut, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_move_out(handler); @@ -154,7 +154,7 @@ impl MouseRegion { pub fn on_scroll(mut self, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseScrollWheel, &mut V, &mut EventContext) + 'static, { self.handlers = self.handlers.on_scroll(handler); @@ -310,7 +310,7 @@ impl HandlerSet { pub fn on_move(mut self, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseMove, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::move_disc(), None, @@ -332,7 +332,7 @@ impl HandlerSet { pub fn on_move_out(mut self, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseMoveOut, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::move_out_disc(), None, @@ -354,7 +354,7 @@ impl HandlerSet { pub fn on_down(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseDown, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::down_disc(), Some(button), @@ -376,7 +376,7 @@ impl HandlerSet { pub fn on_up(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseUp, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::up_disc(), Some(button), @@ -398,7 +398,7 @@ impl HandlerSet { pub fn on_click(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseClick, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::click_disc(), Some(button), @@ -420,7 +420,7 @@ impl HandlerSet { pub fn on_click_out(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseClickOut, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::click_out_disc(), Some(button), @@ -442,7 +442,7 @@ impl HandlerSet { pub fn on_down_out(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseDownOut, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::down_out_disc(), Some(button), @@ -464,7 +464,7 @@ impl HandlerSet { pub fn on_up_out(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseUpOut, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::up_out_disc(), Some(button), @@ -486,7 +486,7 @@ impl HandlerSet { pub fn on_drag(mut self, button: MouseButton, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseDrag, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::drag_disc(), Some(button), @@ -508,7 +508,7 @@ impl HandlerSet { pub fn on_hover(mut self, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseHover, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::hover_disc(), None, @@ -530,7 +530,7 @@ impl HandlerSet { pub fn on_scroll(mut self, handler: F) -> Self where - V: View, + V: 'static, F: Fn(MouseScrollWheel, &mut V, &mut EventContext) + 'static, { self.insert(MouseEvent::scroll_wheel_disc(), None, diff --git a/crates/gpui_macros/src/gpui_macros.rs b/crates/gpui_macros/src/gpui_macros.rs index caadfe4015..a225759cd1 100644 --- a/crates/gpui_macros/src/gpui_macros.rs +++ b/crates/gpui_macros/src/gpui_macros.rs @@ -281,7 +281,7 @@ pub fn element_derive(input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as DeriveInput); let type_name = ast.ident; - let placeholder_view_generics: Generics = parse_quote! { }; + let placeholder_view_generics: Generics = parse_quote! { }; let placeholder_view_type_name: Ident = parse_quote! { V }; let view_type_name: Ident; let impl_generics: syn::ImplGenerics<'_>; diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs index 0dc594a13f..de410b6211 100644 --- a/crates/language_tools/src/lsp_log.rs +++ b/crates/language_tools/src/lsp_log.rs @@ -450,7 +450,7 @@ impl View for LspLogView { } impl Item for LspLogView { - fn tab_content( + fn tab_content( &self, _: Option, style: &theme::Tab, diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 7a1e8ace63..0f196773c6 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -452,7 +452,7 @@ impl View for SyntaxTreeView { } impl Item for SyntaxTreeView { - fn tab_content( + fn tab_content( &self, _: Option, style: &theme::Tab, diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index f7582f1764..79784516ed 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1320,7 +1320,7 @@ impl ProjectPanel { } } - fn render_entry_visual_element( + fn render_entry_visual_element( details: &EntryDetails, editor: Option<&ViewHandle>, padding: f32, diff --git a/crates/recent_projects/src/highlighted_workspace_location.rs b/crates/recent_projects/src/highlighted_workspace_location.rs index f915cb24ed..79c7ddec18 100644 --- a/crates/recent_projects/src/highlighted_workspace_location.rs +++ b/crates/recent_projects/src/highlighted_workspace_location.rs @@ -3,7 +3,7 @@ use std::path::Path; use fuzzy::StringMatch; use gpui::{ elements::{Label, LabelStyle}, - AnyElement, Element, View, + AnyElement, Element, }; use util::paths::PathExt; use workspace::WorkspaceLocation; @@ -43,7 +43,7 @@ impl HighlightedText { } } - pub fn render(self, style: impl Into) -> AnyElement { + pub fn render(self, style: impl Into) -> AnyElement { Label::new(self.text, style) .with_highlights(self.highlight_positions) .into_any() diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 018ab9cb11..f6b3976f44 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -395,7 +395,7 @@ impl Item for ProjectSearchView { .update(cx, |editor, cx| editor.deactivated(cx)); } - fn tab_content( + fn tab_content( &self, _detail: Option, tab_theme: &theme::Tab, diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 970e0115df..99f7d6332d 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -657,7 +657,7 @@ impl Item for TerminalView { Some(self.terminal().read(cx).title().into()) } - fn tab_content( + fn tab_content( &self, _detail: Option, tab_theme: &theme::Tab, diff --git a/crates/theme/src/ui.rs b/crates/theme/src/ui.rs index a16c3cb21e..bd9af52d0e 100644 --- a/crates/theme/src/ui.rs +++ b/crates/theme/src/ui.rs @@ -10,7 +10,7 @@ use gpui::{ platform, platform::MouseButton, scene::MouseClick, - Action, Element, EventContext, MouseState, View, ViewContext, + Action, Element, EventContext, MouseState, ViewContext, }; use schemars::JsonSchema; use serde::Deserialize; @@ -37,7 +37,7 @@ pub fn checkbox( ) -> MouseEventHandler where Tag: 'static, - V: View, + V: 'static, F: 'static + Fn(&mut V, bool, &mut EventContext), { let label = Label::new(label, style.label.text.clone()) @@ -57,7 +57,7 @@ pub fn checkbox_with_label( where Tag: 'static, D: Element, - V: View, + V: 'static, F: 'static + Fn(&mut V, bool, &mut EventContext), { MouseEventHandler::new(id, cx, |state, _| { @@ -93,7 +93,7 @@ where .with_cursor_style(platform::CursorStyle::PointingHand) } -pub fn svg(style: &SvgStyle) -> ConstrainedBox { +pub fn svg(style: &SvgStyle) -> ConstrainedBox { Svg::new(style.asset.clone()) .with_color(style.color) .constrained() @@ -107,11 +107,11 @@ pub struct IconStyle { pub container: ContainerStyle, } -pub fn icon(style: &IconStyle) -> Container { +pub fn icon(style: &IconStyle) -> Container { svg(&style.icon).contained().with_style(style.container) } -pub fn keystroke_label( +pub fn keystroke_label( label_text: &'static str, label_style: &ContainedText, keystroke_style: &ContainedText, @@ -147,7 +147,7 @@ pub fn cta_button( where Tag: 'static, L: Into>, - V: View, + V: 'static, F: Fn(MouseClick, &mut V, &mut EventContext) + 'static, { MouseEventHandler::::new(0, cx, |state, _| { @@ -186,9 +186,9 @@ pub fn modal( ) -> impl Element where Tag: 'static, - V: View, I: Into>, D: Element, + V: 'static, F: FnOnce(&mut gpui::ViewContext) -> D, { const TITLEBAR_HEIGHT: f32 = 28.; diff --git a/crates/welcome/src/welcome.rs b/crates/welcome/src/welcome.rs index b7460c4c46..4d8df53a1b 100644 --- a/crates/welcome/src/welcome.rs +++ b/crates/welcome/src/welcome.rs @@ -232,7 +232,7 @@ impl Item for WelcomePage { Some("Welcome to Zed!".into()) } - fn tab_content( + fn tab_content( &self, _detail: Option, style: &theme::Tab, diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 21956be446..a115e0f473 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -101,7 +101,7 @@ pub trait Item: View { fn tab_description<'a>(&'a self, _: usize, _: &'a AppContext) -> Option> { None } - fn tab_content( + fn tab_content( &self, detail: Option, style: &theme::Tab, @@ -943,7 +943,7 @@ pub mod test { }) } - fn tab_content( + fn tab_content( &self, detail: Option, _: &theme::Tab, diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 8064478964..f51c2baf68 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1864,12 +1864,12 @@ impl NavHistoryState { } } -pub struct PaneBackdrop { +pub struct PaneBackdrop { child_view: usize, child: AnyElement, } -impl PaneBackdrop { +impl PaneBackdrop { pub fn new(pane_item_view: usize, child: AnyElement) -> Self { PaneBackdrop { child, @@ -1878,7 +1878,7 @@ impl PaneBackdrop { } } -impl Element for PaneBackdrop { +impl Element for PaneBackdrop { type LayoutState = (); type PaintState = (); diff --git a/crates/workspace/src/pane/dragged_item_receiver.rs b/crates/workspace/src/pane/dragged_item_receiver.rs index 2d3fe8ea83..8208b4b3d5 100644 --- a/crates/workspace/src/pane/dragged_item_receiver.rs +++ b/crates/workspace/src/pane/dragged_item_receiver.rs @@ -7,7 +7,7 @@ use gpui::{ geometry::{rect::RectF, vector::Vector2F}, platform::MouseButton, scene::MouseUp, - AppContext, Element, EventContext, MouseState, Quad, View, ViewContext, WeakViewHandle, + AppContext, Element, EventContext, MouseState, Quad, ViewContext, WeakViewHandle, }; use project::ProjectEntryId; @@ -107,7 +107,7 @@ where handler } -pub fn handle_dropped_item( +pub fn handle_dropped_item( event: MouseUp, workspace: WeakViewHandle, pane: &WeakViewHandle, diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs index 977e167f60..00f422de4e 100644 --- a/crates/workspace/src/shared_screen.rs +++ b/crates/workspace/src/shared_screen.rs @@ -104,7 +104,7 @@ impl Item for SharedScreen { } } - fn tab_content( + fn tab_content( &self, _: Option, style: &theme::Tab,