Skip to content
Snippets Groups Projects
Commit e5eeb053 authored by Per Lindgren's avatar Per Lindgren
Browse files

dail3 works

parent 777716c6
No related branches found
No related tags found
No related merge requests found
[package] [package]
name = "envelop_edit" name = "druid_widgets"
version = "0.1.0" version = "0.1.0"
authors = ["Per Lindgren <per.lindgren@ltu.se>"] authors = ["Per Lindgren <per.lindgren@ltu.se>"]
edition = "2018" edition = "2018"
......
// 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, Padding, 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 DialLabel {
value: f64,
}
impl DialLabel {
fn new(text: String) -> impl Widget<DialLabel> {
let solid = Color::rgb8(0x3a, 0x3a, 0x3a);
let label =
Label::new(move |data: &DialLabel, _env: &_| format!("{} {:.3}", text, data.value));
let mut col = Flex::column();
col.add_child(
Dial::new(Size::new(100.0, 100.0))
.lens(DialLabel::value)
.background(solid.clone())
.padding(5.0),
0.0,
);
col.add_child(label.padding(5.0).background(solid.clone()), 1.0);
col
}
}
fn main() -> Result<(), PlatformError> {
AppLauncher::with_window(WindowDesc::new(|| DialLabel::new("Value".to_string())))
.use_simple_logger()
.launch(DialLabel { value: 0.0 })?;
Ok(())
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment