1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use crate::{Color, Point};
use crate::{image_map, Rect};
use crate::text;
use crate::color::Rgba;
use crate::draw::shape::triangle::Triangle;
use crate::render::text::Text;
use crate::widget::primitive::shape::triangles::ColoredPoint;
/// The unique kind for each primitive element in the Ui.
pub enum PrimitiveKind {
Clip,
UnClip,
/// A filled `Rectangle`.
///
/// These are produced by the `Rectangle` and `BorderedRectangle` primitive widgets. A `Filled`
/// `Rectangle` widget produces a single `Rectangle`. The `BorderedRectangle` produces two
/// `Rectangle`s, the first for the outer border and the second for the inner on top.
Rectangle {
/// The fill colour for the rectangle.
color: Color
},
/// A series of consecutive `Triangles` that are all the same color.
TrianglesSingleColor {
/// The color of all triangles.
color: Rgba, //Todo why is this not Color
/// An ordered slice of triangles.
triangles: Vec<Triangle<Point>>
},
/// A series of consecutive `Triangles` with unique colors per vertex.
///
/// This variant is produced by the general purpose `Triangles` primitive widget.
TrianglesMultiColor {
/// An ordered slice of multicolored triangles.
triangles: Vec<Triangle<ColoredPoint>>
},
/// A single `Image`, produced by the primitive `Image` widget.
Image {
/// The unique identifier of the image that will be drawn.
image_id: image_map::Id,
/// When `Some`, colours the `Image`. When `None`, the `Image` uses its regular colours.
color: Option<Color>,
/// The area of the texture that will be drawn to the `Image`'s `Rect`.
source_rect: Option<Rect>,
},
/// A single block of `Text`, produced by the primitive `Text` widget.
Text {
/// The colour of the `Text`.
color: Color,
/// All glyphs within the `Text` laid out in their correct positions in order from top-left
/// to bottom right.
text: Text,
/// The unique identifier for the font, useful for the `glyph_cache.rect_for(id, glyph)`
/// method when using the `carbide::text::GlyphCache` (rusttype's GPU `Cache`).
font_id: text::font::Id,
},
}