diff --git a/src/raygui.h b/src/raygui.h index a9419d3..1ee042d 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -640,7 +640,7 @@ static int style[NUM_PROPERTIES] = { // This functions are directly implemented in raygui static Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value -static int GetHexValue(Color color); // Returns hexadecimal value for a Color +static int ColorToInt(Color color); // Returns hexadecimal value for a Color static Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f static bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle static const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed' @@ -2128,20 +2128,20 @@ RAYGUIDEF void GuiLoadStyleImage(const char *fileName) Color *pixels = GetImageData(imStyle); // Load generic style color palette - styleGeneric[DEFAULT_BACKGROUND_COLOR] = GetHexValue(pixels[1 + imStyle.width*1]); - styleGeneric[DEFAULT_LINES_COLOR] = GetHexValue(pixels[0 + imStyle.width*0]); - styleGeneric[DEFAULT_BORDER_COLOR_NORMAL] = GetHexValue(pixels[2 + imStyle.width*2]); - styleGeneric[DEFAULT_BASE_COLOR_NORMAL] = GetHexValue(pixels[3 + imStyle.width*3]); - styleGeneric[DEFAULT_TEXT_COLOR_NORMAL] = GetHexValue(pixels[9 + imStyle.width*4]); - styleGeneric[DEFAULT_BORDER_COLOR_FOCUSED] = GetHexValue(pixels[17 + imStyle.width*2]); - styleGeneric[DEFAULT_BASE_COLOR_FOCUSED] = GetHexValue(pixels[18 + imStyle.width*3]); - styleGeneric[DEFAULT_TEXT_COLOR_FOCUSED] = GetHexValue(pixels[24 + imStyle.width*4]); - styleGeneric[DEFAULT_BORDER_COLOR_PRESSED] = GetHexValue(pixels[32 + imStyle.width*2]); - styleGeneric[DEFAULT_BASE_COLOR_PRESSED] = GetHexValue(pixels[33 + imStyle.width*3]); - styleGeneric[DEFAULT_TEXT_COLOR_PRESSED] = GetHexValue(pixels[39 + imStyle.width*4]); - styleGeneric[DEFAULT_BORDER_COLOR_DISABLED] = GetHexValue(pixels[47 + imStyle.width*2]); - styleGeneric[DEFAULT_BASE_COLOR_DISABLED] = GetHexValue(pixels[48 + imStyle.width*3]); - styleGeneric[DEFAULT_TEXT_COLOR_DISABLED] = GetHexValue(pixels[54 + imStyle.width*4]); + styleGeneric[DEFAULT_BACKGROUND_COLOR] = ColorToInt(pixels[1 + imStyle.width*1]); + styleGeneric[DEFAULT_LINES_COLOR] = ColorToInt(pixels[0 + imStyle.width*0]); + styleGeneric[DEFAULT_BORDER_COLOR_NORMAL] = ColorToInt(pixels[2 + imStyle.width*2]); + styleGeneric[DEFAULT_BASE_COLOR_NORMAL] = ColorToInt(pixels[3 + imStyle.width*3]); + styleGeneric[DEFAULT_TEXT_COLOR_NORMAL] = ColorToInt(pixels[9 + imStyle.width*4]); + styleGeneric[DEFAULT_BORDER_COLOR_FOCUSED] = ColorToInt(pixels[17 + imStyle.width*2]); + styleGeneric[DEFAULT_BASE_COLOR_FOCUSED] = ColorToInt(pixels[18 + imStyle.width*3]); + styleGeneric[DEFAULT_TEXT_COLOR_FOCUSED] = ColorToInt(pixels[24 + imStyle.width*4]); + styleGeneric[DEFAULT_BORDER_COLOR_PRESSED] = ColorToInt(pixels[32 + imStyle.width*2]); + styleGeneric[DEFAULT_BASE_COLOR_PRESSED] = ColorToInt(pixels[33 + imStyle.width*3]); + styleGeneric[DEFAULT_TEXT_COLOR_PRESSED] = ColorToInt(pixels[39 + imStyle.width*4]); + styleGeneric[DEFAULT_BORDER_COLOR_DISABLED] = ColorToInt(pixels[47 + imStyle.width*2]); + styleGeneric[DEFAULT_BASE_COLOR_DISABLED] = ColorToInt(pixels[48 + imStyle.width*3]); + styleGeneric[DEFAULT_TEXT_COLOR_DISABLED] = ColorToInt(pixels[54 + imStyle.width*4]); // Update full style with generic values GuiUpdateStyleComplete(); @@ -2153,20 +2153,20 @@ RAYGUIDEF void GuiLoadStyleImage(const char *fileName) RAYGUIDEF void GuiLoadStylePalette(Color *palette) { // Load generic style color palette - styleGeneric[DEFAULT_BACKGROUND_COLOR] = GetHexValue(palette[0]); - styleGeneric[DEFAULT_LINES_COLOR] = GetHexValue(palette[1]); - styleGeneric[DEFAULT_BORDER_COLOR_NORMAL] = GetHexValue(palette[2]); - styleGeneric[DEFAULT_BASE_COLOR_NORMAL] = GetHexValue(palette[3]); - styleGeneric[DEFAULT_TEXT_COLOR_NORMAL] = GetHexValue(palette[4]); - styleGeneric[DEFAULT_BORDER_COLOR_FOCUSED] = GetHexValue(palette[5]); - styleGeneric[DEFAULT_BASE_COLOR_FOCUSED] = GetHexValue(palette[6]); - styleGeneric[DEFAULT_TEXT_COLOR_FOCUSED] = GetHexValue(palette[7]); - styleGeneric[DEFAULT_BORDER_COLOR_PRESSED] = GetHexValue(palette[8]); - styleGeneric[DEFAULT_BASE_COLOR_PRESSED] = GetHexValue(palette[9]); - styleGeneric[DEFAULT_TEXT_COLOR_PRESSED] = GetHexValue(palette[10]); - styleGeneric[DEFAULT_BORDER_COLOR_DISABLED] = GetHexValue(palette[11]); - styleGeneric[DEFAULT_BASE_COLOR_DISABLED] = GetHexValue(palette[12]); - styleGeneric[DEFAULT_TEXT_COLOR_DISABLED] = GetHexValue(palette[13]); + styleGeneric[DEFAULT_BACKGROUND_COLOR] = ColorToInt(palette[0]); + styleGeneric[DEFAULT_LINES_COLOR] = ColorToInt(palette[1]); + styleGeneric[DEFAULT_BORDER_COLOR_NORMAL] = ColorToInt(palette[2]); + styleGeneric[DEFAULT_BASE_COLOR_NORMAL] = ColorToInt(palette[3]); + styleGeneric[DEFAULT_TEXT_COLOR_NORMAL] = ColorToInt(palette[4]); + styleGeneric[DEFAULT_BORDER_COLOR_FOCUSED] = ColorToInt(palette[5]); + styleGeneric[DEFAULT_BASE_COLOR_FOCUSED] = ColorToInt(palette[6]); + styleGeneric[DEFAULT_TEXT_COLOR_FOCUSED] = ColorToInt(palette[7]); + styleGeneric[DEFAULT_BORDER_COLOR_PRESSED] = ColorToInt(palette[8]); + styleGeneric[DEFAULT_BASE_COLOR_PRESSED] = ColorToInt(palette[9]); + styleGeneric[DEFAULT_TEXT_COLOR_PRESSED] = ColorToInt(palette[10]); + styleGeneric[DEFAULT_BORDER_COLOR_DISABLED] = ColorToInt(palette[11]); + styleGeneric[DEFAULT_BASE_COLOR_DISABLED] = ColorToInt(palette[12]); + styleGeneric[DEFAULT_TEXT_COLOR_DISABLED] = ColorToInt(palette[13]); // Update full style with generic values GuiUpdateStyleComplete(); @@ -2512,7 +2512,7 @@ static Color GetColor(int hexValue) } // Returns hexadecimal value for a Color -static int GetHexValue(Color color) +static int ColorToInt(Color color) { return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a); } diff --git a/tools/rGuiStyler/rguistyler.c b/tools/rGuiStyler/rguistyler.c index c16034b..1e08d26 100644 --- a/tools/rGuiStyler/rguistyler.c +++ b/tools/rGuiStyler/rguistyler.c @@ -255,6 +255,8 @@ int main(int argc, char *argv[]) bool toggleBackgroundColor = false; bool toggleLinesColor = false; bool toggleDefaultColor = false; + + Vector3 colorHSV = { 0.0f, 0.0f, 0.0f }; //-------------------------------------------------------------------------------------- // Main game loop @@ -271,7 +273,7 @@ int main(int argc, char *argv[]) if (toggleBackgroundColor) { - styleGeneric[DEFAULT_BACKGROUND_COLOR] = GetHexValue(colorPickerValue); + styleGeneric[DEFAULT_BACKGROUND_COLOR] = ColorToInt(colorPickerValue); } else { @@ -285,7 +287,7 @@ int main(int argc, char *argv[]) saveColor = true; } - GuiSetStyleProperty(GetGuiStylePropertyIndex(currentSelectedControl, currentSelectedProperty), GetHexValue(colorPickerValue)); + GuiSetStyleProperty(GetGuiStylePropertyIndex(currentSelectedControl, currentSelectedProperty), ColorToInt(colorPickerValue)); } } @@ -299,6 +301,8 @@ int main(int argc, char *argv[]) // TODO: Support text editing on GuiTextBox() // NOTE: Editing mode should be detected (status = MOUSE_HOVER) and update colorPicker properly... sprintf(colorHex, "%02X%02X%02X%02X", colorPickerValue.r, colorPickerValue.g, colorPickerValue.b, colorPickerValue.a); + + colorHSV = ColorToHSV(colorPickerValue); //---------------------------------------------------------------------------------- // Draw @@ -381,15 +385,19 @@ int main(int argc, char *argv[]) toggleLinesColor = GuiToggleButton((Rectangle){ 156, guiPosY + 521, 180, 20 }, "LINES_COLOR", toggleLinesColor); toggleDefaultColor = GuiToggleButton((Rectangle){ 156, guiPosY + 546, 180, 20 }, "DEFAULT_STYLE_MODE", toggleDefaultColor); - // Draw labels for GuiColorPicker information + // Draw labels for GuiColorPicker information (RGBA) GuiGroupBox((Rectangle){ guiPosX + 303, guiPosY + 299, 60, 74 }, "RGBA"); - GuiLabel((Rectangle){ guiPosX + 313, guiPosY + 310, 60, 70 }, FormatText("R: %03i", colorPickerValue.r)); GuiLabel((Rectangle){ guiPosX + 313, guiPosY + 325, 60, 70 }, FormatText("G: %03i", colorPickerValue.g)); GuiLabel((Rectangle){ guiPosX + 313, guiPosY + 340, 60, 70 }, FormatText("B: %03i", colorPickerValue.b)); GuiLabel((Rectangle){ guiPosX + 313, guiPosY + 355, 60, 70 }, FormatText("A: %03i", colorPickerValue.a)); + // Draw labels for GuiColorPicker information (HSV) GuiGroupBox((Rectangle){ guiPosX + 303, guiPosY + 385, 60, 60 }, "HSV"); + GuiLabel((Rectangle){ guiPosX + 313, guiPosY + 395, 60, 70 }, FormatText("H: %.0f ยบ", colorHSV.x)); + GuiLabel((Rectangle){ guiPosX + 313, guiPosY + 412, 60, 70 }, FormatText("S: %.0f %%", colorHSV.y*100)); + GuiLabel((Rectangle){ guiPosX + 313, guiPosY + 429, 60, 70 }, FormatText("V: %.0f %%", colorHSV.z*100)); + GuiTextBox((Rectangle){ guiPosX + 303, guiPosY + 545, 60, 20 }, colorHex, 8); for(int i = 0; i < 12; i++) colorBoxValue[i] = ColorBox((Rectangle){ guiPosX + 303 + 20*(i%3), guiPosY + 455 + 20*(i/3), 20, 20 }, &colorPickerValue, colorBoxValue[i]);