diff options
author | 2019-09-19 15:01:12 +0200 | |
---|---|---|
committer | 2019-09-19 15:01:12 +0200 | |
commit | f9de39ddaa3020a9585b1648afb0ead45dfd7aa9 (patch) | |
tree | 04289787e353b4b059354d22ce53f2b79464431c /examples/tour/renderer/radio.rs | |
parent | dd093c79d7da84675be648c7df2ebfc85b5039f2 (diff) | |
download | iced-f9de39ddaa3020a9585b1648afb0ead45dfd7aa9.tar.gz iced-f9de39ddaa3020a9585b1648afb0ead45dfd7aa9.tar.bz2 iced-f9de39ddaa3020a9585b1648afb0ead45dfd7aa9.zip |
Unify `web` and `ggez` tour examples :tada:
Diffstat (limited to 'examples/tour/renderer/radio.rs')
-rw-r--r-- | examples/tour/renderer/radio.rs | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/examples/tour/renderer/radio.rs b/examples/tour/renderer/radio.rs deleted file mode 100644 index 0f7815d6..00000000 --- a/examples/tour/renderer/radio.rs +++ /dev/null @@ -1,63 +0,0 @@ -use super::Renderer; - -use ggez::graphics::{DrawParam, Rect}; -use iced::{radio, MouseCursor, Point, Rectangle}; - -const SPRITE: Rect = Rect { - x: 98.0, - y: 28.0, - w: 28.0, - h: 28.0, -}; - -impl radio::Renderer for Renderer<'_> { - fn draw( - &mut self, - cursor_position: Point, - bounds: Rectangle, - bounds_with_label: Rectangle, - is_selected: bool, - ) -> MouseCursor { - let mouse_over = bounds_with_label.contains(cursor_position); - - let width = self.spritesheet.width() as f32; - let height = self.spritesheet.height() as f32; - - self.sprites.add(DrawParam { - src: Rect { - x: (SPRITE.x + (if mouse_over { SPRITE.w } else { 0.0 })) - / width, - y: SPRITE.y / height, - w: SPRITE.w / width, - h: SPRITE.h / height, - }, - dest: ggez::mint::Point2 { - x: bounds.x, - y: bounds.y, - }, - ..DrawParam::default() - }); - - if is_selected { - self.sprites.add(DrawParam { - src: Rect { - x: (SPRITE.x + SPRITE.w * 2.0) / width, - y: SPRITE.y / height, - w: SPRITE.w / width, - h: SPRITE.h / height, - }, - dest: ggez::mint::Point2 { - x: bounds.x, - y: bounds.y, - }, - ..DrawParam::default() - }); - } - - if mouse_over { - MouseCursor::Pointer - } else { - MouseCursor::OutOfBounds - } - } -} |