Skip to main content

teksilo_core/styles/
combo_box_style.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Tier-3 style protocol for `ComboBox`. See `docs/styling-system.md`.
5
6use std::rc::Rc;
7
8use serde::{Deserialize, Serialize};
9
10use crate::build_context::BuildContext;
11use crate::signal::Signal;
12use crate::widget_id::WidgetId;
13
14/// Tier-1 design-language variant for a combo box trigger. Mirrors the
15/// `TextInputVariant` shape because both controls live in the same
16/// "form-field" visual family — apps that ship a Material 3 theme
17/// typically want filled triggers for both, etc.
18#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default, Serialize, Deserialize)]
19pub enum ComboBoxVariant {
20    /// IntUI default: 1 dp bordered rectangle with a vertical divider
21    /// before the chevron.
22    #[default]
23    Outlined,
24    /// Filled background, no border (Material 3 dropdown style).
25    Filled,
26    /// Just a baseline underline under the trigger.
27    Underline,
28    /// No chrome at all — for embedded combo boxes where the parent
29    /// surface IS the chrome (table cells, inline pickers).
30    Plain,
31}
32
33#[derive(Clone, Debug)]
34pub struct ComboBoxStyleConfig {
35    /// Pre-built selected-item display subtree.
36    pub selected_label: WidgetId,
37    pub is_open: Signal<bool>,
38    pub is_hovered: Signal<bool>,
39    pub is_focused: Signal<bool>,
40    pub is_disabled: Signal<bool>,
41    pub variant: ComboBoxVariant,
42}
43
44pub trait ComboBoxStyle: 'static {
45    fn make_body(&self, cfg: &ComboBoxStyleConfig, ctx: &mut BuildContext) -> WidgetId;
46}
47
48pub type SharedComboBoxStyle = Rc<dyn ComboBoxStyle>;