diff options
author | 2019-12-06 19:37:56 +0100 | |
---|---|---|
committer | 2019-12-11 21:34:40 +0100 | |
commit | a88aae5e04e0a92457e5dd617a86af823e90af6c (patch) | |
tree | 2b3601cc15d041709a883c3b80685cf8e0baaa20 /wgpu | |
parent | 80324284282f173e4d26e1f297daaf71a93f51a6 (diff) | |
download | iced-a88aae5e04e0a92457e5dd617a86af823e90af6c.tar.gz iced-a88aae5e04e0a92457e5dd617a86af823e90af6c.tar.bz2 iced-a88aae5e04e0a92457e5dd617a86af823e90af6c.zip |
Added an `Icon` widget to native.
Diffstat (limited to 'wgpu')
-rw-r--r-- | wgpu/src/primitive.rs | 6 | ||||
-rw-r--r-- | wgpu/src/renderer/widget.rs | 1 | ||||
-rw-r--r-- | wgpu/src/renderer/widget/icon.rs | 21 | ||||
-rw-r--r-- | wgpu/src/svg.rs | 3 |
4 files changed, 26 insertions, 5 deletions
diff --git a/wgpu/src/primitive.rs b/wgpu/src/primitive.rs index c637626b..1b0729cf 100644 --- a/wgpu/src/primitive.rs +++ b/wgpu/src/primitive.rs @@ -3,8 +3,6 @@ use iced_native::{ VerticalAlignment, }; -use crate::svg; - /// A rendering primitive. #[derive(Debug, Clone)] pub enum Primitive { @@ -50,8 +48,8 @@ pub enum Primitive { }, /// A svg icon primitive Svg { - /// The handle of the icon - handle: svg::Handle, + /// The path of the icon + handle: crate::svg::Handle, /// The bounds of the icon bounds: Rectangle, }, diff --git a/wgpu/src/renderer/widget.rs b/wgpu/src/renderer/widget.rs index 52410bee..3e1b8d92 100644 --- a/wgpu/src/renderer/widget.rs +++ b/wgpu/src/renderer/widget.rs @@ -1,6 +1,7 @@ mod button; mod checkbox; mod column; +mod icon; mod image; mod radio; mod row; diff --git a/wgpu/src/renderer/widget/icon.rs b/wgpu/src/renderer/widget/icon.rs new file mode 100644 index 00000000..a271bb47 --- /dev/null +++ b/wgpu/src/renderer/widget/icon.rs @@ -0,0 +1,21 @@ +use crate::{svg::Handle, Primitive, Renderer}; +use iced_native::{ + icon, MouseCursor, Rectangle, +}; +use std::path::Path; + +impl icon::Renderer for Renderer { + fn draw( + &mut self, + bounds: Rectangle, + path: &Path, + ) -> Self::Output { + ( + Primitive::Svg { + handle: Handle::from_path(path), + bounds, + }, + MouseCursor::OutOfBounds, + ) + } +}
\ No newline at end of file diff --git a/wgpu/src/svg.rs b/wgpu/src/svg.rs index 87394799..1b8f14b0 100644 --- a/wgpu/src/svg.rs +++ b/wgpu/src/svg.rs @@ -4,12 +4,13 @@ use iced_native::{Hasher, Rectangle}; use std::{ cell::RefCell, collections::{HashMap, HashSet}, + fmt::Debug, hash::{Hash, Hasher as _}, mem, path::PathBuf, rc::Rc, + u32, }; -use std::fmt::Debug; #[derive(Debug)] |