From b1bf8443b2a8340d0d873e8b6b82ba22a8019a36 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 9 Apr 2020 21:39:15 +0300 Subject: [PATCH 1/7] SL-12999 Some menus allow mouse scroll to zoom camera --- indra/newview/CMakeLists.txt | 2 + indra/newview/llpanelnearbymedia.cpp | 55 +------- indra/newview/llpanelnearbymedia.h | 9 +- .../newview/llpanelpresetscamerapulldown.cpp | 78 +----------- indra/newview/llpanelpresetscamerapulldown.h | 17 +-- indra/newview/llpanelpresetspulldown.cpp | 76 +---------- indra/newview/llpanelpresetspulldown.h | 16 +-- indra/newview/llpanelpulldown.cpp | 118 ++++++++++++++++++ indra/newview/llpanelpulldown.h | 55 ++++++++ indra/newview/llpanelvolumepulldown.cpp | 58 +-------- indra/newview/llpanelvolumepulldown.h | 15 +-- 11 files changed, 190 insertions(+), 309 deletions(-) create mode 100644 indra/newview/llpanelpulldown.cpp create mode 100644 indra/newview/llpanelpulldown.h diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e5748ce4a5..c62fe1a82d 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -495,6 +495,7 @@ set(viewer_SOURCE_FILES llpaneltiptoast.cpp llpanelvoiceeffect.cpp llpaneltopinfobar.cpp + llpanelpulldown.cpp llpanelvoicedevicesettings.cpp llpanelvolume.cpp llpanelvolumepulldown.cpp @@ -1111,6 +1112,7 @@ set(viewer_HEADER_FILES llpanelsnapshot.h llpanelteleporthistory.h llpaneltiptoast.h + llpanelpulldown.h llpanelvoicedevicesettings.h llpanelvoiceeffect.h llpaneltopinfobar.h diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index b654e928e2..a8887eb936 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -82,8 +82,6 @@ LLPanelNearByMedia::LLPanelNearByMedia() mParcelMediaItem(NULL), mParcelAudioItem(NULL) { - mHoverTimer.stop(); - // This is just an initial value, mParcelAudioAutoStart does not affect ParcelMediaAutoPlayEnable mParcelAudioAutoStart = gSavedSettings.getS32("ParcelMediaAutoPlayEnable") != 0 && gSavedSettings.getBOOL("MediaTentativeAutoPlay"); @@ -111,7 +109,7 @@ LLPanelNearByMedia::~LLPanelNearByMedia() BOOL LLPanelNearByMedia::postBuild() { - LLPanel::postBuild(); + LLPanelPulldown::postBuild(); const S32 RESIZE_BAR_THICKNESS = 6; LLResizeBar::Params p; @@ -193,45 +191,10 @@ void LLPanelNearByMedia::handleMediaAutoPlayChanged(const LLSD& newvalue) inst->cancelNotification(); } -/*virtual*/ -void LLPanelNearByMedia::onMouseEnter(S32 x, S32 y, MASK mask) -{ - mHoverTimer.stop(); - LLPanel::onMouseEnter(x,y,mask); -} - - -/*virtual*/ -void LLPanelNearByMedia::onMouseLeave(S32 x, S32 y, MASK mask) -{ - mHoverTimer.start(); - LLPanel::onMouseLeave(x,y,mask); -} - -/*virtual*/ -void LLPanelNearByMedia::onTopLost() -{ - setVisible(FALSE); -} - - -/*virtual*/ -void LLPanelNearByMedia::onVisibilityChange ( BOOL new_visibility ) -{ - if (new_visibility) - { - mHoverTimer.start(); // timer will be stopped when mouse hovers over panel - } - else - { - mHoverTimer.stop(); - } -} - /*virtual*/ void LLPanelNearByMedia::reshape(S32 width, S32 height, BOOL called_from_parent) { - LLPanel::reshape(width, height, called_from_parent); + LLPanelPulldown::reshape(width, height, called_from_parent); LLButton* more_btn = findChild("more_btn"); if (more_btn && more_btn->getValue().asBoolean()) @@ -255,24 +218,14 @@ void LLPanelNearByMedia::draw() refreshList(); updateControls(); - - F32 alpha = mHoverTimer.getStarted() - ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), AUTO_CLOSE_FADE_TIME_START, AUTO_CLOSE_FADE_TIME_END, 1.f, 0.f) - : 1.0f; - LLViewDrawContext context(alpha); - LLPanel::draw(); - - if (alpha == 0.f) - { - setVisible(false); - } + LLPanelPulldown::draw(); } /*virtual*/ BOOL LLPanelNearByMedia::handleHover(S32 x, S32 y, MASK mask) { - LLPanel::handleHover(x, y, mask); + LLPanelPulldown::handleHover(x, y, mask); // If we are hovering over this panel, make sure to clear any hovered media // ID. Note that the more general solution would be to clear this ID when diff --git a/indra/newview/llpanelnearbymedia.h b/indra/newview/llpanelnearbymedia.h index a9c1b190cf..2d898d0aa1 100644 --- a/indra/newview/llpanelnearbymedia.h +++ b/indra/newview/llpanelnearbymedia.h @@ -27,7 +27,7 @@ #ifndef LL_LLPANELNEARBYMEDIA_H #define LL_LLPANELNEARBYMEDIA_H -#include "llpanel.h" +#include "llpanelpulldown.h" class LLPanelNearbyMedia; class LLButton; @@ -39,16 +39,12 @@ class LLTextBox; class LLComboBox; class LLViewerMediaImpl; -class LLPanelNearByMedia : public LLPanel +class LLPanelNearByMedia : public LLPanelPulldown { public: /*virtual*/ BOOL postBuild(); /*virtual*/ void draw(); - /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); - /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); - /*virtual*/ void onTopLost(); - /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); @@ -173,7 +169,6 @@ private: LLRect mMoreRect; LLRect mLessRect; - LLFrameTimer mHoverTimer; LLScrollListItem* mParcelMediaItem; LLScrollListItem* mParcelAudioItem; }; diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp index fdf73e069e..183123e534 100644 --- a/indra/newview/llpanelpresetscamerapulldown.cpp +++ b/indra/newview/llpanelpresetscamerapulldown.cpp @@ -41,9 +41,6 @@ #include "llscrolllistctrl.h" #include "lltrans.h" -/* static */ const F32 LLPanelPresetsCameraPulldown::sAutoCloseFadeStartTimeSec = 2.0f; -/* static */ const F32 LLPanelPresetsCameraPulldown::sAutoCloseTotalTimeSec = 3.0f; - ///---------------------------------------------------------------------------- /// Class LLPanelPresetsCameraPulldown ///---------------------------------------------------------------------------- @@ -51,8 +48,6 @@ // Default constructor LLPanelPresetsCameraPulldown::LLPanelPresetsCameraPulldown() { - mHoverTimer.stop(); - mCommitCallbackRegistrar.add("Presets.toggleCameraFloater", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2)); mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2)); @@ -74,7 +69,7 @@ BOOL LLPanelPresetsCameraPulldown::postBuild() populatePanel(); - return LLPanel::postBuild(); + return LLPanelPulldown::postBuild(); } void LLPanelPresetsCameraPulldown::populatePanel() @@ -118,61 +113,6 @@ void LLPanelPresetsCameraPulldown::populatePanel() } } -/*virtual*/ -void LLPanelPresetsCameraPulldown::onMouseEnter(S32 x, S32 y, MASK mask) -{ - mHoverTimer.stop(); - LLPanel::onMouseEnter(x,y,mask); -} - -/*virtual*/ -void LLPanelPresetsCameraPulldown::onTopLost() -{ - setVisible(FALSE); -} - -/*virtual*/ -BOOL LLPanelPresetsCameraPulldown::handleMouseDown(S32 x, S32 y, MASK mask) -{ - LLPanel::handleMouseDown(x,y,mask); - return TRUE; -} - -/*virtual*/ -BOOL LLPanelPresetsCameraPulldown::handleRightMouseDown(S32 x, S32 y, MASK mask) -{ - LLPanel::handleRightMouseDown(x, y, mask); - return TRUE; -} - -/*virtual*/ -BOOL LLPanelPresetsCameraPulldown::handleDoubleClick(S32 x, S32 y, MASK mask) -{ - LLPanel::handleDoubleClick(x, y, mask); - return TRUE; -} - -/*virtual*/ -void LLPanelPresetsCameraPulldown::onMouseLeave(S32 x, S32 y, MASK mask) -{ - mHoverTimer.start(); - LLPanel::onMouseLeave(x,y,mask); -} - -/*virtual*/ -void LLPanelPresetsCameraPulldown::onVisibilityChange ( BOOL new_visibility ) -{ - if (new_visibility) - { - mHoverTimer.start(); // timer will be stopped when mouse hovers over panel - } - else - { - mHoverTimer.stop(); - - } -} - void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data) { LLScrollListCtrl* scroll = getChild("preset_camera_list"); @@ -207,19 +147,3 @@ void LLPanelPresetsCameraPulldown::onViewButtonClick(const LLSD& user_data) LLFloaterReg::toggleInstanceOrBringToFront("camera"); } - -//virtual -void LLPanelPresetsCameraPulldown::draw() -{ - F32 alpha = mHoverTimer.getStarted() - ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f) - : 1.0f; - LLViewDrawContext context(alpha); - - LLPanel::draw(); - - if (alpha == 0.f) - { - setVisible(FALSE); - } -} diff --git a/indra/newview/llpanelpresetscamerapulldown.h b/indra/newview/llpanelpresetscamerapulldown.h index 12d9bc26ec..c49bab042e 100644 --- a/indra/newview/llpanelpresetscamerapulldown.h +++ b/indra/newview/llpanelpresetscamerapulldown.h @@ -29,22 +29,12 @@ #include "linden_common.h" -#include "llpanel.h" +#include "llpanelpulldown.h" -class LLFrameTimer; - -class LLPanelPresetsCameraPulldown : public LLPanel +class LLPanelPresetsCameraPulldown : public LLPanelPulldown { public: LLPanelPresetsCameraPulldown(); - /*virtual*/ void draw(); - /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); - /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); - /*virtual*/ void onTopLost(); - /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); /*virtual*/ BOOL postBuild(); void populatePanel(); @@ -53,9 +43,6 @@ class LLPanelPresetsCameraPulldown : public LLPanel void onRowClick(const LLSD& user_data); std::list mPresetNames; - LLFrameTimer mHoverTimer; - static const F32 sAutoCloseFadeStartTimeSec; - static const F32 sAutoCloseTotalTimeSec; LOG_CLASS(LLPanelPresetsCameraPulldown); }; diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp index 332fd9969d..aa5ba3f210 100644 --- a/indra/newview/llpanelpresetspulldown.cpp +++ b/indra/newview/llpanelpresetspulldown.cpp @@ -40,9 +40,6 @@ #include "llscrolllistctrl.h" #include "lltrans.h" -/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseFadeStartTimeSec = 2.0f; -/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseTotalTimeSec = 3.0f; - ///---------------------------------------------------------------------------- /// Class LLPanelPresetsPulldown ///---------------------------------------------------------------------------- @@ -67,7 +64,7 @@ BOOL LLPanelPresetsPulldown::postBuild() populatePanel(); - return LLPanel::postBuild(); + return LLPanelPulldown::postBuild(); } void LLPanelPresetsPulldown::populatePanel() @@ -111,61 +108,6 @@ void LLPanelPresetsPulldown::populatePanel() } } -/*virtual*/ -void LLPanelPresetsPulldown::onMouseEnter(S32 x, S32 y, MASK mask) -{ - mHoverTimer.stop(); - LLPanel::onMouseEnter(x,y,mask); -} - -/*virtual*/ -void LLPanelPresetsPulldown::onTopLost() -{ - setVisible(FALSE); -} - -/*virtual*/ -BOOL LLPanelPresetsPulldown::handleMouseDown(S32 x, S32 y, MASK mask) -{ - LLPanel::handleMouseDown(x,y,mask); - return TRUE; -} - -/*virtual*/ -BOOL LLPanelPresetsPulldown::handleRightMouseDown(S32 x, S32 y, MASK mask) -{ - LLPanel::handleRightMouseDown(x, y, mask); - return TRUE; -} - -/*virtual*/ -BOOL LLPanelPresetsPulldown::handleDoubleClick(S32 x, S32 y, MASK mask) -{ - LLPanel::handleDoubleClick(x, y, mask); - return TRUE; -} - -/*virtual*/ -void LLPanelPresetsPulldown::onMouseLeave(S32 x, S32 y, MASK mask) -{ - mHoverTimer.start(); - LLPanel::onMouseLeave(x,y,mask); -} - -/*virtual*/ -void LLPanelPresetsPulldown::onVisibilityChange ( BOOL new_visibility ) -{ - if (new_visibility) - { - mHoverTimer.start(); // timer will be stopped when mouse hovers over panel - } - else - { - mHoverTimer.stop(); - - } -} - void LLPanelPresetsPulldown::onRowClick(const LLSD& user_data) { LLScrollListCtrl* scroll = getChild("preset_list"); @@ -212,19 +154,3 @@ void LLPanelPresetsPulldown::onGraphicsButtonClick(const LLSD& user_data) } } } - -//virtual -void LLPanelPresetsPulldown::draw() -{ - F32 alpha = mHoverTimer.getStarted() - ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f) - : 1.0f; - LLViewDrawContext context(alpha); - - LLPanel::draw(); - - if (alpha == 0.f) - { - setVisible(FALSE); - } -} diff --git a/indra/newview/llpanelpresetspulldown.h b/indra/newview/llpanelpresetspulldown.h index 322bf5a58f..c0d32b9b21 100644 --- a/indra/newview/llpanelpresetspulldown.h +++ b/indra/newview/llpanelpresetspulldown.h @@ -29,22 +29,13 @@ #include "linden_common.h" -#include "llpanel.h" +#include "llpanelpulldown.h" -class LLFrameTimer; -class LLPanelPresetsPulldown : public LLPanel +class LLPanelPresetsPulldown : public LLPanelPulldown { public: LLPanelPresetsPulldown(); - /*virtual*/ void draw(); - /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); - /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); - /*virtual*/ void onTopLost(); - /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); /*virtual*/ BOOL postBuild(); void populatePanel(); @@ -53,9 +44,6 @@ class LLPanelPresetsPulldown : public LLPanel void onRowClick(const LLSD& user_data); std::list mPresetNames; - LLFrameTimer mHoverTimer; - static const F32 sAutoCloseFadeStartTimeSec; - static const F32 sAutoCloseTotalTimeSec; LOG_CLASS(LLPanelPresetsPulldown); }; diff --git a/indra/newview/llpanelpulldown.cpp b/indra/newview/llpanelpulldown.cpp new file mode 100644 index 0000000000..4de6ee8182 --- /dev/null +++ b/indra/newview/llpanelpulldown.cpp @@ -0,0 +1,118 @@ +/** +* @file llpanelpulldown.cpp +* @brief A panel that serves as a basis for multiple toolbar pulldown panels +* +* $LicenseInfo:firstyear=2020&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2020, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "llpanelpulldown.h" + +const F32 AUTO_CLOSE_FADE_TIME_START_SEC = 2.0f; +const F32 AUTO_CLOSE_FADE_TIME_END_SEC = 3.0f; + +///---------------------------------------------------------------------------- +/// Class LLPanelPresetsCameraPulldown +///---------------------------------------------------------------------------- + +// Default constructor +LLPanelPulldown::LLPanelPulldown() +{ + mHoverTimer.stop(); +} + +/*virtual*/ +void LLPanelPulldown::onMouseEnter(S32 x, S32 y, MASK mask) +{ + mHoverTimer.stop(); + LLPanel::onMouseEnter(x, y, mask); +} + +/*virtual*/ +void LLPanelPulldown::onTopLost() +{ + setVisible(FALSE); +} + +/*virtual*/ +BOOL LLPanelPulldown::handleMouseDown(S32 x, S32 y, MASK mask) +{ + LLPanel::handleMouseDown(x, y, mask); + return TRUE; +} + +/*virtual*/ +BOOL LLPanelPulldown::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + LLPanel::handleRightMouseDown(x, y, mask); + return TRUE; +} + +/*virtual*/ +BOOL LLPanelPulldown::handleDoubleClick(S32 x, S32 y, MASK mask) +{ + LLPanel::handleDoubleClick(x, y, mask); + return TRUE; +} + +BOOL LLPanelPulldown::handleScrollWheel(S32 x, S32 y, S32 clicks) +{ + LLPanel::handleScrollWheel(x, y, clicks); + return TRUE; //If we got here, then we are in Pulldown's rect, consume the event. +} + +/*virtual*/ +void LLPanelPulldown::onMouseLeave(S32 x, S32 y, MASK mask) +{ + mHoverTimer.start(); + LLPanel::onMouseLeave(x, y, mask); +} + +/*virtual*/ +void LLPanelPulldown::onVisibilityChange(BOOL new_visibility) +{ + if (new_visibility) + { + mHoverTimer.start(); // timer will be stopped when mouse hovers over panel + } + else + { + mHoverTimer.stop(); + } +} + +//virtual +void LLPanelPulldown::draw() +{ + F32 alpha = mHoverTimer.getStarted() + ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), AUTO_CLOSE_FADE_TIME_START_SEC, AUTO_CLOSE_FADE_TIME_END_SEC, 1.f, 0.f) + : 1.0f; + LLViewDrawContext context(alpha); + + LLPanel::draw(); + + if (alpha == 0.f) + { + setVisible(FALSE); + } +} diff --git a/indra/newview/llpanelpulldown.h b/indra/newview/llpanelpulldown.h new file mode 100644 index 0000000000..705e76d0ab --- /dev/null +++ b/indra/newview/llpanelpulldown.h @@ -0,0 +1,55 @@ +/** + * @file llpanelpulldown.h + * @brief A panel that serves as a basis for multiple toolbar pulldown panels + * + * $LicenseInfo:firstyear=2020&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2020, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLPANELPULLDOWN_H +#define LL_LLPANELPULLDOWN_H + +#include "linden_common.h" + +#include "llpanel.h" + +class LLFrameTimer; + +class LLPanelPulldown : public LLPanel +{ +public: + LLPanelPulldown(); + /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); + /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); + /*virtual*/ void onTopLost(); + /*virtual*/ void onVisibilityChange(BOOL new_visibility); + + /*virtual*/ void draw(); + +protected: + LLFrameTimer mHoverTimer; +}; + +#endif // LL_LLPANELPULLDOWN_H diff --git a/indra/newview/llpanelvolumepulldown.cpp b/indra/newview/llpanelvolumepulldown.cpp index f063d84272..6f11e76a72 100644 --- a/indra/newview/llpanelvolumepulldown.cpp +++ b/indra/newview/llpanelvolumepulldown.cpp @@ -41,9 +41,6 @@ #include "llfloaterpreference.h" #include "llsliderctrl.h" -/* static */ const F32 LLPanelVolumePulldown::sAutoCloseFadeStartTimeSec = 2.0f; -/* static */ const F32 LLPanelVolumePulldown::sAutoCloseTotalTimeSec = 3.0f; - ///---------------------------------------------------------------------------- /// Class LLPanelVolumePulldown ///---------------------------------------------------------------------------- @@ -51,8 +48,6 @@ // Default constructor LLPanelVolumePulldown::LLPanelVolumePulldown() { - mHoverTimer.stop(); - mCommitCallbackRegistrar.add("Vol.setControlFalse", boost::bind(&LLPanelVolumePulldown::setControlFalse, this, _2)); mCommitCallbackRegistrar.add("Vol.SetSounds", boost::bind(&LLPanelVolumePulldown::onClickSetSounds, this)); mCommitCallbackRegistrar.add("Vol.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelVolumePulldown::updateMediaAutoPlayCheckbox, this, _1)); @@ -62,41 +57,7 @@ LLPanelVolumePulldown::LLPanelVolumePulldown() BOOL LLPanelVolumePulldown::postBuild() { - return LLPanel::postBuild(); -} - -/*virtual*/ -void LLPanelVolumePulldown::onMouseEnter(S32 x, S32 y, MASK mask) -{ - mHoverTimer.stop(); - LLPanel::onMouseEnter(x,y,mask); -} - -/*virtual*/ -void LLPanelVolumePulldown::onTopLost() -{ - setVisible(FALSE); -} - -/*virtual*/ -void LLPanelVolumePulldown::onMouseLeave(S32 x, S32 y, MASK mask) -{ - mHoverTimer.start(); - LLPanel::onMouseLeave(x,y,mask); -} - -/*virtual*/ -void LLPanelVolumePulldown::onVisibilityChange ( BOOL new_visibility ) -{ - if (new_visibility) - { - mHoverTimer.start(); // timer will be stopped when mouse hovers over panel - } - else - { - mHoverTimer.stop(); - - } + return LLPanelPulldown::postBuild(); } void LLPanelVolumePulldown::onAdvancedButtonClick(const LLSD& user_data) @@ -150,20 +111,3 @@ void LLPanelVolumePulldown::onClickSetSounds() // or if sound effects are disabled. getChild("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds")); } - -//virtual -void LLPanelVolumePulldown::draw() -{ - F32 alpha = mHoverTimer.getStarted() - ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f) - : 1.0f; - LLViewDrawContext context(alpha); - - LLPanel::draw(); - - if (alpha == 0.f) - { - setVisible(FALSE); - } -} - diff --git a/indra/newview/llpanelvolumepulldown.h b/indra/newview/llpanelvolumepulldown.h index 4f23112f50..e907bb0c78 100644 --- a/indra/newview/llpanelvolumepulldown.h +++ b/indra/newview/llpanelvolumepulldown.h @@ -30,19 +30,12 @@ #include "linden_common.h" -#include "llpanel.h" +#include "llpanelpulldown.h" -class LLFrameTimer; - -class LLPanelVolumePulldown : public LLPanel +class LLPanelVolumePulldown : public LLPanelPulldown { public: LLPanelVolumePulldown(); - /*virtual*/ void draw(); - /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); - /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); - /*virtual*/ void onTopLost(); - /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); /*virtual*/ BOOL postBuild(); private: @@ -52,10 +45,6 @@ class LLPanelVolumePulldown : public LLPanel // "Streaming Music" and "Media" are unchecked. Otherwise enables it. void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl); void onAdvancedButtonClick(const LLSD& user_data); - - LLFrameTimer mHoverTimer; - static const F32 sAutoCloseFadeStartTimeSec; - static const F32 sAutoCloseTotalTimeSec; }; From f96fb4fe4e8f7e72607862d10c5212f2108bec88 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 10 Apr 2020 15:34:23 +0300 Subject: [PATCH 2/7] SL-12999 Removed unused variables --- indra/newview/llpanelnearbymedia.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index a8887eb936..02911313ed 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -66,9 +66,6 @@ extern LLControlGroup gSavedSettings; static const LLUUID PARCEL_MEDIA_LIST_ITEM_UUID = LLUUID("CAB5920F-E484-4233-8621-384CF373A321"); static const LLUUID PARCEL_AUDIO_LIST_ITEM_UUID = LLUUID("DF4B020D-8A24-4B95-AB5D-CA970D694822"); -const F32 AUTO_CLOSE_FADE_TIME_START= 2.0f; -const F32 AUTO_CLOSE_FADE_TIME_END = 3.0f; - // // LLPanelNearByMedia // From 1ec8c7a68adb10c78e1cc31182b797d6a2ae386f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 10 Apr 2020 17:06:14 +0300 Subject: [PATCH 3/7] SL-12999 List can go out of floater's rect, so it should consume scroll events --- indra/newview/skins/default/xui/en/floater_camera.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml index 60461c5743..9deb38e3af 100644 --- a/indra/newview/skins/default/xui/en/floater_camera.xml +++ b/indra/newview/skins/default/xui/en/floater_camera.xml @@ -217,6 +217,8 @@ name="preset_combo" top_pad="10" width="136"> + Date: Fri, 10 Apr 2020 18:38:56 +0300 Subject: [PATCH 4/7] SL-12994 FIXED [Camera Presets] Zoom fraction should be saved as a part of Camera preset, not as separate setting --- indra/newview/llagentcamera.cpp | 8 ++++++-- indra/newview/llagentcamera.h | 3 +++ indra/newview/llfloatercamera.cpp | 3 ++- indra/newview/llfloatersavecamerapreset.cpp | 6 ++++++ indra/newview/llpresetsmanager.cpp | 3 --- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index d1da132587..f1d8bf3cf1 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1987,8 +1987,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 LLAgentCamera::getCurrentCameraOffset() { - LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~getCurrentAvatarRotation(); - return camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale"); + return (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~getCurrentAvatarRotation(); } LLVector3d LLAgentCamera::getCurrentFocusOffset() @@ -2829,6 +2828,11 @@ BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, return mPointAt->setPointAt(target_type, object, position); } +void LLAgentCamera::resetCameraZoomFraction() +{ + mCameraZoomFraction = INITIAL_ZOOM_FRACTION; +} + ELookAtType LLAgentCamera::getLookAtType() { if (mLookAt) diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 357dd5e12a..420cc0b601 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -282,6 +282,9 @@ public: F32 calcCameraFOVZoomFactor(); F32 getAgentHUDTargetZoom(); + void resetCameraZoomFraction(); + F32 getCurrentCameraZoomFraction() { return mCameraZoomFraction; } + //-------------------------------------------------------------------- // Pan //-------------------------------------------------------------------- diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index cc02862868..e1e7ee8445 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -565,7 +565,8 @@ void LLFloaterCamera::switchToPreset(const std::string& name) { LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name); } - gAgentCamera.setCameraZoomFraction(gSavedSettings.getF32("CameraZoomFraction")); + + gAgentCamera.resetCameraZoomFraction(); LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); if (camera_floater) diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp index 34aefdf1c1..e2bd2e6d6a 100644 --- a/indra/newview/llfloatersavecamerapreset.cpp +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -107,6 +107,12 @@ void LLFloaterSaveCameraPreset::onBtnSave() gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset()); gSavedSettings.setVector3d("FocusOffsetRearView", gAgentCamera.getCurrentFocusOffset()); } + else + { + LLVector3 camera_offset = gSavedSettings.getVector3("CameraOffsetRearView") * gAgentCamera.getCurrentCameraZoomFraction(); + gSavedSettings.setVector3("CameraOffsetRearView", camera_offset); + gAgentCamera.resetCameraZoomFraction(); + } if (is_saving_new) { std::list preset_names; diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index fd89a1fcb6..129187ccbd 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -309,9 +309,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n name_list.clear(); getControlNames(name_list); name_list.push_back("PresetCameraActive"); - - gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction(true)); - name_list.push_back("CameraZoomFraction"); } else { From 70d340a1bff2707138ac41fdd1408a5b2e46fc71 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 13 Apr 2020 20:02:58 +0300 Subject: [PATCH 5/7] SL-12993 Focus on avatar after saving new preset --- indra/newview/llagentcamera.cpp | 4 ++-- indra/newview/llagentcamera.h | 2 +- indra/newview/llfloatersavecamerapreset.cpp | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index f1d8bf3cf1..5efd614b22 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2656,7 +2656,7 @@ void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camer //----------------------------------------------------------------------------- // setFocusOnAvatar() //----------------------------------------------------------------------------- -void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) +void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate, BOOL reset_axes) { if (focus_on_avatar != mFocusOnAvatar) { @@ -2673,7 +2673,7 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) //RN: when focused on the avatar, we're not "looking" at it // looking implies intent while focusing on avatar means // you're just walking around with a camera on you...eesh. - if (!mFocusOnAvatar && focus_on_avatar) + if (!mFocusOnAvatar && focus_on_avatar && reset_axes) { setFocusGlobal(LLVector3d::zero); mCameraFOVZoomFactor = 0.f; diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 420cc0b601..841b0e353d 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -217,7 +217,7 @@ public: void validateFocusObject(); void setFocusGlobal(const LLPickInfo& pick); void setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null); - void setFocusOnAvatar(BOOL focus, BOOL animate); + void setFocusOnAvatar(BOOL focus, BOOL animate, BOOL reset_axes = TRUE); void setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id); void clearFocusObject(); void setFocusObject(LLViewerObject* object); diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp index e2bd2e6d6a..c02f8f0ea1 100644 --- a/indra/newview/llfloatersavecamerapreset.cpp +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -106,6 +106,8 @@ void LLFloaterSaveCameraPreset::onBtnSave() { gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset()); gSavedSettings.setVector3d("FocusOffsetRearView", gAgentCamera.getCurrentFocusOffset()); + gAgentCamera.resetCameraZoomFraction(); + gAgentCamera.setFocusOnAvatar(TRUE, TRUE, FALSE); } else { From 74d6e6b65c9c3e85e8ec84939b35a1e584379e1f Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 20 Apr 2020 14:27:22 +0300 Subject: [PATCH 6/7] SL-12904 FIXED Camera Preset does not restore correctly when sitting --- indra/llmath/llquaternion.h | 24 ++++++++++ indra/llxml/llcontrol.cpp | 51 +++++++++++++++++++++ indra/llxml/llcontrol.h | 15 ++++-- indra/llxml/llcontrolgroupreader.h | 1 + indra/newview/app_settings/camera/Front.xml | 16 +++++++ indra/newview/app_settings/camera/Rear.xml | 16 +++++++ indra/newview/app_settings/camera/Side.xml | 16 +++++++ indra/newview/app_settings/settings.xml | 16 +++++++ indra/newview/llagentcamera.cpp | 15 ++++-- indra/newview/llagentcamera.h | 4 ++ indra/newview/llfloatercamera.cpp | 14 ++++++ indra/newview/llfloatersavecamerapreset.cpp | 6 +++ indra/newview/llfloatersettingsdebug.cpp | 42 +++++++++++++++++ indra/newview/llpresetsmanager.cpp | 1 + indra/newview/llvoavatar.cpp | 3 +- 15 files changed, 232 insertions(+), 8 deletions(-) diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h index aa0b1752f4..95e4c09695 100644 --- a/indra/llmath/llquaternion.h +++ b/indra/llmath/llquaternion.h @@ -28,6 +28,7 @@ #define LLQUATERNION_H #include +#include #ifndef LLMATH_H //enforce specific include order to avoid tangling inline dependencies #error "Please include llmath.h first." @@ -64,6 +65,29 @@ public: const LLVector3 &y_axis, const LLVector3 &z_axis); // Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis] + explicit LLQuaternion(const LLSD& sd) + { + setValue(sd); + } + + void setValue(const LLSD& sd) + { + mQ[VX] = (F32) sd[0].asReal(); + mQ[VY] = (F32) sd[1].asReal(); + mQ[VZ] = (F32) sd[2].asReal(); + mQ[VS] = (F32) sd[3].asReal(); + } + + LLSD getValue() const + { + LLSD ret; + ret[0] = mQ[VX]; + ret[1] = mQ[VY]; + ret[2] = mQ[VZ]; + ret[3] = mQ[VS]; + return ret; + } + BOOL isIdentity() const; BOOL isNotIdentity() const; BOOL isFinite() const; // checks to see if all values of LLQuaternion are finite diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index ccf4f3ddf5..80a414d00f 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -40,6 +40,7 @@ #include "v4coloru.h" #include "v4color.h" #include "v3color.h" +#include "llquaternion.h" #include "llrect.h" #include "llxmltree.h" #include "llsdserialize.h" @@ -125,6 +126,9 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) case TYPE_VEC3D: result = LLVector3d(a) == LLVector3d(b); break; + case TYPE_QUAT: + result = LLQuaternion(a) == LLQuaternion(b); + break; case TYPE_RECT: result = LLRect(a) == LLRect(b); break; @@ -361,6 +365,7 @@ const std::string LLControlGroup::mTypeString[TYPE_COUNT] = { "U32" ,"String" ,"Vector3" ,"Vector3D" + ,"Quaternion" ,"Rect" ,"Color4" ,"Color3" @@ -523,6 +528,11 @@ LLControlVariable* LLControlGroup::declareVec3d(const std::string& name, const L return declareControl(name, TYPE_VEC3D, initial_val.getValue(), comment, persist); } +LLControlVariable* LLControlGroup::declareQuat(const std::string& name, const LLQuaternion &initial_val, const std::string& comment, LLControlVariable::ePersist persist) +{ + return declareControl(name, TYPE_QUAT, initial_val.getValue(), comment, persist); +} + LLControlVariable* LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist) { return declareControl(name, TYPE_RECT, initial_val.getValue(), comment, persist); @@ -600,6 +610,11 @@ LLVector3d LLControlGroup::getVector3d(const std::string& name) return get(name); } +LLQuaternion LLControlGroup::getQuaternion(const std::string& name) +{ + return get(name); +} + LLRect LLControlGroup::getRect(const std::string& name) { return get(name); @@ -677,6 +692,11 @@ void LLControlGroup::setVector3d(const std::string& name, const LLVector3d &val) set(name, val); } +void LLControlGroup::setQuaternion(const std::string& name, const LLQuaternion &val) +{ + set(name, val); +} + void LLControlGroup::setRect(const std::string& name, const LLRect &val) { set(name, val); @@ -859,6 +879,16 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require validitems++; } break; + case TYPE_QUAT: + { + LLQuaternion quat; + + child_nodep->getAttributeQuat("value", quat); + + control->set(quat.getValue()); + validitems++; + } + break; case TYPE_RECT: { //RN: hack to support reading rectangles from a string @@ -1201,6 +1231,11 @@ template <> eControlType get_control_type() return TYPE_VEC3D; } +template <> eControlType get_control_type() +{ + return TYPE_QUAT; +} + template <> eControlType get_control_type() { return TYPE_RECT; @@ -1236,6 +1271,10 @@ template <> LLSD convert_to_llsd(const LLVector3d& in) { return in.getValue(); } +template <> LLSD convert_to_llsd(const LLQuaternion& in) +{ + return in.getValue(); +} template <> LLSD convert_to_llsd(const LLRect& in) { @@ -1348,6 +1387,18 @@ LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, cons } } +template<> +LLQuaternion convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +{ + if (type == TYPE_QUAT) + return (LLQuaternion)sd; + else + { + CONTROL_ERRS << "Invalid LLQuaternion value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL; + return LLQuaternion(); + } +} + template<> LLRect convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) { diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index de0d366492..f136918896 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -67,6 +67,7 @@ class LLVector3; class LLVector3d; +class LLQuaternion; class LLColor4; class LLColor3; @@ -80,6 +81,7 @@ typedef enum e_control_type TYPE_STRING, TYPE_VEC3, TYPE_VEC3D, + TYPE_QUAT, TYPE_RECT, TYPE_COL4, TYPE_COL3, @@ -220,6 +222,7 @@ public: LLControlVariable* declareString(const std::string& name, const std::string &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareQuat(const std::string& name, const LLQuaternion &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); @@ -234,10 +237,10 @@ public: LLWString getWString(const std::string& name); LLVector3 getVector3(const std::string& name); - LLVector3d getVector3d(const std::string& name); + LLVector3d getVector3d(const std::string& name); LLRect getRect(const std::string& name); LLSD getLLSD(const std::string& name); - + LLQuaternion getQuaternion(const std::string& name); LLColor4 getColor(const std::string& name); LLColor4 getColor4(const std::string& name); @@ -270,6 +273,7 @@ public: void setString(const std::string& name, const std::string& val); void setVector3(const std::string& name, const LLVector3 &val); void setVector3d(const std::string& name, const LLVector3d &val); + void setQuaternion(const std::string& name, const LLQuaternion &val); void setRect(const std::string& name, const LLRect &val); void setColor4(const std::string& name, const LLColor4 &val); void setLLSD(const std::string& name, const LLSD& val); @@ -436,7 +440,8 @@ template <> eControlType get_control_type(); //template <> eControlType get_control_type () template <> eControlType get_control_type(); template <> eControlType get_control_type(); -template <> eControlType get_control_type(); +template <> eControlType get_control_type(); +template <> eControlType get_control_type(); template <> eControlType get_control_type(); template <> eControlType get_control_type(); template <> eControlType get_control_type(); @@ -444,7 +449,8 @@ template <> eControlType get_control_type(); template <> LLSD convert_to_llsd(const U32& in); template <> LLSD convert_to_llsd(const LLVector3& in); -template <> LLSD convert_to_llsd(const LLVector3d& in); +template <> LLSD convert_to_llsd(const LLVector3d& in); +template <> LLSD convert_to_llsd(const LLQuaternion& in); template <> LLSD convert_to_llsd(const LLRect& in); template <> LLSD convert_to_llsd(const LLColor4& in); template <> LLSD convert_to_llsd(const LLColor3& in); @@ -453,6 +459,7 @@ template<> std::string convert_from_llsd(const LLSD& sd, eControlTy template<> LLWString convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> LLVector3 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); +template<> LLQuaternion convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> LLRect convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> bool convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> S32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); diff --git a/indra/llxml/llcontrolgroupreader.h b/indra/llxml/llcontrolgroupreader.h index 6a27a65499..fe77d33fc4 100644 --- a/indra/llxml/llcontrolgroupreader.h +++ b/indra/llxml/llcontrolgroupreader.h @@ -65,6 +65,7 @@ public: virtual void setString(const std::string& name, const std::string& val) {} virtual void setVector3(const std::string& name, const LLVector3 &val) {} virtual void setVector3d(const std::string& name, const LLVector3d &val) {} + virtual void setQuaternion(const std::string& name, const LLQuaternion &val) {} virtual void setRect(const std::string& name, const LLRect &val) {} virtual void setColor4(const std::string& name, const LLColor4 &val) {} virtual void setLLSD(const std::string& name, const LLSD& val) {} diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml index 7b5d597fdf..f9f615c4a7 100644 --- a/indra/newview/app_settings/camera/Front.xml +++ b/indra/newview/app_settings/camera/Front.xml @@ -11,6 +11,22 @@ Value 1 + AvatarSitRotation + + Comment + Avatar real sitting rotation used in preset + Persist + 1 + Type + Quaternion + Value + + 0 + 0 + 0 + 1 + + CameraAngle Comment diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml index 7aa36c3e59..a084f83bfe 100644 --- a/indra/newview/app_settings/camera/Rear.xml +++ b/indra/newview/app_settings/camera/Rear.xml @@ -11,6 +11,22 @@ Value 1 + AvatarSitRotation + + Comment + Avatar real sitting rotation used in preset + Persist + 1 + Type + Quaternion + Value + + 0 + 0 + 0 + 1 + + CameraAngle Comment diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml index 8890d9cbce..5db5b164bd 100644 --- a/indra/newview/app_settings/camera/Side.xml +++ b/indra/newview/app_settings/camera/Side.xml @@ -11,6 +11,22 @@ Value 1 + AvatarSitRotation + + Comment + Avatar real sitting rotation used in preset + Persist + 1 + Type + Quaternion + Value + + 0 + 0 + 0 + 1 + + CameraAngle Comment diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index cc86ba85c1..84448919e1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4397,6 +4397,22 @@ 1.0 + AvatarSitRotation + + Comment + Avatar real sitting rotation used in preset + Persist + 1 + Type + Quaternion + Value + + 0 + 0 + 0 + 1 + + FocusPosOnLogout Comment diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 5efd614b22..7a82cf2f66 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1804,8 +1804,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) at_axis.mV[VZ] = 0.f; at_axis.normalize(); gAgent.resetAxes(at_axis * ~parent_rot); - - local_camera_offset = local_camera_offset * parent_rot; + + local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot; } else { @@ -1998,7 +1998,10 @@ LLVector3d LLAgentCamera::getCurrentFocusOffset() LLQuaternion LLAgentCamera::getCurrentAvatarRotation() { LLViewerObject* sit_object = (LLViewerObject*)gAgentAvatarp->getParent(); - return sit_object ? sit_object->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); + + LLQuaternion av_rot = gAgent.getFrameAgent().getQuaternion(); + LLQuaternion obj_rot = sit_object ? sit_object->getRenderRotation() : LLQuaternion::DEFAULT; + return av_rot * obj_rot; } bool LLAgentCamera::isJoystickCameraUsed() @@ -2828,6 +2831,12 @@ BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, return mPointAt->setPointAt(target_type, object, position); } +void LLAgentCamera::rotateToInitSitRot() +{ + gAgent.rotate(~gAgent.getFrameAgent().getQuaternion()); + gAgent.rotate(mInitSitRot); +} + void LLAgentCamera::resetCameraZoomFraction() { mCameraZoomFraction = INITIAL_ZOOM_FRACTION; diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 841b0e353d..ec1ed433d7 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -121,6 +121,8 @@ public: LLVector3d getCurrentFocusOffset(); LLQuaternion getCurrentAvatarRotation(); bool isJoystickCameraUsed(); + void setInitSitRot(LLQuaternion sit_rot) { mInitSitRot = sit_rot; }; + void rotateToInitSitRot(); private: /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */ @@ -135,6 +137,8 @@ private: /** Initial focus offset */ LLPointer mFocusOffsetInitial; + LLQuaternion mInitSitRot; + //-------------------------------------------------------------------- // Position //-------------------------------------------------------------------- diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index e1e7ee8445..2399e4f495 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -44,6 +44,7 @@ #include "llfirstuse.h" #include "llhints.h" #include "lltabcontainer.h" +#include "llvoavatarself.h" static LLDefaultChildRegistry::Register r("panel_camera_item"); @@ -566,6 +567,19 @@ void LLFloaterCamera::switchToPreset(const std::string& name) LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name); } + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + LLQuaternion sit_rot = gSavedSettings.getQuaternion("AvatarSitRotation"); + if (sit_rot != LLQuaternion()) + { + gAgent.rotate(~gAgent.getFrameAgent().getQuaternion()); + gAgent.rotate(sit_rot); + } + else + { + gAgentCamera.rotateToInitSitRot(); + } + } gAgentCamera.resetCameraZoomFraction(); LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp index c02f8f0ea1..5704a7a525 100644 --- a/indra/newview/llfloatersavecamerapreset.cpp +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -28,6 +28,7 @@ #include "llfloatersavecamerapreset.h" +#include "llagent.h" #include "llagentcamera.h" #include "llbutton.h" #include "llcombobox.h" @@ -38,6 +39,7 @@ #include "llpresetsmanager.h" #include "llradiogroup.h" #include "lltrans.h" +#include "llvoavatarself.h" LLFloaterSaveCameraPreset::LLFloaterSaveCameraPreset(const LLSD &key) : LLModalDialog(key) @@ -102,6 +104,10 @@ void LLFloaterSaveCameraPreset::onBtnSave() } else { + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + gSavedSettings.setQuaternion("AvatarSitRotation", gAgent.getFrameAgent().getQuaternion()); + } if (gAgentCamera.isJoystickCameraUsed()) { gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset()); diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp index fb202b4c40..186994c857 100644 --- a/indra/newview/llfloatersettingsdebug.cpp +++ b/indra/newview/llfloatersettingsdebug.cpp @@ -111,6 +111,7 @@ void LLFloaterSettingsDebug::onCommitSettings() LLVector3 vector; LLVector3d vectord; + LLQuaternion quat; LLRect rect; LLColor4 col4; LLColor3 col3; @@ -146,6 +147,13 @@ void LLFloaterSettingsDebug::onCommitSettings() vectord.mdV[VZ] = getChild("val_spinner_3")->getValue().asReal(); controlp->set(vectord.getValue()); break; + case TYPE_QUAT: + quat.mQ[VX] = getChild("val_spinner_1")->getValue().asReal(); + quat.mQ[VY] = getChild("val_spinner_2")->getValue().asReal(); + quat.mQ[VZ] = getChild("val_spinner_3")->getValue().asReal(); + quat.mQ[VS] = getChild("val_spinner_4")->getValue().asReal();; + controlp->set(quat.getValue()); + break; case TYPE_RECT: rect.mLeft = getChild("val_spinner_1")->getValue().asInteger(); rect.mRight = getChild("val_spinner_2")->getValue().asInteger(); @@ -351,6 +359,40 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) } break; } + case TYPE_QUAT: + { + LLQuaternion q; + q.setValue(sd); + spinner1->setVisible(TRUE); + spinner1->setLabel(std::string("X")); + spinner2->setVisible(TRUE); + spinner2->setLabel(std::string("Y")); + spinner3->setVisible(TRUE); + spinner3->setLabel(std::string("Z")); + spinner4->setVisible(TRUE); + spinner4->setLabel(std::string("S")); + if (!spinner1->hasFocus()) + { + spinner1->setPrecision(4); + spinner1->setValue(q.mQ[VX]); + } + if (!spinner2->hasFocus()) + { + spinner2->setPrecision(4); + spinner2->setValue(q.mQ[VY]); + } + if (!spinner3->hasFocus()) + { + spinner3->setPrecision(4); + spinner3->setValue(q.mQ[VZ]); + } + if (!spinner4->hasFocus()) + { + spinner4->setPrecision(4); + spinner4->setValue(q.mQ[VS]); + } + break; + } case TYPE_RECT: { LLRect r; diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 129187ccbd..4dbd6a523d 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -261,6 +261,7 @@ void LLPresetsManager::getControlNames(std::vector& names) ("TrackFocusObject") ("CameraOffsetRearView") ("FocusOffsetRearView") + ("AvatarSitRotation") ; names = camera_controls; } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index b524db478e..7fb4cc6822 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -7336,7 +7336,8 @@ void LLVOAvatar::sitOnObject(LLViewerObject *sit_object) mRoot->updateWorldMatrixChildren(); stopMotion(ANIM_AGENT_BODY_NOISE); - + + gAgentCamera.setInitSitRot(gAgent.getFrameAgent().getQuaternion()); } //----------------------------------------------------------------------------- From 2ea5c5986a467e253ad0131b4af0faee23b263a4 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 23 Apr 2020 13:22:27 +0300 Subject: [PATCH 7/7] SL-12904 Temporarily use LLSD to avoid crashes on older viewers --- indra/newview/app_settings/camera/Front.xml | 2 +- indra/newview/app_settings/camera/Rear.xml | 2 +- indra/newview/app_settings/camera/Side.xml | 2 +- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llfloatercamera.cpp | 2 +- indra/newview/llfloatersavecamerapreset.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml index f9f615c4a7..39f44e11a8 100644 --- a/indra/newview/app_settings/camera/Front.xml +++ b/indra/newview/app_settings/camera/Front.xml @@ -18,7 +18,7 @@ Persist 1 Type - Quaternion + LLSD Value 0 diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml index a084f83bfe..8dc36353ce 100644 --- a/indra/newview/app_settings/camera/Rear.xml +++ b/indra/newview/app_settings/camera/Rear.xml @@ -18,7 +18,7 @@ Persist 1 Type - Quaternion + LLSD Value 0 diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml index 5db5b164bd..089ab93a8f 100644 --- a/indra/newview/app_settings/camera/Side.xml +++ b/indra/newview/app_settings/camera/Side.xml @@ -18,7 +18,7 @@ Persist 1 Type - Quaternion + LLSD Value 0 diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 84448919e1..3e3d6a7237 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4404,7 +4404,7 @@ Persist 1 Type - Quaternion + LLSD Value 0 diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index 2399e4f495..d574f1433f 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -569,7 +569,7 @@ void LLFloaterCamera::switchToPreset(const std::string& name) if (isAgentAvatarValid() && gAgentAvatarp->getParent()) { - LLQuaternion sit_rot = gSavedSettings.getQuaternion("AvatarSitRotation"); + LLQuaternion sit_rot(gSavedSettings.getLLSD("AvatarSitRotation")); if (sit_rot != LLQuaternion()) { gAgent.rotate(~gAgent.getFrameAgent().getQuaternion()); diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp index 5704a7a525..11809f9c82 100644 --- a/indra/newview/llfloatersavecamerapreset.cpp +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -106,7 +106,7 @@ void LLFloaterSaveCameraPreset::onBtnSave() { if (isAgentAvatarValid() && gAgentAvatarp->getParent()) { - gSavedSettings.setQuaternion("AvatarSitRotation", gAgent.getFrameAgent().getQuaternion()); + gSavedSettings.setLLSD("AvatarSitRotation", gAgent.getFrameAgent().getQuaternion().getValue()); } if (gAgentCamera.isJoystickCameraUsed()) {