Remove appearance from Handle

... and pass it directly to `Renderer::draw` instead.
This commit is contained in:
Héctor Ramón Jiménez 2022-12-06 04:34:00 +01:00
parent 314b0f7dc5
commit b205a66347
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
14 changed files with 112 additions and 75 deletions

View file

@ -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<Data>,
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<u32>;
/// 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<Color>, bounds: Rectangle);
}