Added an Icon widget to native.
This commit is contained in:
parent
8032428428
commit
a88aae5e04
7 changed files with 138 additions and 6 deletions
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
mod button;
|
||||
mod checkbox;
|
||||
mod column;
|
||||
mod icon;
|
||||
mod image;
|
||||
mod radio;
|
||||
mod row;
|
||||
|
|
|
|||
21
wgpu/src/renderer/widget/icon.rs
Normal file
21
wgpu/src/renderer/widget/icon.rs
Normal file
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue