Skip to content

Move IS_DRAWING_BOUNDARY_BOX to User Configurable IMGUI Setting #18

@ecrinyildiz

Description

@ecrinyildiz

Description

The IS_DRAWING_BOUNDARY_BOX macro is currently hardcoded as true, making it a fixed compile-time setting. To provide more flexibility, this setting should be moved to a user-configurable IMGUI editor window, allowing users to enable or disable boundary box drawing dynamically at runtime.

Proposed Solution

1- Replace the macro #define IS_DRAWING_BOUNDARY_BOX true with a runtime-configurable variable.
2- Integrate IMGUI to create a checkbox setting in the UI editor.
3- Store the setting in a globally accessible configuration structure.

Suggested Implementation Plan

1- Create a Settings.h File

#ifndef SETTINGS_H
#define SETTINGS_H

namespace Settings
{
    extern bool isDrawingBoundaryBox; // 🔹 Global setting (default: true)
}

#endif // SETTINGS_H

2- Define the Setting in Settings.cpp

#include "Settings.h"

namespace Settings
{
    bool isDrawingBoundaryBox = true; // 🔹 Default to true
}

3- Modify LogicElementsDraw.h

#include "Settings.h"  // Include the settings file

namespace LogicElementsDraw
{
    void DrawBoundaryBox(const std::shared_ptr<LogicElements::LogicGate> gate);
}

4- Modify DrawBoundaryBox() in LogicElementsDraw.cpp

void LogicElementsDraw::DrawBoundaryBox(const std::shared_ptr<LogicElements::LogicGate> gate)
{
    if (!Settings::isDrawingBoundaryBox) return;  // ✅ Check setting before drawing

    DrawRectangleLinesEx(gate->getBoundingBox(), 2, RED);
}

5- Integrate IMGUI Setting (GUIXXX.cpp(use the correct file if already exist))

#include "Settings.h"
#include "imgui.h"

void RenderSettingsWindow()
{
    ImGui::Begin("Settings");

    // Checkbox for enabling/disabling boundary box
    ImGui::Checkbox("Draw Boundary Box", &Settings::isDrawingBoundaryBox);

    ImGui::End();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions