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
8e550432
Commit
8e550432
authored
3 years ago
by
Gino Valente
Browse files
Options
Downloads
Patches
Plain Diff
Updated code to use resolve_or(_else)
parent
e01b1603
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/render_primitive.rs
+8
-26
8 additions, 26 deletions
kayak_core/src/render_primitive.rs
with
8 additions
and
26 deletions
kayak_core/src/render_primitive.rs
+
8
−
26
View file @
8e550432
...
@@ -2,7 +2,7 @@ use crate::{
...
@@ -2,7 +2,7 @@ use crate::{
color
::
Color
,
color
::
Color
,
layout_cache
::
Rect
,
layout_cache
::
Rect
,
render_command
::
RenderCommand
,
render_command
::
RenderCommand
,
styles
::{
Corner
,
Edge
,
Style
,
StyleProp
},
styles
::{
Corner
,
Edge
,
Style
},
};
};
#[derive(Debug,
Clone,
PartialEq)]
#[derive(Debug,
Clone,
PartialEq)]
...
@@ -56,35 +56,17 @@ impl From<&Style> for RenderPrimitive {
...
@@ -56,35 +56,17 @@ impl From<&Style> for RenderPrimitive {
fn
from
(
style
:
&
Style
)
->
Self
{
fn
from
(
style
:
&
Style
)
->
Self
{
let
render_command
=
style
.render_command
.resolve
();
let
render_command
=
style
.render_command
.resolve
();
let
background_color
=
if
matches!
(
style
.background_color
,
StyleProp
::
Default
)
{
let
background_color
=
style
.background_color
.resolve_or
(
Color
::
TRANSPARENT
);
Color
::
TRANSPARENT
}
else
{
style
.background_color
.resolve
()
};
let
border_color
=
if
matches!
(
style
.border_color
,
StyleProp
::
Default
)
{
let
border_color
=
style
.border_color
.resolve_or
(
Color
::
TRANSPARENT
);
Color
::
TRANSPARENT
}
else
{
style
.border_color
.resolve
()
};
let
font
=
if
matches!
(
style
.font
,
StyleProp
::
Default
)
{
let
font
=
style
String
::
from
(
crate
::
DEFAULT_FONT
)
.font
}
else
{
.resolve_or_else
(||
String
::
from
(
crate
::
DEFAULT_FONT
));
style
.font
.resolve
()
};
let
font_size
=
if
matches!
(
style
.font_size
,
StyleProp
::
Default
)
{
let
font_size
=
style
.font_size
.resolve_or
(
14.0
);
14.0
}
else
{
style
.font_size
.resolve
()
};
let
line_height
=
if
matches!
(
style
.line_height
,
StyleProp
::
Default
)
{
let
line_height
=
style
.line_height
.resolve_or
(
font_size
*
1.2
);
font_size
*
1.2
}
else
{
style
.line_height
.resolve
()
};
match
render_command
{
match
render_command
{
RenderCommand
::
Empty
=>
Self
::
Empty
,
RenderCommand
::
Empty
=>
Self
::
Empty
,
...
...
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