| 1354 | } |
| 1355 | |
| 1356 | void onAutoRotation(int par1) |
| 1357 | { |
| 1358 | CRLog::trace("onAutoRotation(%d)", par1); |
| 1359 | if (par1 < 0 || par1 > 3) |
| 1360 | return; |
| 1361 | if (_pauseRotationTimer) { |
| 1362 | _pauseRotationTimer = false; |
| 1363 | ClearTimer(paused_rotate_timer); |
| 1364 | } |
| 1365 | cr_rotate_angle_t oldOrientation = CRPocketBookWindowManager::instance->getScreenOrientation(); |
| 1366 | cr_rotate_angle_t newOrientation = pocketbook_orientations[par1]; |
| 1367 | CRLog::trace("onAutoRotation(), oldOrient = %d, newOrient = %d", oldOrientation, newOrientation); |
| 1368 | if (oldOrientation == newOrientation) |
| 1369 | return; |
| 1370 | CRPropRef props = CRPocketBookDocView::instance->getProps(); |
| 1371 | int rotate_mode = props->getIntDef(PROP_POCKETBOOK_ROTATE_MODE, PB_ROTATE_MODE_180); |
| 1372 | if (rotate_mode && (oldOrientation & 1) != (newOrientation & 1)) { |
| 1373 | CRLog::trace("rotate_mode && (oldOrientation & 1) != (newOrientation & 1)"); |
| 1374 | if (rotate_mode == PB_ROTATE_MODE_180 || rotate_mode > PB_ROTATE_MODE_180_SLOW_PREV_NEXT) |
| 1375 | return; |
| 1376 | bool prev = false; |
| 1377 | if (rotate_mode == PB_ROTATE_MODE_180_SLOW_PREV_NEXT) { // back+forward |
| 1378 | switch (oldOrientation) { |
| 1379 | case CR_ROTATE_ANGLE_0: |
| 1380 | prev = (newOrientation == CR_ROTATE_ANGLE_90); |
| 1381 | break; |
| 1382 | case CR_ROTATE_ANGLE_90: |
| 1383 | prev = (newOrientation == CR_ROTATE_ANGLE_180); |
| 1384 | break; |
| 1385 | case CR_ROTATE_ANGLE_270: |
| 1386 | prev = (newOrientation == CR_ROTATE_ANGLE_0); |
| 1387 | break; |
| 1388 | case CR_ROTATE_ANGLE_180: |
| 1389 | prev = (newOrientation == CR_ROTATE_ANGLE_270); |
| 1390 | break; |
| 1391 | } |
| 1392 | } |
| 1393 | if (prev) |
| 1394 | SendEvent(main_handler, EVT_PREVPAGE, 0, 0); |
| 1395 | else |
| 1396 | SendEvent(main_handler, EVT_NEXTPAGE, 0, 0); |
| 1397 | SetAutoPowerOff(0); |
| 1398 | SetAutoPowerOff(1); // reset auto-power-off timer! |
| 1399 | } else { |
| 1400 | int dx = _wm->getScreen()->getWidth(); |
| 1401 | int dy = _wm->getScreen()->getHeight(); |
| 1402 | if ((oldOrientation & 1) == (newOrientation & 1)) { |
| 1403 | SetOrientation(par1); |
| 1404 | _wm->reconfigure(dx, dy, newOrientation); |
| 1405 | _wm->update(true); |
| 1406 | } else { |
| 1407 | _pausedRotation = par1; |
| 1408 | SetWeakTimer("RotatePage", paused_rotate_timer, 400); |
| 1409 | _pauseRotationTimer = true; |
| 1410 | } |
| 1411 | } |
| 1412 | } |
| 1413 | void OnFormatEnd() |
no test coverage detected