History

Refactor GoToLine to use cx.observe_new_views()

Conrad Irwin committed 3 years ago

Commit 1b9f76c1 parent cbdd4ac11 files · +137 −66Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t