From 75ae0de9bdd3376b6e537bf59030059c926114ee Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Wed, 16 Nov 2022 17:42:41 +0100 Subject: feat: SVG styling with icon fill color --- native/src/svg.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'native/src/svg.rs') diff --git a/native/src/svg.rs b/native/src/svg.rs index a8e481d2..08b0984a 100644 --- a/native/src/svg.rs +++ b/native/src/svg.rs @@ -6,11 +6,14 @@ use std::hash::{Hash, Hasher as _}; use std::path::PathBuf; use std::sync::Arc; +pub use iced_style::svg::{Appearance, StyleSheet}; + /// A handle of Svg data. #[derive(Debug, Clone)] pub struct Handle { id: u64, data: Arc, + appearance: Appearance, } impl Handle { @@ -36,6 +39,7 @@ impl Handle { Handle { id: hasher.finish(), data: Arc::new(data), + appearance: Appearance::default(), } } @@ -48,6 +52,16 @@ impl Handle { pub fn data(&self) -> &Data { &self.data } + + /// Returns the styling [`Appearance`] for the SVG. + pub fn appearance(&self) -> Appearance { + self.appearance + } + + /// Set the [`Appearance`] for the SVG. + pub fn set_appearance(&mut self, appearance: Appearance) { + self.appearance = appearance; + } } impl Hash for Handle { -- cgit From b205a663471a8170d7b30cc59894425c09bea563 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 6 Dec 2022 04:34:00 +0100 Subject: Remove `appearance` from `Handle` ... and pass it directly to `Renderer::draw` instead. --- native/src/svg.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'native/src/svg.rs') diff --git a/native/src/svg.rs b/native/src/svg.rs index 08b0984a..2168e409 100644 --- a/native/src/svg.rs +++ b/native/src/svg.rs @@ -1,19 +1,16 @@ //! Load and draw vector graphics. -use crate::{Hasher, Rectangle, Size}; +use crate::{Color, Hasher, Rectangle, Size}; use std::borrow::Cow; use std::hash::{Hash, Hasher as _}; use std::path::PathBuf; use std::sync::Arc; -pub use iced_style::svg::{Appearance, StyleSheet}; - /// A handle of Svg data. #[derive(Debug, Clone)] pub struct Handle { id: u64, data: Arc, - appearance: Appearance, } impl Handle { @@ -39,7 +36,6 @@ impl Handle { Handle { id: hasher.finish(), data: Arc::new(data), - appearance: Appearance::default(), } } @@ -52,16 +48,6 @@ impl Handle { pub fn data(&self) -> &Data { &self.data } - - /// Returns the styling [`Appearance`] for the SVG. - pub fn appearance(&self) -> Appearance { - self.appearance - } - - /// Set the [`Appearance`] for the SVG. - pub fn set_appearance(&mut self, appearance: Appearance) { - self.appearance = appearance; - } } impl Hash for Handle { @@ -98,6 +84,6 @@ pub trait Renderer: crate::Renderer { /// Returns the default dimensions of an SVG for the given [`Handle`]. fn dimensions(&self, handle: &Handle) -> Size; - /// Draws an SVG with the given [`Handle`] and inside the provided `bounds`. - fn draw(&mut self, handle: Handle, bounds: Rectangle); + /// Draws an SVG with the given [`Handle`], an optional [`Color`] filter, and inside the provided `bounds`. + fn draw(&mut self, handle: Handle, color: Option, bounds: Rectangle); } -- cgit