MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Window.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::Vruta {
6class EventSource;
7}
8
9namespace MayaFlux::Buffers {
10class VKBuffer;
11}
12
13namespace MayaFlux::Core {
14
15/**
16 * @class Window
17 * @brief Platform-agnostic window wrapper
18 *
19 * Wraps a window (provided via a backend) and provides a unified interface
20 * for window management, event handling, and state tracking.
21 */
22class MAYAFLUX_API Window {
23public:
24 virtual ~Window() = default;
25
26 /**
27 * @brief Show the window
28 */
29 virtual void show() = 0;
30
31 /**
32 * @brief Hide the window
33 */
34 virtual void hide() = 0;
35
36 /**
37 * @brief Destroy the window and release resources
38 */
39 virtual void destroy() = 0;
40
41 /**
42 * @brief Poll for window events (non-blocking)
43 */
44 [[nodiscard]] virtual bool should_close() const = 0;
45
46 /**
47 * @brief Get the current window state
48 */
49 [[nodiscard]] virtual const WindowState& get_state() const = 0;
50
51 /*
52 * @brief Get the window creation parameters
53 */
54 [[nodiscard]] virtual const WindowCreateInfo& get_create_info() const = 0;
55
56 /**
57 * @brief Set input configuration (keyboard, mouse, cursor)
58 * @param config Input configuration settings
59 */
60 virtual void set_input_config(const InputConfig& config) = 0;
61
62 /**
63 * @brief Get current input configuration
64 * @return Current input configuration settings
65 */
66 [[nodiscard]] virtual const InputConfig& get_input_config() const = 0;
67
68 /**
69 * @brief Set the callback function for window events
70 * @param callback Function to be called on window events
71 */
72 virtual void set_event_callback(WindowEventCallback callback) = 0;
73
74 /**
75 * @brief Get native window handle (platform-specific)
76 * @return Pointer to the native window handle
77 */
78 [[nodiscard]] virtual void* get_native_handle() const = 0;
79
80 /**
81 * @brief Get native display handle (platform-specific)
82 * @return Pointer to the native display handle
83 */
84 [[nodiscard]] virtual void* get_native_display() const = 0;
85
86 /**
87 * @brief Set window title, size, or position
88 * @param title New window title
89 */
90 virtual void set_title(const std::string& title) = 0;
91
92 /**
93 * @brief Resize the window
94 * @param width New window width
95 * @param height New window height
96 */
97 virtual void set_size(uint32_t width, uint32_t height) = 0;
98
99 /**
100 * @brief Move the window to a new position
101 * @param x New X coordinate
102 * @param y New Y coordinate
103 */
104 virtual void set_position(uint32_t x, uint32_t y) = 0;
105
106 /**
107 * @brief Gets the event source for awaiting events
108 */
109 [[nodiscard]] virtual Vruta::EventSource& get_event_source() = 0;
110 [[nodiscard]] virtual const Vruta::EventSource& get_event_source() const = 0;
111
112 /**
113 * @brief Check if window is registered with graphics subsystem
114 */
115 [[nodiscard]] virtual bool is_graphics_registered() const = 0;
116
117 /**
118 * @brief Mark window as registered/unregistered with graphics
119 * Called by GraphicsSubsystem during register/unregister
120 */
121 virtual void set_graphics_registered(bool registered) = 0;
122
123 /**
124 * @brief Register a VKBuffer as rendering to this window
125 * @param buffer Buffer that will render to this window
126 *
127 * Used for tracking and queries. Does not affect rendering directly.
128 */
129 virtual void register_rendering_buffer(std::shared_ptr<Buffers::VKBuffer> buffer) = 0;
130
131 /**
132 * @brief Unregister a VKBuffer from this window
133 * @param buffer Buffer to unregister
134 */
135 virtual void unregister_rendering_buffer(std::shared_ptr<Buffers::VKBuffer> buffer) = 0;
136
137 /**
138 * @brief Track a secondary command buffer for this frame
139 * @param cmd_id Command buffer ID that contains draw commands for this window
140 *
141 * Called by RenderProcessor after recording. PresentProcessor queries these
142 * to know which secondary buffers to execute.
143 */
144 virtual void track_frame_command(uint64_t cmd_id) = 0;
145
146 /**
147 * @brief Get all command buffers recorded for this frame
148 * @return Vector of command buffer IDs
149 *
150 * Called by PresentProcessor to collect secondary buffers for execution.
151 */
152 [[nodiscard]] virtual const std::vector<uint64_t>& get_frame_commands() const = 0;
153
154 /**
155 * @brief Clear tracked commands for this frame
156 *
157 * Called after presenting to reset for next frame.
158 */
159 virtual void clear_frame_commands() = 0;
160
161 /**
162 * @brief Get all VKBuffers currently rendering to this window
163 * @return Vector of buffers (weak_ptr to avoid ownership issues)
164 */
165 [[nodiscard]] virtual std::vector<std::shared_ptr<Buffers::VKBuffer>> get_rendering_buffers() const = 0;
166};
167}
virtual void unregister_rendering_buffer(std::shared_ptr< Buffers::VKBuffer > buffer)=0
Unregister a VKBuffer from this window.
virtual void destroy()=0
Destroy the window and release resources.
virtual void register_rendering_buffer(std::shared_ptr< Buffers::VKBuffer > buffer)=0
Register a VKBuffer as rendering to this window.
virtual void set_input_config(const InputConfig &config)=0
Set input configuration (keyboard, mouse, cursor)
virtual const Vruta::EventSource & get_event_source() const =0
virtual void * get_native_display() const =0
Get native display handle (platform-specific)
virtual void track_frame_command(uint64_t cmd_id)=0
Track a secondary command buffer for this frame.
virtual ~Window()=default
virtual void set_graphics_registered(bool registered)=0
Mark window as registered/unregistered with graphics Called by GraphicsSubsystem during register/unre...
virtual void set_event_callback(WindowEventCallback callback)=0
Set the callback function for window events.
virtual const WindowCreateInfo & get_create_info() const =0
virtual void hide()=0
Hide the window.
virtual void set_title(const std::string &title)=0
Set window title, size, or position.
virtual void * get_native_handle() const =0
Get native window handle (platform-specific)
virtual Vruta::EventSource & get_event_source()=0
Gets the event source for awaiting events.
virtual void clear_frame_commands()=0
Clear tracked commands for this frame.
virtual void set_size(uint32_t width, uint32_t height)=0
Resize the window.
virtual std::vector< std::shared_ptr< Buffers::VKBuffer > > get_rendering_buffers() const =0
Get all VKBuffers currently rendering to this window.
virtual bool is_graphics_registered() const =0
Check if window is registered with graphics subsystem.
virtual const WindowState & get_state() const =0
Get the current window state.
virtual const InputConfig & get_input_config() const =0
Get current input configuration.
virtual void show()=0
Show the window.
virtual const std::vector< uint64_t > & get_frame_commands() const =0
Get all command buffers recorded for this frame.
virtual void set_position(uint32_t x, uint32_t y)=0
Move the window to a new position.
virtual bool should_close() const =0
Poll for window events (non-blocking)
Platform-agnostic window wrapper.
Definition Window.hpp:22
Awaitable event stream for window events.
std::function< void(const WindowEvent &)> WindowEventCallback
Input configuration for a window.
Configuration for creating a single window instance.
Runtime state of a window (mutable by system, read by user)