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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
//! Container theme trait - Contract/Connector for scrollbar colors and dimensions
//!
//! # Architecture Role
//!
//! **ContainerTheme is a CONTRACT/CONNECTOR trait** that connects:
//! - Factory rendering functions (`factory/render.rs`)
//! - System theme managers (e.g., `AppTheme`, etc.)
//!
//! # How It Works
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ 1. System Theme Manager (e.g., AppTheme) │
//! │ - Stores actual color values │
//! │ - Implements ContainerTheme trait (mapping) │
//! └─────────────────────────────────────────────────────────────┘
//! ↓
//! ┌─────────────────────────────────────────────────────────────┐
//! │ 2. ContainerTheme trait (THIS MODULE) │
//! │ - Defines contract (which methods/colors needed) │
//! │ - Acts as connector interface │
//! └─────────────────────────────────────────────────────────────┘
//! ↓
//! ┌─────────────────────────────────────────────────────────────┐
//! │ 3. Factory render functions (factory/render.rs) │
//! │ - Accept &dyn ContainerTheme │
//! │ - Call trait methods to get colors/dimensions │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Implementation Example
//!
//! Each system theme manager implements ContainerTheme with proper color mapping:
//!
//! ```rust,ignore
//! // In ui/render/theme.rs (or your theme module)
//! impl ContainerTheme for AppTheme {
//! fn scrollbar_width(&self) -> f64 {
//! 12.0
//! }
//!
//! fn scrollbar_track_color(&self) -> [u8; 4] {
//! [30, 30, 30, 255] // ← Map to your theme's scrollbar track color
//! }
//!
//! fn scrollbar_thumb_color(&self) -> [u8; 4] {
//! [80, 80, 80, 255] // ← Map to your theme's scrollbar thumb color
//! }
//! // ... rest of methods
//! }
//! ```
//!
//! # Usage in Factory
//!
//! ```rust,ignore
//! use container::factory::render_default;
//!
//! let app_theme = AppTheme::default();
//!
//! // AppTheme automatically converts to &dyn ContainerTheme
//! render_default(ctx, &container, &app_theme, &state, &input_handler, rect);
//! // ↑ Any theme implementing ContainerTheme
//! ```
//!
//! # Notes
//!
//! - **Not used in production inline rendering** - Terminal uses direct color access
//! - **Used by factory for prototyping** - Enables factory to work with any theme
//! - **Each project implements its own mapping** - No hardcoded theme assumptions
/// Theme trait for container scrollbar colors and dimensions
///
/// This trait defines the color and dimension contract that any system theme
/// must implement to work with factory rendering functions.
///
/// # Responsibility
///
/// **System theme managers** (e.g., AppTheme) implement this trait by:
/// - Mapping their internal color fields to ContainerTheme methods
/// - Providing appropriate colors for scrollbar states
/// - Providing dimensions for scrollbar sizing
///
/// **Factory rendering** uses this trait by:
/// - Accepting `&dyn ContainerTheme` parameter
/// - Calling trait methods to get colors and dimensions
/// - Working with ANY theme that implements this contract
///
/// # Default Theme
///
/// If you don't have a system theme yet, use `DefaultContainerTheme`:
///
/// ```rust,ignore
/// use container::factory::render_default;
/// use container::theme::DefaultContainerTheme;
///
/// let theme = DefaultContainerTheme::new();
/// render_default(ctx, &container, &theme, &state, &input_handler, rect);
/// ```
///
/// # Implementation Location
///
/// Implement this trait in the **same module as your system theme**:
///
/// ```rust,ignore
/// // In ui/render/theme.rs (example for Terminal)
/// pub struct AppTheme {
/// pub scrollbar_track: [u8; 4],
/// pub scrollbar_thumb: [u8; 4],
/// pub scrollbar_hover: [u8; 4],
/// // ... other theme fields
/// }
///
/// impl ContainerTheme for AppTheme {
/// fn scrollbar_width(&self) -> f64 { 12.0 }
/// fn scrollbar_track_color(&self) -> [u8; 4] { self.scrollbar_track }
/// fn scrollbar_thumb_color(&self) -> [u8; 4] { self.scrollbar_thumb }
/// // ... map all methods to your theme fields
/// }
/// ```
// =============================================================================
// Default Theme Implementation
// =============================================================================
/// Default container theme using inline spec colors
///
/// This theme provides the exact colors and dimensions from the inline specs
/// (layout/render_ui.rs:246) for quick prototyping.
///
/// # Colors
///
/// - Track: rgba(30, 30, 30, 255)
/// - Thumb: rgba(80, 80, 80, 255)
/// - Hover: rgba(100, 100, 100, 255)
///
/// # Dimensions
///
/// - Scrollbar width: 12.0px
/// - Min thumb height: 20.0px
/// - Container padding: 0.0px
///
/// # Usage
///
/// ```rust,ignore
/// use container::factory::render_default;
/// use container::theme::DefaultContainerTheme;
///
/// let theme = DefaultContainerTheme::new();
/// render_default(ctx, &container, &theme, &state, &input_handler, rect);
/// ```
///
/// For production, implement ContainerTheme for your system theme instead.
;