summaryrefslogtreecommitdiffstats
path: root/renderer
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-21 17:56:01 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-21 17:56:01 +0100
commit7a50e9e8fbb8d37e53a42c1dd5936b97463ead53 (patch)
treec0960018f287bcb2043a1752ae85ad0d45e00f21 /renderer
parent545cc909c9f356dd733d273173694db9b8c28594 (diff)
downloadiced-7a50e9e8fbb8d37e53a42c1dd5936b97463ead53.tar.gz
iced-7a50e9e8fbb8d37e53a42c1dd5936b97463ead53.tar.bz2
iced-7a50e9e8fbb8d37e53a42c1dd5936b97463ead53.zip
Convert `Renderer::Theme` to generic `Widget` type
Diffstat (limited to 'renderer')
-rw-r--r--renderer/src/compositor.rs14
-rw-r--r--renderer/src/geometry.rs2
-rw-r--r--renderer/src/geometry/cache.rs4
-rw-r--r--renderer/src/lib.rs29
4 files changed, 23 insertions, 26 deletions
diff --git a/renderer/src/compositor.rs b/renderer/src/compositor.rs
index f10ed048..dc2c50ff 100644
--- a/renderer/src/compositor.rs
+++ b/renderer/src/compositor.rs
@@ -5,10 +5,10 @@ use crate::{Renderer, Settings};
use std::env;
-pub enum Compositor<Theme> {
- TinySkia(iced_tiny_skia::window::Compositor<Theme>),
+pub enum Compositor {
+ TinySkia(iced_tiny_skia::window::Compositor),
#[cfg(feature = "wgpu")]
- Wgpu(iced_wgpu::window::Compositor<Theme>),
+ Wgpu(iced_wgpu::window::Compositor),
}
pub enum Surface {
@@ -17,9 +17,9 @@ pub enum Surface {
Wgpu(iced_wgpu::window::Surface<'static>),
}
-impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
+impl crate::graphics::Compositor for Compositor {
type Settings = Settings;
- type Renderer = Renderer<Theme>;
+ type Renderer = Renderer;
type Surface = Surface;
fn new<W: Window + Clone>(
@@ -225,11 +225,11 @@ impl Candidate {
)
}
- fn build<Theme, W: Window>(
+ fn build<W: Window>(
self,
settings: Settings,
_compatible_window: W,
- ) -> Result<Compositor<Theme>, Error> {
+ ) -> Result<Compositor, Error> {
match self {
Self::TinySkia => {
let compositor = iced_tiny_skia::window::compositor::new(
diff --git a/renderer/src/geometry.rs b/renderer/src/geometry.rs
index 1ecb0a43..19ac87da 100644
--- a/renderer/src/geometry.rs
+++ b/renderer/src/geometry.rs
@@ -29,7 +29,7 @@ macro_rules! delegate {
}
impl Frame {
- pub fn new<Theme>(renderer: &Renderer<Theme>, size: Size) -> Self {
+ pub fn new(renderer: &Renderer, size: Size) -> Self {
match renderer {
Renderer::TinySkia(_) => {
Frame::TinySkia(iced_tiny_skia::geometry::Frame::new(size))
diff --git a/renderer/src/geometry/cache.rs b/renderer/src/geometry/cache.rs
index d4bb04b3..3aff76b9 100644
--- a/renderer/src/geometry/cache.rs
+++ b/renderer/src/geometry/cache.rs
@@ -54,9 +54,9 @@ impl Cache {
/// Otherwise, the previously stored [`Geometry`] will be returned. The
/// [`Cache`] is not cleared in this case. In other words, it will keep
/// returning the stored [`Geometry`] if needed.
- pub fn draw<Theme>(
+ pub fn draw(
&self,
- renderer: &Renderer<Theme>,
+ renderer: &Renderer,
bounds: Size,
draw_fn: impl FnOnce(&mut Frame),
) -> Geometry {
diff --git a/renderer/src/lib.rs b/renderer/src/lib.rs
index f2acfa00..a7df414b 100644
--- a/renderer/src/lib.rs
+++ b/renderer/src/lib.rs
@@ -32,10 +32,10 @@ use std::borrow::Cow;
/// The default graphics renderer for [`iced`].
///
/// [`iced`]: https://github.com/iced-rs/iced
-pub enum Renderer<Theme> {
- TinySkia(iced_tiny_skia::Renderer<Theme>),
+pub enum Renderer {
+ TinySkia(iced_tiny_skia::Renderer),
#[cfg(feature = "wgpu")]
- Wgpu(iced_wgpu::Renderer<Theme>),
+ Wgpu(iced_wgpu::Renderer),
}
macro_rules! delegate {
@@ -48,7 +48,7 @@ macro_rules! delegate {
};
}
-impl<T> Renderer<T> {
+impl Renderer {
pub fn draw_mesh(&mut self, mesh: Mesh) {
match self {
Self::TinySkia(_) => {
@@ -64,9 +64,7 @@ impl<T> Renderer<T> {
}
}
-impl<T> core::Renderer for Renderer<T> {
- type Theme = T;
-
+impl core::Renderer for Renderer {
fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)) {
match self {
Self::TinySkia(renderer) => {
@@ -148,15 +146,14 @@ impl<T> core::Renderer for Renderer<T> {
}
}
-impl<T> text::Renderer for Renderer<T> {
+impl text::Renderer for Renderer {
type Font = Font;
type Paragraph = Paragraph;
type Editor = Editor;
- const ICON_FONT: Font = iced_tiny_skia::Renderer::<T>::ICON_FONT;
- const CHECKMARK_ICON: char = iced_tiny_skia::Renderer::<T>::CHECKMARK_ICON;
- const ARROW_DOWN_ICON: char =
- iced_tiny_skia::Renderer::<T>::ARROW_DOWN_ICON;
+ const ICON_FONT: Font = iced_tiny_skia::Renderer::ICON_FONT;
+ const CHECKMARK_ICON: char = iced_tiny_skia::Renderer::CHECKMARK_ICON;
+ const ARROW_DOWN_ICON: char = iced_tiny_skia::Renderer::ARROW_DOWN_ICON;
fn default_font(&self) -> Self::Font {
delegate!(self, renderer, renderer.default_font())
@@ -214,7 +211,7 @@ impl<T> text::Renderer for Renderer<T> {
}
#[cfg(feature = "image")]
-impl<T> crate::core::image::Renderer for Renderer<T> {
+impl crate::core::image::Renderer for Renderer {
type Handle = crate::core::image::Handle;
fn dimensions(
@@ -235,7 +232,7 @@ impl<T> crate::core::image::Renderer for Renderer<T> {
}
#[cfg(feature = "svg")]
-impl<T> crate::core::svg::Renderer for Renderer<T> {
+impl crate::core::svg::Renderer for Renderer {
fn dimensions(&self, handle: &crate::core::svg::Handle) -> core::Size<u32> {
delegate!(self, renderer, renderer.dimensions(handle))
}
@@ -251,7 +248,7 @@ impl<T> crate::core::svg::Renderer for Renderer<T> {
}
#[cfg(feature = "geometry")]
-impl<T> crate::graphics::geometry::Renderer for Renderer<T> {
+impl crate::graphics::geometry::Renderer for Renderer {
type Geometry = crate::Geometry;
fn draw(&mut self, layers: Vec<Self::Geometry>) {
@@ -283,7 +280,7 @@ impl<T> crate::graphics::geometry::Renderer for Renderer<T> {
}
#[cfg(feature = "wgpu")]
-impl<T> iced_wgpu::primitive::pipeline::Renderer for Renderer<T> {
+impl iced_wgpu::primitive::pipeline::Renderer for Renderer {
fn draw_pipeline_primitive(
&mut self,
bounds: Rectangle,