mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-03 20:59:18 -05:00
Fixed some parameters
Removed image button from list, added toggle buttons for default colors.
This commit is contained in:
@ -60,7 +60,7 @@
|
|||||||
#define CONTROL_LIST_HEIGHT 38
|
#define CONTROL_LIST_HEIGHT 38
|
||||||
#define STATUS_BAR_HEIGHT 25
|
#define STATUS_BAR_HEIGHT 25
|
||||||
|
|
||||||
#define NUM_CONTROLS 15
|
#define NUM_CONTROLS 14
|
||||||
#define NUM_STYLES_A 4
|
#define NUM_STYLES_A 4
|
||||||
#define NUM_STYLES_B 8
|
#define NUM_STYLES_B 8
|
||||||
#define NUM_STYLES_C 12
|
#define NUM_STYLES_C 12
|
||||||
@ -72,7 +72,7 @@ typedef enum {
|
|||||||
LABEL = 0,
|
LABEL = 0,
|
||||||
LABELBUTTON,
|
LABELBUTTON,
|
||||||
BUTTON,
|
BUTTON,
|
||||||
IMAGEBUTTON,
|
//IMAGEBUTTON,
|
||||||
TOGGLE,
|
TOGGLE,
|
||||||
TOGGLEGROUP,
|
TOGGLEGROUP,
|
||||||
SLIDER,
|
SLIDER,
|
||||||
@ -110,7 +110,7 @@ const char *guiControlText[NUM_CONTROLS] = {
|
|||||||
"LABEL",
|
"LABEL",
|
||||||
"LABELBUTTON",
|
"LABELBUTTON",
|
||||||
"BUTTON",
|
"BUTTON",
|
||||||
"IMAGEBUTTON",
|
//"IMAGEBUTTON",
|
||||||
"TOGGLE",
|
"TOGGLE",
|
||||||
"TOGGLEGROUP",
|
"TOGGLEGROUP",
|
||||||
"SLIDER",
|
"SLIDER",
|
||||||
@ -192,7 +192,7 @@ int main(int argc, char *argv[])
|
|||||||
(Rectangle){ guiPosX + 23, guiPosY + 18, 50, 10 }, // LABEL
|
(Rectangle){ guiPosX + 23, guiPosY + 18, 50, 10 }, // LABEL
|
||||||
(Rectangle){ guiPosX + 98, guiPosY + 18, 140, 10 }, // LABELBUTTON
|
(Rectangle){ guiPosX + 98, guiPosY + 18, 140, 10 }, // LABELBUTTON
|
||||||
(Rectangle){ guiPosX + 184, guiPosY + 250, 180, 30 }, // BUTTON
|
(Rectangle){ guiPosX + 184, guiPosY + 250, 180, 30 }, // BUTTON
|
||||||
(Rectangle){ guiPosX + 251, guiPosY + 5, 113, 32 }, // IMAGEBUTTON
|
//(Rectangle){ guiPosX + 251, guiPosY + 5, 113, 32 }, // IMAGEBUTTON
|
||||||
(Rectangle){ guiPosX + 20, guiPosY + 54, 60, 30 }, // TOGGLE
|
(Rectangle){ guiPosX + 20, guiPosY + 54, 60, 30 }, // TOGGLE
|
||||||
(Rectangle){ guiPosX + 98, guiPosY + 54, 65, 30 }, // TOGGLEGROUP
|
(Rectangle){ guiPosX + 98, guiPosY + 54, 65, 30 }, // TOGGLEGROUP
|
||||||
(Rectangle){ guiPosX + 20, guiPosY + 104, 344, 20 }, // SLIDER
|
(Rectangle){ guiPosX + 20, guiPosY + 104, 344, 20 }, // SLIDER
|
||||||
@ -256,6 +256,10 @@ int main(int argc, char *argv[])
|
|||||||
bool toggleLinesColor = false;
|
bool toggleLinesColor = false;
|
||||||
bool toggleDefaultColor = false;
|
bool toggleDefaultColor = false;
|
||||||
|
|
||||||
|
bool toggleBackgroundColorPressed = false;
|
||||||
|
bool toggleLinesColorPressed = false;
|
||||||
|
bool toggleDefaultColorPressed = false;
|
||||||
|
|
||||||
Vector3 colorHSV = { 0.0f, 0.0f, 0.0f };
|
Vector3 colorHSV = { 0.0f, 0.0f, 0.0f };
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -270,13 +274,34 @@ int main(int argc, char *argv[])
|
|||||||
GuiLoadStyle(droppedFiles[0]);
|
GuiLoadStyle(droppedFiles[0]);
|
||||||
ClearDroppedFiles();
|
ClearDroppedFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toggleBackgroundColorPressed != toggleBackgroundColor)
|
||||||
|
{
|
||||||
|
colorPickerValue = GetColor(styleGeneric[DEFAULT_BACKGROUND_COLOR]);
|
||||||
|
}
|
||||||
if (toggleBackgroundColor)
|
if (toggleBackgroundColor)
|
||||||
{
|
{
|
||||||
|
toggleBackgroundColorPressed = true;
|
||||||
|
currentSelectedControl = -1;
|
||||||
|
currentSelectedProperty = -1;
|
||||||
styleGeneric[DEFAULT_BACKGROUND_COLOR] = ColorToInt(colorPickerValue);
|
styleGeneric[DEFAULT_BACKGROUND_COLOR] = ColorToInt(colorPickerValue);
|
||||||
}
|
}
|
||||||
else
|
else toggleBackgroundColorPressed = false;
|
||||||
|
|
||||||
|
if (toggleLinesColorPressed != toggleLinesColor)
|
||||||
{
|
{
|
||||||
|
colorPickerValue = GetColor(styleGeneric[DEFAULT_LINES_COLOR]);
|
||||||
|
}
|
||||||
|
if (toggleLinesColor)
|
||||||
|
{
|
||||||
|
toggleLinesColorPressed = true;
|
||||||
|
currentSelectedControl = -1;
|
||||||
|
currentSelectedProperty = -1;
|
||||||
|
styleGeneric[DEFAULT_LINES_COLOR] = ColorToInt(colorPickerValue);
|
||||||
|
}
|
||||||
|
else toggleLinesColorPressed = false;
|
||||||
|
|
||||||
|
|
||||||
if ((currentSelectedControl != -1) && (currentSelectedProperty != -1))
|
if ((currentSelectedControl != -1) && (currentSelectedProperty != -1))
|
||||||
{
|
{
|
||||||
if ((previousSelectedProperty != currentSelectedProperty) || (previousSelectedControl != currentSelectedControl)) saveColor = false;
|
if ((previousSelectedProperty != currentSelectedProperty) || (previousSelectedControl != currentSelectedControl)) saveColor = false;
|
||||||
@ -289,7 +314,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
GuiSetStyleProperty(GetGuiStylePropertyIndex(currentSelectedControl, currentSelectedProperty), ColorToInt(colorPickerValue));
|
GuiSetStyleProperty(GetGuiStylePropertyIndex(currentSelectedControl, currentSelectedProperty), ColorToInt(colorPickerValue));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
previousSelectedProperty = currentSelectedProperty;
|
previousSelectedProperty = currentSelectedProperty;
|
||||||
previousSelectedControl = currentSelectedControl;
|
previousSelectedControl = currentSelectedControl;
|
||||||
@ -315,15 +340,15 @@ int main(int argc, char *argv[])
|
|||||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GuiBackgroundColor());
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GuiBackgroundColor());
|
||||||
|
|
||||||
// Draw info bar top
|
// Draw info bar top
|
||||||
DrawRectangle(0, 0, GetScreenWidth(), 24, GRAY);
|
DrawRectangle(0, 0, GetScreenWidth(), 24, GetColor(styleGeneric[DEFAULT_BASE_COLOR_NORMAL]));
|
||||||
DrawText("CHOOSE CONTROL", 35, 8, styleGeneric[DEFAULT_TEXT_SIZE], LIGHTGRAY);
|
DrawText("CHOOSE CONTROL", 35, 8, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(styleGeneric[DEFAULT_TEXT_COLOR_NORMAL]));
|
||||||
DrawText("> CHOOSE PROPERTY STYLE", 152, 8, styleGeneric[DEFAULT_TEXT_SIZE], LIGHTGRAY);
|
DrawText("> CHOOSE PROPERTY STYLE", 152, 8, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(styleGeneric[DEFAULT_TEXT_COLOR_NORMAL]));
|
||||||
DrawText("> STYLE VIEWER", guiPosX + 10, 8, styleGeneric[DEFAULT_TEXT_SIZE], LIGHTGRAY);
|
DrawText("> STYLE VIEWER", guiPosX + 10, 8, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(styleGeneric[DEFAULT_TEXT_COLOR_NORMAL]));
|
||||||
|
|
||||||
// Draw status bar bottom
|
// Draw status bar bottom
|
||||||
DrawRectangle(0, GetScreenHeight() - 24, GetScreenWidth(), 24, LIGHTGRAY);
|
DrawRectangle(0, GetScreenHeight() - 24, GetScreenWidth(), 24, GetColor(styleGeneric[DEFAULT_BASE_COLOR_NORMAL]));
|
||||||
GuiLabel((Rectangle){20, GetScreenHeight() - 16, 100, 20}, FormatText("CURRENT SELECTION: %s_%s", guiControlText[currentSelectedControl], guiStylesTextC[currentSelectedProperty]));
|
DrawText(FormatText("CURRENT SELECTION: %s_%s", guiControlText[currentSelectedControl], guiStylesTextC[currentSelectedProperty]), 20, GetScreenHeight() - 16, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(styleGeneric[DEFAULT_TEXT_COLOR_NORMAL]));
|
||||||
GuiLabel((Rectangle){guiPosX + 100, GetScreenHeight() - 16, 100, 20}, FormatText("SAVE STATUS: %s", guiText));
|
DrawText(FormatText("SAVE STATUS: %s", guiText), guiPosX + 100, GetScreenHeight() - 16, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(styleGeneric[DEFAULT_TEXT_COLOR_NORMAL]));
|
||||||
|
|
||||||
// Draw Gui controls
|
// Draw Gui controls
|
||||||
currentSelectedControl = GuiListView(bounds[LISTVIEW], guiControlText, NUM_CONTROLS, currentSelectedControl);
|
currentSelectedControl = GuiListView(bounds[LISTVIEW], guiControlText, NUM_CONTROLS, currentSelectedControl);
|
||||||
@ -340,7 +365,7 @@ int main(int argc, char *argv[])
|
|||||||
case CHECKBOX:
|
case CHECKBOX:
|
||||||
case COLORPICKER: currentSelectedProperty = GuiListView((Rectangle){ 156, guiPosY + 3, 180, 485 }, guiStylesTextB, NUM_STYLES_B, currentSelectedProperty); break;
|
case COLORPICKER: currentSelectedProperty = GuiListView((Rectangle){ 156, guiPosY + 3, 180, 485 }, guiStylesTextB, NUM_STYLES_B, currentSelectedProperty); break;
|
||||||
case BUTTON:
|
case BUTTON:
|
||||||
case IMAGEBUTTON:
|
//case IMAGEBUTTON:
|
||||||
case TOGGLE:
|
case TOGGLE:
|
||||||
case TOGGLEGROUP:
|
case TOGGLEGROUP:
|
||||||
case COMBOBOX:
|
case COMBOBOX:
|
||||||
@ -360,7 +385,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (GuiLabelButton(bounds[LABELBUTTON], "github.com/raysan5/raygui")) {}
|
if (GuiLabelButton(bounds[LABELBUTTON], "github.com/raysan5/raygui")) {}
|
||||||
|
|
||||||
if (GuiImageButtonEx(bounds[IMAGEBUTTON], texIcons , (Rectangle){ 0, 0, texIcons.width/3, texIcons.height/6 }, "Load Style")) { }
|
if (GuiImageButtonEx((Rectangle){ guiPosX + 251, guiPosY + 5, 113, 32 }, texIcons , (Rectangle){ 0, 0, texIcons.width/3, texIcons.height/6 }, "Load Style")) { }
|
||||||
|
|
||||||
toggle = GuiToggleButton(bounds[TOGGLE], "toggle", toggle);
|
toggle = GuiToggleButton(bounds[TOGGLE], "toggle", toggle);
|
||||||
|
|
||||||
@ -475,7 +500,7 @@ static int GetGuiStylePropertyIndex(int control, int property)
|
|||||||
case LABEL: guiProp = LABEL_TEXT_COLOR_NORMAL + property; break;
|
case LABEL: guiProp = LABEL_TEXT_COLOR_NORMAL + property; break;
|
||||||
case LABELBUTTON: guiProp = LABEL_TEXT_COLOR_NORMAL + property; break;
|
case LABELBUTTON: guiProp = LABEL_TEXT_COLOR_NORMAL + property; break;
|
||||||
case BUTTON: guiProp = BUTTON_BORDER_COLOR_NORMAL + property; break;
|
case BUTTON: guiProp = BUTTON_BORDER_COLOR_NORMAL + property; break;
|
||||||
case IMAGEBUTTON: guiProp = BUTTON_BORDER_COLOR_NORMAL + property; break;
|
//case IMAGEBUTTON: guiProp = BUTTON_BORDER_COLOR_NORMAL + property; break;
|
||||||
case TOGGLE: guiProp = TOGGLE_BORDER_COLOR_NORMAL + property; break;
|
case TOGGLE: guiProp = TOGGLE_BORDER_COLOR_NORMAL + property; break;
|
||||||
case TOGGLEGROUP: guiProp = TOGGLE_BORDER_COLOR_NORMAL + property; break;
|
case TOGGLEGROUP: guiProp = TOGGLE_BORDER_COLOR_NORMAL + property; break;
|
||||||
case SLIDER: guiProp = SLIDER_BORDER_COLOR_NORMAL + property; break;
|
case SLIDER: guiProp = SLIDER_BORDER_COLOR_NORMAL + property; break;
|
||||||
|
|||||||
Reference in New Issue
Block a user