ailloli_ui_editor/paint/
paint_model.rs

1//! UI-framework-neutral editor paint command values.
2
3use ailloli_ui_core::{Color, Rect};
4use ailloli_ui_text::TextLayoutHandle;
5
6/// Neutral editor paint item. UI adapters convert this into draw commands.
7///
8/// All positions, rectangles, radii, and widths are logical pixels. Text layout
9/// handles are shared references and cheap to clone.
10///
11/// # Examples
12///
13/// ```
14/// use ailloli_ui_core::{Color, Rect};
15/// use ailloli_ui_editor::EditorPaintItem;
16/// let item = EditorPaintItem::Background { rect: Rect::new(0.0, 0.0, 20.0, 10.0), color: Color::BLACK };
17/// assert!(matches!(item, EditorPaintItem::Background { .. }));
18/// ```
19#[derive(Debug, Clone)]
20pub enum EditorPaintItem {
21    /// Editor-surface fill.
22    Background {
23        /// Area to fill.
24        rect: Rect,
25        /// Fill color.
26        color: Color,
27    },
28    /// Code gutter fill.
29    GutterBackground {
30        /// Gutter area.
31        rect: Rect,
32        /// Fill color.
33        color: Color,
34    },
35    /// Shaped one-based logical line number.
36    LineNumber {
37        /// Baseline origin `[x, y]`.
38        pos: [f32; 2],
39        /// Text color.
40        color: Color,
41        /// Shaped number layout.
42        layout: TextLayoutHandle,
43    },
44    /// Compact diagnostic mark in the gutter.
45    DiagnosticGutterMarker {
46        /// Marker area.
47        rect: Rect,
48        /// Severity color.
49        color: Color,
50    },
51    /// Vertical guide extending from a fold marker.
52    FoldGutterGuide {
53        /// Guide area.
54        rect: Rect,
55        /// Guide color.
56        color: Color,
57    },
58    /// Interactive fold marker in the gutter.
59    FoldGutterMarker {
60        /// Marker hit/draw area.
61        rect: Rect,
62        /// Expanded or collapsed marker color.
63        color: Color,
64        /// Index into the frame's fold-region slice.
65        region_index: usize,
66        /// Whether the represented region is collapsed.
67        collapsed: bool,
68    },
69    /// Fill and focus ring for the caret's visual line.
70    ActiveLine {
71        /// Line fill area clipped to the text viewport.
72        fill_rect: Rect,
73        /// Ring bounds clipped to the text viewport.
74        ring_rect: Rect,
75        /// Line fill color.
76        fill: Color,
77        /// Ring color.
78        ring: Color,
79    },
80    /// Selection fill for one visual-line segment.
81    Selection {
82        /// Selected visual segment.
83        rect: Rect,
84        /// Selection color.
85        color: Color,
86    },
87    /// Search-result fill for one visual-line segment.
88    SearchHighlight {
89        /// Matched visual segment.
90        rect: Rect,
91        /// Active or inactive match color.
92        color: Color,
93        /// Whether this segment belongs to the active match.
94        active: bool,
95    },
96    /// Two-logical-pixel diagnostic underline.
97    DiagnosticUnderline {
98        /// Underline area.
99        rect: Rect,
100        /// Severity color.
101        color: Color,
102        /// Whether this diagnostic is active.
103        active: bool,
104    },
105    /// Shaped label displayed after a collapsed fold header.
106    FoldPlaceholder {
107        /// Baseline origin `[x, y]`.
108        pos: [f32; 2],
109        /// Label color.
110        color: Color,
111        /// Shaped placeholder label.
112        layout: TextLayoutHandle,
113    },
114    /// Uniform or syntax-styled text run.
115    Text {
116        /// Baseline origin `[x, y]`.
117        pos: [f32; 2],
118        /// Base text color for adapters that do not inspect glyph colors.
119        color: Color,
120        /// Shaped text layout.
121        layout: TextLayoutHandle,
122    },
123    /// Insertion caret.
124    Caret {
125        /// Caret rectangle.
126        rect: Rect,
127        /// Caret color.
128        color: Color,
129    },
130    /// Vertical or horizontal scrollbar track and thumb.
131    Scrollbar {
132        /// Complete track bounds.
133        track_rect: Rect,
134        /// Scroll-position thumb bounds inside the track.
135        thumb_rect: Rect,
136        /// Track fill color.
137        track_color: Color,
138        /// Thumb fill color.
139        thumb_color: Color,
140        /// Corner radius in logical pixels.
141        radius: f32,
142    },
143}