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 = false; // Disabled by default - causes issues on macOS Retina with SDL_Renderer
33};
34
59
65
66 // Window resize data
67 int window_width = 0;
69
70 // Keyboard data
71 int key_code = 0;
72 int scan_code = 0;
73 bool key_shift = false;
74 bool key_ctrl = false;
75 bool key_alt = false;
76 bool key_super = false;
77
78 // Mouse data
79 float mouse_x = 0.0f;
80 float mouse_y = 0.0f;
81 int mouse_button = 0;
82 float wheel_x = 0.0f;
83 float wheel_y = 0.0f;
84
85 // Drop file data
86 std::string dropped_file;
87
88 // Native event copy (SDL2/SDL3). Only valid when has_native_event is true.
89 bool has_native_event = false;
90 SDL_Event native_event{};
91};
92
97 bool is_active = true;
98 bool is_minimized = false;
99 bool is_maximized = false;
100 bool is_fullscreen = false;
101 bool is_focused = true;
102 bool is_resizing = false;
103 int width = 0;
104 int height = 0;
105};
106
115 public:
116 virtual ~IWindowBackend() = default;
117
118 // =========================================================================
119 // Lifecycle Management
120 // =========================================================================
121
127 virtual absl::Status Initialize(const WindowConfig& config) = 0;
128
133 virtual absl::Status Shutdown() = 0;
134
138 virtual bool IsInitialized() const = 0;
139
140 // =========================================================================
141 // Event Processing
142 // =========================================================================
143
149 virtual bool PollEvent(WindowEvent& out_event) = 0;
150
155 virtual void ProcessNativeEvent(void* native_event) = 0;
156
157 // =========================================================================
158 // Window State
159 // =========================================================================
160
164 virtual WindowStatus GetStatus() const = 0;
165
169 virtual bool IsActive() const = 0;
170
174 virtual void SetActive(bool active) = 0;
175
179 virtual void GetSize(int* width, int* height) const = 0;
180
184 virtual void SetSize(int width, int height) = 0;
185
189 virtual std::string GetTitle() const = 0;
190
194 virtual void SetTitle(const std::string& title) = 0;
195
196 // =========================================================================
197 // Renderer Integration
198 // =========================================================================
199
205 virtual bool InitializeRenderer(gfx::IRenderer* renderer) = 0;
206
211 virtual SDL_Window* GetNativeWindow() = 0;
212
213 // =========================================================================
214 // ImGui Integration
215 // =========================================================================
216
222 virtual absl::Status InitializeImGui(gfx::IRenderer* renderer) = 0;
223
227 virtual void ShutdownImGui() = 0;
228
232 virtual void NewImGuiFrame() = 0;
233
238 virtual void RenderImGui(gfx::IRenderer* renderer) = 0;
239
240 // =========================================================================
241 // Audio Support (Legacy compatibility)
242 // =========================================================================
243
247 virtual uint32_t GetAudioDevice() const = 0;
248
252 virtual std::shared_ptr<int16_t> GetAudioBuffer() const = 0;
253
254 // =========================================================================
255 // Backend Information
256 // =========================================================================
257
261 virtual std::string GetBackendName() const = 0;
262
266 virtual int GetSDLVersion() const = 0;
267};
268
273 SDL2,
274 SDL3,
275 Auto // Automatically select based on availability
276};
277
282 public:
288 static std::unique_ptr<IWindowBackend> Create(WindowBackendType type);
289
294
298 static bool IsAvailable(WindowBackendType type);
299};
300
301} // namespace platform
302} // namespace yaze
303
304#endif // YAZE_APP_PLATFORM_IWINDOW_H_
Defines an abstract interface for all rendering operations.
Definition irenderer.h:40
Abstract window backend interface.
Definition iwindow.h:114
virtual int GetSDLVersion() const =0
Get SDL version being used.
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 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:281
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:38
WindowBackendType
Backend type enumeration for factory.
Definition iwindow.h:272
SDL2/SDL3 compatibility layer.
Window configuration parameters.
Definition iwindow.h:24
Platform-agnostic window event data.
Definition iwindow.h:63
WindowEventType type
Definition iwindow.h:64
Window backend status information.
Definition iwindow.h:96