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
a6492787
Commit
a6492787
authored
2 years ago
by
John Mitchell
Browse files
Options
Downloads
Patches
Plain Diff
Help the entity hierarchy to be a bit cleaner for `PreviousWidget`.
parent
5d4ca7a1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/context.rs
+15
-1
15 additions, 1 deletion
src/context.rs
src/widgets/scroll/scroll_context.rs
+2
-2
2 additions, 2 deletions
src/widgets/scroll/scroll_context.rs
src/widgets/window_context_provider.rs
+1
-1
1 addition, 1 deletion
src/widgets/window_context_provider.rs
with
18 additions
and
4 deletions
src/context.rs
+
15
−
1
View file @
a6492787
...
...
@@ -865,20 +865,34 @@ fn update_widget(
)
->
(
Tree
,
bool
)
{
// Check if we should update this widget
let
should_rerender
=
{
// TODO: Move the spawning to when we create the widget.
let
old_props_entity
=
if
let
Ok
(
mut
cloned_widget_entities
)
=
cloned_widget_entities
.try_write
()
{
if
let
Some
(
entity
)
=
cloned_widget_entities
.get
(
&
entity
.0
)
.cloned
()
{
let
old_parent_entity
=
if
let
Ok
(
tree
)
=
tree
.try_read
()
{
if
let
Some
(
parent_entity
)
=
tree
.get_parent
(
entity
)
{
cloned_widget_entities
.get
(
&
parent_entity
.0
)
.copied
()
}
else
{
None
}
}
else
{
None
};
if
let
Some
(
entity
)
=
cloned_widget_entities
.get
(
&
entity
.0
)
.copied
()
{
if
let
Some
(
possible_entity
)
=
world
.get_entity
(
entity
)
{
let
target
=
possible_entity
.id
();
cloned_widget_entities
.insert
(
entity
,
target
);
target
}
else
{
let
target
=
world
.spawn_empty
()
.insert
(
PreviousWidget
)
.id
();
if
let
Some
(
parent_id
)
=
old_parent_entity
{
world
.entity_mut
(
parent_id
)
.add_child
(
target
);
}
cloned_widget_entities
.insert
(
entity
,
target
);
target
}
}
else
{
let
target
=
world
.spawn_empty
()
.insert
(
PreviousWidget
)
.id
();
if
let
Some
(
parent_id
)
=
old_parent_entity
{
world
.entity_mut
(
parent_id
)
.add_child
(
target
);
}
cloned_widget_entities
.insert
(
entity
.0
,
target
);
target
}
...
...
This diff is collapsed.
Click to expand it.
src/widgets/scroll/scroll_context.rs
+
2
−
2
View file @
a6492787
use
bevy
::
prelude
::{
Bundle
,
Commands
,
Component
,
Entity
,
In
,
Query
,
Vec2
};
use
bevy
::
prelude
::{
Bundle
,
Commands
,
Component
,
Entity
,
In
,
Query
,
Vec2
,
BuildChildren
};
use
crate
::{
children
::
KChildren
,
...
...
@@ -173,7 +173,7 @@ pub fn scroll_context_render(
)
>
,
)
->
bool
{
if
let
Ok
((
context_provider
,
children
,
styles
,
mut
computed_styles
))
=
query
.get_mut
(
entity
)
{
let
context_entity
=
commands
.spawn
(
context_provider
.initial_value
)
.id
();
let
context_entity
=
commands
.spawn
(
context_provider
.initial_value
)
.
set_parent
(
entity
)
.
id
();
widget_context
.set_context_entity
::
<
ScrollContext
>
(
Some
(
entity
),
context_entity
);
*
computed_styles
=
styles
.clone
()
.into
();
children
.process
(
&
widget_context
,
Some
(
entity
));
...
...
This diff is collapsed.
Click to expand it.
src/widgets/window_context_provider.rs
+
1
−
1
View file @
a6492787
...
...
@@ -76,7 +76,7 @@ pub fn window_context_render(
{
context_entity
}
else
{
commands
.spawn
(
WindowContext
::
default
())
.id
()
commands
.spawn
(
WindowContext
::
default
())
.
set_parent
(
window_context_entity
)
.
id
()
};
widget_context
.set_context_entity
::
<
WindowContext
>
(
Some
(
window_context_entity
),
context_entity
);
...
...
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