Skip to content

Commit

Permalink
ruis::rect
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Gagis committed Feb 14, 2024
1 parent e54e0ae commit ccf232b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/ruisapp/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/ruisapp/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class application : public utki::intrusive_singleton<application>
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
Expand All @@ -157,9 +158,9 @@ class application : public utki::intrusive_singleton<application>

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<float>& pos, unsigned id)
Expand Down
4 changes: 2 additions & 2 deletions src/ruisapp/glue/android/glue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ruis::real>()));
this->update_window_rect(ruis::rect(ruis::vector2(0), win_size.to<ruis::real>()));
}

std::unique_ptr<papki::file> ruisapp::application::get_res_file(const std::string& path) const
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/ruisapp/glue/friend_accessors.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ruisapp/glue/ios/glue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ - (void)touchesCancelled:(NSSet<UITouch *> *)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),
Expand All @@ -269,7 +269,7 @@ - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}

update_window_rect(
ruis::rectangle(
ruis::rect(
ruis::vector2(0),
ruis::vector2(
round(w.frame.size.width * scale),
Expand Down
4 changes: 2 additions & 2 deletions src/ruisapp/glue/linux/glue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/ruisapp/glue/macosx/glue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<const NSString*>(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);
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions src/ruisapp/glue/windows/glue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ccf232b

Please sign in to comment.