Remove redundant widget modules in subcrates

Instead, we can define the type aliases just once in the root crate!
This commit is contained in:
Héctor Ramón Jiménez 2022-03-09 14:10:15 +07:00
parent 7d9ab71790
commit 12c1a3f829
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
62 changed files with 225 additions and 780 deletions

View file

@ -1,8 +1,10 @@
//! Create a renderer from a [`Backend`].
use crate::backend::{self, Backend};
use crate::{Primitive, Vector};
use iced_native::image;
use iced_native::layout;
use iced_native::renderer;
use iced_native::svg;
use iced_native::text::{self, Text};
use iced_native::{Background, Element, Font, Point, Rectangle, Size};
@ -168,3 +170,31 @@ where
});
}
}
impl<B> image::Renderer for Renderer<B>
where
B: Backend + backend::Image,
{
type Handle = image::Handle;
fn dimensions(&self, handle: &image::Handle) -> (u32, u32) {
self.backend().dimensions(handle)
}
fn draw(&mut self, handle: image::Handle, bounds: Rectangle) {
self.draw_primitive(Primitive::Image { handle, bounds })
}
}
impl<B> svg::Renderer for Renderer<B>
where
B: Backend + backend::Svg,
{
fn dimensions(&self, handle: &svg::Handle) -> (u32, u32) {
self.backend().viewport_dimensions(handle)
}
fn draw(&mut self, handle: svg::Handle, bounds: Rectangle) {
self.draw_primitive(Primitive::Svg { handle, bounds })
}
}