conrod_core/
label.rs

1use color::{hsl, hsla, rgb, rgba, Color};
2use ui::Ui;
3
4/// Font size used throughout Conrod.
5pub type FontSize = u32;
6
7/// Widgets that may display some label.
8pub trait Labelable<'a>: Sized {
9    /// Set the label for the widget.
10    fn label(self, text: &'a str) -> Self;
11
12    /// Set the color of the widget's label.
13    fn label_color(self, color: Color) -> Self;
14
15    /// Set the color of the widget's label from rgba values.
16    fn label_rgba(self, r: f32, g: f32, b: f32, a: f32) -> Self {
17        self.label_color(rgba(r, g, b, a))
18    }
19
20    /// Set the color of the widget's label from rgb values.
21    fn label_rgb(self, r: f32, g: f32, b: f32) -> Self {
22        self.label_color(rgb(r, g, b))
23    }
24
25    /// Set the color of the widget's label from hsla values.
26    fn label_hsla(self, h: f32, s: f32, l: f32, a: f32) -> Self {
27        self.label_color(hsla(h, s, l, a))
28    }
29
30    /// Set the color of the widget's label from hsl values.
31    fn label_hsl(self, h: f32, s: f32, l: f32) -> Self {
32        self.label_color(hsl(h, s, l))
33    }
34
35    /// Set the font size for the widget's label.
36    fn label_font_size(self, size: FontSize) -> Self;
37
38    /// Set a "small" font size for the widget's label.
39    fn small_font(self, ui: &Ui) -> Self {
40        self.label_font_size(ui.theme.font_size_small)
41    }
42
43    /// Set a "medium" font size for the widget's label.
44    fn medium_font(self, ui: &Ui) -> Self {
45        self.label_font_size(ui.theme.font_size_medium)
46    }
47
48    /// Set a "large" font size for the widget's label.
49    fn large_font(self, ui: &Ui) -> Self {
50        self.label_font_size(ui.theme.font_size_large)
51    }
52}