mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Don't allocate interactive bounds
This commit is contained in:
parent
1ae25f52a1
commit
0d30b698a4
@ -748,10 +748,10 @@ impl Interactivity {
|
||||
cx.with_z_index(style.z_index.unwrap_or(0), |cx| cx.add_opaque_layer(bounds))
|
||||
}
|
||||
|
||||
let interactive_bounds = Rc::new(InteractiveBounds {
|
||||
let interactive_bounds = InteractiveBounds {
|
||||
bounds: bounds.intersect(&cx.content_mask().bounds),
|
||||
stacking_order: cx.stacking_order().clone(),
|
||||
});
|
||||
};
|
||||
|
||||
if let Some(mouse_cursor) = style.mouse_cursor {
|
||||
let mouse_position = &cx.mouse_position();
|
||||
@ -784,28 +784,28 @@ impl Interactivity {
|
||||
for listener in self.mouse_down_listeners {
|
||||
let interactive_bounds = interactive_bounds.clone();
|
||||
cx.on_mouse_event(move |event: &MouseDownEvent, phase, cx| {
|
||||
listener(event, &*interactive_bounds, phase, cx);
|
||||
listener(event, &interactive_bounds, phase, cx);
|
||||
})
|
||||
}
|
||||
|
||||
for listener in self.mouse_up_listeners {
|
||||
let interactive_bounds = interactive_bounds.clone();
|
||||
cx.on_mouse_event(move |event: &MouseUpEvent, phase, cx| {
|
||||
listener(event, &*interactive_bounds, phase, cx);
|
||||
listener(event, &interactive_bounds, phase, cx);
|
||||
})
|
||||
}
|
||||
|
||||
for listener in self.mouse_move_listeners {
|
||||
let interactive_bounds = interactive_bounds.clone();
|
||||
cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {
|
||||
listener(event, &*interactive_bounds, phase, cx);
|
||||
listener(event, &interactive_bounds, phase, cx);
|
||||
})
|
||||
}
|
||||
|
||||
for listener in self.scroll_wheel_listeners {
|
||||
let interactive_bounds = interactive_bounds.clone();
|
||||
cx.on_mouse_event(move |event: &ScrollWheelEvent, phase, cx| {
|
||||
listener(event, &*interactive_bounds, phase, cx);
|
||||
listener(event, &interactive_bounds, phase, cx);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -46,29 +46,17 @@ const ACTIVE_DRAG_Z_INDEX: u8 = 1;
|
||||
pub struct StackingOrder {
|
||||
#[deref]
|
||||
#[deref_mut]
|
||||
z_indices: Arc<SmallVec<[u8; 8]>>,
|
||||
z_indices: SmallVec<[u8; 32]>,
|
||||
}
|
||||
|
||||
impl Default for StackingOrder {
|
||||
fn default() -> Self {
|
||||
StackingOrder {
|
||||
z_indices: Arc::new(SmallVec::new()),
|
||||
z_indices: SmallVec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StackingOrder {
|
||||
/// Pushes a new z-index onto the stacking order.
|
||||
pub fn push(&mut self, z_index: u8) {
|
||||
Arc::make_mut(&mut self.z_indices).push(z_index);
|
||||
}
|
||||
|
||||
/// Pops the last z-index off the stacking order.
|
||||
pub fn pop(&mut self) {
|
||||
Arc::make_mut(&mut self.z_indices).pop();
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the two different phases when dispatching events.
|
||||
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum DispatchPhase {
|
||||
|
Loading…
Reference in New Issue
Block a user