mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Fix bounds calculations
This commit is contained in:
parent
7738867639
commit
713d72942d
@ -118,7 +118,6 @@ impl<V: 'static> Div<V> {
|
||||
})
|
||||
}
|
||||
|
||||
let bounds = layout.bounds;
|
||||
let pressed = Cell::new(hovered && cx.is_mouse_down(MouseButton::Left));
|
||||
cx.on_event(layout.order, move |_, event: &MouseButtonEvent, _| {
|
||||
if bounds.contains_point(event.position) {
|
||||
|
@ -63,15 +63,14 @@ impl<V: 'static, E: Element<V> + Styleable> Element<V> for Hoverable<E> {
|
||||
) where
|
||||
Self: Sized,
|
||||
{
|
||||
self.hovered
|
||||
.set(layout.bounds.contains_point(cx.mouse_position()));
|
||||
let bounds = layout.bounds + parent_origin;
|
||||
self.hovered.set(bounds.contains_point(cx.mouse_position()));
|
||||
|
||||
let slot = self.cascade_slot;
|
||||
let style = self.hovered.get().then_some(self.hovered_style.clone());
|
||||
self.style_cascade().set(slot, style);
|
||||
|
||||
let hovered = self.hovered.clone();
|
||||
let bounds = layout.bounds;
|
||||
cx.on_event(layout.order, move |_view, _: &MouseMovedEvent, cx| {
|
||||
cx.bubble_event();
|
||||
if bounds.contains_point(cx.mouse_position()) != hovered.get() {
|
||||
|
@ -68,7 +68,7 @@ impl<V: 'static, E: Element<V> + Styleable> Element<V> for Pressable<E> {
|
||||
self.style_cascade().set(slot, style);
|
||||
|
||||
let pressed = self.pressed.clone();
|
||||
let bounds = layout.bounds;
|
||||
let bounds = layout.bounds + parent_origin;
|
||||
cx.on_event(layout.order, move |_view, event: &MouseButtonEvent, cx| {
|
||||
if event.is_down {
|
||||
if bounds.contains_point(event.position) {
|
||||
|
Loading…
Reference in New Issue
Block a user