Open raysan5 opened 1 year ago
Some more info while investigating those properties:
At this moment TEXT_PADDING
and TEXT_ALIGNMENT
are set by control, here the custom values set by default raygui style plus some concerns:
GuiSetStyle(TEXTBOX, TEXT_PADDING, 4); // OK: text inner padding from bounds
GuiSetStyle(STATUSBAR, TEXT_PADDING, 8); // OK: text inner padding from bounds -> TEXT_INDENTATION?
GuiSetStyle(SLIDER, TEXT_PADDING, 4); // WARNING: Padding refers to outside label spacing -> LABEL_SEPARATION (using TEXT_PADDING for label text internal content)
GuiSetStyle(PROGRESSBAR, TEXT_PADDING, 4); // WARNING: Padding refers to outside label spacing -> LABEL_SEPARATION
GuiSetStyle(CHECKBOX, TEXT_PADDING, 4); // WARNING: Padding refers to outside label spacing -> LABEL_SEPARATION
GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); // OK: text alignment inside text-bounds
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); // OK: text alignment inside text-bounds
GuiSetStyle(STATUSBAR, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); // OK: text alignment inside text-bounds
GuiSetStyle(VALUEBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); // WARNING: Text alignment refers to label side on control -> LABEL_SIDE: 0-left, 1-right
GuiSetStyle(SPINNER, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); // WARNING: Text alignment refers to label side on control -> LABEL_SIDE: 0-left, 1-right
GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, TEXT_ALIGN_RIGHT); // WARNING: Text alignment refers to label side on control -> LABEL_SIDE: 0-left, 1-right
Noted that TEXT_PADDING
and TEXT_ALIGNMENT
usage could be missleading for some controls, not directly referring to padding/alignment inside text-bounds but LABEL positioning around a specific control (SLIDER, PROGRESSBAR, CHECKBOX, VALUEBOX, SPINNER). That functionality should be reviewed, specific properties can be created for affected controls.
Still thinking about this issue. Just noticed that for controls not containing text inside the control bounds (SLIDER
, PROGRESSBAR
, CHECKBOX
) text padding and alignment could be used, despite referring to outside labels. It simplifies controls properties.
On the other side, controls actually containing some text inside the control (VALUEBOX
, SPINNER
) could be missleading and somewhat limit the control capabilities (i.e. the contained value padding and alignment).
I find it confusing to have both global and per control settings.
My solution is to make all properties apply globally and per control. That way, we get rid of the confusing. Or prefix global properties with a letter like G_
so we know that G_TEXT_ALIGN_VERTICAL
is a global property and that properties without the G_
prefix are per control properties.
Beside the font used, raygui supports multiple text-styling properties for controls text drawing. At this moment some text-styling properties can be configured by-control while some other properties are global for all controls.
Per-control properties:
TEXT_PADDING
: Control text padding, not considering borderTEXT_ALIGNMENT
: Control text horizontal alignment inside control text bound (after border and padding)Global properties:
TEXT_SIZE
: Text size (glyphs max height)TEXT_SPACING
: Text spacing between glyphsTEXT_LINE_SPACING
: Text spacing between linesTEXT_ALIGNMENT_VERTICAL
: Text vertical alignment inside text bounds (after border and padding)TEXT_WRAP_MODE
: Text wrap-mode inside text boundsIn any case, those properties can be set by user before drawing each control for a per-control configuration but in the case of per-control properties they are saved individually with the style while with the global properties they must be set at runtime depending on the user needs.
Also, all those properties determine how
GetTextBounds()
is calculated and howGuiDrawText()
behaves (functions used by all controls).I'm considering unifying all those properties per-control or global but I'm seing multiple issues... because some current per-control properties should probably stay configured per control...