Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kayak UI
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
Commits
e7c76a74
Commit
e7c76a74
authored
3 years ago
by
MrGVSV
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up TextBox styles
This also seems to have fixed a bug that caused the textbox to jump when focused (?)
parent
058f8a18
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
src/widgets/text_box.rs
+27
-28
27 additions, 28 deletions
src/widgets/text_box.rs
with
27 additions
and
28 deletions
src/widgets/text_box.rs
+
27
−
28
View file @
e7c76a74
use
crate
::
core
::{
use
crate
::
core
::{
render_command
::
RenderCommand
,
render_command
::
RenderCommand
,
rsx
,
rsx
,
styles
::{
Style
,
StyleProp
,
Units
},
styles
::{
Style
,
Units
},
widget
,
Bound
,
Children
,
Color
,
EventType
,
MutableBound
,
OnEvent
,
WidgetProps
,
widget
,
Bound
,
Children
,
Color
,
EventType
,
MutableBound
,
OnEvent
,
WidgetProps
,
};
};
use
std
::
sync
::{
Arc
,
RwLock
};
use
std
::
sync
::{
Arc
,
RwLock
};
...
@@ -79,30 +79,32 @@ pub fn TextBox(props: TextBoxProps) {
...
@@ -79,30 +79,32 @@ pub fn TextBox(props: TextBoxProps) {
value
,
value
,
..
..
}
=
props
.clone
();
}
=
props
.clone
();
let
current_styles
=
props
.styles
.clone
()
.unwrap_or_default
();
props
.styles
=
Some
(
Style
{
props
.styles
=
Some
(
render_command
:
StyleProp
::
Value
(
RenderCommand
::
Layout
),
Style
::
default
()
height
:
StyleProp
::
Value
(
Units
::
Pixels
(
26.0
)),
// Required styles
top
:
if
matches!
(
current_styles
.top
,
StyleProp
::
Value
{
..
})
{
.with_style
(
Style
{
current_styles
.top
.clone
()
render_command
:
RenderCommand
::
Layout
.into
(),
}
else
{
..
Default
::
default
()
StyleProp
::
Value
(
Units
::
Pixels
(
0.0
))
})
},
// Apply any prop-given styles
bottom
:
if
matches!
(
current_styles
.bottom
,
StyleProp
::
Value
{
..
})
{
.with_style
(
props
.styles
)
current_styles
.top
.clone
()
// If not set by props, apply these styles
}
else
{
.with_style
(
Style
{
StyleProp
::
Value
(
Units
::
Pixels
(
0.0
))
top
:
Units
::
Pixels
(
0.0
)
.into
(),
},
bottom
:
Units
::
Pixels
(
0.0
)
.into
(),
..
current_styles
height
:
Units
::
Pixels
(
26.0
)
.into
(),
});
..
Default
::
default
()
})
);
let
background_styles
=
Style
{
let
background_styles
=
Style
{
background_color
:
StyleProp
::
Value
(
Color
::
new
(
0.176
,
0.196
,
0.215
,
1.0
)),
background_color
:
Color
::
new
(
0.176
,
0.196
,
0.215
,
1.0
)
.into
(
),
border_radius
:
StyleProp
::
Value
(
(
5.0
,
5.0
,
5.0
,
5.0
)),
border_radius
:
(
5.0
,
5.0
,
5.0
,
5.0
)
.into
(
),
height
:
StyleProp
::
Value
(
Units
::
Pixels
(
26.0
)),
height
:
Units
::
Pixels
(
26.0
)
.into
(
),
padding_left
:
StyleProp
::
Value
(
Units
::
Pixels
(
5.0
)),
padding_left
:
Units
::
Pixels
(
5.0
)
.into
(
),
padding_right
:
StyleProp
::
Value
(
Units
::
Pixels
(
5.0
)),
padding_right
:
Units
::
Pixels
(
5.0
)
.into
(
),
..
props
.styles
.clone
()
.unwrap_or_
default
()
..
Default
::
default
()
};
};
let
has_focus
=
context
.create_state
(
Focus
(
false
))
.unwrap
();
let
has_focus
=
context
.create_state
(
Focus
(
false
))
.unwrap
();
...
@@ -138,14 +140,11 @@ pub fn TextBox(props: TextBoxProps) {
...
@@ -138,14 +140,11 @@ pub fn TextBox(props: TextBoxProps) {
let
text_styles
=
if
value
.is_empty
()
||
(
has_focus
.get
()
.0
&&
value
.is_empty
())
{
let
text_styles
=
if
value
.is_empty
()
||
(
has_focus
.get
()
.0
&&
value
.is_empty
())
{
Style
{
Style
{
color
:
StyleProp
::
Value
(
Color
::
new
(
0.5
,
0.5
,
0.5
,
1.0
)),
color
:
Color
::
new
(
0.5
,
0.5
,
0.5
,
1.0
)
.into
(
),
..
Style
::
default
()
..
Style
::
default
()
}
}
}
else
{
}
else
{
Style
{
Style
::
default
()
color
:
props
.styles
.clone
()
.unwrap_or_default
()
.color
,
..
Style
::
default
()
}
};
};
let
value
=
if
value
.is_empty
()
{
let
value
=
if
value
.is_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