Unified · Split
| @@ -57,6 +57,7 @@ use language::{ · 56 unmodified lines | ||
| 57 | 57 | Diagnostic, IndentKind, IndentSize, Language, LanguageRegistry, LanguageServerName, |
| 58 | 58 | OffsetRangeExt, Point, Selection, SelectionGoal, TransactionId, |
| 59 | 59 | }; |
| 60 | +use lazy_static::lazy_static; | |
| 60 | 61 | use link_go_to_definition::{GoToDefinitionLink, InlayHighlight, LinkGoToDefinitionState}; |
| 61 | 62 | use lsp::{DiagnosticSeverity, Documentation, LanguageServerId}; |
| 62 | 63 | use movement::TextLayoutDetails; |
| @@ -66,7 +67,7 @@ pub use multi_buffer::{ · 3 unmodified lines | ||
| 66 | 67 | ToPoint, |
| 67 | 68 | }; |
| 68 | 69 | use ordered_float::OrderedFloat; |
| 69 | −use parking_lot::RwLock; | |
| 70 | +use parking_lot::{Mutex, RwLock}; | |
| 70 | 71 | use project::{FormatTrigger, Location, Project}; |
| 71 | 72 | use rand::prelude::*; |
| 72 | 73 | use rpc::proto::*; |
| @@ -1,25 +1,55 @@ | ||
| 1 | 1 | use editor::Editor; |
| 2 | 2 | use gpui::{ |
| 3 | 3 | actions, div, AppContext, Div, EventEmitter, ParentElement, Render, SharedString, |
| 4 | − StatelessInteractive, Styled, View, ViewContext, VisualContext, | |
| 4 | + StatefulInteractivity, StatelessInteractive, Styled, View, ViewContext, VisualContext, | |
| 5 | 5 | }; |
| 6 | 6 | use text::Point; |
| 7 | 7 | use theme::ActiveTheme; |
| 8 | 8 | use ui::{h_stack, modal, v_stack, Label, LabelColor}; |
| 9 | 9 | use util::paths::FILE_ROW_COLUMN_DELIMITER; |
| 10 | −use workspace::{ModalRegistry, Modal, ModalEvent}; | |
| 10 | +use workspace::{Modal, ModalEvent, Workspace}; | |
| 11 | 11 | |
| 12 | 12 | actions!(Toggle); |
| 13 | 13 | |
| 14 | 14 | pub fn init(cx: &mut AppContext) { |
| 15 | − cx.global_mut::<ModalRegistry>() | |
| 16 | − .register_modal(Toggle, |workspace, cx| { | |
| 17 | − let editor = workspace | |
| 18 | − .active_item(cx) | |
| 19 | − .and_then(|active_item| active_item.downcast::<Editor>())?; | |
| 20 | − | |
| 21 | − Some(cx.build_view(|cx| GoToLine::new(editor, cx))) | |
| 22 | − }); | |
| 15 | + cx.observe_new_views( | |
| 16 | + |workspace: &mut Workspace, _: &mut ViewContext<Workspace>| { | |
| 17 | + workspace | |
| 18 | + .modal_layer() | |
| 19 | + .register_modal(Toggle, |workspace, cx| { | |
| 20 | + let editor = workspace | |
| 21 | + .active_item(cx) | |
| 22 | + .and_then(|active_item| active_item.downcast::<Editor>())?; | |
| 23 | + | |
| 24 | + Some(cx.build_view(|cx| GoToLine::new(editor, cx))) | |
| 25 | + }); | |
| 26 | + dbg!("hey!"); | |
| 27 | + }, | |
| 28 | + ) | |
| 29 | + .detach(); | |
| 30 | + | |
| 31 | + // // cx.window_global() | |
| 32 | + // // cx.window_global::<Workspace> | |
| 33 | + // // cx.window_global::<ActiveEditor>() | |
| 34 | + // Workspace::on_init(|workspace, cx| { | |
| 35 | + // workspace.on_open_item() | |
| 36 | + // }); | |
| 37 | + | |
| 38 | + // Editor::on_init(|editor, cx|{ | |
| 39 | + | |
| 40 | + // }) | |
| 41 | + | |
| 42 | + // Editor::register_action(|_editor, _: &Toggle, cx| { | |
| 43 | + // dbg!("HEY!"); | |
| 44 | + // // let editor = cx.view(); | |
| 45 | + // // cx.update_window(cx.window().handle(), |cx, view| { | |
| 46 | + // // let workspace = view.downcast::<Workspace>(); | |
| 47 | + // // }) | |
| 48 | + // // workspace.show_modal(cx.build_view(|cx| GoToLine::new(editor, cx))) | |
| 49 | + // }) | |
| 50 | + // cx.global_mut::<ModalRegistry>() | |
| 51 | + // .register_modal(Toggle, |workspace, cx| { | |
| 52 | + // }); | |
| 23 | 53 | } |
| 24 | 54 | |
| 25 | 55 | pub struct GoToLine { |
| @@ -128,13 +158,14 @@ impl Modal for GoToLine { · 102 unmodified lines | ||
| 128 | 158 | } |
| 129 | 159 | |
| 130 | 160 | impl Render for GoToLine { |
| 131 | − type Element = Div<Self>; | |
| 161 | + type Element = Div<Self, StatefulInteractivity<Self>>; | |
| 132 | 162 | |
| 133 | 163 | fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element { |
| 134 | 164 | modal(cx) |
| 135 | − .w_96() | |
| 165 | + .id("go to line") | |
| 136 | 166 | .on_action(Self::cancel) |
| 137 | 167 | .on_action(Self::confirm) |
| 168 | + .w_96() | |
| 138 | 169 | .child( |
| 139 | 170 | v_stack() |
| 140 | 171 | .px_1() |
| @@ -18,8 +18,8 @@ use crate::{ · 17 unmodified lines | ||
| 18 | 18 | AppMetadata, AssetSource, BackgroundExecutor, ClipboardItem, Context, DispatchPhase, DisplayId, |
| 19 | 19 | Entity, EventEmitter, FocusEvent, FocusHandle, FocusId, ForegroundExecutor, KeyBinding, Keymap, |
| 20 | 20 | LayoutId, PathPromptOptions, Pixels, Platform, PlatformDisplay, Point, Render, SubscriberSet, |
| 21 | − Subscription, SvgRenderer, Task, TextStyle, TextStyleRefinement, TextSystem, View, Window, | |
| 22 | − WindowContext, WindowHandle, WindowId, | |
| 21 | + Subscription, SvgRenderer, Task, TextStyle, TextStyleRefinement, TextSystem, View, ViewContext, | |
| 22 | + Window, WindowContext, WindowHandle, WindowId, | |
| 23 | 23 | }; |
| 24 | 24 | use anyhow::{anyhow, Result}; |
| 25 | 25 | use collections::{HashMap, HashSet, VecDeque}; |
| @@ -167,6 +167,7 @@ type Handler = Box<dyn FnMut(&mut AppContext) -> bool + 'static>; · 141 unmodified lines | ||
| 167 | 167 | type Listener = Box<dyn FnMut(&dyn Any, &mut AppContext) -> bool + 'static>; |
| 168 | 168 | type QuitHandler = Box<dyn FnOnce(&mut AppContext) -> LocalBoxFuture<'static, ()> + 'static>; |
| 169 | 169 | type ReleaseListener = Box<dyn FnOnce(&mut dyn Any, &mut AppContext) + 'static>; |
| 170 | +type NewViewListener = Box<dyn FnMut(AnyView, &mut WindowContext) + 'static>; | |
| 170 | 171 | |
| 171 | 172 | // struct FrameConsumer { |
| 172 | 173 | // next_frame_callbacks: Vec<FrameCallback>, |
| @@ -193,6 +194,7 @@ pub struct AppContext { · 20 unmodified lines | ||
| 193 | 194 | pub(crate) text_style_stack: Vec<TextStyleRefinement>, |
| 194 | 195 | pub(crate) globals_by_type: HashMap<TypeId, AnyBox>, |
| 195 | 196 | pub(crate) entities: EntityMap, |
| 197 | + pub(crate) new_view_observers: SubscriberSet<TypeId, NewViewListener>, | |
| 196 | 198 | pub(crate) windows: SlotMap<WindowId, Option<Window>>, |
| 197 | 199 | pub(crate) keymap: Arc<Mutex<Keymap>>, |
| 198 | 200 | pub(crate) global_action_listeners: |
| @@ -251,6 +253,7 @@ impl AppContext { · 52 unmodified lines | ||
| 251 | 253 | text_style_stack: Vec::new(), |
| 252 | 254 | globals_by_type: HashMap::default(), |
| 253 | 255 | entities, |
| 256 | + new_view_observers: SubscriberSet::new(), | |
| 254 | 257 | windows: SlotMap::with_key(), |
| 255 | 258 | keymap: Arc::new(Mutex::new(Keymap::default())), |
| 256 | 259 | global_action_listeners: HashMap::default(), |
| @@ -599,6 +602,7 @@ impl AppContext { · 342 unmodified lines | ||
| 599 | 602 | |
| 600 | 603 | fn apply_notify_effect(&mut self, emitter: EntityId) { |
| 601 | 604 | self.pending_notifications.remove(&emitter); |
| 605 | + | |
| 602 | 606 | self.observers |
| 603 | 607 | .clone() |
| 604 | 608 | .retain(&emitter, |handler| handler(self)); |
| @@ -828,6 +832,23 @@ impl AppContext { · 223 unmodified lines | ||
| 828 | 832 | self.globals_by_type.insert(global_type, lease.global); |
| 829 | 833 | } |
| 830 | 834 | |
| 835 | + pub fn observe_new_views<V: 'static>( | |
| 836 | + &mut self, | |
| 837 | + on_new: impl 'static + Fn(&mut V, &mut ViewContext<V>), | |
| 838 | + ) -> Subscription { | |
| 839 | + self.new_view_observers.insert( | |
| 840 | + TypeId::of::<V>(), | |
| 841 | + Box::new(move |any_view: AnyView, cx: &mut WindowContext| { | |
| 842 | + any_view | |
| 843 | + .downcast::<V>() | |
| 844 | + .unwrap() | |
| 845 | + .update(cx, |view_state, cx| { | |
| 846 | + on_new(view_state, cx); | |
| 847 | + }) | |
| 848 | + }), | |
| 849 | + ) | |
| 850 | + } | |
| 851 | + | |
| 831 | 852 | pub fn observe_release<E, T>( |
| 832 | 853 | &mut self, |
| 833 | 854 | handle: &E, |
| @@ -258,7 +258,7 @@ impl VisualContext for AsyncWindowContext { · 257 unmodified lines | ||
| 258 | 258 | build_view_state: impl FnOnce(&mut ViewContext<'_, V>) -> V, |
| 259 | 259 | ) -> Self::Result<View<V>> |
| 260 | 260 | where |
| 261 | − V: 'static, | |
| 261 | + V: 'static + Render, | |
| 262 | 262 | { |
| 263 | 263 | self.window |
| 264 | 264 | .update(self, |_, cx| cx.build_view(build_view_state)) |
| @@ -112,7 +112,7 @@ pub trait VisualContext: Context { · 111 unmodified lines | ||
| 112 | 112 | build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V, |
| 113 | 113 | ) -> Self::Result<View<V>> |
| 114 | 114 | where |
| 115 | − V: 'static; | |
| 115 | + V: 'static + Render; | |
| 116 | 116 | |
| 117 | 117 | fn update_view<V: 'static, R>( |
| 118 | 118 | &mut self, |
| @@ -414,10 +414,14 @@ pub trait ElementInteractivity<V: 'static>: 'static { · 413 unmodified lines | ||
| 414 | 414 | Box::new(move |_, key_down, context, phase, cx| { |
| 415 | 415 | if phase == DispatchPhase::Bubble { |
| 416 | 416 | let key_down = key_down.downcast_ref::<KeyDownEvent>().unwrap(); |
| 417 | + dbg!(key_down); | |
| 417 | 418 | if let KeyMatch::Some(action) = |
| 418 | 419 | cx.match_keystroke(&global_id, &key_down.keystroke, context) |
| 419 | 420 | { |
| 421 | + dbg!(&action); | |
| 420 | 422 | return Some(action); |
| 423 | + } else { | |
| 424 | + dbg!("none"); | |
| 421 | 425 | } |
| 422 | 426 | } |
| 423 | 427 | |
| @@ -1411,7 +1411,7 @@ impl VisualContext for WindowContext<'_> { · 1410 unmodified lines | ||
| 1411 | 1411 | build_view_state: impl FnOnce(&mut ViewContext<'_, V>) -> V, |
| 1412 | 1412 | ) -> Self::Result<View<V>> |
| 1413 | 1413 | where |
| 1414 | − V: 'static, | |
| 1414 | + V: 'static + Render, | |
| 1415 | 1415 | { |
| 1416 | 1416 | let slot = self.app.entities.reserve(); |
| 1417 | 1417 | let view = View { |
| @@ -1419,7 +1419,16 @@ impl VisualContext for WindowContext<'_> { · 1 unmodified line | ||
| 1419 | 1419 | }; |
| 1420 | 1420 | let mut cx = ViewContext::new(&mut *self.app, &mut *self.window, &view); |
| 1421 | 1421 | let entity = build_view_state(&mut cx); |
| 1422 | − self.entities.insert(slot, entity); | |
| 1422 | + cx.entities.insert(slot, entity); | |
| 1423 | + | |
| 1424 | + cx.new_view_observers | |
| 1425 | + .clone() | |
| 1426 | + .retain(&TypeId::of::<V>(), |observer| { | |
| 1427 | + let any_view = AnyView::from(view.clone()); | |
| 1428 | + (observer)(any_view, self); | |
| 1429 | + true | |
| 1430 | + }); | |
| 1431 | + | |
| 1423 | 1432 | view |
| 1424 | 1433 | } |
| 1425 | 1434 | |
| @@ -2102,7 +2111,7 @@ impl<V> Context for ViewContext<'_, V> { · 676 unmodified lines | ||
| 2102 | 2111 | } |
| 2103 | 2112 | |
| 2104 | 2113 | impl<V: 'static> VisualContext for ViewContext<'_, V> { |
| 2105 | − fn build_view<W: 'static>( | |
| 2114 | + fn build_view<W: Render + 'static>( | |
| 2106 | 2115 | &mut self, |
| 2107 | 2116 | build_view_state: impl FnOnce(&mut ViewContext<'_, W>) -> W, |
| 2108 | 2117 | ) -> Self::Result<View<W>> { |
| @@ -407,6 +407,14 @@ impl Dock { · 406 unmodified lines | ||
| 407 | 407 | // } |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | +impl Render for Dock { | |
| 411 | + type Element = Div<Self>; | |
| 412 | + | |
| 413 | + fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element { | |
| 414 | + todo!() | |
| 415 | + } | |
| 416 | +} | |
| 417 | + | |
| 410 | 418 | // todo!() |
| 411 | 419 | // impl View for Dock { |
| 412 | 420 | // fn ui_name() -> &'static str { |
| @@ -1,25 +1,15 @@ | ||
| 1 | 1 | use crate::Workspace; |
| 2 | 2 | use gpui::{ |
| 3 | − div, px, AnyView, AppContext, Component, Div, EventEmitter, ParentElement, Render, | |
| 4 | − StatelessInteractive, Styled, Subscription, View, ViewContext, WeakView, | |
| 3 | + div, px, AnyView, Component, Div, EventEmitter, ParentElement, Render, StatelessInteractive, | |
| 4 | + Styled, Subscription, View, ViewContext, | |
| 5 | 5 | }; |
| 6 | 6 | use std::{any::TypeId, sync::Arc}; |
| 7 | 7 | use ui::v_stack; |
| 8 | 8 | |
| 9 | −pub struct ModalRegistry { | |
| 10 | − registered_modals: Vec<(TypeId, Box<dyn Fn(Div<Workspace>) -> Div<Workspace>>)>, | |
| 11 | −} | |
| 12 | − | |
| 13 | 9 | pub struct ModalLayer { |
| 14 | − workspace: WeakView<Workspace>, | |
| 15 | 10 | open_modal: Option<AnyView>, |
| 16 | 11 | subscription: Option<Subscription>, |
| 17 | −} | |
| 18 | − | |
| 19 | −pub fn init_modal_registry(cx: &mut AppContext) { | |
| 20 | − cx.set_global(ModalRegistry { | |
| 21 | − registered_modals: Vec::new(), | |
| 22 | − }); | |
| 12 | + registered_modals: Vec<(TypeId, Box<dyn Fn(Div<Workspace>) -> Div<Workspace>>)>, | |
| 23 | 13 | } |
| 24 | 14 | |
| 25 | 15 | pub enum ModalEvent { |
| @@ -30,7 +20,15 @@ pub trait Modal: EventEmitter + Render { · 4 unmodified lines | ||
| 30 | 20 | fn to_modal_event(&self, _: &Self::Event) -> Option<ModalEvent>; |
| 31 | 21 | } |
| 32 | 22 | |
| 33 | −impl ModalRegistry { | |
| 23 | +impl ModalLayer { | |
| 24 | + pub fn new() -> Self { | |
| 25 | + Self { | |
| 26 | + open_modal: None, | |
| 27 | + subscription: None, | |
| 28 | + registered_modals: Vec::new(), | |
| 29 | + } | |
| 30 | + } | |
| 31 | + | |
| 34 | 32 | pub fn register_modal<A: 'static, V, B>(&mut self, action: A, build_view: B) |
| 35 | 33 | where |
| 36 | 34 | V: Modal, |
| @@ -44,32 +42,19 @@ impl ModalRegistry { · 7 unmodified lines | ||
| 44 | 42 | let build_view = build_view.clone(); |
| 45 | 43 | |
| 46 | 44 | div.on_action(move |workspace, event: &A, cx| { |
| 47 | − let Some(new_modal) = | |
| 48 | − (build_view)(workspace, cx) else { | |
| 49 | − return | |
| 50 | − }; | |
| 51 | − workspace.modal_layer.update(cx, |modal_layer, cx| { | |
| 52 | − modal_layer.show_modal(new_modal, cx); | |
| 53 | − }) | |
| 45 | + let Some(new_modal) = (build_view)(workspace, cx) else { | |
| 46 | + return; | |
| 47 | + }; | |
| 48 | + workspace.modal_layer().show_modal(new_modal, cx); | |
| 54 | 49 | }) |
| 55 | 50 | }), |
| 56 | 51 | )); |
| 57 | 52 | } |
| 58 | −} | |
| 59 | − | |
| 60 | −impl ModalLayer { | |
| 61 | − pub fn new(workspace: WeakView<Workspace>) -> Self { | |
| 62 | − Self { | |
| 63 | − workspace, | |
| 64 | − open_modal: None, | |
| 65 | − subscription: None, | |
| 66 | − } | |
| 67 | − } | |
| 68 | 53 | |
| 69 | − pub fn show_modal<V: Modal>(&mut self, new_modal: View<V>, cx: &mut ViewContext<Self>) { | |
| 54 | + pub fn show_modal<V: Modal>(&mut self, new_modal: View<V>, cx: &mut ViewContext<Workspace>) { | |
| 70 | 55 | self.subscription = Some(cx.subscribe(&new_modal, |this, modal, e, cx| { |
| 71 | 56 | match modal.read(cx).to_modal_event(e) { |
| 72 | − Some(ModalEvent::Dismissed) => this.hide_modal(cx), | |
| 57 | + Some(ModalEvent::Dismissed) => this.modal_layer().hide_modal(cx), | |
| 73 | 58 | None => {} |
| 74 | 59 | } |
| 75 | 60 | })); |
| @@ -77,16 +62,16 @@ impl ModalLayer { · 1 unmodified line | ||
| 77 | 62 | cx.notify(); |
| 78 | 63 | } |
| 79 | 64 | |
| 80 | − pub fn hide_modal(&mut self, cx: &mut ViewContext<Self>) { | |
| 65 | + pub fn hide_modal(&mut self, cx: &mut ViewContext<Workspace>) { | |
| 81 | 66 | self.open_modal.take(); |
| 82 | 67 | self.subscription.take(); |
| 83 | 68 | cx.notify(); |
| 84 | 69 | } |
| 85 | 70 | |
| 86 | − pub fn render(&self, cx: &ViewContext<Workspace>) -> Div<Workspace> { | |
| 71 | + pub fn wrapper_element(&self, cx: &ViewContext<Workspace>) -> Div<Workspace> { | |
| 87 | 72 | let mut parent = div().relative().size_full(); |
| 88 | 73 | |
| 89 | − for (_, action) in cx.global::<ModalRegistry>().registered_modals.iter() { | |
| 74 | + for (_, action) in self.registered_modals.iter() { | |
| 90 | 75 | parent = (action)(parent); |
| 91 | 76 | } |
| 92 | 77 | |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | use crate::ItemHandle; |
| 2 | 2 | use gpui::{ |
| 3 | − AnyView, AppContext, Entity, EntityId, EventEmitter, Render, View, ViewContext, WindowContext, | |
| 3 | + AnyView, AppContext, Div, Entity, EntityId, EventEmitter, Render, View, ViewContext, | |
| 4 | + WindowContext, | |
| 4 | 5 | }; |
| 5 | 6 | |
| 6 | 7 | pub trait ToolbarItemView: Render + EventEmitter { |
| @@ -56,6 +57,14 @@ pub struct Toolbar { · 49 unmodified lines | ||
| 56 | 57 | items: Vec<(Box<dyn ToolbarItemViewHandle>, ToolbarItemLocation)>, |
| 57 | 58 | } |
| 58 | 59 | |
| 60 | +impl Render for Toolbar { | |
| 61 | + type Element = Div<Self>; | |
| 62 | + | |
| 63 | + fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element { | |
| 64 | + todo!() | |
| 65 | + } | |
| 66 | +} | |
| 67 | + | |
| 59 | 68 | // todo!() |
| 60 | 69 | // impl View for Toolbar { |
| 61 | 70 | // fn ui_name() -> &'static str { |
| @@ -37,10 +37,10 @@ use futures::{ · 36 unmodified lines | ||
| 37 | 37 | }; |
| 38 | 38 | use gpui::{ |
| 39 | 39 | div, point, size, AnyModel, AnyView, AnyWeakView, AppContext, AsyncAppContext, |
| 40 | − AsyncWindowContext, Bounds, Component, Div, Entity, EntityId, EventEmitter, FocusHandle, | |
| 41 | − GlobalPixels, Model, ModelContext, ParentElement, Point, Render, Size, StatefulInteractive, | |
| 42 | − Styled, Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowBounds, | |
| 43 | − WindowContext, WindowHandle, WindowOptions, | |
| 40 | + AsyncWindowContext, Bounds, Component, Context, Div, Entity, EntityId, EventEmitter, | |
| 41 | + FocusHandle, GlobalPixels, Model, ModelContext, ParentElement, Point, Render, Size, | |
| 42 | + StatefulInteractive, Styled, Subscription, Task, View, ViewContext, VisualContext, WeakView, | |
| 43 | + WindowBounds, WindowContext, WindowHandle, WindowOptions, | |
| 44 | 44 | }; |
| 45 | 45 | use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem}; |
| 46 | 46 | use itertools::Itertools; |
| @@ -225,7 +225,6 @@ pub fn init_settings(cx: &mut AppContext) { · 178 unmodified lines | ||
| 225 | 225 | |
| 226 | 226 | pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) { |
| 227 | 227 | init_settings(cx); |
| 228 | − init_modal_registry(cx); | |
| 229 | 228 | pane::init(cx); |
| 230 | 229 | notifications::init(cx); |
| 231 | 230 | |
| @@ -545,7 +544,7 @@ pub struct Workspace { · 313 unmodified lines | ||
| 545 | 544 | last_active_center_pane: Option<WeakView<Pane>>, |
| 546 | 545 | last_active_view_id: Option<proto::ViewId>, |
| 547 | 546 | status_bar: View<StatusBar>, |
| 548 | − modal_layer: View<ModalLayer>, | |
| 547 | + modal_layer: ModalLayer, | |
| 549 | 548 | // titlebar_item: Option<AnyViewHandle>, |
| 550 | 549 | notifications: Vec<(TypeId, usize, Box<dyn NotificationHandle>)>, |
| 551 | 550 | project: Model<Project>, |
| @@ -697,7 +696,7 @@ impl Workspace { · 145 unmodified lines | ||
| 697 | 696 | }); |
| 698 | 697 | |
| 699 | 698 | let workspace_handle = cx.view().downgrade(); |
| 700 | − let modal_layer = cx.build_view(|cx| ModalLayer::new(workspace_handle)); | |
| 699 | + let modal_layer = ModalLayer::new(); | |
| 701 | 700 | |
| 702 | 701 | // todo!() |
| 703 | 702 | // cx.update_default_global::<DragAndDrop<Workspace>, _, _>(|drag_and_drop, _| { |
| @@ -781,6 +780,10 @@ impl Workspace { · 77 unmodified lines | ||
| 781 | 780 | } |
| 782 | 781 | } |
| 783 | 782 | |
| 783 | + pub fn modal_layer(&mut self) -> &mut ModalLayer { | |
| 784 | + &mut self.modal_layer | |
| 785 | + } | |
| 786 | + | |
| 784 | 787 | fn new_local( |
| 785 | 788 | abs_paths: Vec<PathBuf>, |
| 786 | 789 | app_state: Arc<AppState>, |
| @@ -3707,9 +3710,9 @@ impl Render for Workspace { · 2920 unmodified lines | ||
| 3707 | 3710 | .bg(cx.theme().colors().background) |
| 3708 | 3711 | .child(self.render_titlebar(cx)) |
| 3709 | 3712 | .child( |
| 3713 | + // todo! should this be a component a view? | |
| 3710 | 3714 | self.modal_layer |
| 3711 | − .read(cx) | |
| 3712 | − .render(cx) | |
| 3715 | + .wrapper_element(cx) | |
| 3713 | 3716 | .relative() |
| 3714 | 3717 | .flex_1() |
| 3715 | 3718 | .w_full() |