Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kayak UI 0.11
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Forks
Kayak UI 0.11
Commits
3aa6a251
Commit
3aa6a251
authored
3 years ago
by
MrGVSV
Browse files
Options
Downloads
Patches
Plain Diff
Updated get_nodes_under method to be more generic
parent
d64cb0e5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
kayak_core/src/context.rs
+4
-4
4 additions, 4 deletions
kayak_core/src/context.rs
kayak_core/src/cursor.rs
+1
-1
1 addition, 1 deletion
kayak_core/src/cursor.rs
kayak_core/src/widget_manager.rs
+9
-6
9 additions, 6 deletions
kayak_core/src/widget_manager.rs
with
14 additions
and
11 deletions
kayak_core/src/context.rs
+
4
−
4
View file @
3aa6a251
...
...
@@ -360,7 +360,7 @@ impl KayakContext {
match
input_event
{
InputEvent
::
MouseMoved
(
point
)
=>
{
if
let
Some
((
next
,
next_nodes
))
=
self
.widget_manager
.get_nodes_under
(
*
point
,
None
)
{
if
let
Some
((
next
,
next_nodes
))
=
self
.widget_manager
.get_nodes_under
(
*
point
,
None
,
true
)
{
event_stream
.push
(
Event
::
new
(
next
,
EventType
::
Hover
));
// Mouse In - Applies to all matching nodes
...
...
@@ -373,7 +373,7 @@ impl KayakContext {
}
}
if
let
Some
((
..
,
prev_nodes
))
=
self
.widget_manager
.get_nodes_under
(
self
.last_mouse_position
,
None
)
{
if
let
Some
((
..
,
prev_nodes
))
=
self
.widget_manager
.get_nodes_under
(
self
.last_mouse_position
,
None
,
true
)
{
// Mouse Out - Applies to all matching nodes
for
prev
in
prev_nodes
{
if
let
Some
(
rect
)
=
self
.widget_manager.layout_cache.rect
.get
(
&
prev
)
{
...
...
@@ -391,7 +391,7 @@ impl KayakContext {
// Reset global mouse pressed
self
.is_mouse_pressed
=
true
;
if
let
Some
((
prev
,
..
))
=
self
.widget_manager
.get_nodes_under
(
self
.last_mouse_position
,
None
)
{
if
let
Some
((
prev
,
..
))
=
self
.widget_manager
.get_nodes_under
(
self
.last_mouse_position
,
None
,
true
)
{
event_stream
.push
(
Event
::
new
(
prev
,
EventType
::
MouseDown
));
// Find a focusable widget in the hierarchy
...
...
@@ -427,7 +427,7 @@ impl KayakContext {
// Reset global mouse pressed
self
.is_mouse_pressed
=
false
;
if
let
Some
((
prev
,
..
))
=
self
.widget_manager
.get_nodes_under
(
self
.last_mouse_position
,
None
)
{
if
let
Some
((
prev
,
..
))
=
self
.widget_manager
.get_nodes_under
(
self
.last_mouse_position
,
None
,
true
)
{
event_stream
.push
(
Event
::
new
(
prev
,
EventType
::
MouseUp
));
if
Self
::
contains_event
(
...
...
This diff is collapsed.
Click to expand it.
kayak_core/src/cursor.rs
+
1
−
1
View file @
3aa6a251
...
...
@@ -15,4 +15,4 @@ impl Default for PointerEvents {
fn
default
()
->
Self
{
Self
::
All
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
kayak_core/src/widget_manager.rs
+
9
−
6
View file @
3aa6a251
...
...
@@ -395,8 +395,9 @@ impl WidgetManager {
///
/// * `position`: The 2D point to check under
/// * `parent`: The parent to start at (or `None` for the root element)
/// * `respect_pointer_events`: Whether a widget's `pointer_events` style should be respected
///
pub
fn
get_nodes_under
(
&
self
,
position
:
(
f32
,
f32
),
parent
:
Option
<
Index
>
)
->
Option
<
(
Index
,
Vec
<
Index
>
)
>
{
pub
fn
get_nodes_under
(
&
self
,
position
:
(
f32
,
f32
),
parent
:
Option
<
Index
>
,
respect_pointer_events
:
bool
)
->
Option
<
(
Index
,
Vec
<
Index
>
)
>
{
// TODO: Find a more efficient way of finding a node at a given point
// The main issue with recursively checking if a node contains the point is that we cannot be sure
...
...
@@ -426,9 +427,11 @@ impl WidgetManager {
while
stack
.len
()
>
0
{
let
(
parent
,
nest_level
)
=
stack
.pop
()
.unwrap
();
let
mut
pointer_events
=
PointerEvents
::
default
();
if
let
Some
(
widget
)
=
self
.current_widgets
.get
(
parent
)
.unwrap
()
{
if
let
Some
(
styles
)
=
widget
.get_styles
()
{
pointer_events
=
styles
.pointer_events
.resolve
();
if
respect_pointer_events
{
if
let
Some
(
widget
)
=
self
.current_widgets
.get
(
parent
)
.unwrap
()
{
if
let
Some
(
styles
)
=
widget
.get_styles
()
{
pointer_events
=
styles
.pointer_events
.resolve
();
}
}
}
...
...
@@ -472,7 +475,7 @@ impl WidgetManager {
/// Get the "best match" node at the given position
#[allow(dead_code)]
pub
fn
get_node_at
(
&
self
,
position
:
(
f32
,
f32
),
parent
:
Option
<
Index
>
)
->
Option
<
Index
>
{
Some
(
self
.get_nodes_under
(
position
,
parent
)
?
.0
)
pub
fn
get_node_at
(
&
self
,
position
:
(
f32
,
f32
),
parent
:
Option
<
Index
>
,
respect_pointer_events
:
bool
)
->
Option
<
Index
>
{
Some
(
self
.get_nodes_under
(
position
,
parent
,
respect_pointer_events
)
?
.0
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment