[REPL] Take orientation into account when offsetting thick borders.

This commit is contained in:
Eloy Durán
2013-11-08 18:36:59 +01:00
parent 3bc3ecdad3
commit dceb65c6f2
2 changed files with 27 additions and 64 deletions

View File

@@ -424,40 +424,40 @@ get_app_windows_bounds(void)
// iPad Retina | 1704x2216 (TODO This is the screenshot!)
// -----------------------------------------------------------
// TODO
// * support landscape
// * check on Retina mac
int w = (int)CGRectGetWidth(bounds);
int h = (int)CGRectGetHeight(bounds);
// NSLog(@"W: %d H: %d", w, h);
bool landscape = w > h;
bool found_thick_border = false;
#define MATCHES_FRAME(ww,hh) (landscape ? (w == hh && h == ww) : (w == ww && h == hh))
#define UPDATE_BOUNDS(x_delta, y_delta, width, height) \
if (landscape) { \
bounds.origin.y += x_delta; \
bounds.origin.x += y_delta; \
bounds.size = CGSizeMake(height, width); \
} else { \
bounds.origin.x += x_delta; \
bounds.origin.y += y_delta; \
bounds.size = CGSizeMake(width, height); \
} \
found_thick_border = true;
if (simulator_device_family == DEVICE_FAMILY_IPHONE) {
if (simulator_retina_type == DEVICE_RETINA_FALSE && w == 368 && h == 716) {
NSLog(@"DEVICE WITH THICK BORDERS: Original iPhone");
bounds.origin.x += 25;
bounds.origin.y += 121;
bounds.size = CGSizeMake(320, 480);
found_thick_border = true;
} else if (simulator_retina_type == DEVICE_RETINA_3_5 && w == 724 && h == 1044) {
NSLog(@"DEVICE WITH THICK BORDERS: iPhone Retina 3.5");
bounds.origin.x += 42;
bounds.origin.y += 44;
bounds.size = CGSizeMake(640, 960);
found_thick_border = true;
} else if (simulator_retina_type == DEVICE_RETINA_4 && w == 724 && h == 1220) {
NSLog(@"DEVICE WITH THICK BORDERS: iPhone Retina 4");
bounds.origin.x += 42;
bounds.origin.y += 44;
bounds.size = CGSizeMake(640, 1136);
found_thick_border = true;
if (simulator_retina_type == DEVICE_RETINA_FALSE && MATCHES_FRAME(368, 716)) {
UPDATE_BOUNDS(25, 121, 320, 480);
} else if (simulator_retina_type == DEVICE_RETINA_3_5 && MATCHES_FRAME(724, 1044)) {
UPDATE_BOUNDS(42, 44, 640, 960);
} else if (simulator_retina_type == DEVICE_RETINA_4 && MATCHES_FRAME(724, 1220)) {
UPDATE_BOUNDS(42, 44, 640, 1136);
}
} else {
if (simulator_retina_type == DEVICE_RETINA_FALSE && w == 852 && h == 1108) {
NSLog(@"DEVICE WITH THICK BORDERS: Original iPad");
bounds.origin.x += 42;
bounds.origin.y += 44;
bounds.size = CGSizeMake(768, 1024);
found_thick_border = true;
if (simulator_retina_type == DEVICE_RETINA_FALSE && MATCHES_FRAME(852, 1108)) {
UPDATE_BOUNDS(42, 44, 768, 1024);
// TODO This is the screenshot!
//} else if (simulator_retina_type == DEVICE_RETINA_TRUE && w == 1704 && h == 2216) {
//NSLog(@"DEVICE WITH THICK BORDERS: iPad Retina");
@@ -469,45 +469,8 @@ get_app_windows_bounds(void)
bounds.size.height -= 24;
}
// Inset the main view frame.
//if (simulator_device_family == DEVICE_FAMILY_IPHONE) {
//switch (simulator_retina_type) {
//case DEVICE_RETINA_4:
//// TODO I assume this is based on the thick border? Because
//// at 50% (as recommended) it has no thick border.
////
//// bounds.origin.y += 25;
//// bounds.size.height -= 50;
////
//// 23x window chrome + 1px sep. line
//bounds.origin.y += 24;
//bounds.size.height -= 24;
//break;
//case DEVICE_RETINA_3_5:
//bounds.origin.y += 25;
//bounds.size.height -= 50;
//break;
//default:
//if (bounds.size.width < bounds.size.height) {
//bounds.origin.x += 30;
//bounds.size.width -= 60;
//bounds.origin.y += 120;
//bounds.size.height -= 240;
//}
//else {
//bounds.origin.x += 120;
//bounds.size.width -= 240;
//bounds.origin.y += 30;
//bounds.size.height -= 60;
//}
//}
//}
//else {
//bounds.origin.y += 25;
//bounds.size.height -= 50;
//}
#undef MATCHES_FRAME
#undef UPDATE_BOUNDS
#endif
[app_windows_bounds addObject:[NSValue valueWithRect:bounds]];

2
vm

Submodule vm updated: e6552989b0...f29c79cc50