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
87354204
Commit
87354204
authored
2 years ago
by
John Mitchell
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bugs with bevy parent/children hierarchy.
parent
284f4c35
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
examples/tabs/tabs.rs
+2
-2
2 additions, 2 deletions
examples/tabs/tabs.rs
src/children.rs
+1
-0
1 addition, 0 deletions
src/children.rs
src/context.rs
+31
-22
31 additions, 22 deletions
src/context.rs
with
34 additions
and
24 deletions
examples/tabs/tabs.rs
+
2
−
2
View file @
87354204
...
...
@@ -75,10 +75,10 @@ fn startup(
..
Default
::
default
()
}}
>
<
TabBundle
tab
=
{
Tab
{
index
:
0
}}
>
<
TabBundle
key
=
{
"tab1"
}
tab
=
{
Tab
{
index
:
0
}}
>
<
TextWidgetBundle
text
=
{
TextProps
{
content
:
"Tab 1 Content"
.into
(),
size
:
14.0
,
line_height
:
Some
(
14.0
),
..
Default
::
default
()
}}
/>
</
TabBundle
>
<
TabBundle
tab
=
{
Tab
{
index
:
1
}}
>
<
TabBundle
key
=
{
"tab2"
}
tab
=
{
Tab
{
index
:
1
}}
>
<
TextWidgetBundle
text
=
{
TextProps
{
content
:
"Tab 2 Content"
.into
(),
size
:
14.0
,
line_height
:
Some
(
14.0
),
..
Default
::
default
()
}}
/>
</
TabBundle
>
</
ElementBundle
>
...
...
This diff is collapsed.
Click to expand it.
src/children.rs
+
1
−
0
View file @
87354204
...
...
@@ -63,6 +63,7 @@ impl KChildren {
for
child
in
self
.inner
.iter
()
{
if
let
Some
(
parent_id
)
=
parent_id
{
if
let
Some
(
mut
entity_commands
)
=
commands
.get_entity
(
*
child
)
{
entity_commands
.remove
::
<
Parent
>
();
entity_commands
.set_parent
(
parent_id
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/context.rs
+
31
−
22
View file @
87354204
...
...
@@ -783,6 +783,14 @@ fn update_widgets(
}
}
// let had_change = diff.has_changes();
// if had_change {
// println!("Tree Before:");
// tree.dump_all_at(Some(world), entity.0);
// println!("Changes:");
// diff.debug_print(world);
// }
// Children of this node need to be despawned.
let
mut
despawn_list
=
Vec
::
default
();
'outer
:
for
(
_index
,
changed_entity
,
parent
,
changes
)
in
diff
.changes
.iter
()
...
...
@@ -872,6 +880,7 @@ fn update_widgets(
world
.get_entity_mut
(
changed_entity
.0
)
{
entity_commands
.insert
(
Mounted
);
entity_commands
.remove
::
<
bevy
::
prelude
::
Parent
>
();
entity_commands
.set_parent
(
parent
.0
);
}
if
world
.get_entity
(
changed_entity
.0
)
.is_some
()
{
...
...
@@ -888,18 +897,21 @@ fn update_widgets(
// If the child exists as a child of one of the children we do not need to remove it.
// TODO: This is kinda of expensive we should think of a way of making this faster..
if
let
Ok
(
order_tree
)
=
order_tree
.try_read
()
{
for
sibling
in
order_tree
.child_iter
(
order_tree
.parent
(
*
changed_entity
)
.unwrap
())
{
for
child
in
tree
.down_iter_at
(
sibling
,
true
)
{
if
let
Some
(
entity_ref
)
=
world
.get_entity
(
child
.0
)
{
if
let
Some
(
children
)
=
entity_ref
.get
::
<
KChildren
>
()
if
let
Some
(
parent
)
=
order_tree
.parent
(
*
changed_entity
)
{
for
sibling
in
order_tree
.child_iter
(
parent
)
{
for
child
in
tree
.down_iter_at
(
sibling
,
true
)
{
if
let
Some
(
entity_ref
)
=
world
.get_entity
(
child
.0
)
{
if
children
.contains_entity
(
changed_entity
.0
)
{
trace!
(
"Caught an entity that was marked as deleted but wasn't! {:?}"
,
changed_entity
.0
);
// Don't despawn changed entity because it exists as a child passed via props
continue
'outer
;
if
let
Some
(
children
)
=
entity_ref
.get
::
<
KChildren
>
()
{
if
children
.contains_entity
(
changed_entity
.0
)
{
trace!
(
"Caught an entity that was marked as deleted but wasn't! {:?}"
,
changed_entity
.0
);
// Don't despawn changed entity because it exists as a child passed via props
continue
'outer
;
}
}
}
}
...
...
@@ -926,14 +938,6 @@ fn update_widgets(
}
}
// let had_change = diff.has_changes();
// if had_change {
// println!("Tree Before:");
// tree.dump_all_at(Some(world), entity.0);
// println!("Changes:");
// diff.debug_print(world);
// }
tree
.merge
(
&
widget_context
,
*
entity
,
diff
,
UPDATE_DEPTH
);
// if had_change {
...
...
@@ -966,19 +970,22 @@ fn update_widgets(
// Remove state entity
if
let
Some
(
state_entity
)
=
widget_state
.remove
(
entity
)
{
if
let
Some
(
entity_mut
)
=
world
.get_entity_mut
(
state_entity
)
{
if
let
Some
(
mut
entity_mut
)
=
world
.get_entity_mut
(
state_entity
)
{
entity_mut
.remove_parent
();
entity_mut
.despawn_recursive
();
}
}
// Remove widget entity
if
let
Some
(
entity_mut
)
=
world
.get_entity_mut
(
entity
)
{
if
let
Some
(
mut
entity_mut
)
=
world
.get_entity_mut
(
entity
)
{
log
::
trace!
(
"Removing entity! {:?} - {:?} with parent {:?}"
,
entity
.index
(),
entity_mut
.get
::
<
WidgetName
>
(),
parent
.index
(),
);
entity_mut
.remove_parent
();
entity_mut
.remove
::
<
bevy
::
prelude
::
Children
>
();
entity_mut
.despawn
();
// Also remove all cloned widget entities
...
...
@@ -1089,7 +1096,9 @@ fn update_widgets(
order_tree
.remove
(
*
entity
);
}
tree
.remove
(
*
entity
);
if
let
Some
(
entity_mut
)
=
world
.get_entity_mut
(
entity
.0
)
{
if
let
Some
(
mut
entity_mut
)
=
world
.get_entity_mut
(
entity
.0
)
{
entity_mut
.remove_parent
();
entity_mut
.remove
::
<
bevy
::
prelude
::
Children
>
();
entity_mut
.despawn
();
}
}
...
...
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