Skip to main content

nadir_debug/
style.rs

1// Copyright 2026 Joseph Anthony Abbott III
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! The debug UI's look: its scale, sizes and colors.
16
17use nadir_core::{Color, Vec2};
18use nadir_render::UiScale;
19
20/// The debug UI's look. Sizes are in UI units: a UI unit is a pixel of
21/// the font.
22#[non_exhaustive]
23#[derive(Clone, Copy, Debug, PartialEq)]
24pub struct Style {
25    /// The UI's scale: the settings' UI scale, a free one, by default the
26    /// output's own pixels (`UiScale::Free(1.0)`).
27    pub scale: UiScale,
28    /// Around a row's text, above and below, and inside a window's edges.
29    pub padding: f32,
30    /// Between two rows, or two widgets of a row.
31    pub spacing: f32,
32    /// How far a tree node's children are moved in.
33    pub indent: f32,
34    /// How much of a row a control takes, its label after it.
35    pub control_share: f32,
36    /// How wide a labelled control is in a row of several
37    /// ([`Ui::horizontal`](crate::Ui::horizontal)).
38    pub control_width: f32,
39    /// How wide the scrollbar is, and how large the resize grip.
40    pub scrollbar: f32,
41    /// The smallest a window may be made.
42    pub min_size: Vec2,
43    /// A window's body.
44    pub panel: Color,
45    /// A window's title bar.
46    pub title: Color,
47    /// The title bar of the window in front.
48    pub title_front: Color,
49    /// A control at rest.
50    pub widget: Color,
51    /// A control under the pointer.
52    pub hot: Color,
53    /// A control held.
54    pub active: Color,
55    /// A checkbox's mark, a slider's handle, a plot's line.
56    pub accent: Color,
57    /// Text.
58    pub text: Color,
59    /// A line, the scrollbar's track.
60    pub dim: Color,
61    /// Selected text.
62    pub selection: Color,
63}
64
65impl Default for Style {
66    fn default() -> Self {
67        Self {
68            scale: UiScale::Free(1.0),
69            padding: 2.0,
70            spacing: 2.0,
71            indent: 10.0,
72            control_share: 0.6,
73            control_width: 80.0,
74            scrollbar: 6.0,
75            min_size: Vec2::new(60.0, 40.0),
76            panel: Color::rgba(24, 24, 32, 230),
77            title: Color::rgb(48, 48, 72),
78            title_front: Color::rgb(64, 72, 128),
79            widget: Color::rgb(56, 56, 72),
80            hot: Color::rgb(80, 80, 104),
81            active: Color::rgb(104, 104, 144),
82            accent: Color::rgb(160, 200, 255),
83            text: Color::rgb(230, 230, 230),
84            dim: Color::rgb(96, 96, 112),
85            selection: Color::rgb(64, 96, 160),
86        }
87    }
88}