Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
druid-widgets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Paul Miller
druid-widgets
Commits
15bd4622
Commit
15bd4622
authored
5 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
envelope works
parent
c2936bb2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/dial_test3.rs
+22
-8
22 additions, 8 deletions
examples/dial_test3.rs
with
22 additions
and
8 deletions
examples/dial_test3.rs
+
22
−
8
View file @
15bd4622
...
@@ -28,7 +28,7 @@ use log::info;
...
@@ -28,7 +28,7 @@ use log::info;
use
druid_widgets
::
*
;
use
druid_widgets
::
*
;
#[derive(Clone,
Data,
Lens)]
#[derive(Clone,
Data,
Lens
,
Default
)]
struct
DialLabel
{
struct
DialLabel
{
value
:
f64
,
value
:
f64
,
}
}
...
@@ -51,7 +51,7 @@ impl DialLabel {
...
@@ -51,7 +51,7 @@ impl DialLabel {
col
col
}
}
}
}
#[derive(Clone,
Data,
Lens)]
#[derive(Clone,
Data,
Lens
,
Default
)]
struct
Envelope
{
struct
Envelope
{
attack
:
DialLabel
,
attack
:
DialLabel
,
decay
:
DialLabel
,
decay
:
DialLabel
,
...
@@ -62,29 +62,43 @@ struct Envelope {
...
@@ -62,29 +62,43 @@ struct Envelope {
impl
Envelope
{
impl
Envelope
{
fn
new
()
->
impl
Widget
<
Envelope
>
{
fn
new
()
->
impl
Widget
<
Envelope
>
{
let
solid
=
Color
::
rgb8
(
0x3a
,
0x3a
,
0x3a
);
let
solid
=
Color
::
rgb8
(
0x3a
,
0x3a
,
0x3a
);
let
mut
col
=
Flex
::
column
();
let
mut
row
=
Flex
::
row
();
col
.add_child
(
row
.add_child
(
DialLabel
::
new
(
"Attack"
)
DialLabel
::
new
(
"Attack"
)
.lens
(
Envelope
::
attack
)
.lens
(
Envelope
::
attack
)
.background
(
solid
.clone
())
.background
(
solid
.clone
())
.padding
(
5.0
),
.padding
(
5.0
),
0.0
,
0.0
,
);
);
col
.add_child
(
row
.add_child
(
DialLabel
::
new
(
"Decay"
)
DialLabel
::
new
(
"Decay"
)
.lens
(
Envelope
::
decay
)
.lens
(
Envelope
::
decay
)
.background
(
solid
.clone
())
.background
(
solid
.clone
())
.padding
(
5.0
),
.padding
(
5.0
),
0.0
,
0.0
,
);
);
col
row
.add_child
(
DialLabel
::
new
(
"Sustain"
)
.lens
(
Envelope
::
sustain
)
.background
(
solid
.clone
())
.padding
(
5.0
),
0.0
,
);
row
.add_child
(
DialLabel
::
new
(
"Release"
)
.lens
(
Envelope
::
release
)
.background
(
solid
.clone
())
.padding
(
5.0
),
0.0
,
);
row
}
}
}
}
fn
main
()
->
Result
<
(),
PlatformError
>
{
fn
main
()
->
Result
<
(),
PlatformError
>
{
AppLauncher
::
with_window
(
WindowDesc
::
new
(
||
DialLabel
::
new
(
"Value"
)
))
AppLauncher
::
with_window
(
WindowDesc
::
new
(
Envelope
::
new
))
.use_simple_logger
()
.use_simple_logger
()
.launch
(
DialLabel
{
value
:
0.0
}
)
?
;
.launch
(
Envelope
::
default
()
)
?
;
Ok
(())
Ok
(())
}
}
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