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
faa847fc
Unverified
Commit
faa847fc
authored
3 years ago
by
MrGVSV
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added dump methods on tree
parent
9e2c45c9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kayak_core/src/tree.rs
+51
-0
51 additions, 0 deletions
kayak_core/src/tree.rs
with
51 additions
and
0 deletions
kayak_core/src/tree.rs
+
51
−
0
View file @
faa847fc
...
@@ -436,6 +436,57 @@ impl Tree {
...
@@ -436,6 +436,57 @@ impl Tree {
// );
// );
// }
// }
}
}
/// Dumps the tree's current state to the console
///
/// To dump only a section of the tree, use [dump_at] instead.
///
/// # Arguments
///
/// * `widgets`: Optionally, provide the current widgets to include metadata about each widget
///
/// returns: ()
pub
fn
dump
(
&
self
,
widgets
:
Option
<&
Arena
<
Option
<
Box
<
dyn
Widget
>>>>
)
{
if
let
Some
(
root
)
=
self
.root_node
{
self
.dump_at_internal
(
root
,
0
,
widgets
);
}
}
/// Dumps a section of the tree's current state to the console (starting from a specific index)
///
/// To dump the entire tree, use [dump] instead.
///
/// # Arguments
///
/// * `start_index`: The index to start recursing from (including itself)
/// * `widgets`: Optionally, provide the current widgets to include metadata about each widget
///
/// returns: ()
pub
fn
dump_at
(
&
self
,
start_index
:
Index
,
widgets
:
Option
<&
Arena
<
Option
<
Box
<
dyn
Widget
>>>>
)
{
self
.dump_at_internal
(
start_index
,
0
,
widgets
);
}
fn
dump_at_internal
(
&
self
,
start_index
:
Index
,
depth
:
usize
,
widgets
:
Option
<&
Arena
<
Option
<
Box
<
dyn
Widget
>>>>
)
{
let
mut
name
=
None
;
if
let
Some
(
widgets
)
=
widgets
{
if
let
Some
(
widget
)
=
widgets
.get
(
start_index
)
{
if
let
Some
(
widget
)
=
widget
{
name
=
Some
(
widget
.get_name
());
}
}
}
let
indent
=
"
\t
"
.repeat
(
depth
);
let
raw_parts
=
start_index
.into_raw_parts
();
println!
(
"{}{} [{}:{}]"
,
indent
,
name
.unwrap_or_default
(),
raw_parts
.0
,
raw_parts
.1
);
if
let
Some
(
children
)
=
self
.children
.get
(
&
start_index
)
{
for
node_index
in
children
{
self
.dump_at_internal
(
*
node_index
,
depth
+
1
,
widgets
);
}
}
}
}
}
pub
struct
DownwardIterator
<
'a
>
{
pub
struct
DownwardIterator
<
'a
>
{
...
...
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