diff --git a/examples/dial_test.rs b/examples/dial_test.rs deleted file mode 100644 index 40ec480a50fa9e1475ba57d16df36b46015ae1f1..0000000000000000000000000000000000000000 --- a/examples/dial_test.rs +++ /dev/null @@ -1,93 +0,0 @@ -// 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, -} - -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( - 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 })?; - - Ok(()) -} diff --git a/examples/dial_test2.rs b/examples/dial_test2.rs deleted file mode 100644 index cfad4d7372c0137465437589e311fa638ee49109..0000000000000000000000000000000000000000 --- a/examples/dial_test2.rs +++ /dev/null @@ -1,103 +0,0 @@ -// 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(()) -} diff --git a/examples/dial_test3.rs b/examples/dial_test3.rs deleted file mode 100644 index bc2dbb8247050e7bbd5afbfae02bcd7cff95639f..0000000000000000000000000000000000000000 --- a/examples/dial_test3.rs +++ /dev/null @@ -1,104 +0,0 @@ -// 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, Default)] -struct DialLabel { - value: f64, -} - -impl DialLabel { - fn new(text: &str) -> impl Widget<DialLabel> { - let text = text.to_string(); - let label = - Label::new(move |data: &DialLabel, _env: &_| format!("{} {:.3}", text, data.value)); - let solid = Color::rgb8(0x3a, 0x3a, 0x3a); - 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 - } -} -#[derive(Clone, Data, Lens, Default)] -struct Envelope { - attack: DialLabel, - decay: DialLabel, - sustain: DialLabel, - release: DialLabel, -} - -impl Envelope { - fn new() -> impl Widget<Envelope> { - let solid = Color::rgb8(0x3a, 0x3a, 0x3a); - let mut row = Flex::row(); - row.add_child( - DialLabel::new("Attack") - .lens(Envelope::attack) - .background(solid.clone()) - .padding(5.0), - 0.0, - ); - row.add_child( - DialLabel::new("Decay") - .lens(Envelope::decay) - .background(solid.clone()) - .padding(5.0), - 0.0, - ); - 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> { - AppLauncher::with_window(WindowDesc::new(Envelope::new)) - .use_simple_logger() - .launch(Envelope::default())?; - - Ok(()) -}