add more logging, use autolayout constraints to pin metal view to superview to support orientation changes easier

This commit is contained in:
Yoshi Sugawara 2020-07-14 17:49:38 -10:00
parent 82d6d8e876
commit 897aee0bcf
3 changed files with 25 additions and 7 deletions

View File

@ -500,6 +500,12 @@
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size
{
NSLog(@"mtkView drawableSizeWillChange to: %f x %f",size.width,size.height);
// due to autolayout constraints?
if (size.width == INFINITY || size.height == INFINITY) {
NSLog(@"mtkView drawableSizeWillChange width or height is inifinity, skipping...");
return;
}
[self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES];
}

View File

@ -31196,7 +31196,8 @@ bool video_driver_translate_coord_viewport(
int norm_vp_height = (int)vp->height;
int norm_full_vp_width = (int)vp->full_width;
int norm_full_vp_height = (int)vp->full_height;
printf("yoshi debug: video size: %i, %i full size: %i, %i \n",norm_vp_width,norm_vp_height,norm_full_vp_width,norm_full_vp_height);
printf("yoshi debug: video_driver_translate_coord_viewport: incoming mouse coord: %i,%i \n",mouse_x,mouse_y);
if (norm_vp_width <= 0 ||
norm_vp_height <= 0 ||
norm_full_vp_width <= 0 ||
@ -31234,7 +31235,7 @@ bool video_driver_translate_coord_viewport(
*res_y = scaled_y;
*res_screen_x = scaled_screen_x;
*res_screen_y = scaled_screen_y;
printf("yoshi debug: translated coordinates: res: (%i,%i) res_screen:(%i,%i) \n",scaled_x,scaled_y,scaled_screen_x,scaled_screen_y);
return true;
}

View File

@ -125,10 +125,11 @@ static void handle_touch_event(NSArray* touches)
CGPoint coord;
UITouch *touch = [touches objectAtIndex:i];
if (touch.view != [CocoaView get].view)
continue;
// if (touch.view != [CocoaView get].view)
// continue;
coord = [touch locationInView:[touch view]];
NSLog(@"yoshi debug: handle_touch_event: coord = %f,%f , scaled = %f,%f",coord.x,coord.y,coord.x*scale,coord.y*scale);
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled)
{
@ -365,8 +366,15 @@ enum
}
// _renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[_renderView setFrame:self.window.bounds];
[[CocoaView get].view addSubview:_renderView];
// [_renderView setFrame:self.window.bounds];
_renderView.translatesAutoresizingMaskIntoConstraints = NO;
UIView *rootView = [CocoaView get].view;
[rootView addSubview:_renderView];
[[_renderView.topAnchor constraintEqualToAnchor:rootView.topAnchor] setActive:YES];
[[_renderView.bottomAnchor constraintEqualToAnchor:rootView.bottomAnchor] setActive:YES];
[[_renderView.leadingAnchor constraintEqualToAnchor:rootView.leadingAnchor] setActive:YES];
[[_renderView.trailingAnchor constraintEqualToAnchor:rootView.trailingAnchor] setActive:YES];
// [self.window addSubview:_renderView];
// self.window.contentView.nextResponder = _listener;
@ -377,7 +385,10 @@ enum
}
- (void)setVideoMode:(gfx_ctx_mode_t)mode {
// no-op for iOS?
// hmm might need some scaling factor...
MetalView *metalView = (MetalView*) _renderView;
[metalView setDrawableSize:CGSizeMake(mode.width, mode.height)];
NSLog(@"setVideoMode set drawable size to %i x %i",mode.width,mode.height);
}
- (void)setCursorVisible:(bool)v {