Rename MouseCursor to mouse::Interaction
This commit is contained in:
parent
d4c4198f72
commit
98bc8cf2a7
35 changed files with 170 additions and 171 deletions
|
|
@ -70,7 +70,7 @@ impl Sandbox for Example {
|
|||
mod bezier {
|
||||
use iced::{
|
||||
canvas::{self, Canvas, Cursor, Event, Frame, Geometry, Path, Stroke},
|
||||
mouse, Element, Length, MouseCursor, Point, Rectangle,
|
||||
mouse, Element, Length, Point, Rectangle,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -166,15 +166,15 @@ mod bezier {
|
|||
}
|
||||
}
|
||||
|
||||
fn mouse_cursor(
|
||||
fn mouse_interaction(
|
||||
&self,
|
||||
bounds: Rectangle,
|
||||
cursor: Cursor,
|
||||
) -> MouseCursor {
|
||||
) -> mouse::Interaction {
|
||||
if cursor.is_over(&bounds) {
|
||||
MouseCursor::Crosshair
|
||||
mouse::Interaction::Crosshair
|
||||
} else {
|
||||
MouseCursor::default()
|
||||
mouse::Interaction::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ mod circle {
|
|||
// if you wish to, by creating your own `Renderer` trait, which could be
|
||||
// implemented by `iced_wgpu` and other renderers.
|
||||
use iced_native::{
|
||||
layout, Background, Color, Element, Hasher, Layout, Length,
|
||||
MouseCursor, Point, Size, Widget,
|
||||
layout, mouse, Background, Color, Element, Hasher, Layout, Length,
|
||||
Point, Size, Widget,
|
||||
};
|
||||
use iced_wgpu::{Defaults, Primitive, Renderer};
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ mod circle {
|
|||
_defaults: &Defaults,
|
||||
layout: Layout<'_>,
|
||||
_cursor_position: Point,
|
||||
) -> (Primitive, MouseCursor) {
|
||||
) -> (Primitive, mouse::Interaction) {
|
||||
(
|
||||
Primitive::Quad {
|
||||
bounds: layout.bounds(),
|
||||
|
|
@ -66,7 +66,7 @@ mod circle {
|
|||
border_width: 0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
},
|
||||
MouseCursor::default(),
|
||||
mouse::Interaction::default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,8 +157,7 @@ impl Application for GameOfLife {
|
|||
mod grid {
|
||||
use iced::{
|
||||
canvas::{self, Canvas, Cursor, Event, Frame, Geometry, Path},
|
||||
mouse, Color, Element, Length, MouseCursor, Point, Rectangle, Size,
|
||||
Vector,
|
||||
mouse, Color, Element, Length, Point, Rectangle, Size, Vector,
|
||||
};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
|
|
@ -397,16 +396,20 @@ mod grid {
|
|||
vec![life, hovered_cell]
|
||||
}
|
||||
|
||||
fn mouse_cursor(
|
||||
fn mouse_interaction(
|
||||
&self,
|
||||
bounds: Rectangle,
|
||||
cursor: Cursor,
|
||||
) -> MouseCursor {
|
||||
) -> mouse::Interaction {
|
||||
match self.interaction {
|
||||
Some(Interaction::Drawing) => MouseCursor::Crosshair,
|
||||
Some(Interaction::Panning { .. }) => MouseCursor::Grabbing,
|
||||
None if cursor.is_over(&bounds) => MouseCursor::Crosshair,
|
||||
_ => MouseCursor::default(),
|
||||
Some(Interaction::Drawing) => mouse::Interaction::Crosshair,
|
||||
Some(Interaction::Panning { .. }) => {
|
||||
mouse::Interaction::Grabbing
|
||||
}
|
||||
None if cursor.is_over(&bounds) => {
|
||||
mouse::Interaction::Crosshair
|
||||
}
|
||||
_ => mouse::Interaction::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ mod rainbow {
|
|||
// if you wish to, by creating your own `Renderer` trait, which could be
|
||||
// implemented by `iced_wgpu` and other renderers.
|
||||
use iced_native::{
|
||||
layout, Element, Hasher, Layout, Length, MouseCursor, Point, Size,
|
||||
Vector, Widget,
|
||||
layout, mouse, Element, Hasher, Layout, Length, Point, Size, Vector,
|
||||
Widget,
|
||||
};
|
||||
use iced_wgpu::{
|
||||
triangle::{Mesh2D, Vertex2D},
|
||||
|
|
@ -54,7 +54,7 @@ mod rainbow {
|
|||
_defaults: &Defaults,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
) -> (Primitive, MouseCursor) {
|
||||
) -> (Primitive, mouse::Interaction) {
|
||||
let b = layout.bounds();
|
||||
|
||||
// R O Y G B I V
|
||||
|
|
@ -141,7 +141,7 @@ mod rainbow {
|
|||
},
|
||||
}),
|
||||
},
|
||||
MouseCursor::default(),
|
||||
mouse::Interaction::default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use iced_wgpu::{
|
|||
wgpu, window::SwapChain, Primitive, Renderer, Settings, Target,
|
||||
};
|
||||
use iced_winit::{
|
||||
futures, winit, Cache, Clipboard, MouseCursor, Size, UserInterface,
|
||||
futures, mouse, winit, Cache, Clipboard, Size, UserInterface,
|
||||
};
|
||||
|
||||
use winit::{
|
||||
|
|
@ -63,7 +63,7 @@ pub fn main() {
|
|||
let mut events = Vec::new();
|
||||
let mut cache = Some(Cache::default());
|
||||
let mut renderer = Renderer::new(&mut device, Settings::default());
|
||||
let mut output = (Primitive::None, MouseCursor::default());
|
||||
let mut output = (Primitive::None, mouse::Interaction::default());
|
||||
let clipboard = Clipboard::new(&window);
|
||||
|
||||
// Initialize scene and GUI controls
|
||||
|
|
@ -189,7 +189,7 @@ pub fn main() {
|
|||
scene.draw(&mut encoder, &frame.view);
|
||||
|
||||
// And then iced on top
|
||||
let mouse_cursor = renderer.draw(
|
||||
let mouse_interaction = renderer.draw(
|
||||
&mut device,
|
||||
&mut encoder,
|
||||
Target {
|
||||
|
|
@ -205,9 +205,11 @@ pub fn main() {
|
|||
queue.submit(&[encoder.finish()]);
|
||||
|
||||
// And update the mouse cursor
|
||||
window.set_cursor_icon(iced_winit::conversion::mouse_cursor(
|
||||
mouse_cursor,
|
||||
));
|
||||
window.set_cursor_icon(
|
||||
iced_winit::conversion::mouse_interaction(
|
||||
mouse_interaction,
|
||||
),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue