Merge branch 'main' into user-timeline
This commit is contained in:
commit
d3b9eca791
50 changed files with 3076 additions and 1109 deletions
|
@ -1634,14 +1634,10 @@ impl MutableAppContext {
|
|||
pub fn default_global<T: 'static + Default>(&mut self) -> &T {
|
||||
let type_id = TypeId::of::<T>();
|
||||
self.update(|this| {
|
||||
if !this.globals.contains_key(&type_id) {
|
||||
if let Entry::Vacant(entry) = this.cx.globals.entry(type_id) {
|
||||
entry.insert(Box::new(T::default()));
|
||||
this.notify_global(type_id);
|
||||
}
|
||||
|
||||
this.cx
|
||||
.globals
|
||||
.entry(type_id)
|
||||
.or_insert_with(|| Box::new(T::default()));
|
||||
});
|
||||
self.globals.get(&type_id).unwrap().downcast_ref().unwrap()
|
||||
}
|
||||
|
|
|
@ -703,6 +703,20 @@ impl<'a> EventContext<'a> {
|
|||
self.view_stack.last().copied()
|
||||
}
|
||||
|
||||
pub fn is_parent_view_focused(&self) -> bool {
|
||||
if let Some(parent_view_id) = self.view_stack.last() {
|
||||
self.app.focused_view_id(self.window_id) == Some(*parent_view_id)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn focus_parent_view(&mut self) {
|
||||
if let Some(parent_view_id) = self.view_stack.last() {
|
||||
self.app.focus(self.window_id, Some(*parent_view_id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dispatch_any_action(&mut self, action: Box<dyn Action>) {
|
||||
self.dispatched_actions.push(DispatchDirective {
|
||||
dispatcher_view_id: self.view_stack.last().copied(),
|
||||
|
|
|
@ -164,7 +164,7 @@ impl<'a> Hash for CacheKeyRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct Line {
|
||||
layout: Arc<LineLayout>,
|
||||
style_runs: SmallVec<[(u32, Color, Underline); 32]>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue