mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-07 22:59:17 -05:00
DEFAULT properties propagation is done automatically
This commit is contained in:
25
src/raygui.h
25
src/raygui.h
@ -225,7 +225,7 @@ typedef struct GuiTextBoxState {
|
||||
typedef struct GuiStyleProp {
|
||||
unsigned short controlId;
|
||||
unsigned short propertyId;
|
||||
unsigned int propertyValue;
|
||||
int propertyValue;
|
||||
} GuiStyleProp;
|
||||
|
||||
// Gui control state
|
||||
@ -3861,15 +3861,7 @@ RAYGUIDEF void GuiLoadStyle(const char *fileName)
|
||||
|
||||
sscanf(buffer, "p %d %d 0x%x", &controlId, &propertyId, &propertyValue);
|
||||
|
||||
if (controlId == 0) // DEFAULT control
|
||||
{
|
||||
// If a DEFAULT property is loaded, it is propagated to all controls,
|
||||
// NOTE: All DEFAULT properties should be defined first in the file
|
||||
GuiSetStyle(0, propertyId, propertyValue);
|
||||
|
||||
if (propertyId < NUM_PROPS_DEFAULT) for (int i = 1; i < NUM_CONTROLS; i++) GuiSetStyle(i, propertyId, propertyValue);
|
||||
}
|
||||
else GuiSetStyle(controlId, propertyId, propertyValue);
|
||||
GuiSetStyle(controlId, propertyId, propertyValue);
|
||||
|
||||
} break;
|
||||
case 'f':
|
||||
@ -4050,15 +4042,7 @@ RAYGUIDEF void GuiLoadStyleDefault(void)
|
||||
GuiSetStyle(DEFAULT, TEXT_PADDING, 0); // WARNING: Some controls use other values
|
||||
GuiSetStyle(DEFAULT, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); // WARNING: Some controls use other values
|
||||
|
||||
// Populate all controls with default style
|
||||
for (int i = 1; i < NUM_CONTROLS; i++)
|
||||
{
|
||||
for (int j = 0; j < NUM_PROPS_DEFAULT; j++) GuiSetStyle(i, j, GuiGetStyle(DEFAULT, j));
|
||||
}
|
||||
|
||||
guiFont = GetFontDefault(); // Initialize default font
|
||||
|
||||
// Initialize default control-specific properties: BORDER_WIDTH, TEXT_PADDING, TEXT_ALIGNMENT
|
||||
// Initialize control-specific property values
|
||||
// NOTE: Those properties are in default list but require specific values by control type
|
||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
|
||||
GuiSetStyle(BUTTON, BORDER_WIDTH, 2);
|
||||
@ -4074,7 +4058,6 @@ RAYGUIDEF void GuiLoadStyleDefault(void)
|
||||
GuiSetStyle(STATUSBAR, TEXT_PADDING, 10);
|
||||
GuiSetStyle(STATUSBAR, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
|
||||
|
||||
|
||||
// Initialize extended property values
|
||||
// NOTE: By default, extended property values are initialized to 0
|
||||
GuiSetStyle(DEFAULT, TEXT_SIZE, 10); // DEFAULT, shared by all controls
|
||||
@ -4112,6 +4095,8 @@ RAYGUIDEF void GuiLoadStyleDefault(void)
|
||||
GuiSetStyle(COLORPICKER, HUEBAR_PADDING, 0xa);
|
||||
GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT, 6);
|
||||
GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW, 2);
|
||||
|
||||
guiFont = GetFontDefault(); // Initialize default font
|
||||
}
|
||||
|
||||
// Get text with icon id prepended
|
||||
|
||||
Reference in New Issue
Block a user