uzor 1.2.0

Core UI engine — geometry, interaction, input state
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
//! Atomic widget builders.
//!
//! Atomics are simpler than composites — each builder wraps a single
//! `register_layout_manager_*` call from `uzor::ui::widgets::atomic::*`.
//! Most atomics need only an id, a rect, and a label; defaults handle the
//! rest.
//!
//! For atomics not covered here (rare ones — `chevron`, `tooltip`,
//! `shape_selector`, etc.) call the raw `register_layout_manager_*` re-export
//! via [`super::raw`] directly.

use crate::core::types::Rect;
use crate::docking::panels::DockPanel;
use crate::layout::{LayoutManager, LayoutNodeId, StyleManager};
use crate::render::RenderContext;
use crate::types::{WidgetId, WidgetState};

// =============================================================================
// StyledButtonTheme — reads from StyleManager, delegates rest to Default
// =============================================================================

use crate::ui::widgets::atomic::button::theme::{ButtonTheme, DefaultButtonTheme};
use crate::ui::widgets::atomic::button::style::{ButtonStyle, DefaultButtonStyle};
use crate::ui::widgets::atomic::button::settings::ButtonSettings;

struct StyledButtonTheme {
    bg_normal:               String,
    bg_hover:                String,
    bg_active:               String,
    bg_pressed:              String,
    bg_disabled:             String,
    text_normal:             String,
    text_hover:              String,
    text_active:             String,
    text_disabled:           String,
    icon_normal:             String,
    icon_hover:              String,
    icon_active:             String,
    icon_disabled:           String,
    border_normal:           String,
    border_hover:            String,
    border_focused:          String,
    accent:                  String,
    danger:                  String,
    success:                 String,
    warning:                 String,
    toolbar_item_bg_hover:   String,
    toolbar_item_bg_active:  String,
    toolbar_item_text:       String,
    toolbar_item_text_hover: String,
    fallback:                DefaultButtonTheme,
}

impl StyledButtonTheme {
    fn from_styles(s: &StyleManager) -> Self {
        let accent     = s.color_or_owned("accent",         "#2962ff");
        let accent_dim = s.color_or_owned("accent_dim",     "rgba(41,98,255,0.15)");
        let surface    = s.color_or_owned("surface",        "transparent");
        let surface_r  = s.color_or_owned("surface_raised", "#2a2e39");
        let fg_0       = s.color_or_owned("fg_0",           "#ffffff");
        let fg_1       = s.color_or_owned("fg_1",           "#d1d5db");
        let fg_2       = s.color_or_owned("fg_2",           "#878B91");
        let fg_3       = s.color_or_owned("fg_3",           "#555860");
        let border_c   = s.color_or_owned("border",         "rgba(255,255,255,0.06)");
        let error_c    = s.color_or_owned("error",          "#ef5350");
        let ok_c       = s.color_or_owned("ok",             "#10b981");
        let warn_c     = s.color_or_owned("warn",           "#f59e0b");
        Self {
            bg_normal:               "transparent".into(),     // button text-on-surface by default
            bg_hover:                accent_dim.clone(),
            bg_active:               accent.clone(),
            bg_pressed:              accent.clone(),
            bg_disabled:             surface.clone(),
            text_normal:             fg_1.clone(),
            text_hover:              fg_0.clone(),
            text_active:             fg_0.clone(),
            text_disabled:           fg_3.clone(),
            icon_normal:             fg_2.clone(),
            icon_hover:              fg_0.clone(),
            icon_active:             fg_0.clone(),
            icon_disabled:           fg_3.clone(),
            border_normal:           border_c.clone(),
            border_hover:            border_c.clone(),
            border_focused:          accent.clone(),
            accent:                  accent.clone(),
            danger:                  error_c,
            success:                 ok_c,
            warning:                 warn_c,
            toolbar_item_bg_hover:   surface_r.clone(),
            toolbar_item_bg_active:  accent.clone(),
            toolbar_item_text:       fg_1,
            toolbar_item_text_hover: fg_0,
            fallback:                DefaultButtonTheme,
        }
    }
}

