History

close button on rear mirror view

stojce committed 13 years ago

Commit 2fcb2461 parent 890313b5 files · +107 −29Browse files

Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all

Unified · Split

interface/src/Application.cpp+85−27
@@ -69,6 +69,11 @@ · 68 unmodified lines
6969 #include "ui/TextRenderer.h"
7070 #include "InfoView.h"
7171
72+#include <QSvgRenderer>
73+#include <QPainter>
74+#include <QGLWidget>
75+#include <SharedUtil.h>
76+
7277 using namespace std;
7378
7479 // Starfield information
@@ -85,11 +90,12 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2; · 10 unmodified lines
8590 // Startup optimistically with small jitter buffer that
8691 // will start playback on the second received audio packet.
8792
88−
8993 const int MIRROR_VIEW_TOP_PADDING = 5;
9094 const int MIRROR_VIEW_LEFT_PADDING = 10;
9195 const int MIRROR_VIEW_WIDTH = 265;
9296 const int MIRROR_VIEW_HEIGHT = 215;
97+const int MIRROR_ICON_SIZE = 16;
98+const int MIRROR_CLOSE_ICON_PADDING = 5;
9399
94100 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
95101 fprintf(stdout, "%s", message.toLocal8Bit().constData());
@@ -258,12 +264,12 @@ void Application::restoreSizeAndPosition() { · 162 unmodified lines
258264
259265 settings->beginGroup("Window");
260266
261− float x = loadSetting(settings, "x", 0);
262− float y = loadSetting(settings, "y", 0);
267+ int x = (int) loadSetting(settings, "x", 0);
268+ int y = (int) loadSetting(settings, "y", 0);
263269 _window->move(x, y);
264270
265− int width = loadSetting(settings, "width", available.width());
266− int height = loadSetting(settings, "height", available.height());
271+ int width = (int) loadSetting(settings, "width", available.width());
272+ int height = (int) loadSetting(settings, "height", available.height());
267273 _window->resize(width, height);
268274
269275 settings->endGroup();
@@ -427,7 +433,6 @@ void Application::paintGL() { · 157 unmodified lines
427433 _glowEffect.render();
428434
429435 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
430−
431436 glm::vec3 targetPosition = _myAvatar.getEyeLevelPosition();
432437 if (_myAvatar.getHead().getBlendFace().isActive()) {
433438 // make sure we're aligned to the blend face eyes
@@ -441,21 +446,30 @@ void Application::paintGL() { · 7 unmodified lines
441446 _mirrorCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
442447 _mirrorCamera.update(1.0f/_fps);
443448
444− glViewport(MIRROR_VIEW_LEFT_PADDING, _glWidget->height() - MIRROR_VIEW_HEIGHT - MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);
445− glScissor(MIRROR_VIEW_LEFT_PADDING, _glWidget->height() - MIRROR_VIEW_HEIGHT - MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);
446−
449+ // set the bounds of rear mirror view
450+ glViewport(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
451+ glScissor(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
447452 updateProjectionMatrix(_mirrorCamera);
448−
449453 glEnable(GL_SCISSOR_TEST);
450454 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
455+
456+ // render rear mirror view
451457 glPushMatrix();
452458 displaySide(_mirrorCamera);
453459 glPopMatrix();
454460
455− // reset Viewport
461+ // render rear view tools if mouse is in the bounds
462+ QPoint mousePosition = _glWidget->mapFromGlobal(QCursor::pos());
463+
464+ qDebug("mouse pos: x = %d, y = %d\n", mousePosition.x(), mousePosition.y());
465+
466+ if (_mirrorViewRect.contains(mousePosition.x(), mousePosition.y())) {
467+ displayRearMirrorTools();
468+ }
469+
470+ // reset Viewport and projection matrix
456471 glViewport(0, 0, _glWidget->width(), _glWidget->height());
457472 glDisable(GL_SCISSOR_TEST);
458−
459473 updateProjectionMatrix();
460474 }
461475
@@ -481,6 +495,8 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 19 unmodified lines
481495 void Application::resizeGL(int width, int height) {
482496 resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height);
483497 resetCamerasOnResizeGL(_myCamera, width, height);
498+
499+ _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);
484500
485501 glViewport(0, 0, width, height); // shouldn't this account for the menu???
486502
@@ -1024,7 +1040,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 537 unmodified lines
10241040 if (activeWindow() == _window) {
10251041 _mouseX = event->x();
10261042 _mouseY = event->y();
1027−
1043+
10281044 // detect drag
10291045 glm::vec3 mouseVoxelPos(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z);
10301046 if (!_justEditedVoxel && mouseVoxelPos != _lastMouseVoxelPos) {
@@ -1062,6 +1078,15 @@ void Application::mousePressEvent(QMouseEvent* event) { · 31 unmodified lines
10621078 return;
10631079 }
10641080
1081+ if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
1082+
1083+ QRect closeIconRect = QRect(MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(), MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(), MIRROR_ICON_SIZE, MIRROR_ICON_SIZE);
1084+
1085+ if (closeIconRect.contains(_mouseX, _mouseY)) {
1086+ Menu::getInstance()->triggerOption(MenuOption::Mirror);
1087+ }
1088+ }
1089+
10651090 if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) {
10661091 _pieMenu.mousePressEvent(_mouseX, _mouseY);
10671092 }
@@ -1636,11 +1661,14 @@ void Application::init() { · 568 unmodified lines
16361661 _myAvatar.setPosition(START_LOCATION);
16371662 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
16381663 _myCamera.setModeShiftRate(1.0f);
1639− _myAvatar.setDisplayingLookatVectors(false);
1664+ _myAvatar.setDisplayingLookatVectors(false);
1665+
16401666 _mirrorCamera.setMode(CAMERA_MODE_MIRROR);
1641− _mirrorCamera.setModeShiftRate(1.0f);
16421667 _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT);
1643− _mirrorCamera.setFieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES);
1668+ _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);
1669+
1670+ switchToResourcesParentIfRequired();
1671+ _closeTextureId = _glWidget->bindTexture(QImage("./resources/images/close.png"));
16441672
16451673 OculusManager::connect();
16461674 if (OculusManager::isConnected()) {
@@ -2472,15 +2500,6 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 825 unmodified lines
24722500 float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
24732501
24742502 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane);
2475−
2476− /*
2477− // when mirrored, we must flip left and right
2478− if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
2479− float tmp = left;
2480− left = -right;
2481− right = -tmp;
2482− }
2483− */
24842503 }
24852504
24862505 void Application::displaySide(Camera& whichCamera) {
@@ -2730,7 +2749,7 @@ void Application::displaySide(Camera& whichCamera) { · 243 unmodified lines
27302749 }
27312750
27322751 // brad's frustum for debugging
2733− if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
2752+ if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
27342753 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
27352754 "Application::displaySide() ... renderViewFrustum...");
27362755 renderViewFrustum(_viewFrustum);
@@ -2962,7 +2981,7 @@ void Application::displayOverlay() { · 225 unmodified lines
29622981 if (_pieMenu.isDisplayed()) {
29632982 _pieMenu.render();
29642983 }
2965−
2984+
29662985 glPopMatrix();
29672986 }
29682987
@@ -3781,3 +3800,42 @@ void* Application::networkReceive(void* args) { · 812 unmodified lines
37813800 void Application::packetSentNotification(ssize_t length) {
37823801 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
37833802 }
3803+
3804+void Application::displayRearMirrorTools() {
3805+
3806+ glMatrixMode(GL_PROJECTION);
3807+ glPushMatrix();
3808+ glLoadIdentity();
3809+ gluOrtho2D(_mirrorViewRect.left(), _mirrorViewRect.right(), _mirrorViewRect.bottom(), _mirrorViewRect.top());
3810+ glDisable(GL_DEPTH_TEST);
3811+ glDisable(GL_LIGHTING);
3812+
3813+ glEnable(GL_TEXTURE_2D);
3814+ glBindTexture(GL_TEXTURE_2D, _closeTextureId);
3815+
3816+ glColor3f(1, 1, 1);
3817+ glBegin(GL_QUADS);
3818+
3819+ int lp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left();
3820+ int tp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top();
3821+ int lwp = MIRROR_ICON_SIZE + lp;
3822+ int twp = MIRROR_ICON_SIZE + tp;
3823+
3824+ glTexCoord2f(1, 1);
3825+ glVertex2f(lp, tp);
3826+
3827+ glTexCoord2f(0, 1);
3828+ glVertex2f(lwp, tp);
3829+
3830+ glTexCoord2f(0, 0);
3831+ glVertex2f(lwp, twp);
3832+
3833+ glTexCoord2f(1, 0);
3834+ glVertex2f(lp, twp);
3835+
3836+ glEnd();
3837+
3838+ glPopMatrix();
3839+
3840+ glDisable(GL_TEXTURE_2D);
3841+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t