Skip to main content

teksilo_widgets/styles/
recipe_list_container_style.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Default `ListContainerStyle` impl.
5//!
6//! IntUI's list/tree container chrome is just the drag-insertion
7//! indicator. The recipe ships a `RectWidget`-leaf factory for
8//! custom recipes that want a composed indicator, and a
9//! `ListInsertionRecipe` (`BorderRole::Accent`, 2 dp thickness) for
10//! the inline paint path the widgets use today.
11
12use teksilo_core::build_context::BuildContext;
13use teksilo_core::styles::{
14    ListContainerStyle, ListInsertionConfig, ListInsertionRecipe, SharedListContainerStyle,
15};
16use teksilo_core::widget_id::WidgetId;
17use teksilo_tokens::BorderRole;
18
19use crate::primitives::RectWidget;
20
21/// Default `ListContainerStyle` shipped with Teksilo.
22#[derive(Debug, Default, Clone, Copy)]
23pub struct RecipeListContainerStyle;
24
25impl ListContainerStyle for RecipeListContainerStyle {
26    fn make_insertion_indicator(
27        &self,
28        cfg: &ListInsertionConfig,
29        ctx: &mut BuildContext,
30    ) -> WidgetId {
31        // Reference shape: a `width × 2` accent-coloured rect.
32        // Custom container styles may install a different leaf.
33        let _ = cfg.axis_offset; // positioned by the container's place_children
34        let _ = cfg.width;
35        ctx.add(RectWidget::new().background(BorderRole::Accent))
36    }
37
38    fn insertion(&self) -> ListInsertionRecipe {
39        ListInsertionRecipe::default()
40    }
41}
42
43pub fn resolve_list_container_style(
44    override_: &Option<SharedListContainerStyle>,
45    ctx: &BuildContext,
46) -> SharedListContainerStyle {
47    if let Some(s) = override_.clone() {
48        return s;
49    }
50    ctx.theme_signal()
51        .get()
52        .style_slots
53        .list_container
54        .clone()
55        .unwrap_or_else(|| std::rc::Rc::new(RecipeListContainerStyle) as SharedListContainerStyle)
56}