impl ButtonTheme for StyledButtonTheme {
    fn button_bg_normal(&self)   -> &str { &self.bg_normal }
    fn button_bg_hover(&self)    -> &str { &self.bg_hover }
    fn button_bg_pressed(&self)  -> &str { &self.bg_pressed }
    fn button_bg_active(&self)   -> &str { &self.bg_active }
    fn button_bg_disabled(&self) -> &str { &self.bg_disabled }

    fn button_text_normal(&self)   -> &str { &self.text_normal }
    fn button_text_hover(&self)    -> &str { &self.text_hover }
    fn button_text_active(&self)   -> &str { &self.text_active }
    fn button_text_disabled(&self) -> &str { &self.text_disabled }

    fn button_icon_normal(&self)   -> &str { &self.icon_normal }
    fn button_icon_hover(&self)    -> &str { &self.icon_hover }
    fn button_icon_active(&self)   -> &str { &self.icon_active }
    fn button_icon_disabled(&self) -> &str { &self.icon_disabled }

    fn button_border_normal(&self)  -> &str { &self.border_normal }
    fn button_border_hover(&self)   -> &str { &self.border_hover }
    fn button_border_focused(&self) -> &str { &self.border_focused }

    fn button_accent(&self)   -> &str { &self.accent }
    fn button_danger(&self)   -> &str { &self.danger }
    fn button_success(&self)  -> &str { &self.success }
    fn button_warning(&self)  -> &str { &self.warning }

    fn toolbar_item_bg_hover(&self)    -> &str { &self.toolbar_item_bg_hover }
    fn toolbar_item_bg_active(&self)   -> &str { &self.toolbar_item_bg_active }
    fn toolbar_item_text(&self)        -> &str { &self.toolbar_item_text }
    fn toolbar_item_text_hover(&self)  -> &str { &self.toolbar_item_text_hover }
    fn toolbar_item_text_active(&self) -> &str { self.fallback.toolbar_item_text_active() }
    fn toolbar_separator(&self)        -> &str { self.fallback.toolbar_separator() }
    fn toolbar_background(&self)       -> &str { self.fallback.toolbar_background() }
    fn toolbar_accent(&self)           -> &str { &self.accent }

    fn button_primary_bg(&self)           -> &str { &self.accent }
    fn button_primary_bg_hover(&self)     -> &str { self.fallback.button_primary_bg_hover() }
    fn button_danger_bg(&self)            -> &str { self.fallback.button_danger_bg() }
    fn button_danger_bg_hover(&self)      -> &str { self.fallback.button_danger_bg_hover() }
    fn button_danger_border(&self)        -> &str { self.fallback.button_danger_border() }
    fn button_danger_border_hover(&self)  -> &str { self.fallback.button_danger_border_hover() }
    fn button_danger_text(&self)          -> &str { &self.danger }
    fn button_secondary_hover_bg(&self)   -> &str { self.fallback.button_secondary_hover_bg() }
    fn button_secondary_text_muted(&self) -> &str { self.fallback.button_secondary_text_muted() }
    fn button_secondary_text(&self)       -> &str { self.fallback.button_secondary_text() }
    fn button_ghost_idle_bg(&self)        -> &str { self.fallback.button_ghost_idle_bg() }
    fn button_utility_bg(&self)           -> &str { self.fallback.button_utility_bg() }
    fn button_utility_bg_hover(&self)     -> &str { self.fallback.button_utility_bg_hover() }
}

struct StyledButtonStyle {
    radius:    f64,
    padding_x: f64,
    font_size: f64,
    fallback:  DefaultButtonStyle,
}

impl StyledButtonStyle {
    fn from_styles(s: &StyleManager) -> Self {
        Self {
            radius:    s.size_or("button_radius",    4.0),
            padding_x: s.size_or("button_padding",   8.0),
            font_size: s.size_or("button_font_size", 13.0),
            fallback:  DefaultButtonStyle,
        }
    }
}

