Skip to content

Commit 7b1451f

Browse files
committed
stuff
1 parent 43e5516 commit 7b1451f

3 files changed

Lines changed: 68 additions & 58 deletions

File tree

src/ruisapp/glue/ios/glue.mm

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -84,49 +84,3 @@ int main(int argc, char * argv[]){
8484

8585
return ret;
8686
}
87-
88-
// void application::set_fullscreen(bool enable){
89-
// auto& ww = get_impl(this->window_pimpl);
90-
// UIWindow* w = ww.window;
91-
92-
// float scale = [[UIScreen mainScreen] scale];
93-
94-
// using std::round;
95-
96-
// if(enable){
97-
// if( [[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f ) {
98-
// CGRect rect = w.frame;
99-
// w.rootViewController.view.frame = rect;
100-
// }
101-
// update_window_rect(
102-
// ruis::rect(
103-
// ruis::vector2(0),
104-
// ruis::vector2(
105-
// round(w.frame.size.width * scale),
106-
// round(w.frame.size.height * scale)
107-
// )
108-
// )
109-
// );
110-
// w.windowLevel = UIWindowLevelStatusBar;
111-
// }else{
112-
// CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
113-
114-
// if( [[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f ) {
115-
// CGRect rect = w.frame;
116-
// rect.origin.y += statusBarSize.height;
117-
// rect.size.height -= statusBarSize.height;
118-
// w.rootViewController.view.frame = rect;
119-
// }
120-
121-
// update_window_rect(
122-
// ruis::rect(
123-
// ruis::vector2(0),
124-
// ruis::vector2(
125-
// round(w.frame.size.width * scale),
126-
// round((w.frame.size.height - statusBarSize.height) * scale)
127-
// )
128-
// )
129-
// );
130-
// w.windowLevel = UIWindowLevelNormal;
131-
// }
132-
// }

src/ruisapp/glue/ios/window.cxx

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,22 @@ void handle_mouse_move(
145145

146146
utki::assert(self->window, SL);
147147

148-
// TODO: for optimization, check if rect has changed
149-
// set the GL viewport
150-
self->window->gui.set_viewport(ruis::rect{
151-
{ ruis::real(rect.origin.x), ruis::real(rect.origin.y)},
152-
{ruis::real(rect.size.width), ruis::real(rect.size.height)}
153-
} // TODO: remove?
154-
// self->window->ruis_native_window.get().get_content_rect()
155-
);
148+
auto& natwin = self->window->ruis_native_window.get();
149+
150+
// TODO: get correct content rect
151+
auto content_rect = natwin.get_content_rect();
152+
// ruis::rect content_rect{
153+
// {ruis::real(rect.origin.x), ruis::real(rect.origin.y)},
154+
// {ruis::real(rect.size.width), ruis::real(rect.size.height)} //
155+
// };
156+
157+
// utki::log_debug([&](auto&o){
158+
// o << "content_rect = " << content_rect << std::endl;
159+
// });
160+
161+
// TODO: for optimization, check if rect has changed
162+
// set the GL viewport
163+
self->window->gui.set_viewport(content_rect);
156164

157165
auto& glue = get_glue();
158166
glue.render();
@@ -165,7 +173,6 @@ void handle_mouse_move(
165173
for (UITouch* touch in touches) {
166174
CGPoint p = [touch locationInView:self.view];
167175

168-
// TRACE(<< "touch began = " << ruis::Vec2r(p.x * scale, p.y * scale).rounded() << std::endl)
169176
using std::round;
170177
handle_mouse_button(
171178
true, // is_down
@@ -183,7 +190,6 @@ void handle_mouse_move(
183190
for (UITouch* touch in touches) {
184191
CGPoint p = [touch locationInView:self.view];
185192

186-
// TRACE(<< "touch moved = " << ruis::Vec2r(p.x * scale, p.y * scale).rounded() << std::endl)
187193
using std::round;
188194
handle_mouse_move(
189195
round(ruis::vector2(p.x * scale, p.y * scale)), // pos
@@ -199,7 +205,6 @@ void handle_mouse_move(
199205
for (UITouch* touch in touches) {
200206
CGPoint p = [touch locationInView:self.view];
201207

202-
// TRACE(<< "touch ended = " << ruis::Vec2r(p.x * scale, p.y * scale).rounded() << std::endl)
203208
using std::round;
204209
handle_mouse_button(
205210
false, // is_down
@@ -329,6 +334,55 @@ void native_window::bind_rendering_context()
329334
[EAGLContext setCurrentContext:this->ios_egl_context.context];
330335
}
331336

337+
void native_window::set_fullscreen_internal(bool enable)
338+
{
339+
float scale = [[UIScreen mainScreen] scale];
340+
341+
using std::round;
342+
343+
if(enable){
344+
if( [[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f ) {
345+
CGRect rect = this->ios_window.window.frame;
346+
this->ios_window.window.rootViewController.view.frame = rect;
347+
}
348+
349+
// TODO: this was setting the viewport, is something still needed here?
350+
// update_window_rect(
351+
// ruis::rect(
352+
// ruis::vector2(0),
353+
// ruis::vector2(
354+
// round(this->ios_window.window.frame.size.width * scale),
355+
// round(this->ios_window.window.frame.size.height * scale)
356+
// )
357+
// )
358+
// );
359+
360+
this->ios_window.window.windowLevel = UIWindowLevelStatusBar;
361+
}else{
362+
CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
363+
364+
if( [[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f ) {
365+
CGRect rect = this->ios_window.window.frame;
366+
rect.origin.y += statusBarSize.height;
367+
rect.size.height -= statusBarSize.height;
368+
this->ios_window.window.rootViewController.view.frame = rect;
369+
}
370+
371+
// TODO: this was setting the viewport, is something still needed here?
372+
// update_window_rect(
373+
// ruis::rect(
374+
// ruis::vector2(0),
375+
// ruis::vector2(
376+
// round(this->ios_window.window.frame.size.width * scale),
377+
// round((this->ios_window.window.frame.size.height - statusBarSize.height) * scale)
378+
// )
379+
// )
380+
// );
381+
382+
this->ios_window.window.windowLevel = UIWindowLevelNormal;
383+
}
384+
}
385+
332386
ruis::rect native_window::get_content_rect() const
333387
{
334388
UIWindow* w = this->ios_window.window;

src/ruisapp/glue/ios/window.hxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ public:
105105

106106
void bind_rendering_context() override;
107107

108-
ruis::rect get_content_rect() const;
108+
void set_fullscreen_internal(bool enable) override;
109+
110+
ruis::rect get_content_rect() const;
109111
};
110112
} // namespace

0 commit comments

Comments
 (0)