1 ///
2 module glui.label;
3 
4 import raylib;
5 
6 import glui.node;
7 import glui.utils;
8 import glui.style;
9 
10 alias label = simpleConstructor!GluiLabel;
11 
12 @safe:
13 
14 /// A label can be used to display text on the screen.
15 /// Styles: $(UL
16 ///     $(LI `style` = Default style for this node.)
17 /// )
18 class GluiLabel : GluiNode {
19 
20     mixin DefineStyles;
21     mixin ImplHoveredRect;
22 
23     public {
24 
25         /// Text of this label.
26         string text;
27 
28         /// If true, the content of the label should not be wrapped into new lines if it's too long to fit into one.
29         bool disableWrap;
30 
31     }
32 
33     static foreach (index; 0 .. BasicNodeParamLength) {
34 
35         /// Initialize the label with given text.
36         this(BasicNodeParam!index sup, string text = "") {
37 
38             super(sup);
39             this.text = text;
40 
41         }
42 
43     }
44 
45     protected override void resizeImpl(Vector2 available) {
46 
47         import std.math;
48 
49         minSize = style.measureText(available, text, !disableWrap);
50 
51     }
52 
53     protected override void drawImpl(Rectangle outer, Rectangle inner) {
54 
55         const style = pickStyle();
56         style.drawBackground(outer);
57         style.drawText(inner, text, !disableWrap);
58 
59     }
60 
61     protected override const(Style) pickStyle() const {
62 
63         return style;
64 
65     }
66 
67 }