impl ButtonStyle for StyledButtonStyle {
    fn radius(&self)             -> f64  { self.radius }
    fn padding_x(&self)          -> f64  { self.padding_x }
    fn padding_y(&self)          -> f64  { self.fallback.padding_y() }
    fn icon_size(&self)          -> f64  { self.fallback.icon_size() }
    fn font_size(&self)          -> f64  { self.font_size }
    fn gap(&self)                -> f64  { self.fallback.gap() }
    fn border_width(&self)       -> f64  { self.fallback.border_width() }
    fn show_active_border(&self) -> bool { self.fallback.show_active_border() }
}

fn button_settings_from_styles(s: &StyleManager) -> ButtonSettings {
    ButtonSettings {
        theme: Box::new(StyledButtonTheme::from_styles(s)),
        style: Box::new(StyledButtonStyle::from_styles(s)),
    }
}

// =============================================================================
// Button
// =============================================================================

use crate::ui::widgets::atomic::button::input::register_layout_manager_button;
use crate::ui::widgets::atomic::button::render::ButtonView;
use crate::types::IconId;

/// Chainable builder for an atomic button.
///
/// Reactive options:
/// - `.on_click(|| ...)` — closure invoked when the widget is clicked in the
///   current frame.  No need to handle the click via `App::on_*`.
/// - `.bind_count(&mut u32)` — increments a counter per click (for "increment"
///   style demos).
pub struct ButtonBuilder<'a> {
    id:            WidgetId,
    rect:          Rect,
    parent:        LayoutNodeId,
    text:          Option<&'a str>,
    icon:          Option<&'a IconId>,
    active:        bool,
    disabled:      bool,
    widget_state:  Option<WidgetState>,
    settings:      Option<ButtonSettings>,
    on_click:      Option<Box<dyn FnOnce() + 'a>>,
    bind_count:    Option<&'a mut u32>,
}

/// Entry point: build a button at the given id + rect.
pub fn button<'a>(id: impl Into<WidgetId>, rect: Rect) -> ButtonBuilder<'a> {
    ButtonBuilder {
        id: id.into(),
        rect,
        parent:       LayoutNodeId::ROOT,
        text:         None,
        icon:         None,
        active:       false,
        disabled:     false,
        widget_state: None,
        settings:     None,
        on_click:     None,
        bind_count:   None,
    }
}

