Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text-styling properties configuration #328

Open
raysan5 opened this issue Sep 1, 2023 · 3 comments
Open

Text-styling properties configuration #328

raysan5 opened this issue Sep 1, 2023 · 3 comments

Comments

@raysan5
Copy link
Owner

raysan5 commented Sep 1, 2023

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 border
  • TEXT_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 glyphs
  • TEXT_LINE_SPACING: Text spacing between lines
  • TEXT_ALIGNMENT_VERTICAL: Text vertical alignment inside text bounds (after border and padding)
  • TEXT_WRAP_MODE: Text wrap-mode inside text bounds

In 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 how GuiDrawText() 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...

@raysan5
Copy link
Owner Author

raysan5 commented Sep 4, 2023

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.

@raysan5
Copy link
Owner Author

raysan5 commented Sep 8, 2023

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).

@a-alhusaini
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants