Finished merge of drag update
This commit is contained in:
commit
ca877245be
15 changed files with 306 additions and 279 deletions
|
@ -1,6 +1,7 @@
|
|||
use crate::{
|
||||
geometry::vector::Vector2F, CursorRegion, DebugContext, Element, ElementBox, Event,
|
||||
EventContext, LayoutContext, MouseRegion, NavigationDirection, PaintContext, SizeConstraint,
|
||||
EventContext, LayoutContext, MouseButton, MouseEvent, MouseRegion, NavigationDirection,
|
||||
PaintContext, SizeConstraint,
|
||||
};
|
||||
use pathfinder_geometry::rect::RectF;
|
||||
use serde_json::json;
|
||||
|
@ -116,7 +117,11 @@ impl Element for EventHandler {
|
|||
true
|
||||
} else {
|
||||
match event {
|
||||
Event::LeftMouseDown { position, .. } => {
|
||||
Event::MouseDown(MouseEvent {
|
||||
button: MouseButton::Left,
|
||||
position,
|
||||
..
|
||||
}) => {
|
||||
if let Some(callback) = self.mouse_down.as_mut() {
|
||||
if visible_bounds.contains_point(*position) {
|
||||
return callback(cx);
|
||||
|
@ -124,7 +129,11 @@ impl Element for EventHandler {
|
|||
}
|
||||
false
|
||||
}
|
||||
Event::RightMouseDown { position, .. } => {
|
||||
Event::MouseDown(MouseEvent {
|
||||
button: MouseButton::Right,
|
||||
position,
|
||||
..
|
||||
}) => {
|
||||
if let Some(callback) = self.right_mouse_down.as_mut() {
|
||||
if visible_bounds.contains_point(*position) {
|
||||
return callback(cx);
|
||||
|
@ -132,11 +141,11 @@ impl Element for EventHandler {
|
|||
}
|
||||
false
|
||||
}
|
||||
Event::NavigateMouseDown {
|
||||
Event::MouseDown(MouseEvent {
|
||||
button: MouseButton::Navigate(direction),
|
||||
position,
|
||||
direction,
|
||||
..
|
||||
} => {
|
||||
}) => {
|
||||
if let Some(callback) = self.navigate_mouse_down.as_mut() {
|
||||
if visible_bounds.contains_point(*position) {
|
||||
return callback(*direction, cx);
|
||||
|
|
|
@ -3,7 +3,8 @@ use std::{any::Any, f32::INFINITY};
|
|||
use crate::{
|
||||
json::{self, ToJson, Value},
|
||||
Axis, DebugContext, Element, ElementBox, ElementStateHandle, Event, EventContext,
|
||||
LayoutContext, PaintContext, RenderContext, SizeConstraint, Vector2FExt, View,
|
||||
LayoutContext, MouseMovedEvent, PaintContext, RenderContext, ScrollWheelEvent, SizeConstraint,
|
||||
Vector2FExt, View,
|
||||
};
|
||||
use pathfinder_geometry::{
|
||||
rect::RectF,
|
||||
|
@ -287,11 +288,11 @@ impl Element for Flex {
|
|||
handled = child.dispatch_event(event, cx) || handled;
|
||||
}
|
||||
if !handled {
|
||||
if let &Event::ScrollWheel {
|
||||
if let &Event::ScrollWheel(ScrollWheelEvent {
|
||||
position,
|
||||
delta,
|
||||
precise,
|
||||
} = event
|
||||
}) = event
|
||||
{
|
||||
if *remaining_space < 0. && bounds.contains_point(position) {
|
||||
if let Some(scroll_state) = self.scroll_state.as_ref() {
|
||||
|
@ -321,7 +322,7 @@ impl Element for Flex {
|
|||
}
|
||||
|
||||
if !handled {
|
||||
if let &Event::MouseMoved { position, .. } = event {
|
||||
if let &Event::MouseMoved(MouseMovedEvent { position, .. }) = event {
|
||||
// If this is a scrollable flex, and the mouse is over it, eat the scroll event to prevent
|
||||
// propogating it to the element below.
|
||||
if self.scroll_state.is_some() && bounds.contains_point(position) {
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
},
|
||||
json::json,
|
||||
DebugContext, Element, ElementBox, ElementRc, Event, EventContext, LayoutContext, PaintContext,
|
||||
RenderContext, SizeConstraint, View, ViewContext,
|
||||
RenderContext, ScrollWheelEvent, SizeConstraint, View, ViewContext,
|
||||
};
|
||||
use std::{cell::RefCell, collections::VecDeque, ops::Range, rc::Rc};
|
||||
use sum_tree::{Bias, SumTree};
|
||||
|
@ -311,11 +311,11 @@ impl Element for List {
|
|||
state.items = new_items;
|
||||
|
||||
match event {
|
||||
Event::ScrollWheel {
|
||||
Event::ScrollWheel(ScrollWheelEvent {
|
||||
position,
|
||||
delta,
|
||||
precise,
|
||||
} => {
|
||||
}) => {
|
||||
if bounds.contains_point(*position) {
|
||||
if state.scroll(scroll_top, bounds.height(), *delta, *precise, cx) {
|
||||
handled = true;
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
vector::{vec2f, Vector2F},
|
||||
},
|
||||
json::{self, json},
|
||||
ElementBox, RenderContext, View,
|
||||
ElementBox, RenderContext, ScrollWheelEvent, View,
|
||||
};
|
||||
use json::ToJson;
|
||||
use std::{cell::RefCell, cmp, ops::Range, rc::Rc};
|
||||
|
@ -310,11 +310,11 @@ impl Element for UniformList {
|
|||
}
|
||||
|
||||
match event {
|
||||
Event::ScrollWheel {
|
||||
Event::ScrollWheel(ScrollWheelEvent {
|
||||
position,
|
||||
delta,
|
||||
precise,
|
||||
} => {
|
||||
}) => {
|
||||
if bounds.contains_point(*position) {
|
||||
if self.scroll(*position, *delta, *precise, layout.scroll_max, cx) {
|
||||
handled = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue