Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Micro Ui
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
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
Micro Ui
Commits
d29af9f9
Verified
Commit
d29af9f9
authored
11 months ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Include panel component
parent
8e259e69
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
src/components.rs
+2
-0
2 additions, 0 deletions
src/components.rs
src/components/panel.rs
+81
-0
81 additions, 0 deletions
src/components/panel.rs
src/utilities.rs
+1
-1
1 addition, 1 deletion
src/utilities.rs
with
84 additions
and
1 deletion
src/components.rs
+
2
−
0
View file @
d29af9f9
mod
button
;
mod
button
;
mod
inset_icon
;
mod
inset_icon
;
mod
panel
;
pub
use
button
::{
pub
use
button
::{
button_props
,
render_button_widget
,
ButtonWidget
,
ButtonWidgetProps
,
ButtonWidgetState
,
button_props
,
render_button_widget
,
ButtonWidget
,
ButtonWidgetProps
,
ButtonWidgetState
,
};
};
pub
use
inset_icon
::{
render_inset_icon_widget
,
InsetIconProps
,
InsetIconWidget
};
pub
use
inset_icon
::{
render_inset_icon_widget
,
InsetIconProps
,
InsetIconWidget
};
pub
use
panel
::{
render_panel_widget
,
PanelProps
,
PanelWidget
,
PanelVariant
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/components/panel.rs
0 → 100644
+
81
−
0
View file @
d29af9f9
use
bevy
::
prelude
::
*
;
use
kayak_ui
::
prelude
::
*
;
use
crate
::
parent_widget
;
use
crate
::
theme
::
tokens
::
THEME_NINEPATCH_PANEL_DEFAULT
;
use
crate
::
theme
::
ThemeProvider
;
use
crate
::{
px
,
value
};
#[derive(Default,
Copy,
Clone,
Eq,
PartialEq)]
pub
enum
PanelVariant
{
#[default]
Regular
,
Simple
,
}
#[derive(Component,
Default,
Clone,
PartialEq)]
pub
struct
PanelProps
{
pub
background
:
Option
<
String
>
,
pub
inner_layout
:
StyleProp
<
LayoutType
>
,
}
impl
Widget
for
PanelProps
{}
parent_widget!
(
PanelProps
=>
PanelWidget
);
pub
fn
render_panel_widget
(
In
(
entity
):
In
<
Entity
>
,
widget_context
:
Res
<
KayakWidgetContext
>
,
mut
commands
:
Commands
,
mut
query
:
Query
<
(
&
PanelProps
,
&
KChildren
,
&
mut
ComputedStyles
,
&
KStyle
)
>
,
theme_provider
:
ThemeProvider
,
)
->
bool
{
if
let
Ok
((
props
,
children
,
mut
computed
,
style
))
=
query
.get_mut
(
entity
)
{
let
parent_id
=
Some
(
entity
);
let
patch
=
theme_provider
.get_patch
(
props
.background
.clone
()
.unwrap_or_else
(||
String
::
from
(
THEME_NINEPATCH_PANEL_DEFAULT
)),
)
.unwrap
();
*
computed
=
KStyle
{
render_command
:
value
(
RenderCommand
::
NinePatch
{
handle
:
patch
.handle
.clone_weak
(),
border
:
patch
.border
,
scale
:
1.0
,
}),
min_height
:
px
(
patch
.border.bottom
+
patch
.border.top
+
8.0
),
min_width
:
px
(
patch
.border.left
+
patch
.border.right
+
8.0
),
..
Default
::
default
()
}
.with_style
(
style
)
.with_style
(
KStyle
{
padding
:
value
(
Edge
::
new
(
Units
::
Pixels
(
patch
.border.top
),
Units
::
Pixels
(
patch
.border.right
),
Units
::
Pixels
(
patch
.border.bottom
),
Units
::
Pixels
(
patch
.border.left
),
)),
..
Default
::
default
()
})
.into
();
let
inner_style
=
match
&
style
.padding
{
StyleProp
::
Unset
=>
KStyle
{
layout_type
:
props
.inner_layout
.clone
(),
..
Default
::
default
()
},
pad
=>
KStyle
{
layout_type
:
props
.inner_layout
.clone
(),
padding
:
pad
.clone
(),
..
Default
::
default
()
},
};
children
.process
(
&
widget_context
,
&
mut
commands
,
Some
(
entity
));
}
true
}
This diff is collapsed.
Click to expand it.
src/utilities.rs
+
1
−
1
View file @
d29af9f9
...
@@ -230,7 +230,7 @@ pub mod context {
...
@@ -230,7 +230,7 @@ pub mod context {
pub
struct
CresthollowBaseComponentsPlugin
;
pub
struct
CresthollowBaseComponentsPlugin
;
impl
KayakUIPlugin
for
CresthollowBaseComponentsPlugin
{
impl
KayakUIPlugin
for
CresthollowBaseComponentsPlugin
{
fn
build
(
&
self
,
widget_context
:
&
mut
KayakRootContext
)
{
fn
build
(
&
self
,
widget_context
:
&
mut
KayakRootContext
)
{
//
register_widget!(widget_context, PanelProps, EmptyState, render_panel_widget);
register_widget!
(
widget_context
,
PanelProps
,
EmptyState
,
render_panel_widget
);
register_widget!
(
register_widget!
(
widget_context
,
widget_context
,
ButtonWidgetProps
,
ButtonWidgetProps
,
...
...
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