raylibtech / rtools

rtools feedback and issues
17 stars 1 forks source link

[rGuiLayout] Exporting Anchors isn't functional #14

Closed Andidy closed 2 years ago

Andidy commented 2 years ago

When I check export anchors it modifies the code that defines the position of the control. However, it doesn't create the variable for the anchor.

Here is my control: image

Here is the generated code, Note that the declaration of anchor01 isn't present, (I removed the comments to make the code smaller but none of the actual code):

#include "raylib.h"

#define RAYGUI_IMPLEMENTATION
#include "raygui.h"

static void Button000();

int main()
{
    int screenWidth = 800;
    int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "my_layout");

    // my_layout: controls initialization
    //----------------------------------------------------------------------------------
    const char *Button000Text = "Spawn Entity";

    Rectangle layoutRecs[1] = {
        (Rectangle){ anchor01.x + 10, anchor01.y + 10, 125, 30 },
    };
    //----------------------------------------------------------------------------------

    SetTargetFPS(60);
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        BeginDrawing();
            ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); 

            if (GuiButton(layoutRecs[0], Button000Text)) Button000(); 
        EndDrawing();
    }
    CloseWindow();        // Close window and OpenGL context

    return 0;
}

static void Button000()
{
    // TODO: Implement control logic
}
Andidy commented 2 years ago

Perhaps this is because I'm using the ZERO / free version? I am using v2.1 ZERO to be specific.

Andidy commented 2 years ago

A similar export issue occurs with the ValueBox's text parameter.

if (GuiValueBox(layoutRecs[1], ValueBOx001Text /* <- This isn't declared */, &ValueBOx001Value, 0, 100, ValueBOx001EditMode)) ValueBOx001EditMode = !ValueBOx001EditMode;
raysan5 commented 2 years ago

@Andidy I can't remember exactly right now but I think there was an option to export anchors.

Andidy commented 2 years ago

@Andidy I can't remember exactly right now but I think there was an option to export anchors.

Yes, sorry I should have been more clear. I did check the "Export Anchors" button and this did add a Vector2 called "anchor01" to be the anchor point in the code for setting the position of the controls. image

However the variable used is not automatically declared anywhere. There isn't a line generated that says something like

Vector2 anchor01 = { 0, 0 };
raysan5 commented 2 years ago

Reviewed.