Create iced_widget subcrate and re-organize the whole codebase
This commit is contained in:
parent
c54409d171
commit
3a0d34c024
209 changed files with 1959 additions and 2183 deletions
|
|
@ -48,10 +48,6 @@ features = ["std"]
|
|||
version = "1.9"
|
||||
features = ["derive"]
|
||||
|
||||
[dependencies.iced_native]
|
||||
version = "0.9"
|
||||
path = "../native"
|
||||
|
||||
[dependencies.iced_graphics]
|
||||
version = "0.7"
|
||||
path = "../graphics"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
use crate::core;
|
||||
use crate::core::{Color, Font, Point, Size};
|
||||
use crate::graphics::backend;
|
||||
use crate::graphics::{Primitive, Transformation, Viewport};
|
||||
use crate::quad;
|
||||
use crate::text;
|
||||
use crate::triangle;
|
||||
use crate::{Layer, Primitive, Settings, Transformation};
|
||||
|
||||
use iced_graphics::backend;
|
||||
use iced_graphics::{Color, Font, Size, Viewport};
|
||||
use crate::{Layer, Settings};
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing::info_span;
|
||||
|
|
@ -363,9 +364,9 @@ impl backend::Text for Backend {
|
|||
size: f32,
|
||||
font: Font,
|
||||
bounds: Size,
|
||||
point: iced_native::Point,
|
||||
point: Point,
|
||||
nearest_only: bool,
|
||||
) -> Option<text::Hit> {
|
||||
) -> Option<core::text::Hit> {
|
||||
self.text_pipeline.hit_test(
|
||||
contents,
|
||||
size,
|
||||
|
|
@ -383,17 +384,14 @@ 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: &core::image::Handle) -> Size<u32> {
|
||||
self.image_pipeline.dimensions(handle)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
impl backend::Svg for Backend {
|
||||
fn viewport_dimensions(
|
||||
&self,
|
||||
handle: &iced_native::svg::Handle,
|
||||
) -> Size<u32> {
|
||||
fn viewport_dimensions(&self, handle: &core::svg::Handle) -> Size<u32> {
|
||||
self.image_pipeline.viewport_dimensions(handle)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use iced_graphics::geometry::fill::{self, Fill};
|
||||
use iced_graphics::geometry::{
|
||||
use crate::core::{Gradient, Point, Rectangle, Size, Vector};
|
||||
use crate::graphics::geometry::fill::{self, Fill};
|
||||
use crate::graphics::geometry::{
|
||||
LineCap, LineDash, LineJoin, Path, Stroke, Style, Text,
|
||||
};
|
||||
use iced_graphics::primitive::{self, Primitive};
|
||||
use iced_graphics::{Gradient, Point, Rectangle, Size, Vector};
|
||||
use crate::graphics::primitive::{self, Primitive};
|
||||
|
||||
use lyon::geom::euclid;
|
||||
use lyon::tessellation;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
mod atlas;
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
use iced_graphics::image::raster;
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
use iced_graphics::image::vector;
|
||||
|
||||
use crate::layer;
|
||||
use crate::{Buffer, Transformation};
|
||||
use atlas::Atlas;
|
||||
|
||||
use iced_native::{Rectangle, Size};
|
||||
use crate::core::{Rectangle, Size};
|
||||
use crate::graphics::Transformation;
|
||||
use crate::layer;
|
||||
use crate::Buffer;
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
use crate::graphics::image::raster;
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
use crate::graphics::image::vector;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
|
|
@ -18,10 +19,10 @@ use std::mem;
|
|||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
use iced_native::image;
|
||||
use crate::core::image;
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
use iced_native::svg;
|
||||
use crate::core::svg;
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing::info_span;
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ use allocator::Allocator;
|
|||
|
||||
pub const SIZE: u32 = 2048;
|
||||
|
||||
use iced_graphics::image;
|
||||
use iced_graphics::Size;
|
||||
use crate::core::Size;
|
||||
use crate::graphics::image;
|
||||
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::core::Size;
|
||||
use crate::image::atlas::{self, allocator};
|
||||
|
||||
use iced_graphics::Size;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Allocation {
|
||||
Partial {
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ impl Region {
|
|||
(rectangle.min.x as u32, rectangle.min.y as u32)
|
||||
}
|
||||
|
||||
pub fn size(&self) -> iced_graphics::Size<u32> {
|
||||
pub fn size(&self) -> crate::core::Size<u32> {
|
||||
let size = self.allocation.rectangle.size();
|
||||
|
||||
iced_graphics::Size::new(size.width as u32, size.height as u32)
|
||||
crate::core::Size::new(size.width as u32, size.height as u32)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::core::Size;
|
||||
use crate::graphics::image;
|
||||
use crate::image::atlas;
|
||||
|
||||
use iced_graphics::image;
|
||||
use iced_graphics::Size;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Entry {
|
||||
Contiguous(atlas::Allocation),
|
||||
|
|
|
|||
|
|
@ -10,12 +10,9 @@ pub use mesh::Mesh;
|
|||
pub use quad::Quad;
|
||||
pub use text::Text;
|
||||
|
||||
use crate::Primitive;
|
||||
|
||||
use iced_graphics::alignment;
|
||||
use iced_graphics::{
|
||||
Background, Color, Font, Point, Rectangle, Size, Vector, Viewport,
|
||||
};
|
||||
use crate::core::alignment;
|
||||
use crate::core::{Background, Color, Font, Point, Rectangle, Size, Vector};
|
||||
use crate::graphics::{Primitive, Viewport};
|
||||
|
||||
/// A group of primitives that should be clipped together.
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{Color, Rectangle};
|
||||
|
||||
use iced_native::{image, svg};
|
||||
use crate::core::image;
|
||||
use crate::core::svg;
|
||||
use crate::core::{Color, Rectangle};
|
||||
|
||||
/// A raster or vector image.
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! A collection of triangle primitives.
|
||||
use crate::primitive;
|
||||
use crate::{Gradient, Point, Rectangle};
|
||||
use crate::core::{Gradient, Point, Rectangle};
|
||||
use crate::graphics::primitive;
|
||||
|
||||
/// A mesh of triangles.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{alignment, Color, Font, Rectangle};
|
||||
use crate::core::alignment;
|
||||
use crate::core::{Color, Font, Rectangle};
|
||||
|
||||
/// A paragraph of text.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
|
|||
|
|
@ -50,25 +50,17 @@ mod quad;
|
|||
mod text;
|
||||
mod triangle;
|
||||
|
||||
pub use iced_graphics::primitive;
|
||||
pub use iced_graphics::{
|
||||
Antialiasing, Color, Error, Font, Gradient, Point, Rectangle, Size, Vector,
|
||||
Viewport,
|
||||
};
|
||||
pub use iced_native::alignment;
|
||||
pub use iced_graphics as graphics;
|
||||
pub use iced_graphics::core;
|
||||
|
||||
pub use iced_native::Theme;
|
||||
pub use wgpu;
|
||||
|
||||
pub use backend::Backend;
|
||||
pub use layer::Layer;
|
||||
pub use primitive::Primitive;
|
||||
pub use settings::Settings;
|
||||
|
||||
use buffer::Buffer;
|
||||
|
||||
use iced_graphics::Transformation;
|
||||
|
||||
#[cfg(any(feature = "image", feature = "svg"))]
|
||||
mod image;
|
||||
|
||||
|
|
@ -76,5 +68,4 @@ mod image;
|
|||
///
|
||||
/// [`wgpu`]: https://github.com/gfx-rs/wgpu-rs
|
||||
/// [`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>;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::core::Rectangle;
|
||||
use crate::graphics::Transformation;
|
||||
use crate::layer;
|
||||
use crate::{Buffer, Transformation};
|
||||
|
||||
use iced_native::Rectangle;
|
||||
use crate::Buffer;
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::mem;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
//! Configure a renderer.
|
||||
pub use crate::Antialiasing;
|
||||
|
||||
use crate::Font;
|
||||
use crate::core::Font;
|
||||
use crate::graphics::Antialiasing;
|
||||
|
||||
/// The settings of a [`Backend`].
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
use crate::core::alignment;
|
||||
use crate::core::text::Hit;
|
||||
use crate::core::{Color, Font, Point, Rectangle, Size};
|
||||
use crate::layer::Text;
|
||||
|
||||
pub use iced_native::text::Hit;
|
||||
|
||||
use iced_native::alignment;
|
||||
use iced_native::{Color, Font, Rectangle, Size};
|
||||
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use std::borrow::Cow;
|
||||
use std::cell::RefCell;
|
||||
|
|
@ -269,9 +267,9 @@ impl Pipeline {
|
|||
&self,
|
||||
content: &str,
|
||||
size: f32,
|
||||
font: iced_native::Font,
|
||||
bounds: iced_native::Size,
|
||||
point: iced_native::Point,
|
||||
font: Font,
|
||||
bounds: Size,
|
||||
point: Point,
|
||||
_nearest_only: bool,
|
||||
) -> Option<Hit> {
|
||||
self.system.as_ref().unwrap().with(|fields| {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
mod msaa;
|
||||
|
||||
use crate::buffer::r#static::Buffer;
|
||||
use crate::core::{Gradient, Size};
|
||||
use crate::graphics::{Antialiasing, Transformation};
|
||||
use crate::layer::mesh::{self, Mesh};
|
||||
use crate::settings;
|
||||
use crate::Transformation;
|
||||
|
||||
use iced_graphics::Size;
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing::info_span;
|
||||
|
|
@ -137,7 +135,7 @@ impl Layer {
|
|||
gradient_vertex_offset += written_bytes;
|
||||
|
||||
match gradient {
|
||||
iced_graphics::Gradient::Linear(linear) => {
|
||||
Gradient::Linear(linear) => {
|
||||
use glam::{IVec4, Vec4};
|
||||
|
||||
let start_offset = self.gradient.color_stop_offset;
|
||||
|
|
@ -319,7 +317,7 @@ impl Pipeline {
|
|||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
format: wgpu::TextureFormat,
|
||||
antialiasing: Option<settings::Antialiasing>,
|
||||
antialiasing: Option<Antialiasing>,
|
||||
) -> Pipeline {
|
||||
Pipeline {
|
||||
blit: antialiasing.map(|a| msaa::Blit::new(device, format, a)),
|
||||
|
|
@ -453,7 +451,7 @@ fn primitive_state() -> wgpu::PrimitiveState {
|
|||
}
|
||||
|
||||
fn multisample_state(
|
||||
antialiasing: Option<settings::Antialiasing>,
|
||||
antialiasing: Option<Antialiasing>,
|
||||
) -> wgpu::MultisampleState {
|
||||
wgpu::MultisampleState {
|
||||
count: antialiasing.map(|a| a.sample_count()).unwrap_or(1),
|
||||
|
|
@ -465,11 +463,11 @@ fn multisample_state(
|
|||
mod solid {
|
||||
use crate::buffer::dynamic;
|
||||
use crate::buffer::r#static::Buffer;
|
||||
use crate::settings;
|
||||
use crate::graphics::primitive;
|
||||
use crate::graphics::{Antialiasing, Transformation};
|
||||
use crate::triangle;
|
||||
|
||||
use encase::ShaderType;
|
||||
use iced_graphics::primitive;
|
||||
use iced_graphics::Transformation;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Pipeline {
|
||||
|
|
@ -550,7 +548,7 @@ mod solid {
|
|||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
format: wgpu::TextureFormat,
|
||||
antialiasing: Option<settings::Antialiasing>,
|
||||
antialiasing: Option<Antialiasing>,
|
||||
) -> Self {
|
||||
let constants_layout = device.create_bind_group_layout(
|
||||
&wgpu::BindGroupLayoutDescriptor {
|
||||
|
|
@ -633,7 +631,7 @@ mod solid {
|
|||
mod gradient {
|
||||
use crate::buffer::dynamic;
|
||||
use crate::buffer::r#static::Buffer;
|
||||
use crate::settings;
|
||||
use crate::graphics::Antialiasing;
|
||||
use crate::triangle;
|
||||
|
||||
use encase::ShaderType;
|
||||
|
|
@ -755,7 +753,7 @@ mod gradient {
|
|||
pub(super) fn new(
|
||||
device: &wgpu::Device,
|
||||
format: wgpu::TextureFormat,
|
||||
antialiasing: Option<settings::Antialiasing>,
|
||||
antialiasing: Option<Antialiasing>,
|
||||
) -> Self {
|
||||
let constants_layout = device.create_bind_group_layout(
|
||||
&wgpu::BindGroupLayoutDescriptor {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::settings;
|
||||
use crate::graphics;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Blit {
|
||||
|
|
@ -14,7 +14,7 @@ impl Blit {
|
|||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
format: wgpu::TextureFormat,
|
||||
antialiasing: settings::Antialiasing,
|
||||
antialiasing: graphics::Antialiasing,
|
||||
) -> Blit {
|
||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
//! Connect a window with a renderer.
|
||||
use crate::{Backend, Color, Error, Primitive, Renderer, Settings, Viewport};
|
||||
use crate::core::Color;
|
||||
use crate::graphics;
|
||||
use crate::graphics::compositor;
|
||||
use crate::graphics::{Error, Primitive, Viewport};
|
||||
use crate::{Backend, Renderer, Settings};
|
||||
|
||||
use futures::stream::{self, StreamExt};
|
||||
|
||||
use iced_graphics::window::compositor;
|
||||
use iced_native::futures;
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
|
@ -184,7 +186,7 @@ pub fn present<Theme, T: AsRef<str>>(
|
|||
}
|
||||
}
|
||||
|
||||
impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
|
||||
impl<Theme> graphics::Compositor for Compositor<Theme> {
|
||||
type Settings = Settings;
|
||||
type Renderer = Renderer<Theme>;
|
||||
type Surface = wgpu::Surface;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue