Remove trailing spaces

This commit is contained in:
Ray 2021-03-19 20:12:50 +01:00
parent 13aac618ad
commit 6b216626ec
2 changed files with 55 additions and 55 deletions

View File

@ -51,7 +51,7 @@ int main()
//---------------------------------------------------------------------------------------
int screenWidth = 690;
int screenHeight = 560;
InitWindow(screenWidth, screenHeight, "raygui - controls test suite");
SetExitKey(0);
@ -59,19 +59,19 @@ int main()
//----------------------------------------------------------------------------------
int dropdownBox000Active = 0;
bool dropDown000EditMode = false;
int dropdownBox001Active = 0;
bool dropDown001EditMode = false;
bool dropDown001EditMode = false;
int spinner001Value = 0;
bool spinnerEditMode = false;
int valueBox002Value = 0;
bool valueBoxEditMode = false;
char textBoxText[64] = "Text box";
bool textBoxEditMode = false;
int listViewScrollIndex = 0;
int listViewActive = -1;
@ -83,32 +83,32 @@ int main()
char multiTextBoxText[256] = "Multi text box";
bool multiTextBoxEditMode = false;
Color colorPickerValue = RED;
int sliderValue = 50;
int sliderBarValue = 60;
float progressValue = 0.4f;
bool forceSquaredChecked = false;
float alphaValue = 0.5f;
int comboBoxActive = 1;
int toggleGroupActive = 0;
Vector2 viewScroll = { 0, 0 };
//----------------------------------------------------------------------------------
// Custom GUI font loading
//Font font = LoadFontEx("fonts/rainyhearts16.ttf", 12, 0, 0);
//GuiSetFont(font);
bool exitWindow = false;
bool showMessageBox = false;
char textInput[256] = { 0 };
bool showTextInputBox = false;
char textInputFileName[256] = { 0 };
SetTargetFPS(60);
@ -120,18 +120,18 @@ int main()
// Update
//----------------------------------------------------------------------------------
exitWindow = WindowShouldClose();
if (IsKeyPressed(KEY_ESCAPE)) showMessageBox = !showMessageBox;
if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_S)) showTextInputBox = true;
if (IsFileDropped())
{
int dropsCount = 0;
char **droppedFiles = GetDroppedFiles(&dropsCount);
if ((dropsCount > 0) && IsFileExtension(droppedFiles[0], ".rgs")) GuiLoadStyle(droppedFiles[0]);
ClearDroppedFiles(); // Clear internal buffers
}
//----------------------------------------------------------------------------------
@ -141,29 +141,29 @@ int main()
BeginDrawing();
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
// raygui: controls drawing
//----------------------------------------------------------------------------------
if (dropDown000EditMode || dropDown001EditMode) GuiLock();
//GuiDisable();
// First GUI column
//GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
forceSquaredChecked = GuiCheckBox((Rectangle){ 25, 108, 15, 15 }, "FORCE CHECK!", forceSquaredChecked);
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
//GuiSetStyle(VALUEBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
if (GuiSpinner((Rectangle){ 25, 135, 125, 30 }, NULL, &spinner001Value, 0, 100, spinnerEditMode)) spinnerEditMode = !spinnerEditMode;
if (GuiValueBox((Rectangle){ 25, 175, 125, 30 }, NULL, &valueBox002Value, 0, 100, valueBoxEditMode)) valueBoxEditMode = !valueBoxEditMode;
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
if (GuiTextBox((Rectangle){ 25, 215, 125, 30 }, textBoxText, 64, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
GuiSetTooltip("Save current file.");
if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(RICON_FILE_SAVE, "Save File"))) showTextInputBox = true;
GuiClearTooltip();
GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES");
GuiLock();
GuiSetState(GUI_STATE_NORMAL); if (GuiButton((Rectangle){ 30, 320, 115, 30 }, "NORMAL")) { }
@ -172,9 +172,9 @@ int main()
GuiSetState(GUI_STATE_DISABLED); if (GuiButton((Rectangle){ 30, 425, 115, 30 }, "DISABLED")) { }
GuiSetState(GUI_STATE_NORMAL);
GuiUnlock();
comboBoxActive = GuiComboBox((Rectangle){ 25, 470, 125, 30 }, "ONE;TWO;THREE;FOUR", comboBoxActive);
// NOTE: GuiDropdownBox must draw after any other control that can be covered on unfolding
GuiSetStyle(DROPDOWNBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
if (GuiDropdownBox((Rectangle){ 25, 65, 125, 30 }, "#01#ONE;#02#TWO;#03#THREE;#04#FOUR", &dropdownBox001Active, dropDown001EditMode)) dropDown001EditMode = !dropDown001EditMode;
@ -187,50 +187,50 @@ int main()
listViewExActive = GuiListViewEx((Rectangle){ 165, 180, 140, 200 }, listViewExList, 8, &listViewExFocus, &listViewExScrollIndex, listViewExActive);
toggleGroupActive = GuiToggleGroup((Rectangle){ 165, 400, 140, 25 }, "#1#ONE\n#3#TWO\n#8#THREE\n#23#", toggleGroupActive);
// Third GUI column
if (GuiTextBoxMulti((Rectangle){ 320, 25, 225, 140 }, multiTextBoxText, 256, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode;
colorPickerValue = GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, colorPickerValue);
sliderValue = GuiSlider((Rectangle){ 355, 400, 165, 20 }, "TEST", TextFormat("%2.2f", (float)sliderValue), sliderValue, -50, 100);
sliderBarValue = GuiSliderBar((Rectangle){ 320, 430, 200, 20 }, NULL, TextFormat("%i", (int)sliderBarValue), sliderBarValue, 0, 100);
progressValue = GuiProgressBar((Rectangle){ 320, 460, 200, 20 }, NULL, NULL, progressValue, 0, 1);
// NOTE: View rectangle could be used to perform some scissor test
Rectangle view = GuiScrollPanel((Rectangle){ 560, 25, 100, 160 }, (Rectangle){ 560, 25, 200, 400 }, &viewScroll);
GuiStatusBar((Rectangle){ 0, GetScreenHeight() - 20, GetScreenWidth(), 20 }, "This is a status bar");
alphaValue = GuiColorBarAlpha((Rectangle){ 320, 490, 200, 30 }, alphaValue);
if (showMessageBox)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
int result = GuiMessageBox((Rectangle){ GetScreenWidth()/2 - 125, GetScreenHeight()/2 - 50, 250, 100 }, GuiIconText(RICON_EXIT, "Close Window"), "Do you really want to exit?", "Yes;No");
int result = GuiMessageBox((Rectangle){ GetScreenWidth()/2 - 125, GetScreenHeight()/2 - 50, 250, 100 }, GuiIconText(RICON_EXIT, "Close Window"), "Do you really want to exit?", "Yes;No");
if ((result == 0) || (result == 2)) showMessageBox = false;
else if (result == 1) exitWindow = true;
}
if (showTextInputBox)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
int result = GuiTextInputBox((Rectangle){ GetScreenWidth()/2 - 120, GetScreenHeight()/2 - 60, 240, 140 }, GuiIconText(RICON_FILE_SAVE, "Save file as..."), "Introduce a save file name", "Ok;Cancel", textInput);
if (result == 1)
{
// TODO: Validate textInput value and save
strcpy(textInputFileName, textInput);
}
if ((result == 0) || (result == 1) || (result == 2))
if ((result == 0) || (result == 1) || (result == 2))
{
showTextInputBox = false;
strcpy(textInput, "\0");
}
}
GuiUnlock();
//----------------------------------------------------------------------------------

