- Introduced support for multiple windows, sharing the primary editor's buffer list. - Added `GUIFrontend::OpenNewWindow_` for creating secondary windows with independent dimensions and input handlers. - Redesigned `WindowState` to encapsulate per-window attributes (dimensions, renderer, input, etc.). - Updated input processing and command execution to route events based on active window, preserving window-level states. - Enhanced SDL2 and ImGui integration for proper context management across multiple windows. - Increased robustness by handling window closing, resizing, and cleanup of secondary windows without affecting the primary editor. - Updated documentation and key bindings for multi-window operations (e.g., Cmd+N / Ctrl+Shift+N). - Version updated to 1.8.0 to reflect the major GUI enhancement.
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
/*
|
|
* GUIFrontend - couples ImGuiInputHandler + GUIRenderer and owns SDL2/ImGui lifecycle
|
|
*/
|
|
#pragma once
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "Frontend.h"
|
|
#include "GUIConfig.h"
|
|
#include "ImGuiInputHandler.h"
|
|
#include "ImGuiRenderer.h"
|
|
#include "Editor.h"
|
|
|
|
|
|
struct SDL_Window;
|
|
typedef void *SDL_GLContext;
|
|
|
|
class GUIFrontend final : public Frontend {
|
|
public:
|
|
GUIFrontend() = default;
|
|
|
|
~GUIFrontend() override = default;
|
|
|
|
bool Init(int &argc, char **argv, Editor &ed) override;
|
|
|
|
void Step(Editor &ed, bool &running) override;
|
|
|
|
void Shutdown() override;
|
|
|
|
private:
|
|
// Per-window state
|
|
struct WindowState {
|
|
SDL_Window *window = nullptr;
|
|
SDL_GLContext gl_ctx = nullptr;
|
|
ImGuiInputHandler input{};
|
|
ImGuiRenderer renderer{};
|
|
Editor editor{};
|
|
int width = 1280;
|
|
int height = 800;
|
|
bool alive = true;
|
|
};
|
|
|
|
// Open a new secondary window sharing the primary editor's buffer list.
|
|
// Returns false if window creation fails.
|
|
bool OpenNewWindow_(Editor &primary);
|
|
|
|
static bool LoadGuiFont_(const char *path, float size_px);
|
|
|
|
GUIConfig config_{};
|
|
// Primary window (index 0 in windows_); created during Init.
|
|
std::vector<std::unique_ptr<WindowState> > windows_;
|
|
}; |