From 3a0d34c0240f4421737a6a08761f99d6f8140d02 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Mar 2023 05:37:11 +0100 Subject: Create `iced_widget` subcrate and re-organize the whole codebase --- tiny_skia/src/backend.rs | 18 +++++++++--------- tiny_skia/src/geometry.rs | 12 ++++++------ tiny_skia/src/lib.rs | 11 +++-------- tiny_skia/src/settings.rs | 2 +- tiny_skia/src/text.rs | 11 +++++------ tiny_skia/src/window/compositor.rs | 9 +++++---- 6 files changed, 29 insertions(+), 34 deletions(-) (limited to 'tiny_skia/src') diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs index 050c6c75..d364e36a 100644 --- a/tiny_skia/src/backend.rs +++ b/tiny_skia/src/backend.rs @@ -1,9 +1,9 @@ -use crate::{Color, Font, Primitive, Settings, Size, Viewport}; - -use iced_graphics::alignment; -use iced_graphics::backend; -use iced_graphics::text; -use iced_graphics::{Background, Rectangle, Vector}; +use crate::core::alignment; +use crate::core::text; +use crate::core::{Background, Color, Font, Point, Rectangle, Size, Vector}; +use crate::graphics::backend; +use crate::graphics::{Primitive, Viewport}; +use crate::Settings; use std::borrow::Cow; @@ -470,7 +470,7 @@ impl backend::Text for Backend { size: f32, font: Font, bounds: Size, - point: iced_native::Point, + point: Point, nearest_only: bool, ) -> Option { self.text_pipeline.hit_test( @@ -490,7 +490,7 @@ impl backend::Text for Backend { #[cfg(feature = "image")] impl backend::Image for Backend { - fn dimensions(&self, _handle: &iced_native::image::Handle) -> Size { + fn dimensions(&self, _handle: &crate::core::image::Handle) -> Size { // TODO Size::new(0, 0) } @@ -500,7 +500,7 @@ impl backend::Image for Backend { impl backend::Svg for Backend { fn viewport_dimensions( &self, - _handle: &iced_native::svg::Handle, + _handle: &crate::core::svg::Handle, ) -> Size { // TODO Size::new(0, 0) diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 73fc1ebd..c66621dd 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -1,9 +1,9 @@ -use crate::{Point, Primitive, Rectangle, Size, Vector}; - -use iced_graphics::geometry::fill::{self, Fill}; -use iced_graphics::geometry::stroke::{self, Stroke}; -use iced_graphics::geometry::{Path, Style, Text}; -use iced_graphics::Gradient; +use crate::core::Gradient; +use crate::core::{Point, Rectangle, Size, Vector}; +use crate::graphics::geometry::fill::{self, Fill}; +use crate::graphics::geometry::stroke::{self, Stroke}; +use crate::graphics::geometry::{Path, Style, Text}; +use crate::graphics::Primitive; pub struct Frame { size: Size, diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs index ef5c6b1d..bf83e400 100644 --- a/tiny_skia/src/lib.rs +++ b/tiny_skia/src/lib.rs @@ -7,19 +7,14 @@ mod text; #[cfg(feature = "geometry")] pub mod geometry; -pub use iced_graphics::primitive; +pub use iced_graphics as graphics; +pub use iced_graphics::core; pub use backend::Backend; -pub use primitive::Primitive; pub use settings::Settings; -pub use iced_graphics::{ - Color, Error, Font, Point, Rectangle, Size, Vector, Viewport, -}; - /// A [`tiny-skia`] graphics renderer for [`iced`]. /// /// [`tiny-skia`]: https://github.com/RazrFalcon/tiny-skia /// [`iced`]: https://github.com/iced-rs/iced -pub type Renderer = - iced_graphics::Renderer; +pub type Renderer = iced_graphics::Renderer; diff --git a/tiny_skia/src/settings.rs b/tiny_skia/src/settings.rs index 88098345..9e4be0c4 100644 --- a/tiny_skia/src/settings.rs +++ b/tiny_skia/src/settings.rs @@ -1,4 +1,4 @@ -use crate::Font; +use crate::core::Font; /// The settings of a [`Backend`]. /// diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs index da3a06bf..7a5034c2 100644 --- a/tiny_skia/src/text.rs +++ b/tiny_skia/src/text.rs @@ -1,7 +1,6 @@ -pub use iced_native::text::Hit; - -use iced_native::alignment; -use iced_native::{Color, Font, Rectangle, Size}; +use crate::core::alignment; +use crate::core::text::Hit; +use crate::core::{Color, Font, Point, Rectangle, Size}; use rustc_hash::{FxHashMap, FxHashSet}; use std::borrow::Cow; @@ -189,8 +188,8 @@ impl Pipeline { content: &str, size: f32, font: iced_native::Font, - bounds: iced_native::Size, - point: iced_native::Point, + bounds: Size, + point: Point, _nearest_only: bool, ) -> Option { self.system.as_ref().unwrap().with(|fields| { diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 76f371e1..cea1cabf 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -1,6 +1,7 @@ -use crate::{Backend, Color, Error, Primitive, Renderer, Settings, Viewport}; - -use iced_graphics::window::compositor::{self, Information, SurfaceError}; +use crate::core::Color; +use crate::graphics::compositor::{self, Information, SurfaceError}; +use crate::graphics::{Error, Primitive, Viewport}; +use crate::{Backend, Renderer, Settings}; use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use std::marker::PhantomData; @@ -15,7 +16,7 @@ pub struct Surface { buffer: Vec, } -impl iced_graphics::window::Compositor for Compositor { +impl crate::graphics::Compositor for Compositor { type Settings = Settings; type Renderer = Renderer; type Surface = Surface; -- cgit