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
68d56a11
Unverified
Commit
68d56a11
authored
3 years ago
by
Ygg01
Browse files
Options
Downloads
Patches
Plain Diff
Refactor on_change to shared function
parent
bd9786d5
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
src/widgets/mod.rs
+2
-0
2 additions, 0 deletions
src/widgets/mod.rs
src/widgets/on_change.rs
+27
-0
27 additions, 0 deletions
src/widgets/on_change.rs
src/widgets/text_box.rs
+3
-30
3 additions, 30 deletions
src/widgets/text_box.rs
with
32 additions
and
30 deletions
src/widgets/mod.rs
+
2
−
0
View file @
68d56a11
...
@@ -8,6 +8,7 @@ mod if_element;
...
@@ -8,6 +8,7 @@ mod if_element;
mod
image
;
mod
image
;
mod
inspector
;
mod
inspector
;
mod
nine_patch
;
mod
nine_patch
;
mod
on_change
;
mod
scroll
;
mod
scroll
;
mod
text
;
mod
text
;
mod
text_box
;
mod
text_box
;
...
@@ -24,6 +25,7 @@ pub use if_element::*;
...
@@ -24,6 +25,7 @@ pub use if_element::*;
pub
use
image
::
*
;
pub
use
image
::
*
;
pub
use
inspector
::
*
;
pub
use
inspector
::
*
;
pub
use
nine_patch
::
*
;
pub
use
nine_patch
::
*
;
pub
use
on_change
::
*
;
pub
use
scroll
::
*
;
pub
use
scroll
::
*
;
pub
use
text
::
*
;
pub
use
text
::
*
;
pub
use
text_box
::
*
;
pub
use
text_box
::
*
;
...
...
This diff is collapsed.
Click to expand it.
src/widgets/on_change.rs
0 → 100644
+
27
−
0
View file @
68d56a11
use
std
::
sync
::{
Arc
,
RwLock
};
#[derive(Debug,
Clone,
PartialEq)]
pub
struct
ChangeEvent
{
pub
value
:
String
,
}
#[derive(Clone)]
pub
struct
OnChange
(
pub
Arc
<
RwLock
<
dyn
FnMut
(
ChangeEvent
)
+
Send
+
Sync
+
'static
>>
);
impl
OnChange
{
pub
fn
new
<
F
:
FnMut
(
ChangeEvent
)
+
Send
+
Sync
+
'static
>
(
f
:
F
)
->
OnChange
{
OnChange
(
Arc
::
new
(
RwLock
::
new
(
f
)))
}
}
impl
PartialEq
for
OnChange
{
fn
eq
(
&
self
,
_other
:
&
Self
)
->
bool
{
true
}
}
impl
std
::
fmt
::
Debug
for
OnChange
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
f
.debug_tuple
(
"OnChange"
)
.finish
()
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/widgets/text_box.rs
+
3
−
30
View file @
68d56a11
use
crate
::
core
::{
use
crate
::
{
core
::{
render_command
::
RenderCommand
,
render_command
::
RenderCommand
,
rsx
,
rsx
,
styles
::{
Corner
,
Style
,
Units
},
styles
::{
Corner
,
Style
,
Units
},
widget
,
Bound
,
Children
,
Color
,
EventType
,
MutableBound
,
OnEvent
,
WidgetProps
,
widget
,
Bound
,
Children
,
Color
,
EventType
,
MutableBound
,
OnEvent
,
WidgetProps
,
};
},
widgets
::
ChangeEvent
};
use
kayak_core
::{
CursorIcon
,
OnLayout
};
use
kayak_core
::{
CursorIcon
,
OnLayout
};
use
std
::
sync
::{
Arc
,
RwLock
};
use
crate
::
widgets
::{
Background
,
Clip
,
Text
};
use
crate
::
widgets
::{
Background
,
Clip
,
Text
,
OnChange
};
/// Props used by the [`TextBox`] widget
/// Props used by the [`TextBox`] widget
#[derive(Default,
Debug,
PartialEq,
Clone)]
#[derive(Default,
Debug,
PartialEq,
Clone)]
...
@@ -56,32 +55,6 @@ impl WidgetProps for TextBoxProps {
...
@@ -56,32 +55,6 @@ impl WidgetProps for TextBoxProps {
}
}
}
}
#[derive(Debug,
Clone,
PartialEq)]
pub
struct
ChangeEvent
{
pub
value
:
String
,
}
#[derive(Clone)]
pub
struct
OnChange
(
pub
Arc
<
RwLock
<
dyn
FnMut
(
ChangeEvent
)
+
Send
+
Sync
+
'static
>>
);
impl
OnChange
{
pub
fn
new
<
F
:
FnMut
(
ChangeEvent
)
+
Send
+
Sync
+
'static
>
(
f
:
F
)
->
OnChange
{
OnChange
(
Arc
::
new
(
RwLock
::
new
(
f
)))
}
}
impl
PartialEq
for
OnChange
{
fn
eq
(
&
self
,
_other
:
&
Self
)
->
bool
{
true
}
}
impl
std
::
fmt
::
Debug
for
OnChange
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
f
.debug_tuple
(
"OnChange"
)
.finish
()
}
}
#[derive(Debug,
Clone,
Copy,
PartialEq)]
#[derive(Debug,
Clone,
Copy,
PartialEq)]
pub
struct
Focus
(
pub
bool
);
pub
struct
Focus
(
pub
bool
);
...
...
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