impl<'a> ButtonBuilder<'a> {
    pub fn parent(mut self, p: LayoutNodeId) -> Self { self.parent = p; self }
    pub fn text(mut self, t: &'a str) -> Self { self.text = Some(t); self }
    pub fn icon(mut self, i: &'a IconId) -> Self { self.icon = Some(i); self }
    pub fn active(mut self, on: bool) -> Self { self.active = on; self }
    pub fn disabled(mut self, on: bool) -> Self { self.disabled = on; self }
    pub fn state(mut self, s: WidgetState) -> Self { self.widget_state = Some(s); self }
    pub fn settings(mut self, s: ButtonSettings) -> Self { self.settings = Some(s); self }

    /// Reactive on-click closure.  Invoked at `.build()` if the widget was
    /// clicked this frame.  Replaces the need for an `App::on_*` callback.
    pub fn on_click(mut self, f: impl FnOnce() + 'a) -> Self {
        self.on_click = Some(Box::new(f));
        self
    }

    /// Reactive counter — increments on each click.  Useful for click-counter
    /// demos and toolbar action telemetry.
    pub fn bind_count(mut self, n: &'a mut u32) -> Self { self.bind_count = Some(n); self }

    pub fn build<P: DockPanel>(
        self,
        layout: &mut LayoutManager<P>,
        render: &mut dyn RenderContext,
    ) {
        // Invoke reactive callbacks if clicked this frame (and not disabled).
        if !self.disabled && layout.was_clicked(&self.id) {
            if let Some(cb) = self.on_click {
                cb();
            }
            if let Some(n) = self.bind_count {
                *n = n.wrapping_add(1);
            }
        }

        let view = ButtonView {
            icon: self.icon,
            text: self.text,
            active: self.active,
            disabled: self.disabled,
            active_border: None,
            hover_chevron: None,
        };
        let settings = self.settings.unwrap_or_else(|| button_settings_from_styles(layout.styles()));
        let ws = self.widget_state.unwrap_or_else(|| {
            // Pull live state from coordinator if available.
            layout.ctx().input.widget_state(&self.id)
        });
        register_layout_manager_button(
            layout, render, self.parent, self.id, self.rect, ws, &view, &settings,
        );
    }
}

// =============================================================================
// Text
// =============================================================================

use crate::ui::widgets::atomic::text::input::register_layout_manager_text;
use crate::ui::widgets::atomic::text::settings::TextSettings;
use crate::ui::widgets::atomic::text::style::DefaultTextStyle;
use crate::ui::widgets::atomic::text::theme::{DefaultTextTheme, TextTheme};
use crate::ui::widgets::atomic::text::types::{TextOverflow, TextView};
use crate::render::{TextAlign, TextBaseline};

struct StyledTextTheme {
    color:       String,
    color_hover: String,
}

impl StyledTextTheme {
    fn from_styles(s: &StyleManager) -> Self {
        Self {
            color:       s.color_or_owned("fg_1", "#d1d4dc"),
            color_hover: s.color_or_owned("fg_0", "#ffffff"),
        }
    }
}

impl TextTheme for StyledTextTheme {
    fn text_color(&self)       -> &str { &self.color }
    fn text_color_hover(&self) -> &str { &self.color_hover }
}

fn text_settings_from_styles(s: &StyleManager) -> TextSettings {
    TextSettings {
        theme: Box::new(StyledTextTheme::from_styles(s)),
        style: Box::new(DefaultTextStyle),
    }
}

#[allow(dead_code)]
fn _suppress_default_text_theme_unused(_t: &DefaultTextTheme) {}

/// Chainable builder for a text label.
pub struct TextBuilder<'a> {
    id:       WidgetId,
    rect:     Rect,
    parent:   LayoutNodeId,
    text:     &'a str,
    color:    Option<&'a str>,
    align:    TextAlign,
    baseline: TextBaseline,
    overflow: TextOverflow,
    settings: Option<TextSettings>,
}

/// Entry point: build a text label at the given id + rect.
pub fn text<'a>(id: impl Into<WidgetId>, rect: Rect, text: &'a str) -> TextBuilder<'a> {
    TextBuilder {
        id: id.into(),
        rect,
        parent:   LayoutNodeId::ROOT,
        text,
        color:    None,
        align:    TextAlign::Left,
        baseline: TextBaseline::Middle,
        overflow: TextOverflow::Clip,
        settings: None,
    }
}

impl<'a> TextBuilder<'a> {
    pub fn parent(mut self, p: LayoutNodeId) -> Self { self.parent = p; self }
    pub fn color(mut self, c: &'a str) -> Self { self.color = Some(c); self }
    pub fn align(mut self, a: TextAlign) -> Self { self.align = a; self }
    pub fn baseline(mut self, b: TextBaseline) -> Self { self.baseline = b; self }
    pub fn overflow(mut self, o: TextOverflow) -> Self { self.overflow = o; self }
    pub fn settings(mut self, s: TextSettings) -> Self { self.settings = Some(s); self }

    pub fn build<P: DockPanel>(
        self,
        layout: &mut LayoutManager<P>,
        render: &mut dyn RenderContext,
    ) {
        let view = TextView {
            text:     self.text,
            color:    self.color,
            align:    self.align,
            baseline: self.baseline,
            font:     None,
            overflow: self.overflow,
            hovered:  false,
        };
        let settings = self.settings.unwrap_or_else(|| text_settings_from_styles(layout.styles()));
        register_layout_manager_text(
            layout, render, self.parent, self.id, self.rect,
            WidgetState::Normal, &view, &settings,
        );
    }
}

// =============================================================================
// Checkbox
// =============================================================================

use crate::ui::widgets::atomic::checkbox::input::register_layout_manager_checkbox;
use crate::ui::widgets::atomic::checkbox::settings::CheckboxSettings;
use crate::ui::widgets::atomic::checkbox::types::{CheckboxRenderKind, CheckboxView};

/// Chainable builder for a checkbox.
///
/// Two ways to wire state:
/// - `.checked(bool)` + handle click yourself in `App::on_unhandled_click`.
/// - `.bind(&mut bool)` — reactive: builder reads the value for paint AND
///   toggles it on click in the same frame.  The app does not write a click
///   handler.
pub struct CheckboxBuilder<'a> {
    id:       WidgetId,
    rect:     Rect,
    parent:   LayoutNodeId,
    checked:  bool,
    bind:     Option<&'a mut bool>,
    label:    Option<&'a str>,
    settings: Option<CheckboxSettings>,
    kind:     Option<CheckboxRenderKind<'a>>,
    font:     &'a str,
}

