Commented some issues

This commit is contained in:
raysan5
2016-06-15 21:24:23 +02:00
parent 20f3a5d76d
commit b61d361be5
2 changed files with 57 additions and 13 deletions

View File

@ -112,6 +112,9 @@ misrepresented as being the original software.
#define MAX_PATH_OR_CMD 1024 /* _MAX_PATH or MAX_PATH */ #define MAX_PATH_OR_CMD 1024 /* _MAX_PATH or MAX_PATH */
#define MAX_MULTIPLE 32 #define MAX_MULTIPLE 32
#define _MAX_FNAME 32 // Ray: Added to avoid compile error
#define _MAX_EXT 8 // Ray: Added to avoid compile error
char tinyfd_version [ 8 ] = "2.4.3"; char tinyfd_version [ 8 ] = "2.4.3";
#ifdef TINYFD_WIN_CONSOLE_ONLY #ifdef TINYFD_WIN_CONSOLE_ONLY

View File

@ -2,6 +2,11 @@
* *
* raygui styler - raygui Style Editor * raygui styler - raygui Style Editor
* *
* Compile this program using:
* gcc -c external/tinyfiledialogs.c -std=c99 -Wall
* gcc -o $(NAME_PART).exe $(FILE_NAME) tinyfiledialogs.o -lraylib -lglfw3 -lopengl32 -lgdi32 -lcomdlg32 -lole32 -std=c99 -Wall
*
*
* This example has been created using raylib v1.5 (www.raylib.com) * This example has been created using raylib v1.5 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
@ -135,10 +140,12 @@ int main()
else cursorData[w*sizeCursor*2 + 2*h + 1] = 0; else cursorData[w*sizeCursor*2 + 2*h + 1] = 0;
} }
} }
} }
Texture2D cursorTexture = LoadTextureEx(cursorData, sizeCursor, sizeCursor, UNCOMPRESSED_GRAY_ALPHA); Texture2D cursorTexture = LoadTextureEx(cursorData, sizeCursor, sizeCursor, UNCOMPRESSED_GRAY_ALPHA);
free(cursorData); free(cursorData);
//----------------------------------------------------------- //-----------------------------------------------------------
// Color picker // Color picker
//----------------------------------------------------------- //-----------------------------------------------------------
Vector2 colorPickerPos = { (float)screenWidth - 287, 20.0f }; Vector2 colorPickerPos = { (float)screenWidth - 287, 20.0f };
@ -164,6 +171,7 @@ int main()
for (int i = 0; i < NUM_COLOR_SAMPLES; i++) colorSample[i] = RAYWHITE; for (int i = 0; i < NUM_COLOR_SAMPLES; i++) colorSample[i] = RAYWHITE;
int sampleDelta = 18;
int rgbWidthLabel = 30; int rgbWidthLabel = 30;
int rgbHeightLabel = 20; int rgbHeightLabel = 20;
int rgbDelta = 6; int rgbDelta = 6;
@ -193,7 +201,7 @@ int main()
bool toggleActive = false; bool toggleActive = false;
int toggleNum = 3; int toggleNum = 3;
char *toggleGuiText[3] = { "toggle", "group", "selection"}; char *toggleGuiText[3] = { "toggle", "group", "selection" };
float sliderValue = 50; float sliderValue = 50;
float sliderBarValue = 50; float sliderBarValue = 50;
@ -203,7 +211,7 @@ int main()
int spinnerValue = 20; int spinnerValue = 20;
int comboNum = 5; int comboNum = 5;
char *comboText[5] = { "this", "is", "a" ,"combo", "box"}; char *comboText[5] = { "this", "is", "a" ,"combo", "box" };
int comboActive = 0; int comboActive = 0;
char *guiText = (char *)malloc(20); char *guiText = (char *)malloc(20);
@ -211,6 +219,7 @@ int main()
bool saveStyle = false; bool saveStyle = false;
bool loadStyle = false; bool loadStyle = false;
bool isModified = false;
const char *fileName; const char *fileName;
@ -231,7 +240,7 @@ int main()
Texture2D checkerTexture = LoadTextureEx(pixels, size, size, UNCOMPRESSED_R8G8B8A8); Texture2D checkerTexture = LoadTextureEx(pixels, size, size, UNCOMPRESSED_R8G8B8A8);
free(pixels); free(pixels);
//----------------------------------------------------------- //-----------------------------------------------------------
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -251,7 +260,7 @@ int main()
printf("Droped file detected: %s\n", droppedFiles[0]); printf("Droped file detected: %s\n", droppedFiles[0]);
} }
if(guiElementSelected == PROGRESSBAR) if (guiElementSelected == PROGRESSBAR)
{ {
if (progressValue > 1.0f) progressValue = 0; if (progressValue > 1.0f) progressValue = 0;
progressValue += 0.005f; progressValue += 0.005f;
@ -294,6 +303,8 @@ int main()
else if (guiPropertyType[guiPropertyHover] == 1) sizeValueSelected = GetStyleProperty(guiPropertyHover); else if (guiPropertyType[guiPropertyHover] == 1) sizeValueSelected = GetStyleProperty(guiPropertyHover);
} }
// TODO: REVIEW: Can make the application crash...
/*
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{ {
if (guiPropertySelected == i) guiPropertySelected = -1; if (guiPropertySelected == i) guiPropertySelected = -1;
@ -311,13 +322,21 @@ int main()
else sizeValueSelected = GetStyleProperty(guiPropertySelected); else sizeValueSelected = GetStyleProperty(guiPropertySelected);
} }
} }
*/
break; break;
} }
else guiPropertyHover = -1; else guiPropertyHover = -1;
} }
// Update style size value // Update style size value
if ((guiPropertySelected >= 0) && (guiPropertyType[guiPropertySelected] == 1)) SetStyleProperty(guiPropertySelected, sizeValueSelected); if ((guiPropertySelected >= 0) && (guiPropertyType[guiPropertySelected] == 1))
{
if (GetStyleProperty(guiPropertySelected) != sizeValueSelected)
{
isModified = true;
SetStyleProperty(guiPropertySelected, sizeValueSelected);
}
}
// Color picker logic // Color picker logic
if (CheckCollisionPointRec(GetMousePosition(), colorPickerBounds)) if (CheckCollisionPointRec(GetMousePosition(), colorPickerBounds))
@ -346,7 +365,14 @@ int main()
colorPickerValue.b = blueValue; colorPickerValue.b = blueValue;
colorPickerValue.a = alphaValue; colorPickerValue.a = alphaValue;
if ((guiPropertySelected >= 0) && (guiPropertyType[guiPropertySelected] == 0)) SetStyleProperty(guiPropertySelected, GetHexValue(colorPickerValue)); if ((guiPropertySelected >= 0) && (guiPropertyType[guiPropertySelected] == 0))
{
if (GetStyleProperty(guiPropertySelected) != GetHexValue(colorPickerValue))
{
SetStyleProperty(guiPropertySelected, GetHexValue(colorPickerValue));
isModified = true;
}
}
} }
// Color samples // Color samples
@ -377,32 +403,36 @@ int main()
alphaValue = colorPickerValue.a; alphaValue = colorPickerValue.a;
} }
} }
} }
// Update style color value // Update style color value --> PROGRAM CRASH!!!
/*
if (guiPropertySelected == BACKGROUND_COLOR) bgColor = colorPickerValue; if (guiPropertySelected == BACKGROUND_COLOR) bgColor = colorPickerValue;
else if ((guiPropertySelected != BACKGROUND_COLOR) && (guiPropertyType[guiPropertySelected] == 0)) else if ((guiPropertySelected != BACKGROUND_COLOR) && (guiPropertyType[guiPropertySelected] == 0))
{ {
bgColor = GetColor(GetStyleProperty(BACKGROUND_COLOR)); bgColor = GetColor(GetStyleProperty(BACKGROUND_COLOR));
SetStyleProperty(guiPropertySelected, GetHexValue(colorPickerValue)); SetStyleProperty(guiPropertySelected, GetHexValue(colorPickerValue));
} }
*/
if (saveStyle) if (saveStyle)
{ {
SaveGuiStyle(fileName); SaveGuiStyle(fileName);
saveStyle = false; saveStyle = false;
fileName = ""; fileName = "";
isModified = false;
} }
if (loadStyle) if (loadStyle)
{ {
LoadGuiStyle(fileName); LoadGuiStyle(fileName);
loadStyle = false; loadStyle = false;
fileName = ""; fileName = "";
isModified = false;
ClearDroppedFiles(); ClearDroppedFiles();
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -411,6 +441,16 @@ int main()
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
// Show selected properties
if (guiPropertySelected >= 0) DrawText(FormatText("SELECTED PROPERTY: <%s>", guiPropertyName[guiPropertySelected]), 5, screenHeight - STATUS_BAR_HEIGHT + 8, FONT_SIZE , BLACK);
else DrawText("SELECTED PROPERTY: <style property> / none", 5, screenHeight - STATUS_BAR_HEIGHT + 8, FONT_SIZE , BLACK);
// Show if have been a modification
if (!isModified) DrawText("SAVE STATUS: SAVED (filename.style)", screenWidth - 230 , screenHeight - STATUS_BAR_HEIGHT + 8, FONT_SIZE , BLACK);
else DrawText("SAVE STATUS: NOT SAVED", screenWidth - 230, screenHeight - STATUS_BAR_HEIGHT + 8, FONT_SIZE , BLACK);
DrawText(FormatText("ColorPicker hexadecimal value #%x", GetHexValue(colorPickerValue)), screenWidth/2 - 180 , screenHeight - STATUS_BAR_HEIGHT + 8, FONT_SIZE , BLACK);
// Background color // Background color
DrawRectangle(0,0, guiElementRec[0].width, GetScreenHeight() - STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.3f)); DrawRectangle(0,0, guiElementRec[0].width, GetScreenHeight() - STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.3f));
DrawRectangle(guiElementRec[0].width,0, propertyRec[0].width, GetScreenHeight() - STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.1f)); DrawRectangle(guiElementRec[0].width,0, propertyRec[0].width, GetScreenHeight() - STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.1f));
@ -543,6 +583,7 @@ int main()
loadStyle = true; loadStyle = true;
} }
} }
if (GuiButton((Rectangle){ colorPickerPos.x, screenHeight - 2*rgbWidthLabel - STATUS_BAR_HEIGHT, colorPickerTexture.width, rgbWidthLabel}, "Save Style")) if (GuiButton((Rectangle){ colorPickerPos.x, screenHeight - 2*rgbWidthLabel - STATUS_BAR_HEIGHT, colorPickerTexture.width, rgbWidthLabel}, "Save Style"))
{ {
fileName = tinyfd_saveFileDialog( "", "name.style", 0, NULL, NULL); fileName = tinyfd_saveFileDialog( "", "name.style", 0, NULL, NULL);