mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-01 11:49:18 -05:00
Fixed drawing names order, fixed anchors drawing errors, Updated codeExporter
This commit is contained in:
@ -144,7 +144,6 @@ int main()
|
|||||||
int saveAnchorSelected = -1;
|
int saveAnchorSelected = -1;
|
||||||
|
|
||||||
int snapFrameCounter = 0;
|
int snapFrameCounter = 0;
|
||||||
bool saved = true;
|
|
||||||
|
|
||||||
bool lockMode = false;
|
bool lockMode = false;
|
||||||
bool globalReference = false;
|
bool globalReference = false;
|
||||||
@ -283,7 +282,7 @@ int main()
|
|||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyPressed(KEY_ESCAPE)/* || WindowShouldClose()*/)
|
if (IsKeyPressed(KEY_ESCAPE) && !textEditMode && !nameEditMode)/* || WindowShouldClose()*/
|
||||||
{
|
{
|
||||||
ultimateMessage = !ultimateMessage;
|
ultimateMessage = !ultimateMessage;
|
||||||
selectedControl = -1;
|
selectedControl = -1;
|
||||||
@ -291,11 +290,11 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (WindowShouldClose()) exitWindow = true;
|
if (WindowShouldClose()) exitWindow = true;
|
||||||
|
|
||||||
mouseX = GetMouseX();
|
mouseX = GetMouseX();
|
||||||
mouseY = GetMouseY();
|
mouseY = GetMouseY();
|
||||||
|
|
||||||
snapFrameCounter++;
|
snapFrameCounter++;
|
||||||
if (saved && (snapFrameCounter%(120*60)) == 0) saved = false;
|
|
||||||
|
|
||||||
// Enables or disables snapMode if not in textEditMode
|
// Enables or disables snapMode if not in textEditMode
|
||||||
if (IsKeyPressed(KEY_S) && (!textEditMode) && (!nameEditMode)) snapMode = !snapMode;
|
if (IsKeyPressed(KEY_S) && (!textEditMode) && (!nameEditMode)) snapMode = !snapMode;
|
||||||
@ -341,7 +340,8 @@ int main()
|
|||||||
layout.controls[layout.controlsCount].id = layout.controlsCount;
|
layout.controls[layout.controlsCount].id = layout.controlsCount;
|
||||||
layout.controls[layout.controlsCount].type = selectedType;
|
layout.controls[layout.controlsCount].type = selectedType;
|
||||||
layout.controls[layout.controlsCount].rec = (Rectangle){ mouseX - defaultRec[selectedType].width/2, mouseY - defaultRec[selectedType].height/2, defaultRec[selectedType].width, defaultRec[selectedType].height };
|
layout.controls[layout.controlsCount].rec = (Rectangle){ mouseX - defaultRec[selectedType].width/2, mouseY - defaultRec[selectedType].height/2, defaultRec[selectedType].width, defaultRec[selectedType].height };
|
||||||
strcpy(layout.controls[layout.controlsCount].text, "SAMPLE TEXT");
|
if ((layout.controls[layout.controlsCount].type == LABEL) || (layout.controls[layout.controlsCount].type == TEXTBOX) || (layout.controls[layout.controlsCount].type == BUTTON) || (layout.controls[layout.controlsCount].type == TOGGLE)
|
||||||
|
|| (layout.controls[layout.controlsCount].type == GROUPBOX) || (layout.controls[layout.controlsCount].type == WINDOWBOX) || (layout.controls[layout.controlsCount].type == STATUSBAR) || (layout.controls[layout.controlsCount].type == DUMMYREC)) strcpy(layout.controls[layout.controlsCount].text, "SAMPLE TEXT");
|
||||||
strcpy(layout.controls[layout.controlsCount].name, FormatText("%s%03i", controlTypeNameLow[layout.controls[layout.controlsCount].type], layout.controlsCount));
|
strcpy(layout.controls[layout.controlsCount].name, FormatText("%s%03i", controlTypeNameLow[layout.controls[layout.controlsCount].type], layout.controlsCount));
|
||||||
layout.controls[layout.controlsCount].ap = &layout.anchors[0]; // Default anchor point (0, 0)
|
layout.controls[layout.controlsCount].ap = &layout.anchors[0]; // Default anchor point (0, 0)
|
||||||
|
|
||||||
@ -558,6 +558,8 @@ int main()
|
|||||||
{
|
{
|
||||||
layout.controls[i].type = layout.controls[i + 1].type;
|
layout.controls[i].type = layout.controls[i + 1].type;
|
||||||
layout.controls[i].rec = layout.controls[i + 1].rec;
|
layout.controls[i].rec = layout.controls[i + 1].rec;
|
||||||
|
strcpy(layout.controls[i].text, "\0");
|
||||||
|
strcpy(layout.controls[i].name, "\0");
|
||||||
strcpy(layout.controls[i].text, layout.controls[i + 1].text);
|
strcpy(layout.controls[i].text, layout.controls[i + 1].text);
|
||||||
strcpy(layout.controls[i].name, layout.controls[i + 1].name);
|
strcpy(layout.controls[i].name, layout.controls[i + 1].name);
|
||||||
layout.controls[i].ap = layout.controls[i + 1].ap;
|
layout.controls[i].ap = layout.controls[i + 1].ap;
|
||||||
@ -658,7 +660,7 @@ int main()
|
|||||||
else if (keyCount == 32) framesCounter = 21;
|
else if (keyCount == 32) framesCounter = 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nameEditMode)
|
if ((nameEditMode))
|
||||||
{
|
{
|
||||||
// Locks the selectedControl for text editing
|
// Locks the selectedControl for text editing
|
||||||
selectedControl = saveControlSelected;
|
selectedControl = saveControlSelected;
|
||||||
@ -717,7 +719,8 @@ int main()
|
|||||||
strcpy(prevControlText, layout.controls[selectedControl].text);
|
strcpy(prevControlText, layout.controls[selectedControl].text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_N) && !textEditMode)
|
// Turns on NameEditMode
|
||||||
|
if (IsKeyPressed(KEY_N) && !textEditMode && (selectedControl != -1))
|
||||||
{
|
{
|
||||||
nameEditMode = true;
|
nameEditMode = true;
|
||||||
strcpy(prevControlName, layout.controls[selectedControl].name);
|
strcpy(prevControlName, layout.controls[selectedControl].name);
|
||||||
@ -742,7 +745,7 @@ int main()
|
|||||||
if (CheckCollisionPointCircle(GetMousePosition(), (Vector2){ layout.anchors[i].x, layout.anchors[i].y }, ANCHOR_RADIUS))
|
if (CheckCollisionPointCircle(GetMousePosition(), (Vector2){ layout.anchors[i].x, layout.anchors[i].y }, ANCHOR_RADIUS))
|
||||||
{
|
{
|
||||||
selectedAnchor = i;
|
selectedAnchor = i;
|
||||||
anchorMode = true;
|
if (layout.anchors[selectedAnchor].enabled) anchorMode = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1012,8 +1015,6 @@ int main()
|
|||||||
{
|
{
|
||||||
if (GetExtension(fileName) == NULL) strcat(fileName, ".rgl\0"); // No extension provided
|
if (GetExtension(fileName) == NULL) strcat(fileName, ".rgl\0"); // No extension provided
|
||||||
SaveLayoutRGL(fileName, false);
|
SaveLayoutRGL(fileName, false);
|
||||||
saved = true;
|
|
||||||
snapFrameCounter = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1033,7 +1034,7 @@ int main()
|
|||||||
const char *filters[] = { "*.c", "*.go", "*.lua" };
|
const char *filters[] = { "*.c", "*.go", "*.lua" };
|
||||||
const char *fileName = tinyfd_saveFileDialog("Generate code file", "layout.c", 3, filters, "Code file");
|
const char *fileName = tinyfd_saveFileDialog("Generate code file", "layout.c", 3, filters, "Code file");
|
||||||
|
|
||||||
if (fileName != NULL) GenerateCode(fileName, false);
|
if (fileName != NULL) GenerateCode(fileName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tracemap texture control logic
|
// Tracemap texture control logic
|
||||||
@ -1177,7 +1178,12 @@ int main()
|
|||||||
case CHECKBOX: GuiCheckBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, false); break;
|
case CHECKBOX: GuiCheckBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, false); break;
|
||||||
case TEXTBOX: GuiTextBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text, 32, false); break;
|
case TEXTBOX: GuiTextBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text, 32, false); break;
|
||||||
case GROUPBOX: GuiGroupBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text); break;
|
case GROUPBOX: GuiGroupBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text); break;
|
||||||
case WINDOWBOX: GuiWindowBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text); break;
|
case WINDOWBOX:
|
||||||
|
{
|
||||||
|
GuiFade(0.8f);
|
||||||
|
GuiWindowBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text);
|
||||||
|
GuiFade(1.0f);
|
||||||
|
}break;
|
||||||
case DUMMYREC: GuiDummyRec((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text); break;
|
case DUMMYREC: GuiDummyRec((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text); break;
|
||||||
case DROPDOWNBOX: GuiDropdownBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, list, 3, 2); break;
|
case DROPDOWNBOX: GuiDropdownBox((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, list, 3, 2); break;
|
||||||
case STATUSBAR: GuiStatusBar((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text, 15); break;
|
case STATUSBAR: GuiStatusBar((Rectangle){ layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height }, layout.controls[i].text, 15); break;
|
||||||
@ -1187,6 +1193,7 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((layout.controls[i].ap->id == selectedAnchor) && (layout.controls[i].ap->id > 0)) DrawLine(layout.controls[i].ap->x, layout.controls[i].ap->y, layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, RED);
|
if ((layout.controls[i].ap->id == selectedAnchor) && (layout.controls[i].ap->id > 0)) DrawLine(layout.controls[i].ap->x, layout.controls[i].ap->y, layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, RED);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ((layout.controls[i].ap->id == selectedAnchor) && (layout.controls[i].ap->id > 0)) DrawLine(layout.controls[i].ap->x, layout.controls[i].ap->y, layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, BLUE);
|
else if ((layout.controls[i].ap->id == selectedAnchor) && (layout.controls[i].ap->id > 0)) DrawLine(layout.controls[i].ap->x, layout.controls[i].ap->y, layout.controls[i].ap->x + layout.controls[i].rec.x, layout.controls[i].ap->y + layout.controls[i].rec.y, BLUE);
|
||||||
}
|
}
|
||||||
@ -1220,51 +1227,54 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw the anchorPoints
|
// Draw the anchorPoints
|
||||||
for (int i = 1; i < MAX_ANCHOR_POINTS; i++)
|
for (int i = 0; i < MAX_ANCHOR_POINTS; i++)
|
||||||
{
|
{
|
||||||
if (layout.anchors[i].id == selectedAnchor && anchorNewPos)
|
if ((layout.anchors[i].enabled) && (layout.anchors[i].x != 0) && (layout.anchors[i].y != 0))
|
||||||
{
|
{
|
||||||
// Draw the anchor that is currently moving
|
if (layout.anchors[i].id == selectedAnchor && anchorNewPos)
|
||||||
DrawCircle(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(ORANGE, 0.5f));
|
{
|
||||||
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, ORANGE);
|
// Draw the anchor that is currently moving
|
||||||
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, ORANGE);
|
DrawCircle(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(ORANGE, 0.5f));
|
||||||
}
|
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, ORANGE);
|
||||||
if (layout.anchors[i].id == selectedAnchor && IsKeyDown(KEY_A))
|
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, ORANGE);
|
||||||
{
|
}
|
||||||
// Draw the anchor that is currently moving
|
if (layout.anchors[i].id == selectedAnchor && IsKeyDown(KEY_A))
|
||||||
DrawCircle(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(ORANGE, 0.5f));
|
{
|
||||||
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, ORANGE);
|
// Draw the anchor that is currently moving
|
||||||
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, ORANGE);
|
DrawCircle(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(ORANGE, 0.5f));
|
||||||
}
|
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, ORANGE);
|
||||||
else if (layout.anchors[i].hidding && layout.anchors[i].id == selectedAnchor)
|
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, ORANGE);
|
||||||
{
|
}
|
||||||
// Draw idle anchor
|
else if (layout.anchors[i].hidding && layout.anchors[i].id == selectedAnchor)
|
||||||
DrawCircle(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(BLUE, 0.5f));
|
{
|
||||||
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, BLUE);
|
// Draw idle anchor
|
||||||
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, BLUE);
|
DrawCircle(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(BLUE, 0.5f));
|
||||||
DrawText(FormatText("[%i, %i]", layout.anchors[i].x, layout.anchors[i].y), layout.anchors[i].x, layout.anchors[i].y - 25, 20, BLUE);
|
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, BLUE);
|
||||||
}
|
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, BLUE);
|
||||||
else if (layout.anchors[i].id == selectedAnchor)
|
DrawText(FormatText("[%i, %i]", layout.anchors[i].x, layout.anchors[i].y), layout.anchors[i].x, layout.anchors[i].y - 25, 20, BLUE);
|
||||||
{
|
}
|
||||||
// Draw the selected anchor
|
else if (layout.anchors[i].id == selectedAnchor)
|
||||||
DrawCircle(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(RED, 0.5f));
|
{
|
||||||
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, RED);
|
// Draw the selected anchor
|
||||||
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, RED);
|
DrawCircle(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(RED, 0.5f));
|
||||||
DrawText(FormatText("[%i, %i]", layout.anchors[i].x, layout.anchors[i].y), layout.anchors[i].x, layout.anchors[i].y - 25, 20, RED);
|
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, RED);
|
||||||
}
|
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, RED);
|
||||||
else if (layout.anchors[i].hidding)
|
DrawText(FormatText("[%i, %i]", layout.anchors[i].x, layout.anchors[i].y), layout.anchors[i].x, layout.anchors[i].y - 25, 20, RED);
|
||||||
{
|
}
|
||||||
// Draw idle anchor
|
else if (layout.anchors[i].hidding)
|
||||||
DrawCircleLines(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(BLUE, 0.5f));
|
{
|
||||||
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, BLUE);
|
// Draw idle anchor
|
||||||
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, BLUE);
|
DrawCircleLines(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(BLUE, 0.5f));
|
||||||
}
|
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, BLUE);
|
||||||
else
|
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, BLUE);
|
||||||
{
|
}
|
||||||
// Draw idle anchor
|
else
|
||||||
DrawCircleLines(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(RED, 0.5f));
|
{
|
||||||
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, RED);
|
// Draw idle anchor
|
||||||
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, RED);
|
DrawCircleLines(layout.anchors[i].x, layout.anchors[i].y, ANCHOR_RADIUS, Fade(RED, 0.5f));
|
||||||
|
DrawRectangle(layout.anchors[i].x - ANCHOR_RADIUS - 5, layout.anchors[i].y, ANCHOR_RADIUS*2 + 10, 1, RED);
|
||||||
|
DrawRectangle(layout.anchors[i].x, layout.anchors[i].y - ANCHOR_RADIUS - 5, 1, ANCHOR_RADIUS*2 + 10, RED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1308,13 +1318,23 @@ int main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw cursor on nameEditMode
|
// Draw nameEditMode
|
||||||
if (nameEditMode)
|
if (nameEditMode)
|
||||||
{
|
{
|
||||||
DrawText(FormatText("%s", layout.controls[selectedControl].name), layout.controls[selectedControl].rec.x + layout.controls[selectedControl].ap->x, layout.controls[selectedControl].rec.y + layout.controls[selectedControl].ap->y + layout.controls[selectedControl].rec.height + 10, style[DEFAULT_TEXT_SIZE]*2, BLACK);
|
DrawText(FormatText("%s", layout.controls[selectedControl].name), layout.controls[selectedControl].rec.x + layout.controls[selectedControl].ap->x, layout.controls[selectedControl].rec.y + layout.controls[selectedControl].ap->y + layout.controls[selectedControl].rec.height + 10, style[DEFAULT_TEXT_SIZE]*2, BLACK);
|
||||||
|
|
||||||
if (((framesCounter/20)%2) == 0) DrawText("|", layout.controls[selectedControl].rec.x + layout.controls[selectedControl].ap->x + MeasureText(layout.controls[selectedControl].name, style[DEFAULT_TEXT_SIZE]*2) + 2, layout.controls[selectedControl].rec.y + layout.controls[selectedControl].ap->y + layout.controls[selectedControl].rec.height + 10, style[DEFAULT_TEXT_SIZE]*2 + 2, BLACK);
|
if (((framesCounter/20)%2) == 0) DrawText("|", layout.controls[selectedControl].rec.x + layout.controls[selectedControl].ap->x + MeasureText(layout.controls[selectedControl].name, style[DEFAULT_TEXT_SIZE]*2) + 2, layout.controls[selectedControl].rec.y + layout.controls[selectedControl].ap->y + layout.controls[selectedControl].rec.height + 10, style[DEFAULT_TEXT_SIZE]*2 + 2, BLACK);
|
||||||
}
|
}
|
||||||
|
else if (IsKeyDown(KEY_N))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < layout.controlsCount; i++)
|
||||||
|
{
|
||||||
|
// Draws the Controls when placed on the grid.
|
||||||
|
if (!layout.controls[i].ap->hidding)
|
||||||
|
DrawText(FormatText("%s", layout.controls[i].name), layout.controls[i].rec.x + layout.controls[i].ap->x, layout.controls[i].rec.y + layout.controls[i].ap->y + layout.controls[i].rec.height + 10, style[DEFAULT_TEXT_SIZE]*2, BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Draw anchor linking line
|
// Draw anchor linking line
|
||||||
if (anchorLinkMode) DrawLine(layout.anchors[linkedAnchor].x, layout.anchors[linkedAnchor].y, mouseX, mouseY, BLACK);
|
if (anchorLinkMode) DrawLine(layout.anchors[linkedAnchor].x, layout.anchors[linkedAnchor].y, mouseX, mouseY, BLACK);
|
||||||
@ -1384,13 +1404,11 @@ int main()
|
|||||||
{
|
{
|
||||||
if (GetExtension(fileName) == NULL) strcat(fileName, ".rgl\0"); // No extension provided
|
if (GetExtension(fileName) == NULL) strcat(fileName, ".rgl\0"); // No extension provided
|
||||||
SaveLayoutRGL(fileName, false);
|
SaveLayoutRGL(fileName, false);
|
||||||
saved = true;
|
|
||||||
snapFrameCounter = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exitWindow = true;
|
exitWindow = true;
|
||||||
}
|
}
|
||||||
if (GuiButton((Rectangle){ GetScreenWidth()/2 + 20, GetScreenHeight()/2 + 10, 70, 25 }, "No")) { exitWindow = true; }
|
else if (GuiButton((Rectangle){ GetScreenWidth()/2 + 20, GetScreenHeight()/2 + 10, 70, 25 }, "No")) { exitWindow = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
@ -1505,6 +1523,8 @@ static void LoadLayoutRGL(const char *fileName)
|
|||||||
|
|
||||||
if (rglFile != NULL)
|
if (rglFile != NULL)
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < MAX_ANCHOR_POINTS; i++) layout.anchors[i].hidding = false;
|
||||||
|
|
||||||
fgets(buffer, 256, rglFile);
|
fgets(buffer, 256, rglFile);
|
||||||
|
|
||||||
if (buffer[0] != 'R') // Text file!
|
if (buffer[0] != 'R') // Text file!
|
||||||
@ -1595,7 +1615,7 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
|
|
||||||
for (int i = 0; i < layout.controlsCount; i++)
|
for (int i = 0; i < layout.controlsCount; i++)
|
||||||
{
|
{
|
||||||
if (layout.controls[i].type == BUTTON) fprintf(ftool, "static void %s();\t\t// %s: %s logic\n", layout.controls[i].name, controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
if (layout.controls[i].type == BUTTON) fprintf(ftool, "static void %s();\t\t// %s: %s logic\n", layout.controls[i].name, controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(ftool, "\n");
|
fprintf(ftool, "\n");
|
||||||
@ -1613,19 +1633,15 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
fprintf(ftool, " // raygui: controls initialization\n");
|
fprintf(ftool, " // raygui: controls initialization\n");
|
||||||
fprintf(ftool, " //----------------------------------------------------------------------------------\n");
|
fprintf(ftool, " //----------------------------------------------------------------------------------\n");
|
||||||
fprintf(ftool, " // Anchor points\n");
|
fprintf(ftool, " // Anchor points\n");
|
||||||
fprintf(ftool, " Vector2 %s%02i = { 0, 0 };\n", "anchor", 0);
|
|
||||||
|
|
||||||
for(int i = 1; i < MAX_ANCHOR_POINTS; i++)
|
for(int i = 0; i < MAX_ANCHOR_POINTS; i++)
|
||||||
{
|
{
|
||||||
if (layout.anchors[i].x != 0 && layout.anchors[i].y != 0)
|
for (int j = 0; j < layout.controlsCount; j++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < layout.controlsCount; j++)
|
if (layout.controls[j].ap->id == layout.anchors[i].id)
|
||||||
{
|
{
|
||||||
if (layout.controls[j].ap->id == layout.anchors[i].id)
|
fprintf(ftool, " Vector2 %s%02i = { %i, %i };\n", "anchor", i, layout.anchors[i].x, layout.anchors[i].y);
|
||||||
{
|
break;
|
||||||
fprintf(ftool, " Vector2 %s%02i = { %i, %i };\n", "anchor", i, layout.anchors[i].x, layout.anchors[i].y);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1638,13 +1654,13 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
// Bools
|
// Bools
|
||||||
case WINDOWBOX:
|
case WINDOWBOX:
|
||||||
{
|
{
|
||||||
fprintf(ftool, " \n\t// %s: %s\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
fprintf(ftool, " \n\t// %s: %s\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
fprintf(ftool, " bool %sActive = true;\n", layout.controls[i].name);
|
fprintf(ftool, " bool %sActive = true;\n", layout.controls[i].name);
|
||||||
}
|
}
|
||||||
case TOGGLE:
|
case TOGGLE:
|
||||||
case CHECKBOX:
|
case CHECKBOX:
|
||||||
{
|
{
|
||||||
fprintf(ftool, " \n\t// %s: %s\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
fprintf(ftool, " \n\t// %s: %s\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
fprintf(ftool, " bool %s = false;\n", layout.controls[i].name);
|
fprintf(ftool, " bool %s = false;\n", layout.controls[i].name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1654,7 +1670,7 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
case LISTVIEW:
|
case LISTVIEW:
|
||||||
case TOGGLEGROUP:
|
case TOGGLEGROUP:
|
||||||
{
|
{
|
||||||
fprintf(ftool, " \n\t// %s: %s\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
fprintf(ftool, " \n\t// %s: %s\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
fprintf(ftool, " int %sCount = 3;\n", layout.controls[i].name);
|
fprintf(ftool, " int %sCount = 3;\n", layout.controls[i].name);
|
||||||
fprintf(ftool, " int %sActive = 0;\n", layout.controls[i].name);
|
fprintf(ftool, " int %sActive = 0;\n", layout.controls[i].name);
|
||||||
fprintf(ftool, " const char *%sList[3] = { \"ONE\", \"TWO\", \"THREE\" };\n", layout.controls[i].name);
|
fprintf(ftool, " const char *%sList[3] = { \"ONE\", \"TWO\", \"THREE\" };\n", layout.controls[i].name);
|
||||||
@ -1666,7 +1682,7 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
case SLIDERBAR:
|
case SLIDERBAR:
|
||||||
case PROGRESSBAR:
|
case PROGRESSBAR:
|
||||||
{
|
{
|
||||||
fprintf(ftool, " \n\t// %s: %s\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
fprintf(ftool, " \n\t// %s: %s\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
fprintf(ftool, " float %sValue = 50.0f;\n", layout.controls[i].name);
|
fprintf(ftool, " float %sValue = 50.0f;\n", layout.controls[i].name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1675,7 +1691,7 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
case VALUEBOX:
|
case VALUEBOX:
|
||||||
case SPINNER:
|
case SPINNER:
|
||||||
{
|
{
|
||||||
fprintf(ftool, " \n\t// %s: %s\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
fprintf(ftool, " \n\t// %s: %s\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
fprintf(ftool, " int %sValue = 0;\n", layout.controls[i].name);
|
fprintf(ftool, " int %sValue = 0;\n", layout.controls[i].name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1683,14 +1699,14 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
// Colors
|
// Colors
|
||||||
case COLORPICKER:
|
case COLORPICKER:
|
||||||
{
|
{
|
||||||
fprintf(ftool, " \n\t// %s: %s\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
fprintf(ftool, " \n\t// %s: %s\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
fprintf(ftool, " Color %sColor;\n", layout.controls[i].name);
|
fprintf(ftool, " Color %sColor;\n", layout.controls[i].name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TEXTBOX:
|
case TEXTBOX:
|
||||||
{
|
{
|
||||||
fprintf(ftool, " \n\t// %s: %s\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
fprintf(ftool, " \n\t// %s: %s\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
fprintf(ftool, " char %s[32] = \"%s\";\n", layout.controls[i].name, layout.controls[i].text);
|
fprintf(ftool, " char %s[32] = \"%s\";\n", layout.controls[i].name, layout.controls[i].text);
|
||||||
fprintf(ftool, " int %sSize = 32;\n", layout.controls[i].name);
|
fprintf(ftool, " int %sSize = 32;\n", layout.controls[i].name);
|
||||||
}
|
}
|
||||||
@ -1698,7 +1714,6 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(ftool, " //----------------------------------------------------------------------------------\n");
|
|
||||||
fprintf(ftool, "\n");
|
fprintf(ftool, "\n");
|
||||||
|
|
||||||
if (!noStaticData)
|
if (!noStaticData)
|
||||||
@ -1711,11 +1726,13 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
{
|
{
|
||||||
fprintf(ftool, " (Rectangle){ %s%02i%s + %i, %s%02i%s + %i, %i, %i }", "anchor", layout.controls[i].ap->id, ".x", layout.controls[i].rec.x, "anchor", layout.controls[i].ap->id, ".y", layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height);
|
fprintf(ftool, " (Rectangle){ %s%02i%s + %i, %s%02i%s + %i, %i, %i }", "anchor", layout.controls[i].ap->id, ".x", layout.controls[i].rec.x, "anchor", layout.controls[i].ap->id, ".y", layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height);
|
||||||
|
|
||||||
if (i == layout.controlsCount - 1) fprintf(ftool, "\t\t// %s: %s\n };\n\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
if (i == layout.controlsCount - 1) fprintf(ftool, "\t\t// %s: %s\n };\n\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
else fprintf(ftool, ",\t\t// %s: %s\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
else fprintf(ftool, ",\t\t// %s: %s\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(ftool, " //----------------------------------------------------------------------------------\n");
|
||||||
|
|
||||||
fprintf(ftool, " SetTargetFPS(60);\n");
|
fprintf(ftool, " SetTargetFPS(60);\n");
|
||||||
fprintf(ftool, " //--------------------------------------------------------------------------------------\n\n");
|
fprintf(ftool, " //--------------------------------------------------------------------------------------\n\n");
|
||||||
fprintf(ftool, " // Main game loop\n");
|
fprintf(ftool, " // Main game loop\n");
|
||||||
@ -1757,7 +1774,7 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
case WINDOWBOX:
|
case WINDOWBOX:
|
||||||
{
|
{
|
||||||
fprintf(ftool, "\t\t\tif (%sActive)\n\t\t\t{\n", layout.controls[i].name);
|
fprintf(ftool, "\t\t\tif (%sActive)\n\t\t\t{\n", layout.controls[i].name);
|
||||||
fprintf(ftool, "\t\t\t\t%sActive = GuiWindowBox((Rectangle){ %s%02i%s + %i, %s%02i%s + %i, %i, %i }, \"%s\");\n", layout.controls[i].name, "anchor", layout.controls[i].ap->id, ".x", layout.controls[i].rec.x, "anchor", layout.controls[i].ap->id, ".y", layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height, layout.controls[i].text);
|
fprintf(ftool, "\t\t\t\t%sActive = !GuiWindowBox((Rectangle){ %s%02i%s + %i, %s%02i%s + %i, %i, %i }, \"%s\");\n", layout.controls[i].name, "anchor", layout.controls[i].ap->id, ".x", layout.controls[i].rec.x, "anchor", layout.controls[i].ap->id, ".y", layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height, layout.controls[i].text);
|
||||||
fprintf(ftool, "\t\t\t}\n");
|
fprintf(ftool, "\t\t\t}\n");
|
||||||
}break;
|
}break;
|
||||||
case DUMMYREC: fprintf(ftool, "\t\t\tGuiDummyRec((Rectangle){ %s%02i%s + %i, %s%02i%s + %i, %i, %i }, \"%s\");\n", "anchor", layout.controls[i].ap->id, ".x", layout.controls[i].rec.x, "anchor", layout.controls[i].ap->id, ".y", layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height, layout.controls[i].text); break;
|
case DUMMYREC: fprintf(ftool, "\t\t\tGuiDummyRec((Rectangle){ %s%02i%s + %i, %s%02i%s + %i, %i, %i }, \"%s\");\n", "anchor", layout.controls[i].ap->id, ".x", layout.controls[i].rec.x, "anchor", layout.controls[i].ap->id, ".y", layout.controls[i].rec.y, layout.controls[i].rec.width, layout.controls[i].rec.height, layout.controls[i].text); break;
|
||||||
@ -1792,7 +1809,7 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
case WINDOWBOX:
|
case WINDOWBOX:
|
||||||
{
|
{
|
||||||
fprintf(ftool, "\t\t\tif (%sActive)\n\t\t\t{\n", layout.controls[i].name);
|
fprintf(ftool, "\t\t\tif (%sActive)\n\t\t\t{\n", layout.controls[i].name);
|
||||||
fprintf(ftool, "\t\t\t%sActive = GuiWindowBox(layoutRecs[%i], \"%s\");\n", layout.controls[i].name, i, layout.controls[i].text);
|
fprintf(ftool, "\t\t\t\t%sActive = !GuiWindowBox(layoutRecs[%i], \"%s\");\n", layout.controls[i].name, i, layout.controls[i].text);
|
||||||
fprintf(ftool, "\t\t\t}\n");
|
fprintf(ftool, "\t\t\t}\n");
|
||||||
}break;
|
}break;
|
||||||
case DUMMYREC: fprintf(ftool, "\t\t\tGuiDummyRec(layoutRecs[%i], \"%s\");\n", i, layout.controls[i].text); break;
|
case DUMMYREC: fprintf(ftool, "\t\t\tGuiDummyRec(layoutRecs[%i], \"%s\");\n", i, layout.controls[i].text); break;
|
||||||
@ -1823,7 +1840,7 @@ static void GenerateCode(const char *fileName , bool noStaticData)
|
|||||||
{
|
{
|
||||||
if (layout.controls[i].type == BUTTON)
|
if (layout.controls[i].type == BUTTON)
|
||||||
{
|
{
|
||||||
fprintf(ftool, "// %s: %s logic\n", controlTypeName[layout.controls[i].type], layout.controls[i].name);
|
fprintf(ftool, "// %s: %s logic\n", controlTypeNameLow[layout.controls[i].type], layout.controls[i].name);
|
||||||
fprintf(ftool, "static void %s()\n{\n // TODO: Implement control logic\n}\n\n", layout.controls[i].name);
|
fprintf(ftool, "static void %s()\n{\n // TODO: Implement control logic\n}\n\n", layout.controls[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user