reset view

- reset icon
- resetView signal
This commit is contained in:
stojce 2013-10-28 18:19:31 +01:00
parent b09e657ecc
commit 4fe9964e5a
5 changed files with 17 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -685,7 +685,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
case Qt::Key_Space: case Qt::Key_Space:
resetSensors(); resetSensors();
_audio.reset();
break; break;
case Qt::Key_G: case Qt::Key_G:
@ -1724,6 +1723,7 @@ void Application::init() {
connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
} }
void Application::closeMirrorView() { void Application::closeMirrorView() {
@ -3777,6 +3777,8 @@ void Application::resetSensors() {
_myTransmitter.resetLevels(); _myTransmitter.resetLevels();
_myAvatar.setVelocity(glm::vec3(0,0,0)); _myAvatar.setVelocity(glm::vec3(0,0,0));
_myAvatar.setThrust(glm::vec3(0,0,0)); _myAvatar.setThrust(glm::vec3(0,0,0));
_audio.reset();
} }
static void setShortcutsEnabled(QWidget* widget, bool enabled) { static void setShortcutsEnabled(QWidget* widget, bool enabled) {

View file

@ -201,6 +201,7 @@ private slots:
void closeMirrorView(); void closeMirrorView();
void restoreMirrorView(); void restoreMirrorView();
void shrinkMirrorView(); void shrinkMirrorView();
void resetSensors();
private: private:
void resetCamerasOnResizeGL(Camera& camera, int width, int height); void resetCamerasOnResizeGL(Camera& camera, int width, int height);
@ -241,7 +242,6 @@ private:
bool maybeEditVoxelUnderCursor(); bool maybeEditVoxelUnderCursor();
void deleteVoxelUnderCursor(); void deleteVoxelUnderCursor();
void eyedropperVoxelUnderCursor(); void eyedropperVoxelUnderCursor();
void resetSensors();
void injectVoxelAddedSoundEffect(); void injectVoxelAddedSoundEffect();
void setMenuShortcutsEnabled(bool enabled); void setMenuShortcutsEnabled(bool enabled);

View file

@ -15,32 +15,39 @@ const int ICON_PADDING = 5;
RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) : _parent(parent), _bounds(bounds), _windowed(false), _fullScreen(false) { RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) : _parent(parent), _bounds(bounds), _windowed(false), _fullScreen(false) {
switchToResourcesParentIfRequired(); switchToResourcesParentIfRequired();
_closeTextureId = _parent->bindTexture(QImage("./resources/images/close.png")); _closeTextureId = _parent->bindTexture(QImage("./resources/images/close.png"));
_shrinkTextureId = _parent->bindTexture(QImage("./resources/images/close.png")); _resetTextureId = _parent->bindTexture(QImage("./resources/images/reset.png"));
}; };
void RearMirrorTools::render(bool fullScreen) { void RearMirrorTools::render(bool fullScreen) {
if (fullScreen) { if (fullScreen) {
_fullScreen = true; _fullScreen = true;
displayIcon(_parent->geometry(), ICON_PADDING, ICON_PADDING, _shrinkTextureId); displayIcon(_parent->geometry(), ICON_PADDING, ICON_PADDING, _closeTextureId);
} else { } else {
// render rear view tools if mouse is in the bounds // render rear view tools if mouse is in the bounds
QPoint mousePosition = _parent->mapFromGlobal(QCursor::pos()); QPoint mousePosition = _parent->mapFromGlobal(QCursor::pos());
_windowed = _bounds.contains(mousePosition.x(), mousePosition.y()); _windowed = _bounds.contains(mousePosition.x(), mousePosition.y());
if (_windowed) { if (_windowed) {
displayIcon(_bounds, _bounds.left() + ICON_PADDING, ICON_PADDING, _closeTextureId); displayIcon(_bounds, _bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, _closeTextureId);
displayIcon(_bounds, _bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, _resetTextureId);
} }
} }
} }
bool RearMirrorTools::mousePressEvent(int x, int y) { bool RearMirrorTools::mousePressEvent(int x, int y) {
if (_windowed) { if (_windowed) {
QRect closeIconRect = QRect(ICON_PADDING + _bounds.left(), ICON_PADDING + _bounds.top(), ICON_SIZE, ICON_SIZE); QRect closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE);
if (closeIconRect.contains(x, y)) { if (closeIconRect.contains(x, y)) {
_windowed = false; _windowed = false;
emit closeView(); emit closeView();
return true; return true;
} }
QRect resetIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE);
if (resetIconRect.contains(x, y)) {
emit resetView();
return true;
}
if (_bounds.contains(x, y)) { if (_bounds.contains(x, y)) {
_windowed = false; _windowed = false;
emit restoreView(); emit restoreView();

View file

@ -23,13 +23,14 @@ public:
signals: signals:
void closeView(); void closeView();
void shrinkView(); void shrinkView();
void resetView();
void restoreView(); void restoreView();
private: private:
QGLWidget* _parent; QGLWidget* _parent;
QRect _bounds; QRect _bounds;
GLuint _closeTextureId; GLuint _closeTextureId;
GLuint _shrinkTextureId; GLuint _resetTextureId;
bool _windowed; bool _windowed;
bool _fullScreen; bool _fullScreen;