egui_charts/styles/mod.rs
1//! UI sizing, typography, icon sizes and keyboard focus helpers.
2//!
3//! UI colours, text, spacing and radii come from the applied [`Theme`](crate::theme::Theme).
4//! These modules retain fixed component dimensions and the default font sizes used by
5//! the theme. See `docs/theme.md` for runtime customisation.
6
7pub mod focus;
8pub mod icons;
9#[cfg(feature = "ui")]
10pub(crate) mod responsive;
11#[cfg(feature = "ui")]
12#[cfg_attr(docsrs, doc(cfg(feature = "ui")))]
13pub use responsive::LayoutContext;
14pub mod sizing;
15pub mod typography;
16
17/// Give the scroll areas of `ui` the menus' thin scroll bar: 3 px at the right edge, in its own
18/// column beside the rows, with a handle at 43 % of the text colour.
19///
20/// Floating bars are the ones egui draws with the handle opacities; the column they allocate
21/// keeps the bar off the rows.
22#[cfg(feature = "ui")]
23pub(crate) fn menu_scroll_bar(ui: &mut egui::Ui) {
24 let scroll = &mut ui.spacing_mut().scroll;
25 scroll.floating = true;
26 scroll.bar_width = 3.0;
27 scroll.floating_width = 3.0;
28 scroll.floating_allocated_width = 3.0 + scroll.bar_inner_margin;
29 scroll.foreground_color = true;
30 scroll.dormant_handle_opacity = 0.43;
31 scroll.active_handle_opacity = 0.43;
32 scroll.dormant_background_opacity = 0.0;
33 scroll.active_background_opacity = 0.0;
34 scroll.interact_background_opacity = 0.0;
35 scroll.fade.strength = 0.0;
36}
37
38// =============================================================================
39// Stroke Helpers
40// =============================================================================
41
42/// Common stroke width constants (legacy -- prefer `DESIGN_TOKENS.stroke.*`).
43pub mod stroke {
44 /// Hairline stroke (1px)
45 pub const HAIRLINE: f32 = 1.0;
46
47 /// Thin stroke (1.2px)
48 pub const THIN: f32 = 1.2;
49
50 /// Medium stroke (1.5px)
51 pub const MEDIUM: f32 = 1.5;
52
53 /// Thick stroke (2px)
54 pub const THICK: f32 = 2.0;
55}