yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
iwindow.h
Go to the documentation of this file.
1// iwindow.h - Window Backend Abstraction Layer
2// Provides interface for swapping window implementations (SDL2, SDL3)
3
4#ifndef YAZE_APP_PLATFORM_IWINDOW_H_
5#define YAZE_APP_PLATFORM_IWINDOW_H_
6
7#include <cstdint>
8#include <memory>
9#include <string>
10
11#include "absl/status/status.h"
14
15// Forward declarations to avoid SDL header dependency in interface
16struct SDL_Window;
17
18namespace yaze {
19namespace platform {
20
25 std::string title = "Yet Another Zelda3 Editor";
26 int width = 0; // 0 means auto-detect from display
27 int height = 0; // 0 means auto-detect from display
28 float display_scale = 0.8f; // Percentage of display to use when auto-detect
29 bool resizable = true;
30 bool maximized = false;
31 bool fullscreen = false;
32 bool high_dpi =
33 false; // Disabled by default - causes issues on macOS Retina with SDL_Renderer
34 bool hidden = false; // Start window hidden (for service mode)
35};
36
61
67
68 // Window resize data
69 int window_width = 0;
71
72 // Keyboard data
73 int key_code = 0;
74 int scan_code = 0;
75 bool key_shift = false;
76 bool key_ctrl = false;
77 bool key_alt = false;
78 bool key_super = false;
79
80 // Mouse data
81 float mouse_x = 0.0f;
82 float mouse_y = 0.0f;
83 int mouse_button = 0;
84 float wheel_x = 0.0f;
85 float wheel_y = 0.0f;
86
87 // Drop file data
88 std::string dropped_file;
89
90 // Native event copy (SDL2/SDL3). Only valid when has_native_event is true.
91 bool has_native_event = false;
92 SDL_Event native_event{};
93};
94
99 bool is_active = true;
100 bool is_minimized = false;
101 bool is_maximized = false;
102 bool is_fullscreen = false;
103 bool is_focused = true;
104 bool is_resizing = false;
105 int width = 0;
106 int height = 0;
107};
108
117 public:
118 virtual ~IWindowBackend() = default;
119
120 // =========================================================================
121 // Lifecycle Management
122 // =========================================================================
123
129 virtual absl::Status Initialize(const WindowConfig& config) = 0;
130
135 virtual absl::Status Shutdown() = 0;
136
140 virtual bool IsInitialized() const = 0;
141
142 // =========================================================================
143 // Event Processing
144 // =========================================================================
145
151 virtual bool PollEvent(WindowEvent& out_event) = 0;
152
157 virtual void ProcessNativeEvent(void* native_event) = 0;
158
159 // =========================================================================
160 // Window State
161 // =========================================================================
162
166 virtual WindowStatus GetStatus() const = 0;
167
171 virtual bool IsActive() const = 0;
172
176 virtual void SetActive(bool active) = 0;
177
181 virtual void GetSize(int* width, int* height) const = 0;
182
186 virtual void SetSize(int width, int height) = 0;
187
191 virtual std::string GetTitle() const = 0;
192
196 virtual void SetTitle(const std::string& title) = 0;
197
201 virtual void ShowWindow() = 0;
202
206 virtual void HideWindow() = 0;
207
208 // =========================================================================
209 // Renderer Integration
210 // =========================================================================
211
217 virtual bool InitializeRenderer(gfx::IRenderer* renderer) = 0;
218
223 virtual SDL_Window* GetNativeWindow() = 0;
224
225 // =========================================================================
226 // ImGui Integration
227 // =========================================================================
228
234 virtual absl::Status InitializeImGui(gfx::IRenderer* renderer) = 0;
235
239 virtual void ShutdownImGui() = 0;
240
244 virtual void NewImGuiFrame() = 0;
245
250 virtual void RenderImGui(gfx::IRenderer* renderer) = 0;
251
252 // =========================================================================
253 // Audio Support (Legacy compatibility)
254 // =========================================================================
255
259 virtual uint32_t GetAudioDevice() const = 0;
260
264 virtual std::shared_ptr<int16_t> GetAudioBuffer() const = 0;
265
266 // =========================================================================
267 // Backend Information
268 // =========================================================================
269
273 virtual std::string GetBackendName() const = 0;
274
278 virtual int GetSDLVersion() const = 0;
279};
280
285 SDL2,
286 SDL3,
287 GLFW, // Reserved for future native multi-viewport backend
288 IOS,
289 Null, // Headless/Server mode
290 Auto // Automatically select based on availability
291};
292
297 public:
303 static std::unique_ptr<IWindowBackend> Create(WindowBackendType type);
304
309
313 static bool IsAvailable(WindowBackendType type);
314};
315
316} // namespace platform
317} // namespace yaze
318
319#endif // YAZE_APP_PLATFORM_IWINDOW_H_
Defines an abstract interface for all rendering operations.
Definition irenderer.h:60
Abstract window backend interface.
Definition iwindow.h:116
virtual int GetSDLVersion() const =0
Get SDL version being used.
virtual void ShowWindow()=0
Show the window.
virtual uint32_t GetAudioDevice() const =0
Get audio device ID (for legacy audio buffer management)
virtual absl::Status Shutdown()=0
Shutdown the window backend and release resources.
virtual void SetSize(int width, int height)=0
Set window dimensions.
virtual WindowStatus GetStatus() const =0
Get current window status.
virtual std::string GetTitle() const =0
Get window title.
virtual void GetSize(int *width, int *height) const =0
Get window dimensions.
virtual absl::Status Initialize(const WindowConfig &config)=0
Initialize the window backend with configuration.
virtual void ShutdownImGui()=0
Shutdown ImGui backends.
virtual bool PollEvent(WindowEvent &out_event)=0
Poll and process pending events.
virtual std::shared_ptr< int16_t > GetAudioBuffer() const =0
Get audio buffer (for legacy audio management)
virtual SDL_Window * GetNativeWindow()=0
Get the underlying SDL_Window pointer for ImGui integration.
virtual bool IsInitialized() const =0
Check if the backend is initialized.
virtual bool InitializeRenderer(gfx::IRenderer *renderer)=0
Initialize renderer for this window.
virtual absl::Status InitializeImGui(gfx::IRenderer *renderer)=0
Initialize ImGui backends for this window/renderer combo.
virtual void SetActive(bool active)=0
Set window active state.
virtual void ProcessNativeEvent(void *native_event)=0
Process a native SDL event (for ImGui integration)
virtual void RenderImGui(gfx::IRenderer *renderer)=0
Render ImGui draw data (and viewports if enabled)
virtual std::string GetBackendName() const =0
Get backend name for debugging/logging.
virtual void SetTitle(const std::string &title)=0
Set window title.
virtual ~IWindowBackend()=default
virtual void HideWindow()=0
Hide the window.
virtual void NewImGuiFrame()=0
Start a new ImGui frame.
virtual bool IsActive() const =0
Check if window is still active (not closed)
Factory for creating window backends.
Definition iwindow.h:296
static WindowBackendType GetDefaultType()
Get the default backend type for this build.
static std::unique_ptr< IWindowBackend > Create(WindowBackendType type)
Create a window backend of the specified type.
static bool IsAvailable(WindowBackendType type)
Check if a backend type is available.
WindowEventType
Window event types (platform-agnostic)
Definition iwindow.h:40
WindowBackendType
Backend type enumeration for factory.
Definition iwindow.h:284
SDL2/SDL3 compatibility layer.
Window configuration parameters.
Definition iwindow.h:24
Platform-agnostic window event data.
Definition iwindow.h:65
WindowEventType type
Definition iwindow.h:66
Window backend status information.
Definition iwindow.h:98