From 811fc87294b30160f00b9775b32201b79b396acc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Aug 2013 12:18:19 -0700 Subject: [PATCH] move avatar size changes to Avatar slots --- interface/src/Application.cpp | 23 ++--------------------- interface/src/Application.h | 4 ---- interface/src/Menu.cpp | 22 +++++++++++++++------- interface/src/avatar/Avatar.cpp | 19 +++++++++++++++++++ interface/src/avatar/Avatar.h | 3 +++ 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1d85393860..dd30053c1d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -710,10 +710,10 @@ void Application::keyPressEvent(QKeyEvent* event) { } break; case Qt::Key_Plus: - increaseAvatarSize(); + _myAvatar.increaseSize(); break; case Qt::Key_Minus: - decreaseAvatarSize(); + _myAvatar.decreaseSize(); break; case Qt::Key_1: @@ -1142,25 +1142,6 @@ void Application::setFullscreen(bool fullscreen) { updateCursor(); } -void Application::increaseAvatarSize() { - if ((1.f + SCALING_RATIO) * _myAvatar.getNewScale() < MAX_SCALE) { - _myAvatar.setNewScale((1.f + SCALING_RATIO) * _myAvatar.getNewScale()); - qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); - } -} - -void Application::decreaseAvatarSize() { - if (MIN_SCALE < (1.f - SCALING_RATIO) * _myAvatar.getNewScale()) { - _myAvatar.setNewScale((1.f - SCALING_RATIO) * _myAvatar.getNewScale()); - qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); - } -} - -void Application::resetAvatarSize() { - _myAvatar.setNewScale(1.f); - qDebug("Reseted scale to %f\n", _myAvatar.getNewScale()); -} - void Application::setFrustumOffset(bool frustumOffset) { // reshape so that OpenGL will get the right lens details for the camera of choice resizeGL(_glWidget->width(), _glWidget->height()); diff --git a/interface/src/Application.h b/interface/src/Application.h index 14d98b4490..cb3e64a071 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -142,10 +142,6 @@ private slots: void setFullscreen(bool fullscreen); - void increaseAvatarSize(); - void decreaseAvatarSize(); - void resetAvatarSize(); - void renderThrustAtVoxel(const glm::vec3& thrust); void renderLineToTouchedVoxel(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index d04d4008c3..e42a162973 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -151,13 +151,21 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::ParticleSystem); addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::FirstPerson, Qt::Key_P, true); - addActionToQMenuAndActionHash(renderMenu, MenuOption::IncreaseAvatarSize); - addActionToQMenuAndActionHash(renderMenu, MenuOption::DecreaseAvatarSize); - addActionToQMenuAndActionHash(renderMenu, MenuOption::ResetAvatarSize); - - // renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus); - // renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus); - // renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize())); + addActionToQMenuAndActionHash(renderMenu, + MenuOption::IncreaseAvatarSize, + Qt::Key_Plus, + appInstance->getAvatar(), + SLOT(increaseSize())); + addActionToQMenuAndActionHash(renderMenu, + MenuOption::DecreaseAvatarSize, + Qt::Key_Minus, + appInstance->getAvatar(), + SLOT(decreaseSize())); + addActionToQMenuAndActionHash(renderMenu, + MenuOption::ResetAvatarSize, + 0, + appInstance->getAvatar(), + SLOT(resetSize())); QMenu* toolsMenu = addMenu("Tools"); addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Stats, Qt::Key_Slash); diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index f466ea90d6..2879c7ded0 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -1659,6 +1659,25 @@ void Avatar::goHome() { setPosition(START_LOCATION); } +void Avatar::increaseSize() { + if ((1.f + SCALING_RATIO) * _newScale < MAX_SCALE) { + _newScale *= (1.f + SCALING_RATIO); + qDebug("Changed scale to %f\n", _newScale); + } +} + +void Avatar::decreaseSize() { + if (MIN_SCALE < (1.f - SCALING_RATIO) * _newScale) { + _newScale *= (1.f - SCALING_RATIO); + qDebug("Changed scale to %f\n", _newScale); + } +} + +void Avatar::resetSize() { + _newScale = 1.0f; + qDebug("Reseted scale to %f\n", _newScale); +} + void Avatar::setNewScale(const float scale) { _newScale = scale; } diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 1a6d53dc1a..952e9274e0 100755 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -215,6 +215,9 @@ public: public slots: void setWantCollisionsOn(bool wantCollisionsOn) { _isCollisionsOn = wantCollisionsOn; } void goHome(); + void increaseSize(); + void decreaseSize(); + void resetSize(); private: // privatize copy constructor and assignment operator to avoid copying