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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Miller
druid-widgets
Commits
777716c6
Commit
777716c6
authored
5 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
dail2 now works
parent
4d9839fc
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_test2.rs
+103
-0
103 additions, 0 deletions
examples/dial_test2.rs
with
103 additions
and
0 deletions
examples/dial_test2.rs
0 → 100644
+
103
−
0
View file @
777716c6
// Copyright 2019 The xi-editor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! An example of an animating widget.
use
std
::
f64
::
consts
::
PI
;
use
druid
::
kurbo
::{
BezPath
,
Line
};
use
druid
::
widget
::{
Flex
,
Label
,
WidgetExt
};
use
druid
::{
AppLauncher
,
BoxConstraints
,
Color
,
Data
,
Env
,
Event
,
EventCtx
,
LayoutCtx
,
Lens
,
LensWrap
,
LinearGradient
,
PaintCtx
,
PlatformError
,
Point
,
RenderContext
,
Size
,
UnitPoint
,
UpdateCtx
,
Vec2
,
WheelEvent
,
Widget
,
WindowDesc
,
};
use
log
::
info
;
use
druid_widgets
::
*
;
#[derive(Clone,
Data,
Lens)]
struct
DialData
{
value
:
f64
,
value2
:
f64
,
}
fn
build_app
()
->
impl
Widget
<
(
DialData
)
>
{
let
solid
=
Color
::
rgb8
(
0x3a
,
0x3a
,
0x3a
);
let
gradient
=
LinearGradient
::
new
(
UnitPoint
::
TOP_LEFT
,
UnitPoint
::
BOTTOM_RIGHT
,
(
Color
::
rgb8
(
0x11
,
0x11
,
0x11
),
Color
::
rgb8
(
0xbb
,
0xbb
,
0xbb
)),
);
Flex
::
column
()
.with_child
(
Flex
::
row
()
.with_child
(
Label
::
new
(
"top left"
)
.background
(
solid
.clone
())
.padding
(
10.0
),
1.0
,
)
.with_child
(
LensWrap
::
new
(
Dial
::
new
(
Size
::
new
(
100.0
,
100.0
)),
DialData
::
value
)
.background
(
solid
.clone
())
.padding
(
10.0
),
0.0
,
)
.with_child
(
LensWrap
::
new
(
Dial
::
new
(
Size
::
new
(
200.0
,
200.0
)),
DialData
::
value2
)
.background
(
solid
.clone
())
.padding
(
10.0
),
0.0
,
)
.with_child
(
Label
::
new
(
"top right"
)
.background
(
solid
.clone
())
.padding
(
10.0
),
1.0
,
),
0.0
,
// vertical
)
.with_child
(
Flex
::
row
()
.with_child
(
Label
::
new
(
"bottom left"
)
.background
(
gradient
.clone
())
.rounded
(
10.0
)
.padding
(
10.0
),
0.0
,
)
.with_child
(
Label
::
new
(
"bottom right"
)
.border
(
solid
.clone
(),
4.0
)
.rounded
(
10.0
)
.padding
(
10.0
),
1.0
,
),
1.0
,
)
}
fn
main
()
->
Result
<
(),
PlatformError
>
{
AppLauncher
::
with_window
(
WindowDesc
::
new
(
build_app
))
.use_simple_logger
()
.launch
(
DialData
{
value
:
0.0
,
value2
:
1.0
,
})
?
;
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