View File

@ -721,7 +721,7 @@ bool GuiWindowBox(Rectangle bounds, const char *title)
Rectangle statusBar = { bounds.x, bounds.y, bounds.width, (float)statusBarHeight };
if (bounds.height < statusBarHeight*2.0f) bounds.height = statusBarHeight*2.0f;
Rectangle windowPanel = { bounds.x, bounds.y + (float)statusBarHeight - 1, bounds.width, bounds.height - (float)statusBarHeight };
Rectangle closeButtonRec = { statusBar.x + statusBar.width - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - 20,
statusBar.y + statusBarHeight/2.0f - 18.0f/2.0f, 18, 18 };
@ -735,7 +735,7 @@ bool GuiWindowBox(Rectangle bounds, const char *title)
//--------------------------------------------------------------------
GuiStatusBar(statusBar, title); // Draw window header as status bar
GuiPanel(windowPanel); // Draw window base
// Draw window close button
int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH);
int tempTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
@ -920,7 +920,7 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll)
// Draw scrollbar lines depending on current state
GuiDrawRectangle(bounds, GuiGetStyle(DEFAULT, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER + (state*3))), guiAlpha), BLANK);
// Set scrollbar slider size back to the way it was before
GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, slider);
//--------------------------------------------------------------------
@ -1171,7 +1171,7 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
// Draw control
//--------------------------------------------------------------------
GuiDrawRectangle(bounds, GuiGetStyle(CHECKBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(CHECKBOX, BORDER + (state*3))), guiAlpha), BLANK);
if (checked)
{
Rectangle check = { bounds.x + GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING),
@ -1403,7 +1403,7 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
{
int byteLength = 0;
const char *textUtf8 = CodepointToUtf8(key, &byteLength);
for (int i = 0; i < byteLength; i++)
{
text[keyCount] = textUtf8[i];
@ -1650,19 +1650,19 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
Color baseColor = BLANK;
if (state == GUI_STATE_PRESSED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_PRESSED));
else if (state == GUI_STATE_DISABLED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_DISABLED));
// WARNING: BLANK color does not work properly with Fade()
GuiDrawRectangle(bounds, GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER + (state*3))), guiAlpha), baseColor);
GuiDrawText(textValue, GetTextBounds(VALUEBOX, bounds), GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(VALUEBOX, TEXT + (state*3))), guiAlpha));
// Draw blinking cursor
if ((state == GUI_STATE_PRESSED) && (editMode && ((framesCounter/20)%2 == 0)))
if ((state == GUI_STATE_PRESSED) && (editMode && ((framesCounter/20)%2 == 0)))
{
// NOTE: ValueBox internal text is always centered
Rectangle cursor = { bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 1, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
}
// Draw text label if provided
if (text != NULL) GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
//--------------------------------------------------------------------
@ -2095,7 +2095,7 @@ int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
// Draw control
//--------------------------------------------------------------------
GuiDrawRectangle(bounds, GuiGetStyle(SCROLLBAR, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), guiAlpha), Fade(GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_DISABLED)), guiAlpha)); // Draw the background
GuiDrawRectangle(scrollbar, 0, BLANK, Fade(GetColor(GuiGetStyle(BUTTON, BASE_COLOR_NORMAL)), guiAlpha)); // Draw the scrollbar active area background
GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, BORDER + state*3)), guiAlpha)); // Draw the slider bar
@ -3309,13 +3309,13 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color
// Gui draw rectangle using default raygui plain style with borders
static void GuiDrawRectangle(Rectangle rec, int borderWidth, Color borderColor, Color color)
{
if (color.a > 0)
if (color.a > 0)
{
// Draw rectangle filled with color
DrawRectangle((int)rec.x, (int)rec.y, (int)rec.width, (int)rec.height, color);
}
if (borderWidth > 0)
if (borderWidth > 0)
{
// Draw rectangle border lines with color
DrawRectangle((int)rec.x, (int)rec.y, (int)rec.width, borderWidth, borderColor);
@ -3323,7 +3323,7 @@ static void GuiDrawRectangle(Rectangle rec, int borderWidth, Color borderColor,
DrawRectangle((int)rec.x + (int)rec.width - borderWidth, (int)rec.y + borderWidth, borderWidth, (int)rec.height - 2*borderWidth, borderColor);
DrawRectangle((int)rec.x, (int)rec.y + (int)rec.height - borderWidth, (int)rec.width, borderWidth, borderColor);
}
// TODO: For n-patch-based style we would need: [state] and maybe [control]
// In this case all controls drawing logic should be moved to this function... I don't like it...
}
@ -3543,7 +3543,7 @@ static Color Fade(Color color, float alpha)
{
if (alpha < 0.0f) alpha = 0.0f;
else if (alpha > 1.0f) alpha = 1.0f;
Color result = { color.r, color.g, color.b, (unsigned char)(255.0f*alpha) };
return result;