diff options
| author | 2023-07-12 12:23:18 -0700 | |
|---|---|---|
| committer | 2023-07-12 12:23:18 -0700 | |
| commit | 633f405f3f78bc7f82d2b2061491b0e011137451 (patch) | |
| tree | 5ebfc1f45d216a5c14a90492563599e6969eab4d /examples/bezier_tool/src/main.rs | |
| parent | 41836dd80d0534608e7aedfbf2319c540a23de1a (diff) | |
| parent | 21bd51426d900e271206f314e0c915dd41065521 (diff) | |
| download | iced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.gz iced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.bz2 iced-633f405f3f78bc7f82d2b2061491b0e011137451.zip | |
Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts:
#	Cargo.toml
#	core/src/window/icon.rs
#	core/src/window/id.rs
#	core/src/window/position.rs
#	core/src/window/settings.rs
#	examples/integration/src/main.rs
#	examples/integration_opengl/src/main.rs
#	glutin/src/application.rs
#	native/src/subscription.rs
#	native/src/window.rs
#	runtime/src/window/action.rs
#	src/lib.rs
#	src/window.rs
#	winit/Cargo.toml
#	winit/src/application.rs
#	winit/src/icon.rs
#	winit/src/settings.rs
#	winit/src/window.rs
Diffstat (limited to 'examples/bezier_tool/src/main.rs')
| -rw-r--r-- | examples/bezier_tool/src/main.rs | 39 | 
1 files changed, 23 insertions, 16 deletions
| diff --git a/examples/bezier_tool/src/main.rs b/examples/bezier_tool/src/main.rs index 7c3916d4..310be28f 100644 --- a/examples/bezier_tool/src/main.rs +++ b/examples/bezier_tool/src/main.rs @@ -61,10 +61,8 @@ impl Sandbox for Example {  mod bezier {      use iced::mouse;      use iced::widget::canvas::event::{self, Event}; -    use iced::widget::canvas::{ -        self, Canvas, Cursor, Frame, Geometry, Path, Stroke, -    }; -    use iced::{Element, Length, Point, Rectangle, Theme}; +    use iced::widget::canvas::{self, Canvas, Frame, Geometry, Path, Stroke}; +    use iced::{Element, Length, Point, Rectangle, Renderer, Theme};      #[derive(Default)]      pub struct State { @@ -100,10 +98,10 @@ mod bezier {              state: &mut Self::State,              event: Event,              bounds: Rectangle, -            cursor: Cursor, +            cursor: mouse::Cursor,          ) -> (event::Status, Option<Curve>) {              let cursor_position = -                if let Some(position) = cursor.position_in(&bounds) { +                if let Some(position) = cursor.position_in(bounds) {                      position                  } else {                      return (event::Status::Ignored, None); @@ -152,22 +150,26 @@ mod bezier {          fn draw(              &self,              state: &Self::State, +            renderer: &Renderer,              _theme: &Theme,              bounds: Rectangle, -            cursor: Cursor, +            cursor: mouse::Cursor,          ) -> Vec<Geometry> { -            let content = -                self.state.cache.draw(bounds.size(), |frame: &mut Frame| { +            let content = self.state.cache.draw( +                renderer, +                bounds.size(), +                |frame: &mut Frame| {                      Curve::draw_all(self.curves, frame);                      frame.stroke(                          &Path::rectangle(Point::ORIGIN, frame.size()),                          Stroke::default().with_width(2.0),                      ); -                }); +                }, +            );              if let Some(pending) = state { -                let pending_curve = pending.draw(bounds, cursor); +                let pending_curve = pending.draw(renderer, bounds, cursor);                  vec![content, pending_curve]              } else { @@ -179,9 +181,9 @@ mod bezier {              &self,              _state: &Self::State,              bounds: Rectangle, -            cursor: Cursor, +            cursor: mouse::Cursor,          ) -> mouse::Interaction { -            if cursor.is_over(&bounds) { +            if cursor.is_over(bounds) {                  mouse::Interaction::Crosshair              } else {                  mouse::Interaction::default() @@ -216,10 +218,15 @@ mod bezier {      }      impl Pending { -        fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Geometry { -            let mut frame = Frame::new(bounds.size()); +        fn draw( +            &self, +            renderer: &Renderer, +            bounds: Rectangle, +            cursor: mouse::Cursor, +        ) -> Geometry { +            let mut frame = Frame::new(renderer, bounds.size()); -            if let Some(cursor_position) = cursor.position_in(&bounds) { +            if let Some(cursor_position) = cursor.position_in(bounds) {                  match *self {                      Pending::One { from } => {                          let line = Path::line(from, cursor_position); | 
