Skip to main content

egui_charts/ui/widget_bar/panels/object_tree/
config.rs

1//! Configuration for the Object Tree panel
2//!
3//! Provides customization options for display and behavior.
4
5use crate::tokens::DESIGN_TOKENS;
6
7/// Configuration for the Object Tree panel
8#[derive(Clone, Debug)]
9pub struct ObjectTreeConfig {
10    // === Display Options ===
11    /// Show the Data Window section
12    pub show_data_window: bool,
13    /// Show hidden objects in the tree
14    pub show_hidden_objects: bool,
15    /// Show locked indicator icon
16    pub show_lock_indicator: bool,
17    /// Show color indicators next to items
18    pub show_color_indicators: bool,
19    /// Group objects by type (indicators, drawings)
20    pub group_by_type: bool,
21    /// Show item count badges on group headers
22    pub show_item_counts: bool,
23    /// Show expand/collapse chevron for items with properties
24    pub show_expand_chevron: bool,
25
26    // === Behavior Options ===
27    /// Enable drag-and-drop reordering
28    pub enable_drag_drop: bool,
29    /// Enable multi-selection (Ctrl+click, Shift+click)
30    pub enable_multi_select: bool,
31    /// Enable inline property editing
32    pub enable_inline_edit: bool,
33    /// Enable context menu on right-click
34    pub enable_context_menu: bool,
35    /// Enable keyboard shortcuts
36    pub enable_keyboard_shortcuts: bool,
37
38    // === Dimensions ===
39    /// Row height for tree items
40    pub row_height: f32,
41    /// Indent width for nested items
42    pub indent_width: f32,
43    /// Maximum panel height (for scroll area)
44    pub max_height: f32,
45    /// Icon size in rows
46    pub icon_size: f32,
47    /// Color indicator size
48    pub color_indicator_size: f32,
49    /// Toggle button size
50    pub toggle_size: f32,
51
52    // === Animation ===
53    /// Animate expand/collapse transitions
54    pub animate_transitions: bool,
55}
56
57impl Default for ObjectTreeConfig {
58    fn default() -> Self {
59        Self {
60            // Display
61            show_data_window: true,
62            show_hidden_objects: true,
63            show_lock_indicator: true,
64            show_color_indicators: true,
65            group_by_type: true,
66            show_item_counts: true,
67            show_expand_chevron: true,
68
69            // Behavior
70            enable_drag_drop: true,
71            enable_multi_select: true,
72            enable_inline_edit: false, // Uses dialogs instead
73            enable_context_menu: true,
74            enable_keyboard_shortcuts: true,
75
76            // Dimensions
77            row_height: DESIGN_TOKENS.sizing.button_sm, // 24px
78            indent_width: crate::theme::Theme::default().spacing.xl, // 12px
79            max_height: 400.0,
80            icon_size: 16.0,
81            color_indicator_size: 10.0,
82            toggle_size: 16.0,
83
84            // Animation
85            animate_transitions: true,
86        }
87    }
88}
89
90impl ObjectTreeConfig {
91    /// Create a minimal configuration (no extra features)
92    pub fn minimal() -> Self {
93        Self {
94            show_data_window: false,
95            show_hidden_objects: false,
96            show_lock_indicator: false,
97            show_color_indicators: false,
98            group_by_type: false,
99            show_item_counts: false,
100            show_expand_chevron: false,
101            enable_drag_drop: false,
102            enable_multi_select: false,
103            enable_inline_edit: false,
104            enable_context_menu: false,
105            enable_keyboard_shortcuts: false,
106            animate_transitions: false,
107            ..Default::default()
108        }
109    }
110
111    /// Create a compact configuration
112    pub fn compact() -> Self {
113        Self {
114            row_height: 20.0,
115            indent_width: 8.0,
116            icon_size: 14.0,
117            color_indicator_size: 8.0,
118            toggle_size: 14.0,
119            ..Default::default()
120        }
121    }
122}