Redesigned GuiLoadStylePalette()

- Renamed to GuiLoadStyleProps()
 - Support style properties array loading
This commit is contained in:
Ray
2018-11-21 17:42:43 +01:00
parent 13b78e8149
commit 1dfc2882ef

View File

@ -359,7 +359,7 @@ RAYGUIDEF bool GuiMessageBox(Rectangle bounds, const char *windowTitle, const ch
#if defined(RAYGUI_STYLE_LOADING) #if defined(RAYGUI_STYLE_LOADING)
RAYGUIDEF void GuiLoadStyle(const char *fileName); // Load style file (.rgs) RAYGUIDEF void GuiLoadStyle(const char *fileName); // Load style file (.rgs)
RAYGUIDEF void GuiLoadStylePalette(const int *palette); // Load style from a color palette array (14 values required) RAYGUIDEF void GuiLoadStyleProps(const int *props, int count); // Load style from a color palette array (14 values required)
RAYGUIDEF void GuiLoadStylePaletteImage(const char *fileName); // Load style from an image palette file (64x16) RAYGUIDEF void GuiLoadStylePaletteImage(const char *fileName); // Load style from an image palette file (64x16)
RAYGUIDEF void GuiUpdateStyleComplete(void); // Updates full style properties set with default values RAYGUIDEF void GuiUpdateStyleComplete(void); // Updates full style properties set with default values
@ -2910,14 +2910,20 @@ RAYGUIDEF void GuiLoadStyle(const char *fileName)
} }
} }
// Load style from a palette array (DEFAULT - 24 values required) // Load style from a palette values array
RAYGUIDEF void GuiLoadStylePalette(const int *palette) RAYGUIDEF void GuiLoadStyleProps(const int *props, int count)
{ {
// Load default style color palette int completeSets = count/(NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED);
for (int i = 0; i < (NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED); i++) GuiSetStyle(DEFAULT, i, palette[i]); int uncompleteSetProps = count%(NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED);
// Update all controls style with default values // Load style palette values from array (complete property sets)
GuiUpdateStyleComplete(); for (int i = 0; i < completeSets; i++)
{
for (int j = 0; j < (NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED); i++) GuiSetStyle(i, j, props[i]);
}
// Load style palette values from array (uncomplete property set)
for (int k = 0; k < uncompleteSetProps; k++) GuiSetStyle(completeSets, k, props[completeSets*(NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED) + k]);
} }
// Load GUI style from an image style file // Load GUI style from an image style file
@ -2957,7 +2963,7 @@ RAYGUIDEF void GuiUpdateStyleComplete(void)
// NOTE: Extended style properties are ignored // NOTE: Extended style properties are ignored
for (int i = 1; i < NUM_CONTROLS; i++) for (int i = 1; i < NUM_CONTROLS; i++)
{ {
for (int j = 0; j < NUM_PROPS_DEFAULT; j++)GuiSetStyle(i, j, GuiGetStyle(DEFAULT, j)); for (int j = 0; j < NUM_PROPS_DEFAULT; j++) GuiSetStyle(i, j, GuiGetStyle(DEFAULT, j));
} }
} }
#endif // defined(RAYGUI_STYLE_LOADING) #endif // defined(RAYGUI_STYLE_LOADING)
@ -2986,8 +2992,6 @@ static unsigned int *GetStyleDefault(void)
GuiSetStyle(DEFAULT, BORDER_COLOR_DISABLED, 0xb5c1c2ff); GuiSetStyle(DEFAULT, BORDER_COLOR_DISABLED, 0xb5c1c2ff);
GuiSetStyle(DEFAULT, BASE_COLOR_DISABLED, 0xe6e9e9ff); GuiSetStyle(DEFAULT, BASE_COLOR_DISABLED, 0xe6e9e9ff);
GuiSetStyle(DEFAULT, TEXT_COLOR_DISABLED, 0xaeb7b8ff); GuiSetStyle(DEFAULT, TEXT_COLOR_DISABLED, 0xaeb7b8ff);
GuiSetStyle(DEFAULT, TEXT_SIZE, 10);
GuiSetStyle(DEFAULT, TEXT_SPACING, 1);
GuiSetStyle(DEFAULT, BORDER_WIDTH, 1); GuiSetStyle(DEFAULT, BORDER_WIDTH, 1);
GuiSetStyle(DEFAULT, INNER_PADDING, 1); GuiSetStyle(DEFAULT, INNER_PADDING, 1);
@ -2999,8 +3003,11 @@ static unsigned int *GetStyleDefault(void)
// Initialize extended property values // Initialize extended property values
// NOTE: By default, extended property values are initialized to 0 // NOTE: By default, extended property values are initialized to 0
GuiSetStyle(DEFAULT, TEXT_SIZE, 10);
GuiSetStyle(DEFAULT, TEXT_SPACING, 1);
GuiSetStyle(DEFAULT, LINES_COLOR, 0x90abb5ff); // DEFAULT specific property GuiSetStyle(DEFAULT, LINES_COLOR, 0x90abb5ff); // DEFAULT specific property
GuiSetStyle(DEFAULT, BACKGROUND_COLOR, 0xf5f5f5ff); // DEFAULT specific property GuiSetStyle(DEFAULT, BACKGROUND_COLOR, 0xf5f5f5ff); // DEFAULT specific property
GuiSetStyle(BUTTON, BORDER_WIDTH, 2); GuiSetStyle(BUTTON, BORDER_WIDTH, 2);
GuiSetStyle(TOGGLE, GROUP_PADDING, 2); GuiSetStyle(TOGGLE, GROUP_PADDING, 2);
GuiSetStyle(SLIDER, SLIDER_WIDTH, 15); GuiSetStyle(SLIDER, SLIDER_WIDTH, 15);