ltk/widget/text_edit/
theme.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>

use crate::types::Color;

pub fn bg()           -> Color { crate::theme::palette().surface_alt }
pub fn border()       -> Color { crate::theme::palette().divider }
pub fn text()         -> Color { crate::theme::palette().text_primary }
pub fn placeholder()  -> Color { crate::theme::palette().text_secondary }
pub fn focus_border() -> Color { crate::theme::palette().text_primary }
pub fn cursor()       -> Color { crate::theme::palette().text_primary }
/// Selection highlight — accent colour at low opacity so the text
/// underneath stays readable.
pub fn selection() -> Color
{
	let a = crate::theme::palette().accent;
	Color::rgba( a.r, a.g, a.b, 0.35 )
}

/// The selection of a multiline field without the focus.
pub fn selection_inactive() -> Color
{
	let c = crate::theme::palette().text_secondary;
	Color::rgba( c.r, c.g, c.b, 0.25 )
}

pub const BORDER_W:       f32 = 1.5;
pub const FOCUS_BORDER_W: f32 = 2.0;
pub const HEIGHT:         f32 = 48.0;
pub const RADIUS:         f32 = 100.0;
pub const FONT_SIZE:      f32 = 16.0;
pub const PAD_H:          f32 = 20.0;
pub const CARET_W:        f32 = 2.0;
/// How much taller than the glyph box the caret is drawn.
pub const CARET_OVERHANG: f32 = 4.0;
/// Vertical padding inside multiline boxes — the single-line variant
/// centres the text vertically in `HEIGHT`, so it doesn't need this.
pub const PAD_V_MULTI:    f32 = 12.0;
/// Line height multiplier on top of [`FONT_SIZE`] when laying out
/// multiline content. 1.4 leaves enough room above and below each
/// line that adjacent rows do not visually crowd each other.
pub const LINE_H_MULT:    f32 = 1.4;
/// Default visible row count for a [`super::TextEdit`] in multiline mode.
pub const ROWS_DEFAULT:   u32 = 5;
/// Corner radius applied to multiline boxes — the pill shape used by
/// the single-line variant looks wrong at multi-row heights.
pub const RADIUS_MULTI:   f32 = 12.0;
/// Side length of the [`super::TextEdit::password_toggle`] eye icon in a
/// field [`HEIGHT`] tall; it scales with the field height.
pub const PASSWORD_TOGGLE_SIZE: f32 = 20.0;
/// Extra horizontal slop on each side of the eye icon's hit zone
/// to make the toggle finger-friendly even on touch panels.
pub const PASSWORD_TOGGLE_SLOP: f32 = 4.0;
/// Columns from one tab stop of a multiline field to the next, each as wide as a digit, as a monospace column is.
pub const TAB_COLUMNS:      f32 = 4.0;
/// Width of a multiline field's scroll bar, and its gap to the field's edge.
pub const SCROLLBAR_W:      f32 = 6.0;
pub const SCROLLBAR_MARGIN: f32 = 3.0;
/// Width from the field's right edge that a press takes as one on the scroll bar.
pub const SCROLLBAR_HIT:    f32 = 20.0;
pub const SCROLLBAR_MIN:    f32 = 32.0;

pub fn scrollbar_track() -> Color
{
	let c = crate::theme::palette().divider;
	Color::rgba( c.r, c.g, c.b, c.a * 0.5 )
}
pub fn scrollbar_thumb() -> Color { crate::theme::palette().text_secondary }
/// Before the line numbers of a multiline field that shows them.
pub const GUTTER_PAD:       f32 = 12.0;