pub fn checkbox<'a>(id: impl Into<WidgetId>, rect: Rect) -> CheckboxBuilder<'a> {
    CheckboxBuilder {
        id: id.into(),
        rect,
        parent:   LayoutNodeId::ROOT,
        checked:  false,
        bind:     None,
        label:    None,
        settings: None,
        kind:     None,
        font:     "13px sans-serif",
    }
}

impl<'a> CheckboxBuilder<'a> {
    pub fn parent(mut self, p: LayoutNodeId) -> Self { self.parent = p; self }
    pub fn checked(mut self, on: bool) -> Self { self.checked = on; self }

    /// Reactive binding: the builder reads `*flag` for paint AND, if the
    /// widget is clicked this frame, flips `*flag = !*flag` before paint.
    /// The app does not need any click handler for this checkbox.
    pub fn bind(mut self, flag: &'a mut bool) -> Self { self.bind = Some(flag); self }

    pub fn label(mut self, l: &'a str) -> Self { self.label = Some(l); self }
    pub fn settings(mut self, s: CheckboxSettings) -> Self { self.settings = Some(s); self }
    pub fn kind(mut self, k: CheckboxRenderKind<'a>) -> Self { self.kind = Some(k); self }
    pub fn font(mut self, f: &'a str) -> Self { self.font = f; self }

    pub fn build<P: DockPanel>(
        self,
        layout: &mut LayoutManager<P>,
        render: &mut dyn RenderContext,
    ) {
        // Resolve checked state: bind takes priority; toggle on click.
        let checked = if let Some(flag) = self.bind {
            if layout.was_clicked(&self.id) {
                *flag = !*flag;
            }
            *flag
        } else {
            self.checked
        };

        let view = CheckboxView {
            checked,
            label:   self.label,
        };
        let settings = self.settings.unwrap_or_default();
        let kind     = self.kind.unwrap_or(CheckboxRenderKind::Standard);
        let ws = layout.ctx().input.widget_state(&self.id);
        register_layout_manager_checkbox(
            layout, render, self.parent, self.id, self.rect, ws, &view, &settings, &kind, self.font,
        );
    }
}

// =============================================================================
// Toggle
// =============================================================================

use crate::ui::widgets::atomic::toggle::input::register_layout_manager_toggle;
use crate::ui::widgets::atomic::toggle::settings::ToggleSettings;
use crate::ui::widgets::atomic::toggle::types::{ToggleRenderKind, ToggleView};

pub struct ToggleBuilder<'a> {
    id:       WidgetId,
    rect:     Rect,
    parent:   LayoutNodeId,
    toggled:  bool,
    bind:     Option<&'a mut bool>,
    label:    Option<&'a str>,
    disabled: bool,
    settings: Option<ToggleSettings>,
    kind:     Option<ToggleRenderKind<'a>>,
}

pub fn toggle<'a>(id: impl Into<WidgetId>, rect: Rect) -> ToggleBuilder<'a> {
    ToggleBuilder {
        id: id.into(),
        rect,
        parent:   LayoutNodeId::ROOT,
        toggled:  false,
        bind:     None,
        label:    None,
        disabled: false,
        settings: None,
        kind:     None,
    }
}

impl<'a> ToggleBuilder<'a> {
    pub fn parent(mut self, p: LayoutNodeId) -> Self { self.parent = p; self }
    pub fn toggled(mut self, on: bool) -> Self { self.toggled = on; self }

    /// Reactive binding — see [`CheckboxBuilder::bind`].
    pub fn bind(mut self, flag: &'a mut bool) -> Self { self.bind = Some(flag); self }

    pub fn label(mut self, l: &'a str) -> Self { self.label = Some(l); self }
    pub fn disabled(mut self, on: bool) -> Self { self.disabled = on; self }
    pub fn settings(mut self, s: ToggleSettings) -> Self { self.settings = Some(s); self }
    pub fn kind(mut self, k: ToggleRenderKind<'a>) -> Self { self.kind = Some(k); self }

    pub fn build<P: DockPanel>(
        self,
        layout: &mut LayoutManager<P>,
        render: &mut dyn RenderContext,
    ) {
        let toggled = if let Some(flag) = self.bind {
            if layout.was_clicked(&self.id) && !self.disabled {
                *flag = !*flag;
            }
            *flag
        } else {
            self.toggled
        };

        let view = ToggleView {
            toggled,
            label:    self.label,
            disabled: self.disabled,
        };
        let settings = self.settings.unwrap_or_default();
        let kind     = self.kind.unwrap_or(ToggleRenderKind::Switch);
        let ws = layout.ctx().input.widget_state(&self.id);
        register_layout_manager_toggle(
            layout, render, self.parent, self.id, self.rect, ws, &view, &settings, &kind,
        );
    }
}

// =============================================================================
// Separator
// =============================================================================

use crate::ui::widgets::atomic::separator::input::register_layout_manager_separator;
use crate::ui::widgets::atomic::separator::settings::SeparatorSettings;
use crate::ui::widgets::atomic::separator::input::SeparatorKind;
use crate::ui::widgets::atomic::separator::types::{SeparatorOrientation, SeparatorType};
use crate::ui::widgets::atomic::separator::render::SeparatorView;

pub struct SeparatorBuilder {
    id:          WidgetId,
    rect:        Rect,
    parent:      LayoutNodeId,
    kind:        SeparatorKind,
    sep_type:    SeparatorType,
    hovered:     bool,
    dragging:    bool,
    settings:    Option<SeparatorSettings>,
}

pub fn separator(id: impl Into<WidgetId>, rect: Rect) -> SeparatorBuilder {
    SeparatorBuilder {
        id: id.into(),
        rect,
        parent:   LayoutNodeId::ROOT,
        kind:     SeparatorKind::Divider,
        sep_type: SeparatorType::Divider { orientation: SeparatorOrientation::Horizontal },
        hovered:  false,
        dragging: false,
        settings: None,
    }
}

impl SeparatorBuilder {
    pub fn parent(mut self, p: LayoutNodeId) -> Self { self.parent = p; self }
    pub fn kind(mut self, k: SeparatorKind) -> Self { self.kind = k; self }
    pub fn sep_type(mut self, t: SeparatorType) -> Self { self.sep_type = t; self }
    pub fn hovered(mut self, on: bool) -> Self { self.hovered = on; self }
    pub fn dragging(mut self, on: bool) -> Self { self.dragging = on; self }
    pub fn settings(mut self, s: SeparatorSettings) -> Self { self.settings = Some(s); self }

    pub fn build<P: DockPanel>(
        self,
        layout: &mut LayoutManager<P>,
        render: &mut dyn RenderContext,
    ) {
        let view = SeparatorView {
            kind:     self.sep_type,
            hovered:  self.hovered,
            dragging: self.dragging,
        };
        let settings = self.settings.unwrap_or_default();
        register_layout_manager_separator(
            layout, render, self.parent, self.id, self.rect, self.kind, &view, &settings,
        );
    }
}