Code Review for Job #19443
Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -89,8 +89,6 @@ const int MIRROR_VIEW_TOP_PADDING = 5; · 88 unmodified lines | ||
| 89 | 89 | const int MIRROR_VIEW_LEFT_PADDING = 10; |
| 90 | 90 | const int MIRROR_VIEW_WIDTH = 265; |
| 91 | 91 | const int MIRROR_VIEW_HEIGHT = 215; |
| 92 | −const int MIRROR_ICON_SIZE = 16; | |
| 93 | −const int MIRROR_CLOSE_ICON_PADDING = 5; | |
| 94 | 92 | |
| 95 | 93 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 96 | 94 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); |
| @@ -109,6 +107,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 12 unmodified lines | ||
| 109 | 107 | _wantToKillLocalVoxels(false), |
| 110 | 108 | _audioScope(256, 200, true), |
| 111 | 109 | _profile(QString()), |
| 110 | + _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), | |
| 112 | 111 | _mouseX(0), |
| 113 | 112 | _mouseY(0), |
| 114 | 113 | _lastMouseMove(usecTimestampNow()), |
| @@ -454,16 +453,14 @@ void Application::paintGL() { · 339 unmodified lines | ||
| 454 | 453 | displaySide(_mirrorCamera, selfAvatarOnly); |
| 455 | 454 | glPopMatrix(); |
| 456 | 455 | |
| 457 | − // render rear view tools if mouse is in the bounds | |
| 458 | − QPoint mousePosition = _glWidget->mapFromGlobal(QCursor::pos()); | |
| 459 | − if (_mirrorViewRect.contains(mousePosition.x(), mousePosition.y())) { | |
| 460 | − displayRearMirrorTools(); | |
| 461 | − } | |
| 456 | + _rearMirrorTools->render(false); | |
| 462 | 457 | |
| 463 | 458 | // reset Viewport and projection matrix |
| 464 | 459 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); |
| 465 | 460 | glDisable(GL_SCISSOR_TEST); |
| 466 | 461 | updateProjectionMatrix(_myCamera, updateViewFrustum); |
| 462 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 463 | + _rearMirrorTools->render(true); | |
| 467 | 464 | } |
| 468 | 465 | |
| 469 | 466 | displayOverlay(); |
| @@ -489,8 +486,6 @@ void Application::resizeGL(int width, int height) { · 19 unmodified lines | ||
| 489 | 486 | resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height); |
| 490 | 487 | resetCamerasOnResizeGL(_myCamera, width, height); |
| 491 | 488 | |
| 492 | − _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT); | |
| 493 | − | |
| 494 | 489 | glViewport(0, 0, width, height); // shouldn't this account for the menu??? |
| 495 | 490 | |
| 496 | 491 | updateProjectionMatrix(); |
| @@ -690,7 +685,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 193 unmodified lines | ||
| 690 | 685 | |
| 691 | 686 | case Qt::Key_Space: |
| 692 | 687 | resetSensors(); |
| 693 | − _audio.reset(); | |
| 694 | 688 | break; |
| 695 | 689 | |
| 696 | 690 | case Qt::Key_G: |
| @@ -1085,12 +1079,9 @@ void Application::mousePressEvent(QMouseEvent* event) { · 388 unmodified lines | ||
| 1085 | 1079 | return; |
| 1086 | 1080 | } |
| 1087 | 1081 | |
| 1088 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 1089 | − QRect closeIconRect = QRect(MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(), MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(), MIRROR_ICON_SIZE, MIRROR_ICON_SIZE); | |
| 1090 | − | |
| 1091 | − if (closeIconRect.contains(_mouseX, _mouseY)) { | |
| 1092 | − Menu::getInstance()->triggerOption(MenuOption::Mirror); | |
| 1093 | − } | |
| 1082 | + if (_rearMirrorTools->mousePressEvent(_mouseX, _mouseY)) { | |
| 1083 | + // stop propagation | |
| 1084 | + return; | |
| 1094 | 1085 | } |
| 1095 | 1086 | |
| 1096 | 1087 | if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) { |
| @@ -1675,10 +1666,6 @@ void Application::init() { · 578 unmodified lines | ||
| 1675 | 1666 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); |
| 1676 | 1667 | _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT); |
| 1677 | 1668 | _mirrorCamera.setFieldOfView(30); |
| 1678 | − _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT); | |
| 1679 | − | |
| 1680 | − switchToResourcesParentIfRequired(); | |
| 1681 | − _closeTextureId = _glWidget->bindTexture(QImage("./resources/images/close.png")); | |
| 1682 | 1669 | |
| 1683 | 1670 | OculusManager::connect(); |
| 1684 | 1671 | if (OculusManager::isConnected()) { |
| @@ -1731,8 +1718,39 @@ void Application::init() { · 46 unmodified lines | ||
| 1731 | 1718 | _pieMenu.addAction(_followMode); |
| 1732 | 1719 | |
| 1733 | 1720 | _audio.init(_glWidget); |
| 1721 | + | |
| 1722 | + _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect); | |
| 1723 | + connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); | |
| 1724 | + connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); | |
| 1725 | + connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); | |
| 1726 | + connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); | |
| 1734 | 1727 | } |
| 1735 | 1728 | |
| 1729 | +void Application::closeMirrorView() { | |
| 1730 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 1731 | + Menu::getInstance()->triggerOption(MenuOption::Mirror);; | |
| 1732 | + } | |
| 1733 | +} | |
| 1734 | + | |
| 1735 | +void Application::restoreMirrorView() { | |
| 1736 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 1737 | + Menu::getInstance()->triggerOption(MenuOption::Mirror);; | |
| 1738 | + } | |
| 1739 | + | |
| 1740 | + if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 1741 | + Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); | |
| 1742 | + } | |
| 1743 | +} | |
| 1744 | + | |
| 1745 | +void Application::shrinkMirrorView() { | |
| 1746 | + if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 1747 | + Menu::getInstance()->triggerOption(MenuOption::Mirror);; | |
| 1748 | + } | |
| 1749 | + | |
| 1750 | + if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 1751 | + Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); | |
| 1752 | + } | |
| 1753 | +} | |
| 1736 | 1754 | |
| 1737 | 1755 | const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; |
| 1738 | 1756 | const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; |
| @@ -3758,6 +3776,8 @@ void Application::resetSensors() { · 2019 unmodified lines | ||
| 3758 | 3776 | _myTransmitter.resetLevels(); |
| 3759 | 3777 | _myAvatar.setVelocity(glm::vec3(0,0,0)); |
| 3760 | 3778 | _myAvatar.setThrust(glm::vec3(0,0,0)); |
| 3779 | + | |
| 3780 | + _audio.reset(); | |
| 3761 | 3781 | } |
| 3762 | 3782 | |
| 3763 | 3783 | static void setShortcutsEnabled(QWidget* widget, bool enabled) { |
| @@ -3957,41 +3977,3 @@ void Application::packetSentNotification(ssize_t length) { · 193 unmodified lines | ||
| 3957 | 3977 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length); |
| 3958 | 3978 | } |
| 3959 | 3979 | |
| 3960 | −void Application::displayRearMirrorTools() { | |
| 3961 | − | |
| 3962 | − glMatrixMode(GL_PROJECTION); | |
| 3963 | − glPushMatrix(); | |
| 3964 | − glLoadIdentity(); | |
| 3965 | − gluOrtho2D(_mirrorViewRect.left(), _mirrorViewRect.right(), _mirrorViewRect.bottom(), _mirrorViewRect.top()); | |
| 3966 | − glDisable(GL_DEPTH_TEST); | |
| 3967 | − glDisable(GL_LIGHTING); | |
| 3968 | − | |
| 3969 | − glEnable(GL_TEXTURE_2D); | |
| 3970 | − glBindTexture(GL_TEXTURE_2D, _closeTextureId); | |
| 3971 | − | |
| 3972 | − glColor3f(1, 1, 1); | |
| 3973 | − glBegin(GL_QUADS); | |
| 3974 | − | |
| 3975 | − int lp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(); | |
| 3976 | − int tp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(); | |
| 3977 | − int lwp = MIRROR_ICON_SIZE + lp; | |
| 3978 | − int twp = MIRROR_ICON_SIZE + tp; | |
| 3979 | − | |
| 3980 | − glTexCoord2f(1, 1); | |
| 3981 | − glVertex2f(lp, tp); | |
| 3982 | − | |
| 3983 | − glTexCoord2f(0, 1); | |
| 3984 | − glVertex2f(lwp, tp); | |
| 3985 | − | |
| 3986 | − glTexCoord2f(0, 0); | |
| 3987 | − glVertex2f(lwp, twp); | |
| 3988 | − | |
| 3989 | − glTexCoord2f(1, 0); | |
| 3990 | − glVertex2f(lp, twp); | |
| 3991 | − | |
| 3992 | − glEnd(); | |
| 3993 | − | |
| 3994 | − glPopMatrix(); | |
| 3995 | − | |
| 3996 | − glDisable(GL_TEXTURE_2D); | |
| 3997 | −} | |