Create iced_widget subcrate and re-organize the whole codebase

This commit is contained in:
Héctor Ramón Jiménez 2023-03-04 05:37:11 +01:00
parent c54409d171
commit 3a0d34c024
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
209 changed files with 1959 additions and 2183 deletions

View file

@ -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<text::Hit> {
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<u32> {
fn dimensions(&self, _handle: &crate::core::image::Handle) -> Size<u32> {
// 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<u32> {
// TODO
Size::new(0, 0)

View file

@ -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,

View file

@ -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<Theme = iced_native::Theme> =
iced_graphics::Renderer<Backend, Theme>;
pub type Renderer<Theme> = iced_graphics::Renderer<Backend, Theme>;

View file

@ -1,4 +1,4 @@
use crate::Font;
use crate::core::Font;
/// The settings of a [`Backend`].
///

View file

@ -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<Hit> {
self.system.as_ref().unwrap().with(|fields| {

View file

@ -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<u32>,
}
impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
type Settings = Settings;
type Renderer = Renderer<Theme>;
type Surface = Surface;