Skip to content

Commit 5db7455

Browse files
committed
stuff
1 parent b48b3e9 commit 5db7455

File tree

3 files changed

+50
-13
lines changed

3 files changed

+50
-13
lines changed

src/ruis/render/native_window.hpp

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2424
#include <functional>
2525
#include <list>
2626

27+
#include <r4/vector.hpp>
28+
2729
#include "../util/mouse_cursor.hpp"
2830

2931
namespace ruis::render {
@@ -34,16 +36,23 @@ class native_window
3436
{
3537
friend class ruis::render::context;
3638

37-
bool is_fullscreen_v = false;
38-
3939
virtual void bind_rendering_context() {}
4040

41+
virtual bool is_rendering_context_bound() const noexcept
42+
{
43+
return false;
44+
}
45+
4146
virtual void set_fullscreen_internal(bool enable) {}
4247

4348
std::list<mouse_cursor> cursor_stack = {mouse_cursor::arrow};
4449

4550
virtual void set_mouse_cursor(ruis::mouse_cursor c) {}
4651

52+
bool is_fullscreen_v = false;
53+
bool is_maximized_v = false;
54+
bool is_minimized_v = false;
55+
4756
public:
4857
native_window() = default;
4958

@@ -55,25 +64,44 @@ class native_window
5564

5665
virtual ~native_window() = default;
5766

58-
// TODO: make private somehow?
67+
// ========================
68+
// = content presentation =
69+
5970
virtual void swap_frame_buffers() {}
6071

72+
virtual void set_vsync_enabled(bool enabled) noexcept {}
73+
74+
// =====================
75+
// = window dimensions =
76+
6177
void set_fullscreen(bool enable);
6278

6379
bool is_fullscreen() const noexcept
6480
{
6581
return this->is_fullscreen_v;
6682
}
6783

68-
// TODO: add set_maximized(bool) & is_maximized()
69-
// TODO: add set_minimized(bool) & is_minimized()
70-
// TODO: add set_hidden(bool) & is_hidden()
84+
virtual void set_maximized(bool maximized) noexcept {}
7185

72-
/**
73-
* @brief Handler of window close event.
74-
* Invoked when user tries to close the window, e.g. by clicking the window's close button.
75-
*/
76-
std::function<void()> close_handler;
86+
bool is_maximized() const noexcept
87+
{
88+
return this->is_maximized_v;
89+
}
90+
91+
virtual void set_minimized(bool minimized) noexcept {}
92+
93+
bool is_minimized() const noexcept
94+
{
95+
return this->is_minimized_v;
96+
}
97+
98+
virtual r4::vector2<unsigned> get_dims() const noexcept
99+
{
100+
return {0, 0};
101+
}
102+
103+
// does not guarantee exactly the requested dims will be set
104+
virtual void set_dims(const r4::vector2<unsigned> dims) const noexcept {}
77105

78106
// ================
79107
// = mouse cursor =
@@ -85,11 +113,20 @@ class native_window
85113

86114
virtual void set_mouse_cursor_visible(bool visible) {}
87115

116+
// =========
117+
// = other =
118+
88119
/**
89120
* @brief Show/hide the virtual keyboard.
90121
* On mobile platforms this function should show/hide the on-screen keyboard.
91122
* On desktop platforms with physical keyboard this funtion should do nothing.
92123
*/
93124
virtual void set_virtual_keyboard_visible(bool visible) noexcept {}
125+
126+
/**
127+
* @brief Handler of window close event.
128+
* Invoked when user tries to close the window, e.g. by clicking the window's close button.
129+
*/
130+
std::function<void()> close_handler;
94131
};
95132
} // namespace ruis::render

tests/app/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class application : public ruisapp::application{
9595
// std::shared_ptr<ruis::widget> c = ruis::gui::inst().inflater().Inflate(zf);
9696

9797
ASSERT(c.get().try_get_widget_as<ruis::push_button>("show_VK_button"))
98-
std::dynamic_pointer_cast<ruis::push_button>(c.get().try_get_widget("show_VK_button"))->click_handler = [this](ruis::push_button& b){
98+
std::dynamic_pointer_cast<ruis::push_button>(c.get().try_get_widget("show_VK_button"))->click_handler = [](ruis::push_button& b){
9999
b.context.get().window().set_virtual_keyboard_visible(true);
100100
};
101101

0 commit comments

Comments
 (0)