From ccf232b65b25f6fbc58fe69853e060643ee288f9 Mon Sep 17 00:00:00 2001 From: Ivan Gagis Date: Wed, 14 Feb 2024 12:55:09 +0200 Subject: [PATCH] ruis::rect --- src/ruisapp/application.cpp | 2 +- src/ruisapp/application.hpp | 7 ++++--- src/ruisapp/glue/android/glue.cxx | 4 ++-- src/ruisapp/glue/friend_accessors.cxx | 2 +- src/ruisapp/glue/ios/glue.mm | 4 ++-- src/ruisapp/glue/linux/glue.cxx | 4 ++-- src/ruisapp/glue/macosx/glue.mm | 6 +++--- src/ruisapp/glue/windows/glue.cxx | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/ruisapp/application.cpp b/src/ruisapp/application.cpp index 6994edd..182132a 100644 --- a/src/ruisapp/application.cpp +++ b/src/ruisapp/application.cpp @@ -41,7 +41,7 @@ void application::render() this->swap_frame_buffers(); } -void application::update_window_rect(const ruis::rectangle& rect) +void application::update_window_rect(const ruis::rect& rect) { if (this->curWinRect == rect) { return; diff --git a/src/ruisapp/application.hpp b/src/ruisapp/application.hpp index b2451a8..d870235 100644 --- a/src/ruisapp/application.hpp +++ b/src/ruisapp/application.hpp @@ -144,7 +144,8 @@ class application : public utki::intrusive_singleton private: // this is a viewport rectangle in coordinates that are as follows: x grows // right, y grows up. - ruis::rectangle curWinRect = ruis::rectangle(0, 0, 0, 0); + // TODO: naming convention + ruis::rect curWinRect = {0, 0, 0, 0}; public: const ruis::vector2& window_dims() const noexcept @@ -157,9 +158,9 @@ class application : public utki::intrusive_singleton friend void render(application& app); - void update_window_rect(const ruis::rectangle& rect); + void update_window_rect(const ruis::rect& rect); - friend void update_window_rect(application& app, const ruis::rectangle& rect); + friend void update_window_rect(application& app, const ruis::rect& rect); // pos is in usual window coordinates, y goes down. void handle_mouse_move(const r4::vector2& pos, unsigned id) diff --git a/src/ruisapp/glue/android/glue.cxx b/src/ruisapp/glue/android/glue.cxx index 2b4f739..b7d34a9 100644 --- a/src/ruisapp/glue/android/glue.cxx +++ b/src/ruisapp/glue/android/glue.cxx @@ -1122,7 +1122,7 @@ ruisapp::application::application(std::string name, const window_params& wp) : storage_dir(initialize_storage_dir(this->name)) { auto win_size = get_impl(*this).get_window_size(); - this->update_window_rect(ruis::rectangle(ruis::vector2(0), win_size.to())); + this->update_window_rect(ruis::rect(ruis::vector2(0), win_size.to())); } std::unique_ptr ruisapp::application::get_res_file(const std::string& path) const @@ -1738,7 +1738,7 @@ void on_content_rect_changed(ANativeActivity* activity, const ARect* rect) update_window_rect( app, - ruis::rectangle( + ruis::rect( float(rect->left), cur_window_dims.y() - float(rect->bottom), float(rect->right - rect->left), diff --git a/src/ruisapp/glue/friend_accessors.cxx b/src/ruisapp/glue/friend_accessors.cxx index 09b0570..0ddccd8 100644 --- a/src/ruisapp/glue/friend_accessors.cxx +++ b/src/ruisapp/glue/friend_accessors.cxx @@ -31,7 +31,7 @@ void render(application& app) app.render(); } -void update_window_rect(application& app, const ruis::rectangle& rect) +void update_window_rect(application& app, const ruis::rect& rect) { app.update_window_rect(rect); } diff --git a/src/ruisapp/glue/ios/glue.mm b/src/ruisapp/glue/ios/glue.mm index 6536f91..c85ca8f 100644 --- a/src/ruisapp/glue/ios/glue.mm +++ b/src/ruisapp/glue/ios/glue.mm @@ -249,7 +249,7 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ w.rootViewController.view.frame = rect; } update_window_rect( - ruis::rectangle( + ruis::rect( ruis::vector2(0), ruis::vector2( round(w.frame.size.width * scale), @@ -269,7 +269,7 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ } update_window_rect( - ruis::rectangle( + ruis::rect( ruis::vector2(0), ruis::vector2( round(w.frame.size.width * scale), diff --git a/src/ruisapp/glue/linux/glue.cxx b/src/ruisapp/glue/linux/glue.cxx index 65094fc..fb6e5af 100644 --- a/src/ruisapp/glue/linux/glue.cxx +++ b/src/ruisapp/glue/linux/glue.cxx @@ -910,7 +910,7 @@ application::application(std::string name, const window_params& wp) : #ifdef RUISAPP_RASPBERRYPI this->set_fullscreen(true); #else - this->update_window_rect(ruis::rectangle(0, 0, ruis::real(wp.dims.x()), ruis::real(wp.dims.y()))); + this->update_window_rect(ruis::rect(0, 0, ruis::real(wp.dims.x()), ruis::real(wp.dims.y()))); #endif } @@ -1459,7 +1459,7 @@ int main(int argc, const char** argv) } if (new_win_dims.is_positive_or_zero()) { - update_window_rect(*app, ruis::rectangle(0, new_win_dims)); + update_window_rect(*app, ruis::rect(0, new_win_dims)); } render(*app); diff --git a/src/ruisapp/glue/macosx/glue.mm b/src/ruisapp/glue/macosx/glue.mm index e5a54f1..9fd118a 100644 --- a/src/ruisapp/glue/macosx/glue.mm +++ b/src/ruisapp/glue/macosx/glue.mm @@ -150,7 +150,7 @@ void macosx_HandleCharacterInput(const void* nsstring, ruis::key key){ handle_character_input(ruisapp::application::inst(), macosx_input_string_provider(reinterpret_cast(nsstring)), key); } -void macosx_UpdateWindowRect(const ruis::rectangle& r){ +void macosx_UpdateWindowRect(const ruis::rect& r){ auto& ww = get_impl(get_window_pimpl(ruisapp::application::inst())); [ww.openglContextId update];//after resizing window we need to update OpenGL context update_window_rect(ruisapp::application::inst(), r); @@ -592,7 +592,7 @@ -(void)windowDidResize:(NSNotification*)n{ NSWindow* nsw = [n object]; NSRect frame = [nsw frame]; NSRect rect = [nsw contentRectForFrameRect:frame]; - macosx_UpdateWindowRect(ruis::rectangle(0, 0, rect.size.width, rect.size.height)); + macosx_UpdateWindowRect(ruis::rect(0, 0, rect.size.width, rect.size.height)); } -(NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize{ @@ -837,7 +837,7 @@ int main(int argc, const char** argv){ { LOG([&](auto&o){o << "application::application(): enter" << std::endl;}) this->update_window_rect( - ruis::rectangle( + ruis::rect( 0, 0, ruis::real(wp.dims.x()), diff --git a/src/ruisapp/glue/windows/glue.cxx b/src/ruisapp/glue/windows/glue.cxx index a98e485..32d10bc 100644 --- a/src/ruisapp/glue/windows/glue.cxx +++ b/src/ruisapp/glue/windows/glue.cxx @@ -605,7 +605,7 @@ LRESULT CALLBACK window_procedure(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_ case WM_SIZE: // resize GL, LoWord=Width, HiWord=Height - update_window_rect(ruisapp::inst(), ruis::rectangle(0, 0, float(LOWORD(l_param)), float(HIWORD(l_param)))); + update_window_rect(ruisapp::inst(), ruis::rect(0, 0, float(LOWORD(l_param)), float(HIWORD(l_param)))); return 0; case WM_USER: @@ -716,7 +716,7 @@ application::application(std::string name, const window_params& wp) : storage_dir(initialize_storage_dir(this->name)), curWinRect(0, 0, -1, -1) { - this->update_window_rect(ruis::rectangle(0, 0, ruis::real(wp.dims.x()), ruis::real(wp.dims.y()))); + this->update_window_rect(ruis::rect(0, 0, ruis::real(wp.dims.x()), ruis::real(wp.dims.y()))); } void application::quit() noexcept