egui_charts/ui/drawing_toolbar/config.rs
1//! Drawing toolbar dimensions and retained configuration values.
2//!
3//! Use [`DrawingToolbarConfig`] to set toolbar width and padding; colors come from
4//! the active egui visuals and theme.
5
6// =============================================================================
7// Fixed Desktop Constants
8// =============================================================================
9
10/// Default drawing toolbar width in egui logical points.
11pub const TOOLBAR_WIDTH: f32 = 52.0;
12
13/// Default icon side length in egui logical points.
14pub const ICON_SIZE: f32 = 18.0;
15
16/// Default padding in egui logical points.
17pub const PADDING: f32 = 4.0;
18
19/// Default submenu width in egui logical points.
20pub const SUBMENU_WIDTH: f32 = 200.0;
21
22// =============================================================================
23// Config Struct
24// =============================================================================
25
26/// Toolbar width and padding in egui logical points, with retained compatibility values.
27#[derive(Debug, Clone)]
28pub struct DrawingToolbarConfig {
29 /// Retained for source compatibility; ignored when rendering.
30 pub icon_size: f32,
31 /// Toolbar width.
32 pub width: f32,
33 /// Padding before the first toolbar control.
34 pub padding: f32,
35 /// Retained for source compatibility; ignored when rendering.
36 pub submenu_width: f32,
37 /// Retained for source compatibility; tool names are shown in flyouts.
38 pub show_names: bool,
39 /// Retained for source compatibility; rendering uses `width`.
40 pub expanded_width: f32,
41 /// Retained for source compatibility; rendering uses `width`.
42 pub collapsed_width: f32,
43 // Legacy fields kept for compatibility
44 /// Retained for source compatibility; ignored when rendering.
45 pub base_icon_size: f32,
46 /// Retained for source compatibility; rendering uses `width`.
47 pub base_width: f32,
48 /// Retained for source compatibility; rendering uses `padding`.
49 pub base_padding: f32,
50 /// Retained for source compatibility; ignored when rendering.
51 pub base_submenu_width: f32,
52}
53
54impl Default for DrawingToolbarConfig {
55 fn default() -> Self {
56 Self {
57 // Fixed desktop values
58 icon_size: ICON_SIZE,
59 width: TOOLBAR_WIDTH,
60 padding: PADDING,
61 submenu_width: SUBMENU_WIDTH,
62 show_names: false,
63 expanded_width: TOOLBAR_WIDTH,
64 collapsed_width: TOOLBAR_WIDTH,
65 // Legacy fields (same as primary values)
66 base_icon_size: ICON_SIZE,
67 base_width: TOOLBAR_WIDTH,
68 base_padding: PADDING,
69 base_submenu_width: SUBMENU_WIDTH,
70 }
71 }
72}
73
74impl DrawingToolbarConfig {
75 /// Create default dimensions; the theme argument is unused.
76 pub fn from_theme(_theme: &crate::theme::Theme) -> Self {
77 Self::default()
78 }
79
80 /// Retained for source compatibility; leaves dimensions unchanged.
81 pub fn update_for_window_width(&mut self, _window_width: f32) {
82 // no scaling needed
83 }
84}