iced-yoda/wgpu/src/primitive.rs

101 lines
2.6 KiB
Rust
Raw Normal View History

use iced_native::{
2020-02-12 08:49:42 +01:00
image, svg, Background, Color, Font, HorizontalAlignment, Point, Rectangle,
Vector, VerticalAlignment,
};
2019-10-05 19:22:51 +02:00
use crate::triangle;
use std::sync::Arc;
2019-11-22 22:14:24 +01:00
/// A rendering primitive.
2019-10-05 19:22:51 +02:00
#[derive(Debug, Clone)]
pub enum Primitive {
2019-11-22 22:14:24 +01:00
/// An empty primitive
2019-10-05 19:22:51 +02:00
None,
2019-11-22 22:14:24 +01:00
/// A group of primitives
2019-10-05 19:22:51 +02:00
Group {
2019-11-22 22:14:24 +01:00
/// The primitives of the group
2019-10-05 19:22:51 +02:00
primitives: Vec<Primitive>,
},
2019-11-22 22:14:24 +01:00
/// A text primitive
2019-10-05 19:22:51 +02:00
Text {
2019-11-22 22:14:24 +01:00
/// The contents of the text
2019-10-05 19:22:51 +02:00
content: String,
2019-11-22 22:14:24 +01:00
/// The bounds of the text
2019-10-05 19:22:51 +02:00
bounds: Rectangle,
2019-11-22 22:14:24 +01:00
/// The color of the text
color: Color,
2019-11-22 22:14:24 +01:00
/// The size of the text
2019-10-05 19:22:51 +02:00
size: f32,
2019-11-22 22:14:24 +01:00
/// The font of the text
font: Font,
2019-11-22 22:14:24 +01:00
/// The horizontal alignment of the text
horizontal_alignment: HorizontalAlignment,
2019-11-22 22:14:24 +01:00
/// The vertical alignment of the text
vertical_alignment: VerticalAlignment,
2019-10-05 19:22:51 +02:00
},
2019-11-22 22:14:24 +01:00
/// A quad primitive
2019-10-07 02:17:40 +02:00
Quad {
2019-11-22 22:14:24 +01:00
/// The bounds of the quad
2019-10-06 19:22:25 +02:00
bounds: Rectangle,
2019-11-22 22:14:24 +01:00
/// The background of the quad
2019-10-06 19:22:25 +02:00
background: Background,
2019-11-22 22:14:24 +01:00
/// The border radius of the quad
border_radius: u16,
/// The border width of the quad
border_width: u16,
/// The border color of the quad
border_color: Color,
2019-10-06 19:22:25 +02:00
},
2019-11-22 22:14:24 +01:00
/// An image primitive
Image {
/// The handle of the image
handle: image::Handle,
2019-11-22 22:14:24 +01:00
/// The bounds of the image
bounds: Rectangle,
},
/// An SVG primitive
Svg {
/// The path of the SVG file
handle: svg::Handle,
/// The bounds of the viewport
bounds: Rectangle,
},
2019-11-22 22:14:24 +01:00
/// A clip primitive
Clip {
2019-11-22 22:14:24 +01:00
/// The bounds of the clip
bounds: Rectangle,
2019-11-22 22:14:24 +01:00
/// The offset transformation of the clip
offset: Vector<u32>,
2019-11-22 22:14:24 +01:00
/// The content of the clip
content: Box<Primitive>,
},
/// A low-level primitive to render a mesh of triangles.
///
/// It can be used to render many kinds of geometry freely.
2020-02-12 08:49:42 +01:00
Mesh2D {
/// The top-left coordinate of the mesh
origin: Point,
/// The vertex and index buffers of the mesh
2020-03-07 23:45:54 +01:00
buffers: triangle::Mesh2D,
},
/// A cached primitive.
///
/// This can be useful if you are implementing a widget where primitive
/// generation is expensive.
Cached {
/// The origin of the coordinate system of the cached primitives
origin: Point,
/// The cached primitive
cache: Arc<Primitive>,
2020-02-12 08:49:42 +01:00
},
2019-10-06 19:22:25 +02:00
}
impl Default for Primitive {
fn default() -> Primitive {
Primitive::None
}
}