Extended max guiControls, added duplicate controls

This commit is contained in:
Ray San 2018-03-21 13:28:39 +01:00
parent b2ecbf1f3a
commit d390b9aaa1

View File

@ -22,7 +22,7 @@
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
#define MAX_GUI_CONTROLS 64 // Maximum number of gui controls
#define MAX_GUI_CONTROLS 256 // Maximum number of gui controls
#define MAX_ANCHOR_POINTS 8 // Maximum number of anchor points
#define GRID_LINE_SPACING 10 // Grid line spacing in pixels
@ -199,7 +199,7 @@ int main()
};
Texture2D texture = LoadTexture("icons.png");
//Texture2D rfxgenLayout = LoadTexture("screenshot000.png");
//Texture2D rfxgenLayout = LoadTexture("screenshot001.png");
// Initialize anchor points to default values
for (int i = 0; i < MAX_ANCHOR_POINTS; i++)
@ -706,13 +706,24 @@ int main()
else if (layout[selectedControl].rec.height <= 20) layout[selectedControl].rec.height = 20;
}
// TODO: Draw global app screen limits (black rectangle with black default anchor)
// Shows or hides the grid if not in textEditMode
if (IsKeyPressed(KEY_G) && (!textEditMode)) showGrid = !showGrid;
// Duplicate selected control
if ((IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_D)) && (selectedControl != -1) && !anchorMode)
{
// Add a copy of selected control
layout[controlsCounter].id = controlsCounter;
layout[controlsCounter].type = layout[selectedControl].type;
layout[controlsCounter].rec = layout[selectedControl].rec;
strcpy(layout[controlsCounter].text, layout[selectedControl].text);
layout[controlsCounter].ap = layout[selectedControl].ap; // Default anchor point (0, 0)
controlsCounter++;
}
if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_S))
{
char currrentPathFile[256];
@ -876,8 +887,8 @@ int main()
if (helpMode)
{
DrawRectangleRec((Rectangle){ 20, 20, 260, 270 }, GetColor(style[DEFAULT_BACKGROUND_COLOR]));
GuiGroupBox((Rectangle){ 20, 20, 260, 270 }, "Shortcuts");
DrawRectangleRec((Rectangle){ 20, 20, 260, 290 }, GetColor(style[DEFAULT_BACKGROUND_COLOR]));
GuiGroupBox((Rectangle){ 20, 20, 260, 290 }, "Shortcuts");
GuiLabel((Rectangle){ 30, 30, 0, 0 }, "G - Show/hide grid");
GuiLabel((Rectangle){ 30, 50, 0, 0 }, "S - Toggle snap");
GuiLabel((Rectangle){ 30, 70, 0, 0 }, "A - Anchor mode");
@ -891,6 +902,7 @@ int main()
GuiLabel((Rectangle){ 30, 230, 0, 0 }, "L. Ctrl + Enter - Export layout to code");
GuiLabel((Rectangle){ 30, 250, 0, 0 }, "L. Ctrl + S - Save layout(.rgl)");
GuiLabel((Rectangle){ 30, 270, 0, 0 }, "L. Ctrl + O - Open layout(.rgl)");
GuiLabel((Rectangle){ 30, 290, 0, 0 }, "L. Ctrl + D - Duplicate selected control");
}
// Draw status bar bottom with debug information
@ -908,6 +920,7 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture);
//UnloadTexture(rfxgenLayout);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
@ -984,6 +997,7 @@ static void SaveLayoutRGL(const char *fileName, bool binary)
fwrite(&layout[i].rec, 1, sizeof(Rectangle), rglFile);
fwrite(layout[i].text, 1, 32, rglFile);
// TODO: Export anchors data
}