stellarlib 0.1.0
Loading...
Searching...
No Matches
window.hpp
1/* clang-format off */
2
3/*
4 stellarlib
5 Copyright (C) 2025-2026 Domán Zana
6
7 This software is provided 'as-is', without any express or implied
8 warranty. In no event will the authors be held liable for any damages
9 arising from the use of this software.
10
11 Permission is granted to anyone to use this software for any purpose,
12 including commercial applications, and to alter it and redistribute it
13 freely, subject to the following restrictions:
14
15 1. The origin of this software must not be misrepresented; you must not
16 claim that you wrote the original software. If you use this software
17 in a product, an acknowledgment in the product documentation would be
18 appreciated but is not required.
19 2. Altered source versions must be plainly marked as such, and must not be
20 misrepresented as being the original software.
21 3. This notice may not be removed or altered from any source distribution.
22*/
23
24#ifndef STELLARLIB_APP_WINDOW_HPP
25#define STELLARLIB_APP_WINDOW_HPP
26
27#include <stellarlib/app/lifecycle.hpp>
28
29#include <SDL3/SDL_events.h>
30#include <SDL3/SDL_video.h>
31
32#include <memory>
33#include <string>
34
35/**
36 * @brief Application runtime
37 */
38namespace stellarlib::app
39{
40/**
41 * @brief Window subsystem
42 */
43class window final
44{
45friend internal::lifecycle<class context>;
46
47public:
48 /**
49 * @brief Window initialization descriptor
50 */
51 struct info final
52 {
53 /**
54 * @brief Title of the window
55 */
56 std::string title;
57 };
58
59 /**
60 * @brief Deleted copy constructor
61 */
62 [[nodiscard]]
63 constexpr window(const window &) noexcept = delete;
64
65 /**
66 * @brief Deleted move constructor
67 */
68 [[nodiscard]]
69 constexpr window(window &&) noexcept = delete;
70
71 /**
72 * @brief Deleted copy assignment operator
73 */
74 constexpr auto operator=(const window &) noexcept
75 -> window & = delete;
76
77 /**
78 * @brief Deleted move assignment operator
79 */
80 constexpr auto operator=(window &&) noexcept
81 -> window & = delete;
82
83 /**
84 * @brief Destructor
85 */
87
88 /**
89 * @brief Returns the title of the window
90 * @return Title of the window
91 */
92 [[nodiscard]]
93 auto title() const
94 -> std::string;
95
96 /**
97 * @brief Sets the title of the window
98 * @param title Title of the window
99 */
100 void set_title(const std::string &title);
101
102private:
103 std::unique_ptr<SDL_Window, void (*)(SDL_Window *)> _handle{nullptr, nullptr};
104
105 [[nodiscard]]
106 explicit window(const info &info);
107
108 void iterate();
109
110 void event(const SDL_Event &event) const;
111};
112}
113
114#endif
auto title() const -> std::string
Returns the title of the window.
void set_title(const std::string &title)
Sets the title of the window.
constexpr window(window &&) noexcept=delete
Deleted move constructor.
constexpr window(const window &) noexcept=delete
Deleted copy constructor.
Application runtime.
Definition clock.hpp:33
context::info info
Main initialization descriptor.
Definition init.hpp:41
Window initialization descriptor.
Definition window.hpp:52
std::string title
Title of the window.
Definition window.hpp:56