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 /// Text of this label. 24 string text; 25 26 static foreach (index; 0 .. BasicNodeParamLength) { 27 28 /// Initialize the label with given text. 29 this(BasicNodeParam!index sup, string text = "") { 30 31 super(sup); 32 this.text = text; 33 34 } 35 36 } 37 38 protected override void resizeImpl(Vector2 available) { 39 40 minSize = style.measureText(available, text); 41 42 } 43 44 protected override void drawImpl(Rectangle outer, Rectangle inner) { 45 46 const style = pickStyle(); 47 style.drawBackground(outer); 48 style.drawText(inner, text); 49 50 } 51 52 protected override const(Style) pickStyle() const { 53 54 return style; 55 56 } 57 58 }