Added styler tool
This commit is contained in:
parent
b408add811
commit
fb3d69a1b7
1384
styler/color_picker_raw.raw
Normal file
1384
styler/color_picker_raw.raw
Normal file
File diff suppressed because one or more lines are too long
1
styler/colorpicker.h
Normal file
1
styler/colorpicker.h
Normal file
File diff suppressed because one or more lines are too long
4104
styler/external/tinyfiledialogs.c
vendored
Normal file
4104
styler/external/tinyfiledialogs.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
225
styler/external/tinyfiledialogs.h
vendored
Normal file
225
styler/external/tinyfiledialogs.h
vendored
Normal file
@ -0,0 +1,225 @@
|
||||
/*
|
||||
tinyfiledialogs.h
|
||||
unique header file of "tiny file dialogs" created [November 9, 2014]
|
||||
Copyright (c) 2014 - 2015 Guillaume Vareille http://ysengrin.com
|
||||
http://tinyfiledialogs.sourceforge.net
|
||||
|
||||
Let me know here mailto:tinfyfiledialogs@ysengrin.com
|
||||
- if you are including tiny file dialogs,
|
||||
I'll be happy to add your link to the list of projects using it.
|
||||
- If you are using it on not listed here hardware / OS / compiler.
|
||||
- and please, leave a review on Sourceforge. Thanks.
|
||||
|
||||
tiny file dialogs (cross-platform C C++)
|
||||
InputBox PasswordBox MessageBox ColorPicker
|
||||
OpenFileDialog SaveFileDialog SelectFolderDialog
|
||||
Native dialog library for WINDOWS MAC OSX GTK+ QT CONSOLE & more
|
||||
v2.2 [July 9, 2015] zlib licence.
|
||||
|
||||
A single C file (add it to your C or C++ project) with 6 modal function calls:
|
||||
- message box & question box
|
||||
- input box & password box
|
||||
- save file dialog
|
||||
- open file dialog & multiple files
|
||||
- select folder dialog
|
||||
- color picker.
|
||||
|
||||
Complement to OpenGL GLFW GLUT GLUI VTK SDL Ogre3D Unity3D
|
||||
or any GUI-less program, there is NO INIT & NO MAIN LOOP.
|
||||
The dialogs can be forced into console mode.
|
||||
|
||||
On Windows:
|
||||
- native code & some vbs create the graphic dialogs
|
||||
- enhanced console mode can use dialog.exe from
|
||||
http://andrear.altervista.org/home/cdialog.php
|
||||
- basic console input.
|
||||
|
||||
On Unix (command line call attempts):
|
||||
- applescript
|
||||
- zenity
|
||||
- kdialog
|
||||
- Xdialog
|
||||
- python2 tkinter
|
||||
- dialog (opens a console if needed)
|
||||
- whiptail, gdialog, gxmessage
|
||||
- basic console input.
|
||||
The same executable can run across desktops & distributions.
|
||||
|
||||
tested with C & C++ compilers
|
||||
on Windows Visual Studio MinGW Mac OSX LINUX FREEBSD ILLUMOS SOLARIS
|
||||
using Gnome Kde Enlightenment Mate Cinnamon Unity
|
||||
Lxde Lxqt Xfce WindowMaker IceWm Cde Jds
|
||||
|
||||
- License -
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef TINYFILEDIALOGS_H
|
||||
#define TINYFILEDIALOGS_H
|
||||
|
||||
/*
|
||||
if tinydialogs.c is compiled with a C++ compiler
|
||||
rather than with a C compiler, you need to comment out:
|
||||
extern "C" {
|
||||
and the corresponding closing bracket:
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
int tinyfd_messageBox (
|
||||
char const * const aTitle , /* "" */
|
||||
char const * const aMessage , /* "" may contain \n and \t */
|
||||
char const * const aDialogType , /* "ok" "okcancel" "yesno" */
|
||||
char const * const aIconType , /* "info" "warning" "error" "question" */
|
||||
int const aDefaultButton ) ; /* 0 for cancel/no , 1 for ok/yes */
|
||||
/* returns 0 for cancel/no , 1 for ok/yes */
|
||||
|
||||
char const * tinyfd_inputBox (
|
||||
char const * const aTitle , /* "" */
|
||||
char const * const aMessage , /* "" may NOT contain \n nor \t on windows */
|
||||
char const * const aDefaultInput ) ; /* "" , if NULL it's a passwordBox */
|
||||
/* returns NULL on cancel */
|
||||
|
||||
char const * tinyfd_saveFileDialog (
|
||||
char const * const aTitle , /* "" */
|
||||
char const * const aDefaultPathAndFile , /* "" */
|
||||
int const aNumOfFilterPatterns , /* 0 */
|
||||
char const * const * const aFilterPatterns , /* NULL or {"*.jpg","*.png"} */
|
||||
char const * const aSingleFilterDescription ) ; /* NULL or "image files" */
|
||||
/* returns NULL on cancel */
|
||||
|
||||
char const * tinyfd_openFileDialog (
|
||||
char const * const aTitle , /* "" */
|
||||
char const * const aDefaultPathAndFile , /* "" */
|
||||
int const aNumOfFilterPatterns , /* 0 */
|
||||
char const * const * const aFilterPatterns , /* NULL or {"*.jpg","*.png"} */
|
||||
char const * const aSingleFilterDescription , /* NULL or "image files" */
|
||||
int const aAllowMultipleSelects ) ; /* 0 or 1 */
|
||||
/* in case of multiple files, the separator is | */
|
||||
/* returns NULL on cancel */
|
||||
|
||||
char const * tinyfd_selectFolderDialog (
|
||||
char const * const aTitle , /* "" */
|
||||
char const * const aDefaultPath ) ; /* "" */
|
||||
/* returns NULL on cancel */
|
||||
|
||||
char const * tinyfd_colorChooser(
|
||||
char const * const aTitle , /* "" */
|
||||
char const * const aDefaultHexRGB , /* NULL or "#FF0000" */
|
||||
unsigned char const aDefaultRGB[3] , /* { 0 , 255 , 255 } */
|
||||
unsigned char aoResultRGB[3] ) ; /* { 0 , 0 , 0 } */
|
||||
/* returns the hexcolor as a string "#FF0000" */
|
||||
/* aoResultRGB also contains the result */
|
||||
/* aDefaultRGB is used only if aDefaultHexRGB is NULL */
|
||||
/* aDefaultRGB and aoResultRGB can be the same array */
|
||||
/* returns NULL on cancel */
|
||||
|
||||
extern int tinyfd_forceConsole ; /* 0 (default) or 1
|
||||
can be modified at run time.
|
||||
for unix & windows: 0 (graphic mode) or 1 (console mode).
|
||||
0: try to use a graphic solution, if it fails then it uses console mode.
|
||||
1: forces all dialogs into console mode even when the X server is present,
|
||||
if the package dialog (and a console is present) or dialog.exe is installed.
|
||||
on windows it only make sense for console applications */
|
||||
|
||||
/* #define TINYFD_WIN_CONSOLE_ONLY //*/
|
||||
/* On windows, Define this if you don't want to include the code
|
||||
creating the GUI dialogs. Then you don't need link against Comdlg32.lib */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* TINYFILEDIALOGS_H */
|
||||
|
||||
|
||||
/*
|
||||
- This is not for android nor ios.
|
||||
- The code is pure C, perfectly compatible with C++.
|
||||
- There's one file filter only, it may contain several patterns.
|
||||
- If no filter description is provided,
|
||||
the list of patterns will become the description.
|
||||
- char const * filterPatterns[3] = { "*.obj" , "*.stl" , "*.dxf" } ;
|
||||
- On windows, inputbox and passwordbox are not as smooth as they should be:
|
||||
they open a console window for a few seconds.
|
||||
- On windows link against Comdlg32.lib
|
||||
This linking is not compulsary for console mode (see above).
|
||||
- On unix: it tries command line calls, so no such need.
|
||||
- On unix you need applescript, zenity, kdialog, Xdialog, python2/tkinter
|
||||
or dialog (will open a terminal if running without console);
|
||||
- One of those is already included on most (if not all) desktops.
|
||||
- In the absence of those it will use gdialog, gxmessage or whiptail
|
||||
with a textinputbox.
|
||||
- If nothing is found, it switches to basic console input,
|
||||
it opens a console if needed.
|
||||
- Avoid using " and ' in titles and messages.
|
||||
- Use windows separators on windows and unix separators on unix.
|
||||
- String memory is preallocated statically for all the returned values.
|
||||
- File and path names are tested before return, they are valid.
|
||||
- If you pass only a path instead of path + filename,
|
||||
make sure it ends with a separator.
|
||||
- tinyfd_forceConsole=1; at run time, forces dialogs into console mode.
|
||||
- On windows, console mode only make sense for console applications.
|
||||
- Mutiple selects are not allowed in console mode.
|
||||
- The package dialog must be installed to run in enhanced console mode.
|
||||
It is already installed on most unix systems.
|
||||
- On osx, the package dialog can be installed via http://macports.org
|
||||
- On windows, for enhanced console mode,
|
||||
dialog.exe should be copied somewhere on your executable path.
|
||||
It can be found at the bottom of the following page:
|
||||
http://andrear.altervista.org/home/cdialog.php
|
||||
- If dialog is missing, it will switch to basic console input.
|
||||
|
||||
- Here is the Hello World (and a bit more):
|
||||
if a console is missing, it will use graphic dialogs
|
||||
if a graphical display is absent, it will use console dialogs
|
||||
|
||||
#include <stddef.h>
|
||||
#include "tinyfiledialogs.h"
|
||||
int main()
|
||||
{
|
||||
tinyfd_forceConsole = tinyfd_messageBox("Hello World",
|
||||
"force dialogs into console mode?\
|
||||
\n\t(it's better if dialog is installed)",
|
||||
"yesno", "question", 0);
|
||||
|
||||
char const * lThePassword = tinyfd_inputBox(
|
||||
"a password box","your password will be revealed",NULL);
|
||||
|
||||
if ( lThePassword )
|
||||
tinyfd_messageBox("your password is", lThePassword, "ok", "info", 1);
|
||||
}
|
||||
|
||||
OSX :
|
||||
$ gcc -o main.app main.c tinyfiledialogs.c
|
||||
|
||||
UNIX :
|
||||
$ gcc -o main main.c tinyfiledialogs.c
|
||||
|
||||
MinGW :
|
||||
> gcc -o main.exe main.c tinyfiledialogs.c -LC:/mingw/lib -lcomdlg32
|
||||
|
||||
VisualStudio :
|
||||
create a console application project
|
||||
(by default it links against Comdlg32.lib)
|
||||
*/
|
126
styler/external/tinyfiledialogs_readme.txt
vendored
Normal file
126
styler/external/tinyfiledialogs_readme.txt
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
tiny file dialogs (cross-platform C C++)
|
||||
InputBox PasswordBox MessageBox ColorPicker
|
||||
OpenFileDialog SaveFileDialog SelectFolderDialog
|
||||
Native dialog library for WINDOWS MAC OSX GTK+ QT CONSOLE & more
|
||||
tested with C & C++ compilers
|
||||
on Visual Studio 2013 MinGW OSX LINUX FREEBSD ILLUMOS SOLARIS
|
||||
using Gnome Kde Enlightenment Mate Cinnamon Unity
|
||||
Lxde Lxqt Xfce WindowMaker IceWm Cde Jds
|
||||
v2.2 [July 9, 2015] zlib licence.
|
||||
|
||||
int tinyfd_messageBox (
|
||||
char const * const aTitle , // ""
|
||||
char const * const aMessage , // "" may contain \n and \t
|
||||
char const * const aDialogType , // "ok" "okcancel" "yesno"
|
||||
char const * const aIconType , // "info" "warning" "error" "question"
|
||||
int const aDefaultButton ) ; // 0 for cancel/no , 1 for ok/yes
|
||||
// returns 0 for cancel/no , 1 for ok/yes
|
||||
|
||||
char const * tinyfd_inputBox (
|
||||
char const * const aTitle , // ""
|
||||
char const * const aMessage , // "" may NOT contain \n nor \t on windows
|
||||
char const * const aDefaultInput ) ; // "" , if NULL it's a passwordBox
|
||||
// returns NULL on cancel
|
||||
|
||||
char const * tinyfd_saveFileDialog (
|
||||
char const * const aTitle , // ""
|
||||
char const * const aDefaultPathAndFile , // ""
|
||||
int const aNumOfFilterPatterns , // 0
|
||||
char const * const * const aFilterPatterns , // NULL or {"*.txt"}
|
||||
char const * const aSingleFilterDescription ) ; // NULL or "image files"
|
||||
// returns NULL on cancel
|
||||
|
||||
char const * tinyfd_openFileDialog (
|
||||
char const * const aTitle , // ""
|
||||
char const * const aDefaultPathAndFile , // ""
|
||||
int const aNumOfFilterPatterns , // 0
|
||||
char const * const * const aFilterPatterns , // NULL or {"*.jpg","*.png"}
|
||||
char const * const aSingleFilterDescription , // NULL or "image files"
|
||||
int const aAllowMultipleSelects ) ; // 0
|
||||
// in case of multiple files, the separator is |
|
||||
// returns NULL on cancel
|
||||
|
||||
char const * tinyfd_selectFolderDialog (
|
||||
char const * const aTitle , // ""
|
||||
char const * const aDefaultPath ) ; // ""
|
||||
// returns NULL on cancel
|
||||
|
||||
char const * tinyfd_colorChooser(
|
||||
char const * const aTitle , // ""
|
||||
char const * const aDefaultHexRGB , // NULL or "#FF0000”
|
||||
unsigned char const aDefaultRGB[3] , // { 0 , 255 , 255 }
|
||||
unsigned char aoResultRGB[3] ) ; // { 0 , 0 , 0 }
|
||||
// returns the hexcolor as a string "#FF0000"
|
||||
// aoResultRGB also contains the result
|
||||
// aDefaultRGB is used only if aDefaultHexRGB is NULL
|
||||
// aDefaultRGB and aoResultRGB can be the same array
|
||||
// returns NULL on cancel
|
||||
|
||||
- This is not for android nor ios.
|
||||
- The code is pure C, perfectly compatible with C++.
|
||||
- There's one file filter only, it may contain several patterns.
|
||||
- If no filter description is provided,
|
||||
the list of patterns will become the description.
|
||||
- char const * filterPatterns[3] = { "*.obj" , "*.stl" , "*.dxf" } ;
|
||||
- On windows, inputbox and passwordbox are not as smooth as they should be:
|
||||
they open a console window for a few seconds.
|
||||
- On windows link against Comdlg32.lib
|
||||
This linking is not compulsary for console mode (see header file).
|
||||
- On unix: it tries command line calls, so no such need.
|
||||
- On unix you need applescript, zenity, kdialog, Xdialog, python2/tkinter
|
||||
or dialog (will open a terminal if running without console);
|
||||
- One of those is already included on most (if not all) desktops.
|
||||
- In the absence of those it will use gdialog, gxmessage or whiptail
|
||||
with a textinputbox.
|
||||
- If nothing is found, it switches to basic console input,
|
||||
it opens a console if needed.
|
||||
- Avoid using " and ' in titles and messages.
|
||||
- Use windows separators on windows and unix separators on unix.
|
||||
- String memory is preallocated statically for all the returned values.
|
||||
- File and path names are tested before return, they are valid.
|
||||
- If you pass only a path instead of path + filename,
|
||||
make sure it ends with a separator.
|
||||
- tinyfd_forceConsole=1; at run time, forces dialogs into console mode.
|
||||
- On windows, console mode only make sense for console applications.
|
||||
- Mutiple selects are not allowed in console mode.
|
||||
- The package dialog must be installed to run in enhanced console mode.
|
||||
It is already installed on most unix systems.
|
||||
- On osx, the package dialog can be installed via http://macports.org
|
||||
- On windows, for enhanced console mode,
|
||||
dialog.exe should be copied somewhere on your executable path.
|
||||
It can be found at the bottom of the following page:
|
||||
http://andrear.altervista.org/home/cdialog.php
|
||||
- If dialog is missing, it will switch to basic console input.
|
||||
|
||||
- Here is the Hello World:
|
||||
if a console is missing, it will use graphic dialogs
|
||||
if a graphical display is absent, it will use console dialogs
|
||||
|
||||
#include <stddef.h>
|
||||
#include "tinyfiledialogs.h"
|
||||
int main()
|
||||
{
|
||||
tinyfd_forceConsole = tinyfd_messageBox("Hello World",
|
||||
"force dialogs into console mode?\
|
||||
\n\t(it's better if dialog is installed)",
|
||||
"yesno", "question", 0);
|
||||
|
||||
char const * lThePassword = tinyfd_inputBox(
|
||||
"a password box","your password will be revealed",NULL);
|
||||
|
||||
if ( lThePassword )
|
||||
tinyfd_messageBox("your password is", lThePassword, "ok", "info", 1);
|
||||
}
|
||||
|
||||
OSX :
|
||||
$ gcc -o main.app main.c tinyfiledialogs.c
|
||||
|
||||
UNIX :
|
||||
$ gcc -o main main.c tinyfiledialogs.c
|
||||
|
||||
MinGW :
|
||||
> gcc -o main.exe main.c tinyfiledialogs.c -LC:/mingw/lib -lcomdlg32
|
||||
|
||||
VisualStudio :
|
||||
create a console application project
|
||||
(by default it links against Comdlg32.lib)
|
591
styler/raygui_styler.c
Normal file
591
styler/raygui_styler.c
Normal file
@ -0,0 +1,591 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raygui styler - raygui Style Editor
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2015 Sergio Martinez and Ramon Santamaria
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "../raygui.h"
|
||||
|
||||
#include "external/tinyfiledialogs.h"
|
||||
#include "colorpicker.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define FONT_SIZE 10
|
||||
#define COLOR_REC BEIGE
|
||||
#define NUM_COLOR_SAMPLES 10
|
||||
#define ELEMENT_HEIGHT 38
|
||||
#define STATUS_BAR_HEIGHT 25
|
||||
|
||||
#define NUM_ELEMENTS 13
|
||||
|
||||
// NOTE: Be extremely careful when defining: NUM_ELEMENTS, GuiElement, guiElementText, guiPropertyNum, guiPropertyType and guiPropertyPos
|
||||
// All those variables must be coherent, one small mistake breaks the program (and it could take ours to find the error!)
|
||||
|
||||
typedef enum { GLOBAL, BACKGROUND, LABEL, BUTTON, TOGGLE, TOGGLEGROUP, SLIDER, SLIDERBAR, PROGRESSBAR, SPINNER, COMBOBOX, CHECKBOX, TEXTBOX } GuiElement;
|
||||
|
||||
const char *guiElementText[NUM_ELEMENTS] = { "GLOBAL", "BACKGROUND", "LABEL", "BUTTON", "TOGGLE", "TOGGLEGROUP", "SLIDER", "SLIDERBAR", "PROGRESSBAR", "SPINNER", "COMBOBOX", "CHECKBOX", "TEXTBOX" };
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 1280;
|
||||
const int screenHeight = 720;
|
||||
|
||||
const int guiPropertyNum[NUM_ELEMENTS] = { 5, 1, 3, 11, 14, 1, 7, 6, 4, 14, 18, 8, 6 };
|
||||
|
||||
// Defines if the property to change is a Color or a value to update it accordingly
|
||||
// NOTE: 0 - Color, 1 - value
|
||||
const unsigned char guiPropertyType[NUM_PROPERTIES] = { 0, 0, 0, 1, 1, 0, 1, 0, 1, 1,
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 1, 0, 0, 0, 0, 1 };
|
||||
int aux = 0;
|
||||
int guiPropertyPos[NUM_ELEMENTS];
|
||||
|
||||
for (int i = 0; i < NUM_ELEMENTS; i++)
|
||||
{
|
||||
guiPropertyPos[i] = aux;
|
||||
aux += guiPropertyNum[i];
|
||||
}
|
||||
|
||||
//SetConfigFlags(FLAG_FULLSCREEN_MODE);
|
||||
InitWindow(screenWidth, screenHeight, "raygui styler");
|
||||
|
||||
int count = 0;
|
||||
char **droppedFiles;
|
||||
|
||||
Rectangle guiElementRec[NUM_ELEMENTS];
|
||||
|
||||
for (int i = 0; i < NUM_ELEMENTS; i++) guiElementRec[i] = (Rectangle){ 0, 0 + i*ELEMENT_HEIGHT, 140, ELEMENT_HEIGHT };
|
||||
|
||||
|
||||
int guiElementSelected = -1;
|
||||
int guiElementHover = -1;
|
||||
|
||||
// Generate properties rectangles depending on guiPropertyNum[] and guiPropertyPos[]
|
||||
//------------------------------------------------------------
|
||||
Rectangle propertyRec[NUM_PROPERTIES];
|
||||
|
||||
for (int j = 0; j < NUM_ELEMENTS; j++)
|
||||
{
|
||||
for (int i = 0; i < guiPropertyNum[j]; i++)
|
||||
{
|
||||
if ((j + guiPropertyNum[j]) > 18) propertyRec[guiPropertyPos[j] + i] = (Rectangle){ guiElementRec[0].width, guiElementRec[18 - guiPropertyNum[j]].y + i*ELEMENT_HEIGHT, 260, ELEMENT_HEIGHT };
|
||||
else propertyRec[guiPropertyPos[j] + i] = (Rectangle){ guiElementRec[0].width, guiElementRec[j].y + i*ELEMENT_HEIGHT, 260, ELEMENT_HEIGHT };
|
||||
}
|
||||
}
|
||||
|
||||
int guiPropertySelected = -1;
|
||||
int guiPropertyHover = -1;
|
||||
//------------------------------------------------------------
|
||||
|
||||
// GUI
|
||||
//-----------------------------------------------------------
|
||||
int guiPosX = 455;
|
||||
int guiPosY = 35;
|
||||
|
||||
int guiHeight = 30;
|
||||
int guiWidth = 150;
|
||||
|
||||
int deltaX = 153;
|
||||
int deltaY = 60;
|
||||
|
||||
int selectPosX = 401;
|
||||
//int selectPosY = 0;
|
||||
int selectWidth = screenWidth - 723;
|
||||
//int selectHeight = screenHeight;
|
||||
//------------------------------------------------------------
|
||||
|
||||
// Cursor texture generation
|
||||
//-----------------------------------------------------------
|
||||
int sizeCursor = 16; // size must be POT
|
||||
unsigned char *cursorData = (unsigned char *)malloc(sizeCursor*sizeCursor*2*sizeof(unsigned char));
|
||||
|
||||
for(int w = 0; w < sizeCursor; w++)
|
||||
{
|
||||
for (int h = 0; h < sizeCursor; h++)
|
||||
{
|
||||
cursorData[w*sizeCursor*2 + 2*h] = 0;
|
||||
if((sizeCursor%2) == 0)
|
||||
{
|
||||
if(((w == (sizeCursor/2 - 1)) || (w == sizeCursor/2)) && ((h == (sizeCursor/2 - 1)) || (h == sizeCursor/2)))
|
||||
{
|
||||
cursorData[w*sizeCursor*2 + 2*h + 1] = 0;
|
||||
}
|
||||
else if((w == (sizeCursor/2 - 1)) || (w == sizeCursor/2)) cursorData[w*sizeCursor*2 + 2*h + 1] = 255;
|
||||
else if((h == (sizeCursor/2 - 1)) || (h == sizeCursor/2)) cursorData[w*sizeCursor*2 + 2*h + 1] = 255;
|
||||
else cursorData[w*sizeCursor*2 + 2*h + 1] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Texture2D cursorTexture = LoadTextureEx(cursorData, sizeCursor, sizeCursor, UNCOMPRESSED_GRAY_ALPHA);
|
||||
free(cursorData);
|
||||
//-----------------------------------------------------------
|
||||
// Color picker
|
||||
//-----------------------------------------------------------
|
||||
Vector2 colorPickerPos = { (float)screenWidth - 287, 20.0f };
|
||||
|
||||
Image colorPickerImage;
|
||||
colorPickerImage.data = pickerData;
|
||||
colorPickerImage.width = 256;
|
||||
colorPickerImage.height = 256;
|
||||
colorPickerImage.mipmaps = 1;
|
||||
colorPickerImage.format = UNCOMPRESSED_R8G8B8;
|
||||
|
||||
Texture2D colorPickerTexture = LoadTextureFromImage(colorPickerImage);
|
||||
|
||||
Vector2 cursorPickerPos = {colorPickerPos.x +(colorPickerTexture.width/2) - cursorTexture.width/2, colorPickerPos.y + (colorPickerTexture.height/2) - cursorTexture.height/2};
|
||||
|
||||
Color *colorPickerPixel = GetImageData(colorPickerImage);
|
||||
|
||||
Rectangle colorPickerBounds = (Rectangle){ (int)colorPickerPos.x, (int)colorPickerPos.y, colorPickerTexture.width, colorPickerTexture.height };
|
||||
|
||||
Vector2 colorPosition;
|
||||
Color colorPickerValue;
|
||||
Color colorSample[NUM_COLOR_SAMPLES];
|
||||
|
||||
for (int i = 0; i < NUM_COLOR_SAMPLES; i++) colorSample[i] = RAYWHITE;
|
||||
|
||||
int rgbWidthLabel = 30;
|
||||
int rgbHeightLabel = 20;
|
||||
int rgbDelta = 6;
|
||||
int redValue = 0;
|
||||
int greenValue = 0;
|
||||
int blueValue = 0;
|
||||
int alphaValue = 255;
|
||||
|
||||
// -- Color samples
|
||||
Rectangle colorSelectedBoundsRec = {colorPickerPos.x, colorPickerPos.y + colorPickerTexture.height + 2*rgbDelta, 2*rgbWidthLabel, 2*rgbWidthLabel};
|
||||
bool colorSelectedHover = false;
|
||||
|
||||
Rectangle sampleBoundsRec[NUM_COLOR_SAMPLES];
|
||||
int sampleHover = -1;
|
||||
int sampleSelected = 0;
|
||||
|
||||
for (int i = 0; i < NUM_COLOR_SAMPLES/2; i++) sampleBoundsRec[i] = (Rectangle) {colorPickerPos.x + 2*rgbWidthLabel + i*rgbWidthLabel + 3*rgbDelta + i*rgbDelta, colorPickerPos.y + colorPickerTexture.height + 2*rgbDelta, rgbWidthLabel, rgbWidthLabel - 2};
|
||||
for (int i = NUM_COLOR_SAMPLES/2; i < NUM_COLOR_SAMPLES; i++) sampleBoundsRec[i] = (Rectangle) {colorPickerPos.x + 2*rgbWidthLabel + (i-5)*rgbWidthLabel + 3*rgbDelta + (i-5)*rgbDelta, colorPickerPos.y + colorPickerTexture.height + 2*rgbDelta + rgbWidthLabel + 2, rgbWidthLabel, rgbWidthLabel - 2};
|
||||
//------------------------------------------------------------
|
||||
|
||||
// Value size selection
|
||||
//-----------------------------------------------------------
|
||||
int sizeValueSelected = 10;
|
||||
//-----------------------------------------------------------
|
||||
|
||||
Color bgColor = RAYWHITE;
|
||||
|
||||
bool toggleActive = false;
|
||||
int toggleNum = 3;
|
||||
char *toggleGuiText[3] = { "toggle", "group", "selection"};
|
||||
|
||||
float sliderValue = 50;
|
||||
float sliderBarValue = 50;
|
||||
|
||||
float progressValue = 0;
|
||||
|
||||
int spinnerValue = 20;
|
||||
|
||||
int comboNum = 5;
|
||||
char *comboText[5] = { "this", "is", "a" ,"combo", "box"};
|
||||
int comboActive = 0;
|
||||
|
||||
char *guiText = (char *)malloc(20);
|
||||
for (int i = 0; i < 20; i++) guiText[i] = '\0';
|
||||
|
||||
bool saveStyle = false;
|
||||
bool loadStyle = false;
|
||||
|
||||
const char *fileName;
|
||||
|
||||
// Checked texture generation
|
||||
//-----------------------------------------------------------
|
||||
int size = 8;
|
||||
Color *pixels = (Color *)malloc(size*size*sizeof(Color));
|
||||
|
||||
for (int y = 0; y < size; y++)
|
||||
{
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
if (((x/(size/2) + y/(size/2)))%2 == 0) pixels[y*size + x] = RAYWHITE;
|
||||
else pixels[y*size + x] = Fade(LIGHTGRAY, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D checkerTexture = LoadTextureEx(pixels, size, size, UNCOMPRESSED_R8G8B8A8);
|
||||
|
||||
free(pixels);
|
||||
//-----------------------------------------------------------
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsFileDropped())
|
||||
{
|
||||
guiPropertySelected = -1;
|
||||
droppedFiles = GetDroppedFiles(&count);
|
||||
fileName = droppedFiles[0];
|
||||
loadStyle = true;
|
||||
|
||||
printf("Droped file detected: %s\n", droppedFiles[0]);
|
||||
}
|
||||
|
||||
if(guiElementSelected == PROGRESSBAR)
|
||||
{
|
||||
if (progressValue > 1.0f) progressValue = 0;
|
||||
progressValue += 0.005f;
|
||||
}
|
||||
|
||||
for (int i = 0; i < NUM_ELEMENTS; i++)
|
||||
{
|
||||
if (CheckCollisionPointRec(GetMousePosition(), guiElementRec[i]))
|
||||
{
|
||||
guiElementSelected = i;
|
||||
guiElementHover = i;
|
||||
|
||||
guiPropertySelected = -1;
|
||||
guiPropertyHover = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CheckCollisionPointRec(GetMousePosition(), guiElementRec[guiElementHover])) guiElementHover = -1;
|
||||
|
||||
// Check for selected property
|
||||
for (int i = guiPropertyPos[guiElementSelected]; i < guiPropertyPos[guiElementSelected] + guiPropertyNum[guiElementSelected]; i++)
|
||||
{
|
||||
if (CheckCollisionPointRec(GetMousePosition(), propertyRec[i]))
|
||||
{
|
||||
guiPropertyHover = i;
|
||||
|
||||
// Show current value in color picker or spinner
|
||||
if (guiPropertySelected == -1)
|
||||
{
|
||||
if (guiPropertyType[guiPropertyHover] == 0) // Color type
|
||||
{
|
||||
// Update color picker color value
|
||||
colorPickerValue = GetColor(GetStyleProperty(guiPropertyHover));
|
||||
redValue = colorPickerValue.r;
|
||||
greenValue = colorPickerValue.g;
|
||||
blueValue = colorPickerValue.b;
|
||||
cursorPickerPos = (Vector2){screenWidth, screenHeight};
|
||||
}
|
||||
// Value Type
|
||||
else if (guiPropertyType[guiPropertyHover] == 1) sizeValueSelected = GetStyleProperty(guiPropertyHover);
|
||||
}
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
if (guiPropertySelected == i) guiPropertySelected = -1;
|
||||
else
|
||||
{
|
||||
guiPropertySelected = i;
|
||||
|
||||
if (guiPropertyType[guiPropertyHover] == 0)
|
||||
{
|
||||
colorPickerValue = GetColor(GetStyleProperty(guiPropertySelected));
|
||||
redValue = colorPickerValue.r;
|
||||
greenValue = colorPickerValue.g;
|
||||
blueValue = colorPickerValue.b;
|
||||
}
|
||||
else sizeValueSelected = GetStyleProperty(guiPropertySelected);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else guiPropertyHover = -1;
|
||||
}
|
||||
|
||||
// Update style size value
|
||||
if ((guiPropertySelected >= 0) && (guiPropertyType[guiPropertySelected] == 1)) SetStyleProperty(guiPropertySelected, sizeValueSelected);
|
||||
|
||||
// Color picker logic
|
||||
if (CheckCollisionPointRec(GetMousePosition(), colorPickerBounds))
|
||||
{
|
||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
if (!IsCursorHidden()) HideCursor();
|
||||
|
||||
cursorPickerPos = (Vector2){ GetMousePosition().x - cursorTexture.width/2, GetMousePosition().y - cursorTexture.height/2};
|
||||
colorPosition = (Vector2){ GetMousePosition().x - colorPickerPos.x, GetMousePosition().y - colorPickerPos.y};
|
||||
|
||||
colorPickerValue = colorPickerPixel[(int)colorPosition.x + (int)colorPosition.y*colorPickerTexture.width];
|
||||
redValue = colorPickerValue.r;
|
||||
greenValue = colorPickerValue.g;
|
||||
blueValue = colorPickerValue.b;
|
||||
alphaValue = colorPickerValue.a;
|
||||
}
|
||||
if (IsMouseButtonUp(MOUSE_LEFT_BUTTON)) if(IsCursorHidden()) ShowCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsCursorHidden()) ShowCursor();
|
||||
|
||||
colorPickerValue.r = redValue;
|
||||
colorPickerValue.g = greenValue;
|
||||
colorPickerValue.b = blueValue;
|
||||
colorPickerValue.a = alphaValue;
|
||||
|
||||
if ((guiPropertySelected >= 0) && (guiPropertyType[guiPropertySelected] == 0)) SetStyleProperty(guiPropertySelected, GetHexValue(colorPickerValue));
|
||||
}
|
||||
|
||||
// Color samples
|
||||
if (CheckCollisionPointRec(GetMousePosition(), colorSelectedBoundsRec))
|
||||
{
|
||||
colorSelectedHover = true;
|
||||
|
||||
if(IsMouseButtonDown (MOUSE_RIGHT_BUTTON)) colorSample[sampleSelected] = colorPickerValue;
|
||||
}
|
||||
else colorSelectedHover = false;
|
||||
|
||||
for (int i = 0; i < NUM_COLOR_SAMPLES; i++)
|
||||
{
|
||||
if (CheckCollisionPointRec(GetMousePosition(), sampleBoundsRec[i]))
|
||||
{
|
||||
sampleHover = i;
|
||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
sampleSelected = i;
|
||||
}
|
||||
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON))
|
||||
{
|
||||
sampleSelected = i;
|
||||
colorPickerValue = colorSample[sampleSelected];
|
||||
redValue = colorPickerValue.r;
|
||||
greenValue = colorPickerValue.g;
|
||||
blueValue = colorPickerValue.b;
|
||||
alphaValue = colorPickerValue.a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update style color value
|
||||
if (guiPropertySelected == BACKGROUND_COLOR) bgColor = colorPickerValue;
|
||||
else if ((guiPropertySelected != BACKGROUND_COLOR) && (guiPropertyType[guiPropertySelected] == 0))
|
||||
{
|
||||
bgColor = GetColor(GetStyleProperty(BACKGROUND_COLOR));
|
||||
SetStyleProperty(guiPropertySelected, GetHexValue(colorPickerValue));
|
||||
}
|
||||
|
||||
if (saveStyle)
|
||||
{
|
||||
SaveGuiStyle(fileName);
|
||||
saveStyle = false;
|
||||
fileName = "";
|
||||
}
|
||||
|
||||
if (loadStyle)
|
||||
{
|
||||
LoadGuiStyle(fileName);
|
||||
loadStyle = false;
|
||||
fileName = "";
|
||||
|
||||
ClearDroppedFiles();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Background color
|
||||
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));
|
||||
|
||||
// UI sample
|
||||
// Background
|
||||
DrawRectangle(400,0, screenWidth - 320 - 400, GetScreenHeight() - STATUS_BAR_HEIGHT, bgColor);
|
||||
|
||||
GuiLabel((Rectangle){guiPosX, guiPosY, guiWidth, guiHeight}, "Label");
|
||||
GuiLabelEx((Rectangle){guiPosX + deltaX, guiPosY, guiWidth, guiHeight}, "LabelEx", BLACK, BLACK, WHITE);
|
||||
|
||||
if (GuiButton((Rectangle){guiPosX, guiPosY + deltaY, guiWidth, guiHeight}, "Button")) { }
|
||||
|
||||
GuiToggleButton((Rectangle){guiPosX, guiPosY + 2*deltaY, guiWidth, guiHeight}, "Toggle inactive", false);
|
||||
GuiToggleButton((Rectangle){guiPosX + deltaX, guiPosY + 2*deltaY, guiWidth, guiHeight}, "Toggle active", true);
|
||||
|
||||
toggleActive = GuiToggleGroup((Rectangle){guiPosX, guiPosY + 3*deltaY, guiWidth, guiHeight}, toggleNum, toggleGuiText, toggleActive);
|
||||
|
||||
sliderValue = GuiSlider((Rectangle){guiPosX, guiPosY + 4*deltaY, 3*guiWidth, guiHeight}, sliderValue, 0, 100);
|
||||
|
||||
sliderBarValue = GuiSliderBar((Rectangle){guiPosX, guiPosY + 5*deltaY, 3*guiWidth, guiHeight}, sliderBarValue, -50, 50);
|
||||
|
||||
GuiProgressBar((Rectangle){guiPosX, guiPosY + 6*deltaY, 3*guiWidth, guiHeight}, progressValue);
|
||||
|
||||
spinnerValue = GuiSpinner((Rectangle){guiPosX, guiPosY + 7*deltaY, guiWidth, guiHeight}, spinnerValue, 0, 100);
|
||||
|
||||
comboActive = GuiComboBox((Rectangle){guiPosX, guiPosY + 8*deltaY, guiWidth, guiHeight}, comboNum, comboText, comboActive);
|
||||
|
||||
GuiCheckBox((Rectangle){guiPosX, guiPosY + 9*deltaY, guiWidth/5, guiHeight}, "", false);
|
||||
GuiCheckBox((Rectangle){guiPosX + deltaX/4, guiPosY + 9*deltaY, guiWidth/5, guiHeight}, "", true);
|
||||
|
||||
guiText = GuiTextBox((Rectangle){guiPosX, guiPosY + 10*deltaY, guiWidth, guiHeight}, guiText);
|
||||
|
||||
if (guiElementSelected >= 0) DrawRectangleRec(guiElementRec[guiElementSelected], COLOR_REC);
|
||||
if (guiElementHover >= 0) DrawRectangleRec(guiElementRec[guiElementHover], Fade(COLOR_REC, 0.5f));
|
||||
if (guiElementSelected >= 0) DrawRectangleLines(guiElementRec[guiElementSelected].x, guiElementRec[guiElementSelected].y, guiElementRec[guiElementSelected].width, guiElementRec[guiElementSelected].height, Fade(COLOR_REC,0.5f));
|
||||
|
||||
// Draw corresponding selected properties depending on guiElementSelected
|
||||
//----------------------------------------------------------------------------------------------
|
||||
if (guiElementSelected >= 0)
|
||||
{
|
||||
if (guiPropertyHover >= 0) DrawRectangleRec(propertyRec[guiPropertyHover], Fade(COLOR_REC,0.3f));
|
||||
|
||||
if (guiPropertySelected >= 0) DrawRectangleRec(propertyRec[guiPropertySelected], Fade(COLOR_REC, 0.4f));
|
||||
if (guiPropertySelected >= 0) DrawRectangleLines(propertyRec[guiPropertySelected].x, propertyRec[guiPropertySelected].y, propertyRec[guiPropertySelected].width, propertyRec[guiPropertySelected].height, Fade(COLOR_REC, 0.8f));
|
||||
|
||||
for (int i = guiPropertyPos[guiElementSelected]; i < guiPropertyPos[guiElementSelected] + guiPropertyNum[guiElementSelected]; i++)
|
||||
{
|
||||
DrawText(guiPropertyName[i], propertyRec[i].x + propertyRec[i].width/2 - MeasureText(guiPropertyName[i], FONT_SIZE)/2, propertyRec[i].y + 15, FONT_SIZE, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
|
||||
// Draw Element selected rectangles
|
||||
switch (guiElementSelected)
|
||||
{
|
||||
case GLOBAL: DrawRectangleLines(selectPosX + 2, 2, selectWidth - 4, GetScreenHeight() - 4 - STATUS_BAR_HEIGHT, COLOR_REC); break;
|
||||
case BACKGROUND: DrawRectangleLines(selectPosX + 10, 10, selectWidth - 20, GetScreenHeight() - 20 - STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.8f)); break;
|
||||
case LABEL: DrawRectangleLines(selectPosX + 10, guiPosY - 10, selectWidth - 20, guiHeight + 20, Fade(COLOR_REC, 0.8f)); break;
|
||||
case BUTTON: DrawRectangleLines(selectPosX + 10, guiPosY + deltaY - 10, selectWidth - 20, guiHeight + 20, Fade(COLOR_REC, 0.8f)); break;
|
||||
case TOGGLE:
|
||||
case TOGGLEGROUP: DrawRectangleLines(selectPosX + 10, guiPosY + (2 * deltaY) - 10, selectWidth - 20, guiHeight + 80, Fade(COLOR_REC, 0.8f)); break;
|
||||
case SLIDER: DrawRectangleLines(selectPosX + 10, guiPosY + (4 * deltaY) - 10, selectWidth - 20, guiHeight + 80, Fade(COLOR_REC, 0.8f)); break;
|
||||
case PROGRESSBAR: DrawRectangleLines(selectPosX + 10, guiPosY + (6 * deltaY) - 10, selectWidth - 20, guiHeight + 20, Fade(COLOR_REC, 0.8f)); break;
|
||||
case SPINNER: DrawRectangleLines(selectPosX + 10, guiPosY + (7 * deltaY) - 10, selectWidth - 20, guiHeight + 20, Fade(COLOR_REC, 0.8f)); break;
|
||||
case COMBOBOX: DrawRectangleLines(selectPosX + 10, guiPosY + (8 * deltaY) - 10, selectWidth - 20, guiHeight + 20, Fade(COLOR_REC, 0.8f)); break;
|
||||
case CHECKBOX: DrawRectangleLines(selectPosX + 10, guiPosY + (9 * deltaY) - 10, selectWidth - 20, guiHeight + 20, Fade(COLOR_REC, 0.8f)); break;
|
||||
case TEXTBOX: DrawRectangleLines(selectPosX + 10, guiPosY + (10 * deltaY) - 10, selectWidth - 20, guiHeight + 20, Fade(COLOR_REC, 0.8f)); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// Value editor
|
||||
// -- Color picker
|
||||
DrawRectangleRec((Rectangle){colorPickerPos.x - 2, colorPickerPos.y - 2, colorPickerTexture.width + 4, colorPickerTexture.height + 4}, COLOR_REC);
|
||||
DrawTextureV(colorPickerTexture, colorPickerPos, WHITE);
|
||||
DrawTextureV(cursorTexture, cursorPickerPos, WHITE);
|
||||
|
||||
//DrawRectangleV(GetMousePosition(), (Vector2){ 4, 4 }, RED);
|
||||
|
||||
// -- Color value result
|
||||
if(colorSelectedHover) DrawRectangle(colorPickerPos.x - 3, colorPickerPos.y - 3 + colorPickerTexture.height + 2*rgbDelta, 2*rgbWidthLabel + 6, 2*rgbWidthLabel + 6, BLACK);
|
||||
else DrawRectangle(colorPickerPos.x - 2, colorPickerPos.y - 2 + colorPickerTexture.height + 2*rgbDelta, 2*rgbWidthLabel + 4, 2*rgbWidthLabel + 4, Fade(COLOR_REC, 0.8f));
|
||||
DrawRectangleRec (colorSelectedBoundsRec, WHITE);
|
||||
DrawRectangleRec (colorSelectedBoundsRec, colorPickerValue);
|
||||
|
||||
// -- Color samples
|
||||
for (int i = 0; i < NUM_COLOR_SAMPLES/2; i++)
|
||||
{
|
||||
if (i == sampleSelected) DrawRectangle (colorPickerPos.x + 2*rgbWidthLabel + i*rgbWidthLabel + 3*rgbDelta + i*rgbDelta - 2, colorPickerPos.y - 2 + colorPickerTexture.height + 2*rgbDelta, rgbWidthLabel + 4, rgbWidthLabel + 2, BLACK);
|
||||
else if (i == sampleHover) DrawRectangle (colorPickerPos.x + 2*rgbWidthLabel + i*rgbWidthLabel + 3*rgbDelta + i*rgbDelta - 2, colorPickerPos.y - 2 + colorPickerTexture.height + 2*rgbDelta, rgbWidthLabel + 4, rgbWidthLabel + 2, Fade(COLOR_REC, 0.8f));
|
||||
else DrawRectangle (colorPickerPos.x + 2*rgbWidthLabel + i*rgbWidthLabel + 3*rgbDelta + i*rgbDelta - 1, colorPickerPos.y - 1 + colorPickerTexture.height + 2*rgbDelta, rgbWidthLabel + 2, rgbWidthLabel, Fade(COLOR_REC, 0.6f));
|
||||
DrawRectangle(colorPickerPos.x + 2*rgbWidthLabel + i*rgbWidthLabel + 3*rgbDelta + i*rgbDelta, colorPickerPos.y + colorPickerTexture.height + 2*rgbDelta, rgbWidthLabel, rgbWidthLabel - 2, colorSample[i]);
|
||||
}
|
||||
for (int i = NUM_COLOR_SAMPLES/2; i < NUM_COLOR_SAMPLES; i++)
|
||||
{
|
||||
if (i == sampleSelected) DrawRectangle (colorPickerPos.x + 2*rgbWidthLabel + (i-5)*rgbWidthLabel + 3*rgbDelta + (i-5)*rgbDelta - 2, colorPickerPos.y - 2 + colorPickerTexture.height + 2*rgbDelta + rgbWidthLabel + 2, rgbWidthLabel + 4, rgbWidthLabel + 2, BLACK);
|
||||
else if (i == sampleHover) DrawRectangle (colorPickerPos.x + 2*rgbWidthLabel + (i-5)*rgbWidthLabel + 3*rgbDelta + (i-5)*rgbDelta - 2, colorPickerPos.y - 2 + colorPickerTexture.height + 2*rgbDelta + rgbWidthLabel + 2, rgbWidthLabel + 4, rgbWidthLabel + 2, Fade(COLOR_REC, 0.8f));
|
||||
else DrawRectangle (colorPickerPos.x + 2*rgbWidthLabel + (i-5)*rgbWidthLabel + 3*rgbDelta + (i-5)*rgbDelta - 1, colorPickerPos.y - 1 + colorPickerTexture.height + 2*rgbDelta + rgbWidthLabel + 2, rgbWidthLabel + 2, rgbWidthLabel, Fade(COLOR_REC, 0.6f));
|
||||
DrawRectangle(colorPickerPos.x + 2*rgbWidthLabel + (i-5)*rgbWidthLabel + 3*rgbDelta + (i-5)*rgbDelta, colorPickerPos.y + colorPickerTexture.height + 2*rgbDelta + rgbWidthLabel + 2, rgbWidthLabel, rgbWidthLabel - 2, colorSample[i]);
|
||||
}
|
||||
|
||||
// -- RGBA sliders
|
||||
GuiLabelEx((Rectangle){colorPickerPos.x, colorPickerPos.y + colorPickerTexture.height + 14*rgbDelta, rgbWidthLabel, rgbHeightLabel}, FormatText("%d", redValue), BLACK, COLOR_REC, RED);
|
||||
redValue = GuiSlider((Rectangle)(Rectangle){colorPickerPos.x + rgbWidthLabel + rgbDelta, colorPickerPos.y + colorPickerTexture.height + 14*rgbDelta, colorPickerTexture.height - rgbWidthLabel - rgbDelta, rgbHeightLabel}, redValue, 0, 255);
|
||||
|
||||
GuiLabelEx((Rectangle){colorPickerPos.x, colorPickerPos.y + colorPickerTexture.height + 15*rgbDelta + rgbHeightLabel, rgbWidthLabel, rgbHeightLabel}, FormatText("%d", greenValue), BLACK, COLOR_REC, GREEN);
|
||||
greenValue = GuiSlider((Rectangle)(Rectangle){colorPickerPos.x + rgbWidthLabel + rgbDelta, colorPickerPos.y + colorPickerTexture.height + 15*rgbDelta + rgbHeightLabel, colorPickerTexture.height - rgbWidthLabel - rgbDelta, rgbHeightLabel}, greenValue, 0, 255);
|
||||
|
||||
GuiLabelEx((Rectangle){colorPickerPos.x, colorPickerPos.y + colorPickerTexture.height + 16*rgbDelta + 2*rgbHeightLabel, rgbWidthLabel, rgbHeightLabel}, FormatText("%d", blueValue), BLACK, COLOR_REC, BLUE);
|
||||
blueValue = GuiSlider((Rectangle)(Rectangle){colorPickerPos.x + rgbWidthLabel + rgbDelta, colorPickerPos.y + colorPickerTexture.height + 16*rgbDelta + 2*rgbHeightLabel, colorPickerTexture.height - rgbWidthLabel - rgbDelta, rgbHeightLabel}, blueValue, 0, 255);
|
||||
|
||||
DrawTextureRec(checkerTexture, (Rectangle){0,0,rgbWidthLabel, rgbHeightLabel}, (Vector2){colorPickerPos.x, colorPickerPos.y + colorPickerTexture.height + 17*rgbDelta + 3*rgbHeightLabel}, WHITE);
|
||||
DrawRectangle(colorPickerPos.x, colorPickerPos.y + colorPickerTexture.height + 17*rgbDelta + 3*rgbHeightLabel, rgbWidthLabel, rgbHeightLabel, Fade(colorPickerValue, (float)alphaValue/100));
|
||||
alphaValue = GuiSlider((Rectangle)(Rectangle){colorPickerPos.x + rgbWidthLabel + rgbDelta, colorPickerPos.y + colorPickerTexture.height + 17*rgbDelta + 3*rgbHeightLabel, colorPickerTexture.height - rgbWidthLabel - rgbDelta, rgbHeightLabel}, alphaValue, 0, 255);
|
||||
DrawRectangleLines(colorPickerPos.x,colorPickerPos.y + colorPickerTexture.height + 17*rgbDelta + 3*rgbHeightLabel,rgbWidthLabel, rgbHeightLabel, COLOR_REC);
|
||||
|
||||
// -- VALUE Spinner
|
||||
GuiLabel((Rectangle){ colorPickerPos.x + 2*rgbDelta, colorPickerPos.y + colorPickerTexture.height + 10*rgbHeightLabel, rgbWidthLabel, rgbWidthLabel}, "Value");
|
||||
sizeValueSelected = GuiSpinner((Rectangle){ colorPickerPos.x + 2*rgbWidthLabel, colorPickerPos.y + colorPickerTexture.height + 10*rgbHeightLabel, colorPickerTexture.height - 2*rgbWidthLabel, rgbWidthLabel}, sizeValueSelected, 0, 50);
|
||||
|
||||
// -- Import & Save buttons
|
||||
if (GuiButton((Rectangle){ colorPickerPos.x, screenHeight - 3*rgbWidthLabel - rgbDelta - STATUS_BAR_HEIGHT, colorPickerTexture.width, rgbWidthLabel}, "Import Style"))
|
||||
{
|
||||
fileName = tinyfd_openFileDialog( "", "name.style", 0, NULL, NULL, 0);
|
||||
if(fileName == NULL) fileName = "";
|
||||
else
|
||||
{
|
||||
guiPropertySelected = -1;
|
||||
loadStyle = true;
|
||||
}
|
||||
}
|
||||
if (GuiButton((Rectangle){ colorPickerPos.x, screenHeight - 2*rgbWidthLabel - STATUS_BAR_HEIGHT, colorPickerTexture.width, rgbWidthLabel}, "Save Style"))
|
||||
{
|
||||
fileName = tinyfd_saveFileDialog( "", "name.style", 0, NULL, NULL);
|
||||
if(fileName == NULL) fileName = "";
|
||||
else saveStyle = true;
|
||||
}
|
||||
//GuiLabel((Rectangle){colorPickerPos.x, screenHeight - 2*rgbWidthLabel - STATUS_BAR_HEIGHT + rgbDelta, 2*rgbWidthLabel, rgbWidthLabel}, "File name");
|
||||
//fileName = GuiTextBox((Rectangle){colorPickerPos.x + 2*rgbWidthLabel, screenHeight - 2*rgbWidthLabel - STATUS_BAR_HEIGHT + rgbDelta, colorPickerTexture.width - 2*rgbWidthLabel, rgbWidthLabel}, fileName);
|
||||
|
||||
// Draw GUI Elements text
|
||||
for (int i = 0; i < NUM_ELEMENTS; i++) DrawText(guiElementText[i], guiElementRec[i].width/2 - MeasureText(guiElementText[i], FONT_SIZE)/2, 15 + i*ELEMENT_HEIGHT, FONT_SIZE, BLACK);
|
||||
|
||||
// Draw Borders
|
||||
DrawLine(guiElementRec[0].width, 0, guiElementRec[0].width, screenHeight - STATUS_BAR_HEIGHT, COLOR_REC);
|
||||
DrawLine(400, 0, 400, screenHeight - STATUS_BAR_HEIGHT, COLOR_REC);
|
||||
DrawLine(401, 0, 401, screenHeight - STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.4f));
|
||||
DrawLine(screenWidth - 320, 0, screenWidth - 320, screenHeight - STATUS_BAR_HEIGHT, COLOR_REC);
|
||||
DrawLine(screenWidth - 321, 0, screenWidth - 321, screenHeight - STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.4f));
|
||||
|
||||
// Draw info bar
|
||||
DrawLine(0, screenHeight - STATUS_BAR_HEIGHT, screenWidth, screenHeight - STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.8f));
|
||||
DrawLine(0, screenHeight - STATUS_BAR_HEIGHT + 1, screenWidth, screenHeight - STATUS_BAR_HEIGHT + 1, Fade(COLOR_REC, 0.4f));
|
||||
DrawRectangle(0, screenHeight - STATUS_BAR_HEIGHT, screenWidth, STATUS_BAR_HEIGHT, Fade(COLOR_REC, 0.1f));
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Unload all loaded data (textures, fonts, audio)
|
||||
//UnloadImage(colorPickerImage);
|
||||
UnloadTexture(colorPickerTexture);
|
||||
UnloadTexture(checkerTexture);
|
||||
UnloadTexture(cursorTexture);
|
||||
|
||||
free(guiText);
|
||||
//free(fileName);
|
||||
free(colorPickerPixel);
|
||||
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
98
styler/test.style
Normal file
98
styler/test.style
Normal file
@ -0,0 +1,98 @@
|
||||
GLOBAL_BASE_COLOR 0x59cbe8ff
|
||||
GLOBAL_BORDER_COLOR 0xffffffff
|
||||
GLOBAL_TEXT_COLOR 0xffffffff
|
||||
GLOBAL_TEXT_FONTSIZE 0x1d
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0x12d070ff
|
||||
LABEL_BORDER_WIDTH 0x1
|
||||
LABEL_TEXT_COLOR 0xffffffff
|
||||
LABEL_TEXT_PADDING 0x14
|
||||
BUTTON_BORDER_WIDTH 0x2
|
||||
BUTTON_TEXT_PADDING 0x14
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0xffffffff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0xfe0000ff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0xffffffff
|
||||
BUTTON_HOVER_BORDER_COLOR 0xffffffff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0xb5e7f4ff
|
||||
BUTTON_HOVER_TEXT_COLOR 0xffffffff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0xffffffff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0xa2e2f2ff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0xffffffff
|
||||
TOGGLE_TEXT_PADDING 0x14
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0xffffffff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0xb5e7f4ff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0xffffffff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0xffffffff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0xb5e7f4ff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0xffffffff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0xffffffff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0xa2e2f2ff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0xffffffff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0xffffffff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0x6bd0eaff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0xffffffff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x1
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x1
|
||||
SLIDER_BORDER_COLOR 0xffffffff
|
||||
SLIDER_INSIDE_COLOR 0xb5e7f4ff
|
||||
SLIDER_DEFAULT_COLOR 0x90dcefff
|
||||
SLIDER_HOVER_COLOR 0x7dd6edff
|
||||
SLIDER_ACTIVE_COLOR 0x59cbe8ff
|
||||
SLIDERBAR_BORDER_COLOR 0xffffffff
|
||||
SLIDERBAR_INSIDE_COLOR 0xb5e7f4ff
|
||||
SLIDERBAR_DEFAULT_COLOR 0x90dcefff
|
||||
SLIDERBAR_HOVER_COLOR 0x7dd6edff
|
||||
SLIDERBAR_ACTIVE_COLOR 0x59cbe8ff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0x6bd0eaff
|
||||
PROGRESSBAR_BORDER_COLOR 0xffffffff
|
||||
PROGRESSBAR_INSIDE_COLOR 0xb5e7f4ff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0x90dcefff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x2
|
||||
SPINNER_LABEL_BORDER_COLOR 0xffffffff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0xb5e7f4ff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0xffffffff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0xb5e7f4ff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0xffffffff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0xffffffff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0xffffffff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0xb5e7f4ff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0xffffffff
|
||||
SPINNER_HOVER_TEXT_COLOR 0xffffffff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0xffffffff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0xa2e2f2ff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0xffffffff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0xffffffff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x1e
|
||||
COMBOBOX_BUTTON_HEIGHT 0x1e
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0xffffffff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0xb5e7f4ff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0xffffffff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0xffffffff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0xffffffff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0xb5e7f4ff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0xffffffff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0xffffffff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0xffffffff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0x6bd0eaff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0xffffffff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0xffffffff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0x6bd0eaff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0xffffffff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0xffffffff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0xb5e7f4ff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0xffffffff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0xffffffff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0xffffffff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0x90dcefff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0x6bd0eaff
|
||||
CHECKBOX_INSIDE_WIDTH 0x4
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0xffffffff
|
||||
TEXTBOX_INSIDE_COLOR 0xb5e7f4ff
|
||||
TEXTBOX_TEXT_COLOR 0xffffffff
|
||||
TEXTBOX_LINE_COLOR 0xffffffff
|
||||
TEXTBOX_TEXT_FONTSIZE 0xa
|
Loading…
x
Reference in New Issue
Block a user