mirror of
https://github.com/raysan5/raygui.git
synced 2026-01-28 09:49:18 -05:00
Added GuiLabelEx()
This commit is contained in:
21
src/raygui.h
21
src/raygui.h
@ -388,6 +388,7 @@ RAYGUIDEF Vector2 GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 vi
|
|||||||
|
|
||||||
// Basic controls set
|
// Basic controls set
|
||||||
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text); // Label control, shows text
|
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text); // Label control, shows text
|
||||||
|
RAYGUIDEF void GuiLabelEx(Rectangle bounds, const char *text, int alignment, int padding); // Label control extended
|
||||||
RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked
|
RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked
|
||||||
RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text); // Label button control, show true when clicked
|
RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text); // Label button control, show true when clicked
|
||||||
RAYGUIDEF bool GuiImageButton(Rectangle bounds, Texture2D texture); // Image button control, returns true when clicked
|
RAYGUIDEF bool GuiImageButton(Rectangle bounds, Texture2D texture); // Image button control, returns true when clicked
|
||||||
@ -1021,7 +1022,7 @@ RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text)
|
|||||||
DrawRectangle(bounds.x, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
DrawRectangle(bounds.x, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
||||||
DrawRectangle(bounds.x, bounds.y + bounds.height - 1, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
DrawRectangle(bounds.x, bounds.y + bounds.height - 1, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
||||||
DrawRectangle(bounds.x + bounds.width - 1, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
DrawRectangle(bounds.x + bounds.width - 1, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
||||||
if (text[0] == '\0') DrawRectangle(bounds.x, bounds.y, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
if ((text == NULL) || (text[0] == '\0')) DrawRectangle(bounds.x, bounds.y, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawRectangle(bounds.x, bounds.y, GROUPBOX_TEXT_PADDING, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
DrawRectangle(bounds.x, bounds.y, GROUPBOX_TEXT_PADDING, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
||||||
@ -1036,7 +1037,7 @@ RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text)
|
|||||||
DrawRectangle(bounds.x, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha));
|
DrawRectangle(bounds.x, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha));
|
||||||
DrawRectangle(bounds.x, bounds.y + bounds.height - 1, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha));
|
DrawRectangle(bounds.x, bounds.y + bounds.height - 1, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha));
|
||||||
DrawRectangle(bounds.x + bounds.width - 1, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha));
|
DrawRectangle(bounds.x + bounds.width - 1, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha));
|
||||||
if (text[0] == '\0') DrawRectangle(bounds.x, bounds.y, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
if ((text == NULL) || (text[0] == '\0')) DrawRectangle(bounds.x, bounds.y, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawRectangle(bounds.x, bounds.y, GROUPBOX_TEXT_PADDING, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha));
|
DrawRectangle(bounds.x, bounds.y, GROUPBOX_TEXT_PADDING, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha));
|
||||||
@ -1108,6 +1109,13 @@ RAYGUIDEF Vector2 GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 vi
|
|||||||
|
|
||||||
// Label control
|
// Label control
|
||||||
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text)
|
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text)
|
||||||
|
{
|
||||||
|
GuiLabelEx(bounds, text, 0, 0); // Left-alignment, no-padding
|
||||||
|
}
|
||||||
|
|
||||||
|
// Label control extended
|
||||||
|
// NOTE: Alignment and padding are just considered on horizontal
|
||||||
|
RAYGUIDEF void GuiLabelEx(Rectangle bounds, const char *text, int alignment, int padding)
|
||||||
{
|
{
|
||||||
GuiControlState state = guiState;
|
GuiControlState state = guiState;
|
||||||
|
|
||||||
@ -1117,6 +1125,11 @@ RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text)
|
|||||||
if (bounds.width < textWidth) bounds.width = textWidth;
|
if (bounds.width < textWidth) bounds.width = textWidth;
|
||||||
if (bounds.height < textHeight) bounds.height = textHeight;
|
if (bounds.height < textHeight) bounds.height = textHeight;
|
||||||
|
|
||||||
|
Vector2 textPosition = { bounds.x + padding, bounds.y + bounds.height/2 - textHeight/2 + VALIGN_OFFSET(bounds.height) }; // Left alignment
|
||||||
|
|
||||||
|
if (alignment == 1) textPosition.x = bounds.x + bounds.width/2 - textWidth/2 + padding; // Middle-alignment
|
||||||
|
else if (alignment == 2) textPosition.x = bounds.x + bounds.width - textWidth + padding; // Right alignment
|
||||||
|
|
||||||
// Update control
|
// Update control
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// ...
|
// ...
|
||||||
@ -1128,8 +1141,8 @@ RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text)
|
|||||||
{
|
{
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
case FOCUSED:
|
case FOCUSED:
|
||||||
case PRESSED: GuiDrawText(text, bounds.x, bounds.y + bounds.height/2 - textHeight/2 + VALIGN_OFFSET(bounds.height), Fade(GetColor(style[LABEL_TEXT_COLOR_NORMAL]), guiAlpha)); break;
|
case PRESSED: GuiDrawText(text, textPosition.x, textPosition.y, Fade(GetColor(style[LABEL_TEXT_COLOR_NORMAL]), guiAlpha)); break;
|
||||||
case DISABLED: GuiDrawText(text, bounds.x, bounds.y + bounds.height/2 - textHeight/2 + VALIGN_OFFSET(bounds.height), Fade(GetColor(style[LABEL_TEXT_COLOR_DISABLED]), guiAlpha)); break;
|
case DISABLED: GuiDrawText(text, textPosition.x, textPosition.y, Fade(GetColor(style[LABEL_TEXT_COLOR_DISABLED]), guiAlpha)); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user