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

View file

@ -201,6 +201,7 @@ private slots:
void closeMirrorView();
void restoreMirrorView();
void shrinkMirrorView();
void resetSensors();
private:
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
@ -241,7 +242,6 @@ private:
bool maybeEditVoxelUnderCursor();
void deleteVoxelUnderCursor();
void eyedropperVoxelUnderCursor();
void resetSensors();
void injectVoxelAddedSoundEffect();
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) {
switchToResourcesParentIfRequired();
_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) {
if (fullScreen) {
_fullScreen = true;
displayIcon(_parent->geometry(), ICON_PADDING, ICON_PADDING, _shrinkTextureId);
displayIcon(_parent->geometry(), ICON_PADDING, ICON_PADDING, _closeTextureId);
} else {
// render rear view tools if mouse is in the bounds
QPoint mousePosition = _parent->mapFromGlobal(QCursor::pos());
_windowed = _bounds.contains(mousePosition.x(), mousePosition.y());
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) {
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)) {
_windowed = false;
emit closeView();
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)) {
_windowed = false;
emit restoreView();

View file

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