Replace WindowContext::notify
with WindowContext::refresh
This commit is contained in:
parent
d0c101cb6e
commit
2923b71f83
11 changed files with 35 additions and 30 deletions
|
@ -109,7 +109,7 @@ impl CopilotCodeVerification {
|
||||||
let user_code = data.user_code.clone();
|
let user_code = data.user_code.clone();
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
cx.write_to_clipboard(ClipboardItem::new(user_code.clone()));
|
cx.write_to_clipboard(ClipboardItem::new(user_code.clone()));
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.child(Label::new(data.user_code.clone()))
|
.child(Label::new(data.user_code.clone()))
|
||||||
|
|
|
@ -1027,7 +1027,7 @@ impl Interactivity {
|
||||||
if e.modifiers.command != command_held
|
if e.modifiers.command != command_held
|
||||||
&& text_bounds.contains(&cx.mouse_position())
|
&& text_bounds.contains(&cx.mouse_position())
|
||||||
{
|
{
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1038,7 +1038,7 @@ impl Interactivity {
|
||||||
if phase == DispatchPhase::Capture
|
if phase == DispatchPhase::Capture
|
||||||
&& bounds.contains(&event.position) != hovered
|
&& bounds.contains(&event.position) != hovered
|
||||||
{
|
{
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1188,7 +1188,7 @@ impl Interactivity {
|
||||||
if phase == DispatchPhase::Capture
|
if phase == DispatchPhase::Capture
|
||||||
&& group_bounds.contains(&event.position) != hovered
|
&& group_bounds.contains(&event.position) != hovered
|
||||||
{
|
{
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1203,7 +1203,7 @@ impl Interactivity {
|
||||||
if phase == DispatchPhase::Capture
|
if phase == DispatchPhase::Capture
|
||||||
&& bounds.contains(&event.position) != hovered
|
&& bounds.contains(&event.position) != hovered
|
||||||
{
|
{
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1237,7 +1237,7 @@ impl Interactivity {
|
||||||
|
|
||||||
if can_drop {
|
if can_drop {
|
||||||
listener(drag.value.as_ref(), cx);
|
listener(drag.value.as_ref(), cx);
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
cx.stop_propagation();
|
cx.stop_propagation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1268,7 +1268,7 @@ impl Interactivity {
|
||||||
&& interactive_bounds.visibly_contains(&event.position, cx)
|
&& interactive_bounds.visibly_contains(&event.position, cx)
|
||||||
{
|
{
|
||||||
*pending_mouse_down.borrow_mut() = Some(event.clone());
|
*pending_mouse_down.borrow_mut() = Some(event.clone());
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1299,7 +1299,7 @@ impl Interactivity {
|
||||||
cursor_offset,
|
cursor_offset,
|
||||||
});
|
});
|
||||||
pending_mouse_down.take();
|
pending_mouse_down.take();
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
cx.stop_propagation();
|
cx.stop_propagation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1319,7 +1319,7 @@ impl Interactivity {
|
||||||
pending_mouse_down.borrow_mut();
|
pending_mouse_down.borrow_mut();
|
||||||
if pending_mouse_down.is_some() {
|
if pending_mouse_down.is_some() {
|
||||||
captured_mouse_down = pending_mouse_down.take();
|
captured_mouse_down = pending_mouse_down.take();
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fire click handlers during the bubble phase.
|
// Fire click handlers during the bubble phase.
|
||||||
|
@ -1413,7 +1413,7 @@ impl Interactivity {
|
||||||
_task: None,
|
_task: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
@ -1453,7 +1453,7 @@ impl Interactivity {
|
||||||
cx.on_mouse_event(move |_: &MouseUpEvent, phase, cx| {
|
cx.on_mouse_event(move |_: &MouseUpEvent, phase, cx| {
|
||||||
if phase == DispatchPhase::Capture {
|
if phase == DispatchPhase::Capture {
|
||||||
*active_state.borrow_mut() = ElementClickedState::default();
|
*active_state.borrow_mut() = ElementClickedState::default();
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -1471,7 +1471,7 @@ impl Interactivity {
|
||||||
if group || element {
|
if group || element {
|
||||||
*active_state.borrow_mut() =
|
*active_state.borrow_mut() =
|
||||||
ElementClickedState { group, element };
|
ElementClickedState { group, element };
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1531,7 +1531,7 @@ impl Interactivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if *scroll_offset != old_scroll_offset {
|
if *scroll_offset != old_scroll_offset {
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
cx.stop_propagation();
|
cx.stop_propagation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ impl Element for Img {
|
||||||
} else {
|
} else {
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
if image_future.await.ok().is_some() {
|
if image_future.await.ok().is_some() {
|
||||||
cx.on_next_frame(|cx| cx.notify());
|
cx.on_next_frame(|cx| cx.refresh());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
|
@ -258,7 +258,7 @@ impl StateInner {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn logical_scroll_top(&self) -> ListOffset {
|
fn logical_scroll_top(&self) -> ListOffset {
|
||||||
|
|
|
@ -389,7 +389,7 @@ impl Element for InteractiveText {
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse_down.take();
|
mouse_down.take();
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -399,7 +399,7 @@ impl Element for InteractiveText {
|
||||||
text_state.index_for_position(bounds, event.position)
|
text_state.index_for_position(bounds, event.position)
|
||||||
{
|
{
|
||||||
mouse_down.set(Some(mouse_down_index));
|
mouse_down.set(Some(mouse_down_index));
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -290,6 +290,7 @@ impl Element for AnyView {
|
||||||
&& cache_key.stacking_order == *cx.stacking_order()
|
&& cache_key.stacking_order == *cx.stacking_order()
|
||||||
&& cache_key.text_style == cx.text_style()
|
&& cache_key.text_style == cx.text_style()
|
||||||
&& !cx.window.dirty_views.contains(&self.entity_id())
|
&& !cx.window.dirty_views.contains(&self.entity_id())
|
||||||
|
&& !cx.window.refreshing
|
||||||
{
|
{
|
||||||
cx.reuse_geometry();
|
cx.reuse_geometry();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -269,6 +269,7 @@ pub struct Window {
|
||||||
bounds_observers: SubscriberSet<(), AnyObserver>,
|
bounds_observers: SubscriberSet<(), AnyObserver>,
|
||||||
active: bool,
|
active: bool,
|
||||||
pub(crate) dirty: bool,
|
pub(crate) dirty: bool,
|
||||||
|
pub(crate) refreshing: bool,
|
||||||
pub(crate) drawing: bool,
|
pub(crate) drawing: bool,
|
||||||
activation_observers: SubscriberSet<(), AnyObserver>,
|
activation_observers: SubscriberSet<(), AnyObserver>,
|
||||||
pub(crate) focus: Option<FocusId>,
|
pub(crate) focus: Option<FocusId>,
|
||||||
|
@ -424,6 +425,7 @@ impl Window {
|
||||||
bounds_observers: SubscriberSet::new(),
|
bounds_observers: SubscriberSet::new(),
|
||||||
active: false,
|
active: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
|
refreshing: false,
|
||||||
drawing: false,
|
drawing: false,
|
||||||
activation_observers: SubscriberSet::new(),
|
activation_observers: SubscriberSet::new(),
|
||||||
focus: None,
|
focus: None,
|
||||||
|
@ -478,8 +480,9 @@ impl<'a> WindowContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark the window as dirty, scheduling it to be redrawn on the next frame.
|
/// Mark the window as dirty, scheduling it to be redrawn on the next frame.
|
||||||
pub fn notify(&mut self) {
|
pub fn refresh(&mut self) {
|
||||||
if !self.window.drawing {
|
if !self.window.drawing {
|
||||||
|
self.window.refreshing = true;
|
||||||
self.window.dirty = true;
|
self.window.dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -519,7 +522,7 @@ impl<'a> WindowContext<'a> {
|
||||||
self.window.focus_invalidated = true;
|
self.window.focus_invalidated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.notify();
|
self.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove focus from all elements within this context's window.
|
/// Remove focus from all elements within this context's window.
|
||||||
|
@ -529,7 +532,7 @@ impl<'a> WindowContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.window.focus = None;
|
self.window.focus = None;
|
||||||
self.notify();
|
self.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disable_focus(&mut self) {
|
pub fn disable_focus(&mut self) {
|
||||||
|
@ -795,7 +798,7 @@ impl<'a> WindowContext<'a> {
|
||||||
self.window.viewport_size = self.window.platform_window.content_size();
|
self.window.viewport_size = self.window.platform_window.content_size();
|
||||||
self.window.bounds = self.window.platform_window.bounds();
|
self.window.bounds = self.window.platform_window.bounds();
|
||||||
self.window.display_id = self.window.platform_window.display().id();
|
self.window.display_id = self.window.platform_window.display().id();
|
||||||
self.notify();
|
self.refresh();
|
||||||
|
|
||||||
self.window
|
self.window
|
||||||
.bounds_observers
|
.bounds_observers
|
||||||
|
@ -1499,6 +1502,7 @@ impl<'a> WindowContext<'a> {
|
||||||
self.platform.set_cursor_style(cursor_style);
|
self.platform.set_cursor_style(cursor_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.window.refreshing = false;
|
||||||
self.window.drawing = false;
|
self.window.drawing = false;
|
||||||
ELEMENT_ARENA.with_borrow_mut(|element_arena| element_arena.clear());
|
ELEMENT_ARENA.with_borrow_mut(|element_arena| element_arena.clear());
|
||||||
|
|
||||||
|
@ -1641,12 +1645,12 @@ impl<'a> WindowContext<'a> {
|
||||||
if event.is::<MouseMoveEvent>() {
|
if event.is::<MouseMoveEvent>() {
|
||||||
// If this was a mouse move event, redraw the window so that the
|
// If this was a mouse move event, redraw the window so that the
|
||||||
// active drag can follow the mouse cursor.
|
// active drag can follow the mouse cursor.
|
||||||
self.notify();
|
self.refresh();
|
||||||
} else if event.is::<MouseUpEvent>() {
|
} else if event.is::<MouseUpEvent>() {
|
||||||
// If this was a mouse up event, cancel the active drag and redraw
|
// If this was a mouse up event, cancel the active drag and redraw
|
||||||
// the window.
|
// the window.
|
||||||
self.active_drag = None;
|
self.active_drag = None;
|
||||||
self.notify();
|
self.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2169,7 +2173,7 @@ impl VisualContext for WindowContext<'_> {
|
||||||
{
|
{
|
||||||
let view = self.new_view(build_view);
|
let view = self.new_view(build_view);
|
||||||
self.window.root_view = Some(view.clone().into());
|
self.window.root_view = Some(view.clone().into());
|
||||||
self.notify();
|
self.refresh();
|
||||||
view
|
view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2583,7 +2587,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.window.drawing {
|
if !self.window.drawing {
|
||||||
self.window_cx.notify();
|
self.window_cx.window.dirty = true;
|
||||||
self.window_cx.app.push_effect(Effect::Notify {
|
self.window_cx.app.push_effect(Effect::Notify {
|
||||||
emitter: self.view.model.entity_id,
|
emitter: self.view.model.entity_id,
|
||||||
});
|
});
|
||||||
|
|
|
@ -584,7 +584,7 @@ impl TerminalElement {
|
||||||
this.update(cx, |term, _| term.try_modifiers_change(&event.modifiers));
|
this.update(cx, |term, _| term.try_modifiers_change(&event.modifiers));
|
||||||
|
|
||||||
if handled {
|
if handled {
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl<M: ManagedView> PopoverMenu<M> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*menu2.borrow_mut() = None;
|
*menu2.borrow_mut() = None;
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
cx.focus_view(&new_menu);
|
cx.focus_view(&new_menu);
|
||||||
|
|
|
@ -153,7 +153,7 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*menu2.borrow_mut() = None;
|
*menu2.borrow_mut() = None;
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
cx.focus_view(&new_menu);
|
cx.focus_view(&new_menu);
|
||||||
|
@ -166,7 +166,7 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
|
||||||
} else {
|
} else {
|
||||||
cx.mouse_position()
|
cx.mouse_position()
|
||||||
};
|
};
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,7 +698,7 @@ mod element {
|
||||||
|
|
||||||
// todo!(schedule serialize)
|
// todo!(schedule serialize)
|
||||||
// workspace.schedule_serialize(cx);
|
// workspace.schedule_serialize(cx);
|
||||||
cx.notify();
|
cx.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_handle(
|
fn push_handle(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue