diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/bezier_tool/src/main.rs | 55 | ||||
| -rw-r--r-- | examples/game_of_life/src/main.rs | 15 | 
2 files changed, 31 insertions, 39 deletions
diff --git a/examples/bezier_tool/src/main.rs b/examples/bezier_tool/src/main.rs index 3cecd058..fe4136b4 100644 --- a/examples/bezier_tool/src/main.rs +++ b/examples/bezier_tool/src/main.rs @@ -70,7 +70,7 @@ impl Sandbox for Example {  mod bezier {      use iced::{          canvas::{self, Canvas, Cursor, Event, Frame, Geometry, Path, Stroke}, -        mouse, ButtonState, Element, Length, MouseCursor, Point, Rectangle, +        mouse, Element, Length, MouseCursor, Point, Rectangle,      };      #[derive(Default)] @@ -114,34 +114,33 @@ mod bezier {              match event {                  Event::Mouse(mouse_event) => match mouse_event { -                    mouse::Event::Input { -                        button: mouse::Button::Left, -                        state: ButtonState::Pressed, -                    } => match self.state.pending { -                        None => { -                            self.state.pending = Some(Pending::One { -                                from: cursor_position, -                            }); -                            None +                    mouse::Event::ButtonPressed(mouse::Button::Left) => { +                        match self.state.pending { +                            None => { +                                self.state.pending = Some(Pending::One { +                                    from: cursor_position, +                                }); +                                None +                            } +                            Some(Pending::One { from }) => { +                                self.state.pending = Some(Pending::Two { +                                    from, +                                    to: cursor_position, +                                }); + +                                None +                            } +                            Some(Pending::Two { from, to }) => { +                                self.state.pending = None; + +                                Some(Curve { +                                    from, +                                    to, +                                    control: cursor_position, +                                }) +                            }                          } -                        Some(Pending::One { from }) => { -                            self.state.pending = Some(Pending::Two { -                                from, -                                to: cursor_position, -                            }); - -                            None -                        } -                        Some(Pending::Two { from, to }) => { -                            self.state.pending = None; - -                            Some(Curve { -                                from, -                                to, -                                control: cursor_position, -                            }) -                        } -                    }, +                    }                      _ => None,                  },              } diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index 983d6cb4..9fb4c3e7 100644 --- a/examples/game_of_life/src/main.rs +++ b/examples/game_of_life/src/main.rs @@ -158,8 +158,8 @@ impl Application for GameOfLife {  mod grid {      use iced::{          canvas::{self, Canvas, Cursor, Event, Frame, Geometry, Path}, -        mouse, ButtonState, Color, Element, Length, MouseCursor, Point, -        Rectangle, Size, Vector, +        mouse, Color, Element, Length, MouseCursor, Point, Rectangle, Size, +        Vector,      };      use std::collections::{HashMap, HashSet}; @@ -268,11 +268,7 @@ mod grid {              bounds: Rectangle,              cursor: Cursor,          ) -> Option<Message> { -            if let Event::Mouse(mouse::Event::Input { -                state: ButtonState::Released, -                .. -            }) = event -            { +            if let Event::Mouse(mouse::Event::ButtonReleased(_)) = event {                  self.interaction = None;              } @@ -287,10 +283,7 @@ mod grid {              match event {                  Event::Mouse(mouse_event) => match mouse_event { -                    mouse::Event::Input { -                        button, -                        state: ButtonState::Pressed, -                    } => match button { +                    mouse::Event::ButtonPressed(button) => match button {                          mouse::Button::Left => {                              self.interaction = Some(Interaction::Drawing);  | 
