diff options
author | Graham Linden <graham@lindenlab.com> | 2019-03-11 08:11:09 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-03-11 08:11:09 -0700 |
commit | 3e560022459bf3534b873a7f6499dfb5eb75a7d9 (patch) | |
tree | 26f134322e5d12add8960a8ecd563b0f9b2918d0 /indra | |
parent | 52566e4b333a6f91c04034a6bdcb1e9099371d12 (diff) |
Tabs -> spaces.
Diffstat (limited to 'indra')
24 files changed, 10337 insertions, 10337 deletions
diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp index a310fc0508..35bda78463 100755 --- a/indra/llcorehttp/tests/llcorehttp_test.cpp +++ b/indra/llcorehttp/tests/llcorehttp_test.cpp @@ -51,26 +51,26 @@ unsigned long ssl_thread_id_callback(void); void ssl_locking_callback(int mode, int type, const char * file, int line); -#if 0 // lltut provides main and runner +#if 0 // lltut provides main and runner namespace tut { - test_runner_singleton runner; + test_runner_singleton runner; } int main() { - curl_global_init(CURL_GLOBAL_ALL); + curl_global_init(CURL_GLOBAL_ALL); - // *FIXME: Need threaded/SSL curl setup here. - - tut::reporter reporter; + // *FIXME: Need threaded/SSL curl setup here. + + tut::reporter reporter; - tut::runner.get().set_callback(&reporter); - tut::runner.get().run_tests(); - return !reporter.all_ok(); + tut::runner.get().set_callback(&reporter); + tut::runner.get().run_tests(); + return !reporter.all_ok(); - curl_global_cleanup(); + curl_global_cleanup(); } #endif // 0 @@ -80,97 +80,97 @@ LLCoreInt::HttpMutex ** ssl_mutex_list = NULL; void init_curl() { - curl_global_init(CURL_GLOBAL_ALL); - - ssl_mutex_count = CRYPTO_num_locks(); - if (ssl_mutex_count > 0) - { - ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count]; - - for (int i(0); i < ssl_mutex_count; ++i) - { - ssl_mutex_list[i] = new LLCoreInt::HttpMutex; - } - - CRYPTO_set_locking_callback(ssl_locking_callback); - CRYPTO_set_id_callback(ssl_thread_id_callback); - } - - LLProxy::getInstance(); + curl_global_init(CURL_GLOBAL_ALL); + + ssl_mutex_count = CRYPTO_num_locks(); + if (ssl_mutex_count > 0) + { + ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count]; + + for (int i(0); i < ssl_mutex_count; ++i) + { + ssl_mutex_list[i] = new LLCoreInt::HttpMutex; + } + + CRYPTO_set_locking_callback(ssl_locking_callback); + CRYPTO_set_id_callback(ssl_thread_id_callback); + } + + LLProxy::getInstance(); } void term_curl() { - SUBSYSTEM_CLEANUP(LLProxy); - - CRYPTO_set_locking_callback(NULL); - for (int i(0); i < ssl_mutex_count; ++i) - { - delete ssl_mutex_list[i]; - } - delete [] ssl_mutex_list; + SUBSYSTEM_CLEANUP(LLProxy); + + CRYPTO_set_locking_callback(NULL); + for (int i(0); i < ssl_mutex_count; ++i) + { + delete ssl_mutex_list[i]; + } + delete [] ssl_mutex_list; } unsigned long ssl_thread_id_callback(void) { #if defined(WIN32) - return (unsigned long) GetCurrentThread(); + return (unsigned long) GetCurrentThread(); #else - return (unsigned long) pthread_self(); + return (unsigned long) pthread_self(); #endif } void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */) { - if (type >= 0 && type < ssl_mutex_count) - { - if (mode & CRYPTO_LOCK) - { - ssl_mutex_list[type]->lock(); - } - else - { - ssl_mutex_list[type]->unlock(); - } - } + if (type >= 0 && type < ssl_mutex_count) + { + if (mode & CRYPTO_LOCK) + { + ssl_mutex_list[type]->lock(); + } + else + { + ssl_mutex_list[type]->unlock(); + } + } } std::string get_base_url() { - const char * env(getenv("LL_TEST_PORT")); - - if (! env) - { - std::cerr << "LL_TEST_PORT environment variable missing." << std::endl; - std::cerr << "Test expects to run in test_llcorehttp_peer.py script." << std::endl; - tut::ensure("LL_TEST_PORT set in environment", NULL != env); - } - - int port(atoi(env)); - std::ostringstream out; - out << "http://localhost:" << port << "/"; - return out.str(); + const char * env(getenv("LL_TEST_PORT")); + + if (! env) + { + std::cerr << "LL_TEST_PORT environment variable missing." << std::endl; + std::cerr << "Test expects to run in test_llcorehttp_peer.py script." << std::endl; + tut::ensure("LL_TEST_PORT set in environment", NULL != env); + } + + int port(atoi(env)); + std::ostringstream out; + out << "http://localhost:" << port << "/"; + return out.str(); } void stop_thread(LLCore::HttpRequest * req) { - if (req) - { - req->requestStopThread(LLCore::HttpHandler::ptr_t()); - - int count = 0; - int limit = 10; - while (count++ < limit && ! HttpService::isStopped()) - { - req->update(1000); - usleep(100000); - } - } + if (req) + { + req->requestStopThread(LLCore::HttpHandler::ptr_t()); + + int count = 0; + int limit = 10; + while (count++ < limit && ! HttpService::isStopped()) + { + req->update(1000); + usleep(100000); + } + } } - + diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 2dcc62ce79..6b325f6232 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -43,7 +43,7 @@ #include "llresizebar.h" #include "llresizehandle.h" #include "llkeyboard.h" -#include "llmenugl.h" // MENU_BAR_HEIGHT +#include "llmenugl.h" // MENU_BAR_HEIGHT #include "llmodaldialog.h" #include "lltextbox.h" #include "llresmgr.h" @@ -65,23 +65,23 @@ const S32 TABBED_FLOATER_OFFSET = 0; namespace LLInitParam { - void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues() - { - declare("relative", LLFloaterEnums::POSITIONING_RELATIVE); - declare("cascading", LLFloaterEnums::POSITIONING_CASCADING); - declare("centered", LLFloaterEnums::POSITIONING_CENTERED); - declare("specified", LLFloaterEnums::POSITIONING_SPECIFIED); - } + void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues() + { + declare("relative", LLFloaterEnums::POSITIONING_RELATIVE); + declare("cascading", LLFloaterEnums::POSITIONING_CASCADING); + declare("centered", LLFloaterEnums::POSITIONING_CENTERED); + declare("specified", LLFloaterEnums::POSITIONING_SPECIFIED); + } } -std::string LLFloater::sButtonNames[BUTTON_COUNT] = +std::string LLFloater::sButtonNames[BUTTON_COUNT] = { - "llfloater_close_btn", //BUTTON_CLOSE - "llfloater_restore_btn", //BUTTON_RESTORE - "llfloater_minimize_btn", //BUTTON_MINIMIZE - "llfloater_tear_off_btn", //BUTTON_TEAR_OFF - "llfloater_dock_btn", //BUTTON_DOCK - "llfloater_help_btn" //BUTTON_HELP + "llfloater_close_btn", //BUTTON_CLOSE + "llfloater_restore_btn", //BUTTON_RESTORE + "llfloater_minimize_btn", //BUTTON_MINIMIZE + "llfloater_tear_off_btn", //BUTTON_TEAR_OFF + "llfloater_dock_btn", //BUTTON_DOCK + "llfloater_help_btn" //BUTTON_HELP }; std::string LLFloater::sButtonToolTips[BUTTON_COUNT]; @@ -89,29 +89,29 @@ std::string LLFloater::sButtonToolTips[BUTTON_COUNT]; std::string LLFloater::sButtonToolTipsIndex[BUTTON_COUNT]= { #ifdef LL_DARWIN - "BUTTON_CLOSE_DARWIN", //"Close (Cmd-W)", //BUTTON_CLOSE + "BUTTON_CLOSE_DARWIN", //"Close (Cmd-W)", //BUTTON_CLOSE #else - "BUTTON_CLOSE_WIN", //"Close (Ctrl-W)", //BUTTON_CLOSE + "BUTTON_CLOSE_WIN", //"Close (Ctrl-W)", //BUTTON_CLOSE #endif - "BUTTON_RESTORE", //"Restore", //BUTTON_RESTORE - "BUTTON_MINIMIZE", //"Minimize", //BUTTON_MINIMIZE - "BUTTON_TEAR_OFF", //"Tear Off", //BUTTON_TEAR_OFF - "BUTTON_DOCK", - "BUTTON_HELP" + "BUTTON_RESTORE", //"Restore", //BUTTON_RESTORE + "BUTTON_MINIMIZE", //"Minimize", //BUTTON_MINIMIZE + "BUTTON_TEAR_OFF", //"Tear Off", //BUTTON_TEAR_OFF + "BUTTON_DOCK", + "BUTTON_HELP" }; LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] = { - LLFloater::onClickClose, //BUTTON_CLOSE - LLFloater::onClickMinimize, //BUTTON_RESTORE - LLFloater::onClickMinimize, //BUTTON_MINIMIZE - LLFloater::onClickTearOff, //BUTTON_TEAR_OFF - LLFloater::onClickDock, //BUTTON_DOCK - LLFloater::onClickHelp //BUTTON_HELP + LLFloater::onClickClose, //BUTTON_CLOSE + LLFloater::onClickMinimize, //BUTTON_RESTORE + LLFloater::onClickMinimize, //BUTTON_MINIMIZE + LLFloater::onClickTearOff, //BUTTON_TEAR_OFF + LLFloater::onClickDock, //BUTTON_DOCK + LLFloater::onClickHelp //BUTTON_HELP }; LLMultiFloater* LLFloater::sHostp = NULL; -BOOL LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting +BOOL LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting LLFloaterView* gFloaterView = NULL; @@ -128,105 +128,105 @@ LLFloaterView* gFloaterView = NULL; //static bool LLFloater::KeyCompare::compare(const LLSD& a, const LLSD& b) { - if (a.type() != b.type()) - { - //LL_ERRS() << "Mismatched LLSD types: (" << a << ") mismatches (" << b << ")" << LL_ENDL; - return false; - } - else if (a.isUndefined()) - return false; - else if (a.isInteger()) - return a.asInteger() < b.asInteger(); - else if (a.isReal()) - return a.asReal() < b.asReal(); - else if (a.isString()) - return a.asString() < b.asString(); - else if (a.isUUID()) - return a.asUUID() < b.asUUID(); - else if (a.isDate()) - return a.asDate() < b.asDate(); - else if (a.isURI()) - return a.asString() < b.asString(); // compare URIs as strings - else if (a.isBoolean()) - return a.asBoolean() < b.asBoolean(); - else - return false; // no valid operation for Binary + if (a.type() != b.type()) + { + //LL_ERRS() << "Mismatched LLSD types: (" << a << ") mismatches (" << b << ")" << LL_ENDL; + return false; + } + else if (a.isUndefined()) + return false; + else if (a.isInteger()) + return a.asInteger() < b.asInteger(); + else if (a.isReal()) + return a.asReal() < b.asReal(); + else if (a.isString()) + return a.asString() < b.asString(); + else if (a.isUUID()) + return a.asUUID() < b.asUUID(); + else if (a.isDate()) + return a.asDate() < b.asDate(); + else if (a.isURI()) + return a.asString() < b.asString(); // compare URIs as strings + else if (a.isBoolean()) + return a.asBoolean() < b.asBoolean(); + else + return false; // no valid operation for Binary } |*==========================================================================*/ bool LLFloater::KeyCompare::equate(const LLSD& a, const LLSD& b) { - return llsd_equals(a, b); + return llsd_equals(a, b); } //************************************ LLFloater::Params::Params() -: title("title"), - short_title("short_title"), - single_instance("single_instance", false), - reuse_instance("reuse_instance", false), - can_resize("can_resize", false), - can_minimize("can_minimize", true), - can_close("can_close", true), - can_drag_on_left("can_drag_on_left", false), - can_tear_off("can_tear_off", true), - save_dock_state("save_dock_state", false), - save_rect("save_rect", false), - save_visibility("save_visibility", false), - can_dock("can_dock", false), - show_title("show_title", true), - positioning("positioning", LLFloaterEnums::POSITIONING_RELATIVE), - header_height("header_height", 0), - legacy_header_height("legacy_header_height", 0), - close_image("close_image"), - restore_image("restore_image"), - minimize_image("minimize_image"), - tear_off_image("tear_off_image"), - dock_image("dock_image"), - help_image("help_image"), - close_pressed_image("close_pressed_image"), - restore_pressed_image("restore_pressed_image"), - minimize_pressed_image("minimize_pressed_image"), - tear_off_pressed_image("tear_off_pressed_image"), - dock_pressed_image("dock_pressed_image"), - help_pressed_image("help_pressed_image"), - open_callback("open_callback"), - close_callback("close_callback"), - follows("follows") -{ - changeDefault(visible, false); +: title("title"), + short_title("short_title"), + single_instance("single_instance", false), + reuse_instance("reuse_instance", false), + can_resize("can_resize", false), + can_minimize("can_minimize", true), + can_close("can_close", true), + can_drag_on_left("can_drag_on_left", false), + can_tear_off("can_tear_off", true), + save_dock_state("save_dock_state", false), + save_rect("save_rect", false), + save_visibility("save_visibility", false), + can_dock("can_dock", false), + show_title("show_title", true), + positioning("positioning", LLFloaterEnums::POSITIONING_RELATIVE), + header_height("header_height", 0), + legacy_header_height("legacy_header_height", 0), + close_image("close_image"), + restore_image("restore_image"), + minimize_image("minimize_image"), + tear_off_image("tear_off_image"), + dock_image("dock_image"), + help_image("help_image"), + close_pressed_image("close_pressed_image"), + restore_pressed_image("restore_pressed_image"), + minimize_pressed_image("minimize_pressed_image"), + tear_off_pressed_image("tear_off_pressed_image"), + dock_pressed_image("dock_pressed_image"), + help_pressed_image("help_pressed_image"), + open_callback("open_callback"), + close_callback("close_callback"), + follows("follows") +{ + changeDefault(visible, false); } //static const LLFloater::Params& LLFloater::getDefaultParams() { - return LLUICtrlFactory::getDefaultParams<LLFloater>(); + return LLUICtrlFactory::getDefaultParams<LLFloater>(); } //static void LLFloater::initClass() { - // translate tooltips for floater buttons - for (S32 i = 0; i < BUTTON_COUNT; i++) - { - sButtonToolTips[i] = LLTrans::getString( sButtonToolTipsIndex[i] ); - } + // translate tooltips for floater buttons + for (S32 i = 0; i < BUTTON_COUNT; i++) + { + sButtonToolTips[i] = LLTrans::getString( sButtonToolTipsIndex[i] ); + } - LLControlVariable* ctrl = LLUI::sSettingGroups["config"]->getControl("ActiveFloaterTransparency").get(); - if (ctrl) - { - ctrl->getSignal()->connect(boost::bind(&LLFloater::updateActiveFloaterTransparency)); - updateActiveFloaterTransparency(); - } + LLControlVariable* ctrl = LLUI::sSettingGroups["config"]->getControl("ActiveFloaterTransparency").get(); + if (ctrl) + { + ctrl->getSignal()->connect(boost::bind(&LLFloater::updateActiveFloaterTransparency)); + updateActiveFloaterTransparency(); + } - ctrl = LLUI::sSettingGroups["config"]->getControl("InactiveFloaterTransparency").get(); - if (ctrl) - { - ctrl->getSignal()->connect(boost::bind(&LLFloater::updateInactiveFloaterTransparency)); - updateInactiveFloaterTransparency(); - } + ctrl = LLUI::sSettingGroups["config"]->getControl("InactiveFloaterTransparency").get(); + if (ctrl) + { + ctrl->getSignal()->connect(boost::bind(&LLFloater::updateInactiveFloaterTransparency)); + updateInactiveFloaterTransparency(); + } } @@ -234,1998 +234,1998 @@ void LLFloater::initClass() static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(&typeid(LLFloater::Params), "floater"); LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) -: LLPanel(), // intentionally do not pass params here, see initFromParams - mDragHandle(NULL), - mTitle(p.title), - mShortTitle(p.short_title), - mSingleInstance(p.single_instance), - mReuseInstance(p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance), // reuse single-instance floaters by default - mKey(key), - mCanTearOff(p.can_tear_off), - mCanMinimize(p.can_minimize), - mCanClose(p.can_close), - mDragOnLeft(p.can_drag_on_left), - mResizable(p.can_resize), - mPositioning(p.positioning), - mMinWidth(p.min_width), - mMinHeight(p.min_height), - mHeaderHeight(p.header_height), - mLegacyHeaderHeight(p.legacy_header_height), - mMinimized(FALSE), - mForeground(FALSE), - mFirstLook(TRUE), - mButtonScale(1.0f), - mAutoFocus(TRUE), // automatically take focus when opened - mCanDock(false), - mDocked(false), - mTornOff(false), - mHasBeenDraggedWhileMinimized(FALSE), - mPreviousMinimizedBottom(0), - mPreviousMinimizedLeft(0), - mMinimizeSignal(NULL) -// mNotificationContext(NULL) -{ - mPosition.setFloater(*this); -// mNotificationContext = new LLFloaterNotificationContext(getHandle()); - - // Clicks stop here. - setMouseOpaque(TRUE); - - // Floaters always draw their background, unlike every other panel. - setBackgroundVisible(TRUE); - - // Floaters start not minimized. When minimized, they save their - // prior rectangle to be used on restore. - mExpandedRect.set(0,0,0,0); - - memset(mButtonsEnabled, 0, BUTTON_COUNT * sizeof(bool)); - memset(mButtons, 0, BUTTON_COUNT * sizeof(LLButton*)); - - addDragHandle(); - addResizeCtrls(); - - initFromParams(p); - - initFloater(p); +: LLPanel(), // intentionally do not pass params here, see initFromParams + mDragHandle(NULL), + mTitle(p.title), + mShortTitle(p.short_title), + mSingleInstance(p.single_instance), + mReuseInstance(p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance), // reuse single-instance floaters by default + mKey(key), + mCanTearOff(p.can_tear_off), + mCanMinimize(p.can_minimize), + mCanClose(p.can_close), + mDragOnLeft(p.can_drag_on_left), + mResizable(p.can_resize), + mPositioning(p.positioning), + mMinWidth(p.min_width), + mMinHeight(p.min_height), + mHeaderHeight(p.header_height), + mLegacyHeaderHeight(p.legacy_header_height), + mMinimized(FALSE), + mForeground(FALSE), + mFirstLook(TRUE), + mButtonScale(1.0f), + mAutoFocus(TRUE), // automatically take focus when opened + mCanDock(false), + mDocked(false), + mTornOff(false), + mHasBeenDraggedWhileMinimized(FALSE), + mPreviousMinimizedBottom(0), + mPreviousMinimizedLeft(0), + mMinimizeSignal(NULL) +// mNotificationContext(NULL) +{ + mPosition.setFloater(*this); +// mNotificationContext = new LLFloaterNotificationContext(getHandle()); + + // Clicks stop here. + setMouseOpaque(TRUE); + + // Floaters always draw their background, unlike every other panel. + setBackgroundVisible(TRUE); + + // Floaters start not minimized. When minimized, they save their + // prior rectangle to be used on restore. + mExpandedRect.set(0,0,0,0); + + memset(mButtonsEnabled, 0, BUTTON_COUNT * sizeof(bool)); + memset(mButtons, 0, BUTTON_COUNT * sizeof(LLButton*)); + + addDragHandle(); + addResizeCtrls(); + + initFromParams(p); + + initFloater(p); } // Note: Floaters constructed from XML call init() twice! void LLFloater::initFloater(const Params& p) { - // Close button. - if (mCanClose) - { - mButtonsEnabled[BUTTON_CLOSE] = TRUE; - } + // Close button. + if (mCanClose) + { + mButtonsEnabled[BUTTON_CLOSE] = TRUE; + } - // Help button: '?' - if ( !mHelpTopic.empty() ) - { - mButtonsEnabled[BUTTON_HELP] = TRUE; - } + // Help button: '?' + if ( !mHelpTopic.empty() ) + { + mButtonsEnabled[BUTTON_HELP] = TRUE; + } - // Minimize button only for top draggers - if ( !mDragOnLeft && mCanMinimize ) - { - mButtonsEnabled[BUTTON_MINIMIZE] = TRUE; - } + // Minimize button only for top draggers + if ( !mDragOnLeft && mCanMinimize ) + { + mButtonsEnabled[BUTTON_MINIMIZE] = TRUE; + } - if(mCanDock) - { - mButtonsEnabled[BUTTON_DOCK] = TRUE; - } + if(mCanDock) + { + mButtonsEnabled[BUTTON_DOCK] = TRUE; + } - buildButtons(p); + buildButtons(p); - // Floaters are created in the invisible state - setVisible(FALSE); + // Floaters are created in the invisible state + setVisible(FALSE); - if (!getParent()) - { - gFloaterView->addChild(this); - } + if (!getParent()) + { + gFloaterView->addChild(this); + } } void LLFloater::addDragHandle() { - if (!mDragHandle) - { - if (mDragOnLeft) - { - LLDragHandleLeft::Params p; - p.name("drag"); - p.follows.flags(FOLLOWS_ALL); - p.label(mTitle); - mDragHandle = LLUICtrlFactory::create<LLDragHandleLeft>(p); - } - else // drag on top - { - LLDragHandleTop::Params p; - p.name("Drag Handle"); - p.follows.flags(FOLLOWS_ALL); - p.label(mTitle); - mDragHandle = LLUICtrlFactory::create<LLDragHandleTop>(p); - } - addChild(mDragHandle); - } - layoutDragHandle(); - applyTitle(); + if (!mDragHandle) + { + if (mDragOnLeft) + { + LLDragHandleLeft::Params p; + p.name("drag"); + p.follows.flags(FOLLOWS_ALL); + p.label(mTitle); + mDragHandle = LLUICtrlFactory::create<LLDragHandleLeft>(p); + } + else // drag on top + { + LLDragHandleTop::Params p; + p.name("Drag Handle"); + p.follows.flags(FOLLOWS_ALL); + p.label(mTitle); + mDragHandle = LLUICtrlFactory::create<LLDragHandleTop>(p); + } + addChild(mDragHandle); + } + layoutDragHandle(); + applyTitle(); } void LLFloater::layoutDragHandle() { - static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); - S32 close_box_size = mCanClose ? floater_close_box_size : 0; - - LLRect rect; - if (mDragOnLeft) - { - rect.setLeftTopAndSize(0, 0, DRAG_HANDLE_WIDTH, getRect().getHeight() - LLPANEL_BORDER_WIDTH - close_box_size); - } - else // drag on top - { - rect = getLocalRect(); - } - mDragHandle->setShape(rect); - updateTitleButtons(); + static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); + S32 close_box_size = mCanClose ? floater_close_box_size : 0; + + LLRect rect; + if (mDragOnLeft) + { + rect.setLeftTopAndSize(0, 0, DRAG_HANDLE_WIDTH, getRect().getHeight() - LLPANEL_BORDER_WIDTH - close_box_size); + } + else // drag on top + { + rect = getLocalRect(); + } + mDragHandle->setShape(rect); + updateTitleButtons(); } // static void LLFloater::updateActiveFloaterTransparency() { - sActiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency"); + sActiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency"); } // static void LLFloater::updateInactiveFloaterTransparency() { - sInactiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency"); + sInactiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency"); } void LLFloater::addResizeCtrls() -{ - // Resize bars (sides) - LLResizeBar::Params p; - p.name("resizebar_left"); - p.resizing_view(this); - p.min_size(mMinWidth); - p.side(LLResizeBar::LEFT); - mResizeBar[LLResizeBar::LEFT] = LLUICtrlFactory::create<LLResizeBar>(p); - addChild( mResizeBar[LLResizeBar::LEFT] ); - - p.name("resizebar_top"); - p.min_size(mMinHeight); - p.side(LLResizeBar::TOP); - - mResizeBar[LLResizeBar::TOP] = LLUICtrlFactory::create<LLResizeBar>(p); - addChild( mResizeBar[LLResizeBar::TOP] ); - - p.name("resizebar_right"); - p.min_size(mMinWidth); - p.side(LLResizeBar::RIGHT); - mResizeBar[LLResizeBar::RIGHT] = LLUICtrlFactory::create<LLResizeBar>(p); - addChild( mResizeBar[LLResizeBar::RIGHT] ); - - p.name("resizebar_bottom"); - p.min_size(mMinHeight); - p.side(LLResizeBar::BOTTOM); - mResizeBar[LLResizeBar::BOTTOM] = LLUICtrlFactory::create<LLResizeBar>(p); - addChild( mResizeBar[LLResizeBar::BOTTOM] ); - - // Resize handles (corners) - LLResizeHandle::Params handle_p; - // handles must not be mouse-opaque, otherwise they block hover events - // to other buttons like the close box. JC - handle_p.mouse_opaque(false); - handle_p.min_width(mMinWidth); - handle_p.min_height(mMinHeight); - handle_p.corner(LLResizeHandle::RIGHT_BOTTOM); - mResizeHandle[0] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); - addChild(mResizeHandle[0]); - - handle_p.corner(LLResizeHandle::RIGHT_TOP); - mResizeHandle[1] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); - addChild(mResizeHandle[1]); - - handle_p.corner(LLResizeHandle::LEFT_BOTTOM); - mResizeHandle[2] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); - addChild(mResizeHandle[2]); - - handle_p.corner(LLResizeHandle::LEFT_TOP); - mResizeHandle[3] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); - addChild(mResizeHandle[3]); - - layoutResizeCtrls(); +{ + // Resize bars (sides) + LLResizeBar::Params p; + p.name("resizebar_left"); + p.resizing_view(this); + p.min_size(mMinWidth); + p.side(LLResizeBar::LEFT); + mResizeBar[LLResizeBar::LEFT] = LLUICtrlFactory::create<LLResizeBar>(p); + addChild( mResizeBar[LLResizeBar::LEFT] ); + + p.name("resizebar_top"); + p.min_size(mMinHeight); + p.side(LLResizeBar::TOP); + + mResizeBar[LLResizeBar::TOP] = LLUICtrlFactory::create<LLResizeBar>(p); + addChild( mResizeBar[LLResizeBar::TOP] ); + + p.name("resizebar_right"); + p.min_size(mMinWidth); + p.side(LLResizeBar::RIGHT); + mResizeBar[LLResizeBar::RIGHT] = LLUICtrlFactory::create<LLResizeBar>(p); + addChild( mResizeBar[LLResizeBar::RIGHT] ); + + p.name("resizebar_bottom"); + p.min_size(mMinHeight); + p.side(LLResizeBar::BOTTOM); + mResizeBar[LLResizeBar::BOTTOM] = LLUICtrlFactory::create<LLResizeBar>(p); + addChild( mResizeBar[LLResizeBar::BOTTOM] ); + + // Resize handles (corners) + LLResizeHandle::Params handle_p; + // handles must not be mouse-opaque, otherwise they block hover events + // to other buttons like the close box. JC + handle_p.mouse_opaque(false); + handle_p.min_width(mMinWidth); + handle_p.min_height(mMinHeight); + handle_p.corner(LLResizeHandle::RIGHT_BOTTOM); + mResizeHandle[0] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); + addChild(mResizeHandle[0]); + + handle_p.corner(LLResizeHandle::RIGHT_TOP); + mResizeHandle[1] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); + addChild(mResizeHandle[1]); + + handle_p.corner(LLResizeHandle::LEFT_BOTTOM); + mResizeHandle[2] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); + addChild(mResizeHandle[2]); + + handle_p.corner(LLResizeHandle::LEFT_TOP); + mResizeHandle[3] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); + addChild(mResizeHandle[3]); + + layoutResizeCtrls(); } void LLFloater::layoutResizeCtrls() { - LLRect rect; + LLRect rect; - // Resize bars (sides) - const S32 RESIZE_BAR_THICKNESS = 3; - rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0); - mResizeBar[LLResizeBar::LEFT]->setRect(rect); + // Resize bars (sides) + const S32 RESIZE_BAR_THICKNESS = 3; + rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0); + mResizeBar[LLResizeBar::LEFT]->setRect(rect); - rect = LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS); - mResizeBar[LLResizeBar::TOP]->setRect(rect); + rect = LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS); + mResizeBar[LLResizeBar::TOP]->setRect(rect); - rect = LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0); - mResizeBar[LLResizeBar::RIGHT]->setRect(rect); + rect = LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0); + mResizeBar[LLResizeBar::RIGHT]->setRect(rect); - rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0); - mResizeBar[LLResizeBar::BOTTOM]->setRect(rect); + rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0); + mResizeBar[LLResizeBar::BOTTOM]->setRect(rect); - // Resize handles (corners) - rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0); - mResizeHandle[0]->setRect(rect); + // Resize handles (corners) + rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0); + mResizeHandle[0]->setRect(rect); - rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT); - mResizeHandle[1]->setRect(rect); - - rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 ); - mResizeHandle[2]->setRect(rect); + rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT); + mResizeHandle[1]->setRect(rect); + + rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 ); + mResizeHandle[2]->setRect(rect); - rect = LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT ); - mResizeHandle[3]->setRect(rect); + rect = LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT ); + mResizeHandle[3]->setRect(rect); } void LLFloater::enableResizeCtrls(bool enable, bool width, bool height) { - mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width); - mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width); + mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width); + mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width); - mResizeBar[LLResizeBar::TOP]->setVisible(enable && height); - mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height); - - mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width); - mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width); - - mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height); - mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height); + mResizeBar[LLResizeBar::TOP]->setVisible(enable && height); + mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height); + + mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width); + mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width); + + mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height); + mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height); - for (S32 i = 0; i < 4; ++i) - { - mResizeHandle[i]->setVisible(enable && width && height); - mResizeHandle[i]->setEnabled(enable && width && height); - } + for (S32 i = 0; i < 4; ++i) + { + mResizeHandle[i]->setVisible(enable && width && height); + mResizeHandle[i]->setEnabled(enable && width && height); + } } void LLFloater::destroy() { - // LLFloaterReg should be synchronized with "dead" floater to avoid returning dead instance before - // it was deleted via LLMortician::updateClass(). See EXT-8458. - LLFloaterReg::removeInstance(mInstanceName, mKey); - die(); + // LLFloaterReg should be synchronized with "dead" floater to avoid returning dead instance before + // it was deleted via LLMortician::updateClass(). See EXT-8458. + LLFloaterReg::removeInstance(mInstanceName, mKey); + die(); } // virtual LLFloater::~LLFloater() { - LLFloaterReg::removeInstance(mInstanceName, mKey); - - if( gFocusMgr.childHasKeyboardFocus(this)) - { - // Just in case we might still have focus here, release it. - releaseFocus(); - } - - // This is important so that floaters with persistent rects (i.e., those - // created with rect control rather than an LLRect) are restored in their - // correct, non-minimized positions. - setMinimized( FALSE ); - - delete mDragHandle; - for (S32 i = 0; i < 4; i++) - { - delete mResizeBar[i]; - delete mResizeHandle[i]; - } - - setVisible(false); // We're not visible if we're destroyed - storeVisibilityControl(); - storeDockStateControl(); - delete mMinimizeSignal; + LLFloaterReg::removeInstance(mInstanceName, mKey); + + if( gFocusMgr.childHasKeyboardFocus(this)) + { + // Just in case we might still have focus here, release it. + releaseFocus(); + } + + // This is important so that floaters with persistent rects (i.e., those + // created with rect control rather than an LLRect) are restored in their + // correct, non-minimized positions. + setMinimized( FALSE ); + + delete mDragHandle; + for (S32 i = 0; i < 4; i++) + { + delete mResizeBar[i]; + delete mResizeHandle[i]; + } + + setVisible(false); // We're not visible if we're destroyed + storeVisibilityControl(); + storeDockStateControl(); + delete mMinimizeSignal; } void LLFloater::storeRectControl() { - if (!mRectControl.empty()) - { - getControlGroup()->setRect( mRectControl, getRect() ); - } - if (!mPosXControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE) - { - getControlGroup()->setF32( mPosXControl, mPosition.mX ); - } - if (!mPosYControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE) - { - getControlGroup()->setF32( mPosYControl, mPosition.mY ); - } + if (!mRectControl.empty()) + { + getControlGroup()->setRect( mRectControl, getRect() ); + } + if (!mPosXControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE) + { + getControlGroup()->setF32( mPosXControl, mPosition.mX ); + } + if (!mPosYControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE) + { + getControlGroup()->setF32( mPosYControl, mPosition.mY ); + } } void LLFloater::storeVisibilityControl() { - if( !sQuitting && mVisibilityControl.size() > 1 ) - { - getControlGroup()->setBOOL( mVisibilityControl, getVisible() ); - } + if( !sQuitting && mVisibilityControl.size() > 1 ) + { + getControlGroup()->setBOOL( mVisibilityControl, getVisible() ); + } } void LLFloater::storeDockStateControl() { - if( !sQuitting && mDocStateControl.size() > 1 ) - { - getControlGroup()->setBOOL( mDocStateControl, isDocked() ); - } + if( !sQuitting && mDocStateControl.size() > 1 ) + { + getControlGroup()->setBOOL( mDocStateControl, isDocked() ); + } } // static std::string LLFloater::getControlName(const std::string& name, const LLSD& key) { - std::string ctrl_name = name; + std::string ctrl_name = name; - // Add the key to the control name if appropriate. - if (key.isString() && !key.asString().empty()) - { - ctrl_name += "_" + key.asString(); - } + // Add the key to the control name if appropriate. + if (key.isString() && !key.asString().empty()) + { + ctrl_name += "_" + key.asString(); + } - return ctrl_name; + return ctrl_name; } // static -LLControlGroup* LLFloater::getControlGroup() +LLControlGroup* LLFloater::getControlGroup() { - // Floater size, position, visibility, etc are saved in per-account settings. - return LLUI::sSettingGroups["account"]; + // Floater size, position, visibility, etc are saved in per-account settings. + return LLUI::sSettingGroups["account"]; } void LLFloater::setVisible( BOOL visible ) { - LLPanel::setVisible(visible); // calls onVisibilityChange() - if( visible && mFirstLook ) - { - mFirstLook = FALSE; - } + LLPanel::setVisible(visible); // calls onVisibilityChange() + if( visible && mFirstLook ) + { + mFirstLook = FALSE; + } - if( !visible ) - { - LLUI::removePopup(this); + if( !visible ) + { + LLUI::removePopup(this); - if( gFocusMgr.childHasMouseCapture( this ) ) - { - gFocusMgr.setMouseCapture(NULL); - } - } + if( gFocusMgr.childHasMouseCapture( this ) ) + { + gFocusMgr.setMouseCapture(NULL); + } + } - for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); ) - { - LLFloater* floaterp = dependent_it->get(); + for(handle_set_iter_t dependent_it = mDependents.begin(); + dependent_it != mDependents.end(); ) + { + LLFloater* floaterp = dependent_it->get(); - if (floaterp) - { - floaterp->setVisible(visible); - } - ++dependent_it; - } + if (floaterp) + { + floaterp->setVisible(visible); + } + ++dependent_it; + } - storeVisibilityControl(); + storeVisibilityControl(); } void LLFloater::setIsSingleInstance(BOOL is_single_instance) { - mSingleInstance = is_single_instance; - if (!mIsReuseInitialized) - { - mReuseInstance = is_single_instance; // reuse single-instance floaters by default - } + mSingleInstance = is_single_instance; + if (!mIsReuseInitialized) + { + mReuseInstance = is_single_instance; // reuse single-instance floaters by default + } } // virtual void LLFloater::onVisibilityChange ( BOOL new_visibility ) { - if (new_visibility) - { - if (getHost()) - getHost()->setFloaterFlashing(this, FALSE); - } - LLPanel::onVisibilityChange ( new_visibility ); + if (new_visibility) + { + if (getHost()) + getHost()->setFloaterFlashing(this, FALSE); + } + LLPanel::onVisibilityChange ( new_visibility ); } void LLFloater::openFloater(const LLSD& key) { LL_INFOS() << "Opening floater " << getName() << " full path: " << getPathname() << LL_ENDL; - LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), true,"floater"); // Last param is event subtype or empty string - - mKey = key; // in case we need to open ourselves again - - if (getSoundFlags() != SILENT - // don't play open sound for hosted (tabbed) windows - && !getHost() - && !getFloaterHost() - && (!getVisible() || isMinimized())) - { - make_ui_sound("UISndWindowOpen"); - } - - //RN: for now, we don't allow rehosting from one multifloater to another - // just need to fix the bugs - if (getFloaterHost() != NULL && getHost() == NULL) - { - // needs a host - // only select tabs if window they are hosted in is visible - getFloaterHost()->addFloater(this, getFloaterHost()->getVisible()); - } - - if (getHost() != NULL) - { - getHost()->setMinimized(FALSE); - getHost()->setVisibleAndFrontmost(mAutoFocus); - getHost()->showFloater(this); - } - else - { - LLFloater* floater_to_stack = LLFloaterReg::getLastFloaterInGroup(mInstanceName); - if (!floater_to_stack) - { - floater_to_stack = LLFloaterReg::getLastFloaterCascading(); - } - applyControlsAndPosition(floater_to_stack); - setMinimized(FALSE); - setVisibleAndFrontmost(mAutoFocus); - } - - mOpenSignal(this, key); - onOpen(key); - - dirtyRect(); + LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), true,"floater"); // Last param is event subtype or empty string + + mKey = key; // in case we need to open ourselves again + + if (getSoundFlags() != SILENT + // don't play open sound for hosted (tabbed) windows + && !getHost() + && !getFloaterHost() + && (!getVisible() || isMinimized())) + { + make_ui_sound("UISndWindowOpen"); + } + + //RN: for now, we don't allow rehosting from one multifloater to another + // just need to fix the bugs + if (getFloaterHost() != NULL && getHost() == NULL) + { + // needs a host + // only select tabs if window they are hosted in is visible + getFloaterHost()->addFloater(this, getFloaterHost()->getVisible()); + } + + if (getHost() != NULL) + { + getHost()->setMinimized(FALSE); + getHost()->setVisibleAndFrontmost(mAutoFocus); + getHost()->showFloater(this); + } + else + { + LLFloater* floater_to_stack = LLFloaterReg::getLastFloaterInGroup(mInstanceName); + if (!floater_to_stack) + { + floater_to_stack = LLFloaterReg::getLastFloaterCascading(); + } + applyControlsAndPosition(floater_to_stack); + setMinimized(FALSE); + setVisibleAndFrontmost(mAutoFocus); + } + + mOpenSignal(this, key); + onOpen(key); + + dirtyRect(); } void LLFloater::closeFloater(bool app_quitting) { - LL_INFOS() << "Closing floater " << getName() << LL_ENDL; - LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), false,"floater"); // Last param is event subtype or empty string - if (app_quitting) - { - LLFloater::sQuitting = true; - } - - // Always unminimize before trying to close. - // Most of the time the user will never see this state. - setMinimized(FALSE); - - if (canClose()) - { - if (getHost()) - { - ((LLMultiFloater*)getHost())->removeFloater(this); - gFloaterView->addChild(this); - } - - if (getSoundFlags() != SILENT - && getVisible() - && !getHost() - && !app_quitting) - { - make_ui_sound("UISndWindowClose"); - } - - gFocusMgr.clearLastFocusForGroup(this); - - if (hasFocus()) - { - // Do this early, so UI controls will commit before the - // window is taken down. - releaseFocus(); - - // give focus to dependee floater if it exists, and we had focus first - if (isDependent()) - { - LLFloater* dependee = mDependeeHandle.get(); - if (dependee && !dependee->isDead()) - { - dependee->setFocus(TRUE); - } - } - } - - - //If floater is a dependent, remove it from parent (dependee) + LL_INFOS() << "Closing floater " << getName() << LL_ENDL; + LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), false,"floater"); // Last param is event subtype or empty string + if (app_quitting) + { + LLFloater::sQuitting = true; + } + + // Always unminimize before trying to close. + // Most of the time the user will never see this state. + setMinimized(FALSE); + + if (canClose()) + { + if (getHost()) + { + ((LLMultiFloater*)getHost())->removeFloater(this); + gFloaterView->addChild(this); + } + + if (getSoundFlags() != SILENT + && getVisible() + && !getHost() + && !app_quitting) + { + make_ui_sound("UISndWindowClose"); + } + + gFocusMgr.clearLastFocusForGroup(this); + + if (hasFocus()) + { + // Do this early, so UI controls will commit before the + // window is taken down. + releaseFocus(); + + // give focus to dependee floater if it exists, and we had focus first + if (isDependent()) + { + LLFloater* dependee = mDependeeHandle.get(); + if (dependee && !dependee->isDead()) + { + dependee->setFocus(TRUE); + } + } + } + + + //If floater is a dependent, remove it from parent (dependee) LLFloater* dependee = mDependeeHandle.get(); if (dependee) { dependee->removeDependentFloater(this); } - // now close dependent floater - for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); ) - { - - LLFloater* floaterp = dependent_it->get(); - if (floaterp) - { - ++dependent_it; - floaterp->closeFloater(app_quitting); - } - else - { - mDependents.erase(dependent_it++); - } - } - - cleanupHandles(); - - dirtyRect(); - - // Close callbacks - onClose(app_quitting); - mCloseSignal(this, LLSD(app_quitting)); - - // Hide or Destroy - if (mSingleInstance) - { - // Hide the instance - if (getHost()) - { - getHost()->setVisible(FALSE); - } - else - { - setVisible(FALSE); - if (!mReuseInstance) - { - destroy(); - } - } - } - else - { - setVisible(FALSE); // hide before destroying (so onVisibilityChange() gets called) - if (!mReuseInstance) - { - destroy(); - } - } - } + // now close dependent floater + for(handle_set_iter_t dependent_it = mDependents.begin(); + dependent_it != mDependents.end(); ) + { + + LLFloater* floaterp = dependent_it->get(); + if (floaterp) + { + ++dependent_it; + floaterp->closeFloater(app_quitting); + } + else + { + mDependents.erase(dependent_it++); + } + } + + cleanupHandles(); + + dirtyRect(); + + // Close callbacks + onClose(app_quitting); + mCloseSignal(this, LLSD(app_quitting)); + + // Hide or Destroy + if (mSingleInstance) + { + // Hide the instance + if (getHost()) + { + getHost()->setVisible(FALSE); + } + else + { + setVisible(FALSE); + if (!mReuseInstance) + { + destroy(); + } + } + } + else + { + setVisible(FALSE); // hide before destroying (so onVisibilityChange() gets called) + if (!mReuseInstance) + { + destroy(); + } + } + } } /*virtual*/ void LLFloater::closeHostedFloater() { - // When toggling *visibility*, close the host instead of the floater when hosted - if (getHost()) - { - getHost()->closeFloater(); - } - else - { - closeFloater(); - } + // When toggling *visibility*, close the host instead of the floater when hosted + if (getHost()) + { + getHost()->closeFloater(); + } + else + { + closeFloater(); + } } /*virtual*/ void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent) { - LLPanel::reshape(width, height, called_from_parent); + LLPanel::reshape(width, height, called_from_parent); } void LLFloater::releaseFocus() { - LLUI::removePopup(this); + LLUI::removePopup(this); - setFocus(FALSE); + setFocus(FALSE); - if( gFocusMgr.childHasMouseCapture( this ) ) - { - gFocusMgr.setMouseCapture(NULL); - } + if( gFocusMgr.childHasMouseCapture( this ) ) + { + gFocusMgr.setMouseCapture(NULL); + } } void LLFloater::setResizeLimits( S32 min_width, S32 min_height ) { - mMinWidth = min_width; - mMinHeight = min_height; - - for( S32 i = 0; i < 4; i++ ) - { - if( mResizeBar[i] ) - { - if (i == LLResizeBar::LEFT || i == LLResizeBar::RIGHT) - { - mResizeBar[i]->setResizeLimits( min_width, S32_MAX ); - } - else - { - mResizeBar[i]->setResizeLimits( min_height, S32_MAX ); - } - } - if( mResizeHandle[i] ) - { - mResizeHandle[i]->setResizeLimits( min_width, min_height ); - } - } + mMinWidth = min_width; + mMinHeight = min_height; + + for( S32 i = 0; i < 4; i++ ) + { + if( mResizeBar[i] ) + { + if (i == LLResizeBar::LEFT || i == LLResizeBar::RIGHT) + { + mResizeBar[i]->setResizeLimits( min_width, S32_MAX ); + } + else + { + mResizeBar[i]->setResizeLimits( min_height, S32_MAX ); + } + } + if( mResizeHandle[i] ) + { + mResizeHandle[i]->setResizeLimits( min_width, min_height ); + } + } } void LLFloater::center() { - if(getHost()) - { - // hosted floaters can't move - return; - } - centerWithin(gFloaterView->getRect()); + if(getHost()) + { + // hosted floaters can't move + return; + } + centerWithin(gFloaterView->getRect()); } LLMultiFloater* LLFloater::getHost() { - return (LLMultiFloater*)mHostHandle.get(); + return (LLMultiFloater*)mHostHandle.get(); } void LLFloater::applyControlsAndPosition(LLFloater* other) { - if (!applyDockState()) - { - if (!applyRectControl()) - { - applyPositioning(other, true); - } - } + if (!applyDockState()) + { + if (!applyRectControl()) + { + applyPositioning(other, true); + } + } } bool LLFloater::applyRectControl() { - bool saved_rect = false; - - LLRect screen_rect = calcScreenRect(); - mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); - - LLFloater* last_in_group = LLFloaterReg::getLastFloaterInGroup(mInstanceName); - if (last_in_group && last_in_group != this) - { - // other floaters in our group, position ourselves relative to them and don't save the rect - mRectControl.clear(); - mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP; - } - else - { - bool rect_specified = false; - if (!mRectControl.empty()) - { - // If we have a saved rect, use it - const LLRect& rect = getControlGroup()->getRect(mRectControl); - if (rect.notEmpty()) saved_rect = true; - if (saved_rect) - { - setOrigin(rect.mLeft, rect.mBottom); - - if (mResizable) - { - reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight())); - } - mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; - LLRect screen_rect = calcScreenRect(); - mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); - rect_specified = true; - } - } - - LLControlVariablePtr x_control = getControlGroup()->getControl(mPosXControl); - LLControlVariablePtr y_control = getControlGroup()->getControl(mPosYControl); - if (x_control.notNull() - && y_control.notNull() - && !x_control->isDefault() - && !y_control->isDefault()) - { - mPosition.mX = x_control->getValue().asReal(); - mPosition.mY = y_control->getValue().asReal(); - mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; - applyRelativePosition(); - - saved_rect = true; - } - - // remember updated position - if (rect_specified) - { - storeRectControl(); - } - } - - if (saved_rect) - { - // propagate any derived positioning data back to settings file - storeRectControl(); - } - - - return saved_rect; + bool saved_rect = false; + + LLRect screen_rect = calcScreenRect(); + mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); + + LLFloater* last_in_group = LLFloaterReg::getLastFloaterInGroup(mInstanceName); + if (last_in_group && last_in_group != this) + { + // other floaters in our group, position ourselves relative to them and don't save the rect + mRectControl.clear(); + mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP; + } + else + { + bool rect_specified = false; + if (!mRectControl.empty()) + { + // If we have a saved rect, use it + const LLRect& rect = getControlGroup()->getRect(mRectControl); + if (rect.notEmpty()) saved_rect = true; + if (saved_rect) + { + setOrigin(rect.mLeft, rect.mBottom); + + if (mResizable) + { + reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight())); + } + mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; + LLRect screen_rect = calcScreenRect(); + mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); + rect_specified = true; + } + } + + LLControlVariablePtr x_control = getControlGroup()->getControl(mPosXControl); + LLControlVariablePtr y_control = getControlGroup()->getControl(mPosYControl); + if (x_control.notNull() + && y_control.notNull() + && !x_control->isDefault() + && !y_control->isDefault()) + { + mPosition.mX = x_control->getValue().asReal(); + mPosition.mY = y_control->getValue().asReal(); + mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; + applyRelativePosition(); + + saved_rect = true; + } + + // remember updated position + if (rect_specified) + { + storeRectControl(); + } + } + + if (saved_rect) + { + // propagate any derived positioning data back to settings file + storeRectControl(); + } + + + return saved_rect; } bool LLFloater::applyDockState() { - bool docked = false; + bool docked = false; - if (mDocStateControl.size() > 1) - { - docked = getControlGroup()->getBOOL(mDocStateControl); - setDocked(docked); - } + if (mDocStateControl.size() > 1) + { + docked = getControlGroup()->getBOOL(mDocStateControl); + setDocked(docked); + } - return docked; + return docked; } void LLFloater::applyPositioning(LLFloater* other, bool on_open) { - // Otherwise position according to the positioning code - switch (mPositioning) - { - case LLFloaterEnums::POSITIONING_CENTERED: - center(); - break; - - case LLFloaterEnums::POSITIONING_SPECIFIED: - break; - - case LLFloaterEnums::POSITIONING_CASCADING: - if (!on_open) - { - applyRelativePosition(); - } - // fall through - case LLFloaterEnums::POSITIONING_CASCADE_GROUP: - if (on_open) - { - if (other != NULL && other != this) - { - stackWith(*other); - } - else - { - static const U32 CASCADING_FLOATER_HOFFSET = 0; - static const U32 CASCADING_FLOATER_VOFFSET = 0; - - const LLRect& snap_rect = gFloaterView->getSnapRect(); - - const S32 horizontal_offset = CASCADING_FLOATER_HOFFSET; - const S32 vertical_offset = snap_rect.getHeight() - CASCADING_FLOATER_VOFFSET; - - S32 rect_height = getRect().getHeight(); - setOrigin(horizontal_offset, vertical_offset - rect_height); - - translate(snap_rect.mLeft, snap_rect.mBottom); - } - setFollows(FOLLOWS_TOP | FOLLOWS_LEFT); - } - break; - - case LLFloaterEnums::POSITIONING_RELATIVE: - { - applyRelativePosition(); - - break; - } - default: - // Do nothing - break; - } + // Otherwise position according to the positioning code + switch (mPositioning) + { + case LLFloaterEnums::POSITIONING_CENTERED: + center(); + break; + + case LLFloaterEnums::POSITIONING_SPECIFIED: + break; + + case LLFloaterEnums::POSITIONING_CASCADING: + if (!on_open) + { + applyRelativePosition(); + } + // fall through + case LLFloaterEnums::POSITIONING_CASCADE_GROUP: + if (on_open) + { + if (other != NULL && other != this) + { + stackWith(*other); + } + else + { + static const U32 CASCADING_FLOATER_HOFFSET = 0; + static const U32 CASCADING_FLOATER_VOFFSET = 0; + + const LLRect& snap_rect = gFloaterView->getSnapRect(); + + const S32 horizontal_offset = CASCADING_FLOATER_HOFFSET; + const S32 vertical_offset = snap_rect.getHeight() - CASCADING_FLOATER_VOFFSET; + + S32 rect_height = getRect().getHeight(); + setOrigin(horizontal_offset, vertical_offset - rect_height); + + translate(snap_rect.mLeft, snap_rect.mBottom); + } + setFollows(FOLLOWS_TOP | FOLLOWS_LEFT); + } + break; + + case LLFloaterEnums::POSITIONING_RELATIVE: + { + applyRelativePosition(); + + break; + } + default: + // Do nothing + break; + } } void LLFloater::applyTitle() { - if (!mDragHandle) - { - return; - } + if (!mDragHandle) + { + return; + } - if (isMinimized() && !mShortTitle.empty()) - { - mDragHandle->setTitle( mShortTitle ); - } - else - { - mDragHandle->setTitle ( mTitle ); - } + if (isMinimized() && !mShortTitle.empty()) + { + mDragHandle->setTitle( mShortTitle ); + } + else + { + mDragHandle->setTitle ( mTitle ); + } - if (getHost()) - { - getHost()->updateFloaterTitle(this); - } + if (getHost()) + { + getHost()->updateFloaterTitle(this); + } } std::string LLFloater::getCurrentTitle() const { - return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null; + return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null; } void LLFloater::setTitle( const std::string& title ) { - mTitle = title; - applyTitle(); + mTitle = title; + applyTitle(); } std::string LLFloater::getTitle() const { - if (mTitle.empty()) - { - return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null; - } - else - { - return mTitle; - } + if (mTitle.empty()) + { + return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null; + } + else + { + return mTitle; + } } void LLFloater::setShortTitle( const std::string& short_title ) { - mShortTitle = short_title; - applyTitle(); + mShortTitle = short_title; + applyTitle(); } std::string LLFloater::getShortTitle() const { - if (mShortTitle.empty()) - { - return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null; - } - else - { - return mShortTitle; - } + if (mShortTitle.empty()) + { + return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null; + } + else + { + return mShortTitle; + } } BOOL LLFloater::canSnapTo(const LLView* other_view) { - if (NULL == other_view) - { - LL_WARNS() << "other_view is NULL" << LL_ENDL; - return FALSE; - } - - if (other_view != getParent()) - { - const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view); - if (other_floaterp - && other_floaterp->getSnapTarget() == getHandle() - && mDependents.find(other_floaterp->getHandle()) != mDependents.end()) - { - // this is a dependent that is already snapped to us, so don't snap back to it - return FALSE; - } - } + if (NULL == other_view) + { + LL_WARNS() << "other_view is NULL" << LL_ENDL; + return FALSE; + } + + if (other_view != getParent()) + { + const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view); + if (other_floaterp + && other_floaterp->getSnapTarget() == getHandle() + && mDependents.find(other_floaterp->getHandle()) != mDependents.end()) + { + // this is a dependent that is already snapped to us, so don't snap back to it + return FALSE; + } + } - return LLPanel::canSnapTo(other_view); + return LLPanel::canSnapTo(other_view); } void LLFloater::setSnappedTo(const LLView* snap_view) { - if (!snap_view || snap_view == getParent()) - { - clearSnapTarget(); - } - else - { - //RN: assume it's a floater as it must be a sibling to our parent floater - const LLFloater* floaterp = dynamic_cast<const LLFloater*>(snap_view); - if (floaterp) - { - setSnapTarget(floaterp->getHandle()); - } - } + if (!snap_view || snap_view == getParent()) + { + clearSnapTarget(); + } + else + { + //RN: assume it's a floater as it must be a sibling to our parent floater + const LLFloater* floaterp = dynamic_cast<const LLFloater*>(snap_view); + if (floaterp) + { + setSnapTarget(floaterp->getHandle()); + } + } } void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) { - const LLRect old_rect = getRect(); - LLView::handleReshape(new_rect, by_user); - - if (by_user && !getHost()) - { - LLFloaterView * floaterVp = dynamic_cast<LLFloaterView*>(getParent()); - if (floaterVp) - { - floaterVp->adjustToFitScreen(this, !isMinimized()); - } - } - - // if not minimized, adjust all snapped dependents to new shape - if (!isMinimized()) - { - if (by_user) - { - if (isDocked()) - { - setDocked( false, false); - } - mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; - LLRect screen_rect = calcScreenRect(); - mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); - } - storeRectControl(); - - // gather all snapped dependents - for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); ++dependent_it) - { - LLFloater* floaterp = dependent_it->get(); - // is a dependent snapped to us? - if (floaterp && floaterp->getSnapTarget() == getHandle()) - { - S32 delta_x = 0; - S32 delta_y = 0; - // check to see if it snapped to right or top, and move if dependee floater is resizing - LLRect dependent_rect = floaterp->getRect(); - if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right? - dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right - { - // was snapped directly onto right side or aligned with it - delta_x += new_rect.getWidth() - old_rect.getWidth(); - } - if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() || - dependent_rect.mTop == getRect().mBottom + old_rect.getHeight()) - { - // was snapped directly onto top side or aligned with it - delta_y += new_rect.getHeight() - old_rect.getHeight(); - } - - // take translation of dependee floater into account as well - delta_x += new_rect.mLeft - old_rect.mLeft; - delta_y += new_rect.mBottom - old_rect.mBottom; - - dependent_rect.translate(delta_x, delta_y); - floaterp->setShape(dependent_rect, by_user); - } - } - } - else - { - // If minimized, and origin has changed, set - // mHasBeenDraggedWhileMinimized to TRUE - if ((new_rect.mLeft != old_rect.mLeft) || - (new_rect.mBottom != old_rect.mBottom)) - { - mHasBeenDraggedWhileMinimized = TRUE; - } - } + const LLRect old_rect = getRect(); + LLView::handleReshape(new_rect, by_user); + + if (by_user && !getHost()) + { + LLFloaterView * floaterVp = dynamic_cast<LLFloaterView*>(getParent()); + if (floaterVp) + { + floaterVp->adjustToFitScreen(this, !isMinimized()); + } + } + + // if not minimized, adjust all snapped dependents to new shape + if (!isMinimized()) + { + if (by_user) + { + if (isDocked()) + { + setDocked( false, false); + } + mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; + LLRect screen_rect = calcScreenRect(); + mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); + } + storeRectControl(); + + // gather all snapped dependents + for(handle_set_iter_t dependent_it = mDependents.begin(); + dependent_it != mDependents.end(); ++dependent_it) + { + LLFloater* floaterp = dependent_it->get(); + // is a dependent snapped to us? + if (floaterp && floaterp->getSnapTarget() == getHandle()) + { + S32 delta_x = 0; + S32 delta_y = 0; + // check to see if it snapped to right or top, and move if dependee floater is resizing + LLRect dependent_rect = floaterp->getRect(); + if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right? + dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right + { + // was snapped directly onto right side or aligned with it + delta_x += new_rect.getWidth() - old_rect.getWidth(); + } + if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() || + dependent_rect.mTop == getRect().mBottom + old_rect.getHeight()) + { + // was snapped directly onto top side or aligned with it + delta_y += new_rect.getHeight() - old_rect.getHeight(); + } + + // take translation of dependee floater into account as well + delta_x += new_rect.mLeft - old_rect.mLeft; + delta_y += new_rect.mBottom - old_rect.mBottom; + + dependent_rect.translate(delta_x, delta_y); + floaterp->setShape(dependent_rect, by_user); + } + } + } + else + { + // If minimized, and origin has changed, set + // mHasBeenDraggedWhileMinimized to TRUE + if ((new_rect.mLeft != old_rect.mLeft) || + (new_rect.mBottom != old_rect.mBottom)) + { + mHasBeenDraggedWhileMinimized = TRUE; + } + } } void LLFloater::setMinimized(BOOL minimize) { - const LLFloater::Params& default_params = LLFloater::getDefaultParams(); - S32 floater_header_size = default_params.header_height; - static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0); - - if (minimize == mMinimized) return; - - if (mMinimizeSignal) - { - (*mMinimizeSignal)(this, LLSD(minimize)); - } - - if (minimize) - { - // minimized flag should be turned on before release focus - mMinimized = TRUE; - mExpandedRect = getRect(); - - // If the floater has been dragged while minimized in the - // past, then locate it at its previous minimized location. - // Otherwise, ask the view for a minimize position. - if (mHasBeenDraggedWhileMinimized) - { - setOrigin(mPreviousMinimizedLeft, mPreviousMinimizedBottom); - } - else - { - S32 left, bottom; - gFloaterView->getMinimizePosition(&left, &bottom); - setOrigin( left, bottom ); - } - - if (mButtonsEnabled[BUTTON_MINIMIZE]) - { - mButtonsEnabled[BUTTON_MINIMIZE] = FALSE; - mButtonsEnabled[BUTTON_RESTORE] = TRUE; - } - - setBorderVisible(TRUE); - - for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); - ++dependent_it) - { - LLFloater* floaterp = dependent_it->get(); - if (floaterp) - { - if (floaterp->isMinimizeable()) - { - floaterp->setMinimized(TRUE); - } - else if (!floaterp->isMinimized()) - { - floaterp->setVisible(FALSE); - } - } - } - - // Lose keyboard focus when minimized - releaseFocus(); - - for (S32 i = 0; i < 4; i++) - { - if (mResizeBar[i] != NULL) - { - mResizeBar[i]->setEnabled(FALSE); - } - if (mResizeHandle[i] != NULL) - { - mResizeHandle[i]->setEnabled(FALSE); - } - } - - // Reshape *after* setting mMinimized - reshape( minimized_width, floater_header_size, TRUE); - } - else - { - // If this window has been dragged while minimized (at any time), - // remember its position for the next time it's minimized. - if (mHasBeenDraggedWhileMinimized) - { - const LLRect& currentRect = getRect(); - mPreviousMinimizedLeft = currentRect.mLeft; - mPreviousMinimizedBottom = currentRect.mBottom; - } - - setOrigin( mExpandedRect.mLeft, mExpandedRect.mBottom ); - if (mButtonsEnabled[BUTTON_RESTORE]) - { - mButtonsEnabled[BUTTON_MINIMIZE] = TRUE; - mButtonsEnabled[BUTTON_RESTORE] = FALSE; - } - - // show dependent floater - for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); - ++dependent_it) - { - LLFloater* floaterp = dependent_it->get(); - if (floaterp) - { - floaterp->setMinimized(FALSE); - floaterp->setVisible(TRUE); - } - } - - for (S32 i = 0; i < 4; i++) - { - if (mResizeBar[i] != NULL) - { - mResizeBar[i]->setEnabled(isResizable()); - } - if (mResizeHandle[i] != NULL) - { - mResizeHandle[i]->setEnabled(isResizable()); - } - } - - mMinimized = FALSE; - setFrontmost(); - // Reshape *after* setting mMinimized - reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE ); - } - - make_ui_sound("UISndWindowClose"); - updateTitleButtons(); - applyTitle (); + const LLFloater::Params& default_params = LLFloater::getDefaultParams(); + S32 floater_header_size = default_params.header_height; + static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0); + + if (minimize == mMinimized) return; + + if (mMinimizeSignal) + { + (*mMinimizeSignal)(this, LLSD(minimize)); + } + + if (minimize) + { + // minimized flag should be turned on before release focus + mMinimized = TRUE; + mExpandedRect = getRect(); + + // If the floater has been dragged while minimized in the + // past, then locate it at its previous minimized location. + // Otherwise, ask the view for a minimize position. + if (mHasBeenDraggedWhileMinimized) + { + setOrigin(mPreviousMinimizedLeft, mPreviousMinimizedBottom); + } + else + { + S32 left, bottom; + gFloaterView->getMinimizePosition(&left, &bottom); + setOrigin( left, bottom ); + } + + if (mButtonsEnabled[BUTTON_MINIMIZE]) + { + mButtonsEnabled[BUTTON_MINIMIZE] = FALSE; + mButtonsEnabled[BUTTON_RESTORE] = TRUE; + } + + setBorderVisible(TRUE); + + for(handle_set_iter_t dependent_it = mDependents.begin(); + dependent_it != mDependents.end(); + ++dependent_it) + { + LLFloater* floaterp = dependent_it->get(); + if (floaterp) + { + if (floaterp->isMinimizeable()) + { + floaterp->setMinimized(TRUE); + } + else if (!floaterp->isMinimized()) + { + floaterp->setVisible(FALSE); + } + } + } + + // Lose keyboard focus when minimized + releaseFocus(); + + for (S32 i = 0; i < 4; i++) + { + if (mResizeBar[i] != NULL) + { + mResizeBar[i]->setEnabled(FALSE); + } + if (mResizeHandle[i] != NULL) + { + mResizeHandle[i]->setEnabled(FALSE); + } + } + + // Reshape *after* setting mMinimized + reshape( minimized_width, floater_header_size, TRUE); + } + else + { + // If this window has been dragged while minimized (at any time), + // remember its position for the next time it's minimized. + if (mHasBeenDraggedWhileMinimized) + { + const LLRect& currentRect = getRect(); + mPreviousMinimizedLeft = currentRect.mLeft; + mPreviousMinimizedBottom = currentRect.mBottom; + } + + setOrigin( mExpandedRect.mLeft, mExpandedRect.mBottom ); + if (mButtonsEnabled[BUTTON_RESTORE]) + { + mButtonsEnabled[BUTTON_MINIMIZE] = TRUE; + mButtonsEnabled[BUTTON_RESTORE] = FALSE; + } + + // show dependent floater + for(handle_set_iter_t dependent_it = mDependents.begin(); + dependent_it != mDependents.end(); + ++dependent_it) + { + LLFloater* floaterp = dependent_it->get(); + if (floaterp) + { + floaterp->setMinimized(FALSE); + floaterp->setVisible(TRUE); + } + } + + for (S32 i = 0; i < 4; i++) + { + if (mResizeBar[i] != NULL) + { + mResizeBar[i]->setEnabled(isResizable()); + } + if (mResizeHandle[i] != NULL) + { + mResizeHandle[i]->setEnabled(isResizable()); + } + } + + mMinimized = FALSE; + setFrontmost(); + // Reshape *after* setting mMinimized + reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE ); + } + + make_ui_sound("UISndWindowClose"); + updateTitleButtons(); + applyTitle (); } void LLFloater::setFocus( BOOL b ) { - if (b && getIsChrome()) - { - return; - } - LLView* last_focus = gFocusMgr.getLastFocusForGroup(this); - // a descendent already has focus - BOOL child_had_focus = hasFocus(); - - // give focus to first valid descendent - LLPanel::setFocus(b); - - if (b) - { - // only push focused floaters to front of stack if not in midst of ctrl-tab cycle - LLFloaterView * parent = dynamic_cast<LLFloaterView *>(getParent()); - if (!getHost() && parent && !parent->getCycleMode()) - { - if (!isFrontmost()) - { - setFrontmost(); - } - } - - // when getting focus, delegate to last descendent which had focus - if (last_focus && !child_had_focus && - last_focus->isInEnabledChain() && - last_focus->isInVisibleChain()) - { - // *FIX: should handle case where focus doesn't stick - last_focus->setFocus(TRUE); - } - } - updateTransparency(b ? TT_ACTIVE : TT_INACTIVE); + if (b && getIsChrome()) + { + return; + } + LLView* last_focus = gFocusMgr.getLastFocusForGroup(this); + // a descendent already has focus + BOOL child_had_focus = hasFocus(); + + // give focus to first valid descendent + LLPanel::setFocus(b); + + if (b) + { + // only push focused floaters to front of stack if not in midst of ctrl-tab cycle + LLFloaterView * parent = dynamic_cast<LLFloaterView *>(getParent()); + if (!getHost() && parent && !parent->getCycleMode()) + { + if (!isFrontmost()) + { + setFrontmost(); + } + } + + // when getting focus, delegate to last descendent which had focus + if (last_focus && !child_had_focus && + last_focus->isInEnabledChain() && + last_focus->isInVisibleChain()) + { + // *FIX: should handle case where focus doesn't stick + last_focus->setFocus(TRUE); + } + } + updateTransparency(b ? TT_ACTIVE : TT_INACTIVE); } // virtual void LLFloater::setRect(const LLRect &rect) { - LLPanel::setRect(rect); - layoutDragHandle(); - layoutResizeCtrls(); + LLPanel::setRect(rect); + layoutDragHandle(); + layoutResizeCtrls(); } // virtual void LLFloater::setIsChrome(BOOL is_chrome) { - // chrome floaters don't take focus at all - if (is_chrome) - { - // remove focus if we're changing to chrome - setFocus(FALSE); - // can't Ctrl-Tab to "chrome" floaters - setFocusRoot(FALSE); - mButtons[BUTTON_CLOSE]->setToolTip(LLStringExplicit(getButtonTooltip(Params(), BUTTON_CLOSE, is_chrome))); - } - - LLPanel::setIsChrome(is_chrome); + // chrome floaters don't take focus at all + if (is_chrome) + { + // remove focus if we're changing to chrome + setFocus(FALSE); + // can't Ctrl-Tab to "chrome" floaters + setFocusRoot(FALSE); + mButtons[BUTTON_CLOSE]->setToolTip(LLStringExplicit(getButtonTooltip(Params(), BUTTON_CLOSE, is_chrome))); + } + + LLPanel::setIsChrome(is_chrome); } // Change the draw style to account for the foreground state. void LLFloater::setForeground(BOOL front) { - if (front != mForeground) - { - mForeground = front; - if (mDragHandle) - mDragHandle->setForeground( front ); + if (front != mForeground) + { + mForeground = front; + if (mDragHandle) + mDragHandle->setForeground( front ); - if (!front) - { - releaseFocus(); - } + if (!front) + { + releaseFocus(); + } - setBackgroundOpaque( front ); - } + setBackgroundOpaque( front ); + } } void LLFloater::cleanupHandles() { - // remove handles to non-existent dependents - for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); ) - { - LLFloater* floaterp = dependent_it->get(); - if (!floaterp) - { - mDependents.erase(dependent_it++); - } - else - { - ++dependent_it; - } - } + // remove handles to non-existent dependents + for(handle_set_iter_t dependent_it = mDependents.begin(); + dependent_it != mDependents.end(); ) + { + LLFloater* floaterp = dependent_it->get(); + if (!floaterp) + { + mDependents.erase(dependent_it++); + } + else + { + ++dependent_it; + } + } } void LLFloater::setHost(LLMultiFloater* host) { - if (mHostHandle.isDead() && host) - { - // make buttons smaller for hosted windows to differentiate from parent - mButtonScale = 0.9f; - - // add tear off button - if (mCanTearOff) - { - mButtonsEnabled[BUTTON_TEAR_OFF] = TRUE; - } - } - else if (!mHostHandle.isDead() && !host) - { - mButtonScale = 1.f; - //mButtonsEnabled[BUTTON_TEAR_OFF] = FALSE; - } - if (host) - { - mHostHandle = host->getHandle(); - mLastHostHandle = host->getHandle(); - } - else - { - mHostHandle.markDead(); - } + if (mHostHandle.isDead() && host) + { + // make buttons smaller for hosted windows to differentiate from parent + mButtonScale = 0.9f; + + // add tear off button + if (mCanTearOff) + { + mButtonsEnabled[BUTTON_TEAR_OFF] = TRUE; + } + } + else if (!mHostHandle.isDead() && !host) + { + mButtonScale = 1.f; + //mButtonsEnabled[BUTTON_TEAR_OFF] = FALSE; + } + if (host) + { + mHostHandle = host->getHandle(); + mLastHostHandle = host->getHandle(); + } + else + { + mHostHandle.markDead(); + } - updateTitleButtons(); + updateTitleButtons(); } void LLFloater::moveResizeHandlesToFront() { - for( S32 i = 0; i < 4; i++ ) - { - if( mResizeBar[i] ) - { - sendChildToFront(mResizeBar[i]); - } - } + for( S32 i = 0; i < 4; i++ ) + { + if( mResizeBar[i] ) + { + sendChildToFront(mResizeBar[i]); + } + } - for( S32 i = 0; i < 4; i++ ) - { - if( mResizeHandle[i] ) - { - sendChildToFront(mResizeHandle[i]); - } - } + for( S32 i = 0; i < 4; i++ ) + { + if( mResizeHandle[i] ) + { + sendChildToFront(mResizeHandle[i]); + } + } } /*virtual*/ BOOL LLFloater::isFrontmost() { - LLFloaterView* floater_view = getParentByType<LLFloaterView>(); - return getVisible() - && (floater_view - && floater_view->getFrontmost() == this); + LLFloaterView* floater_view = getParentByType<LLFloaterView>(); + return getVisible() + && (floater_view + && floater_view->getFrontmost() == this); } void LLFloater::addDependentFloater(LLFloater* floaterp, BOOL reposition) { - mDependents.insert(floaterp->getHandle()); - floaterp->mDependeeHandle = getHandle(); + mDependents.insert(floaterp->getHandle()); + floaterp->mDependeeHandle = getHandle(); - if (reposition) - { - floaterp->setRect(gFloaterView->findNeighboringPosition(this, floaterp)); - floaterp->setSnapTarget(getHandle()); - } - gFloaterView->adjustToFitScreen(floaterp, FALSE, TRUE); - if (floaterp->isFrontmost()) - { - // make sure to bring self and sibling floaters to front - gFloaterView->bringToFront(floaterp); - } + if (reposition) + { + floaterp->setRect(gFloaterView->findNeighboringPosition(this, floaterp)); + floaterp->setSnapTarget(getHandle()); + } + gFloaterView->adjustToFitScreen(floaterp, FALSE, TRUE); + if (floaterp->isFrontmost()) + { + // make sure to bring self and sibling floaters to front + gFloaterView->bringToFront(floaterp); + } } void LLFloater::addDependentFloater(LLHandle<LLFloater> dependent, BOOL reposition) { - LLFloater* dependent_floaterp = dependent.get(); - if(dependent_floaterp) - { - addDependentFloater(dependent_floaterp, reposition); - } + LLFloater* dependent_floaterp = dependent.get(); + if(dependent_floaterp) + { + addDependentFloater(dependent_floaterp, reposition); + } } void LLFloater::removeDependentFloater(LLFloater* floaterp) { - mDependents.erase(floaterp->getHandle()); - floaterp->mDependeeHandle = LLHandle<LLFloater>(); + mDependents.erase(floaterp->getHandle()); + floaterp->mDependeeHandle = LLHandle<LLFloater>(); } BOOL LLFloater::offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index) { - if( mButtonsEnabled[index] ) - { - LLButton* my_butt = mButtons[index]; - S32 local_x = x - my_butt->getRect().mLeft; - S32 local_y = y - my_butt->getRect().mBottom; + if( mButtonsEnabled[index] ) + { + LLButton* my_butt = mButtons[index]; + S32 local_x = x - my_butt->getRect().mLeft; + S32 local_y = y - my_butt->getRect().mBottom; - if ( - my_butt->pointInView(local_x, local_y) && - my_butt->handleMouseDown(local_x, local_y, mask)) - { - // the button handled it - return TRUE; - } - } - return FALSE; + if ( + my_butt->pointInView(local_x, local_y) && + my_butt->handleMouseDown(local_x, local_y, mask)) + { + // the button handled it + return TRUE; + } + } + return FALSE; } BOOL LLFloater::handleScrollWheel(S32 x, S32 y, S32 clicks) { - LLPanel::handleScrollWheel(x,y,clicks); - return TRUE;//always + LLPanel::handleScrollWheel(x,y,clicks); + return TRUE;//always } // virtual BOOL LLFloater::handleMouseUp(S32 x, S32 y, MASK mask) { - LL_DEBUGS() << "LLFloater::handleMouseUp calling LLPanel (really LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL; - BOOL handled = LLPanel::handleMouseUp(x,y,mask); // Not implemented in LLPanel so this actually calls LLView - if (handled) { - LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); - } - return handled; + LL_DEBUGS() << "LLFloater::handleMouseUp calling LLPanel (really LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL; + BOOL handled = LLPanel::handleMouseUp(x,y,mask); // Not implemented in LLPanel so this actually calls LLView + if (handled) { + LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); + } + return handled; } // virtual BOOL LLFloater::handleMouseDown(S32 x, S32 y, MASK mask) { - if( mMinimized ) - { - // Offer the click to titlebar buttons. - // Note: this block and the offerClickToButton helper method can be removed - // because the parent container will handle it for us but we'll keep it here - // for safety until after reworking the panel code to manage hidden children. - if(offerClickToButton(x, y, mask, BUTTON_CLOSE)) return TRUE; - if(offerClickToButton(x, y, mask, BUTTON_RESTORE)) return TRUE; - if(offerClickToButton(x, y, mask, BUTTON_TEAR_OFF)) return TRUE; - if(offerClickToButton(x, y, mask, BUTTON_DOCK)) return TRUE; - - setFrontmost(TRUE, FALSE); - // Otherwise pass to drag handle for movement - return mDragHandle->handleMouseDown(x, y, mask); - } - else - { - bringToFront( x, y ); - BOOL handled = LLPanel::handleMouseDown( x, y, mask ); - if (handled) { - LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); - } - return handled; - } + if( mMinimized ) + { + // Offer the click to titlebar buttons. + // Note: this block and the offerClickToButton helper method can be removed + // because the parent container will handle it for us but we'll keep it here + // for safety until after reworking the panel code to manage hidden children. + if(offerClickToButton(x, y, mask, BUTTON_CLOSE)) return TRUE; + if(offerClickToButton(x, y, mask, BUTTON_RESTORE)) return TRUE; + if(offerClickToButton(x, y, mask, BUTTON_TEAR_OFF)) return TRUE; + if(offerClickToButton(x, y, mask, BUTTON_DOCK)) return TRUE; + + setFrontmost(TRUE, FALSE); + // Otherwise pass to drag handle for movement + return mDragHandle->handleMouseDown(x, y, mask); + } + else + { + bringToFront( x, y ); + BOOL handled = LLPanel::handleMouseDown( x, y, mask ); + if (handled) { + LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); + } + return handled; + } } // virtual BOOL LLFloater::handleRightMouseDown(S32 x, S32 y, MASK mask) { - BOOL was_minimized = mMinimized; - bringToFront( x, y ); - return was_minimized || LLPanel::handleRightMouseDown( x, y, mask ); + BOOL was_minimized = mMinimized; + bringToFront( x, y ); + return was_minimized || LLPanel::handleRightMouseDown( x, y, mask ); } BOOL LLFloater::handleMiddleMouseDown(S32 x, S32 y, MASK mask) { - bringToFront( x, y ); - return LLPanel::handleMiddleMouseDown( x, y, mask ); + bringToFront( x, y ); + return LLPanel::handleMiddleMouseDown( x, y, mask ); } // virtual BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask) { - BOOL was_minimized = mMinimized; - setMinimized(FALSE); - return was_minimized || LLPanel::handleDoubleClick(x, y, mask); + BOOL was_minimized = mMinimized; + setMinimized(FALSE); + return was_minimized || LLPanel::handleDoubleClick(x, y, mask); } void LLFloater::bringToFront( S32 x, S32 y ) { - if (getVisible() && pointInView(x, y)) - { - LLMultiFloater* hostp = getHost(); - if (hostp) - { - hostp->showFloater(this); - } - else - { - LLFloaterView* parent = dynamic_cast<LLFloaterView*>( getParent() ); - if (parent) - { - parent->bringToFront( this ); - } - } - } + if (getVisible() && pointInView(x, y)) + { + LLMultiFloater* hostp = getHost(); + if (hostp) + { + hostp->showFloater(this); + } + else + { + LLFloaterView* parent = dynamic_cast<LLFloaterView*>( getParent() ); + if (parent) + { + parent->bringToFront( this ); + } + } + } } // virtual void LLFloater::setVisibleAndFrontmost(BOOL take_focus,const LLSD& key) { - LLMultiFloater* hostp = getHost(); - if (hostp) - { - hostp->setVisible(TRUE); - hostp->setFrontmost(take_focus); - } - else - { - setVisible(TRUE); - setFrontmost(take_focus); - } + LLMultiFloater* hostp = getHost(); + if (hostp) + { + hostp->setVisible(TRUE); + hostp->setFrontmost(take_focus); + } + else + { + setVisible(TRUE); + setFrontmost(take_focus); + } } void LLFloater::setFrontmost(BOOL take_focus, BOOL restore) { - LLMultiFloater* hostp = getHost(); - if (hostp) - { - // this will bring the host floater to the front and select - // the appropriate panel - hostp->showFloater(this); - } - else - { - // there are more than one floater view - // so we need to query our parent directly - LLFloaterView * parent = dynamic_cast<LLFloaterView*>( getParent() ); - if (parent) - { - parent->bringToFront(this, take_focus, restore); - } - - // Make sure to set the appropriate transparency type (STORM-732). - updateTransparency(hasFocus() || getIsChrome() ? TT_ACTIVE : TT_INACTIVE); - } + LLMultiFloater* hostp = getHost(); + if (hostp) + { + // this will bring the host floater to the front and select + // the appropriate panel + hostp->showFloater(this); + } + else + { + // there are more than one floater view + // so we need to query our parent directly + LLFloaterView * parent = dynamic_cast<LLFloaterView*>( getParent() ); + if (parent) + { + parent->bringToFront(this, take_focus, restore); + } + + // Make sure to set the appropriate transparency type (STORM-732). + updateTransparency(hasFocus() || getIsChrome() ? TT_ACTIVE : TT_INACTIVE); + } } void LLFloater::setCanDock(bool b) { - if(b != mCanDock) - { - mCanDock = b; - if(mCanDock) - { - mButtonsEnabled[BUTTON_DOCK] = !mDocked; - } - else - { - mButtonsEnabled[BUTTON_DOCK] = FALSE; - } - } - updateTitleButtons(); + if(b != mCanDock) + { + mCanDock = b; + if(mCanDock) + { + mButtonsEnabled[BUTTON_DOCK] = !mDocked; + } + else + { + mButtonsEnabled[BUTTON_DOCK] = FALSE; + } + } + updateTitleButtons(); } void LLFloater::setDocked(bool docked, bool pop_on_undock) { - if(docked != mDocked && mCanDock) - { - mDocked = docked; - mButtonsEnabled[BUTTON_DOCK] = !mDocked; + if(docked != mDocked && mCanDock) + { + mDocked = docked; + mButtonsEnabled[BUTTON_DOCK] = !mDocked; - if (mDocked) - { - setMinimized(FALSE); - mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; - } + if (mDocked) + { + setMinimized(FALSE); + mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; + } - updateTitleButtons(); + updateTitleButtons(); - storeDockStateControl(); - } - + storeDockStateControl(); + } + } // static void LLFloater::onClickMinimize(LLFloater* self) { - if (!self) - return; - self->setMinimized( !self->isMinimized() ); + if (!self) + return; + self->setMinimized( !self->isMinimized() ); } void LLFloater::onClickTearOff(LLFloater* self) { - if (!self) - return; - S32 floater_header_size = self->mHeaderHeight; - LLMultiFloater* host_floater = self->getHost(); - if (host_floater) //Tear off - { - LLRect new_rect; - host_floater->removeFloater(self); - // reparent to floater view - gFloaterView->addChild(self); - - self->openFloater(self->getKey()); - if (self->mSaveRect && !self->mRectControl.empty()) - { - self->applyRectControl(); - } - else - { // only force position for floaters that don't have that data saved - new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight()); - self->setRect(new_rect); - } - gFloaterView->adjustToFitScreen(self, FALSE); - // give focus to new window to keep continuity for the user - self->setFocus(TRUE); - self->setTornOff(true); - } - else //Attach to parent. - { - LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get(); - if (new_host) - { - if (self->mSaveRect) - { - self->storeRectControl(); - } - self->setMinimized(FALSE); // to reenable minimize button if it was minimized - new_host->showFloater(self); - // make sure host is visible - new_host->openFloater(new_host->getKey()); - } - self->setTornOff(false); - } - self->updateTitleButtons(); + if (!self) + return; + S32 floater_header_size = self->mHeaderHeight; + LLMultiFloater* host_floater = self->getHost(); + if (host_floater) //Tear off + { + LLRect new_rect; + host_floater->removeFloater(self); + // reparent to floater view + gFloaterView->addChild(self); + + self->openFloater(self->getKey()); + if (self->mSaveRect && !self->mRectControl.empty()) + { + self->applyRectControl(); + } + else + { // only force position for floaters that don't have that data saved + new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight()); + self->setRect(new_rect); + } + gFloaterView->adjustToFitScreen(self, FALSE); + // give focus to new window to keep continuity for the user + self->setFocus(TRUE); + self->setTornOff(true); + } + else //Attach to parent. + { + LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get(); + if (new_host) + { + if (self->mSaveRect) + { + self->storeRectControl(); + } + self->setMinimized(FALSE); // to reenable minimize button if it was minimized + new_host->showFloater(self); + // make sure host is visible + new_host->openFloater(new_host->getKey()); + } + self->setTornOff(false); + } + self->updateTitleButtons(); self->setOpenPositioning(LLFloaterEnums::POSITIONING_RELATIVE); } // static void LLFloater::onClickDock(LLFloater* self) { - if(self && self->mCanDock) - { - self->setDocked(!self->mDocked, true); - } + if(self && self->mCanDock) + { + self->setDocked(!self->mDocked, true); + } } // static void LLFloater::onClickHelp( LLFloater* self ) { - if (self && LLUI::sHelpImpl) - { - // find the current help context for this floater - std::string help_topic; - if (self->findHelpTopic(help_topic)) - { - LLUI::sHelpImpl->showTopic(help_topic); - } - } + if (self && LLUI::sHelpImpl) + { + // find the current help context for this floater + std::string help_topic; + if (self->findHelpTopic(help_topic)) + { + LLUI::sHelpImpl->showTopic(help_topic); + } + } } void LLFloater::initRectControl() { - // save_rect and save_visibility only apply to registered floaters - if (mSaveRect) - { - std::string ctrl_name = getControlName(mInstanceName, mKey); - mRectControl = LLFloaterReg::declareRectControl(ctrl_name); - mPosXControl = LLFloaterReg::declarePosXControl(ctrl_name); - mPosYControl = LLFloaterReg::declarePosYControl(ctrl_name); - } + // save_rect and save_visibility only apply to registered floaters + if (mSaveRect) + { + std::string ctrl_name = getControlName(mInstanceName, mKey); + mRectControl = LLFloaterReg::declareRectControl(ctrl_name); + mPosXControl = LLFloaterReg::declarePosXControl(ctrl_name); + mPosYControl = LLFloaterReg::declarePosYControl(ctrl_name); + } } // static void LLFloater::closeFrontmostFloater() { - LLFloater* floater_to_close = gFloaterView->getFrontmostClosableFloater(); - if(floater_to_close) - { - floater_to_close->closeFloater(); - } + LLFloater* floater_to_close = gFloaterView->getFrontmostClosableFloater(); + if(floater_to_close) + { + floater_to_close->closeFloater(); + } - // if nothing took focus after closing focused floater - // give it to next floater (to allow closing multiple windows via keyboard in rapid succession) - if (gFocusMgr.getKeyboardFocus() == NULL) - { - // HACK: use gFloaterView directly in case we are using Ctrl-W to close snapshot window - // which sits in gSnapshotFloaterView, and needs to pass focus on to normal floater view - gFloaterView->focusFrontFloater(); - } + // if nothing took focus after closing focused floater + // give it to next floater (to allow closing multiple windows via keyboard in rapid succession) + if (gFocusMgr.getKeyboardFocus() == NULL) + { + // HACK: use gFloaterView directly in case we are using Ctrl-W to close snapshot window + // which sits in gSnapshotFloaterView, and needs to pass focus on to normal floater view + gFloaterView->focusFrontFloater(); + } } // static void LLFloater::onClickClose( LLFloater* self ) { - if (!self) - return; - self->onClickCloseBtn(); + if (!self) + return; + self->onClickCloseBtn(); } void LLFloater::onClickCloseBtn(bool app_quitting) { - closeFloater(false); + closeFloater(false); } // virtual void LLFloater::draw() { - const F32 alpha = getCurrentTransparency(); - - // draw background - if( isBackgroundVisible() ) - { - drawShadow(this); - - S32 left = LLPANEL_BORDER_WIDTH; - S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH; - S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH; - S32 bottom = LLPANEL_BORDER_WIDTH; - - LLUIImage* image = NULL; - LLColor4 color; - LLColor4 overlay_color; - if (isBackgroundOpaque()) - { - // NOTE: image may not be set - image = getBackgroundImage(); - color = getBackgroundColor(); - overlay_color = getBackgroundImageOverlay(); - } - else - { - image = getTransparentImage(); - color = getTransparentColor(); - overlay_color = getTransparentImageOverlay(); - } - - if (image) - { - // We're using images for this floater's backgrounds - image->draw(getLocalRect(), overlay_color % alpha); - } - else - { - // We're not using images, use old-school flat colors - gl_rect_2d( left, top, right, bottom, color % alpha ); - - // draw highlight on title bar to indicate focus. RDW - if(hasFocus() - && !getIsChrome() - && !getCurrentTitle().empty()) - { - static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor"); - - const LLFontGL* font = LLFontGL::getFontSansSerif(); - LLRect r = getRect(); - gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - font->getLineHeight() - 1, - titlebar_focus_color % alpha, 0, TRUE); - } - } - } - - LLPanel::updateDefaultBtn(); - - if( getDefaultButton() ) - { - if (hasFocus() && getDefaultButton()->getEnabled()) - { - LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus(); - // is this button a direct descendent and not a nested widget (e.g. checkbox)? - BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && dynamic_cast<LLButton*>(focus_ctrl)->getParent() == this; - // only enable default button when current focus is not a button - getDefaultButton()->setBorderEnabled(!focus_is_child_button); - } - else - { - getDefaultButton()->setBorderEnabled(FALSE); - } - } - if (isMinimized()) - { - for (S32 i = 0; i < BUTTON_COUNT; i++) - { - drawChild(mButtons[i]); - } - drawChild(mDragHandle, 0, 0, TRUE); - } - else - { - // don't call LLPanel::draw() since we've implemented custom background rendering - LLView::draw(); - } - - // update tearoff button for torn off floaters - // when last host goes away - if (mCanTearOff && !getHost()) - { - LLFloater* old_host = mLastHostHandle.get(); - if (!old_host) - { - setCanTearOff(FALSE); - } - } -} - -void LLFloater::drawShadow(LLPanel* panel) -{ - S32 left = LLPANEL_BORDER_WIDTH; - S32 top = panel->getRect().getHeight() - LLPANEL_BORDER_WIDTH; - S32 right = panel->getRect().getWidth() - LLPANEL_BORDER_WIDTH; - S32 bottom = LLPANEL_BORDER_WIDTH; - - static LLUICachedControl<S32> shadow_offset_S32 ("DropShadowFloater", 0); - static LLUIColor shadow_color_cached = LLUIColorTable::instance().getColor("ColorDropShadow"); - LLColor4 shadow_color = shadow_color_cached; - F32 shadow_offset = (F32)shadow_offset_S32; - - if (!panel->isBackgroundOpaque()) - { - shadow_offset *= 0.2f; - shadow_color.mV[VALPHA] *= 0.5f; - } - gl_drop_shadow(left, top, right, bottom, - shadow_color % getCurrentTransparency(), - ll_round(shadow_offset)); + const F32 alpha = getCurrentTransparency(); + + // draw background + if( isBackgroundVisible() ) + { + drawShadow(this); + + S32 left = LLPANEL_BORDER_WIDTH; + S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH; + S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH; + S32 bottom = LLPANEL_BORDER_WIDTH; + + LLUIImage* image = NULL; + LLColor4 color; + LLColor4 overlay_color; + if (isBackgroundOpaque()) + { + // NOTE: image may not be set + image = getBackgroundImage(); + color = getBackgroundColor(); + overlay_color = getBackgroundImageOverlay(); + } + else + { + image = getTransparentImage(); + color = getTransparentColor(); + overlay_color = getTransparentImageOverlay(); + } + + if (image) + { + // We're using images for this floater's backgrounds + image->draw(getLocalRect(), overlay_color % alpha); + } + else + { + // We're not using images, use old-school flat colors + gl_rect_2d( left, top, right, bottom, color % alpha ); + + // draw highlight on title bar to indicate focus. RDW + if(hasFocus() + && !getIsChrome() + && !getCurrentTitle().empty()) + { + static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor"); + + const LLFontGL* font = LLFontGL::getFontSansSerif(); + LLRect r = getRect(); + gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - font->getLineHeight() - 1, + titlebar_focus_color % alpha, 0, TRUE); + } + } + } + + LLPanel::updateDefaultBtn(); + + if( getDefaultButton() ) + { + if (hasFocus() && getDefaultButton()->getEnabled()) + { + LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus(); + // is this button a direct descendent and not a nested widget (e.g. checkbox)? + BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && dynamic_cast<LLButton*>(focus_ctrl)->getParent() == this; + // only enable default button when current focus is not a button + getDefaultButton()->setBorderEnabled(!focus_is_child_button); + } + else + { + getDefaultButton()->setBorderEnabled(FALSE); + } + } + if (isMinimized()) + { + for (S32 i = 0; i < BUTTON_COUNT; i++) + { + drawChild(mButtons[i]); + } + drawChild(mDragHandle, 0, 0, TRUE); + } + else + { + // don't call LLPanel::draw() since we've implemented custom background rendering + LLView::draw(); + } + + // update tearoff button for torn off floaters + // when last host goes away + if (mCanTearOff && !getHost()) + { + LLFloater* old_host = mLastHostHandle.get(); + if (!old_host) + { + setCanTearOff(FALSE); + } + } +} + +void LLFloater::drawShadow(LLPanel* panel) +{ + S32 left = LLPANEL_BORDER_WIDTH; + S32 top = panel->getRect().getHeight() - LLPANEL_BORDER_WIDTH; + S32 right = panel->getRect().getWidth() - LLPANEL_BORDER_WIDTH; + S32 bottom = LLPANEL_BORDER_WIDTH; + + static LLUICachedControl<S32> shadow_offset_S32 ("DropShadowFloater", 0); + static LLUIColor shadow_color_cached = LLUIColorTable::instance().getColor("ColorDropShadow"); + LLColor4 shadow_color = shadow_color_cached; + F32 shadow_offset = (F32)shadow_offset_S32; + + if (!panel->isBackgroundOpaque()) + { + shadow_offset *= 0.2f; + shadow_color.mV[VALPHA] *= 0.5f; + } + gl_drop_shadow(left, top, right, bottom, + shadow_color % getCurrentTransparency(), + ll_round(shadow_offset)); } void LLFloater::updateTransparency(LLView* view, ETypeTransparency transparency_type) { - if (!view) return; - child_list_t children = *view->getChildList(); - child_list_t::iterator it = children.begin(); + if (!view) return; + child_list_t children = *view->getChildList(); + child_list_t::iterator it = children.begin(); - LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(view); - if (ctrl) - { - ctrl->setTransparencyType(transparency_type); - } + LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(view); + if (ctrl) + { + ctrl->setTransparencyType(transparency_type); + } - for(; it != children.end(); ++it) - { - updateTransparency(*it, transparency_type); - } + for(; it != children.end(); ++it) + { + updateTransparency(*it, transparency_type); + } } void LLFloater::updateTransparency(ETypeTransparency transparency_type) { - updateTransparency(this, transparency_type); + updateTransparency(this, transparency_type); } -void LLFloater::setCanMinimize(BOOL can_minimize) +void LLFloater::setCanMinimize(BOOL can_minimize) { - // if removing minimize/restore button programmatically, - // go ahead and unminimize floater - mCanMinimize = can_minimize; - if (!can_minimize) - { - setMinimized(FALSE); - } + // if removing minimize/restore button programmatically, + // go ahead and unminimize floater + mCanMinimize = can_minimize; + if (!can_minimize) + { + setMinimized(FALSE); + } - mButtonsEnabled[BUTTON_MINIMIZE] = can_minimize && !isMinimized(); - mButtonsEnabled[BUTTON_RESTORE] = can_minimize && isMinimized(); + mButtonsEnabled[BUTTON_MINIMIZE] = can_minimize && !isMinimized(); + mButtonsEnabled[BUTTON_RESTORE] = can_minimize && isMinimized(); - updateTitleButtons(); + updateTitleButtons(); } -void LLFloater::setCanClose(BOOL can_close) +void LLFloater::setCanClose(BOOL can_close) { - mCanClose = can_close; - mButtonsEnabled[BUTTON_CLOSE] = can_close; + mCanClose = can_close; + mButtonsEnabled[BUTTON_CLOSE] = can_close; - updateTitleButtons(); + updateTitleButtons(); } -void LLFloater::setCanTearOff(BOOL can_tear_off) +void LLFloater::setCanTearOff(BOOL can_tear_off) { - mCanTearOff = can_tear_off; - mButtonsEnabled[BUTTON_TEAR_OFF] = mCanTearOff && !mHostHandle.isDead(); + mCanTearOff = can_tear_off; + mButtonsEnabled[BUTTON_TEAR_OFF] = mCanTearOff && !mHostHandle.isDead(); - updateTitleButtons(); + updateTitleButtons(); } void LLFloater::setCanResize(BOOL can_resize) { - mResizable = can_resize; - enableResizeCtrls(can_resize); + mResizable = can_resize; + enableResizeCtrls(can_resize); } void LLFloater::setCanDrag(BOOL can_drag) { - // if we delete drag handle, we no longer have access to the floater's title - // so just enable/disable it - if (!can_drag && mDragHandle->getEnabled()) - { - mDragHandle->setEnabled(FALSE); - } - else if (can_drag && !mDragHandle->getEnabled()) - { - mDragHandle->setEnabled(TRUE); - } + // if we delete drag handle, we no longer have access to the floater's title + // so just enable/disable it + if (!can_drag && mDragHandle->getEnabled()) + { + mDragHandle->setEnabled(FALSE); + } + else if (can_drag && !mDragHandle->getEnabled()) + { + mDragHandle->setEnabled(TRUE); + } } bool LLFloater::getCanDrag() { - return mDragHandle->getEnabled(); + return mDragHandle->getEnabled(); } void LLFloater::updateTitleButtons() { - static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); - static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0); - LLRect buttons_rect; - S32 button_count = 0; - for (S32 i = 0; i < BUTTON_COUNT; i++) - { - if (!mButtons[i]) - { - continue; - } - - bool enabled = mButtonsEnabled[i]; - if (i == BUTTON_HELP) - { - // don't show the help button if the floater is minimized - // or if it is a docked tear-off floater - if (isMinimized() || (mButtonsEnabled[BUTTON_TEAR_OFF] && ! mTornOff)) - { - enabled = false; - } - } - if (i == BUTTON_CLOSE && mButtonScale != 1.f) - { - //*HACK: always render close button for hosted floaters so - //that users don't accidentally hit the button when - //closing multiple windows in the chatterbox - enabled = true; - } - - mButtons[i]->setEnabled(enabled); - - if (enabled) - { - button_count++; - - LLRect btn_rect; - if (mDragOnLeft) - { - btn_rect.setLeftTopAndSize( - LLPANEL_BORDER_WIDTH, - getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * button_count, - ll_round((F32)floater_close_box_size * mButtonScale), - ll_round((F32)floater_close_box_size * mButtonScale)); - } - else - { - btn_rect.setLeftTopAndSize( - getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * button_count, - getRect().getHeight() - close_box_from_top, - ll_round((F32)floater_close_box_size * mButtonScale), - ll_round((F32)floater_close_box_size * mButtonScale)); - } - - // first time here, init 'buttons_rect' - if(1 == button_count) - { - buttons_rect = btn_rect; - } - else - { - // if mDragOnLeft=true then buttons are on top-left side vertically aligned - // title is not displayed in this case, calculating 'buttons_rect' for future use - mDragOnLeft ? buttons_rect.mBottom -= btn_rect.mBottom : - buttons_rect.mLeft = btn_rect.mLeft; - } - mButtons[i]->setRect(btn_rect); - mButtons[i]->setVisible(TRUE); - // the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater - mButtons[i]->setTabStop(i == BUTTON_RESTORE); - } - else - { - mButtons[i]->setVisible(FALSE); - } - } - if (mDragHandle) - { - localRectToOtherView(buttons_rect, &buttons_rect, mDragHandle); - mDragHandle->setButtonsRect(buttons_rect); - } + static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); + static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0); + LLRect buttons_rect; + S32 button_count = 0; + for (S32 i = 0; i < BUTTON_COUNT; i++) + { + if (!mButtons[i]) + { + continue; + } + + bool enabled = mButtonsEnabled[i]; + if (i == BUTTON_HELP) + { + // don't show the help button if the floater is minimized + // or if it is a docked tear-off floater + if (isMinimized() || (mButtonsEnabled[BUTTON_TEAR_OFF] && ! mTornOff)) + { + enabled = false; + } + } + if (i == BUTTON_CLOSE && mButtonScale != 1.f) + { + //*HACK: always render close button for hosted floaters so + //that users don't accidentally hit the button when + //closing multiple windows in the chatterbox + enabled = true; + } + + mButtons[i]->setEnabled(enabled); + + if (enabled) + { + button_count++; + + LLRect btn_rect; + if (mDragOnLeft) + { + btn_rect.setLeftTopAndSize( + LLPANEL_BORDER_WIDTH, + getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * button_count, + ll_round((F32)floater_close_box_size * mButtonScale), + ll_round((F32)floater_close_box_size * mButtonScale)); + } + else + { + btn_rect.setLeftTopAndSize( + getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * button_count, + getRect().getHeight() - close_box_from_top, + ll_round((F32)floater_close_box_size * mButtonScale), + ll_round((F32)floater_close_box_size * mButtonScale)); + } + + // first time here, init 'buttons_rect' + if(1 == button_count) + { + buttons_rect = btn_rect; + } + else + { + // if mDragOnLeft=true then buttons are on top-left side vertically aligned + // title is not displayed in this case, calculating 'buttons_rect' for future use + mDragOnLeft ? buttons_rect.mBottom -= btn_rect.mBottom : + buttons_rect.mLeft = btn_rect.mLeft; + } + mButtons[i]->setRect(btn_rect); + mButtons[i]->setVisible(TRUE); + // the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater + mButtons[i]->setTabStop(i == BUTTON_RESTORE); + } + else + { + mButtons[i]->setVisible(FALSE); + } + } + if (mDragHandle) + { + localRectToOtherView(buttons_rect, &buttons_rect, mDragHandle); + mDragHandle->setButtonsRect(buttons_rect); + } } void LLFloater::buildButtons(const Params& floater_params) { - static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); - static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0); - for (S32 i = 0; i < BUTTON_COUNT; i++) - { - if (mButtons[i]) - { - removeChild(mButtons[i]); - delete mButtons[i]; - mButtons[i] = NULL; - } - - LLRect btn_rect; - if (mDragOnLeft) - { - btn_rect.setLeftTopAndSize( - LLPANEL_BORDER_WIDTH, - getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * (i + 1), - ll_round(floater_close_box_size * mButtonScale), - ll_round(floater_close_box_size * mButtonScale)); - } - else - { - btn_rect.setLeftTopAndSize( - getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * (i + 1), - getRect().getHeight() - close_box_from_top, - ll_round(floater_close_box_size * mButtonScale), - ll_round(floater_close_box_size * mButtonScale)); - } - - LLButton::Params p; - p.name(sButtonNames[i]); - p.rect(btn_rect); - p.image_unselected = getButtonImage(floater_params, (EFloaterButton)i); - // Selected, no matter if hovered or not, is "pressed" - LLUIImage* pressed_image = getButtonPressedImage(floater_params, (EFloaterButton)i); - p.image_selected = pressed_image; - p.image_hover_selected = pressed_image; - // Use a glow effect when the user hovers over the button - // These icons are really small, need glow amount increased - p.hover_glow_amount( 0.33f ); - p.click_callback.function(boost::bind(sButtonCallbacks[i], this)); - p.tab_stop(false); - p.follows.flags(FOLLOWS_TOP|FOLLOWS_RIGHT); - p.tool_tip = getButtonTooltip(floater_params, (EFloaterButton)i, getIsChrome()); - p.scale_image(true); - p.chrome(true); - - LLButton* buttonp = LLUICtrlFactory::create<LLButton>(p); - addChild(buttonp); - mButtons[i] = buttonp; - } - - updateTitleButtons(); + static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); + static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0); + for (S32 i = 0; i < BUTTON_COUNT; i++) + { + if (mButtons[i]) + { + removeChild(mButtons[i]); + delete mButtons[i]; + mButtons[i] = NULL; + } + + LLRect btn_rect; + if (mDragOnLeft) + { + btn_rect.setLeftTopAndSize( + LLPANEL_BORDER_WIDTH, + getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * (i + 1), + ll_round(floater_close_box_size * mButtonScale), + ll_round(floater_close_box_size * mButtonScale)); + } + else + { + btn_rect.setLeftTopAndSize( + getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * (i + 1), + getRect().getHeight() - close_box_from_top, + ll_round(floater_close_box_size * mButtonScale), + ll_round(floater_close_box_size * mButtonScale)); + } + + LLButton::Params p; + p.name(sButtonNames[i]); + p.rect(btn_rect); + p.image_unselected = getButtonImage(floater_params, (EFloaterButton)i); + // Selected, no matter if hovered or not, is "pressed" + LLUIImage* pressed_image = getButtonPressedImage(floater_params, (EFloaterButton)i); + p.image_selected = pressed_image; + p.image_hover_selected = pressed_image; + // Use a glow effect when the user hovers over the button + // These icons are really small, need glow amount increased + p.hover_glow_amount( 0.33f ); + p.click_callback.function(boost::bind(sButtonCallbacks[i], this)); + p.tab_stop(false); + p.follows.flags(FOLLOWS_TOP|FOLLOWS_RIGHT); + p.tool_tip = getButtonTooltip(floater_params, (EFloaterButton)i, getIsChrome()); + p.scale_image(true); + p.chrome(true); + + LLButton* buttonp = LLUICtrlFactory::create<LLButton>(p); + addChild(buttonp); + mButtons[i] = buttonp; + } + + updateTitleButtons(); } // static LLUIImage* LLFloater::getButtonImage(const Params& p, EFloaterButton e) { - switch(e) - { - default: - case BUTTON_CLOSE: - return p.close_image; - case BUTTON_RESTORE: - return p.restore_image; - case BUTTON_MINIMIZE: - return p.minimize_image; - case BUTTON_TEAR_OFF: - return p.tear_off_image; - case BUTTON_DOCK: - return p.dock_image; - case BUTTON_HELP: - return p.help_image; - } + switch(e) + { + default: + case BUTTON_CLOSE: + return p.close_image; + case BUTTON_RESTORE: + return p.restore_image; + case BUTTON_MINIMIZE: + return p.minimize_image; + case BUTTON_TEAR_OFF: + return p.tear_off_image; + case BUTTON_DOCK: + return p.dock_image; + case BUTTON_HELP: + return p.help_image; + } } // static LLUIImage* LLFloater::getButtonPressedImage(const Params& p, EFloaterButton e) { - switch(e) - { - default: - case BUTTON_CLOSE: - return p.close_pressed_image; - case BUTTON_RESTORE: - return p.restore_pressed_image; - case BUTTON_MINIMIZE: - return p.minimize_pressed_image; - case BUTTON_TEAR_OFF: - return p.tear_off_pressed_image; - case BUTTON_DOCK: - return p.dock_pressed_image; - case BUTTON_HELP: - return p.help_pressed_image; - } + switch(e) + { + default: + case BUTTON_CLOSE: + return p.close_pressed_image; + case BUTTON_RESTORE: + return p.restore_pressed_image; + case BUTTON_MINIMIZE: + return p.minimize_pressed_image; + case BUTTON_TEAR_OFF: + return p.tear_off_pressed_image; + case BUTTON_DOCK: + return p.dock_pressed_image; + case BUTTON_HELP: + return p.help_pressed_image; + } } // static std::string LLFloater::getButtonTooltip(const Params& p, EFloaterButton e, bool is_chrome) { - // EXT-4081 (Lag Meter: Ctrl+W does not close floater) - // If floater is chrome set 'Close' text for close button's tooltip - if(is_chrome && BUTTON_CLOSE == e) - { - static std::string close_tooltip_chrome = LLTrans::getString("BUTTON_CLOSE_CHROME"); - return close_tooltip_chrome; - } - // TODO: per-floater localizable tooltips set in XML - return sButtonToolTips[e]; + // EXT-4081 (Lag Meter: Ctrl+W does not close floater) + // If floater is chrome set 'Close' text for close button's tooltip + if(is_chrome && BUTTON_CLOSE == e) + { + static std::string close_tooltip_chrome = LLTrans::getString("BUTTON_CLOSE_CHROME"); + return close_tooltip_chrome; + } + // TODO: per-floater localizable tooltips set in XML + return sButtonToolTips[e]; } ///////////////////////////////////////////////////// @@ -2234,946 +2234,946 @@ std::string LLFloater::getButtonTooltip(const Params& p, EFloaterButton e, bool static LLDefaultChildRegistry::Register<LLFloaterView> r("floater_view"); LLFloaterView::LLFloaterView (const Params& p) -: LLUICtrl (p), - mFocusCycleMode(FALSE), - mMinimizePositionVOffset(0), - mSnapOffsetBottom(0), - mSnapOffsetRight(0), - mFrontChild(NULL) +: LLUICtrl (p), + mFocusCycleMode(FALSE), + mMinimizePositionVOffset(0), + mSnapOffsetBottom(0), + mSnapOffsetRight(0), + mFrontChild(NULL) { - mSnapView = getHandle(); + mSnapView = getHandle(); } // By default, adjust vertical. void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) { - LLView::reshape(width, height, called_from_parent); - - mLastSnapRect = getSnapRect(); - - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLView* viewp = *child_it; - LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp); - if (floaterp->isDependent()) - { - // dependents are moved with their "dependee" - continue; - } - - if (!floaterp->isMinimized() && floaterp->getCanDrag()) - { - LLRect old_rect = floaterp->getRect(); - floaterp->applyPositioning(NULL, false); - LLRect new_rect = floaterp->getRect(); - - //LLRect r = floaterp->getRect(); - - //// Compute absolute distance from each edge of screen - //S32 left_offset = llabs(r.mLeft - 0); - //S32 right_offset = llabs(old_right - r.mRight); - - //S32 top_offset = llabs(old_top - r.mTop); - //S32 bottom_offset = llabs(r.mBottom - 0); - - S32 translate_x = new_rect.mLeft - old_rect.mLeft; - S32 translate_y = new_rect.mBottom - old_rect.mBottom; - - //if (left_offset > right_offset) - //{ - // translate_x = new_right - old_right; - //} - - //if (top_offset < bottom_offset) - //{ - // translate_y = new_top - old_top; - //} - - // don't reposition immovable floaters - //if (floaterp->getCanDrag()) - //{ - // floaterp->translate(translate_x, translate_y); - //} - BOOST_FOREACH(LLHandle<LLFloater> dependent_floater, floaterp->mDependents) - { - if (dependent_floater.get()) - { - dependent_floater.get()->translate(translate_x, translate_y); - } - } - } - } + LLView::reshape(width, height, called_from_parent); + + mLastSnapRect = getSnapRect(); + + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + LLView* viewp = *child_it; + LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp); + if (floaterp->isDependent()) + { + // dependents are moved with their "dependee" + continue; + } + + if (!floaterp->isMinimized() && floaterp->getCanDrag()) + { + LLRect old_rect = floaterp->getRect(); + floaterp->applyPositioning(NULL, false); + LLRect new_rect = floaterp->getRect(); + + //LLRect r = floaterp->getRect(); + + //// Compute absolute distance from each edge of screen + //S32 left_offset = llabs(r.mLeft - 0); + //S32 right_offset = llabs(old_right - r.mRight); + + //S32 top_offset = llabs(old_top - r.mTop); + //S32 bottom_offset = llabs(r.mBottom - 0); + + S32 translate_x = new_rect.mLeft - old_rect.mLeft; + S32 translate_y = new_rect.mBottom - old_rect.mBottom; + + //if (left_offset > right_offset) + //{ + // translate_x = new_right - old_right; + //} + + //if (top_offset < bottom_offset) + //{ + // translate_y = new_top - old_top; + //} + + // don't reposition immovable floaters + //if (floaterp->getCanDrag()) + //{ + // floaterp->translate(translate_x, translate_y); + //} + BOOST_FOREACH(LLHandle<LLFloater> dependent_floater, floaterp->mDependents) + { + if (dependent_floater.get()) + { + dependent_floater.get()->translate(translate_x, translate_y); + } + } + } + } } void LLFloaterView::restoreAll() { - // make sure all subwindows aren't minimized - child_list_t child_list = *(getChildList()); - for (child_list_const_iter_t child_it = child_list.begin(); child_it != child_list.end(); ++child_it) - { - LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it); - if (floaterp) - { - floaterp->setMinimized(FALSE); - } - } + // make sure all subwindows aren't minimized + child_list_t child_list = *(getChildList()); + for (child_list_const_iter_t child_it = child_list.begin(); child_it != child_list.end(); ++child_it) + { + LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it); + if (floaterp) + { + floaterp->setMinimized(FALSE); + } + } - // *FIX: make sure dependents are restored + // *FIX: make sure dependents are restored - // children then deleted by default view constructor + // children then deleted by default view constructor } LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLFloater* neighbor ) { - LLRect base_rect = reference_floater->getRect(); - LLRect::tCoordType width = neighbor->getRect().getWidth(); - LLRect::tCoordType height = neighbor->getRect().getHeight(); - LLRect new_rect = neighbor->getRect(); - - LLRect expanded_base_rect = base_rect; - expanded_base_rect.stretch(10); - for(LLFloater::handle_set_iter_t dependent_it = reference_floater->mDependents.begin(); - dependent_it != reference_floater->mDependents.end(); ++dependent_it) - { - LLFloater* sibling = dependent_it->get(); - // check for dependents within 10 pixels of base floater - if (sibling && - sibling != neighbor && - sibling->getVisible() && - expanded_base_rect.overlaps(sibling->getRect())) - { - base_rect.unionWith(sibling->getRect()); - } - } - - LLRect::tCoordType left_margin = llmax(0, base_rect.mLeft); - LLRect::tCoordType right_margin = llmax(0, getRect().getWidth() - base_rect.mRight); - LLRect::tCoordType top_margin = llmax(0, getRect().getHeight() - base_rect.mTop); - LLRect::tCoordType bottom_margin = llmax(0, base_rect.mBottom); - - // find position for floater in following order - // right->left->bottom->top - for (S32 i = 0; i < 5; i++) - { - if (right_margin > width) - { - new_rect.translate(base_rect.mRight - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mTop); - return new_rect; - } - else if (left_margin > width) - { - new_rect.translate(base_rect.mLeft - neighbor->getRect().mRight, base_rect.mTop - neighbor->getRect().mTop); - return new_rect; - } - else if (bottom_margin > height) - { - new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mBottom - neighbor->getRect().mTop); - return new_rect; - } - else if (top_margin > height) - { - new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mBottom); - return new_rect; - } - - // keep growing margins to find "best" fit - left_margin += 20; - right_margin += 20; - top_margin += 20; - bottom_margin += 20; - } - - // didn't find anything, return initial rect - return new_rect; + LLRect base_rect = reference_floater->getRect(); + LLRect::tCoordType width = neighbor->getRect().getWidth(); + LLRect::tCoordType height = neighbor->getRect().getHeight(); + LLRect new_rect = neighbor->getRect(); + + LLRect expanded_base_rect = base_rect; + expanded_base_rect.stretch(10); + for(LLFloater::handle_set_iter_t dependent_it = reference_floater->mDependents.begin(); + dependent_it != reference_floater->mDependents.end(); ++dependent_it) + { + LLFloater* sibling = dependent_it->get(); + // check for dependents within 10 pixels of base floater + if (sibling && + sibling != neighbor && + sibling->getVisible() && + expanded_base_rect.overlaps(sibling->getRect())) + { + base_rect.unionWith(sibling->getRect()); + } + } + + LLRect::tCoordType left_margin = llmax(0, base_rect.mLeft); + LLRect::tCoordType right_margin = llmax(0, getRect().getWidth() - base_rect.mRight); + LLRect::tCoordType top_margin = llmax(0, getRect().getHeight() - base_rect.mTop); + LLRect::tCoordType bottom_margin = llmax(0, base_rect.mBottom); + + // find position for floater in following order + // right->left->bottom->top + for (S32 i = 0; i < 5; i++) + { + if (right_margin > width) + { + new_rect.translate(base_rect.mRight - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mTop); + return new_rect; + } + else if (left_margin > width) + { + new_rect.translate(base_rect.mLeft - neighbor->getRect().mRight, base_rect.mTop - neighbor->getRect().mTop); + return new_rect; + } + else if (bottom_margin > height) + { + new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mBottom - neighbor->getRect().mTop); + return new_rect; + } + else if (top_margin > height) + { + new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mBottom); + return new_rect; + } + + // keep growing margins to find "best" fit + left_margin += 20; + right_margin += 20; + top_margin += 20; + bottom_margin += 20; + } + + // didn't find anything, return initial rect + return new_rect; } void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus, BOOL restore) { - if (!child) - return; - - if (mFrontChild == child) - { - if (give_focus && !gFocusMgr.childHasKeyboardFocus(child)) - { - child->setFocus(TRUE); - } - return; - } - - mFrontChild = child; - - // *TODO: make this respect floater's mAutoFocus value, instead of - // using parameter - if (child->getHost()) - { - // this floater is hosted elsewhere and hence not one of our children, abort - return; - } - std::vector<LLFloater*> floaters_to_move; - // Look at all floaters...tab - for (child_list_const_iter_t child_it = beginChild(); child_it != endChild(); ++child_it) - { - LLFloater* floater = dynamic_cast<LLFloater*>(*child_it); - - // ...but if I'm a dependent floater... - if (floater && child->isDependent()) - { - // ...look for floaters that have me as a dependent... - LLFloater::handle_set_iter_t found_dependent = floater->mDependents.find(child->getHandle()); - - if (found_dependent != floater->mDependents.end()) - { - // ...and make sure all children of that floater (including me) are brought to front... - for (LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin(); - dependent_it != floater->mDependents.end(); ++dependent_it) - { - LLFloater* sibling = dependent_it->get(); - if (sibling) - { - floaters_to_move.push_back(sibling); - } - } - //...before bringing my parent to the front... - floaters_to_move.push_back(floater); - } - } - } - - std::vector<LLFloater*>::iterator floater_it; - for(floater_it = floaters_to_move.begin(); floater_it != floaters_to_move.end(); ++floater_it) - { - LLFloater* floaterp = *floater_it; - sendChildToFront(floaterp); - - // always unminimize dependee, but allow dependents to stay minimized - if (!floaterp->isDependent()) - { - floaterp->setMinimized(FALSE); - } - } - floaters_to_move.clear(); - - // ...then bringing my own dependents to the front... - for (LLFloater::handle_set_iter_t dependent_it = child->mDependents.begin(); - dependent_it != child->mDependents.end(); ++dependent_it) - { - LLFloater* dependent = dependent_it->get(); - if (dependent) - { - sendChildToFront(dependent); - } - } - - // ...and finally bringing myself to front - // (do this last, so that I'm left in front at end of this call) - if (*beginChild() != child) - { - sendChildToFront(child); - } - - if(restore) - { - child->setMinimized(FALSE); - } - - if (give_focus && !gFocusMgr.childHasKeyboardFocus(child)) - { - child->setFocus(TRUE); - // floater did not take focus, so relinquish focus to world - if (!child->hasFocus()) - { - gFocusMgr.setKeyboardFocus(NULL); - } - } + if (!child) + return; + + if (mFrontChild == child) + { + if (give_focus && !gFocusMgr.childHasKeyboardFocus(child)) + { + child->setFocus(TRUE); + } + return; + } + + mFrontChild = child; + + // *TODO: make this respect floater's mAutoFocus value, instead of + // using parameter + if (child->getHost()) + { + // this floater is hosted elsewhere and hence not one of our children, abort + return; + } + std::vector<LLFloater*> floaters_to_move; + // Look at all floaters...tab + for (child_list_const_iter_t child_it = beginChild(); child_it != endChild(); ++child_it) + { + LLFloater* floater = dynamic_cast<LLFloater*>(*child_it); + + // ...but if I'm a dependent floater... + if (floater && child->isDependent()) + { + // ...look for floaters that have me as a dependent... + LLFloater::handle_set_iter_t found_dependent = floater->mDependents.find(child->getHandle()); + + if (found_dependent != floater->mDependents.end()) + { + // ...and make sure all children of that floater (including me) are brought to front... + for (LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin(); + dependent_it != floater->mDependents.end(); ++dependent_it) + { + LLFloater* sibling = dependent_it->get(); + if (sibling) + { + floaters_to_move.push_back(sibling); + } + } + //...before bringing my parent to the front... + floaters_to_move.push_back(floater); + } + } + } + + std::vector<LLFloater*>::iterator floater_it; + for(floater_it = floaters_to_move.begin(); floater_it != floaters_to_move.end(); ++floater_it) + { + LLFloater* floaterp = *floater_it; + sendChildToFront(floaterp); + + // always unminimize dependee, but allow dependents to stay minimized + if (!floaterp->isDependent()) + { + floaterp->setMinimized(FALSE); + } + } + floaters_to_move.clear(); + + // ...then bringing my own dependents to the front... + for (LLFloater::handle_set_iter_t dependent_it = child->mDependents.begin(); + dependent_it != child->mDependents.end(); ++dependent_it) + { + LLFloater* dependent = dependent_it->get(); + if (dependent) + { + sendChildToFront(dependent); + } + } + + // ...and finally bringing myself to front + // (do this last, so that I'm left in front at end of this call) + if (*beginChild() != child) + { + sendChildToFront(child); + } + + if(restore) + { + child->setMinimized(FALSE); + } + + if (give_focus && !gFocusMgr.childHasKeyboardFocus(child)) + { + child->setFocus(TRUE); + // floater did not take focus, so relinquish focus to world + if (!child->hasFocus()) + { + gFocusMgr.setKeyboardFocus(NULL); + } + } } void LLFloaterView::highlightFocusedFloater() { - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLFloater *floater = (LLFloater *)(*child_it); - - // skip dependent floaters, as we'll handle them in a batch along with their dependee(?) - if (floater->isDependent()) - { - continue; - } - - BOOL floater_or_dependent_has_focus = gFocusMgr.childHasKeyboardFocus(floater); - for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin(); - dependent_it != floater->mDependents.end(); - ++dependent_it) - { - LLFloater* dependent_floaterp = dependent_it->get(); - if (dependent_floaterp && gFocusMgr.childHasKeyboardFocus(dependent_floaterp)) - { - floater_or_dependent_has_focus = TRUE; - } - } - - // now set this floater and all its dependents - floater->setForeground(floater_or_dependent_has_focus); - - for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin(); - dependent_it != floater->mDependents.end(); ) - { - LLFloater* dependent_floaterp = dependent_it->get(); - if (dependent_floaterp) - { - dependent_floaterp->setForeground(floater_or_dependent_has_focus); - } - ++dependent_it; - } - - floater->cleanupHandles(); - } + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + LLFloater *floater = (LLFloater *)(*child_it); + + // skip dependent floaters, as we'll handle them in a batch along with their dependee(?) + if (floater->isDependent()) + { + continue; + } + + BOOL floater_or_dependent_has_focus = gFocusMgr.childHasKeyboardFocus(floater); + for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin(); + dependent_it != floater->mDependents.end(); + ++dependent_it) + { + LLFloater* dependent_floaterp = dependent_it->get(); + if (dependent_floaterp && gFocusMgr.childHasKeyboardFocus(dependent_floaterp)) + { + floater_or_dependent_has_focus = TRUE; + } + } + + // now set this floater and all its dependents + floater->setForeground(floater_or_dependent_has_focus); + + for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin(); + dependent_it != floater->mDependents.end(); ) + { + LLFloater* dependent_floaterp = dependent_it->get(); + if (dependent_floaterp) + { + dependent_floaterp->setForeground(floater_or_dependent_has_focus); + } + ++dependent_it; + } + + floater->cleanupHandles(); + } } LLFloater* LLFloaterView::getFrontmostClosableFloater() { - child_list_const_iter_t child_it; - LLFloater* frontmost_floater = NULL; + child_list_const_iter_t child_it; + LLFloater* frontmost_floater = NULL; - for ( child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - frontmost_floater = (LLFloater *)(*child_it); + for ( child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + frontmost_floater = (LLFloater *)(*child_it); - if (frontmost_floater->isInVisibleChain() && frontmost_floater->isCloseable()) - { - return frontmost_floater; - } - } + if (frontmost_floater->isInVisibleChain() && frontmost_floater->isCloseable()) + { + return frontmost_floater; + } + } - return NULL; + return NULL; } void LLFloaterView::unhighlightFocusedFloater() { - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLFloater *floater = (LLFloater *)(*child_it); + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + LLFloater *floater = (LLFloater *)(*child_it); - floater->setForeground(FALSE); - } + floater->setForeground(FALSE); + } } void LLFloaterView::focusFrontFloater() { - LLFloater* floaterp = getFrontmost(); - if (floaterp) - { - floaterp->setFocus(TRUE); - } + LLFloater* floaterp = getFrontmost(); + if (floaterp) + { + floaterp->setFocus(TRUE); + } } void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom) { - const LLFloater::Params& default_params = LLFloater::getDefaultParams(); - S32 floater_header_size = default_params.header_height; - static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0); - LLRect snap_rect_local = getLocalSnapRect(); - snap_rect_local.mTop += mMinimizePositionVOffset; - for(S32 col = snap_rect_local.mLeft; - col < snap_rect_local.getWidth() - minimized_width; - col += minimized_width) - { - for(S32 row = snap_rect_local.mTop - floater_header_size; - row > floater_header_size; - row -= floater_header_size ) //loop rows - { - - bool foundGap = TRUE; - for(child_list_const_iter_t child_it = getChildList()->begin(); - child_it != getChildList()->end(); - ++child_it) //loop floaters - { - // Examine minimized children. - LLFloater* floater = dynamic_cast<LLFloater*>(*child_it); - if(floater->isMinimized()) - { - LLRect r = floater->getRect(); - if((r.mBottom < (row + floater_header_size)) - && (r.mBottom > (row - floater_header_size)) - && (r.mLeft < (col + minimized_width)) - && (r.mLeft > (col - minimized_width))) - { - // needs the check for off grid. can't drag, - // but window resize makes them off - foundGap = FALSE; - break; - } - } - } //done floaters - if(foundGap) - { - *left = col; - *bottom = row; - return; //done - } - } //done this col - } - - // crude - stack'em all at 0,0 when screen is full of minimized - // floaters. - *left = snap_rect_local.mLeft; - *bottom = snap_rect_local.mBottom; + const LLFloater::Params& default_params = LLFloater::getDefaultParams(); + S32 floater_header_size = default_params.header_height; + static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0); + LLRect snap_rect_local = getLocalSnapRect(); + snap_rect_local.mTop += mMinimizePositionVOffset; + for(S32 col = snap_rect_local.mLeft; + col < snap_rect_local.getWidth() - minimized_width; + col += minimized_width) + { + for(S32 row = snap_rect_local.mTop - floater_header_size; + row > floater_header_size; + row -= floater_header_size ) //loop rows + { + + bool foundGap = TRUE; + for(child_list_const_iter_t child_it = getChildList()->begin(); + child_it != getChildList()->end(); + ++child_it) //loop floaters + { + // Examine minimized children. + LLFloater* floater = dynamic_cast<LLFloater*>(*child_it); + if(floater->isMinimized()) + { + LLRect r = floater->getRect(); + if((r.mBottom < (row + floater_header_size)) + && (r.mBottom > (row - floater_header_size)) + && (r.mLeft < (col + minimized_width)) + && (r.mLeft > (col - minimized_width))) + { + // needs the check for off grid. can't drag, + // but window resize makes them off + foundGap = FALSE; + break; + } + } + } //done floaters + if(foundGap) + { + *left = col; + *bottom = row; + return; //done + } + } //done this col + } + + // crude - stack'em all at 0,0 when screen is full of minimized + // floaters. + *left = snap_rect_local.mLeft; + *bottom = snap_rect_local.mBottom; } void LLFloaterView::destroyAllChildren() { - LLView::deleteAllChildren(); + LLView::deleteAllChildren(); } void LLFloaterView::closeAllChildren(bool app_quitting) { - // iterate over a copy of the list, because closing windows will destroy - // some windows on the list. - child_list_t child_list = *(getChildList()); - - for (child_list_const_iter_t it = child_list.begin(); it != child_list.end(); ++it) - { - LLView* viewp = *it; - child_list_const_iter_t exists = std::find(getChildList()->begin(), getChildList()->end(), viewp); - if (exists == getChildList()->end()) - { - // this floater has already been removed - continue; - } - - LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp); - - // Attempt to close floater. This will cause the "do you want to save" - // dialogs to appear. - // Skip invisible floaters if we're not quitting (STORM-192). - if (floaterp->canClose() && !floaterp->isDead() && - (app_quitting || floaterp->getVisible())) - { - floaterp->closeFloater(app_quitting); - } - } + // iterate over a copy of the list, because closing windows will destroy + // some windows on the list. + child_list_t child_list = *(getChildList()); + + for (child_list_const_iter_t it = child_list.begin(); it != child_list.end(); ++it) + { + LLView* viewp = *it; + child_list_const_iter_t exists = std::find(getChildList()->begin(), getChildList()->end(), viewp); + if (exists == getChildList()->end()) + { + // this floater has already been removed + continue; + } + + LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp); + + // Attempt to close floater. This will cause the "do you want to save" + // dialogs to appear. + // Skip invisible floaters if we're not quitting (STORM-192). + if (floaterp->canClose() && !floaterp->isDead() && + (app_quitting || floaterp->getVisible())) + { + floaterp->closeFloater(app_quitting); + } + } } void LLFloaterView::hiddenFloaterClosed(LLFloater* floater) { - for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end(); - it != end_it; - ++it) - { - if (it->first.get() == floater) - { - it->second.disconnect(); - mHiddenFloaters.erase(it); - break; - } - } + for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end(); + it != end_it; + ++it) + { + if (it->first.get() == floater) + { + it->second.disconnect(); + mHiddenFloaters.erase(it); + break; + } + } } void LLFloaterView::hideAllFloaters() { - child_list_t child_list = *(getChildList()); + child_list_t child_list = *(getChildList()); - for (child_list_iter_t it = child_list.begin(); it != child_list.end(); ++it) - { - LLFloater* floaterp = dynamic_cast<LLFloater*>(*it); - if (floaterp && floaterp->getVisible()) - { - floaterp->setVisible(false); - boost::signals2::connection connection = floaterp->mCloseSignal.connect(boost::bind(&LLFloaterView::hiddenFloaterClosed, this, floaterp)); - mHiddenFloaters.push_back(std::make_pair(floaterp->getHandle(), connection)); - } - } + for (child_list_iter_t it = child_list.begin(); it != child_list.end(); ++it) + { + LLFloater* floaterp = dynamic_cast<LLFloater*>(*it); + if (floaterp && floaterp->getVisible()) + { + floaterp->setVisible(false); + boost::signals2::connection connection = floaterp->mCloseSignal.connect(boost::bind(&LLFloaterView::hiddenFloaterClosed, this, floaterp)); + mHiddenFloaters.push_back(std::make_pair(floaterp->getHandle(), connection)); + } + } } void LLFloaterView::showHiddenFloaters() { - for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end(); - it != end_it; - ++it) - { - LLFloater* floaterp = it->first.get(); - if (floaterp) - { - floaterp->setVisible(true); - } - it->second.disconnect(); - } - mHiddenFloaters.clear(); + for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end(); + it != end_it; + ++it) + { + LLFloater* floaterp = it->first.get(); + if (floaterp) + { + floaterp->setVisible(true); + } + it->second.disconnect(); + } + mHiddenFloaters.clear(); } BOOL LLFloaterView::allChildrenClosed() { - // see if there are any visible floaters (some floaters "close" - // by setting themselves invisible) - for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it) - { - LLFloater* floaterp = dynamic_cast<LLFloater*>(*it); + // see if there are any visible floaters (some floaters "close" + // by setting themselves invisible) + for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it) + { + LLFloater* floaterp = dynamic_cast<LLFloater*>(*it); - if (floaterp->getVisible() && !floaterp->isDead() && floaterp->isCloseable()) - { - return false; - } - } - return true; + if (floaterp->getVisible() && !floaterp->isDead() && floaterp->isCloseable()) + { + return false; + } + } + return true; } void LLFloaterView::shiftFloaters(S32 x_offset, S32 y_offset) { - for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it) - { - LLFloater* floaterp = dynamic_cast<LLFloater*>(*it); + for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it) + { + LLFloater* floaterp = dynamic_cast<LLFloater*>(*it); - if (floaterp && floaterp->isMinimized()) - { - floaterp->translate(x_offset, y_offset); - } - } + if (floaterp && floaterp->isMinimized()) + { + floaterp->translate(x_offset, y_offset); + } + } } void LLFloaterView::refresh() { - LLRect snap_rect = getSnapRect(); - if (snap_rect != mLastSnapRect) - { - reshape(getRect().getWidth(), getRect().getHeight(), TRUE); - } - - // Constrain children to be entirely on the screen - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it); - if (floaterp && floaterp->getVisible() ) - { - // minimized floaters are kept fully onscreen - adjustToFitScreen(floaterp, !floaterp->isMinimized()); - } - } + LLRect snap_rect = getSnapRect(); + if (snap_rect != mLastSnapRect) + { + reshape(getRect().getWidth(), getRect().getHeight(), TRUE); + } + + // Constrain children to be entirely on the screen + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it); + if (floaterp && floaterp->getVisible() ) + { + // minimized floaters are kept fully onscreen + adjustToFitScreen(floaterp, !floaterp->isMinimized()); + } + } } void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_outside, BOOL snap_in_toolbars/* = false*/) { - if (floater->getParent() != this) - { - // floater is hosted elsewhere, so ignore - return; - } - LLRect::tCoordType screen_width = getSnapRect().getWidth(); - LLRect::tCoordType screen_height = getSnapRect().getHeight(); - - - // only automatically resize non-minimized, resizable floaters - if( floater->isResizable() && !floater->isMinimized() ) - { - LLRect view_rect = floater->getRect(); - S32 old_width = view_rect.getWidth(); - S32 old_height = view_rect.getHeight(); - S32 min_width; - S32 min_height; - floater->getResizeLimits( &min_width, &min_height ); - - // Make sure floater isn't already smaller than its min height/width? - S32 new_width = llmax( min_width, old_width ); - S32 new_height = llmax( min_height, old_height); - - if((new_width > screen_width) || (new_height > screen_height)) - { - // We have to make this window able to fit on screen - new_width = llmin(new_width, screen_width); - new_height = llmin(new_height, screen_height); - - // ...while respecting minimum width/height - new_width = llmax(new_width, min_width); - new_height = llmax(new_height, min_height); - - LLRect new_rect; - new_rect.setLeftTopAndSize(view_rect.mLeft,view_rect.mTop,new_width, new_height); - - floater->setShape(new_rect); - - if (floater->followsRight()) - { - floater->translate(old_width - new_width, 0); - } - - if (floater->followsTop()) - { - floater->translate(0, old_height - new_height); - } - } - } - - const LLRect& floater_rect = floater->getRect(); - - S32 delta_left = mToolbarLeftRect.notEmpty() ? mToolbarLeftRect.mRight - floater_rect.mRight : 0; - S32 delta_bottom = mToolbarBottomRect.notEmpty() ? mToolbarBottomRect.mTop - floater_rect.mTop : 0; - S32 delta_right = mToolbarRightRect.notEmpty() ? mToolbarRightRect.mLeft - floater_rect.mLeft : 0; - - // move window fully onscreen - if (floater->translateIntoRect( snap_in_toolbars ? getSnapRect() : gFloaterView->getRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX )) - { - floater->clearSnapTarget(); - } - else if (delta_left > 0 && floater_rect.mTop < mToolbarLeftRect.mTop && floater_rect.mBottom > mToolbarLeftRect.mBottom) - { - floater->translate(delta_left, 0); - } - else if (delta_bottom > 0 && floater_rect.mLeft > mToolbarBottomRect.mLeft && floater_rect.mRight < mToolbarBottomRect.mRight) - { - floater->translate(0, delta_bottom); - } - else if (delta_right < 0 && floater_rect.mTop < mToolbarRightRect.mTop && floater_rect.mBottom > mToolbarRightRect.mBottom) - { - floater->translate(delta_right, 0); - } + if (floater->getParent() != this) + { + // floater is hosted elsewhere, so ignore + return; + } + LLRect::tCoordType screen_width = getSnapRect().getWidth(); + LLRect::tCoordType screen_height = getSnapRect().getHeight(); + + + // only automatically resize non-minimized, resizable floaters + if( floater->isResizable() && !floater->isMinimized() ) + { + LLRect view_rect = floater->getRect(); + S32 old_width = view_rect.getWidth(); + S32 old_height = view_rect.getHeight(); + S32 min_width; + S32 min_height; + floater->getResizeLimits( &min_width, &min_height ); + + // Make sure floater isn't already smaller than its min height/width? + S32 new_width = llmax( min_width, old_width ); + S32 new_height = llmax( min_height, old_height); + + if((new_width > screen_width) || (new_height > screen_height)) + { + // We have to make this window able to fit on screen + new_width = llmin(new_width, screen_width); + new_height = llmin(new_height, screen_height); + + // ...while respecting minimum width/height + new_width = llmax(new_width, min_width); + new_height = llmax(new_height, min_height); + + LLRect new_rect; + new_rect.setLeftTopAndSize(view_rect.mLeft,view_rect.mTop,new_width, new_height); + + floater->setShape(new_rect); + + if (floater->followsRight()) + { + floater->translate(old_width - new_width, 0); + } + + if (floater->followsTop()) + { + floater->translate(0, old_height - new_height); + } + } + } + + const LLRect& floater_rect = floater->getRect(); + + S32 delta_left = mToolbarLeftRect.notEmpty() ? mToolbarLeftRect.mRight - floater_rect.mRight : 0; + S32 delta_bottom = mToolbarBottomRect.notEmpty() ? mToolbarBottomRect.mTop - floater_rect.mTop : 0; + S32 delta_right = mToolbarRightRect.notEmpty() ? mToolbarRightRect.mLeft - floater_rect.mLeft : 0; + + // move window fully onscreen + if (floater->translateIntoRect( snap_in_toolbars ? getSnapRect() : gFloaterView->getRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX )) + { + floater->clearSnapTarget(); + } + else if (delta_left > 0 && floater_rect.mTop < mToolbarLeftRect.mTop && floater_rect.mBottom > mToolbarLeftRect.mBottom) + { + floater->translate(delta_left, 0); + } + else if (delta_bottom > 0 && floater_rect.mLeft > mToolbarBottomRect.mLeft && floater_rect.mRight < mToolbarBottomRect.mRight) + { + floater->translate(0, delta_bottom); + } + else if (delta_right < 0 && floater_rect.mTop < mToolbarRightRect.mTop && floater_rect.mBottom > mToolbarRightRect.mBottom) + { + floater->translate(delta_right, 0); + } } void LLFloaterView::draw() { - refresh(); + refresh(); - // hide focused floater if in cycle mode, so that it can be drawn on top - LLFloater* focused_floater = getFocusedFloater(); + // hide focused floater if in cycle mode, so that it can be drawn on top + LLFloater* focused_floater = getFocusedFloater(); - if (mFocusCycleMode && focused_floater) - { - child_list_const_iter_t child_it = getChildList()->begin(); - for (;child_it != getChildList()->end(); ++child_it) - { - if ((*child_it) != focused_floater) - { - drawChild(*child_it); - } - } + if (mFocusCycleMode && focused_floater) + { + child_list_const_iter_t child_it = getChildList()->begin(); + for (;child_it != getChildList()->end(); ++child_it) + { + if ((*child_it) != focused_floater) + { + drawChild(*child_it); + } + } - drawChild(focused_floater, -TABBED_FLOATER_OFFSET, TABBED_FLOATER_OFFSET); - } - else - { - LLView::draw(); - } + drawChild(focused_floater, -TABBED_FLOATER_OFFSET, TABBED_FLOATER_OFFSET); + } + else + { + LLView::draw(); + } } LLRect LLFloaterView::getSnapRect() const { - LLRect snap_rect = getLocalRect(); + LLRect snap_rect = getLocalRect(); - LLView* snap_view = mSnapView.get(); - if (snap_view) - { - snap_view->localRectToOtherView(snap_view->getLocalRect(), &snap_rect, this); - } + LLView* snap_view = mSnapView.get(); + if (snap_view) + { + snap_view->localRectToOtherView(snap_view->getLocalRect(), &snap_rect, this); + } - return snap_rect; + return snap_rect; } LLFloater *LLFloaterView::getFocusedFloater() const { - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - if ((*child_it)->isCtrl()) - { - LLFloater* ctrlp = dynamic_cast<LLFloater*>(*child_it); - if ( ctrlp && ctrlp->hasFocus() ) - { - return ctrlp; - } - } - } - return NULL; + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + if ((*child_it)->isCtrl()) + { + LLFloater* ctrlp = dynamic_cast<LLFloater*>(*child_it); + if ( ctrlp && ctrlp->hasFocus() ) + { + return ctrlp; + } + } + } + return NULL; } LLFloater *LLFloaterView::getFrontmost() const { - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLView* viewp = *child_it; - if ( viewp->getVisible() && !viewp->isDead()) - { - return (LLFloater *)viewp; - } - } - return NULL; + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + LLView* viewp = *child_it; + if ( viewp->getVisible() && !viewp->isDead()) + { + return (LLFloater *)viewp; + } + } + return NULL; } LLFloater *LLFloaterView::getBackmost() const { - LLFloater* back_most = NULL; - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLView* viewp = *child_it; - if ( viewp->getVisible() ) - { - back_most = (LLFloater *)viewp; - } - } - return back_most; + LLFloater* back_most = NULL; + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + LLView* viewp = *child_it; + if ( viewp->getVisible() ) + { + back_most = (LLFloater *)viewp; + } + } + return back_most; } void LLFloaterView::syncFloaterTabOrder() { - // look for a visible modal dialog, starting from first - LLModalDialog* modal_dialog = NULL; - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLModalDialog* dialog = dynamic_cast<LLModalDialog*>(*child_it); - if (dialog && dialog->isModal() && dialog->getVisible()) - { - modal_dialog = dialog; - break; - } - } - - if (modal_dialog) - { - // If we have a visible modal dialog, make sure that it has focus - LLUI::addPopup(modal_dialog); - - if( !gFocusMgr.childHasKeyboardFocus( modal_dialog ) ) - { - modal_dialog->setFocus(TRUE); - } - - if( !gFocusMgr.childHasMouseCapture( modal_dialog ) ) - { - gFocusMgr.setMouseCapture( modal_dialog ); - } - } - else - { - // otherwise, make sure the focused floater is in the front of the child list - for ( child_list_const_reverse_iter_t child_it = getChildList()->rbegin(); child_it != getChildList()->rend(); ++child_it) - { - LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it); - if (gFocusMgr.childHasKeyboardFocus(floaterp)) - { - bringToFront(floaterp, FALSE); - break; - } - } - } -} - -LLFloater* LLFloaterView::getParentFloater(LLView* viewp) const -{ - LLView* parentp = viewp->getParent(); - - while(parentp && parentp != this) - { - viewp = parentp; - parentp = parentp->getParent(); - } - - if (parentp == this) - { - return dynamic_cast<LLFloater*>(viewp); - } - - return NULL; + // look for a visible modal dialog, starting from first + LLModalDialog* modal_dialog = NULL; + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + LLModalDialog* dialog = dynamic_cast<LLModalDialog*>(*child_it); + if (dialog && dialog->isModal() && dialog->getVisible()) + { + modal_dialog = dialog; + break; + } + } + + if (modal_dialog) + { + // If we have a visible modal dialog, make sure that it has focus + LLUI::addPopup(modal_dialog); + + if( !gFocusMgr.childHasKeyboardFocus( modal_dialog ) ) + { + modal_dialog->setFocus(TRUE); + } + + if( !gFocusMgr.childHasMouseCapture( modal_dialog ) ) + { + gFocusMgr.setMouseCapture( modal_dialog ); + } + } + else + { + // otherwise, make sure the focused floater is in the front of the child list + for ( child_list_const_reverse_iter_t child_it = getChildList()->rbegin(); child_it != getChildList()->rend(); ++child_it) + { + LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it); + if (gFocusMgr.childHasKeyboardFocus(floaterp)) + { + bringToFront(floaterp, FALSE); + break; + } + } + } +} + +LLFloater* LLFloaterView::getParentFloater(LLView* viewp) const +{ + LLView* parentp = viewp->getParent(); + + while(parentp && parentp != this) + { + viewp = parentp; + parentp = parentp->getParent(); + } + + if (parentp == this) + { + return dynamic_cast<LLFloater*>(viewp); + } + + return NULL; } S32 LLFloaterView::getZOrder(LLFloater* child) { - S32 rv = 0; - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLView* viewp = *child_it; - if(viewp == child) - { - break; - } - ++rv; - } - return rv; + S32 rv = 0; + for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + LLView* viewp = *child_it; + if(viewp == child) + { + break; + } + ++rv; + } + return rv; } void LLFloaterView::pushVisibleAll(BOOL visible, const skip_list_t& skip_list) { - for (child_list_const_iter_t child_iter = getChildList()->begin(); - child_iter != getChildList()->end(); ++child_iter) - { - LLView *view = *child_iter; - if (skip_list.find(view) == skip_list.end()) - { - view->pushVisible(visible); - } - } + for (child_list_const_iter_t child_iter = getChildList()->begin(); + child_iter != getChildList()->end(); ++child_iter) + { + LLView *view = *child_iter; + if (skip_list.find(view) == skip_list.end()) + { + view->pushVisible(visible); + } + } - LLFloaterReg::blockShowFloaters(true); + LLFloaterReg::blockShowFloaters(true); } void LLFloaterView::popVisibleAll(const skip_list_t& skip_list) { - // make a copy of the list since some floaters change their - // order in the childList when changing visibility. - child_list_t child_list_copy = *getChildList(); + // make a copy of the list since some floaters change their + // order in the childList when changing visibility. + child_list_t child_list_copy = *getChildList(); - for (child_list_const_iter_t child_iter = child_list_copy.begin(); - child_iter != child_list_copy.end(); ++child_iter) - { - LLView *view = *child_iter; - if (skip_list.find(view) == skip_list.end()) - { - view->popVisible(); - } - } + for (child_list_const_iter_t child_iter = child_list_copy.begin(); + child_iter != child_list_copy.end(); ++child_iter) + { + LLView *view = *child_iter; + if (skip_list.find(view) == skip_list.end()) + { + view->popVisible(); + } + } - LLFloaterReg::blockShowFloaters(false); + LLFloaterReg::blockShowFloaters(false); } void LLFloaterView::setToolbarRect(LLToolBarEnums::EToolBarLocation tb, const LLRect& toolbar_rect) { - switch (tb) - { - case LLToolBarEnums::TOOLBAR_LEFT: - mToolbarLeftRect = toolbar_rect; - break; - case LLToolBarEnums::TOOLBAR_BOTTOM: - mToolbarBottomRect = toolbar_rect; - break; - case LLToolBarEnums::TOOLBAR_RIGHT: - mToolbarRightRect = toolbar_rect; - break; - default: - LL_WARNS() << "setToolbarRect() passed odd toolbar number " << (S32) tb << LL_ENDL; - break; - } + switch (tb) + { + case LLToolBarEnums::TOOLBAR_LEFT: + mToolbarLeftRect = toolbar_rect; + break; + case LLToolBarEnums::TOOLBAR_BOTTOM: + mToolbarBottomRect = toolbar_rect; + break; + case LLToolBarEnums::TOOLBAR_RIGHT: + mToolbarRightRect = toolbar_rect; + break; + default: + LL_WARNS() << "setToolbarRect() passed odd toolbar number " << (S32) tb << LL_ENDL; + break; + } } void LLFloater::setInstanceName(const std::string& name) { - if (name != mInstanceName) - { - llassert_always(mInstanceName.empty()); - mInstanceName = name; - if (!mInstanceName.empty()) - { - std::string ctrl_name = getControlName(mInstanceName, mKey); - initRectControl(); - if (!mVisibilityControl.empty()) - { - mVisibilityControl = LLFloaterReg::declareVisibilityControl(ctrl_name); - } - if(!mDocStateControl.empty()) - { - mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name); - } - } + if (name != mInstanceName) + { + llassert_always(mInstanceName.empty()); + mInstanceName = name; + if (!mInstanceName.empty()) + { + std::string ctrl_name = getControlName(mInstanceName, mKey); + initRectControl(); + if (!mVisibilityControl.empty()) + { + mVisibilityControl = LLFloaterReg::declareVisibilityControl(ctrl_name); + } + if(!mDocStateControl.empty()) + { + mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name); + } + } } } void LLFloater::setKey(const LLSD& newkey) { - // Note: We don't have to do anything special with registration when we change keys - mKey = newkey; + // Note: We don't have to do anything special with registration when we change keys + mKey = newkey; } //static void LLFloater::setupParamsForExport(Params& p, LLView* parent) { - // Do rectangle munging to topleft layout first - LLPanel::setupParamsForExport(p, parent); + // Do rectangle munging to topleft layout first + LLPanel::setupParamsForExport(p, parent); - // Copy the rectangle out to apply layout constraints - LLRect rect = p.rect; + // Copy the rectangle out to apply layout constraints + LLRect rect = p.rect; - // Null out other settings - p.rect.left.setProvided(false); - p.rect.top.setProvided(false); - p.rect.right.setProvided(false); - p.rect.bottom.setProvided(false); + // Null out other settings + p.rect.left.setProvided(false); + p.rect.top.setProvided(false); + p.rect.right.setProvided(false); + p.rect.bottom.setProvided(false); - // Explicitly set width/height - p.rect.width.set( rect.getWidth(), true ); - p.rect.height.set( rect.getHeight(), true ); + // Explicitly set width/height + p.rect.width.set( rect.getWidth(), true ); + p.rect.height.set( rect.getHeight(), true ); - // If you can't resize this floater, don't export min_height - // and min_width - bool can_resize = p.can_resize; - if (!can_resize) - { - p.min_height.setProvided(false); - p.min_width.setProvided(false); - } + // If you can't resize this floater, don't export min_height + // and min_width + bool can_resize = p.can_resize; + if (!can_resize) + { + p.min_height.setProvided(false); + p.min_width.setProvided(false); + } } void LLFloater::initFromParams(const LLFloater::Params& p) { - // *NOTE: We have too many classes derived from LLFloater to retrofit them - // all to pass in params via constructors. So we use this method. - - // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible - LLPanel::initFromParams(p); - - // override any follows flags - if (mPositioning != LLFloaterEnums::POSITIONING_SPECIFIED) - { - setFollows(FOLLOWS_NONE); - } - - mTitle = p.title; - mShortTitle = p.short_title; - applyTitle(); - - setCanTearOff(p.can_tear_off); - setCanMinimize(p.can_minimize); - setCanClose(p.can_close); - setCanDock(p.can_dock); - setCanResize(p.can_resize); - setResizeLimits(p.min_width, p.min_height); - - mDragOnLeft = p.can_drag_on_left; - mHeaderHeight = p.header_height; - mLegacyHeaderHeight = p.legacy_header_height; - mSingleInstance = p.single_instance; - mReuseInstance = p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance; - - mPositioning = p.positioning; - - mSaveRect = p.save_rect; - if (p.save_visibility) - { - mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set - } - if(p.save_dock_state) - { - mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set - } - - // open callback - if (p.open_callback.isProvided()) - { - setOpenCallback(initCommitCallback(p.open_callback)); - } - // close callback - if (p.close_callback.isProvided()) - { - setCloseCallback(initCommitCallback(p.close_callback)); - } - - if (mDragHandle) - { - mDragHandle->setTitleVisible(p.show_title); - } + // *NOTE: We have too many classes derived from LLFloater to retrofit them + // all to pass in params via constructors. So we use this method. + + // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible + LLPanel::initFromParams(p); + + // override any follows flags + if (mPositioning != LLFloaterEnums::POSITIONING_SPECIFIED) + { + setFollows(FOLLOWS_NONE); + } + + mTitle = p.title; + mShortTitle = p.short_title; + applyTitle(); + + setCanTearOff(p.can_tear_off); + setCanMinimize(p.can_minimize); + setCanClose(p.can_close); + setCanDock(p.can_dock); + setCanResize(p.can_resize); + setResizeLimits(p.min_width, p.min_height); + + mDragOnLeft = p.can_drag_on_left; + mHeaderHeight = p.header_height; + mLegacyHeaderHeight = p.legacy_header_height; + mSingleInstance = p.single_instance; + mReuseInstance = p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance; + + mPositioning = p.positioning; + + mSaveRect = p.save_rect; + if (p.save_visibility) + { + mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set + } + if(p.save_dock_state) + { + mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set + } + + // open callback + if (p.open_callback.isProvided()) + { + setOpenCallback(initCommitCallback(p.open_callback)); + } + // close callback + if (p.close_callback.isProvided()) + { + setCloseCallback(initCommitCallback(p.close_callback)); + } + + if (mDragHandle) + { + mDragHandle->setTitleVisible(p.show_title); + } } boost::signals2::connection LLFloater::setMinimizeCallback( const commit_signal_t::slot_type& cb ) { - if (!mMinimizeSignal) mMinimizeSignal = new commit_signal_t(); - return mMinimizeSignal->connect(cb); + if (!mMinimizeSignal) mMinimizeSignal = new commit_signal_t(); + return mMinimizeSignal->connect(cb); } boost::signals2::connection LLFloater::setOpenCallback( const commit_signal_t::slot_type& cb ) { - return mOpenSignal.connect(cb); + return mOpenSignal.connect(cb); } boost::signals2::connection LLFloater::setCloseCallback( const commit_signal_t::slot_type& cb ) { - return mCloseSignal.connect(cb); + return mCloseSignal.connect(cb); } LLTrace::BlockTimerStatHandle POST_BUILD("Floater Post Build"); @@ -3181,127 +3181,127 @@ static LLTrace::BlockTimerStatHandle FTM_EXTERNAL_FLOATER_LOAD("Load Extern Floa bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node) { - Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>()); - Params params(default_params); - - LLXUIParser parser; - parser.readXUI(node, params, filename); // *TODO: Error checking - - std::string xml_filename = params.filename; - - if (!xml_filename.empty()) - { - LLXMLNodePtr referenced_xml; - - if (output_node) - { - //if we are exporting, we want to export the current xml - //not the referenced xml - Params output_params; - parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName()); - setupParamsForExport(output_params, parent); - output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); - return TRUE; - } - - LLUICtrlFactory::instance().pushFileName(xml_filename); - - LL_RECORD_BLOCK_TIME(FTM_EXTERNAL_FLOATER_LOAD); - if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml)) - { - LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL; - - return FALSE; - } - - Params referenced_params; - parser.readXUI(referenced_xml, referenced_params, LLUICtrlFactory::getInstance()->getCurFileName()); - params.fillFrom(referenced_params); - - // add children using dimensions from referenced xml for consistent layout - setShape(params.rect); - LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance()); - - LLUICtrlFactory::instance().popFileName(); - } - - - if (output_node) - { - Params output_params(params); - setupParamsForExport(output_params, parent); - output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); - } - - // Default floater position to top-left corner of screen - // However, some legacy floaters have explicit top or bottom - // coordinates set, so respect their wishes. - if (!params.rect.top.isProvided() && !params.rect.bottom.isProvided()) - { - params.rect.top.set(0); - } - if (!params.rect.left.isProvided() && !params.rect.right.isProvided()) - { - params.rect.left.set(0); - } - params.from_xui = true; - applyXUILayout(params, parent, parent == gFloaterView ? gFloaterView->getSnapRect() : parent->getLocalRect()); - initFromParams(params); - - initFloater(params); - - LLMultiFloater* last_host = LLFloater::getFloaterHost(); - if (node->hasName("multi_floater")) - { - LLFloater::setFloaterHost((LLMultiFloater*) this); - } - - LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node); - - if (node->hasName("multi_floater")) - { - LLFloater::setFloaterHost(last_host); - } - - // HACK: When we changed the header height to 25 pixels in Viewer 2, rather - // than re-layout all the floaters we use this value in pixels to make the - // whole floater bigger and change the top-left coordinate for widgets. - // The goal is to eventually set mLegacyHeaderHeight to zero, which would - // make the top-left corner for widget layout the same as the top-left - // corner of the window's content area. James - S32 header_stretch = (mHeaderHeight - mLegacyHeaderHeight); - if (header_stretch > 0) - { - // Stretch the floater vertically, don't move widgets - LLRect rect = getRect(); - rect.mTop += header_stretch; - - // This will also update drag handle, title bar, close box, etc. - setRect(rect); - } - - BOOL result; - { - LL_RECORD_BLOCK_TIME(POST_BUILD); - - result = postBuild(); - } - - if (!result) - { - LL_ERRS() << "Failed to construct floater " << getName() << LL_ENDL; - } - - applyRectControl(); // If we have a saved rect control, apply it - gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen - - moveResizeHandlesToFront(); - - applyDockState(); - - return true; // *TODO: Error checking + Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>()); + Params params(default_params); + + LLXUIParser parser; + parser.readXUI(node, params, filename); // *TODO: Error checking + + std::string xml_filename = params.filename; + + if (!xml_filename.empty()) + { + LLXMLNodePtr referenced_xml; + + if (output_node) + { + //if we are exporting, we want to export the current xml + //not the referenced xml + Params output_params; + parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName()); + setupParamsForExport(output_params, parent); + output_node->setName(node->getName()->mString); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); + return TRUE; + } + + LLUICtrlFactory::instance().pushFileName(xml_filename); + + LL_RECORD_BLOCK_TIME(FTM_EXTERNAL_FLOATER_LOAD); + if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml)) + { + LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL; + + return FALSE; + } + + Params referenced_params; + parser.readXUI(referenced_xml, referenced_params, LLUICtrlFactory::getInstance()->getCurFileName()); + params.fillFrom(referenced_params); + + // add children using dimensions from referenced xml for consistent layout + setShape(params.rect); + LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance()); + + LLUICtrlFactory::instance().popFileName(); + } + + + if (output_node) + { + Params output_params(params); + setupParamsForExport(output_params, parent); + output_node->setName(node->getName()->mString); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); + } + + // Default floater position to top-left corner of screen + // However, some legacy floaters have explicit top or bottom + // coordinates set, so respect their wishes. + if (!params.rect.top.isProvided() && !params.rect.bottom.isProvided()) + { + params.rect.top.set(0); + } + if (!params.rect.left.isProvided() && !params.rect.right.isProvided()) + { + params.rect.left.set(0); + } + params.from_xui = true; + applyXUILayout(params, parent, parent == gFloaterView ? gFloaterView->getSnapRect() : parent->getLocalRect()); + initFromParams(params); + + initFloater(params); + + LLMultiFloater* last_host = LLFloater::getFloaterHost(); + if (node->hasName("multi_floater")) + { + LLFloater::setFloaterHost((LLMultiFloater*) this); + } + + LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node); + + if (node->hasName("multi_floater")) + { + LLFloater::setFloaterHost(last_host); + } + + // HACK: When we changed the header height to 25 pixels in Viewer 2, rather + // than re-layout all the floaters we use this value in pixels to make the + // whole floater bigger and change the top-left coordinate for widgets. + // The goal is to eventually set mLegacyHeaderHeight to zero, which would + // make the top-left corner for widget layout the same as the top-left + // corner of the window's content area. James + S32 header_stretch = (mHeaderHeight - mLegacyHeaderHeight); + if (header_stretch > 0) + { + // Stretch the floater vertically, don't move widgets + LLRect rect = getRect(); + rect.mTop += header_stretch; + + // This will also update drag handle, title bar, close box, etc. + setRect(rect); + } + + BOOL result; + { + LL_RECORD_BLOCK_TIME(POST_BUILD); + + result = postBuild(); + } + + if (!result) + { + LL_ERRS() << "Failed to construct floater " << getName() << LL_ENDL; + } + + applyRectControl(); // If we have a saved rect control, apply it + gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen + + moveResizeHandlesToFront(); + + applyDockState(); + + return true; // *TODO: Error checking } bool LLFloater::isShown() const @@ -3311,7 +3311,7 @@ bool LLFloater::isShown() const bool LLFloater::isDetachedAndNotMinimized() { - return !getHost() && !isMinimized(); + return !getHost() && !isMinimized(); } /* static */ @@ -3336,205 +3336,205 @@ static LLTrace::BlockTimerStatHandle FTM_BUILD_FLOATERS("Build Floaters"); bool LLFloater::buildFromFile(const std::string& filename) { - LL_RECORD_BLOCK_TIME(FTM_BUILD_FLOATERS); - LLXMLNodePtr root; - - if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) - { - LL_WARNS() << "Couldn't find (or parse) floater from: " << filename << LL_ENDL; - return false; - } - - // root must be called floater - if( !(root->hasName("floater") || root->hasName("multi_floater")) ) - { - LL_WARNS() << "Root node should be named floater in: " << filename << LL_ENDL; - return false; - } - - bool res = true; - - LL_DEBUGS() << "Building floater " << filename << LL_ENDL; - LLUICtrlFactory::instance().pushFileName(filename); - { - if (!getFactoryMap().empty()) - { - LLPanel::sFactoryStack.push_front(&getFactoryMap()); - } - - // for local registry callbacks; define in constructor, referenced in XUI or postBuild - getCommitCallbackRegistrar().pushScope(); - getEnableCallbackRegistrar().pushScope(); - - res = initFloaterXML(root, getParent(), filename, NULL); - - setXMLFilename(filename); - - getCommitCallbackRegistrar().popScope(); - getEnableCallbackRegistrar().popScope(); - - if (!getFactoryMap().empty()) - { - LLPanel::sFactoryStack.pop_front(); - } - } - LLUICtrlFactory::instance().popFileName(); - - return res; + LL_RECORD_BLOCK_TIME(FTM_BUILD_FLOATERS); + LLXMLNodePtr root; + + if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) + { + LL_WARNS() << "Couldn't find (or parse) floater from: " << filename << LL_ENDL; + return false; + } + + // root must be called floater + if( !(root->hasName("floater") || root->hasName("multi_floater")) ) + { + LL_WARNS() << "Root node should be named floater in: " << filename << LL_ENDL; + return false; + } + + bool res = true; + + LL_DEBUGS() << "Building floater " << filename << LL_ENDL; + LLUICtrlFactory::instance().pushFileName(filename); + { + if (!getFactoryMap().empty()) + { + LLPanel::sFactoryStack.push_front(&getFactoryMap()); + } + + // for local registry callbacks; define in constructor, referenced in XUI or postBuild + getCommitCallbackRegistrar().pushScope(); + getEnableCallbackRegistrar().pushScope(); + + res = initFloaterXML(root, getParent(), filename, NULL); + + setXMLFilename(filename); + + getCommitCallbackRegistrar().popScope(); + getEnableCallbackRegistrar().popScope(); + + if (!getFactoryMap().empty()) + { + LLPanel::sFactoryStack.pop_front(); + } + } + LLUICtrlFactory::instance().popFileName(); + + return res; } void LLFloater::stackWith(LLFloater& other) { - static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16); + static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16); - LLRect next_rect; - if (other.getHost()) - { - next_rect = other.getHost()->getRect(); - } - else - { - next_rect = other.getRect(); - } - next_rect.translate(floater_offset, -floater_offset); + LLRect next_rect; + if (other.getHost()) + { + next_rect = other.getHost()->getRect(); + } + else + { + next_rect = other.getRect(); + } + next_rect.translate(floater_offset, -floater_offset); - next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight()); - - setShape(next_rect); + next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight()); + + setShape(next_rect); - if (!other.getHost()) - { - other.mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP; - other.setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); - } + if (!other.getHost()) + { + other.mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP; + other.setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); + } } void LLFloater::applyRelativePosition() { - LLRect snap_rect = gFloaterView->getSnapRect(); - LLRect floater_view_screen_rect = gFloaterView->calcScreenRect(); - snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom); - LLRect floater_screen_rect = calcScreenRect(); + LLRect snap_rect = gFloaterView->getSnapRect(); + LLRect floater_view_screen_rect = gFloaterView->calcScreenRect(); + snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom); + LLRect floater_screen_rect = calcScreenRect(); - LLCoordGL new_center = mPosition.convert(); - LLCoordGL cur_center(floater_screen_rect.getCenterX(), floater_screen_rect.getCenterY()); - translate(new_center.mX - cur_center.mX, new_center.mY - cur_center.mY); + LLCoordGL new_center = mPosition.convert(); + LLCoordGL cur_center(floater_screen_rect.getCenterX(), floater_screen_rect.getCenterY()); + translate(new_center.mX - cur_center.mX, new_center.mY - cur_center.mY); } LLCoordFloater::LLCoordFloater(F32 x, F32 y, LLFloater& floater) -: coord_t((S32)x, (S32)y) +: coord_t((S32)x, (S32)y) { - mFloater = floater.getHandle(); + mFloater = floater.getHandle(); } LLCoordFloater::LLCoordFloater(const LLCoordCommon& other, LLFloater& floater) { - mFloater = floater.getHandle(); - convertFromCommon(other); + mFloater = floater.getHandle(); + convertFromCommon(other); } LLCoordFloater& LLCoordFloater::operator=(const LLCoordFloater& other) { - mFloater = other.mFloater; - coord_t::operator =(other); - return *this; + mFloater = other.mFloater; + coord_t::operator =(other); + return *this; } void LLCoordFloater::setFloater(LLFloater& floater) { - mFloater = floater.getHandle(); + mFloater = floater.getHandle(); } bool LLCoordFloater::operator==(const LLCoordFloater& other) const { - return mX == other.mX && mY == other.mY && mFloater == other.mFloater; + return mX == other.mX && mY == other.mY && mFloater == other.mFloater; } LLCoordCommon LL_COORD_FLOATER::convertToCommon() const { - const LLCoordFloater& self = static_cast<const LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this)); - - LLRect snap_rect = gFloaterView->getSnapRect(); - LLRect floater_view_screen_rect = gFloaterView->calcScreenRect(); - snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom); - - LLFloater* floaterp = mFloater.get(); - S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0; - S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0; - LLCoordCommon out; - if (self.mX < -0.5f) - { - out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft)); - } - else if (self.mX > 0.5f) - { - out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS)); - } - else - { - out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width)); - } - - if (self.mY < -0.5f) - { - out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom)); - } - else if (self.mY > 0.5f) - { - out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS)); - } - else - { - out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height)); - } - - // return center point instead of lower left - out.mX += floater_width / 2; - out.mY += floater_height / 2; - - return out; + const LLCoordFloater& self = static_cast<const LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this)); + + LLRect snap_rect = gFloaterView->getSnapRect(); + LLRect floater_view_screen_rect = gFloaterView->calcScreenRect(); + snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom); + + LLFloater* floaterp = mFloater.get(); + S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0; + S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0; + LLCoordCommon out; + if (self.mX < -0.5f) + { + out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft)); + } + else if (self.mX > 0.5f) + { + out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS)); + } + else + { + out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width)); + } + + if (self.mY < -0.5f) + { + out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom)); + } + else if (self.mY > 0.5f) + { + out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS)); + } + else + { + out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height)); + } + + // return center point instead of lower left + out.mX += floater_width / 2; + out.mY += floater_height / 2; + + return out; } void LL_COORD_FLOATER::convertFromCommon(const LLCoordCommon& from) { - LLCoordFloater& self = static_cast<LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this)); - LLRect snap_rect = gFloaterView->getSnapRect(); - LLRect floater_view_screen_rect = gFloaterView->calcScreenRect(); - snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom); - - - LLFloater* floaterp = mFloater.get(); - S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0; - S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0; - - S32 from_x = from.mX - floater_width / 2; - S32 from_y = from.mY - floater_height / 2; - - if (from_x < snap_rect.mLeft) - { - self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f); - } - else if (from_x + floater_width > snap_rect.mRight) - { - self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f); - } - else - { - self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f); - } - - if (from_y < snap_rect.mBottom) - { - self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f); - } - else if (from_y + floater_height > snap_rect.mTop) - { - self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f); - } - else - { - self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f); - } + LLCoordFloater& self = static_cast<LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this)); + LLRect snap_rect = gFloaterView->getSnapRect(); + LLRect floater_view_screen_rect = gFloaterView->calcScreenRect(); + snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom); + + + LLFloater* floaterp = mFloater.get(); + S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0; + S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0; + + S32 from_x = from.mX - floater_width / 2; + S32 from_y = from.mY - floater_height / 2; + + if (from_x < snap_rect.mLeft) + { + self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f); + } + else if (from_x + floater_width > snap_rect.mRight) + { + self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f); + } + else + { + self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f); + } + + if (from_y < snap_rect.mBottom) + { + self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f); + } + else if (from_y + floater_height > snap_rect.mTop) + { + self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f); + } + else + { + self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f); + } } diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index e53ecd30c2..1386f1290a 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -36,298 +36,298 @@ #include "llinitparam.h" #include "llview.h" -#include "llviewmodel.h" // *TODO move dependency to .cpp file +#include "llviewmodel.h" // *TODO move dependency to .cpp file const BOOL TAKE_FOCUS_YES = TRUE; const BOOL TAKE_FOCUS_NO = FALSE; class LLUICtrl - : public LLView, public boost::signals2::trackable + : public LLView, public boost::signals2::trackable { public: - typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> commit_callback_t; - typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t; - // *TODO: add xml support for this type of signal in the future - typedef boost::signals2::signal<void (LLUICtrl* ctrl, S32 x, S32 y, MASK mask)> mouse_signal_t; - - typedef boost::function<bool (LLUICtrl* ctrl, const LLSD& param)> enable_callback_t; - typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t; - - struct CallbackParam : public LLInitParam::Block<CallbackParam> - { - Ignored name; - - Optional<std::string> function_name; - Optional<LLSD> parameter; - - Optional<std::string> control_name; - - CallbackParam(); - }; - - struct CommitCallbackParam : public LLInitParam::Block<CommitCallbackParam, CallbackParam > - { - Optional<commit_callback_t> function; - }; - - // also used for visible callbacks - struct EnableCallbackParam : public LLInitParam::Block<EnableCallbackParam, CallbackParam > - { - Optional<enable_callback_t> function; - }; - - struct EnableControls : public LLInitParam::ChoiceBlock<EnableControls> - { - Alternative<std::string> enabled; - Alternative<std::string> disabled; - - EnableControls(); - }; - struct ControlVisibility : public LLInitParam::ChoiceBlock<ControlVisibility> - { - Alternative<std::string> visible; - Alternative<std::string> invisible; - - ControlVisibility(); - }; - struct Params : public LLInitParam::Block<Params, LLView::Params> - { - Optional<std::string> label; - Optional<bool> tab_stop, - chrome, - requests_front; - Optional<LLSD> initial_value; - - Optional<CommitCallbackParam> init_callback, - commit_callback; - Optional<EnableCallbackParam> validate_callback; - - Optional<CommitCallbackParam> mouseenter_callback, - mouseleave_callback; - - Optional<std::string> control_name; - Optional<EnableControls> enabled_controls; - Optional<ControlVisibility> controls_visibility; - - // font params - Optional<const LLFontGL*> font; - Optional<LLFontGL::HAlign> font_halign; - Optional<LLFontGL::VAlign> font_valign; - - // cruft from LLXMLNode implementation - Ignored type, - length; - - Params(); - }; - - enum ETypeTransparency - { - TT_DEFAULT, - TT_ACTIVE, // focused floater - TT_INACTIVE, // other floaters - TT_FADING, // fading toast - }; - /*virtual*/ ~LLUICtrl(); - - void initFromParams(const Params& p); + typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> commit_callback_t; + typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t; + // *TODO: add xml support for this type of signal in the future + typedef boost::signals2::signal<void (LLUICtrl* ctrl, S32 x, S32 y, MASK mask)> mouse_signal_t; + + typedef boost::function<bool (LLUICtrl* ctrl, const LLSD& param)> enable_callback_t; + typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t; + + struct CallbackParam : public LLInitParam::Block<CallbackParam> + { + Ignored name; + + Optional<std::string> function_name; + Optional<LLSD> parameter; + + Optional<std::string> control_name; + + CallbackParam(); + }; + + struct CommitCallbackParam : public LLInitParam::Block<CommitCallbackParam, CallbackParam > + { + Optional<commit_callback_t> function; + }; + + // also used for visible callbacks + struct EnableCallbackParam : public LLInitParam::Block<EnableCallbackParam, CallbackParam > + { + Optional<enable_callback_t> function; + }; + + struct EnableControls : public LLInitParam::ChoiceBlock<EnableControls> + { + Alternative<std::string> enabled; + Alternative<std::string> disabled; + + EnableControls(); + }; + struct ControlVisibility : public LLInitParam::ChoiceBlock<ControlVisibility> + { + Alternative<std::string> visible; + Alternative<std::string> invisible; + + ControlVisibility(); + }; + struct Params : public LLInitParam::Block<Params, LLView::Params> + { + Optional<std::string> label; + Optional<bool> tab_stop, + chrome, + requests_front; + Optional<LLSD> initial_value; + + Optional<CommitCallbackParam> init_callback, + commit_callback; + Optional<EnableCallbackParam> validate_callback; + + Optional<CommitCallbackParam> mouseenter_callback, + mouseleave_callback; + + Optional<std::string> control_name; + Optional<EnableControls> enabled_controls; + Optional<ControlVisibility> controls_visibility; + + // font params + Optional<const LLFontGL*> font; + Optional<LLFontGL::HAlign> font_halign; + Optional<LLFontGL::VAlign> font_valign; + + // cruft from LLXMLNode implementation + Ignored type, + length; + + Params(); + }; + + enum ETypeTransparency + { + TT_DEFAULT, + TT_ACTIVE, // focused floater + TT_INACTIVE, // other floaters + TT_FADING, // fading toast + }; + /*virtual*/ ~LLUICtrl(); + + void initFromParams(const Params& p); protected: - friend class LLUICtrlFactory; - static const Params& getDefaultParams(); - LLUICtrl(const Params& p = getDefaultParams(), + friend class LLUICtrlFactory; + static const Params& getDefaultParams(); + LLUICtrl(const Params& p = getDefaultParams(), const LLViewModelPtr& viewmodel=LLViewModelPtr(new LLViewModel)); - - commit_signal_t::slot_type initCommitCallback(const CommitCallbackParam& cb); - enable_signal_t::slot_type initEnableCallback(const EnableCallbackParam& cb); + + commit_signal_t::slot_type initCommitCallback(const CommitCallbackParam& cb); + enable_signal_t::slot_type initEnableCallback(const EnableCallbackParam& cb); - // We need this virtual so we can override it with derived versions - virtual LLViewModel* getViewModel() const; + // We need this virtual so we can override it with derived versions + virtual LLViewModel* getViewModel() const; // We shouldn't ever need to set this directly //virtual void setViewModel(const LLViewModelPtr&); - virtual BOOL postBuild(); - + virtual BOOL postBuild(); + public: - // LLView interface - /*virtual*/ BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); - /*virtual*/ BOOL isCtrl() const; - /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); - /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL canFocusChildren() const; - /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); - - // From LLFocusableElement - /*virtual*/ void setFocus( BOOL b ); - /*virtual*/ BOOL hasFocus() const; - - // New virtuals - - // Return NULL by default (overrride if the class has the appropriate interface) - virtual class LLCtrlSelectionInterface* getSelectionInterface(); - virtual class LLCtrlListInterface* getListInterface(); - virtual class LLCtrlScrollInterface* getScrollInterface(); - - bool setControlValue(const LLSD& value); - void setControlVariable(LLControlVariable* control); - virtual void setControlName(const std::string& control, LLView *context = NULL); - - LLControlVariable* getControlVariable() { return mControlVariable; } - - void setEnabledControlVariable(LLControlVariable* control); - void setDisabledControlVariable(LLControlVariable* control); - void setMakeVisibleControlVariable(LLControlVariable* control); - void setMakeInvisibleControlVariable(LLControlVariable* control); - - virtual void setTentative(BOOL b); - virtual BOOL getTentative() const; - virtual void setValue(const LLSD& value); - virtual LLSD getValue() const; + // LLView interface + /*virtual*/ BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); + /*virtual*/ BOOL isCtrl() const; + /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); + /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL canFocusChildren() const; + /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); + + // From LLFocusableElement + /*virtual*/ void setFocus( BOOL b ); + /*virtual*/ BOOL hasFocus() const; + + // New virtuals + + // Return NULL by default (overrride if the class has the appropriate interface) + virtual class LLCtrlSelectionInterface* getSelectionInterface(); + virtual class LLCtrlListInterface* getListInterface(); + virtual class LLCtrlScrollInterface* getScrollInterface(); + + bool setControlValue(const LLSD& value); + void setControlVariable(LLControlVariable* control); + virtual void setControlName(const std::string& control, LLView *context = NULL); + + LLControlVariable* getControlVariable() { return mControlVariable; } + + void setEnabledControlVariable(LLControlVariable* control); + void setDisabledControlVariable(LLControlVariable* control); + void setMakeVisibleControlVariable(LLControlVariable* control); + void setMakeInvisibleControlVariable(LLControlVariable* control); + + virtual void setTentative(BOOL b); + virtual BOOL getTentative() const; + virtual void setValue(const LLSD& value); + virtual LLSD getValue() const; /// When two widgets are displaying the same data (e.g. during a skin /// change), share their ViewModel. virtual void shareViewModelFrom(const LLUICtrl& other); - virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); - virtual void setIsChrome(BOOL is_chrome); - - virtual BOOL acceptsTextInput() const; // Defaults to false - - // A control is dirty if the user has modified its value. - // Editable controls should override this. - virtual BOOL isDirty() const; // Defauls to false - virtual void resetDirty(); //Defaults to no-op - - // Call appropriate callback - virtual void onCommit(); - - // Default to no-op: - virtual void onTabInto(); - - // Clear any user-provided input (text in a text editor, checked checkbox, - // selected radio button, etc.). Defaults to no-op. - virtual void clear(); - - virtual void setColor(const LLColor4& color); - - // Ansariel: Changed to virtual. We might want to change the transparency ourself! - virtual F32 getCurrentTransparency(); - - void setTransparencyType(ETypeTransparency type); - ETypeTransparency getTransparencyType() const {return mTransparencyType;} - - BOOL focusNextItem(BOOL text_entry_only); - BOOL focusPrevItem(BOOL text_entry_only); - BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); - - // Non Virtuals - LLHandle<LLUICtrl> getHandle() const { return getDerivedHandle<LLUICtrl>(); } - BOOL getIsChrome() const; - - void setTabStop( BOOL b ); - BOOL hasTabStop() const; - - LLUICtrl* getParentUICtrl() const; - - // return true if help topic found by crawling through parents - - // topic then put in help_topic_out - bool findHelpTopic(std::string& help_topic_out); - - boost::signals2::connection setCommitCallback(const CommitCallbackParam& cb); - boost::signals2::connection setValidateCallback(const EnableCallbackParam& cb); - - boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb ); - boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb ); - - boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb ); - boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb ); - - boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb ); - boost::signals2::connection setMouseUpCallback( const mouse_signal_t::slot_type& cb ); - boost::signals2::connection setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ); - boost::signals2::connection setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ); - - boost::signals2::connection setDoubleClickCallback( const mouse_signal_t::slot_type& cb ); - - // *TODO: Deprecate; for backwards compatability only: - boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data); - boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb ); - - LLUICtrl* findRootMostFocusRoot(); - - class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter> - { - LLSINGLETON_EMPTY_CTOR(LLTextInputFilter); - /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const - { - return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE); - } - }; - - template <typename F, typename DERIVED> class CallbackRegistry : public LLRegistrySingleton<std::string, F, DERIVED > - {}; - - class CommitCallbackRegistry : public CallbackRegistry<commit_callback_t, CommitCallbackRegistry> - { - LLSINGLETON_EMPTY_CTOR(CommitCallbackRegistry); - }; - // the enable callback registry is also used for visiblity callbacks - class EnableCallbackRegistry : public CallbackRegistry<enable_callback_t, EnableCallbackRegistry> - { - LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry); - }; - + virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); + virtual void setIsChrome(BOOL is_chrome); + + virtual BOOL acceptsTextInput() const; // Defaults to false + + // A control is dirty if the user has modified its value. + // Editable controls should override this. + virtual BOOL isDirty() const; // Defauls to false + virtual void resetDirty(); //Defaults to no-op + + // Call appropriate callback + virtual void onCommit(); + + // Default to no-op: + virtual void onTabInto(); + + // Clear any user-provided input (text in a text editor, checked checkbox, + // selected radio button, etc.). Defaults to no-op. + virtual void clear(); + + virtual void setColor(const LLColor4& color); + + // Ansariel: Changed to virtual. We might want to change the transparency ourself! + virtual F32 getCurrentTransparency(); + + void setTransparencyType(ETypeTransparency type); + ETypeTransparency getTransparencyType() const {return mTransparencyType;} + + BOOL focusNextItem(BOOL text_entry_only); + BOOL focusPrevItem(BOOL text_entry_only); + BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); + + // Non Virtuals + LLHandle<LLUICtrl> getHandle() const { return getDerivedHandle<LLUICtrl>(); } + BOOL getIsChrome() const; + + void setTabStop( BOOL b ); + BOOL hasTabStop() const; + + LLUICtrl* getParentUICtrl() const; + + // return true if help topic found by crawling through parents - + // topic then put in help_topic_out + bool findHelpTopic(std::string& help_topic_out); + + boost::signals2::connection setCommitCallback(const CommitCallbackParam& cb); + boost::signals2::connection setValidateCallback(const EnableCallbackParam& cb); + + boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb ); + + boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb ); + + boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb ); + boost::signals2::connection setMouseUpCallback( const mouse_signal_t::slot_type& cb ); + boost::signals2::connection setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ); + boost::signals2::connection setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ); + + boost::signals2::connection setDoubleClickCallback( const mouse_signal_t::slot_type& cb ); + + // *TODO: Deprecate; for backwards compatability only: + boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data); + boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb ); + + LLUICtrl* findRootMostFocusRoot(); + + class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter> + { + LLSINGLETON_EMPTY_CTOR(LLTextInputFilter); + /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const + { + return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE); + } + }; + + template <typename F, typename DERIVED> class CallbackRegistry : public LLRegistrySingleton<std::string, F, DERIVED > + {}; + + class CommitCallbackRegistry : public CallbackRegistry<commit_callback_t, CommitCallbackRegistry> + { + LLSINGLETON_EMPTY_CTOR(CommitCallbackRegistry); + }; + // the enable callback registry is also used for visiblity callbacks + class EnableCallbackRegistry : public CallbackRegistry<enable_callback_t, EnableCallbackRegistry> + { + LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry); + }; + protected: - static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type); + static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type); - commit_signal_t* mCommitSignal; - enable_signal_t* mValidateSignal; + commit_signal_t* mCommitSignal; + enable_signal_t* mValidateSignal; - commit_signal_t* mMouseEnterSignal; - commit_signal_t* mMouseLeaveSignal; - - mouse_signal_t* mMouseDownSignal; - mouse_signal_t* mMouseUpSignal; - mouse_signal_t* mRightMouseDownSignal; - mouse_signal_t* mRightMouseUpSignal; + commit_signal_t* mMouseEnterSignal; + commit_signal_t* mMouseLeaveSignal; + + mouse_signal_t* mMouseDownSignal; + mouse_signal_t* mMouseUpSignal; + mouse_signal_t* mRightMouseDownSignal; + mouse_signal_t* mRightMouseUpSignal; - mouse_signal_t* mDoubleClickSignal; - + mouse_signal_t* mDoubleClickSignal; + LLViewModelPtr mViewModel; - LLControlVariable* mControlVariable; - boost::signals2::connection mControlConnection; - LLControlVariable* mEnabledControlVariable; - boost::signals2::connection mEnabledControlConnection; - LLControlVariable* mDisabledControlVariable; - boost::signals2::connection mDisabledControlConnection; - LLControlVariable* mMakeVisibleControlVariable; - boost::signals2::connection mMakeVisibleControlConnection; - LLControlVariable* mMakeInvisibleControlVariable; - boost::signals2::connection mMakeInvisibleControlConnection; - - static F32 sActiveControlTransparency; - static F32 sInactiveControlTransparency; - - virtual void addInfo(LLSD & info); - + LLControlVariable* mControlVariable; + boost::signals2::connection mControlConnection; + LLControlVariable* mEnabledControlVariable; + boost::signals2::connection mEnabledControlConnection; + LLControlVariable* mDisabledControlVariable; + boost::signals2::connection mDisabledControlConnection; + LLControlVariable* mMakeVisibleControlVariable; + boost::signals2::connection mMakeVisibleControlConnection; + LLControlVariable* mMakeInvisibleControlVariable; + boost::signals2::connection mMakeInvisibleControlConnection; + + static F32 sActiveControlTransparency; + static F32 sInactiveControlTransparency; + + virtual void addInfo(LLSD & info); + private: - BOOL mIsChrome; - BOOL mRequestsFront; - BOOL mTabStop; - BOOL mTentative; + BOOL mIsChrome; + BOOL mRequestsFront; + BOOL mTabStop; + BOOL mTentative; - ETypeTransparency mTransparencyType; + ETypeTransparency mTransparencyType; }; // Build time optimization, generate once in .cpp file #ifndef LLUICTRL_CPP extern template class LLUICtrl* LLView::getChild<class LLUICtrl>( - const std::string& name, BOOL recurse) const; + const std::string& name, BOOL recurse) const; #endif #endif // LL_LLUICTRL_H diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index 338be1808d..be0ea8bb69 100755 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -38,13 +38,13 @@ // Stub for LLAvatarNameCache bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { - return false; + return false; } LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) { - callback_connection_t connection; - return connection; + callback_connection_t connection; + return connection; } // @@ -52,24 +52,24 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag // BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) { - fullname = "Lynx Linden"; - return TRUE; + fullname = "Lynx Linden"; + return TRUE; } BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) { - group = "My Group"; - return TRUE; + group = "My Group"; + return TRUE; } boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback) { - return boost::signals2::connection(); + return boost::signals2::connection(); } boost::signals2::connection LLCacheName::getGroup(const LLUUID& id, const LLCacheNameCallback& callback) { - return boost::signals2::connection(); + return boost::signals2::connection(); } LLCacheName* gCacheName = NULL; @@ -80,12 +80,12 @@ LLCacheName* gCacheName = NULL; class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args); + static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args); }; std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { - return std::string(); + return std::string(); } // @@ -102,65 +102,65 @@ LLStyle::Params::Params() namespace LLInitParam { - ParamValue<LLUIColor>::ParamValue(const LLUIColor& color) - : super_t(color) - {} - - void ParamValue<LLUIColor>::updateValueFromBlock() - {} - - void ParamValue<LLUIColor>::updateBlockFromValue(bool) - {} - - bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b) - { - return false; - } - - ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp) - : super_t(fontp) - {} - - void ParamValue<const LLFontGL*>::updateValueFromBlock() - {} - - void ParamValue<const LLFontGL*>::updateBlockFromValue(bool) - {} - - void TypeValues<LLFontGL::HAlign>::declareValues() - {} - - void TypeValues<LLFontGL::VAlign>::declareValues() - {} - - void TypeValues<LLFontGL::ShadowType>::declareValues() - {} - - void ParamValue<LLUIImage*>::updateValueFromBlock() - {} - - void ParamValue<LLUIImage*>::updateBlockFromValue(bool) - {} - - - bool ParamCompare<LLUIImage*, false>::equals( - LLUIImage* const &a, - LLUIImage* const &b) - { - return false; - } - - bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b) - { - return false; - } + ParamValue<LLUIColor>::ParamValue(const LLUIColor& color) + : super_t(color) + {} + + void ParamValue<LLUIColor>::updateValueFromBlock() + {} + + void ParamValue<LLUIColor>::updateBlockFromValue(bool) + {} + + bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b) + { + return false; + } + + ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp) + : super_t(fontp) + {} + + void ParamValue<const LLFontGL*>::updateValueFromBlock() + {} + + void ParamValue<const LLFontGL*>::updateBlockFromValue(bool) + {} + + void TypeValues<LLFontGL::HAlign>::declareValues() + {} + + void TypeValues<LLFontGL::VAlign>::declareValues() + {} + + void TypeValues<LLFontGL::ShadowType>::declareValues() + {} + + void ParamValue<LLUIImage*>::updateValueFromBlock() + {} + + void ParamValue<LLUIImage*>::updateBlockFromValue(bool) + {} + + + bool ParamCompare<LLUIImage*, false>::equals( + LLUIImage* const &a, + LLUIImage* const &b) + { + return false; + } + + bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b) + { + return false; + } } //static LLFontGL* LLFontGL::getFontDefault() { - return NULL; + return NULL; } char const* const _PREHASH_AgentData = (char *)"AgentData"; diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index bbe1354fc3..7b395491e6 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -60,8 +60,8 @@ const F32 MIN_ZOOM_FRACTION = 0.25f; const F32 INITIAL_ZOOM_FRACTION = 1.f; const F32 MAX_ZOOM_FRACTION = 8.f; -const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f; // seconds -const F32 FOV_ZOOM_HALF_LIFE = 0.07f; // seconds +const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f; // seconds +const F32 FOV_ZOOM_HALF_LIFE = 0.07f; // seconds const F32 CAMERA_FOCUS_HALF_LIFE = 0.f;//0.02f; const F32 CAMERA_LAG_HALF_LIFE = 0.25f; @@ -107,83 +107,83 @@ LLAgentCamera gAgentCamera; // LLAgentCamera() //----------------------------------------------------------------------------- LLAgentCamera::LLAgentCamera() : - mInitialized(false), - - mDrawDistance( DEFAULT_FAR_PLANE ), - - mLookAt(NULL), - mPointAt(NULL), - - mHUDTargetZoom(1.f), - mHUDCurZoom(1.f), - - mForceMouselook(FALSE), - - mCameraMode( CAMERA_MODE_THIRD_PERSON ), - mLastCameraMode( CAMERA_MODE_THIRD_PERSON ), - - mCameraPreset(CAMERA_PRESET_REAR_VIEW), - - mCameraAnimating( FALSE ), - mAnimationCameraStartGlobal(), - mAnimationFocusStartGlobal(), - mAnimationTimer(), - mAnimationDuration(0.33f), - - mCameraFOVZoomFactor(0.f), - mCameraCurrentFOVZoomFactor(0.f), - mCameraFocusOffset(), - mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW), - - mCameraCollidePlane(), - - mCurrentCameraDistance(2.f), // meters, set in init() - mTargetCameraDistance(2.f), - mCameraZoomFraction(1.f), // deprecated - mThirdPersonHeadOffset(0.f, 0.f, 1.f), - mSitCameraEnabled(FALSE), - mCameraSmoothingLastPositionGlobal(), - mCameraSmoothingLastPositionAgent(), - mCameraSmoothingStop(false), - - mCameraUpVector(LLVector3::z_axis), // default is straight up - - mFocusOnAvatar(TRUE), - mAllowChangeToFollow(FALSE), - mFocusGlobal(), - mFocusTargetGlobal(), - mFocusObject(NULL), - mFocusObjectDist(0.f), - mFocusObjectOffset(), - mFocusDotRadius( 0.1f ), // meters - mTrackFocusObject(TRUE), - - mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed - mWalkKey(0), // like AtKey, but causes less forward thrust - mLeftKey(0), - mUpKey(0), - mYawKey(0.f), - mPitchKey(0.f), - - mOrbitLeftKey(0.f), - mOrbitRightKey(0.f), - mOrbitUpKey(0.f), - mOrbitDownKey(0.f), - mOrbitInKey(0.f), - mOrbitOutKey(0.f), - - mPanUpKey(0.f), - mPanDownKey(0.f), - mPanLeftKey(0.f), - mPanRightKey(0.f), - mPanInKey(0.f), - mPanOutKey(0.f) + mInitialized(false), + + mDrawDistance( DEFAULT_FAR_PLANE ), + + mLookAt(NULL), + mPointAt(NULL), + + mHUDTargetZoom(1.f), + mHUDCurZoom(1.f), + + mForceMouselook(FALSE), + + mCameraMode( CAMERA_MODE_THIRD_PERSON ), + mLastCameraMode( CAMERA_MODE_THIRD_PERSON ), + + mCameraPreset(CAMERA_PRESET_REAR_VIEW), + + mCameraAnimating( FALSE ), + mAnimationCameraStartGlobal(), + mAnimationFocusStartGlobal(), + mAnimationTimer(), + mAnimationDuration(0.33f), + + mCameraFOVZoomFactor(0.f), + mCameraCurrentFOVZoomFactor(0.f), + mCameraFocusOffset(), + mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW), + + mCameraCollidePlane(), + + mCurrentCameraDistance(2.f), // meters, set in init() + mTargetCameraDistance(2.f), + mCameraZoomFraction(1.f), // deprecated + mThirdPersonHeadOffset(0.f, 0.f, 1.f), + mSitCameraEnabled(FALSE), + mCameraSmoothingLastPositionGlobal(), + mCameraSmoothingLastPositionAgent(), + mCameraSmoothingStop(false), + + mCameraUpVector(LLVector3::z_axis), // default is straight up + + mFocusOnAvatar(TRUE), + mAllowChangeToFollow(FALSE), + mFocusGlobal(), + mFocusTargetGlobal(), + mFocusObject(NULL), + mFocusObjectDist(0.f), + mFocusObjectOffset(), + mFocusDotRadius( 0.1f ), // meters + mTrackFocusObject(TRUE), + + mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed + mWalkKey(0), // like AtKey, but causes less forward thrust + mLeftKey(0), + mUpKey(0), + mYawKey(0.f), + mPitchKey(0.f), + + mOrbitLeftKey(0.f), + mOrbitRightKey(0.f), + mOrbitUpKey(0.f), + mOrbitDownKey(0.f), + mOrbitInKey(0.f), + mOrbitOutKey(0.f), + + mPanUpKey(0.f), + mPanDownKey(0.f), + mPanLeftKey(0.f), + mPanRightKey(0.f), + mPanInKey(0.f), + mPanOutKey(0.f) { - mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT ); + mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT ); - clearGeneralKeys(); - clearOrbitKeys(); - clearPanKeys(); + clearGeneralKeys(); + clearOrbitKeys(); + clearPanKeys(); } // Requires gSavedSettings to be initialized. @@ -192,36 +192,36 @@ LLAgentCamera::LLAgentCamera() : //----------------------------------------------------------------------------- void LLAgentCamera::init() { - // *Note: this is where LLViewerCamera::getInstance() used to be constructed. + // *Note: this is where LLViewerCamera::getInstance() used to be constructed. - mDrawDistance = gSavedSettings.getF32("RenderFarClip"); + mDrawDistance = gSavedSettings.getF32("RenderFarClip"); - LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW); - // Leave at 0.1 meters until we have real near clip management - LLViewerCamera::getInstance()->setNear(0.1f); - LLViewerCamera::getInstance()->setFar(mDrawDistance); // if you want to change camera settings, do so in camera.h - LLViewerCamera::getInstance()->setAspect( gViewerWindow->getWorldViewAspectRatio() ); // default, overridden in LLViewerWindow::reshape - LLViewerCamera::getInstance()->setViewHeightInPixels(768); // default, overridden in LLViewerWindow::reshape + LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW); + // Leave at 0.1 meters until we have real near clip management + LLViewerCamera::getInstance()->setNear(0.1f); + LLViewerCamera::getInstance()->setFar(mDrawDistance); // if you want to change camera settings, do so in camera.h + LLViewerCamera::getInstance()->setAspect( gViewerWindow->getWorldViewAspectRatio() ); // default, overridden in LLViewerWindow::reshape + LLViewerCamera::getInstance()->setViewHeightInPixels(768); // default, overridden in LLViewerWindow::reshape - mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); - - mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); + mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); + + mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); - mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView"); - mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView"); - mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView"); + mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView"); + mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView"); + mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView"); - mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView"); - mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView"); - mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView"); + mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView"); + mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView"); + mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView"); - mCameraCollidePlane.clearVec(); - mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"); - mTargetCameraDistance = mCurrentCameraDistance; - mCameraZoomFraction = 1.f; - mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject"); + mCameraCollidePlane.clearVec(); + mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"); + mTargetCameraDistance = mCurrentCameraDistance; + mCameraZoomFraction = 1.f; + mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject"); - mInitialized = true; + mInitialized = true; } //----------------------------------------------------------------------------- @@ -229,40 +229,40 @@ void LLAgentCamera::init() //----------------------------------------------------------------------------- void LLAgentCamera::cleanup() { - setSitCamera(LLUUID::null); - - if(mLookAt) - { - mLookAt->markDead() ; - mLookAt = NULL; - } - if(mPointAt) - { - mPointAt->markDead() ; - mPointAt = NULL; - } - setFocusObject(NULL); + setSitCamera(LLUUID::null); + + if(mLookAt) + { + mLookAt->markDead() ; + mLookAt = NULL; + } + if(mPointAt) + { + mPointAt->markDead() ; + mPointAt = NULL; + } + setFocusObject(NULL); } void LLAgentCamera::setAvatarObject(LLVOAvatarSelf* avatar) { - if (!mLookAt) - { - mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); - } - if (!mPointAt) - { - mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); - } - - if (!mLookAt.isNull()) - { - mLookAt->setSourceObject(avatar); - } - if (!mPointAt.isNull()) - { - mPointAt->setSourceObject(avatar); - } + if (!mLookAt) + { + mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); + } + if (!mPointAt) + { + mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); + } + + if (!mLookAt.isNull()) + { + mLookAt->setSourceObject(avatar); + } + if (!mPointAt.isNull()) + { + mPointAt->setSourceObject(avatar); + } } //----------------------------------------------------------------------------- @@ -270,9 +270,9 @@ void LLAgentCamera::setAvatarObject(LLVOAvatarSelf* avatar) //----------------------------------------------------------------------------- LLAgentCamera::~LLAgentCamera() { - cleanup(); + cleanup(); - // *Note: this is where LLViewerCamera::getInstance() used to be deleted. + // *Note: this is where LLViewerCamera::getInstance() used to be deleted. } // Change camera back to third person, stop the autopilot, @@ -282,74 +282,74 @@ LLAgentCamera::~LLAgentCamera() //----------------------------------------------------------------------------- void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) { - if (gAgent.getAutoPilot()) - { - gAgent.stopAutoPilot(TRUE); - } - - LLSelectMgr::getInstance()->unhighlightAll(); - - // By popular request, keep land selection while walking around. JC - // LLViewerParcelMgr::getInstance()->deselectLand(); - - // force deselect when walking and attachment is selected - // this is so people don't wig out when their avatar moves without animating - if (LLSelectMgr::getInstance()->getSelection()->isAttachment()) - { - LLSelectMgr::getInstance()->deselectAll(); - } - - if (gMenuHolder != NULL) - { - // Hide all popup menus - gMenuHolder->hideMenus(); - } - - if (change_camera && !gSavedSettings.getBOOL("FreezeTime")) - { - changeCameraToDefault(); - - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - handle_toggle_flycam(); - } - - // reset avatar mode from eventual residual motion - if (LLToolMgr::getInstance()->inBuildMode()) - { - LLViewerJoystick::getInstance()->moveAvatar(true); - } - - //Camera Tool is needed for Free Camera Control Mode - if (!LLFloaterCamera::inFreeCameraMode()) - { - LLFloaterReg::hideInstance("build"); - - // Switch back to basic toolset - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - } - - gViewerWindow->showCursor(); - } - - - if (reset_camera && !gSavedSettings.getBOOL("FreezeTime")) - { - if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson()) - { - // leaving mouse-steer mode - LLVector3 agent_at_axis = gAgent.getAtAxis(); - agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector()); - agent_at_axis.normalize(); - gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLSmoothInterpolation::getInterpolant(0.3f))); - } - - setFocusOnAvatar(TRUE, ANIMATE); - - mCameraFOVZoomFactor = 0.f; - } - - mHUDTargetZoom = 1.f; + if (gAgent.getAutoPilot()) + { + gAgent.stopAutoPilot(TRUE); + } + + LLSelectMgr::getInstance()->unhighlightAll(); + + // By popular request, keep land selection while walking around. JC + // LLViewerParcelMgr::getInstance()->deselectLand(); + + // force deselect when walking and attachment is selected + // this is so people don't wig out when their avatar moves without animating + if (LLSelectMgr::getInstance()->getSelection()->isAttachment()) + { + LLSelectMgr::getInstance()->deselectAll(); + } + + if (gMenuHolder != NULL) + { + // Hide all popup menus + gMenuHolder->hideMenus(); + } + + if (change_camera && !gSavedSettings.getBOOL("FreezeTime")) + { + changeCameraToDefault(); + + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + handle_toggle_flycam(); + } + + // reset avatar mode from eventual residual motion + if (LLToolMgr::getInstance()->inBuildMode()) + { + LLViewerJoystick::getInstance()->moveAvatar(true); + } + + //Camera Tool is needed for Free Camera Control Mode + if (!LLFloaterCamera::inFreeCameraMode()) + { + LLFloaterReg::hideInstance("build"); + + // Switch back to basic toolset + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); + } + + gViewerWindow->showCursor(); + } + + + if (reset_camera && !gSavedSettings.getBOOL("FreezeTime")) + { + if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson()) + { + // leaving mouse-steer mode + LLVector3 agent_at_axis = gAgent.getAtAxis(); + agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector()); + agent_at_axis.normalize(); + gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLSmoothInterpolation::getInterpolant(0.3f))); + } + + setFocusOnAvatar(TRUE, ANIMATE); + + mCameraFOVZoomFactor = 0.f; + } + + mHUDTargetZoom = 1.f; } // Allow camera to be moved somewhere other than behind avatar. @@ -358,14 +358,14 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) //----------------------------------------------------------------------------- void LLAgentCamera::unlockView() { - if (getFocusOnAvatar()) - { - if (isAgentAvatarValid()) - { - setFocusGlobal(LLVector3d::zero, gAgentAvatarp->mID); - } - setFocusOnAvatar(FALSE, FALSE); // no animation - } + if (getFocusOnAvatar()) + { + if (isAgentAvatarValid()) + { + setFocusGlobal(LLVector3d::zero, gAgentAvatarp->mID); + } + setFocusOnAvatar(FALSE, FALSE); // no animation + } } //----------------------------------------------------------------------------- @@ -373,10 +373,10 @@ void LLAgentCamera::unlockView() //----------------------------------------------------------------------------- void LLAgentCamera::slamLookAt(const LLVector3 &look_at) { - LLVector3 look_at_norm = look_at; - look_at_norm.mV[VZ] = 0.f; - look_at_norm.normalize(); - gAgent.resetAxes(look_at_norm); + LLVector3 look_at_norm = look_at; + look_at_norm.mV[VZ] = 0.f; + look_at_norm.normalize(); + gAgent.resetAxes(look_at_norm); } //----------------------------------------------------------------------------- @@ -384,169 +384,169 @@ void LLAgentCamera::slamLookAt(const LLVector3 &look_at) //----------------------------------------------------------------------------- LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 original_focus_point, S32 x, S32 y) { - LLMatrix4 obj_matrix = object->getRenderMatrix(); - LLQuaternion obj_rot = object->getRenderRotation(); - LLVector3 obj_pos = object->getRenderPosition(); - - BOOL is_avatar = object->isAvatar(); - // if is avatar - don't do any funk heuristics to position the focal point - // see DEV-30589 - if (is_avatar) - { - return original_focus_point - obj_pos; - } - - LLQuaternion inv_obj_rot = ~obj_rot; // get inverse of rotation - LLVector3 object_extents = object->getScale(); - - // make sure they object extents are non-zero - object_extents.clamp(0.001f, F32_MAX); - - // obj_to_cam_ray is unit vector pointing from object center to camera, in the coordinate frame of the object - LLVector3 obj_to_cam_ray = obj_pos - LLViewerCamera::getInstance()->getOrigin(); - obj_to_cam_ray.rotVec(inv_obj_rot); - obj_to_cam_ray.normalize(); - - // obj_to_cam_ray_proportions are the (positive) ratios of - // the obj_to_cam_ray x,y,z components with the x,y,z object dimensions. - LLVector3 obj_to_cam_ray_proportions; - obj_to_cam_ray_proportions.mV[VX] = llabs(obj_to_cam_ray.mV[VX] / object_extents.mV[VX]); - obj_to_cam_ray_proportions.mV[VY] = llabs(obj_to_cam_ray.mV[VY] / object_extents.mV[VY]); - obj_to_cam_ray_proportions.mV[VZ] = llabs(obj_to_cam_ray.mV[VZ] / object_extents.mV[VZ]); - - // find the largest ratio stored in obj_to_cam_ray_proportions - // this corresponds to the object's local axial plane (XY, YZ, XZ) that is *most* facing the camera - LLVector3 longest_object_axis; - // is x-axis longest? - if (obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VY] - && obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VZ]) - { - // then grab it - longest_object_axis.setVec(obj_matrix.getFwdRow4()); - } - // is y-axis longest? - else if (obj_to_cam_ray_proportions.mV[VY] > obj_to_cam_ray_proportions.mV[VZ]) - { - // then grab it - longest_object_axis.setVec(obj_matrix.getLeftRow4()); - } - // otherwise, use z axis - else - { - longest_object_axis.setVec(obj_matrix.getUpRow4()); - } - - // Use this axis as the normal to project mouse click on to plane with that normal, at the object center. - // This generates a point behind the mouse cursor that is approximately in the middle of the object in - // terms of depth. - // We do this to allow the camera rotation tool to "tumble" the object by rotating the camera. - // If the focus point were the object surface under the mouse, camera rotation would introduce an undesirable - // eccentricity to the object orientation - LLVector3 focus_plane_normal(longest_object_axis); - focus_plane_normal.normalize(); - - LLVector3d focus_pt_global; - gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), focus_plane_normal); - LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global); - - // find vector from camera to focus point in object space - LLVector3 camera_to_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin(); - camera_to_focus_vec.rotVec(inv_obj_rot); - - // find vector from object origin to focus point in object coordinates - LLVector3 focus_offset_from_object_center = focus_pt - obj_pos; - // convert to object-local space - focus_offset_from_object_center.rotVec(inv_obj_rot); - - // We need to project the focus point back into the bounding box of the focused object. - // Do this by calculating the XYZ scale factors needed to get focus offset back in bounds along the camera_focus axis - LLVector3 clip_fraction; - - // for each axis... - for (U32 axis = VX; axis <= VZ; axis++) - { - //...calculate distance that focus offset sits outside of bounding box along that axis... - //NOTE: dist_out_of_bounds keeps the sign of focus_offset_from_object_center - F32 dist_out_of_bounds; - if (focus_offset_from_object_center.mV[axis] > 0.f) - { - dist_out_of_bounds = llmax(0.f, focus_offset_from_object_center.mV[axis] - (object_extents.mV[axis] * 0.5f)); - } - else - { - dist_out_of_bounds = llmin(0.f, focus_offset_from_object_center.mV[axis] + (object_extents.mV[axis] * 0.5f)); - } - - //...then calculate the scale factor needed to push camera_to_focus_vec back in bounds along current axis - if (llabs(camera_to_focus_vec.mV[axis]) < 0.0001f) - { - // don't divide by very small number - clip_fraction.mV[axis] = 0.f; - } - else - { - clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis]; - } - } - - LLVector3 abs_clip_fraction = clip_fraction; - abs_clip_fraction.abs(); - - // find axis of focus offset that is *most* outside the bounding box and use that to - // rescale focus offset to inside object extents - if (abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VY] - && abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VZ]) - { - focus_offset_from_object_center -= clip_fraction.mV[VX] * camera_to_focus_vec; - } - else if (abs_clip_fraction.mV[VY] > abs_clip_fraction.mV[VZ]) - { - focus_offset_from_object_center -= clip_fraction.mV[VY] * camera_to_focus_vec; - } - else - { - focus_offset_from_object_center -= clip_fraction.mV[VZ] * camera_to_focus_vec; - } - - // convert back to world space - focus_offset_from_object_center.rotVec(obj_rot); - - // now, based on distance of camera from object relative to object size - // push the focus point towards the near surface of the object when (relatively) close to the objcet - // or keep the focus point in the object middle when (relatively) far - // NOTE: leave focus point in middle of avatars, since the behavior you want when alt-zooming on avatars - // is almost always "tumble about middle" and not "spin around surface point" - if (!is_avatar) - { - LLVector3 obj_rel = original_focus_point - object->getRenderPosition(); - - //now that we have the object relative position, we should bias toward the center of the object - //based on the distance of the camera to the focus point vs. the distance of the camera to the focus - - F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis()); - F32 viewDist = dist_vec(obj_pos + obj_rel, LLViewerCamera::getInstance()->getOrigin()); - - - LLBBox obj_bbox = object->getBoundingBoxAgent(); - F32 bias = 0.f; - - // virtual_camera_pos is the camera position we are simulating by backing the camera off - // and adjusting the FOV - LLVector3 virtual_camera_pos = gAgent.getPosAgentFromGlobal(mFocusTargetGlobal + (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor)); - - // if the camera is inside the object (large, hollow objects, for example) - // leave focus point all the way to destination depth, away from object center - if(!obj_bbox.containsPointAgent(virtual_camera_pos)) - { - // perform magic number biasing of focus point towards surface vs. planar center - bias = clamp_rescale(relDist/viewDist, 0.1f, 0.7f, 0.0f, 1.0f); - obj_rel = lerp(focus_offset_from_object_center, obj_rel, bias); - } - - focus_offset_from_object_center = obj_rel; - } - - return focus_offset_from_object_center; + LLMatrix4 obj_matrix = object->getRenderMatrix(); + LLQuaternion obj_rot = object->getRenderRotation(); + LLVector3 obj_pos = object->getRenderPosition(); + + BOOL is_avatar = object->isAvatar(); + // if is avatar - don't do any funk heuristics to position the focal point + // see DEV-30589 + if (is_avatar) + { + return original_focus_point - obj_pos; + } + + LLQuaternion inv_obj_rot = ~obj_rot; // get inverse of rotation + LLVector3 object_extents = object->getScale(); + + // make sure they object extents are non-zero + object_extents.clamp(0.001f, F32_MAX); + + // obj_to_cam_ray is unit vector pointing from object center to camera, in the coordinate frame of the object + LLVector3 obj_to_cam_ray = obj_pos - LLViewerCamera::getInstance()->getOrigin(); + obj_to_cam_ray.rotVec(inv_obj_rot); + obj_to_cam_ray.normalize(); + + // obj_to_cam_ray_proportions are the (positive) ratios of + // the obj_to_cam_ray x,y,z components with the x,y,z object dimensions. + LLVector3 obj_to_cam_ray_proportions; + obj_to_cam_ray_proportions.mV[VX] = llabs(obj_to_cam_ray.mV[VX] / object_extents.mV[VX]); + obj_to_cam_ray_proportions.mV[VY] = llabs(obj_to_cam_ray.mV[VY] / object_extents.mV[VY]); + obj_to_cam_ray_proportions.mV[VZ] = llabs(obj_to_cam_ray.mV[VZ] / object_extents.mV[VZ]); + + // find the largest ratio stored in obj_to_cam_ray_proportions + // this corresponds to the object's local axial plane (XY, YZ, XZ) that is *most* facing the camera + LLVector3 longest_object_axis; + // is x-axis longest? + if (obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VY] + && obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VZ]) + { + // then grab it + longest_object_axis.setVec(obj_matrix.getFwdRow4()); + } + // is y-axis longest? + else if (obj_to_cam_ray_proportions.mV[VY] > obj_to_cam_ray_proportions.mV[VZ]) + { + // then grab it + longest_object_axis.setVec(obj_matrix.getLeftRow4()); + } + // otherwise, use z axis + else + { + longest_object_axis.setVec(obj_matrix.getUpRow4()); + } + + // Use this axis as the normal to project mouse click on to plane with that normal, at the object center. + // This generates a point behind the mouse cursor that is approximately in the middle of the object in + // terms of depth. + // We do this to allow the camera rotation tool to "tumble" the object by rotating the camera. + // If the focus point were the object surface under the mouse, camera rotation would introduce an undesirable + // eccentricity to the object orientation + LLVector3 focus_plane_normal(longest_object_axis); + focus_plane_normal.normalize(); + + LLVector3d focus_pt_global; + gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), focus_plane_normal); + LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global); + + // find vector from camera to focus point in object space + LLVector3 camera_to_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin(); + camera_to_focus_vec.rotVec(inv_obj_rot); + + // find vector from object origin to focus point in object coordinates + LLVector3 focus_offset_from_object_center = focus_pt - obj_pos; + // convert to object-local space + focus_offset_from_object_center.rotVec(inv_obj_rot); + + // We need to project the focus point back into the bounding box of the focused object. + // Do this by calculating the XYZ scale factors needed to get focus offset back in bounds along the camera_focus axis + LLVector3 clip_fraction; + + // for each axis... + for (U32 axis = VX; axis <= VZ; axis++) + { + //...calculate distance that focus offset sits outside of bounding box along that axis... + //NOTE: dist_out_of_bounds keeps the sign of focus_offset_from_object_center + F32 dist_out_of_bounds; + if (focus_offset_from_object_center.mV[axis] > 0.f) + { + dist_out_of_bounds = llmax(0.f, focus_offset_from_object_center.mV[axis] - (object_extents.mV[axis] * 0.5f)); + } + else + { + dist_out_of_bounds = llmin(0.f, focus_offset_from_object_center.mV[axis] + (object_extents.mV[axis] * 0.5f)); + } + + //...then calculate the scale factor needed to push camera_to_focus_vec back in bounds along current axis + if (llabs(camera_to_focus_vec.mV[axis]) < 0.0001f) + { + // don't divide by very small number + clip_fraction.mV[axis] = 0.f; + } + else + { + clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis]; + } + } + + LLVector3 abs_clip_fraction = clip_fraction; + abs_clip_fraction.abs(); + + // find axis of focus offset that is *most* outside the bounding box and use that to + // rescale focus offset to inside object extents + if (abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VY] + && abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VZ]) + { + focus_offset_from_object_center -= clip_fraction.mV[VX] * camera_to_focus_vec; + } + else if (abs_clip_fraction.mV[VY] > abs_clip_fraction.mV[VZ]) + { + focus_offset_from_object_center -= clip_fraction.mV[VY] * camera_to_focus_vec; + } + else + { + focus_offset_from_object_center -= clip_fraction.mV[VZ] * camera_to_focus_vec; + } + + // convert back to world space + focus_offset_from_object_center.rotVec(obj_rot); + + // now, based on distance of camera from object relative to object size + // push the focus point towards the near surface of the object when (relatively) close to the objcet + // or keep the focus point in the object middle when (relatively) far + // NOTE: leave focus point in middle of avatars, since the behavior you want when alt-zooming on avatars + // is almost always "tumble about middle" and not "spin around surface point" + if (!is_avatar) + { + LLVector3 obj_rel = original_focus_point - object->getRenderPosition(); + + //now that we have the object relative position, we should bias toward the center of the object + //based on the distance of the camera to the focus point vs. the distance of the camera to the focus + + F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis()); + F32 viewDist = dist_vec(obj_pos + obj_rel, LLViewerCamera::getInstance()->getOrigin()); + + + LLBBox obj_bbox = object->getBoundingBoxAgent(); + F32 bias = 0.f; + + // virtual_camera_pos is the camera position we are simulating by backing the camera off + // and adjusting the FOV + LLVector3 virtual_camera_pos = gAgent.getPosAgentFromGlobal(mFocusTargetGlobal + (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor)); + + // if the camera is inside the object (large, hollow objects, for example) + // leave focus point all the way to destination depth, away from object center + if(!obj_bbox.containsPointAgent(virtual_camera_pos)) + { + // perform magic number biasing of focus point towards surface vs. planar center + bias = clamp_rescale(relDist/viewDist, 0.1f, 0.7f, 0.0f, 1.0f); + obj_rel = lerp(focus_offset_from_object_center, obj_rel, bias); + } + + focus_offset_from_object_center = obj_rel; + } + + return focus_offset_from_object_center; } //----------------------------------------------------------------------------- @@ -554,260 +554,260 @@ LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 origi //----------------------------------------------------------------------------- BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) { - BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars) - - if (!mFocusObject || mFocusObject->isDead() || - mFocusObject->isMesh() || - gSavedSettings.getBOOL("DisableCameraConstraints")) - { - obj_min_distance = 0.f; - return TRUE; - } - - if (mFocusObject->mDrawable.isNull()) - { + BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars) + + if (!mFocusObject || mFocusObject->isDead() || + mFocusObject->isMesh() || + gSavedSettings.getBOOL("DisableCameraConstraints")) + { + obj_min_distance = 0.f; + return TRUE; + } + + if (mFocusObject->mDrawable.isNull()) + { #ifdef LL_RELEASE_FOR_DOWNLOAD - LL_WARNS() << "Focus object with no drawable!" << LL_ENDL; + LL_WARNS() << "Focus object with no drawable!" << LL_ENDL; #else - mFocusObject->dump(); - LL_ERRS() << "Focus object with no drawable!" << LL_ENDL; + mFocusObject->dump(); + LL_ERRS() << "Focus object with no drawable!" << LL_ENDL; #endif - obj_min_distance = 0.f; - return TRUE; - } - - LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation(); - LLVector3 target_offset_origin = mFocusObjectOffset; - LLVector3 camera_offset_target(getCameraPositionAgent() - gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); - - // convert offsets into object local space - camera_offset_target.rotVec(inv_object_rot); - target_offset_origin.rotVec(inv_object_rot); - - // push around object extents based on target offset - LLVector3 object_extents = mFocusObject->getScale(); - if (mFocusObject->isAvatar()) - { - // fudge factors that lets you zoom in on avatars a bit more (which don't do FOV zoom) - object_extents.mV[VX] *= AVATAR_ZOOM_MIN_X_FACTOR; - object_extents.mV[VY] *= AVATAR_ZOOM_MIN_Y_FACTOR; - object_extents.mV[VZ] *= AVATAR_ZOOM_MIN_Z_FACTOR; - soft_limit = TRUE; - } - LLVector3 abs_target_offset = target_offset_origin; - abs_target_offset.abs(); - - LLVector3 target_offset_dir = target_offset_origin; - - BOOL target_outside_object_extents = FALSE; - - for (U32 i = VX; i <= VZ; i++) - { - if (abs_target_offset.mV[i] * 2.f > object_extents.mV[i] + OBJECT_EXTENTS_PADDING) - { - target_outside_object_extents = TRUE; - } - if (camera_offset_target.mV[i] > 0.f) - { - object_extents.mV[i] -= target_offset_origin.mV[i] * 2.f; - } - else - { - object_extents.mV[i] += target_offset_origin.mV[i] * 2.f; - } - } - - // don't shrink the object extents so far that the object inverts - object_extents.clamp(0.001f, F32_MAX); - - // move into first octant - LLVector3 camera_offset_target_abs_norm = camera_offset_target; - camera_offset_target_abs_norm.abs(); - // make sure offset is non-zero - camera_offset_target_abs_norm.clamp(0.001f, F32_MAX); - camera_offset_target_abs_norm.normalize(); - - // find camera position relative to normalized object extents - LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm; - camera_offset_target_scaled.mV[VX] /= object_extents.mV[VX]; - camera_offset_target_scaled.mV[VY] /= object_extents.mV[VY]; - camera_offset_target_scaled.mV[VZ] /= object_extents.mV[VZ]; - - if (camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VY] && - camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VZ]) - { - if (camera_offset_target_abs_norm.mV[VX] < 0.001f) - { - obj_min_distance = object_extents.mV[VX] * 0.5f; - } - else - { - obj_min_distance = object_extents.mV[VX] * 0.5f / camera_offset_target_abs_norm.mV[VX]; - } - } - else if (camera_offset_target_scaled.mV[VY] > camera_offset_target_scaled.mV[VZ]) - { - if (camera_offset_target_abs_norm.mV[VY] < 0.001f) - { - obj_min_distance = object_extents.mV[VY] * 0.5f; - } - else - { - obj_min_distance = object_extents.mV[VY] * 0.5f / camera_offset_target_abs_norm.mV[VY]; - } - } - else - { - if (camera_offset_target_abs_norm.mV[VZ] < 0.001f) - { - obj_min_distance = object_extents.mV[VZ] * 0.5f; - } - else - { - obj_min_distance = object_extents.mV[VZ] * 0.5f / camera_offset_target_abs_norm.mV[VZ]; - } - } - - LLVector3 object_split_axis; - LLVector3 target_offset_scaled = target_offset_origin; - target_offset_scaled.abs(); - target_offset_scaled.normalize(); - target_offset_scaled.mV[VX] /= object_extents.mV[VX]; - target_offset_scaled.mV[VY] /= object_extents.mV[VY]; - target_offset_scaled.mV[VZ] /= object_extents.mV[VZ]; - - if (target_offset_scaled.mV[VX] > target_offset_scaled.mV[VY] && - target_offset_scaled.mV[VX] > target_offset_scaled.mV[VZ]) - { - object_split_axis = LLVector3::x_axis; - } - else if (target_offset_scaled.mV[VY] > target_offset_scaled.mV[VZ]) - { - object_split_axis = LLVector3::y_axis; - } - else - { - object_split_axis = LLVector3::z_axis; - } - - LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent()); - - - F32 camera_offset_clip = camera_offset_object * object_split_axis; - F32 target_offset_clip = target_offset_dir * object_split_axis; - - // target has moved outside of object extents - // check to see if camera and target are on same side - if (target_outside_object_extents) - { - if (camera_offset_clip > 0.f && target_offset_clip > 0.f) - { - return FALSE; - } - else if (camera_offset_clip < 0.f && target_offset_clip < 0.f) - { - return FALSE; - } - } - - // clamp obj distance to diagonal of 10 by 10 cube - obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3); - - obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f); - - return TRUE; + obj_min_distance = 0.f; + return TRUE; + } + + LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation(); + LLVector3 target_offset_origin = mFocusObjectOffset; + LLVector3 camera_offset_target(getCameraPositionAgent() - gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); + + // convert offsets into object local space + camera_offset_target.rotVec(inv_object_rot); + target_offset_origin.rotVec(inv_object_rot); + + // push around object extents based on target offset + LLVector3 object_extents = mFocusObject->getScale(); + if (mFocusObject->isAvatar()) + { + // fudge factors that lets you zoom in on avatars a bit more (which don't do FOV zoom) + object_extents.mV[VX] *= AVATAR_ZOOM_MIN_X_FACTOR; + object_extents.mV[VY] *= AVATAR_ZOOM_MIN_Y_FACTOR; + object_extents.mV[VZ] *= AVATAR_ZOOM_MIN_Z_FACTOR; + soft_limit = TRUE; + } + LLVector3 abs_target_offset = target_offset_origin; + abs_target_offset.abs(); + + LLVector3 target_offset_dir = target_offset_origin; + + BOOL target_outside_object_extents = FALSE; + + for (U32 i = VX; i <= VZ; i++) + { + if (abs_target_offset.mV[i] * 2.f > object_extents.mV[i] + OBJECT_EXTENTS_PADDING) + { + target_outside_object_extents = TRUE; + } + if (camera_offset_target.mV[i] > 0.f) + { + object_extents.mV[i] -= target_offset_origin.mV[i] * 2.f; + } + else + { + object_extents.mV[i] += target_offset_origin.mV[i] * 2.f; + } + } + + // don't shrink the object extents so far that the object inverts + object_extents.clamp(0.001f, F32_MAX); + + // move into first octant + LLVector3 camera_offset_target_abs_norm = camera_offset_target; + camera_offset_target_abs_norm.abs(); + // make sure offset is non-zero + camera_offset_target_abs_norm.clamp(0.001f, F32_MAX); + camera_offset_target_abs_norm.normalize(); + + // find camera position relative to normalized object extents + LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm; + camera_offset_target_scaled.mV[VX] /= object_extents.mV[VX]; + camera_offset_target_scaled.mV[VY] /= object_extents.mV[VY]; + camera_offset_target_scaled.mV[VZ] /= object_extents.mV[VZ]; + + if (camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VY] && + camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VZ]) + { + if (camera_offset_target_abs_norm.mV[VX] < 0.001f) + { + obj_min_distance = object_extents.mV[VX] * 0.5f; + } + else + { + obj_min_distance = object_extents.mV[VX] * 0.5f / camera_offset_target_abs_norm.mV[VX]; + } + } + else if (camera_offset_target_scaled.mV[VY] > camera_offset_target_scaled.mV[VZ]) + { + if (camera_offset_target_abs_norm.mV[VY] < 0.001f) + { + obj_min_distance = object_extents.mV[VY] * 0.5f; + } + else + { + obj_min_distance = object_extents.mV[VY] * 0.5f / camera_offset_target_abs_norm.mV[VY]; + } + } + else + { + if (camera_offset_target_abs_norm.mV[VZ] < 0.001f) + { + obj_min_distance = object_extents.mV[VZ] * 0.5f; + } + else + { + obj_min_distance = object_extents.mV[VZ] * 0.5f / camera_offset_target_abs_norm.mV[VZ]; + } + } + + LLVector3 object_split_axis; + LLVector3 target_offset_scaled = target_offset_origin; + target_offset_scaled.abs(); + target_offset_scaled.normalize(); + target_offset_scaled.mV[VX] /= object_extents.mV[VX]; + target_offset_scaled.mV[VY] /= object_extents.mV[VY]; + target_offset_scaled.mV[VZ] /= object_extents.mV[VZ]; + + if (target_offset_scaled.mV[VX] > target_offset_scaled.mV[VY] && + target_offset_scaled.mV[VX] > target_offset_scaled.mV[VZ]) + { + object_split_axis = LLVector3::x_axis; + } + else if (target_offset_scaled.mV[VY] > target_offset_scaled.mV[VZ]) + { + object_split_axis = LLVector3::y_axis; + } + else + { + object_split_axis = LLVector3::z_axis; + } + + LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent()); + + + F32 camera_offset_clip = camera_offset_object * object_split_axis; + F32 target_offset_clip = target_offset_dir * object_split_axis; + + // target has moved outside of object extents + // check to see if camera and target are on same side + if (target_outside_object_extents) + { + if (camera_offset_clip > 0.f && target_offset_clip > 0.f) + { + return FALSE; + } + else if (camera_offset_clip < 0.f && target_offset_clip < 0.f) + { + return FALSE; + } + } + + // clamp obj distance to diagonal of 10 by 10 cube + obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3); + + obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f); + + return TRUE; } F32 LLAgentCamera::getCameraZoomFraction() { - // 0.f -> camera zoomed all the way out - // 1.f -> camera zoomed all the way in - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - // already [0,1] - return mHUDTargetZoom; - } - else if (mFocusOnAvatar && cameraThirdPerson()) - { - return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f); - } - else if (cameraCustomizeAvatar()) - { - F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); - return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f ); - } - else - { - F32 min_zoom; - F32 max_zoom = getCameraMaxZoomDistance(); - - F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); - if (mFocusObject.notNull()) - { - if (mFocusObject->isAvatar()) - { - min_zoom = AVATAR_MIN_ZOOM; - } - else - { - min_zoom = OBJECT_MIN_ZOOM; - } - } - else - { - min_zoom = LAND_MIN_ZOOM; - } - - return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f); - } + // 0.f -> camera zoomed all the way out + // 1.f -> camera zoomed all the way in + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) + { + // already [0,1] + return mHUDTargetZoom; + } + else if (mFocusOnAvatar && cameraThirdPerson()) + { + return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f); + } + else if (cameraCustomizeAvatar()) + { + F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); + return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f ); + } + else + { + F32 min_zoom; + F32 max_zoom = getCameraMaxZoomDistance(); + + F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); + if (mFocusObject.notNull()) + { + if (mFocusObject->isAvatar()) + { + min_zoom = AVATAR_MIN_ZOOM; + } + else + { + min_zoom = OBJECT_MIN_ZOOM; + } + } + else + { + min_zoom = LAND_MIN_ZOOM; + } + + return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f); + } } void LLAgentCamera::setCameraZoomFraction(F32 fraction) { - // 0.f -> camera zoomed all the way out - // 1.f -> camera zoomed all the way in - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - mHUDTargetZoom = fraction; - } - else if (mFocusOnAvatar && cameraThirdPerson()) - { - mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION); - } - else if (cameraCustomizeAvatar()) - { - LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; - camera_offset_dir.normalize(); - mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM); - } - else - { - F32 min_zoom = LAND_MIN_ZOOM; - F32 max_zoom = getCameraMaxZoomDistance(); - - if (mFocusObject.notNull()) - { - if (mFocusObject.notNull()) - { - if (mFocusObject->isAvatar()) - { - min_zoom = AVATAR_MIN_ZOOM; - } - else - { - min_zoom = OBJECT_MIN_ZOOM; - } - } - } - - LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; - camera_offset_dir.normalize(); - mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom); - } - startCameraAnimation(); + // 0.f -> camera zoomed all the way out + // 1.f -> camera zoomed all the way in + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + + if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) + { + mHUDTargetZoom = fraction; + } + else if (mFocusOnAvatar && cameraThirdPerson()) + { + mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION); + } + else if (cameraCustomizeAvatar()) + { + LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; + camera_offset_dir.normalize(); + mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM); + } + else + { + F32 min_zoom = LAND_MIN_ZOOM; + F32 max_zoom = getCameraMaxZoomDistance(); + + if (mFocusObject.notNull()) + { + if (mFocusObject.notNull()) + { + if (mFocusObject->isAvatar()) + { + min_zoom = AVATAR_MIN_ZOOM; + } + else + { + min_zoom = OBJECT_MIN_ZOOM; + } + } + } + + LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; + camera_offset_dir.normalize(); + mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom); + } + startCameraAnimation(); } @@ -816,21 +816,21 @@ void LLAgentCamera::setCameraZoomFraction(F32 fraction) //----------------------------------------------------------------------------- void LLAgentCamera::cameraOrbitAround(const F32 radians) { - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - // do nothing for hud selection - } - else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON || mCameraMode == CAMERA_MODE_FOLLOW)) - { - gAgent.yaw(radians); - } - else - { - mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f); - - cameraZoomIn(1.f); - } + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) + { + // do nothing for hud selection + } + else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON || mCameraMode == CAMERA_MODE_FOLLOW)) + { + gAgent.yaw(radians); + } + else + { + mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f); + + cameraZoomIn(1.f); + } } @@ -839,29 +839,29 @@ void LLAgentCamera::cameraOrbitAround(const F32 radians) //----------------------------------------------------------------------------- void LLAgentCamera::cameraOrbitOver(const F32 angle) { - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - // do nothing for hud selection - } - else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) - { - gAgent.pitch(angle); - } - else - { - LLVector3 camera_offset_unit(mCameraFocusOffsetTarget); - camera_offset_unit.normalize(); - - F32 angle_from_up = acos( camera_offset_unit * gAgent.getReferenceUpVector() ); - - LLVector3d left_axis; - left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); - F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD); - mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis); - - cameraZoomIn(1.f); - } + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) + { + // do nothing for hud selection + } + else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) + { + gAgent.pitch(angle); + } + else + { + LLVector3 camera_offset_unit(mCameraFocusOffsetTarget); + camera_offset_unit.normalize(); + + F32 angle_from_up = acos( camera_offset_unit * gAgent.getReferenceUpVector() ); + + LLVector3d left_axis; + left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); + F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD); + mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis); + + cameraZoomIn(1.f); + } } //----------------------------------------------------------------------------- @@ -869,65 +869,65 @@ void LLAgentCamera::cameraOrbitOver(const F32 angle) //----------------------------------------------------------------------------- void LLAgentCamera::cameraZoomIn(const F32 fraction) { - if (gDisconnected) - { - return; - } - - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (LLToolMgr::getInstance()->inBuildMode() && selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - // just update hud zoom level - mHUDTargetZoom /= fraction; - return; - } - - - LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); - F32 min_zoom = LAND_MIN_ZOOM; - F32 current_distance = (F32)camera_offset_unit.normalize(); - F32 new_distance = current_distance * fraction; - - // Don't move through focus point - if (mFocusObject) - { - LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]); - - if (mFocusObject->isAvatar()) - { - calcCameraMinDistance(min_zoom); - } - else - { - min_zoom = OBJECT_MIN_ZOOM; - } - } - - new_distance = llmax(new_distance, min_zoom); - - F32 max_distance = getCameraMaxZoomDistance(); + if (gDisconnected) + { + return; + } + + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + if (LLToolMgr::getInstance()->inBuildMode() && selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) + { + // just update hud zoom level + mHUDTargetZoom /= fraction; + return; + } + + + LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); + F32 min_zoom = LAND_MIN_ZOOM; + F32 current_distance = (F32)camera_offset_unit.normalize(); + F32 new_distance = current_distance * fraction; + + // Don't move through focus point + if (mFocusObject) + { + LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]); + + if (mFocusObject->isAvatar()) + { + calcCameraMinDistance(min_zoom); + } + else + { + min_zoom = OBJECT_MIN_ZOOM; + } + } + + new_distance = llmax(new_distance, min_zoom); + + F32 max_distance = getCameraMaxZoomDistance(); max_distance = llmin(max_distance, current_distance * 4.f); //Scaled max relative to current distance. MAINT-3154 - if (new_distance > max_distance) - { - new_distance = max_distance; - - /* - // Unless camera is unlocked - if (!LLViewerCamera::sDisableCameraConstraints) - { - return; - } - */ - } - - if(cameraCustomizeAvatar()) - { - new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM ); - } - - mCameraFocusOffsetTarget = new_distance * camera_offset_unit; + if (new_distance > max_distance) + { + new_distance = max_distance; + + /* + // Unless camera is unlocked + if (!LLViewerCamera::sDisableCameraConstraints) + { + return; + } + */ + } + + if(cameraCustomizeAvatar()) + { + new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM ); + } + + mCameraFocusOffsetTarget = new_distance * camera_offset_unit; } //----------------------------------------------------------------------------- @@ -935,62 +935,62 @@ void LLAgentCamera::cameraZoomIn(const F32 fraction) //----------------------------------------------------------------------------- void LLAgentCamera::cameraOrbitIn(const F32 meters) { - if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) - { - F32 camera_offset_dist = llmax(0.001f, getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale")); - - mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist; - - if (!gSavedSettings.getBOOL("FreezeTime") && mCameraZoomFraction < MIN_ZOOM_FRACTION && meters > 0.f) - { - // No need to animate, camera is already there. - changeCameraToMouselook(FALSE); - } - - mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION); - } - else - { - LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); - F32 current_distance = (F32)camera_offset_unit.normalize(); - F32 new_distance = current_distance - meters; - F32 min_zoom = LAND_MIN_ZOOM; - - // Don't move through focus point - if (mFocusObject.notNull()) - { - if (mFocusObject->isAvatar()) - { - min_zoom = AVATAR_MIN_ZOOM; - } - else - { - min_zoom = OBJECT_MIN_ZOOM; - } - } - - new_distance = llmax(new_distance, min_zoom); - - F32 max_distance = getCameraMaxZoomDistance(); - - if (new_distance > max_distance) - { - // Unless camera is unlocked - if (!gSavedSettings.getBOOL("DisableCameraConstraints")) - { - return; - } - } - - if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() ) - { - new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM ); - } - - // Compute new camera offset - mCameraFocusOffsetTarget = new_distance * camera_offset_unit; - cameraZoomIn(1.f); - } + if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) + { + F32 camera_offset_dist = llmax(0.001f, getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale")); + + mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist; + + if (!gSavedSettings.getBOOL("FreezeTime") && mCameraZoomFraction < MIN_ZOOM_FRACTION && meters > 0.f) + { + // No need to animate, camera is already there. + changeCameraToMouselook(FALSE); + } + + mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION); + } + else + { + LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); + F32 current_distance = (F32)camera_offset_unit.normalize(); + F32 new_distance = current_distance - meters; + F32 min_zoom = LAND_MIN_ZOOM; + + // Don't move through focus point + if (mFocusObject.notNull()) + { + if (mFocusObject->isAvatar()) + { + min_zoom = AVATAR_MIN_ZOOM; + } + else + { + min_zoom = OBJECT_MIN_ZOOM; + } + } + + new_distance = llmax(new_distance, min_zoom); + + F32 max_distance = getCameraMaxZoomDistance(); + + if (new_distance > max_distance) + { + // Unless camera is unlocked + if (!gSavedSettings.getBOOL("DisableCameraConstraints")) + { + return; + } + } + + if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() ) + { + new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM ); + } + + // Compute new camera offset + mCameraFocusOffsetTarget = new_distance * camera_offset_unit; + cameraZoomIn(1.f); + } } @@ -999,15 +999,15 @@ void LLAgentCamera::cameraOrbitIn(const F32 meters) //----------------------------------------------------------------------------- void LLAgentCamera::cameraPanIn(F32 meters) { - LLVector3d at_axis; - at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis()); - - mFocusTargetGlobal += meters * at_axis; - mFocusGlobal = mFocusTargetGlobal; - // don't enforce zoom constraints as this is the only way for users to get past them easily - updateFocusOffset(); - // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx - mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); + LLVector3d at_axis; + at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis()); + + mFocusTargetGlobal += meters * at_axis; + mFocusGlobal = mFocusTargetGlobal; + // don't enforce zoom constraints as this is the only way for users to get past them easily + updateFocusOffset(); + // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx + mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); } //----------------------------------------------------------------------------- @@ -1015,19 +1015,19 @@ void LLAgentCamera::cameraPanIn(F32 meters) //----------------------------------------------------------------------------- void LLAgentCamera::cameraPanLeft(F32 meters) { - LLVector3d left_axis; - left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); - - mFocusTargetGlobal += meters * left_axis; - mFocusGlobal = mFocusTargetGlobal; - - // disable smoothing for camera pan, which causes some residents unhappiness - mCameraSmoothingStop = true; - - cameraZoomIn(1.f); - updateFocusOffset(); - // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx - mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); + LLVector3d left_axis; + left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); + + mFocusTargetGlobal += meters * left_axis; + mFocusGlobal = mFocusTargetGlobal; + + // disable smoothing for camera pan, which causes some residents unhappiness + mCameraSmoothingStop = true; + + cameraZoomIn(1.f); + updateFocusOffset(); + // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx + mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); } //----------------------------------------------------------------------------- @@ -1035,19 +1035,19 @@ void LLAgentCamera::cameraPanLeft(F32 meters) //----------------------------------------------------------------------------- void LLAgentCamera::cameraPanUp(F32 meters) { - LLVector3d up_axis; - up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis()); + LLVector3d up_axis; + up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis()); - mFocusTargetGlobal += meters * up_axis; - mFocusGlobal = mFocusTargetGlobal; + mFocusTargetGlobal += meters * up_axis; + mFocusGlobal = mFocusTargetGlobal; - // disable smoothing for camera pan, which causes some residents unhappiness - mCameraSmoothingStop = true; + // disable smoothing for camera pan, which causes some residents unhappiness + mCameraSmoothingStop = true; - cameraZoomIn(1.f); - updateFocusOffset(); - // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx - mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); + cameraZoomIn(1.f); + updateFocusOffset(); + // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx + mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); } //----------------------------------------------------------------------------- @@ -1055,67 +1055,67 @@ void LLAgentCamera::cameraPanUp(F32 meters) //----------------------------------------------------------------------------- void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) { - static LLVector3 last_at_axis; - - if (!isAgentAvatarValid()) return; - - LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot->getWorldRotation(); - LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot->getWorldRotation(); - - if (LLTrace::get_frame_recording().getLastRecording().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f - && (root_at * last_at_axis > 0.95f)) - { - LLVector3 vel = gAgentAvatarp->getVelocity(); - if (vel.magVecSquared() > 4.f) - { - setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, vel * av_inv_rot); - } - else - { - // *FIX: rotate mframeagent by sit object's rotation? - LLQuaternion look_rotation = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation - LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot; - setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, look_offset); - } - last_at_axis = root_at; - return; - } - - last_at_axis = root_at; - - if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode()) - { - setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, LLVector3(-2.f, 0.f, 0.f)); - } - else - { - // Move head based on cursor position - ELookAtType lookAtType = LOOKAT_TARGET_NONE; - LLVector3 headLookAxis; - LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance()); - - if (cameraMouselook()) - { - lookAtType = LOOKAT_TARGET_MOUSELOOK; - } - else if (cameraThirdPerson()) - { - // range from -.5 to .5 - F32 x_from_center = - ((F32) mouse_x / (F32) gViewerWindow->getWorldViewWidthScaled() ) - 0.5f; - F32 y_from_center = - ((F32) mouse_y / (F32) gViewerWindow->getWorldViewHeightScaled() ) - 0.5f; - - frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD); - frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD); - lookAtType = LOOKAT_TARGET_FREELOOK; - } - - headLookAxis = frameCamera.getAtAxis(); - // RN: we use world-space offset for mouselook and freelook - //headLookAxis = headLookAxis * av_inv_rot; - setLookAt(lookAtType, gAgentAvatarp, headLookAxis); - } + static LLVector3 last_at_axis; + + if (!isAgentAvatarValid()) return; + + LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot->getWorldRotation(); + LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot->getWorldRotation(); + + if (LLTrace::get_frame_recording().getLastRecording().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f + && (root_at * last_at_axis > 0.95f)) + { + LLVector3 vel = gAgentAvatarp->getVelocity(); + if (vel.magVecSquared() > 4.f) + { + setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, vel * av_inv_rot); + } + else + { + // *FIX: rotate mframeagent by sit object's rotation? + LLQuaternion look_rotation = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation + LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot; + setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, look_offset); + } + last_at_axis = root_at; + return; + } + + last_at_axis = root_at; + + if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode()) + { + setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, LLVector3(-2.f, 0.f, 0.f)); + } + else + { + // Move head based on cursor position + ELookAtType lookAtType = LOOKAT_TARGET_NONE; + LLVector3 headLookAxis; + LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance()); + + if (cameraMouselook()) + { + lookAtType = LOOKAT_TARGET_MOUSELOOK; + } + else if (cameraThirdPerson()) + { + // range from -.5 to .5 + F32 x_from_center = + ((F32) mouse_x / (F32) gViewerWindow->getWorldViewWidthScaled() ) - 0.5f; + F32 y_from_center = + ((F32) mouse_y / (F32) gViewerWindow->getWorldViewHeightScaled() ) - 0.5f; + + frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD); + frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD); + lookAtType = LOOKAT_TARGET_FREELOOK; + } + + headLookAxis = frameCamera.getAtAxis(); + // RN: we use world-space offset for mouselook and freelook + //headLookAxis = headLookAxis * av_inv_rot; + setLookAt(lookAtType, gAgentAvatarp, headLookAxis); + } } static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera"); @@ -1125,373 +1125,373 @@ static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera"); //----------------------------------------------------------------------------- void LLAgentCamera::updateCamera() { - LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA); - - // - changed camera_skyward to the new global "mCameraUpVector" - mCameraUpVector = LLVector3::z_axis; - //LLVector3 camera_skyward(0.f, 0.f, 1.f); - - U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode; - - validateFocusObject(); - - if (isAgentAvatarValid() && - gAgentAvatarp->isSitting() && - camera_mode == CAMERA_MODE_MOUSELOOK) - { - //changed camera_skyward to the new global "mCameraUpVector" - mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation(); - } - - if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getActiveFollowCamParams()) - { - mAllowChangeToFollow = FALSE; - mFocusOnAvatar = TRUE; - changeCameraToFollow(); - } - - //NOTE - this needs to be integrated into a general upVector system here within llAgent. - if ( camera_mode == CAMERA_MODE_FOLLOW && mFocusOnAvatar ) - { - mCameraUpVector = mFollowCam.getUpVector(); - } - - if (mSitCameraEnabled) - { - if (mSitCameraReferenceObject->isDead()) - { - setSitCamera(LLUUID::null); - } - } - - // Update UI with our camera inputs - LLFloaterCamera* camera_floater = LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera"); - if (camera_floater) - { - camera_floater->mRotate->setToggleState(gAgentCamera.getOrbitRightKey() > 0.f, // left - gAgentCamera.getOrbitUpKey() > 0.f, // top - gAgentCamera.getOrbitLeftKey() > 0.f, // right - gAgentCamera.getOrbitDownKey() > 0.f); // bottom - - camera_floater->mTrack->setToggleState(gAgentCamera.getPanLeftKey() > 0.f, // left - gAgentCamera.getPanUpKey() > 0.f, // top - gAgentCamera.getPanRightKey() > 0.f, // right - gAgentCamera.getPanDownKey() > 0.f); // bottom - } - - // Handle camera movement based on keyboard. - const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD; // radians per second - const F32 ORBIT_AROUND_RATE = 90.f * DEG_TO_RAD; // radians per second - const F32 PAN_RATE = 5.f; // meters per second - - if (gAgentCamera.getOrbitUpKey() || gAgentCamera.getOrbitDownKey()) - { - F32 input_rate = gAgentCamera.getOrbitUpKey() - gAgentCamera.getOrbitDownKey(); - cameraOrbitOver( input_rate * ORBIT_OVER_RATE / gFPSClamped ); - } - - if (gAgentCamera.getOrbitLeftKey() || gAgentCamera.getOrbitRightKey()) - { - F32 input_rate = gAgentCamera.getOrbitLeftKey() - gAgentCamera.getOrbitRightKey(); - cameraOrbitAround(input_rate * ORBIT_AROUND_RATE / gFPSClamped); - } - - if (gAgentCamera.getOrbitInKey() || gAgentCamera.getOrbitOutKey()) - { - F32 input_rate = gAgentCamera.getOrbitInKey() - gAgentCamera.getOrbitOutKey(); - - LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal(); - F32 distance_to_focus = (F32)to_focus.magVec(); - // Move at distance (in meters) meters per second - cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped ); - } - - if (gAgentCamera.getPanInKey() || gAgentCamera.getPanOutKey()) - { - F32 input_rate = gAgentCamera.getPanInKey() - gAgentCamera.getPanOutKey(); - cameraPanIn(input_rate * PAN_RATE / gFPSClamped); - } - - if (gAgentCamera.getPanRightKey() || gAgentCamera.getPanLeftKey()) - { - F32 input_rate = gAgentCamera.getPanRightKey() - gAgentCamera.getPanLeftKey(); - cameraPanLeft(input_rate * -PAN_RATE / gFPSClamped ); - } - - if (gAgentCamera.getPanUpKey() || gAgentCamera.getPanDownKey()) - { - F32 input_rate = gAgentCamera.getPanUpKey() - gAgentCamera.getPanDownKey(); - cameraPanUp(input_rate * PAN_RATE / gFPSClamped ); - } - - // Clear camera keyboard keys. - gAgentCamera.clearOrbitKeys(); - gAgentCamera.clearPanKeys(); - - // lerp camera focus offset - mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLSmoothInterpolation::getInterpolant(CAMERA_FOCUS_HALF_LIFE)); - - if ( mCameraMode == CAMERA_MODE_FOLLOW ) - { - if (isAgentAvatarValid()) - { - //-------------------------------------------------------------------------------- - // this is where the avatar's position and rotation are given to followCam, and - // where it is updated. All three of its attributes are updated: (1) position, - // (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent. - //-------------------------------------------------------------------------------- - // *TODO: use combined rotation of frameagent and sit object - LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); - - LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams(); - if (current_cam) - { - mFollowCam.copyParams(*current_cam); - mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam ); - mFollowCam.update(); - LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true); - } - else - { - changeCameraToThirdPerson(TRUE); - } - } - } - - BOOL hit_limit; - LLVector3d camera_pos_global; - LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit); - mCameraVirtualPositionAgent = gAgent.getPosAgentFromGlobal(camera_target_global); - LLVector3d focus_target_global = calcFocusPositionTargetGlobal(); - - // perform field of view correction - mCameraFOVZoomFactor = calcCameraFOVZoomFactor(); - camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor); - - gAgent.setShowAvatar(TRUE); // can see avatar by default - - // Adjust position for animation - if (mCameraAnimating) - { - F32 time = mAnimationTimer.getElapsedTimeF32(); - - // yet another instance of critically damped motion, hooray! - // F32 fraction_of_animation = 1.f - pow(2.f, -time / CAMERA_ZOOM_HALF_LIFE); - - // linear interpolation - F32 fraction_of_animation = time / mAnimationDuration; - - BOOL isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK; - BOOL wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK; - F32 fraction_animation_to_skip; - - if (mAnimationCameraStartGlobal == camera_target_global) - { - fraction_animation_to_skip = 0.f; - } - else - { - LLVector3d cam_delta = mAnimationCameraStartGlobal - camera_target_global; - fraction_animation_to_skip = HEAD_BUFFER_SIZE / (F32)cam_delta.magVec(); - } - F32 animation_start_fraction = (wasfirstPerson) ? fraction_animation_to_skip : 0.f; - F32 animation_finish_fraction = (isfirstPerson) ? (1.f - fraction_animation_to_skip) : 1.f; - - if (fraction_of_animation < animation_finish_fraction) - { - if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction ) - { - gAgent.setShowAvatar(FALSE); - } - - // ...adjust position for animation - F32 smooth_fraction_of_animation = llsmoothstep(0.0f, 1.0f, fraction_of_animation); - camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, smooth_fraction_of_animation); - mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, smooth_fraction_of_animation); - } - else - { - // ...animation complete - mCameraAnimating = FALSE; - - camera_pos_global = camera_target_global; - mFocusGlobal = focus_target_global; - - gAgent.endAnimationUpdateUI(); - gAgent.setShowAvatar(TRUE); - } - - if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK)) - { - gAgentAvatarp->updateAttachmentVisibility(mCameraMode); - } - } - else - { - camera_pos_global = camera_target_global; - mFocusGlobal = focus_target_global; - gAgent.setShowAvatar(TRUE); - } - - // smoothing - if (TRUE) - { - LLVector3d agent_pos = gAgent.getPositionGlobal(); - LLVector3d camera_pos_agent = camera_pos_global - agent_pos; - // Sitting on what you're manipulating can cause camera jitter with smoothing. - // This turns off smoothing while editing. -MG - bool in_build_mode = LLToolMgr::getInstance()->inBuildMode(); - mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode; - - if (cameraThirdPerson() && !mCameraSmoothingStop) - { - const F32 SMOOTHING_HALF_LIFE = 0.02f; - - F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE); - - if (!mFocusObject) // we differentiate on avatar mode - { - // for avatar-relative focus, we smooth in avatar space - - // the avatar moves too jerkily w/r/t global space to smooth there. - - LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent; - if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please - { - camera_pos_agent = lerp(mCameraSmoothingLastPositionAgent, camera_pos_agent, smoothing); - camera_pos_global = camera_pos_agent + agent_pos; - } - } - else - { - LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal; - if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please - { - camera_pos_global = lerp(mCameraSmoothingLastPositionGlobal, camera_pos_global, smoothing); - } - } - } - - mCameraSmoothingLastPositionGlobal = camera_pos_global; - mCameraSmoothingLastPositionAgent = camera_pos_agent; - mCameraSmoothingStop = false; - } - - - mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLSmoothInterpolation::getInterpolant(FOV_ZOOM_HALF_LIFE)); - -// LL_INFOS() << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << LL_ENDL; - - LLVector3 focus_agent = gAgent.getPosAgentFromGlobal(mFocusGlobal); - - mCameraPositionAgent = gAgent.getPosAgentFromGlobal(camera_pos_global); - - // Move the camera - - LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent); - //LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent); - - // Change FOV - LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor)); - - // follow camera when in customize mode - if (cameraCustomizeAvatar()) - { - setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent); - } - - // update the travel distance stat - // this isn't directly related to the camera - // but this seemed like the best place to do this - LLVector3d global_pos = gAgent.getPositionGlobal(); - if (!gAgent.getLastPositionGlobal().isExactlyZero()) - { - LLVector3d delta = global_pos - gAgent.getLastPositionGlobal(); - gAgent.setDistanceTraveled(gAgent.getDistanceTraveled() + delta.magVec()); - } - gAgent.setLastPositionGlobal(global_pos); - - if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook()) - { - LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() + - LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + - LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation(); - LLVector3 diff = mCameraPositionAgent - head_pos; - diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation(); - - LLJoint* torso_joint = gAgentAvatarp->mTorsop; - LLJoint* chest_joint = gAgentAvatarp->mChestp; - LLVector3 torso_scale = torso_joint->getScale(); - LLVector3 chest_scale = chest_joint->getScale(); - - // shorten avatar skeleton to avoid foot interpenetration - if (!gAgentAvatarp->mInAir) - { - LLVector3 chest_offset = LLVector3(0.f, 0.f, chest_joint->getPosition().mV[VZ]) * torso_joint->getWorldRotation(); - F32 z_compensate = llclamp(-diff.mV[VZ], -0.2f, 1.f); - F32 scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / chest_offset.mV[VZ]), 0.5f, 1.2f); - torso_joint->setScale(LLVector3(1.f, 1.f, scale_factor)); - - LLJoint* neck_joint = gAgentAvatarp->mNeckp; - LLVector3 neck_offset = LLVector3(0.f, 0.f, neck_joint->getPosition().mV[VZ]) * chest_joint->getWorldRotation(); - scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / neck_offset.mV[VZ]), 0.5f, 1.2f); - chest_joint->setScale(LLVector3(1.f, 1.f, scale_factor)); - diff.mV[VZ] = 0.f; - } - - // SL-315 - gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff); - - gAgentAvatarp->mRoot->updateWorldMatrixChildren(); - - for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); - iter != gAgentAvatarp->mAttachmentPoints.end(); ) - { - LLVOAvatar::attachment_map_t::iterator curiter = iter++; - LLViewerJointAttachment* attachment = curiter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) - { - LLViewerObject *attached_object = (*attachment_iter); - if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull()) - { - // clear any existing "early" movements of attachment - attached_object->mDrawable->clearState(LLDrawable::EARLY_MOVE); - gPipeline.updateMoveNormalAsync(attached_object->mDrawable); - attached_object->updateText(); - } - } - } - - torso_joint->setScale(torso_scale); - chest_joint->setScale(chest_scale); - } + LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA); + + // - changed camera_skyward to the new global "mCameraUpVector" + mCameraUpVector = LLVector3::z_axis; + //LLVector3 camera_skyward(0.f, 0.f, 1.f); + + U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode; + + validateFocusObject(); + + if (isAgentAvatarValid() && + gAgentAvatarp->isSitting() && + camera_mode == CAMERA_MODE_MOUSELOOK) + { + //changed camera_skyward to the new global "mCameraUpVector" + mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation(); + } + + if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getActiveFollowCamParams()) + { + mAllowChangeToFollow = FALSE; + mFocusOnAvatar = TRUE; + changeCameraToFollow(); + } + + //NOTE - this needs to be integrated into a general upVector system here within llAgent. + if ( camera_mode == CAMERA_MODE_FOLLOW && mFocusOnAvatar ) + { + mCameraUpVector = mFollowCam.getUpVector(); + } + + if (mSitCameraEnabled) + { + if (mSitCameraReferenceObject->isDead()) + { + setSitCamera(LLUUID::null); + } + } + + // Update UI with our camera inputs + LLFloaterCamera* camera_floater = LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera"); + if (camera_floater) + { + camera_floater->mRotate->setToggleState(gAgentCamera.getOrbitRightKey() > 0.f, // left + gAgentCamera.getOrbitUpKey() > 0.f, // top + gAgentCamera.getOrbitLeftKey() > 0.f, // right + gAgentCamera.getOrbitDownKey() > 0.f); // bottom + + camera_floater->mTrack->setToggleState(gAgentCamera.getPanLeftKey() > 0.f, // left + gAgentCamera.getPanUpKey() > 0.f, // top + gAgentCamera.getPanRightKey() > 0.f, // right + gAgentCamera.getPanDownKey() > 0.f); // bottom + } + + // Handle camera movement based on keyboard. + const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD; // radians per second + const F32 ORBIT_AROUND_RATE = 90.f * DEG_TO_RAD; // radians per second + const F32 PAN_RATE = 5.f; // meters per second + + if (gAgentCamera.getOrbitUpKey() || gAgentCamera.getOrbitDownKey()) + { + F32 input_rate = gAgentCamera.getOrbitUpKey() - gAgentCamera.getOrbitDownKey(); + cameraOrbitOver( input_rate * ORBIT_OVER_RATE / gFPSClamped ); + } + + if (gAgentCamera.getOrbitLeftKey() || gAgentCamera.getOrbitRightKey()) + { + F32 input_rate = gAgentCamera.getOrbitLeftKey() - gAgentCamera.getOrbitRightKey(); + cameraOrbitAround(input_rate * ORBIT_AROUND_RATE / gFPSClamped); + } + + if (gAgentCamera.getOrbitInKey() || gAgentCamera.getOrbitOutKey()) + { + F32 input_rate = gAgentCamera.getOrbitInKey() - gAgentCamera.getOrbitOutKey(); + + LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal(); + F32 distance_to_focus = (F32)to_focus.magVec(); + // Move at distance (in meters) meters per second + cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped ); + } + + if (gAgentCamera.getPanInKey() || gAgentCamera.getPanOutKey()) + { + F32 input_rate = gAgentCamera.getPanInKey() - gAgentCamera.getPanOutKey(); + cameraPanIn(input_rate * PAN_RATE / gFPSClamped); + } + + if (gAgentCamera.getPanRightKey() || gAgentCamera.getPanLeftKey()) + { + F32 input_rate = gAgentCamera.getPanRightKey() - gAgentCamera.getPanLeftKey(); + cameraPanLeft(input_rate * -PAN_RATE / gFPSClamped ); + } + + if (gAgentCamera.getPanUpKey() || gAgentCamera.getPanDownKey()) + { + F32 input_rate = gAgentCamera.getPanUpKey() - gAgentCamera.getPanDownKey(); + cameraPanUp(input_rate * PAN_RATE / gFPSClamped ); + } + + // Clear camera keyboard keys. + gAgentCamera.clearOrbitKeys(); + gAgentCamera.clearPanKeys(); + + // lerp camera focus offset + mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLSmoothInterpolation::getInterpolant(CAMERA_FOCUS_HALF_LIFE)); + + if ( mCameraMode == CAMERA_MODE_FOLLOW ) + { + if (isAgentAvatarValid()) + { + //-------------------------------------------------------------------------------- + // this is where the avatar's position and rotation are given to followCam, and + // where it is updated. All three of its attributes are updated: (1) position, + // (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent. + //-------------------------------------------------------------------------------- + // *TODO: use combined rotation of frameagent and sit object + LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); + + LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams(); + if (current_cam) + { + mFollowCam.copyParams(*current_cam); + mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam ); + mFollowCam.update(); + LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true); + } + else + { + changeCameraToThirdPerson(TRUE); + } + } + } + + BOOL hit_limit; + LLVector3d camera_pos_global; + LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit); + mCameraVirtualPositionAgent = gAgent.getPosAgentFromGlobal(camera_target_global); + LLVector3d focus_target_global = calcFocusPositionTargetGlobal(); + + // perform field of view correction + mCameraFOVZoomFactor = calcCameraFOVZoomFactor(); + camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor); + + gAgent.setShowAvatar(TRUE); // can see avatar by default + + // Adjust position for animation + if (mCameraAnimating) + { + F32 time = mAnimationTimer.getElapsedTimeF32(); + + // yet another instance of critically damped motion, hooray! + // F32 fraction_of_animation = 1.f - pow(2.f, -time / CAMERA_ZOOM_HALF_LIFE); + + // linear interpolation + F32 fraction_of_animation = time / mAnimationDuration; + + BOOL isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK; + BOOL wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK; + F32 fraction_animation_to_skip; + + if (mAnimationCameraStartGlobal == camera_target_global) + { + fraction_animation_to_skip = 0.f; + } + else + { + LLVector3d cam_delta = mAnimationCameraStartGlobal - camera_target_global; + fraction_animation_to_skip = HEAD_BUFFER_SIZE / (F32)cam_delta.magVec(); + } + F32 animation_start_fraction = (wasfirstPerson) ? fraction_animation_to_skip : 0.f; + F32 animation_finish_fraction = (isfirstPerson) ? (1.f - fraction_animation_to_skip) : 1.f; + + if (fraction_of_animation < animation_finish_fraction) + { + if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction ) + { + gAgent.setShowAvatar(FALSE); + } + + // ...adjust position for animation + F32 smooth_fraction_of_animation = llsmoothstep(0.0f, 1.0f, fraction_of_animation); + camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, smooth_fraction_of_animation); + mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, smooth_fraction_of_animation); + } + else + { + // ...animation complete + mCameraAnimating = FALSE; + + camera_pos_global = camera_target_global; + mFocusGlobal = focus_target_global; + + gAgent.endAnimationUpdateUI(); + gAgent.setShowAvatar(TRUE); + } + + if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK)) + { + gAgentAvatarp->updateAttachmentVisibility(mCameraMode); + } + } + else + { + camera_pos_global = camera_target_global; + mFocusGlobal = focus_target_global; + gAgent.setShowAvatar(TRUE); + } + + // smoothing + if (TRUE) + { + LLVector3d agent_pos = gAgent.getPositionGlobal(); + LLVector3d camera_pos_agent = camera_pos_global - agent_pos; + // Sitting on what you're manipulating can cause camera jitter with smoothing. + // This turns off smoothing while editing. -MG + bool in_build_mode = LLToolMgr::getInstance()->inBuildMode(); + mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode; + + if (cameraThirdPerson() && !mCameraSmoothingStop) + { + const F32 SMOOTHING_HALF_LIFE = 0.02f; + + F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE); + + if (!mFocusObject) // we differentiate on avatar mode + { + // for avatar-relative focus, we smooth in avatar space - + // the avatar moves too jerkily w/r/t global space to smooth there. + + LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent; + if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please + { + camera_pos_agent = lerp(mCameraSmoothingLastPositionAgent, camera_pos_agent, smoothing); + camera_pos_global = camera_pos_agent + agent_pos; + } + } + else + { + LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal; + if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please + { + camera_pos_global = lerp(mCameraSmoothingLastPositionGlobal, camera_pos_global, smoothing); + } + } + } + + mCameraSmoothingLastPositionGlobal = camera_pos_global; + mCameraSmoothingLastPositionAgent = camera_pos_agent; + mCameraSmoothingStop = false; + } + + + mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLSmoothInterpolation::getInterpolant(FOV_ZOOM_HALF_LIFE)); + +// LL_INFOS() << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << LL_ENDL; + + LLVector3 focus_agent = gAgent.getPosAgentFromGlobal(mFocusGlobal); + + mCameraPositionAgent = gAgent.getPosAgentFromGlobal(camera_pos_global); + + // Move the camera + + LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent); + //LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent); + + // Change FOV + LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor)); + + // follow camera when in customize mode + if (cameraCustomizeAvatar()) + { + setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent); + } + + // update the travel distance stat + // this isn't directly related to the camera + // but this seemed like the best place to do this + LLVector3d global_pos = gAgent.getPositionGlobal(); + if (!gAgent.getLastPositionGlobal().isExactlyZero()) + { + LLVector3d delta = global_pos - gAgent.getLastPositionGlobal(); + gAgent.setDistanceTraveled(gAgent.getDistanceTraveled() + delta.magVec()); + } + gAgent.setLastPositionGlobal(global_pos); + + if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook()) + { + LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() + + LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + + LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation(); + LLVector3 diff = mCameraPositionAgent - head_pos; + diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation(); + + LLJoint* torso_joint = gAgentAvatarp->mTorsop; + LLJoint* chest_joint = gAgentAvatarp->mChestp; + LLVector3 torso_scale = torso_joint->getScale(); + LLVector3 chest_scale = chest_joint->getScale(); + + // shorten avatar skeleton to avoid foot interpenetration + if (!gAgentAvatarp->mInAir) + { + LLVector3 chest_offset = LLVector3(0.f, 0.f, chest_joint->getPosition().mV[VZ]) * torso_joint->getWorldRotation(); + F32 z_compensate = llclamp(-diff.mV[VZ], -0.2f, 1.f); + F32 scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / chest_offset.mV[VZ]), 0.5f, 1.2f); + torso_joint->setScale(LLVector3(1.f, 1.f, scale_factor)); + + LLJoint* neck_joint = gAgentAvatarp->mNeckp; + LLVector3 neck_offset = LLVector3(0.f, 0.f, neck_joint->getPosition().mV[VZ]) * chest_joint->getWorldRotation(); + scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / neck_offset.mV[VZ]), 0.5f, 1.2f); + chest_joint->setScale(LLVector3(1.f, 1.f, scale_factor)); + diff.mV[VZ] = 0.f; + } + + // SL-315 + gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff); + + gAgentAvatarp->mRoot->updateWorldMatrixChildren(); + + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); + iter != gAgentAvatarp->mAttachmentPoints.end(); ) + { + LLVOAvatar::attachment_map_t::iterator curiter = iter++; + LLViewerJointAttachment* attachment = curiter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject *attached_object = (*attachment_iter); + if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull()) + { + // clear any existing "early" movements of attachment + attached_object->mDrawable->clearState(LLDrawable::EARLY_MOVE); + gPipeline.updateMoveNormalAsync(attached_object->mDrawable); + attached_object->updateText(); + } + } + } + + torso_joint->setScale(torso_scale); + chest_joint->setScale(chest_scale); + } } void LLAgentCamera::updateLastCamera() { - mLastCameraMode = mCameraMode; + mLastCameraMode = mCameraMode; } void LLAgentCamera::updateFocusOffset() { - validateFocusObject(); - if (mFocusObject.notNull()) - { - LLVector3d obj_pos = gAgent.getPosGlobalFromAgent(mFocusObject->getRenderPosition()); - mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos); - } + validateFocusObject(); + if (mFocusObject.notNull()) + { + LLVector3d obj_pos = gAgent.getPosGlobalFromAgent(mFocusObject->getRenderPosition()); + mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos); + } } void LLAgentCamera::validateFocusObject() { - if (mFocusObject.notNull() && - mFocusObject->isDead()) - { - mFocusObjectOffset.clearVec(); - clearFocusObject(); - mCameraFOVZoomFactor = 0.f; - } + if (mFocusObject.notNull() && + mFocusObject->isDead()) + { + mFocusObjectOffset.clearVec(); + clearFocusObject(); + mCameraFOVZoomFactor = 0.f; + } } //----------------------------------------------------------------------------- @@ -1499,124 +1499,124 @@ void LLAgentCamera::validateFocusObject() //----------------------------------------------------------------------------- LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal() { - if (mFocusObject.notNull() && mFocusObject->isDead()) - { - clearFocusObject(); - } - - if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar) - { - mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedFocus()); - return mFocusTargetGlobal; - } - else if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - LLVector3d at_axis(1.0, 0.0, 0.0); - LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion(); - if (isAgentAvatarValid() && gAgentAvatarp->getParent()) - { - LLViewerObject* root_object = (LLViewerObject*)gAgentAvatarp->getRoot(); - if (!root_object->flagCameraDecoupled()) - { - agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation(); - } - } - at_axis = at_axis * agent_rot; - mFocusTargetGlobal = calcCameraPositionTargetGlobal() + at_axis; - return mFocusTargetGlobal; - } - else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) - { - if (mFocusOnAvatar) - { - LLVector3 focus_target = isAgentAvatarValid() - ? gAgentAvatarp->mHeadp->getWorldPosition() - : gAgent.getPositionAgent(); - LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target); - mFocusTargetGlobal = focus_target_global; - } - return mFocusTargetGlobal; - } - else if (!mFocusOnAvatar) - { - if (mFocusObject.notNull() && !mFocusObject->isDead() && mFocusObject->mDrawable.notNull()) - { - LLDrawable* drawablep = mFocusObject->mDrawable; - - if (mTrackFocusObject && - drawablep && - drawablep->isActive()) - { - if (!mFocusObject->isAvatar()) - { - if (mFocusObject->isSelected()) - { - gPipeline.updateMoveNormalAsync(drawablep); - } - else - { - if (drawablep->isState(LLDrawable::MOVE_UNDAMPED)) - { - gPipeline.updateMoveNormalAsync(drawablep); - } - else - { - gPipeline.updateMoveDampedAsync(drawablep); - } - } - } - } - // if not tracking object, update offset based on new object position - else - { - updateFocusOffset(); - } - LLVector3 focus_agent = mFocusObject->getRenderPosition() + mFocusObjectOffset; - mFocusTargetGlobal.setVec(gAgent.getPosGlobalFromAgent(focus_agent)); - } - return mFocusTargetGlobal; - } - else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatarp->isSitting() && mSitCameraReferenceObject.notNull()) - { - // sit camera - LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition(); - LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation(); - - LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot); - return gAgent.getPosGlobalFromAgent(target_pos); - } - else - { - return gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(); - } + if (mFocusObject.notNull() && mFocusObject->isDead()) + { + clearFocusObject(); + } + + if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar) + { + mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedFocus()); + return mFocusTargetGlobal; + } + else if (mCameraMode == CAMERA_MODE_MOUSELOOK) + { + LLVector3d at_axis(1.0, 0.0, 0.0); + LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion(); + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + LLViewerObject* root_object = (LLViewerObject*)gAgentAvatarp->getRoot(); + if (!root_object->flagCameraDecoupled()) + { + agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation(); + } + } + at_axis = at_axis * agent_rot; + mFocusTargetGlobal = calcCameraPositionTargetGlobal() + at_axis; + return mFocusTargetGlobal; + } + else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) + { + if (mFocusOnAvatar) + { + LLVector3 focus_target = isAgentAvatarValid() + ? gAgentAvatarp->mHeadp->getWorldPosition() + : gAgent.getPositionAgent(); + LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target); + mFocusTargetGlobal = focus_target_global; + } + return mFocusTargetGlobal; + } + else if (!mFocusOnAvatar) + { + if (mFocusObject.notNull() && !mFocusObject->isDead() && mFocusObject->mDrawable.notNull()) + { + LLDrawable* drawablep = mFocusObject->mDrawable; + + if (mTrackFocusObject && + drawablep && + drawablep->isActive()) + { + if (!mFocusObject->isAvatar()) + { + if (mFocusObject->isSelected()) + { + gPipeline.updateMoveNormalAsync(drawablep); + } + else + { + if (drawablep->isState(LLDrawable::MOVE_UNDAMPED)) + { + gPipeline.updateMoveNormalAsync(drawablep); + } + else + { + gPipeline.updateMoveDampedAsync(drawablep); + } + } + } + } + // if not tracking object, update offset based on new object position + else + { + updateFocusOffset(); + } + LLVector3 focus_agent = mFocusObject->getRenderPosition() + mFocusObjectOffset; + mFocusTargetGlobal.setVec(gAgent.getPosGlobalFromAgent(focus_agent)); + } + return mFocusTargetGlobal; + } + else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatarp->isSitting() && mSitCameraReferenceObject.notNull()) + { + // sit camera + LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition(); + LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation(); + + LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot); + return gAgent.getPosGlobalFromAgent(target_pos); + } + else + { + return gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(); + } } LLVector3d LLAgentCamera::calcThirdPersonFocusOffset() { - // ...offset from avatar - LLVector3d focus_offset; - LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion(); - if (isAgentAvatarValid() && gAgentAvatarp->getParent()) - { - agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation(); - } - - focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, ""); - return focus_offset * agent_rot; + // ...offset from avatar + LLVector3d focus_offset; + LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion(); + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation(); + } + + focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, ""); + return focus_offset * agent_rot; } void LLAgentCamera::setupSitCamera() { - // agent frame entering this function is in world coordinates - if (isAgentAvatarValid() && gAgentAvatarp->getParent()) - { - LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); - // slam agent coordinate frame to proper parent local version - LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - gAgent.resetAxes(at_axis * ~parent_rot); - } + // agent frame entering this function is in world coordinates + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); + // slam agent coordinate frame to proper parent local version + LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis(); + at_axis.mV[VZ] = 0.f; + at_axis.normalize(); + gAgent.resetAxes(at_axis * ~parent_rot); + } } //----------------------------------------------------------------------------- @@ -1624,7 +1624,7 @@ void LLAgentCamera::setupSitCamera() //----------------------------------------------------------------------------- const LLVector3 &LLAgentCamera::getCameraPositionAgent() const { - return LLViewerCamera::getInstance()->getOrigin(); + return LLViewerCamera::getInstance()->getOrigin(); } //----------------------------------------------------------------------------- @@ -1632,39 +1632,39 @@ const LLVector3 &LLAgentCamera::getCameraPositionAgent() const //----------------------------------------------------------------------------- LLVector3d LLAgentCamera::getCameraPositionGlobal() const { - return gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()); + return gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()); } //----------------------------------------------------------------------------- // calcCameraFOVZoomFactor() //----------------------------------------------------------------------------- -F32 LLAgentCamera::calcCameraFOVZoomFactor() +F32 LLAgentCamera::calcCameraFOVZoomFactor() { - LLVector3 camera_offset_dir; - camera_offset_dir.setVec(mCameraFocusOffset); - - if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - return 0.f; - } - else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar) - { - // don't FOV zoom on mostly transparent objects - F32 obj_min_dist = 0.f; - calcCameraMinDistance(obj_min_dist); - F32 current_distance = llmax(0.001f, camera_offset_dir.magVec()); - - mFocusObjectDist = obj_min_dist - current_distance; - - F32 new_fov_zoom = llclamp(mFocusObjectDist / current_distance, 0.f, 1000.f); - return new_fov_zoom; - } - else // focusing on land or avatar - { - // keep old field of view until user changes focus explicitly - return mCameraFOVZoomFactor; - //return 0.f; - } + LLVector3 camera_offset_dir; + camera_offset_dir.setVec(mCameraFocusOffset); + + if (mCameraMode == CAMERA_MODE_MOUSELOOK) + { + return 0.f; + } + else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar) + { + // don't FOV zoom on mostly transparent objects + F32 obj_min_dist = 0.f; + calcCameraMinDistance(obj_min_dist); + F32 current_distance = llmax(0.001f, camera_offset_dir.magVec()); + + mFocusObjectDist = obj_min_dist - current_distance; + + F32 new_fov_zoom = llclamp(mFocusObjectDist / current_distance, 0.f, 1000.f); + return new_fov_zoom; + } + else // focusing on land or avatar + { + // keep old field of view until user changes focus explicitly + return mCameraFOVZoomFactor; + //return 0.f; + } } //----------------------------------------------------------------------------- @@ -1672,268 +1672,268 @@ F32 LLAgentCamera::calcCameraFOVZoomFactor() //----------------------------------------------------------------------------- LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) { - // Compute base camera position and look-at points. - F32 camera_land_height; - LLVector3d frame_center_global = !isAgentAvatarValid() ? - gAgent.getPositionGlobal() : - gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition()); - - BOOL isConstrained = FALSE; - LLVector3d head_offset; - head_offset.setVec(mThirdPersonHeadOffset); - - LLVector3d camera_position_global; - - if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar) - { - camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition()); - } - else if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull()) - { - LL_WARNS() << "Null avatar drawable!" << LL_ENDL; - return LLVector3d::zero; - } - head_offset.clearVec(); - if (gAgentAvatarp->isSitting() && gAgentAvatarp->getParent()) - { - gAgentAvatarp->updateHeadOffset(); - head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX]; - head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY]; - head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f; - const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix(); - camera_position_global = gAgent.getPosGlobalFromAgent - ((gAgentAvatarp->getPosition()+ - LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat); - } - else - { - head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ]; - if (gAgentAvatarp->isSitting()) - { - head_offset.mdV[VZ] += 0.1; - } - camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());//frame_center_global; - head_offset = head_offset * gAgentAvatarp->getRenderRotation(); - camera_position_global = camera_position_global + head_offset; - } - } - else if (mCameraMode == CAMERA_MODE_THIRD_PERSON && mFocusOnAvatar) - { - LLVector3 local_camera_offset; - F32 camera_distance = 0.f; - - if (mSitCameraEnabled - && isAgentAvatarValid() - && gAgentAvatarp->isSitting() - && mSitCameraReferenceObject.notNull()) - { - // sit camera - LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition(); - LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation(); - - LLVector3 target_pos = object_pos + (mSitCameraPos * object_rot); - - camera_position_global = gAgent.getPosGlobalFromAgent(target_pos); - } - else - { - local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale"); - - // are we sitting down? - if (isAgentAvatarValid() && gAgentAvatarp->getParent()) - { - LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); - // slam agent coordinate frame to proper parent local version - LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis() * parent_rot; - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - gAgent.resetAxes(at_axis * ~parent_rot); - - local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot; - } - else - { - local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset ); - } - - if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting())) - { - LLVector3 plane_normal; - plane_normal.setVec(mCameraCollidePlane.mV); - - F32 offset_dot_norm = local_camera_offset * plane_normal; - if (llabs(offset_dot_norm) < 0.001f) - { - offset_dot_norm = 0.001f; - } - - camera_distance = local_camera_offset.normalize(); - - F32 pos_dot_norm = gAgent.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal; - - // if agent is outside the colliding half-plane - if (pos_dot_norm > mCameraCollidePlane.mV[VW]) - { - // check to see if camera is on the opposite side (inside) the half-plane - if (offset_dot_norm + pos_dot_norm < mCameraCollidePlane.mV[VW]) - { - // diminish offset by factor to push it back outside the half-plane - camera_distance *= (pos_dot_norm - mCameraCollidePlane.mV[VW] - CAMERA_COLLIDE_EPSILON) / -offset_dot_norm; - } - } - else - { - if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW]) - { - camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm; - } - } - } - else - { - camera_distance = local_camera_offset.normalize(); - } - - mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE); - - if (mTargetCameraDistance != mCurrentCameraDistance) - { - F32 camera_lerp_amt = LLSmoothInterpolation::getInterpolant(CAMERA_ZOOM_HALF_LIFE); - - mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt); - } - - // Make the camera distance current - local_camera_offset *= mCurrentCameraDistance; - - // set the global camera position - LLVector3d camera_offset; - - camera_offset.setVec( local_camera_offset ); - camera_position_global = frame_center_global + head_offset + camera_offset; - - if (isAgentAvatarValid()) - { - LLVector3d camera_lag_d; - F32 lag_interp = LLSmoothInterpolation::getInterpolant(CAMERA_LAG_HALF_LIFE); - LLVector3 target_lag; - LLVector3 vel = gAgent.getVelocity(); - - // lag by appropriate amount for flying - F32 time_in_air = gAgentAvatarp->mTimeInAir.getElapsedTimeF32(); - if(!mCameraAnimating && gAgentAvatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) - { - LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis(); - frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector()); - frame_at_axis.normalize(); - - //transition smoothly in air mode, to avoid camera pop - F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME; - u = llclamp(u, 0.f, 1.f); - - lag_interp *= u; - - if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatarp->getID()) - { - // disable camera lag when using mouse-directed steering - target_lag.clearVec(); - } - else - { - target_lag = vel * gSavedSettings.getF32("DynamicCameraStrength") / 30.f; - } - - mCameraLag = lerp(mCameraLag, target_lag, lag_interp); - - F32 lag_dist = mCameraLag.magVec(); - if (lag_dist > MAX_CAMERA_LAG) - { - mCameraLag = mCameraLag * MAX_CAMERA_LAG / lag_dist; - } - - // clamp camera lag so that avatar is always in front - F32 dot = (mCameraLag - (frame_at_axis * (MIN_CAMERA_LAG * u))) * frame_at_axis; - if (dot < -(MIN_CAMERA_LAG * u)) - { - mCameraLag -= (dot + (MIN_CAMERA_LAG * u)) * frame_at_axis; - } - } - else - { - mCameraLag = lerp(mCameraLag, LLVector3::zero, LLSmoothInterpolation::getInterpolant(0.15f)); - } - - camera_lag_d.setVec(mCameraLag); - camera_position_global = camera_position_global - camera_lag_d; - } - } - } - else - { - LLVector3d focusPosGlobal = calcFocusPositionTargetGlobal(); - // camera gets pushed out later wrt mCameraFOVZoomFactor...this is "raw" value - camera_position_global = focusPosGlobal + mCameraFocusOffset; - } - - if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike()) - { - LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global); - bool constrain = true; - if(regionp && regionp->canManageEstate()) - { - constrain = false; - } - if(constrain) - { - F32 max_dist = (CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode) ? APPEARANCE_MAX_ZOOM : mDrawDistance; - - LLVector3d camera_offset = camera_position_global - gAgent.getPositionGlobal(); - F32 camera_distance = (F32)camera_offset.magVec(); - - if(camera_distance > max_dist) - { - camera_position_global = gAgent.getPositionGlobal() + (max_dist/camera_distance)*camera_offset; - isConstrained = TRUE; - } - } + // Compute base camera position and look-at points. + F32 camera_land_height; + LLVector3d frame_center_global = !isAgentAvatarValid() ? + gAgent.getPositionGlobal() : + gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition()); + + BOOL isConstrained = FALSE; + LLVector3d head_offset; + head_offset.setVec(mThirdPersonHeadOffset); + + LLVector3d camera_position_global; + + if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar) + { + camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition()); + } + else if (mCameraMode == CAMERA_MODE_MOUSELOOK) + { + if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull()) + { + LL_WARNS() << "Null avatar drawable!" << LL_ENDL; + return LLVector3d::zero; + } + head_offset.clearVec(); + if (gAgentAvatarp->isSitting() && gAgentAvatarp->getParent()) + { + gAgentAvatarp->updateHeadOffset(); + head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX]; + head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY]; + head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f; + const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix(); + camera_position_global = gAgent.getPosGlobalFromAgent + ((gAgentAvatarp->getPosition()+ + LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat); + } + else + { + head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ]; + if (gAgentAvatarp->isSitting()) + { + head_offset.mdV[VZ] += 0.1; + } + camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());//frame_center_global; + head_offset = head_offset * gAgentAvatarp->getRenderRotation(); + camera_position_global = camera_position_global + head_offset; + } + } + else if (mCameraMode == CAMERA_MODE_THIRD_PERSON && mFocusOnAvatar) + { + LLVector3 local_camera_offset; + F32 camera_distance = 0.f; + + if (mSitCameraEnabled + && isAgentAvatarValid() + && gAgentAvatarp->isSitting() + && mSitCameraReferenceObject.notNull()) + { + // sit camera + LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition(); + LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation(); + + LLVector3 target_pos = object_pos + (mSitCameraPos * object_rot); + + camera_position_global = gAgent.getPosGlobalFromAgent(target_pos); + } + else + { + local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale"); + + // are we sitting down? + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); + // slam agent coordinate frame to proper parent local version + LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis() * parent_rot; + at_axis.mV[VZ] = 0.f; + at_axis.normalize(); + gAgent.resetAxes(at_axis * ~parent_rot); + + local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot; + } + else + { + local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset ); + } + + if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting())) + { + LLVector3 plane_normal; + plane_normal.setVec(mCameraCollidePlane.mV); + + F32 offset_dot_norm = local_camera_offset * plane_normal; + if (llabs(offset_dot_norm) < 0.001f) + { + offset_dot_norm = 0.001f; + } + + camera_distance = local_camera_offset.normalize(); + + F32 pos_dot_norm = gAgent.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal; + + // if agent is outside the colliding half-plane + if (pos_dot_norm > mCameraCollidePlane.mV[VW]) + { + // check to see if camera is on the opposite side (inside) the half-plane + if (offset_dot_norm + pos_dot_norm < mCameraCollidePlane.mV[VW]) + { + // diminish offset by factor to push it back outside the half-plane + camera_distance *= (pos_dot_norm - mCameraCollidePlane.mV[VW] - CAMERA_COLLIDE_EPSILON) / -offset_dot_norm; + } + } + else + { + if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW]) + { + camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm; + } + } + } + else + { + camera_distance = local_camera_offset.normalize(); + } + + mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE); + + if (mTargetCameraDistance != mCurrentCameraDistance) + { + F32 camera_lerp_amt = LLSmoothInterpolation::getInterpolant(CAMERA_ZOOM_HALF_LIFE); + + mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt); + } + + // Make the camera distance current + local_camera_offset *= mCurrentCameraDistance; + + // set the global camera position + LLVector3d camera_offset; + + camera_offset.setVec( local_camera_offset ); + camera_position_global = frame_center_global + head_offset + camera_offset; + + if (isAgentAvatarValid()) + { + LLVector3d camera_lag_d; + F32 lag_interp = LLSmoothInterpolation::getInterpolant(CAMERA_LAG_HALF_LIFE); + LLVector3 target_lag; + LLVector3 vel = gAgent.getVelocity(); + + // lag by appropriate amount for flying + F32 time_in_air = gAgentAvatarp->mTimeInAir.getElapsedTimeF32(); + if(!mCameraAnimating && gAgentAvatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) + { + LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis(); + frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector()); + frame_at_axis.normalize(); + + //transition smoothly in air mode, to avoid camera pop + F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME; + u = llclamp(u, 0.f, 1.f); + + lag_interp *= u; + + if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatarp->getID()) + { + // disable camera lag when using mouse-directed steering + target_lag.clearVec(); + } + else + { + target_lag = vel * gSavedSettings.getF32("DynamicCameraStrength") / 30.f; + } + + mCameraLag = lerp(mCameraLag, target_lag, lag_interp); + + F32 lag_dist = mCameraLag.magVec(); + if (lag_dist > MAX_CAMERA_LAG) + { + mCameraLag = mCameraLag * MAX_CAMERA_LAG / lag_dist; + } + + // clamp camera lag so that avatar is always in front + F32 dot = (mCameraLag - (frame_at_axis * (MIN_CAMERA_LAG * u))) * frame_at_axis; + if (dot < -(MIN_CAMERA_LAG * u)) + { + mCameraLag -= (dot + (MIN_CAMERA_LAG * u)) * frame_at_axis; + } + } + else + { + mCameraLag = lerp(mCameraLag, LLVector3::zero, LLSmoothInterpolation::getInterpolant(0.15f)); + } + + camera_lag_d.setVec(mCameraLag); + camera_position_global = camera_position_global - camera_lag_d; + } + } + } + else + { + LLVector3d focusPosGlobal = calcFocusPositionTargetGlobal(); + // camera gets pushed out later wrt mCameraFOVZoomFactor...this is "raw" value + camera_position_global = focusPosGlobal + mCameraFocusOffset; + } + + if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike()) + { + LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global); + bool constrain = true; + if(regionp && regionp->canManageEstate()) + { + constrain = false; + } + if(constrain) + { + F32 max_dist = (CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode) ? APPEARANCE_MAX_ZOOM : mDrawDistance; + + LLVector3d camera_offset = camera_position_global - gAgent.getPositionGlobal(); + F32 camera_distance = (F32)camera_offset.magVec(); + + if(camera_distance > max_dist) + { + camera_position_global = gAgent.getPositionGlobal() + (max_dist/camera_distance)*camera_offset; + isConstrained = TRUE; + } + } // JC - Could constrain camera based on parcel stuff here. -// LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global); -// -// if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global))) -// { -// camera_position_global = last_position_global; +// LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global); +// +// if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global))) +// { +// camera_position_global = last_position_global; // -// isConstrained = TRUE; -// } - } +// isConstrained = TRUE; +// } + } - // Don't let camera go underground - F32 camera_min_off_ground = getCameraMinOffGround(); + // Don't let camera go underground + F32 camera_min_off_ground = getCameraMinOffGround(); - camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global); + camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global); - if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground) - { - camera_position_global.mdV[VZ] = camera_land_height + camera_min_off_ground; - isConstrained = TRUE; - } + if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground) + { + camera_position_global.mdV[VZ] = camera_land_height + camera_min_off_ground; + isConstrained = TRUE; + } - if (hit_limit) - { - *hit_limit = isConstrained; - } + if (hit_limit) + { + *hit_limit = isConstrained; + } - return camera_position_global; + return camera_position_global; } LLVector3 LLAgentCamera::getCameraOffsetInitial() { - return convert_from_llsd<LLVector3>(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, ""); + return convert_from_llsd<LLVector3>(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, ""); } F32 LLAgentCamera::getCameraMaxZoomDistance() @@ -1949,48 +1949,48 @@ F32 LLAgentCamera::getCameraMaxZoomDistance() //----------------------------------------------------------------------------- void LLAgentCamera::handleScrollWheel(S32 clicks) { - if (mCameraMode == CAMERA_MODE_FOLLOW && getFocusOnAvatar()) - { - if (!mFollowCam.getPositionLocked()) // not if the followCam position is locked in place - { - mFollowCam.zoom(clicks); - if (mFollowCam.isZoomedToMinimumDistance()) - { - changeCameraToMouselook(FALSE); - } - } - } - else - { - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2); - - // Block if camera is animating - if (mCameraAnimating) - { - return; - } - - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - F32 zoom_factor = (F32)pow(0.8, -clicks); - cameraZoomIn(zoom_factor); - } - else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON)) - { - F32 camera_offset_initial_mag = getCameraOffsetInitial().magVec(); - - F32 current_zoom_fraction = mTargetCameraDistance / (camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale")); - current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks); - - cameraOrbitIn(current_zoom_fraction * camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale")); - } - else - { - F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec(); - cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks))); - } - } + if (mCameraMode == CAMERA_MODE_FOLLOW && getFocusOnAvatar()) + { + if (!mFollowCam.getPositionLocked()) // not if the followCam position is locked in place + { + mFollowCam.zoom(clicks); + if (mFollowCam.isZoomedToMinimumDistance()) + { + changeCameraToMouselook(FALSE); + } + } + } + else + { + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2); + + // Block if camera is animating + if (mCameraAnimating) + { + return; + } + + if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) + { + F32 zoom_factor = (F32)pow(0.8, -clicks); + cameraZoomIn(zoom_factor); + } + else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON)) + { + F32 camera_offset_initial_mag = getCameraOffsetInitial().magVec(); + + F32 current_zoom_fraction = mTargetCameraDistance / (camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale")); + current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks); + + cameraOrbitIn(current_zoom_fraction * camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale")); + } + else + { + F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec(); + cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks))); + } + } } @@ -1999,21 +1999,21 @@ void LLAgentCamera::handleScrollWheel(S32 clicks) //----------------------------------------------------------------------------- F32 LLAgentCamera::getCameraMinOffGround() { - if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - return 0.f; - } - else - { - if (gSavedSettings.getBOOL("DisableCameraConstraints")) - { - return -1000.f; - } - else - { - return 0.5f; - } - } + if (mCameraMode == CAMERA_MODE_MOUSELOOK) + { + return 0.f; + } + else + { + if (gSavedSettings.getBOOL("DisableCameraConstraints")) + { + return -1000.f; + } + else + { + return 0.5f; + } + } } @@ -2022,15 +2022,15 @@ F32 LLAgentCamera::getCameraMinOffGround() //----------------------------------------------------------------------------- void LLAgentCamera::resetCamera() { - // Remove any pitch from the avatar - LLVector3 at = gAgent.getFrameAgent().getAtAxis(); - at.mV[VZ] = 0.f; - at.normalize(); - gAgent.resetAxes(at); - // have to explicitly clear field of view zoom now - mCameraFOVZoomFactor = 0.f; - - updateCamera(); + // Remove any pitch from the avatar + LLVector3 at = gAgent.getFrameAgent().getAtAxis(); + at.mV[VZ] = 0.f; + at.normalize(); + gAgent.resetAxes(at); + // have to explicitly clear field of view zoom now + mCameraFOVZoomFactor = 0.f; + + updateCamera(); } //----------------------------------------------------------------------------- @@ -2038,58 +2038,58 @@ void LLAgentCamera::resetCamera() //----------------------------------------------------------------------------- void LLAgentCamera::changeCameraToMouselook(BOOL animate) { - if (!gSavedSettings.getBOOL("EnableMouselook") - || LLViewerJoystick::getInstance()->getOverrideCamera()) - { - return; - } - - // visibility changes at end of animation - gViewerWindow->getWindow()->resetBusyCount(); - - // Menus should not remain open on switching to mouselook... - LLMenuGL::sMenuContainer->hideMenus(); - LLUI::clearPopups(); - - // unpause avatar animation - gAgent.unpauseAnimation(); - - LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); - - if (isAgentAvatarValid()) - { - gAgentAvatarp->stopMotion(ANIM_AGENT_BODY_NOISE); - gAgentAvatarp->stopMotion(ANIM_AGENT_BREATHE_ROT); - } - - //gViewerWindow->stopGrab(); - LLSelectMgr::getInstance()->deselectAll(); - gViewerWindow->hideCursor(); - gViewerWindow->moveCursorToCenter(); - - if (mCameraMode != CAMERA_MODE_MOUSELOOK) - { - gFocusMgr.setKeyboardFocus(NULL); - - updateLastCamera(); - mCameraMode = CAMERA_MODE_MOUSELOOK; - const U32 old_flags = gAgent.getControlFlags(); - gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != gAgent.getControlFlags()) - { - gAgent.setFlagsDirty(); - } - - if (animate) - { - startCameraAnimation(); - } - else - { - mCameraAnimating = FALSE; - gAgent.endAnimationUpdateUI(); - } - } + if (!gSavedSettings.getBOOL("EnableMouselook") + || LLViewerJoystick::getInstance()->getOverrideCamera()) + { + return; + } + + // visibility changes at end of animation + gViewerWindow->getWindow()->resetBusyCount(); + + // Menus should not remain open on switching to mouselook... + LLMenuGL::sMenuContainer->hideMenus(); + LLUI::clearPopups(); + + // unpause avatar animation + gAgent.unpauseAnimation(); + + LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); + + if (isAgentAvatarValid()) + { + gAgentAvatarp->stopMotion(ANIM_AGENT_BODY_NOISE); + gAgentAvatarp->stopMotion(ANIM_AGENT_BREATHE_ROT); + } + + //gViewerWindow->stopGrab(); + LLSelectMgr::getInstance()->deselectAll(); + gViewerWindow->hideCursor(); + gViewerWindow->moveCursorToCenter(); + + if (mCameraMode != CAMERA_MODE_MOUSELOOK) + { + gFocusMgr.setKeyboardFocus(NULL); + + updateLastCamera(); + mCameraMode = CAMERA_MODE_MOUSELOOK; + const U32 old_flags = gAgent.getControlFlags(); + gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK); + if (old_flags != gAgent.getControlFlags()) + { + gAgent.setFlagsDirty(); + } + + if (animate) + { + startCameraAnimation(); + } + else + { + mCameraAnimating = FALSE; + gAgent.endAnimationUpdateUI(); + } + } } @@ -2098,24 +2098,24 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate) //----------------------------------------------------------------------------- void LLAgentCamera::changeCameraToDefault() { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - return; - } - - if (LLFollowCamMgr::getActiveFollowCamParams()) - { - changeCameraToFollow(); - } - else - { - changeCameraToThirdPerson(); - } - if (gSavedSettings.getBOOL("HideUIControls")) - { - gViewerWindow->setUIVisibility(false); - LLPanelStandStopFlying::getInstance()->setVisible(false); - } + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + return; + } + + if (LLFollowCamMgr::getActiveFollowCamParams()) + { + changeCameraToFollow(); + } + else + { + changeCameraToThirdPerson(); + } + if (gSavedSettings.getBOOL("HideUIControls")) + { + gViewerWindow->setUIVisibility(false); + LLPanelStandStopFlying::getInstance()->setVisible(false); + } } @@ -2124,53 +2124,53 @@ void LLAgentCamera::changeCameraToDefault() //----------------------------------------------------------------------------- void LLAgentCamera::changeCameraToFollow(BOOL animate) { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - return; - } - - if(mCameraMode != CAMERA_MODE_FOLLOW) - { - if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - animate = FALSE; - } - startCameraAnimation(); - - updateLastCamera(); - mCameraMode = CAMERA_MODE_FOLLOW; - - // bang-in the current focus, position, and up vector of the follow cam - mFollowCam.reset(mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis); - - if (gBasicToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - } - - if (isAgentAvatarValid()) - { - // SL-315 - gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero); - gAgentAvatarp->startMotion( ANIM_AGENT_BODY_NOISE ); - gAgentAvatarp->startMotion( ANIM_AGENT_BREATHE_ROT ); - } - - // unpause avatar animation - gAgent.unpauseAnimation(); - - gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); - - if (animate) - { - startCameraAnimation(); - } - else - { - mCameraAnimating = FALSE; - gAgent.endAnimationUpdateUI(); - } - } + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + return; + } + + if(mCameraMode != CAMERA_MODE_FOLLOW) + { + if (mCameraMode == CAMERA_MODE_MOUSELOOK) + { + animate = FALSE; + } + startCameraAnimation(); + + updateLastCamera(); + mCameraMode = CAMERA_MODE_FOLLOW; + + // bang-in the current focus, position, and up vector of the follow cam + mFollowCam.reset(mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis); + + if (gBasicToolset) + { + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); + } + + if (isAgentAvatarValid()) + { + // SL-315 + gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero); + gAgentAvatarp->startMotion( ANIM_AGENT_BODY_NOISE ); + gAgentAvatarp->startMotion( ANIM_AGENT_BREATHE_ROT ); + } + + // unpause avatar animation + gAgent.unpauseAnimation(); + + gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); + + if (animate) + { + startCameraAnimation(); + } + else + { + mCameraAnimating = FALSE; + gAgent.endAnimationUpdateUI(); + } + } } //----------------------------------------------------------------------------- @@ -2178,77 +2178,77 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate) //----------------------------------------------------------------------------- void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - return; - } - - gViewerWindow->getWindow()->resetBusyCount(); - - mCameraZoomFraction = INITIAL_ZOOM_FRACTION; - - if (isAgentAvatarValid()) - { - if (!gAgentAvatarp->isSitting()) - { - // SL-315 - gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero); - } - gAgentAvatarp->startMotion(ANIM_AGENT_BODY_NOISE); - gAgentAvatarp->startMotion(ANIM_AGENT_BREATHE_ROT); - } - - LLVector3 at_axis; - - // unpause avatar animation - gAgent.unpauseAnimation(); - - if (mCameraMode != CAMERA_MODE_THIRD_PERSON) - { - if (gBasicToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - } - - mCameraLag.clearVec(); - if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - mCurrentCameraDistance = MIN_CAMERA_DISTANCE; - mTargetCameraDistance = MIN_CAMERA_DISTANCE; - animate = FALSE; - } - updateLastCamera(); - mCameraMode = CAMERA_MODE_THIRD_PERSON; - gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); - } - - // Remove any pitch from the avatar - if (isAgentAvatarValid() && gAgentAvatarp->getParent()) - { - LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); - at_axis = LLViewerCamera::getInstance()->getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - gAgent.resetAxes(at_axis * ~obj_rot); - } - else - { - at_axis = gAgent.getFrameAgent().getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - gAgent.resetAxes(at_axis); - } - - - if (animate) - { - startCameraAnimation(); - } - else - { - mCameraAnimating = FALSE; - gAgent.endAnimationUpdateUI(); - } + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + return; + } + + gViewerWindow->getWindow()->resetBusyCount(); + + mCameraZoomFraction = INITIAL_ZOOM_FRACTION; + + if (isAgentAvatarValid()) + { + if (!gAgentAvatarp->isSitting()) + { + // SL-315 + gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero); + } + gAgentAvatarp->startMotion(ANIM_AGENT_BODY_NOISE); + gAgentAvatarp->startMotion(ANIM_AGENT_BREATHE_ROT); + } + + LLVector3 at_axis; + + // unpause avatar animation + gAgent.unpauseAnimation(); + + if (mCameraMode != CAMERA_MODE_THIRD_PERSON) + { + if (gBasicToolset) + { + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); + } + + mCameraLag.clearVec(); + if (mCameraMode == CAMERA_MODE_MOUSELOOK) + { + mCurrentCameraDistance = MIN_CAMERA_DISTANCE; + mTargetCameraDistance = MIN_CAMERA_DISTANCE; + animate = FALSE; + } + updateLastCamera(); + mCameraMode = CAMERA_MODE_THIRD_PERSON; + gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); + } + + // Remove any pitch from the avatar + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); + at_axis = LLViewerCamera::getInstance()->getAtAxis(); + at_axis.mV[VZ] = 0.f; + at_axis.normalize(); + gAgent.resetAxes(at_axis * ~obj_rot); + } + else + { + at_axis = gAgent.getFrameAgent().getAtAxis(); + at_axis.mV[VZ] = 0.f; + at_axis.normalize(); + gAgent.resetAxes(at_axis); + } + + + if (animate) + { + startCameraAnimation(); + } + else + { + mCameraAnimating = FALSE; + gAgent.endAnimationUpdateUI(); + } } //----------------------------------------------------------------------------- @@ -2256,81 +2256,81 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) //----------------------------------------------------------------------------- void LLAgentCamera::changeCameraToCustomizeAvatar() { - if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid()) - { - return; - } - - gAgent.standUp(); // force stand up - gViewerWindow->getWindow()->resetBusyCount(); - - if (gFaceEditToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset); - } - - startCameraAnimation(); - - if (mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR) - { - updateLastCamera(); - mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR; - gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); - - gFocusMgr.setKeyboardFocus( NULL ); - gFocusMgr.setMouseCapture( NULL ); - if( gMorphView ) - { - gMorphView->setVisible( TRUE ); - } - // Remove any pitch or rotation from the avatar - LLVector3 at = gAgent.getAtAxis(); - at.mV[VZ] = 0.f; - at.normalize(); - gAgent.resetAxes(at); - - gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); - gAgent.setCustomAnim(TRUE); - gAgentAvatarp->startMotion(ANIM_AGENT_CUSTOMIZE); - LLMotion* turn_motion = gAgentAvatarp->findMotion(ANIM_AGENT_CUSTOMIZE); - - if (turn_motion) - { - // delay camera animation long enough to play through turn animation - setAnimationDuration(turn_motion->getDuration() + CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP); - } - } - - LLVector3 agent_at = gAgent.getAtAxis(); - agent_at.mV[VZ] = 0.f; - agent_at.normalize(); - - // default focus point for customize avatar - LLVector3 focus_target = isAgentAvatarValid() - ? gAgentAvatarp->mHeadp->getWorldPosition() - : gAgent.getPositionAgent(); - - LLVector3d camera_offset(agent_at * -1.0); - // push camera up and out from avatar - camera_offset.mdV[VZ] = 0.1f; - camera_offset *= CUSTOMIZE_AVATAR_CAMERA_DEFAULT_DIST; - LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target); - setAnimationDuration(gSavedSettings.getF32("ZoomTime")); - setCameraPosAndFocusGlobal(focus_target_global + camera_offset, focus_target_global, gAgent.getID()); + if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid()) + { + return; + } + + gAgent.standUp(); // force stand up + gViewerWindow->getWindow()->resetBusyCount(); + + if (gFaceEditToolset) + { + LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset); + } + + startCameraAnimation(); + + if (mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR) + { + updateLastCamera(); + mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR; + gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); + + gFocusMgr.setKeyboardFocus( NULL ); + gFocusMgr.setMouseCapture( NULL ); + if( gMorphView ) + { + gMorphView->setVisible( TRUE ); + } + // Remove any pitch or rotation from the avatar + LLVector3 at = gAgent.getAtAxis(); + at.mV[VZ] = 0.f; + at.normalize(); + gAgent.resetAxes(at); + + gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); + gAgent.setCustomAnim(TRUE); + gAgentAvatarp->startMotion(ANIM_AGENT_CUSTOMIZE); + LLMotion* turn_motion = gAgentAvatarp->findMotion(ANIM_AGENT_CUSTOMIZE); + + if (turn_motion) + { + // delay camera animation long enough to play through turn animation + setAnimationDuration(turn_motion->getDuration() + CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP); + } + } + + LLVector3 agent_at = gAgent.getAtAxis(); + agent_at.mV[VZ] = 0.f; + agent_at.normalize(); + + // default focus point for customize avatar + LLVector3 focus_target = isAgentAvatarValid() + ? gAgentAvatarp->mHeadp->getWorldPosition() + : gAgent.getPositionAgent(); + + LLVector3d camera_offset(agent_at * -1.0); + // push camera up and out from avatar + camera_offset.mdV[VZ] = 0.1f; + camera_offset *= CUSTOMIZE_AVATAR_CAMERA_DEFAULT_DIST; + LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target); + setAnimationDuration(gSavedSettings.getF32("ZoomTime")); + setCameraPosAndFocusGlobal(focus_target_global + camera_offset, focus_target_global, gAgent.getID()); } void LLAgentCamera::switchCameraPreset(ECameraPreset preset) { - //zoom is supposed to be reset for the front and group views - mCameraZoomFraction = 1.f; + //zoom is supposed to be reset for the front and group views + mCameraZoomFraction = 1.f; - //focusing on avatar in that case means following him on movements - mFocusOnAvatar = TRUE; + //focusing on avatar in that case means following him on movements + mFocusOnAvatar = TRUE; - mCameraPreset = preset; + mCameraPreset = preset; - gSavedSettings.setU32("CameraPreset", mCameraPreset); + gSavedSettings.setU32("CameraPreset", mCameraPreset); } @@ -2340,16 +2340,16 @@ void LLAgentCamera::switchCameraPreset(ECameraPreset preset) void LLAgentCamera::setAnimationDuration(F32 duration) { - if (mCameraAnimating) - { - // do not cut any existing camera animation short - F32 animation_left = llmax(0.f, mAnimationDuration - mAnimationTimer.getElapsedTimeF32()); - mAnimationDuration = llmax(duration, animation_left); - } - else - { - mAnimationDuration = duration; - } + if (mCameraAnimating) + { + // do not cut any existing camera animation short + F32 animation_left = llmax(0.f, mAnimationDuration - mAnimationTimer.getElapsedTimeF32()); + mAnimationDuration = llmax(duration, animation_left); + } + else + { + mAnimationDuration = duration; + } } //----------------------------------------------------------------------------- @@ -2357,11 +2357,11 @@ void LLAgentCamera::setAnimationDuration(F32 duration) //----------------------------------------------------------------------------- void LLAgentCamera::startCameraAnimation() { - mAnimationCameraStartGlobal = getCameraPositionGlobal(); - mAnimationFocusStartGlobal = mFocusGlobal; - setAnimationDuration(gSavedSettings.getF32("ZoomTime")); - mAnimationTimer.reset(); - mCameraAnimating = TRUE; + mAnimationCameraStartGlobal = getCameraPositionGlobal(); + mAnimationFocusStartGlobal = mFocusGlobal; + setAnimationDuration(gSavedSettings.getF32("ZoomTime")); + mAnimationTimer.reset(); + mCameraAnimating = TRUE; } //----------------------------------------------------------------------------- @@ -2369,23 +2369,23 @@ void LLAgentCamera::startCameraAnimation() //----------------------------------------------------------------------------- void LLAgentCamera::stopCameraAnimation() { - mCameraAnimating = FALSE; + mCameraAnimating = FALSE; } void LLAgentCamera::clearFocusObject() { - if (mFocusObject.notNull()) - { - startCameraAnimation(); + if (mFocusObject.notNull()) + { + startCameraAnimation(); - setFocusObject(NULL); - mFocusObjectOffset.clearVec(); - } + setFocusObject(NULL); + mFocusObjectOffset.clearVec(); + } } void LLAgentCamera::setFocusObject(LLViewerObject* object) { - mFocusObject = object; + mFocusObject = object; } // Focus on a point, but try to keep camera position stable. @@ -2394,104 +2394,104 @@ void LLAgentCamera::setFocusObject(LLViewerObject* object) //----------------------------------------------------------------------------- void LLAgentCamera::setFocusGlobal(const LLPickInfo& pick) { - LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID); - - if (objectp) - { - // focus on object plus designated offset - // which may or may not be same as pick.mPosGlobal - setFocusGlobal(objectp->getPositionGlobal() + LLVector3d(pick.mObjectOffset), pick.mObjectID); - } - else - { - // focus directly on point where user clicked - setFocusGlobal(pick.mPosGlobal, pick.mObjectID); - } + LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID); + + if (objectp) + { + // focus on object plus designated offset + // which may or may not be same as pick.mPosGlobal + setFocusGlobal(objectp->getPositionGlobal() + LLVector3d(pick.mObjectOffset), pick.mObjectID); + } + else + { + // focus directly on point where user clicked + setFocusGlobal(pick.mPosGlobal, pick.mObjectID); + } } void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id) { - setFocusObject(gObjectList.findObject(object_id)); - LLVector3d old_focus = mFocusTargetGlobal; - LLViewerObject *focus_obj = mFocusObject; - - // if focus has changed - if (old_focus != focus) - { - if (focus.isExactlyZero()) - { - if (isAgentAvatarValid()) - { - mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition()); - } - else - { - mFocusTargetGlobal = gAgent.getPositionGlobal(); - } - mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal; - mCameraFocusOffset = mCameraFocusOffsetTarget; - setLookAt(LOOKAT_TARGET_CLEAR); - } - else - { - mFocusTargetGlobal = focus; - if (!focus_obj) - { - mCameraFOVZoomFactor = 0.f; - } - - mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal; - - startCameraAnimation(); - - if (focus_obj) - { - if (focus_obj->isAvatar()) - { - setLookAt(LOOKAT_TARGET_FOCUS, focus_obj); - } - else - { - setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgent.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation()); - } - } - else - { - setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); - } - } - } - else // focus == mFocusTargetGlobal - { - if (focus.isExactlyZero()) - { - if (isAgentAvatarValid()) - { - mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition()); - } - else - { - mFocusTargetGlobal = gAgent.getPositionGlobal(); - } - } - mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);; - mCameraFocusOffset = mCameraFocusOffsetTarget; - } - - if (mFocusObject.notNull()) - { - // for attachments, make offset relative to avatar, not the attachment - if (mFocusObject->isAttachment()) - { - while (mFocusObject.notNull() && !mFocusObject->isAvatar()) - { - mFocusObject = (LLViewerObject*) mFocusObject->getParent(); - } - setFocusObject((LLViewerObject*)mFocusObject); - } - updateFocusOffset(); - } + setFocusObject(gObjectList.findObject(object_id)); + LLVector3d old_focus = mFocusTargetGlobal; + LLViewerObject *focus_obj = mFocusObject; + + // if focus has changed + if (old_focus != focus) + { + if (focus.isExactlyZero()) + { + if (isAgentAvatarValid()) + { + mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition()); + } + else + { + mFocusTargetGlobal = gAgent.getPositionGlobal(); + } + mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal; + mCameraFocusOffset = mCameraFocusOffsetTarget; + setLookAt(LOOKAT_TARGET_CLEAR); + } + else + { + mFocusTargetGlobal = focus; + if (!focus_obj) + { + mCameraFOVZoomFactor = 0.f; + } + + mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal; + + startCameraAnimation(); + + if (focus_obj) + { + if (focus_obj->isAvatar()) + { + setLookAt(LOOKAT_TARGET_FOCUS, focus_obj); + } + else + { + setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgent.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation()); + } + } + else + { + setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); + } + } + } + else // focus == mFocusTargetGlobal + { + if (focus.isExactlyZero()) + { + if (isAgentAvatarValid()) + { + mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition()); + } + else + { + mFocusTargetGlobal = gAgent.getPositionGlobal(); + } + } + mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);; + mCameraFocusOffset = mCameraFocusOffsetTarget; + } + + if (mFocusObject.notNull()) + { + // for attachments, make offset relative to avatar, not the attachment + if (mFocusObject->isAttachment()) + { + while (mFocusObject.notNull() && !mFocusObject->isAvatar()) + { + mFocusObject = (LLViewerObject*) mFocusObject->getParent(); + } + setFocusObject((LLViewerObject*)mFocusObject); + } + updateFocusOffset(); + } } // Used for avatar customization @@ -2500,48 +2500,48 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object //----------------------------------------------------------------------------- void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, const LLVector3d& focus, const LLUUID &object_id) { - LLVector3d old_focus = mFocusTargetGlobal.isExactlyZero() ? focus : mFocusTargetGlobal; - - F64 focus_delta_squared = (old_focus - focus).magVecSquared(); - const F64 ANIM_EPSILON_SQUARED = 0.0001; - if (focus_delta_squared > ANIM_EPSILON_SQUARED) - { - startCameraAnimation(); - } - - //LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) ); - setFocusObject(gObjectList.findObject(object_id)); - mFocusTargetGlobal = focus; - mCameraFocusOffsetTarget = camera_pos - focus; - mCameraFocusOffset = mCameraFocusOffsetTarget; - - if (mFocusObject) - { - if (mFocusObject->isAvatar()) - { - setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject); - } - else - { - setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgent.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation()); - } - } - else - { - setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); - } - - if (mCameraAnimating) - { - const F64 ANIM_METERS_PER_SECOND = 10.0; - const F64 MIN_ANIM_SECONDS = 0.5; - const F64 MAX_ANIM_SECONDS = 10.0; - F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND ); - anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS ); - setAnimationDuration( (F32)anim_duration ); - } - - updateFocusOffset(); + LLVector3d old_focus = mFocusTargetGlobal.isExactlyZero() ? focus : mFocusTargetGlobal; + + F64 focus_delta_squared = (old_focus - focus).magVecSquared(); + const F64 ANIM_EPSILON_SQUARED = 0.0001; + if (focus_delta_squared > ANIM_EPSILON_SQUARED) + { + startCameraAnimation(); + } + + //LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) ); + setFocusObject(gObjectList.findObject(object_id)); + mFocusTargetGlobal = focus; + mCameraFocusOffsetTarget = camera_pos - focus; + mCameraFocusOffset = mCameraFocusOffsetTarget; + + if (mFocusObject) + { + if (mFocusObject->isAvatar()) + { + setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject); + } + else + { + setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgent.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation()); + } + } + else + { + setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); + } + + if (mCameraAnimating) + { + const F64 ANIM_METERS_PER_SECOND = 10.0; + const F64 MIN_ANIM_SECONDS = 0.5; + const F64 MAX_ANIM_SECONDS = 10.0; + F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND ); + anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS ); + setAnimationDuration( (F32)anim_duration ); + } + + updateFocusOffset(); } //----------------------------------------------------------------------------- @@ -2549,27 +2549,27 @@ void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, con //----------------------------------------------------------------------------- void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos, const LLVector3 &camera_focus) { - BOOL camera_enabled = !object_id.isNull(); - - if (camera_enabled) - { - LLViewerObject *reference_object = gObjectList.findObject(object_id); - if (reference_object) - { - //convert to root object relative? - mSitCameraPos = camera_pos; - mSitCameraFocus = camera_focus; - mSitCameraReferenceObject = reference_object; - mSitCameraEnabled = TRUE; - } - } - else - { - mSitCameraPos.clearVec(); - mSitCameraFocus.clearVec(); - mSitCameraReferenceObject = NULL; - mSitCameraEnabled = FALSE; - } + BOOL camera_enabled = !object_id.isNull(); + + if (camera_enabled) + { + LLViewerObject *reference_object = gObjectList.findObject(object_id); + if (reference_object) + { + //convert to root object relative? + mSitCameraPos = camera_pos; + mSitCameraFocus = camera_focus; + mSitCameraReferenceObject = reference_object; + mSitCameraEnabled = TRUE; + } + } + else + { + mSitCameraPos.clearVec(); + mSitCameraFocus.clearVec(); + mSitCameraReferenceObject = NULL; + mSitCameraEnabled = FALSE; + } } //----------------------------------------------------------------------------- @@ -2577,80 +2577,80 @@ void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camer //----------------------------------------------------------------------------- void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) { - if (focus_on_avatar != mFocusOnAvatar) - { - if (animate) - { - startCameraAnimation(); - } - else - { - stopCameraAnimation(); - } - } - - //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) - { - setFocusGlobal(LLVector3d::zero); - mCameraFOVZoomFactor = 0.f; - if (mCameraMode == CAMERA_MODE_THIRD_PERSON) - { - LLVector3 at_axis; - if (isAgentAvatarValid() && gAgentAvatarp->getParent()) - { - LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); - at_axis = LLViewerCamera::getInstance()->getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - gAgent.resetAxes(at_axis * ~obj_rot); - } - else - { - at_axis = LLViewerCamera::getInstance()->getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - gAgent.resetAxes(at_axis); - } - } - } - // unlocking camera from avatar - else if (mFocusOnAvatar && !focus_on_avatar) - { - // keep camera focus point consistent, even though it is now unlocked - setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID()); - mAllowChangeToFollow = FALSE; - } - - mFocusOnAvatar = focus_on_avatar; + if (focus_on_avatar != mFocusOnAvatar) + { + if (animate) + { + startCameraAnimation(); + } + else + { + stopCameraAnimation(); + } + } + + //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) + { + setFocusGlobal(LLVector3d::zero); + mCameraFOVZoomFactor = 0.f; + if (mCameraMode == CAMERA_MODE_THIRD_PERSON) + { + LLVector3 at_axis; + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); + at_axis = LLViewerCamera::getInstance()->getAtAxis(); + at_axis.mV[VZ] = 0.f; + at_axis.normalize(); + gAgent.resetAxes(at_axis * ~obj_rot); + } + else + { + at_axis = LLViewerCamera::getInstance()->getAtAxis(); + at_axis.mV[VZ] = 0.f; + at_axis.normalize(); + gAgent.resetAxes(at_axis); + } + } + } + // unlocking camera from avatar + else if (mFocusOnAvatar && !focus_on_avatar) + { + // keep camera focus point consistent, even though it is now unlocked + setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID()); + mAllowChangeToFollow = FALSE; + } + + mFocusOnAvatar = focus_on_avatar; } BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position) { - if(object && object->isAttachment()) - { - LLViewerObject* parent = object; - while(parent) - { - if (parent == gAgentAvatarp) - { - // looking at an attachment on ourselves, which we don't want to do - object = gAgentAvatarp; - position.clearVec(); - } - parent = (LLViewerObject*)parent->getParent(); - } - } - if(!mLookAt || mLookAt->isDead()) - { - mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); - mLookAt->setSourceObject(gAgentAvatarp); - } - - return mLookAt->setLookAt(target_type, object, position); + if(object && object->isAttachment()) + { + LLViewerObject* parent = object; + while(parent) + { + if (parent == gAgentAvatarp) + { + // looking at an attachment on ourselves, which we don't want to do + object = gAgentAvatarp; + position.clearVec(); + } + parent = (LLViewerObject*)parent->getParent(); + } + } + if(!mLookAt || mLookAt->isDead()) + { + mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); + mLookAt->setSourceObject(gAgentAvatarp); + } + + return mLookAt->setLookAt(target_type, object, position); } //----------------------------------------------------------------------------- @@ -2658,157 +2658,157 @@ BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, L //----------------------------------------------------------------------------- void LLAgentCamera::lookAtLastChat() { - // Block if camera is animating or not in normal third person camera mode - if (mCameraAnimating || !cameraThirdPerson()) - { - return; - } - - LLViewerObject *chatter = gObjectList.findObject(gAgent.getLastChatter()); - if (!chatter) - { - return; - } - - LLVector3 delta_pos; - if (chatter->isAvatar()) - { - LLVOAvatar *chatter_av = (LLVOAvatar*)chatter; - if (isAgentAvatarValid() && chatter_av->mHeadp) - { - delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatarp->mHeadp->getWorldPosition(); - } - else - { - delta_pos = chatter->getPositionAgent() - gAgent.getPositionAgent(); - } - delta_pos.normalize(); - - gAgent.setControlFlags(AGENT_CONTROL_STOP); - - changeCameraToThirdPerson(); - - LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition(); - LLVector3 left = delta_pos % LLVector3::z_axis; - left.normalize(); - LLVector3 up = left % delta_pos; - up.normalize(); - new_camera_pos -= delta_pos * 0.4f; - new_camera_pos += left * 0.3f; - new_camera_pos += up * 0.2f; - - setFocusOnAvatar(FALSE, FALSE); - - if (chatter_av->mHeadp) - { - setFocusGlobal(gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), gAgent.getLastChatter()); - mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()); - } - else - { - setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter()); - mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); - } - } - else - { - delta_pos = chatter->getRenderPosition() - gAgent.getPositionAgent(); - delta_pos.normalize(); - - gAgent.setControlFlags(AGENT_CONTROL_STOP); - - changeCameraToThirdPerson(); - - LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition(); - LLVector3 left = delta_pos % LLVector3::z_axis; - left.normalize(); - LLVector3 up = left % delta_pos; - up.normalize(); - new_camera_pos -= delta_pos * 0.4f; - new_camera_pos += left * 0.3f; - new_camera_pos += up * 0.2f; - - setFocusOnAvatar(FALSE, FALSE); - - setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter()); - mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); - } + // Block if camera is animating or not in normal third person camera mode + if (mCameraAnimating || !cameraThirdPerson()) + { + return; + } + + LLViewerObject *chatter = gObjectList.findObject(gAgent.getLastChatter()); + if (!chatter) + { + return; + } + + LLVector3 delta_pos; + if (chatter->isAvatar()) + { + LLVOAvatar *chatter_av = (LLVOAvatar*)chatter; + if (isAgentAvatarValid() && chatter_av->mHeadp) + { + delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatarp->mHeadp->getWorldPosition(); + } + else + { + delta_pos = chatter->getPositionAgent() - gAgent.getPositionAgent(); + } + delta_pos.normalize(); + + gAgent.setControlFlags(AGENT_CONTROL_STOP); + + changeCameraToThirdPerson(); + + LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition(); + LLVector3 left = delta_pos % LLVector3::z_axis; + left.normalize(); + LLVector3 up = left % delta_pos; + up.normalize(); + new_camera_pos -= delta_pos * 0.4f; + new_camera_pos += left * 0.3f; + new_camera_pos += up * 0.2f; + + setFocusOnAvatar(FALSE, FALSE); + + if (chatter_av->mHeadp) + { + setFocusGlobal(gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), gAgent.getLastChatter()); + mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()); + } + else + { + setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter()); + mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); + } + } + else + { + delta_pos = chatter->getRenderPosition() - gAgent.getPositionAgent(); + delta_pos.normalize(); + + gAgent.setControlFlags(AGENT_CONTROL_STOP); + + changeCameraToThirdPerson(); + + LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition(); + LLVector3 left = delta_pos % LLVector3::z_axis; + left.normalize(); + LLVector3 up = left % delta_pos; + up.normalize(); + new_camera_pos -= delta_pos * 0.4f; + new_camera_pos += left * 0.3f; + new_camera_pos += up * 0.2f; + + setFocusOnAvatar(FALSE, FALSE); + + setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter()); + mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); + } } bool LLAgentCamera::isfollowCamLocked() { - return mFollowCam.getPositionLocked(); + return mFollowCam.getPositionLocked(); } BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position) { - // disallow pointing at attachments and avatars - if (object && (object->isAttachment() || object->isAvatar())) - { - return FALSE; - } - if (!mPointAt || mPointAt->isDead()) - { - mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); - mPointAt->setSourceObject(gAgentAvatarp); - } - return mPointAt->setPointAt(target_type, object, position); + // disallow pointing at attachments and avatars + if (object && (object->isAttachment() || object->isAvatar())) + { + return FALSE; + } + if (!mPointAt || mPointAt->isDead()) + { + mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); + mPointAt->setSourceObject(gAgentAvatarp); + } + return mPointAt->setPointAt(target_type, object, position); } ELookAtType LLAgentCamera::getLookAtType() { - if (mLookAt) - { - return mLookAt->getLookAtType(); - } - return LOOKAT_TARGET_NONE; + if (mLookAt) + { + return mLookAt->getLookAtType(); + } + return LOOKAT_TARGET_NONE; } EPointAtType LLAgentCamera::getPointAtType() { - if (mPointAt) - { - return mPointAt->getPointAtType(); - } - return POINTAT_TARGET_NONE; + if (mPointAt) + { + return mPointAt->getPointAtType(); + } + return POINTAT_TARGET_NONE; } void LLAgentCamera::clearGeneralKeys() { - mAtKey = 0; - mWalkKey = 0; - mLeftKey = 0; - mUpKey = 0; - mYawKey = 0.f; - mPitchKey = 0.f; + mAtKey = 0; + mWalkKey = 0; + mLeftKey = 0; + mUpKey = 0; + mYawKey = 0.f; + mPitchKey = 0.f; } void LLAgentCamera::clearOrbitKeys() { - mOrbitLeftKey = 0.f; - mOrbitRightKey = 0.f; - mOrbitUpKey = 0.f; - mOrbitDownKey = 0.f; - mOrbitInKey = 0.f; - mOrbitOutKey = 0.f; + mOrbitLeftKey = 0.f; + mOrbitRightKey = 0.f; + mOrbitUpKey = 0.f; + mOrbitDownKey = 0.f; + mOrbitInKey = 0.f; + mOrbitOutKey = 0.f; } void LLAgentCamera::clearPanKeys() { - mPanRightKey = 0.f; - mPanLeftKey = 0.f; - mPanUpKey = 0.f; - mPanDownKey = 0.f; - mPanInKey = 0.f; - mPanOutKey = 0.f; + mPanRightKey = 0.f; + mPanLeftKey = 0.f; + mPanUpKey = 0.f; + mPanDownKey = 0.f; + mPanInKey = 0.f; + mPanOutKey = 0.f; } // static S32 LLAgentCamera::directionToKey(S32 direction) { - if (direction > 0) return 1; - if (direction < 0) return -1; - return 0; + if (direction > 0) return 1; + if (direction < 0) return -1; + return 0; } diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 4575c1501a..27a9891030 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -27,9 +27,9 @@ #ifndef LL_LLAGENTCAMERA_H #define LL_LLAGENTCAMERA_H -#include "llfollowcam.h" // Ventrella -#include "llhudeffectlookat.h" // EPointAtType -#include "llhudeffectpointat.h" // ELookAtType +#include "llfollowcam.h" // Ventrella +#include "llhudeffectlookat.h" // EPointAtType +#include "llhudeffectpointat.h" // ELookAtType class LLPickInfo; class LLVOAvatarSelf; @@ -40,26 +40,26 @@ class LLControlVariable; //-------------------------------------------------------------------- enum ECameraMode { - CAMERA_MODE_THIRD_PERSON, - CAMERA_MODE_MOUSELOOK, - CAMERA_MODE_CUSTOMIZE_AVATAR, - CAMERA_MODE_FOLLOW + CAMERA_MODE_THIRD_PERSON, + CAMERA_MODE_MOUSELOOK, + CAMERA_MODE_CUSTOMIZE_AVATAR, + CAMERA_MODE_FOLLOW }; /** Camera Presets for CAMERA_MODE_THIRD_PERSON */ enum ECameraPreset { - /** Default preset, what the Third Person Mode actually was */ - CAMERA_PRESET_REAR_VIEW, - - /** "Looking at the Avatar from the front" */ - CAMERA_PRESET_FRONT_VIEW, + /** Default preset, what the Third Person Mode actually was */ + CAMERA_PRESET_REAR_VIEW, + + /** "Looking at the Avatar from the front" */ + CAMERA_PRESET_FRONT_VIEW, - /** "Above and to the left, over the shoulder, pulled back a little on the zoom" */ - CAMERA_PRESET_GROUP_VIEW, + /** "Above and to the left, over the shoulder, pulled back a little on the zoom" */ + CAMERA_PRESET_GROUP_VIEW, - /** Current view when a preset is saved */ - CAMERA_PRESET_CUSTOM0 + /** Current view when a preset is saved */ + CAMERA_PRESET_CUSTOM0 }; //------------------------------------------------------------------------ @@ -67,243 +67,243 @@ enum ECameraPreset //------------------------------------------------------------------------ class LLAgentCamera { - LOG_CLASS(LLAgentCamera); + LOG_CLASS(LLAgentCamera); public: - //-------------------------------------------------------------------- - // Constructors / Destructors - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Constructors / Destructors + //-------------------------------------------------------------------- public: - LLAgentCamera(); - virtual ~LLAgentCamera(); - void init(); - void cleanup(); - void setAvatarObject(LLVOAvatarSelf* avatar); - bool isInitialized() { return mInitialized; } + LLAgentCamera(); + virtual ~LLAgentCamera(); + void init(); + void cleanup(); + void setAvatarObject(LLVOAvatarSelf* avatar); + bool isInitialized() { return mInitialized; } private: - bool mInitialized; + bool mInitialized; - //-------------------------------------------------------------------- - // Mode - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Mode + //-------------------------------------------------------------------- public: - void changeCameraToDefault(); - void changeCameraToMouselook(BOOL animate = TRUE); - void changeCameraToThirdPerson(BOOL animate = TRUE); - void changeCameraToCustomizeAvatar(); // Trigger transition animation - void changeCameraToFollow(BOOL animate = TRUE); // Ventrella - BOOL cameraThirdPerson() const { return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); } - BOOL cameraMouselook() const { return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); } - BOOL cameraCustomizeAvatar() const { return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); } - BOOL cameraFollow() const { return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); } - ECameraMode getCameraMode() const { return mCameraMode; } - ECameraMode getLastCameraMode() const { return mLastCameraMode; } - void updateCamera(); // Call once per frame to update camera location/orientation - void resetCamera(); // Slam camera into its default position - void updateLastCamera(); // Set last camera to current camera + void changeCameraToDefault(); + void changeCameraToMouselook(BOOL animate = TRUE); + void changeCameraToThirdPerson(BOOL animate = TRUE); + void changeCameraToCustomizeAvatar(); // Trigger transition animation + void changeCameraToFollow(BOOL animate = TRUE); // Ventrella + BOOL cameraThirdPerson() const { return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); } + BOOL cameraMouselook() const { return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); } + BOOL cameraCustomizeAvatar() const { return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); } + BOOL cameraFollow() const { return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); } + ECameraMode getCameraMode() const { return mCameraMode; } + ECameraMode getLastCameraMode() const { return mLastCameraMode; } + void updateCamera(); // Call once per frame to update camera location/orientation + void resetCamera(); // Slam camera into its default position + void updateLastCamera(); // Set last camera to current camera private: - ECameraMode mCameraMode; // Target mode after transition animation is done - ECameraMode mLastCameraMode; + ECameraMode mCameraMode; // Target mode after transition animation is done + ECameraMode mLastCameraMode; - //-------------------------------------------------------------------- - // Preset - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Preset + //-------------------------------------------------------------------- public: - void switchCameraPreset(ECameraPreset preset); + void switchCameraPreset(ECameraPreset preset); private: - /** Determines default camera offset depending on the current camera preset */ - LLVector3 getCameraOffsetInitial(); - /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */ - F32 getCameraMaxZoomDistance(); + /** Determines default camera offset depending on the current camera preset */ + LLVector3 getCameraOffsetInitial(); + /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */ + F32 getCameraMaxZoomDistance(); - /** Camera preset in Third Person Mode */ - ECameraPreset mCameraPreset; + /** Camera preset in Third Person Mode */ + ECameraPreset mCameraPreset; - /** Initial camera offsets */ - std::map<ECameraPreset, LLPointer<LLControlVariable> > mCameraOffsetInitial; + /** Initial camera offsets */ + std::map<ECameraPreset, LLPointer<LLControlVariable> > mCameraOffsetInitial; - /** Initial focus offsets */ - std::map<ECameraPreset, LLPointer<LLControlVariable> > mFocusOffsetInitial; + /** Initial focus offsets */ + std::map<ECameraPreset, LLPointer<LLControlVariable> > mFocusOffsetInitial; - //-------------------------------------------------------------------- - // Position - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Position + //-------------------------------------------------------------------- public: - LLVector3d getCameraPositionGlobal() const; - const LLVector3 &getCameraPositionAgent() const; - LLVector3d calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target - F32 getCameraMinOffGround(); // Minimum height off ground for this mode, meters - void setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; } - BOOL calcCameraMinDistance(F32 &obj_min_distance); - F32 getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.length(); } - void clearCameraLag() { mCameraLag.clearVec(); } + LLVector3d getCameraPositionGlobal() const; + const LLVector3 &getCameraPositionAgent() const; + LLVector3d calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target + F32 getCameraMinOffGround(); // Minimum height off ground for this mode, meters + void setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; } + BOOL calcCameraMinDistance(F32 &obj_min_distance); + F32 getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.length(); } + void clearCameraLag() { mCameraLag.clearVec(); } private: - F32 mCurrentCameraDistance; // Current camera offset from avatar - F32 mTargetCameraDistance; // Target camera offset from avatar - F32 mCameraFOVZoomFactor; // Amount of fov zoom applied to camera when zeroing in on an object - F32 mCameraCurrentFOVZoomFactor; // Interpolated fov zoom - F32 mCameraFOVDefault; // Default field of view that is basis for FOV zoom effect - LLVector4 mCameraCollidePlane; // Colliding plane for camera - F32 mCameraZoomFraction; // Mousewheel driven fraction of zoom - LLVector3 mCameraPositionAgent; // Camera position in agent coordinates - LLVector3 mCameraVirtualPositionAgent; // Camera virtual position (target) before performing FOV zoom - LLVector3d mCameraSmoothingLastPositionGlobal; - LLVector3d mCameraSmoothingLastPositionAgent; - bool mCameraSmoothingStop; - LLVector3 mCameraLag; // Third person camera lag - LLVector3 mCameraUpVector; // Camera's up direction in world coordinates (determines the 'roll' of the view) - - //-------------------------------------------------------------------- - // Follow - //-------------------------------------------------------------------- + F32 mCurrentCameraDistance; // Current camera offset from avatar + F32 mTargetCameraDistance; // Target camera offset from avatar + F32 mCameraFOVZoomFactor; // Amount of fov zoom applied to camera when zeroing in on an object + F32 mCameraCurrentFOVZoomFactor; // Interpolated fov zoom + F32 mCameraFOVDefault; // Default field of view that is basis for FOV zoom effect + LLVector4 mCameraCollidePlane; // Colliding plane for camera + F32 mCameraZoomFraction; // Mousewheel driven fraction of zoom + LLVector3 mCameraPositionAgent; // Camera position in agent coordinates + LLVector3 mCameraVirtualPositionAgent; // Camera virtual position (target) before performing FOV zoom + LLVector3d mCameraSmoothingLastPositionGlobal; + LLVector3d mCameraSmoothingLastPositionAgent; + bool mCameraSmoothingStop; + LLVector3 mCameraLag; // Third person camera lag + LLVector3 mCameraUpVector; // Camera's up direction in world coordinates (determines the 'roll' of the view) + + //-------------------------------------------------------------------- + // Follow + //-------------------------------------------------------------------- public: - void setUsingFollowCam(bool using_follow_cam); - bool isfollowCamLocked(); + void setUsingFollowCam(bool using_follow_cam); + bool isfollowCamLocked(); private: - LLFollowCam mFollowCam; // Ventrella + LLFollowCam mFollowCam; // Ventrella - //-------------------------------------------------------------------- - // Sit - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Sit + //-------------------------------------------------------------------- public: - void setupSitCamera(); - BOOL sitCameraEnabled() { return mSitCameraEnabled; } - void setSitCamera(const LLUUID &object_id, - const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero); + void setupSitCamera(); + BOOL sitCameraEnabled() { return mSitCameraEnabled; } + void setSitCamera(const LLUUID &object_id, + const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero); private: - LLPointer<LLViewerObject> mSitCameraReferenceObject; // Object to which camera is related when sitting - BOOL mSitCameraEnabled; // Use provided camera information when sitting? - LLVector3 mSitCameraPos; // Root relative camera pos when sitting - LLVector3 mSitCameraFocus; // Root relative camera target when sitting - - //-------------------------------------------------------------------- - // Animation - //-------------------------------------------------------------------- + LLPointer<LLViewerObject> mSitCameraReferenceObject; // Object to which camera is related when sitting + BOOL mSitCameraEnabled; // Use provided camera information when sitting? + LLVector3 mSitCameraPos; // Root relative camera pos when sitting + LLVector3 mSitCameraFocus; // Root relative camera target when sitting + + //-------------------------------------------------------------------- + // Animation + //-------------------------------------------------------------------- public: - void setCameraAnimating(BOOL b) { mCameraAnimating = b; } - BOOL getCameraAnimating() { return mCameraAnimating; } - void setAnimationDuration(F32 seconds); - void startCameraAnimation(); - void stopCameraAnimation(); + void setCameraAnimating(BOOL b) { mCameraAnimating = b; } + BOOL getCameraAnimating() { return mCameraAnimating; } + void setAnimationDuration(F32 seconds); + void startCameraAnimation(); + void stopCameraAnimation(); private: - LLFrameTimer mAnimationTimer; // Seconds that transition animation has been active - F32 mAnimationDuration; // In seconds - BOOL mCameraAnimating; // Camera is transitioning from one mode to another - LLVector3d mAnimationCameraStartGlobal; // Camera start position, global coords - LLVector3d mAnimationFocusStartGlobal; // Camera focus point, global coords - - //-------------------------------------------------------------------- - // Focus - //-------------------------------------------------------------------- + LLFrameTimer mAnimationTimer; // Seconds that transition animation has been active + F32 mAnimationDuration; // In seconds + BOOL mCameraAnimating; // Camera is transitioning from one mode to another + LLVector3d mAnimationCameraStartGlobal; // Camera start position, global coords + LLVector3d mAnimationFocusStartGlobal; // Camera focus point, global coords + + //-------------------------------------------------------------------- + // Focus + //-------------------------------------------------------------------- public: - LLVector3d calcFocusPositionTargetGlobal(); - LLVector3 calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y); - BOOL getFocusOnAvatar() const { return mFocusOnAvatar; } - LLPointer<LLViewerObject>& getFocusObject() { return mFocusObject; } - F32 getFocusObjectDist() const { return mFocusObjectDist; } - void updateFocusOffset(); - 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 setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id); - void clearFocusObject(); - void setFocusObject(LLViewerObject* object); - void setAllowChangeToFollow(BOOL focus) { mAllowChangeToFollow = focus; } - void setObjectTracking(BOOL track) { mTrackFocusObject = track; } - const LLVector3d &getFocusGlobal() const { return mFocusGlobal; } - const LLVector3d &getFocusTargetGlobal() const { return mFocusTargetGlobal; } + LLVector3d calcFocusPositionTargetGlobal(); + LLVector3 calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y); + BOOL getFocusOnAvatar() const { return mFocusOnAvatar; } + LLPointer<LLViewerObject>& getFocusObject() { return mFocusObject; } + F32 getFocusObjectDist() const { return mFocusObjectDist; } + void updateFocusOffset(); + 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 setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id); + void clearFocusObject(); + void setFocusObject(LLViewerObject* object); + void setAllowChangeToFollow(BOOL focus) { mAllowChangeToFollow = focus; } + void setObjectTracking(BOOL track) { mTrackFocusObject = track; } + const LLVector3d &getFocusGlobal() const { return mFocusGlobal; } + const LLVector3d &getFocusTargetGlobal() const { return mFocusTargetGlobal; } private: - LLVector3d mCameraFocusOffset; // Offset from focus point in build mode - LLVector3d mCameraFocusOffsetTarget; // Target towards which we are lerping the camera's focus offset - BOOL mFocusOnAvatar; - BOOL mAllowChangeToFollow; - LLVector3d mFocusGlobal; - LLVector3d mFocusTargetGlobal; - LLPointer<LLViewerObject> mFocusObject; - F32 mFocusObjectDist; - LLVector3 mFocusObjectOffset; - F32 mFocusDotRadius; // Meters - BOOL mTrackFocusObject; - - //-------------------------------------------------------------------- - // Lookat / Pointat - //-------------------------------------------------------------------- + LLVector3d mCameraFocusOffset; // Offset from focus point in build mode + LLVector3d mCameraFocusOffsetTarget; // Target towards which we are lerping the camera's focus offset + BOOL mFocusOnAvatar; + BOOL mAllowChangeToFollow; + LLVector3d mFocusGlobal; + LLVector3d mFocusTargetGlobal; + LLPointer<LLViewerObject> mFocusObject; + F32 mFocusObjectDist; + LLVector3 mFocusObjectOffset; + F32 mFocusDotRadius; // Meters + BOOL mTrackFocusObject; + + //-------------------------------------------------------------------- + // Lookat / Pointat + //-------------------------------------------------------------------- public: - void updateLookAt(const S32 mouse_x, const S32 mouse_y); - BOOL setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero); - ELookAtType getLookAtType(); - void lookAtLastChat(); - void slamLookAt(const LLVector3 &look_at); // Set the physics data - BOOL setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero); - EPointAtType getPointAtType(); + void updateLookAt(const S32 mouse_x, const S32 mouse_y); + BOOL setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero); + ELookAtType getLookAtType(); + void lookAtLastChat(); + void slamLookAt(const LLVector3 &look_at); // Set the physics data + BOOL setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero); + EPointAtType getPointAtType(); public: - LLPointer<LLHUDEffectLookAt> mLookAt; - LLPointer<LLHUDEffectPointAt> mPointAt; + LLPointer<LLHUDEffectLookAt> mLookAt; + LLPointer<LLHUDEffectPointAt> mPointAt; - //-------------------------------------------------------------------- - // Third person - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Third person + //-------------------------------------------------------------------- public: - LLVector3d calcThirdPersonFocusOffset(); - void setThirdPersonHeadOffset(LLVector3 offset) { mThirdPersonHeadOffset = offset; } + LLVector3d calcThirdPersonFocusOffset(); + void setThirdPersonHeadOffset(LLVector3 offset) { mThirdPersonHeadOffset = offset; } private: - LLVector3 mThirdPersonHeadOffset; // Head offset for third person camera position + LLVector3 mThirdPersonHeadOffset; // Head offset for third person camera position - //-------------------------------------------------------------------- - // Orbit - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Orbit + //-------------------------------------------------------------------- public: - void cameraOrbitAround(const F32 radians); // Rotate camera CCW radians about build focus point - void cameraOrbitOver(const F32 radians); // Rotate camera forward radians over build focus point - void cameraOrbitIn(const F32 meters); // Move camera in toward build focus point + void cameraOrbitAround(const F32 radians); // Rotate camera CCW radians about build focus point + void cameraOrbitOver(const F32 radians); // Rotate camera forward radians over build focus point + void cameraOrbitIn(const F32 meters); // Move camera in toward build focus point - //-------------------------------------------------------------------- - // Zoom - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Zoom + //-------------------------------------------------------------------- public: - void handleScrollWheel(S32 clicks); // Mousewheel driven zoom - void cameraZoomIn(const F32 factor); // Zoom in by fraction of current distance - F32 getCameraZoomFraction(); // Get camera zoom as fraction of minimum and maximum zoom - void setCameraZoomFraction(F32 fraction); // Set camera zoom as fraction of minimum and maximum zoom - F32 calcCameraFOVZoomFactor(); - - //-------------------------------------------------------------------- - // Pan - //-------------------------------------------------------------------- + void handleScrollWheel(S32 clicks); // Mousewheel driven zoom + void cameraZoomIn(const F32 factor); // Zoom in by fraction of current distance + F32 getCameraZoomFraction(); // Get camera zoom as fraction of minimum and maximum zoom + void setCameraZoomFraction(F32 fraction); // Set camera zoom as fraction of minimum and maximum zoom + F32 calcCameraFOVZoomFactor(); + + //-------------------------------------------------------------------- + // Pan + //-------------------------------------------------------------------- public: - void cameraPanIn(const F32 meters); - void cameraPanLeft(const F32 meters); - void cameraPanUp(const F32 meters); - - //-------------------------------------------------------------------- - // View - //-------------------------------------------------------------------- + void cameraPanIn(const F32 meters); + void cameraPanLeft(const F32 meters); + void cameraPanUp(const F32 meters); + + //-------------------------------------------------------------------- + // View + //-------------------------------------------------------------------- public: - // Called whenever the agent moves. Puts camera back in default position, deselects items, etc. - void resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE); - // Called on camera movement. Unlocks camera from the default position behind the avatar. - void unlockView(); + // Called whenever the agent moves. Puts camera back in default position, deselects items, etc. + void resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE); + // Called on camera movement. Unlocks camera from the default position behind the avatar. + void unlockView(); public: - F32 mDrawDistance; + F32 mDrawDistance; - //-------------------------------------------------------------------- - // Mouselook - //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + // Mouselook + //-------------------------------------------------------------------- public: - BOOL getForceMouselook() const { return mForceMouselook; } - void setForceMouselook(BOOL mouselook) { mForceMouselook = mouselook; } + BOOL getForceMouselook() const { return mForceMouselook; } + void setForceMouselook(BOOL mouselook) { mForceMouselook = mouselook; } private: - BOOL mForceMouselook; - - //-------------------------------------------------------------------- - // HUD - //-------------------------------------------------------------------- + BOOL mForceMouselook; + + //-------------------------------------------------------------------- + // HUD + //-------------------------------------------------------------------- public: - F32 mHUDTargetZoom; // Target zoom level for HUD objects (used when editing) - F32 mHUDCurZoom; // Current animated zoom level for HUD objects + F32 mHUDTargetZoom; // Target zoom level for HUD objects (used when editing) + F32 mHUDCurZoom; // Current animated zoom level for HUD objects /******************************************************************************** @@ -312,84 +312,84 @@ public: **/ public: - S32 getAtKey() const { return mAtKey; } - S32 getWalkKey() const { return mWalkKey; } - S32 getLeftKey() const { return mLeftKey; } - S32 getUpKey() const { return mUpKey; } - F32 getYawKey() const { return mYawKey; } - F32 getPitchKey() const { return mPitchKey; } - - void setAtKey(S32 mag) { mAtKey = mag; } - void setWalkKey(S32 mag) { mWalkKey = mag; } - void setLeftKey(S32 mag) { mLeftKey = mag; } - void setUpKey(S32 mag) { mUpKey = mag; } - void setYawKey(F32 mag) { mYawKey = mag; } - void setPitchKey(F32 mag) { mPitchKey = mag; } - - void clearGeneralKeys(); - static S32 directionToKey(S32 direction); // Changes direction to -1/0/1 + S32 getAtKey() const { return mAtKey; } + S32 getWalkKey() const { return mWalkKey; } + S32 getLeftKey() const { return mLeftKey; } + S32 getUpKey() const { return mUpKey; } + F32 getYawKey() const { return mYawKey; } + F32 getPitchKey() const { return mPitchKey; } + + void setAtKey(S32 mag) { mAtKey = mag; } + void setWalkKey(S32 mag) { mWalkKey = mag; } + void setLeftKey(S32 mag) { mLeftKey = mag; } + void setUpKey(S32 mag) { mUpKey = mag; } + void setYawKey(F32 mag) { mYawKey = mag; } + void setPitchKey(F32 mag) { mPitchKey = mag; } + + void clearGeneralKeys(); + static S32 directionToKey(S32 direction); // Changes direction to -1/0/1 private: - S32 mAtKey; // Either 1, 0, or -1. Indicates that movement key is pressed - S32 mWalkKey; // Like AtKey, but causes less forward thrust - S32 mLeftKey; - S32 mUpKey; - F32 mYawKey; - F32 mPitchKey; - - //-------------------------------------------------------------------- - // Orbit - //-------------------------------------------------------------------- + S32 mAtKey; // Either 1, 0, or -1. Indicates that movement key is pressed + S32 mWalkKey; // Like AtKey, but causes less forward thrust + S32 mLeftKey; + S32 mUpKey; + F32 mYawKey; + F32 mPitchKey; + + //-------------------------------------------------------------------- + // Orbit + //-------------------------------------------------------------------- public: - F32 getOrbitLeftKey() const { return mOrbitLeftKey; } - F32 getOrbitRightKey() const { return mOrbitRightKey; } - F32 getOrbitUpKey() const { return mOrbitUpKey; } - F32 getOrbitDownKey() const { return mOrbitDownKey; } - F32 getOrbitInKey() const { return mOrbitInKey; } - F32 getOrbitOutKey() const { return mOrbitOutKey; } - - void setOrbitLeftKey(F32 mag) { mOrbitLeftKey = mag; } - void setOrbitRightKey(F32 mag) { mOrbitRightKey = mag; } - void setOrbitUpKey(F32 mag) { mOrbitUpKey = mag; } - void setOrbitDownKey(F32 mag) { mOrbitDownKey = mag; } - void setOrbitInKey(F32 mag) { mOrbitInKey = mag; } - void setOrbitOutKey(F32 mag) { mOrbitOutKey = mag; } - - void clearOrbitKeys(); + F32 getOrbitLeftKey() const { return mOrbitLeftKey; } + F32 getOrbitRightKey() const { return mOrbitRightKey; } + F32 getOrbitUpKey() const { return mOrbitUpKey; } + F32 getOrbitDownKey() const { return mOrbitDownKey; } + F32 getOrbitInKey() const { return mOrbitInKey; } + F32 getOrbitOutKey() const { return mOrbitOutKey; } + + void setOrbitLeftKey(F32 mag) { mOrbitLeftKey = mag; } + void setOrbitRightKey(F32 mag) { mOrbitRightKey = mag; } + void setOrbitUpKey(F32 mag) { mOrbitUpKey = mag; } + void setOrbitDownKey(F32 mag) { mOrbitDownKey = mag; } + void setOrbitInKey(F32 mag) { mOrbitInKey = mag; } + void setOrbitOutKey(F32 mag) { mOrbitOutKey = mag; } + + void clearOrbitKeys(); private: - F32 mOrbitLeftKey; - F32 mOrbitRightKey; - F32 mOrbitUpKey; - F32 mOrbitDownKey; - F32 mOrbitInKey; - F32 mOrbitOutKey; - - //-------------------------------------------------------------------- - // Pan - //-------------------------------------------------------------------- + F32 mOrbitLeftKey; + F32 mOrbitRightKey; + F32 mOrbitUpKey; + F32 mOrbitDownKey; + F32 mOrbitInKey; + F32 mOrbitOutKey; + + //-------------------------------------------------------------------- + // Pan + //-------------------------------------------------------------------- public: - F32 getPanLeftKey() const { return mPanLeftKey; } - F32 getPanRightKey() const { return mPanRightKey; } - F32 getPanUpKey() const { return mPanUpKey; } - F32 getPanDownKey() const { return mPanDownKey; } - F32 getPanInKey() const { return mPanInKey; } - F32 getPanOutKey() const { return mPanOutKey; } - - void setPanLeftKey(F32 mag) { mPanLeftKey = mag; } - void setPanRightKey(F32 mag) { mPanRightKey = mag; } - void setPanUpKey(F32 mag) { mPanUpKey = mag; } - void setPanDownKey(F32 mag) { mPanDownKey = mag; } - void setPanInKey(F32 mag) { mPanInKey = mag; } - void setPanOutKey(F32 mag) { mPanOutKey = mag; } - - void clearPanKeys(); + F32 getPanLeftKey() const { return mPanLeftKey; } + F32 getPanRightKey() const { return mPanRightKey; } + F32 getPanUpKey() const { return mPanUpKey; } + F32 getPanDownKey() const { return mPanDownKey; } + F32 getPanInKey() const { return mPanInKey; } + F32 getPanOutKey() const { return mPanOutKey; } + + void setPanLeftKey(F32 mag) { mPanLeftKey = mag; } + void setPanRightKey(F32 mag) { mPanRightKey = mag; } + void setPanUpKey(F32 mag) { mPanUpKey = mag; } + void setPanDownKey(F32 mag) { mPanDownKey = mag; } + void setPanInKey(F32 mag) { mPanInKey = mag; } + void setPanOutKey(F32 mag) { mPanOutKey = mag; } + + void clearPanKeys(); private: - F32 mPanUpKey; - F32 mPanDownKey; - F32 mPanLeftKey; - F32 mPanRightKey; - F32 mPanInKey; - F32 mPanOutKey; + F32 mPanUpKey; + F32 mPanDownKey; + F32 mPanLeftKey; + F32 mPanRightKey; + F32 mPanInKey; + F32 mPanOutKey; /** Keys ** ** diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index df06ad31e6..9848a1af0b 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -34,7 +34,7 @@ #include "m3math.h" #include "llrender.h" -#include "llagent.h" // for gAgent for getRegion for getWaterHeight +#include "llagent.h" // for gAgent for getRegion for getWaterHeight #include "llcubemap.h" #include "lldrawable.h" #include "llface.h" @@ -64,26 +64,26 @@ F32 LLDrawPoolWater::sWaterFogEnd = 0.f; LLVector3 LLDrawPoolWater::sLightDir; LLDrawPoolWater::LLDrawPoolWater() : - LLFacePool(POOL_WATER) + LLFacePool(POOL_WATER) { - mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - gGL.getTexUnit(0)->bind(mHBTex[0]) ; - mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP); + mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + gGL.getTexUnit(0)->bind(mHBTex[0]) ; + mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP); - mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - gGL.getTexUnit(0)->bind(mHBTex[1]); - mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP); + mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + gGL.getTexUnit(0)->bind(mHBTex[1]); + mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP); - mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE); - llassert(mWaterImagep); - mWaterImagep->setNoDelete(); - mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE); - llassert(mOpaqueWaterImagep); - mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL); - mWaterNormp->setNoDelete(); + mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE); + llassert(mWaterImagep); + mWaterImagep->setNoDelete(); + mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE); + llassert(mOpaqueWaterImagep); + mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL); + mWaterNormp->setNoDelete(); - restoreGL(); + restoreGL(); } LLDrawPoolWater::~LLDrawPoolWater() @@ -93,48 +93,48 @@ LLDrawPoolWater::~LLDrawPoolWater() //static void LLDrawPoolWater::restoreGL() { - + } LLDrawPool *LLDrawPoolWater::instancePool() { - LL_ERRS() << "Should never be calling instancePool on a water pool!" << LL_ENDL; - return NULL; + LL_ERRS() << "Should never be calling instancePool on a water pool!" << LL_ENDL; + return NULL; } void LLDrawPoolWater::prerender() { - mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? - LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; + mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? + LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; - // got rid of modulation by light color since it got a little too - // green at sunset and sl-57047 (underwater turns black at 8:00) - sWaterFogColor = LLWaterParamManager::instance().getFogColor(); - sWaterFogColor.mV[3] = 0; + // got rid of modulation by light color since it got a little too + // green at sunset and sl-57047 (underwater turns black at 8:00) + sWaterFogColor = LLWaterParamManager::instance().getFogColor(); + sWaterFogColor.mV[3] = 0; } S32 LLDrawPoolWater::getNumPasses() { - if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f) - { - return 1; - } + if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f) + { + return 1; + } - return 0; + return 0; } void LLDrawPoolWater::beginPostDeferredPass(S32 pass) { - beginRenderPass(pass); - deferred_render = TRUE; + beginRenderPass(pass); + deferred_render = TRUE; } void LLDrawPoolWater::endPostDeferredPass(S32 pass) { - endRenderPass(pass); - deferred_render = FALSE; + endRenderPass(pass); + deferred_render = FALSE; } //=============================== @@ -142,591 +142,591 @@ void LLDrawPoolWater::endPostDeferredPass(S32 pass) //=============================== void LLDrawPoolWater::renderDeferred(S32 pass) { - LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); - deferred_render = TRUE; - shade(); - deferred_render = FALSE; + LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); + deferred_render = TRUE; + shade(); + deferred_render = FALSE; } //========================================= void LLDrawPoolWater::render(S32 pass) { - LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); - if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1) - { - return; - } - - //do a quick 'n dirty depth sort - for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace* facep = *iter; - facep->mDistance = -facep->mCenterLocal.mV[2]; - } - - std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater()); - - // See if we are rendering water as opaque or not - if (!gSavedSettings.getBOOL("RenderTransparentWater")) - { - // render water for low end hardware - renderOpaqueLegacyWater(); - return; - } - - LLGLEnable blend(GL_BLEND); - - if ((mVertexShaderLevel > 0) && !sSkipScreenCopy) - { - shade(); - return; - } - - LLVOSky *voskyp = gSky.mVOSkyp; - - stop_glerror(); - - if (!gGLManager.mHasMultitexture) - { - // Ack! No multitexture! Bail! - return; - } - - LLFace* refl_face = voskyp->getReflFace(); - - gPipeline.disableLights(); - - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - - LLGLDisable cullFace(GL_CULL_FACE); - - // Set up second pass first - mWaterImagep->addTextureStats(1024.f*1024.f); - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->bind(mWaterImagep) ; - - LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); - F32 up_dot = camera_up * LLVector3::z_axis; - - LLColor4 water_color; - if (LLViewerCamera::getInstance()->cameraUnderWater()) - { - water_color.setVec(1.f, 1.f, 1.f, 0.4f); - } - else - { - water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - } - - gGL.diffuseColor4fv(water_color.mV); - - // Automatically generate texture coords for detail map - glEnable(GL_TEXTURE_GEN_S); //texture unit 1 - glEnable(GL_TEXTURE_GEN_T); //texture unit 1 - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - - // Slowly move over time. - F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f); - F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f}; - F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f}; - glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); - glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); - - gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); - gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA); - - gGL.getTexUnit(0)->activate(); - - glClearStencil(1); - glClear(GL_STENCIL_BUFFER_BIT); - LLGLEnable gls_stencil(GL_STENCIL_TEST); - glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP); - glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); - - for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - continue; - } - gGL.getTexUnit(0)->bind(face->getTexture()); - face->renderIndexed(); - } - - // Now, disable texture coord generation on texture state 1 - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->disable(); - glDisable(GL_TEXTURE_GEN_S); //texture unit 1 - glDisable(GL_TEXTURE_GEN_T); //texture unit 1 - - // Disable texture coordinate and color arrays - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - stop_glerror(); - - if (gSky.mVOSkyp->getCubeMap()) - { - gSky.mVOSkyp->getCubeMap()->enable(0); - gSky.mVOSkyp->getCubeMap()->bind(); - - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview(); - LLMatrix4 camera_rot(camera_mat.getMat3()); - camera_rot.invert(); - - gGL.loadMatrix((F32 *)camera_rot.mMatrix); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f, 0.5f*up_dot); - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - - for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - //refl_face = face; - continue; - } - - if (face->getGeomCount() > 0) - { - face->renderIndexed(); - } - } - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - - gSky.mVOSkyp->getCubeMap()->disable(); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - - } - - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); + if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1) + { + return; + } + + //do a quick 'n dirty depth sort + for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace* facep = *iter; + facep->mDistance = -facep->mCenterLocal.mV[2]; + } + + std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater()); + + // See if we are rendering water as opaque or not + if (!gSavedSettings.getBOOL("RenderTransparentWater")) + { + // render water for low end hardware + renderOpaqueLegacyWater(); + return; + } + + LLGLEnable blend(GL_BLEND); + + if ((mVertexShaderLevel > 0) && !sSkipScreenCopy) + { + shade(); + return; + } + + LLVOSky *voskyp = gSky.mVOSkyp; + + stop_glerror(); + + if (!gGLManager.mHasMultitexture) + { + // Ack! No multitexture! Bail! + return; + } + + LLFace* refl_face = voskyp->getReflFace(); + + gPipeline.disableLights(); + + LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); + + LLGLDisable cullFace(GL_CULL_FACE); + + // Set up second pass first + mWaterImagep->addTextureStats(1024.f*1024.f); + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->bind(mWaterImagep) ; + + LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); + F32 up_dot = camera_up * LLVector3::z_axis; + + LLColor4 water_color; + if (LLViewerCamera::getInstance()->cameraUnderWater()) + { + water_color.setVec(1.f, 1.f, 1.f, 0.4f); + } + else + { + water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); + } + + gGL.diffuseColor4fv(water_color.mV); + + // Automatically generate texture coords for detail map + glEnable(GL_TEXTURE_GEN_S); //texture unit 1 + glEnable(GL_TEXTURE_GEN_T); //texture unit 1 + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + + // Slowly move over time. + F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f); + F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f}; + F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f}; + glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); + glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); + + gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); + gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA); + + gGL.getTexUnit(0)->activate(); + + glClearStencil(1); + glClear(GL_STENCIL_BUFFER_BIT); + LLGLEnable gls_stencil(GL_STENCIL_TEST); + glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP); + glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); + + for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + if (voskyp->isReflFace(face)) + { + continue; + } + gGL.getTexUnit(0)->bind(face->getTexture()); + face->renderIndexed(); + } + + // Now, disable texture coord generation on texture state 1 + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); + glDisable(GL_TEXTURE_GEN_S); //texture unit 1 + glDisable(GL_TEXTURE_GEN_T); //texture unit 1 + + // Disable texture coordinate and color arrays + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + stop_glerror(); + + if (gSky.mVOSkyp->getCubeMap()) + { + gSky.mVOSkyp->getCubeMap()->enable(0); + gSky.mVOSkyp->getCubeMap()->bind(); + + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadIdentity(); + LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview(); + LLMatrix4 camera_rot(camera_mat.getMat3()); + camera_rot.invert(); + + gGL.loadMatrix((F32 *)camera_rot.mMatrix); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f, 0.5f*up_dot); + + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + + for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + if (voskyp->isReflFace(face)) + { + //refl_face = face; + continue; + } + + if (face->getGeomCount() > 0) + { + face->renderIndexed(); + } + } + + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + + gSky.mVOSkyp->getCubeMap()->disable(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + + } + + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); if (refl_face) - { - glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); - renderReflection(refl_face); - } + { + glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); + renderReflection(refl_face); + } - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } // for low end hardware void LLDrawPoolWater::renderOpaqueLegacyWater() { - LLVOSky *voskyp = gSky.mVOSkyp; - - LLGLSLShader* shader = NULL; - if (LLGLSLShader::sNoFixedFunction) - { - if (LLPipeline::sUnderWaterRender) - { - shader = &gObjectSimpleNonIndexedTexGenWaterProgram; - } - else - { - shader = &gObjectSimpleNonIndexedTexGenProgram; - } - - shader->bind(); - } - - stop_glerror(); - - // Depth sorting and write to depth buffer - // since this is opaque, we should see nothing - // behind the water. No blending because - // of no transparency. And no face culling so - // that the underside of the water is also opaque. - LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); - LLGLDisable no_cull(GL_CULL_FACE); - LLGLDisable no_blend(GL_BLEND); - - gPipeline.disableLights(); - - mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); - - // Activate the texture binding and bind one - // texture since all images will have the same texture - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->bind(mOpaqueWaterImagep); - - // Automatically generate texture coords for water texture - if (!shader) - { - glEnable(GL_TEXTURE_GEN_S); //texture unit 0 - glEnable(GL_TEXTURE_GEN_T); //texture unit 0 - glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - } - - // Use the fact that we know all water faces are the same size - // to save some computation - - // Slowly move texture coordinates over time so the watter appears - // to be moving. - F32 movement_period_secs = 50.f; - - F32 offset = fmod(gFrameTimeSeconds, movement_period_secs); - - if (movement_period_secs != 0) - { - offset /= movement_period_secs; - } - else - { - offset = 0; - } - - F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset }; - F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset }; - - if (!shader) - { - glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); - glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); - } - else - { - shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0); - shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1); - } - - gGL.diffuseColor3f(1.f, 1.f, 1.f); - - for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - continue; - } - - face->renderIndexed(); - } - - stop_glerror(); - - if (!shader) - { - // Reset the settings back to expected values - glDisable(GL_TEXTURE_GEN_S); //texture unit 0 - glDisable(GL_TEXTURE_GEN_T); //texture unit 0 - } - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + LLVOSky *voskyp = gSky.mVOSkyp; + + LLGLSLShader* shader = NULL; + if (LLGLSLShader::sNoFixedFunction) + { + if (LLPipeline::sUnderWaterRender) + { + shader = &gObjectSimpleNonIndexedTexGenWaterProgram; + } + else + { + shader = &gObjectSimpleNonIndexedTexGenProgram; + } + + shader->bind(); + } + + stop_glerror(); + + // Depth sorting and write to depth buffer + // since this is opaque, we should see nothing + // behind the water. No blending because + // of no transparency. And no face culling so + // that the underside of the water is also opaque. + LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); + LLGLDisable no_cull(GL_CULL_FACE); + LLGLDisable no_blend(GL_BLEND); + + gPipeline.disableLights(); + + mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); + + // Activate the texture binding and bind one + // texture since all images will have the same texture + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->bind(mOpaqueWaterImagep); + + // Automatically generate texture coords for water texture + if (!shader) + { + glEnable(GL_TEXTURE_GEN_S); //texture unit 0 + glEnable(GL_TEXTURE_GEN_T); //texture unit 0 + glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + } + + // Use the fact that we know all water faces are the same size + // to save some computation + + // Slowly move texture coordinates over time so the watter appears + // to be moving. + F32 movement_period_secs = 50.f; + + F32 offset = fmod(gFrameTimeSeconds, movement_period_secs); + + if (movement_period_secs != 0) + { + offset /= movement_period_secs; + } + else + { + offset = 0; + } + + F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset }; + F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset }; + + if (!shader) + { + glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); + glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); + } + else + { + shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0); + shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1); + } + + gGL.diffuseColor3f(1.f, 1.f, 1.f); + + for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + if (voskyp->isReflFace(face)) + { + continue; + } + + face->renderIndexed(); + } + + stop_glerror(); + + if (!shader) + { + // Reset the settings back to expected values + glDisable(GL_TEXTURE_GEN_S); //texture unit 0 + glDisable(GL_TEXTURE_GEN_T); //texture unit 0 + } + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } void LLDrawPoolWater::renderReflection(LLFace* face) { - LLVOSky *voskyp = gSky.mVOSkyp; - - if (!voskyp) - { - return; - } - - if (!face->getGeomCount()) - { - return; - } - - S8 dr = voskyp->getDrawRefl(); - if (dr < 0) - { - return; - } - - LLGLSNoFog noFog; - - gGL.getTexUnit(0)->bind(mHBTex[dr]); - - LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV)); - face->renderIndexed(); + LLVOSky *voskyp = gSky.mVOSkyp; + + if (!voskyp) + { + return; + } + + if (!face->getGeomCount()) + { + return; + } + + S8 dr = voskyp->getDrawRefl(); + if (dr < 0) + { + return; + } + + LLGLSNoFog noFog; + + gGL.getTexUnit(0)->bind(mHBTex[dr]); + + LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV)); + face->renderIndexed(); } void LLDrawPoolWater::shade() { - if (!deferred_render) - { - gGL.setColorMask(true, true); - } - - LLVOSky *voskyp = gSky.mVOSkyp; - - if(voskyp == NULL) - { - return; - } - - LLGLDisable blend(GL_BLEND); - - LLColor3 light_diffuse(0,0,0); - F32 light_exp = 0.0f; - LLVector3 light_dir; - LLColor3 light_color; - - if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) - { - light_dir = gSky.getSunDirection(); - light_dir.normVec(); - light_color = gSky.getSunDiffuseColor(); - if(gSky.mVOSkyp) { - light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); - light_diffuse.normVec(); - } - light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); - light_diffuse *= light_exp + 0.25f; - } - else - { - light_dir = gSky.getMoonDirection(); - light_dir.normVec(); - light_color = gSky.getMoonDiffuseColor(); - light_diffuse = gSky.mVOSkyp->getMoon().getColorCached(); - light_diffuse.normVec(); - light_diffuse *= 0.5f; - light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); - } - - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= 256.f; - light_exp = light_exp > 32.f ? light_exp : 32.f; - - LLGLSLShader* shader; - - F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight(); - - if (eyedepth < 0.f && LLPipeline::sWaterReflections) - { - if (deferred_render) - { - shader = &gDeferredUnderWaterProgram; - } - else - { - shader = &gUnderWaterProgram; - } - } - else if (deferred_render) - { - shader = &gDeferredWaterProgram; - } - else - { - shader = &gWaterProgram; - } - - if (deferred_render) - { - gPipeline.bindDeferredShader(*shader); - } - else - { - shader->bind(); - } - - sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; - - S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX); - - if (reftex > -1) - { - gGL.getTexUnit(reftex)->activate(); - gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef); - gGL.getTexUnit(0)->activate(); - } - - //bind normal map - S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); - - LLWaterParamManager * param_mgr = &LLWaterParamManager::instance(); - - // change mWaterNormp if needed - if (mWaterNormp->getID() != param_mgr->getNormalMapID()) - { - mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID()); - } - - mWaterNormp->addTextureStats(1024.f*1024.f); - gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ; - if (gSavedSettings.getBOOL("RenderWaterMipNormal")) - { - mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - } - else - { - mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT); - } - - S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX); - - if (screentex > -1) - { - shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); - shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, - param_mgr->getFogDensity()); - gPipeline.mWaterDis.bindTexture(0, screentex); - } - - stop_glerror(); - - gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis); - - if (mVertexShaderLevel == 1) - { - sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue; - shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); - } - - F32 screenRes[] = - { - 1.f/gGLViewport[2], - 1.f/gGLViewport[3] - }; - shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes); - stop_glerror(); - - S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP); - stop_glerror(); - - light_dir.normVec(); - sLightDir = light_dir; - - light_diffuse *= 6.f; - - //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix); - shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth); - shader->uniform1f(LLShaderMgr::WATER_TIME, sTime); - shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); - shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp); - shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); - shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); - shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); - - shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV); - shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale()); - shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset()); - shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier()); - - F32 sunAngle = llmax(0.f, light_dir.mV[2]); - F32 scaledAngle = 1.f - sunAngle; - - shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle); - shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle); - shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle); - - LLColor4 water_color; - LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); - F32 up_dot = camera_up * LLVector3::z_axis; - if (LLViewerCamera::getInstance()->cameraUnderWater()) - { - water_color.setVec(1.f, 1.f, 1.f, 0.4f); - shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); - } - else - { - water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); - } - - if (water_color.mV[3] > 0.9f) - { - water_color.mV[3] = 0.9f; - } - - { - LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0); - LLGLDisable cullface(GL_CULL_FACE); - for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - - if (voskyp->isReflFace(face)) - { - continue; - } - - LLVOWater* water = (LLVOWater*) face->getViewerObject(); - gGL.getTexUnit(diffTex)->bind(face->getTexture()); - - sNeedsReflectionUpdate = TRUE; - - if (water->getUseTexture() || !water->getIsEdgePatch()) - { - sNeedsDistortionUpdate = TRUE; - face->renderIndexed(); - } - else if (gGLManager.mHasDepthClamp || deferred_render) - { - face->renderIndexed(); - } - else - { - LLGLSquashToFarClip far_clip(glh_get_current_projection()); - face->renderIndexed(); - } - } - } - - shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); - shader->disableTexture(LLShaderMgr::WATER_SCREENTEX); - shader->disableTexture(LLShaderMgr::BUMP_MAP); - shader->disableTexture(LLShaderMgr::DIFFUSE_MAP); - shader->disableTexture(LLShaderMgr::WATER_REFTEX); - shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH); - - if (deferred_render) - { - gPipeline.unbindDeferredShader(*shader); - } - else - { - shader->unbind(); - } - - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - if (!deferred_render) - { - gGL.setColorMask(true, false); - } + if (!deferred_render) + { + gGL.setColorMask(true, true); + } + + LLVOSky *voskyp = gSky.mVOSkyp; + + if(voskyp == NULL) + { + return; + } + + LLGLDisable blend(GL_BLEND); + + LLColor3 light_diffuse(0,0,0); + F32 light_exp = 0.0f; + LLVector3 light_dir; + LLColor3 light_color; + + if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) + { + light_dir = gSky.getSunDirection(); + light_dir.normVec(); + light_color = gSky.getSunDiffuseColor(); + if(gSky.mVOSkyp) { + light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); + light_diffuse.normVec(); + } + light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); + light_diffuse *= light_exp + 0.25f; + } + else + { + light_dir = gSky.getMoonDirection(); + light_dir.normVec(); + light_color = gSky.getMoonDiffuseColor(); + light_diffuse = gSky.mVOSkyp->getMoon().getColorCached(); + light_diffuse.normVec(); + light_diffuse *= 0.5f; + light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); + } + + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= 256.f; + light_exp = light_exp > 32.f ? light_exp : 32.f; + + LLGLSLShader* shader; + + F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight(); + + if (eyedepth < 0.f && LLPipeline::sWaterReflections) + { + if (deferred_render) + { + shader = &gDeferredUnderWaterProgram; + } + else + { + shader = &gUnderWaterProgram; + } + } + else if (deferred_render) + { + shader = &gDeferredWaterProgram; + } + else + { + shader = &gWaterProgram; + } + + if (deferred_render) + { + gPipeline.bindDeferredShader(*shader); + } + else + { + shader->bind(); + } + + sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; + + S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX); + + if (reftex > -1) + { + gGL.getTexUnit(reftex)->activate(); + gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef); + gGL.getTexUnit(0)->activate(); + } + + //bind normal map + S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); + + LLWaterParamManager * param_mgr = &LLWaterParamManager::instance(); + + // change mWaterNormp if needed + if (mWaterNormp->getID() != param_mgr->getNormalMapID()) + { + mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID()); + } + + mWaterNormp->addTextureStats(1024.f*1024.f); + gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ; + if (gSavedSettings.getBOOL("RenderWaterMipNormal")) + { + mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + } + else + { + mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT); + } + + S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX); + + if (screentex > -1) + { + shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); + shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, + param_mgr->getFogDensity()); + gPipeline.mWaterDis.bindTexture(0, screentex); + } + + stop_glerror(); + + gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis); + + if (mVertexShaderLevel == 1) + { + sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue; + shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); + } + + F32 screenRes[] = + { + 1.f/gGLViewport[2], + 1.f/gGLViewport[3] + }; + shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes); + stop_glerror(); + + S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP); + stop_glerror(); + + light_dir.normVec(); + sLightDir = light_dir; + + light_diffuse *= 6.f; + + //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix); + shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth); + shader->uniform1f(LLShaderMgr::WATER_TIME, sTime); + shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); + shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp); + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); + shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); + + shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV); + shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale()); + shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset()); + shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier()); + + F32 sunAngle = llmax(0.f, light_dir.mV[2]); + F32 scaledAngle = 1.f - sunAngle; + + shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle); + shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle); + shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle); + + LLColor4 water_color; + LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); + F32 up_dot = camera_up * LLVector3::z_axis; + if (LLViewerCamera::getInstance()->cameraUnderWater()) + { + water_color.setVec(1.f, 1.f, 1.f, 0.4f); + shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); + } + else + { + water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); + shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); + } + + if (water_color.mV[3] > 0.9f) + { + water_color.mV[3] = 0.9f; + } + + { + LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0); + LLGLDisable cullface(GL_CULL_FACE); + for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + + if (voskyp->isReflFace(face)) + { + continue; + } + + LLVOWater* water = (LLVOWater*) face->getViewerObject(); + gGL.getTexUnit(diffTex)->bind(face->getTexture()); + + sNeedsReflectionUpdate = TRUE; + + if (water->getUseTexture() || !water->getIsEdgePatch()) + { + sNeedsDistortionUpdate = TRUE; + face->renderIndexed(); + } + else if (gGLManager.mHasDepthClamp || deferred_render) + { + face->renderIndexed(); + } + else + { + LLGLSquashToFarClip far_clip(glh_get_current_projection()); + face->renderIndexed(); + } + } + } + + shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); + shader->disableTexture(LLShaderMgr::WATER_SCREENTEX); + shader->disableTexture(LLShaderMgr::BUMP_MAP); + shader->disableTexture(LLShaderMgr::DIFFUSE_MAP); + shader->disableTexture(LLShaderMgr::WATER_REFTEX); + shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH); + + if (deferred_render) + { + gPipeline.unbindDeferredShader(*shader); + } + else + { + shader->unbind(); + } + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + if (!deferred_render) + { + gGL.setColorMask(true, false); + } } LLViewerTexture *LLDrawPoolWater::getDebugTexture() { - return LLViewerFetchedTexture::sSmokeImagep; + return LLViewerFetchedTexture::sSmokeImagep; } LLColor3 LLDrawPoolWater::getDebugColor() const { - return LLColor3(0.f, 1.f, 1.f); + return LLColor3(0.f, 1.f, 1.f); } diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index c12ccb386e..2582715dd9 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -46,7 +46,7 @@ static LLDefaultChildRegistry::Register<LLPanelCameraItem> r("panel_camera_item"); -const F32 NUDGE_TIME = 0.25f; // in seconds +const F32 NUDGE_TIME = 0.25f; // in seconds const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed // constants @@ -61,94 +61,94 @@ bool LLFloaterCamera::sAppearanceEditing = false; // Zoom the camera in and out class LLPanelCameraZoom -: public LLPanel +: public LLPanel { - LOG_CLASS(LLPanelCameraZoom); + LOG_CLASS(LLPanelCameraZoom); public: - LLPanelCameraZoom(); + LLPanelCameraZoom(); - /* virtual */ BOOL postBuild(); - /* virtual */ void draw(); + /* virtual */ BOOL postBuild(); + /* virtual */ void draw(); protected: - void onZoomPlusHeldDown(); - void onZoomMinusHeldDown(); - void onSliderValueChanged(); - void onCameraTrack(); - void onCameraRotate(); - F32 getOrbitRate(F32 time); + void onZoomPlusHeldDown(); + void onZoomMinusHeldDown(); + void onSliderValueChanged(); + void onCameraTrack(); + void onCameraRotate(); + F32 getOrbitRate(F32 time); private: - LLButton* mPlusBtn; - LLButton* mMinusBtn; - LLSlider* mSlider; + LLButton* mPlusBtn; + LLButton* mMinusBtn; + LLSlider* mSlider; }; LLPanelCameraItem::Params::Params() -: icon_over("icon_over"), - icon_selected("icon_selected"), - picture("picture"), - text("text"), - selected_picture("selected_picture"), - mousedown_callback("mousedown_callback") +: icon_over("icon_over"), + icon_selected("icon_selected"), + picture("picture"), + text("text"), + selected_picture("selected_picture"), + mousedown_callback("mousedown_callback") { } LLPanelCameraItem::LLPanelCameraItem(const LLPanelCameraItem::Params& p) -: LLPanel(p) +: LLPanel(p) { - LLIconCtrl::Params icon_params = p.picture; - mPicture = LLUICtrlFactory::create<LLIconCtrl>(icon_params); - addChild(mPicture); + LLIconCtrl::Params icon_params = p.picture; + mPicture = LLUICtrlFactory::create<LLIconCtrl>(icon_params); + addChild(mPicture); - icon_params = p.icon_over; - mIconOver = LLUICtrlFactory::create<LLIconCtrl>(icon_params); - addChild(mIconOver); + icon_params = p.icon_over; + mIconOver = LLUICtrlFactory::create<LLIconCtrl>(icon_params); + addChild(mIconOver); - icon_params = p.icon_selected; - mIconSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params); - addChild(mIconSelected); + icon_params = p.icon_selected; + mIconSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params); + addChild(mIconSelected); - icon_params = p.selected_picture; - mPictureSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params); - addChild(mPictureSelected); + icon_params = p.selected_picture; + mPictureSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params); + addChild(mPictureSelected); - LLTextBox::Params text_params = p.text; - mText = LLUICtrlFactory::create<LLTextBox>(text_params); - addChild(mText); + LLTextBox::Params text_params = p.text; + mText = LLUICtrlFactory::create<LLTextBox>(text_params); + addChild(mText); - if (p.mousedown_callback.isProvided()) - { - setCommitCallback(initCommitCallback(p.mousedown_callback)); - } + if (p.mousedown_callback.isProvided()) + { + setCommitCallback(initCommitCallback(p.mousedown_callback)); + } } void set_view_visible(LLView* parent, const std::string& name, bool visible) { - parent->getChildView(name)->setVisible(visible); + parent->getChildView(name)->setVisible(visible); } BOOL LLPanelCameraItem::postBuild() { - setMouseEnterCallback(boost::bind(set_view_visible, this, "hovered_icon", true)); - setMouseLeaveCallback(boost::bind(set_view_visible, this, "hovered_icon", false)); - setMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this)); - setRightMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this)); - return TRUE; + setMouseEnterCallback(boost::bind(set_view_visible, this, "hovered_icon", true)); + setMouseLeaveCallback(boost::bind(set_view_visible, this, "hovered_icon", false)); + setMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this)); + setRightMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this)); + return TRUE; } void LLPanelCameraItem::onAnyMouseClick() { - if (mCommitSignal) (*mCommitSignal)(this, LLSD()); + if (mCommitSignal) (*mCommitSignal)(this, LLSD()); } void LLPanelCameraItem::setValue(const LLSD& value) { - if (!value.isMap()) return;; - if (!value.has("selected")) return; - getChildView("selected_icon")->setVisible( value["selected"]); - getChildView("picture")->setVisible( !value["selected"]); - getChildView("selected_picture")->setVisible( value["selected"]); + if (!value.isMap()) return;; + if (!value.has("selected")) return; + getChildView("selected_icon")->setVisible( value["selected"]); + getChildView("picture")->setVisible( !value["selected"]); + getChildView("selected_picture")->setVisible( value["selected"]); } static LLPanelInjector<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel"); @@ -158,85 +158,85 @@ static LLPanelInjector<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel //------------------------------------------------------------------------------- LLPanelCameraZoom::LLPanelCameraZoom() -: mPlusBtn( NULL ), - mMinusBtn( NULL ), - mSlider( NULL ) +: mPlusBtn( NULL ), + mMinusBtn( NULL ), + mSlider( NULL ) { - mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this)); - mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this)); - mCommitCallbackRegistrar.add("Slider.value_changed", boost::bind(&LLPanelCameraZoom::onSliderValueChanged, this)); - mCommitCallbackRegistrar.add("Camera.track", boost::bind(&LLPanelCameraZoom::onCameraTrack, this)); - mCommitCallbackRegistrar.add("Camera.rotate", boost::bind(&LLPanelCameraZoom::onCameraRotate, this)); + mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this)); + mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this)); + mCommitCallbackRegistrar.add("Slider.value_changed", boost::bind(&LLPanelCameraZoom::onSliderValueChanged, this)); + mCommitCallbackRegistrar.add("Camera.track", boost::bind(&LLPanelCameraZoom::onCameraTrack, this)); + mCommitCallbackRegistrar.add("Camera.rotate", boost::bind(&LLPanelCameraZoom::onCameraRotate, this)); } BOOL LLPanelCameraZoom::postBuild() { - mPlusBtn = getChild <LLButton> ("zoom_plus_btn"); - mMinusBtn = getChild <LLButton> ("zoom_minus_btn"); - mSlider = getChild <LLSlider> ("zoom_slider"); - return LLPanel::postBuild(); + mPlusBtn = getChild <LLButton> ("zoom_plus_btn"); + mMinusBtn = getChild <LLButton> ("zoom_minus_btn"); + mSlider = getChild <LLSlider> ("zoom_slider"); + return LLPanel::postBuild(); } void LLPanelCameraZoom::draw() { - mSlider->setValue(gAgentCamera.getCameraZoomFraction()); - LLPanel::draw(); + mSlider->setValue(gAgentCamera.getCameraZoomFraction()); + LLPanel::draw(); } void LLPanelCameraZoom::onZoomPlusHeldDown() { - F32 val = mSlider->getValueF32(); - F32 inc = mSlider->getIncrement(); - mSlider->setValue(val - inc); - F32 time = mPlusBtn->getHeldDownTime(); - gAgentCamera.unlockView(); - gAgentCamera.setOrbitInKey(getOrbitRate(time)); + F32 val = mSlider->getValueF32(); + F32 inc = mSlider->getIncrement(); + mSlider->setValue(val - inc); + F32 time = mPlusBtn->getHeldDownTime(); + gAgentCamera.unlockView(); + gAgentCamera.setOrbitInKey(getOrbitRate(time)); } void LLPanelCameraZoom::onZoomMinusHeldDown() { - F32 val = mSlider->getValueF32(); - F32 inc = mSlider->getIncrement(); - mSlider->setValue(val + inc); - F32 time = mMinusBtn->getHeldDownTime(); - gAgentCamera.unlockView(); - gAgentCamera.setOrbitOutKey(getOrbitRate(time)); + F32 val = mSlider->getValueF32(); + F32 inc = mSlider->getIncrement(); + mSlider->setValue(val + inc); + F32 time = mMinusBtn->getHeldDownTime(); + gAgentCamera.unlockView(); + gAgentCamera.setOrbitOutKey(getOrbitRate(time)); } void LLPanelCameraZoom::onCameraTrack() { - // EXP-202 when camera panning activated, remove the hint - LLFirstUse::viewPopup( false ); + // EXP-202 when camera panning activated, remove the hint + LLFirstUse::viewPopup( false ); } void LLPanelCameraZoom::onCameraRotate() { - // EXP-202 when camera rotation activated, remove the hint - LLFirstUse::viewPopup( false ); + // EXP-202 when camera rotation activated, remove the hint + LLFirstUse::viewPopup( false ); } F32 LLPanelCameraZoom::getOrbitRate(F32 time) { - if( time < NUDGE_TIME ) - { - F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME; - return rate; - } - else - { - return 1; - } + if( time < NUDGE_TIME ) + { + F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME; + return rate; + } + else + { + return 1; + } } void LLPanelCameraZoom::onSliderValueChanged() { - F32 zoom_level = mSlider->getValueF32(); - gAgentCamera.setCameraZoomFraction(zoom_level); + F32 zoom_level = mSlider->getValueF32(); + gAgentCamera.setCameraZoomFraction(zoom_level); } void activate_camera_tool() { - LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance()); + LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance()); }; // @@ -245,375 +245,375 @@ void activate_camera_tool() /*static*/ bool LLFloaterCamera::inFreeCameraMode() { - LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); - if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK) - { - return true; - } - return false; + LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); + if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK) + { + return true; + } + return false; } void LLFloaterCamera::resetCameraMode() { - LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); - if (!floater_camera) return; - floater_camera->switchMode(CAMERA_CTRL_MODE_PAN); + LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); + if (!floater_camera) return; + floater_camera->switchMode(CAMERA_CTRL_MODE_PAN); } void LLFloaterCamera::onAvatarEditingAppearance(bool editing) { - sAppearanceEditing = editing; - LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); - if (!floater_camera) return; - floater_camera->handleAvatarEditingAppearance(editing); + sAppearanceEditing = editing; + LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); + if (!floater_camera) return; + floater_camera->handleAvatarEditingAppearance(editing); } void LLFloaterCamera::handleAvatarEditingAppearance(bool editing) { - //camera presets (rear, front, etc.) - getChildView("preset_views_list")->setEnabled(!editing); - getChildView("presets_btn")->setEnabled(!editing); + //camera presets (rear, front, etc.) + getChildView("preset_views_list")->setEnabled(!editing); + getChildView("presets_btn")->setEnabled(!editing); - //camera modes (object view, mouselook view) - getChildView("camera_modes_list")->setEnabled(!editing); - getChildView("avatarview_btn")->setEnabled(!editing); + //camera modes (object view, mouselook view) + getChildView("camera_modes_list")->setEnabled(!editing); + getChildView("avatarview_btn")->setEnabled(!editing); } void LLFloaterCamera::update() { - ECameraControlMode mode = determineMode(); - if (mode != mCurrMode) setMode(mode); + ECameraControlMode mode = determineMode(); + if (mode != mCurrMode) setMode(mode); } void LLFloaterCamera::toPrevMode() { - switchMode(mPrevMode); + switchMode(mPrevMode); } /*static*/ void LLFloaterCamera::onLeavingMouseLook() { - LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); - if (floater_camera) - { - floater_camera->updateItemsSelection(); - if(floater_camera->inFreeCameraMode()) - { - activate_camera_tool(); - } - } + LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); + if (floater_camera) + { + floater_camera->updateItemsSelection(); + if(floater_camera->inFreeCameraMode()) + { + activate_camera_tool(); + } + } } LLFloaterCamera* LLFloaterCamera::findInstance() { - return LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera"); + return LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera"); } void LLFloaterCamera::onOpen(const LLSD& key) { - LLFirstUse::viewPopup(); + LLFirstUse::viewPopup(); - mZoom->onOpen(key); + mZoom->onOpen(key); - // Returns to previous mode, see EXT-2727(View tool should remember state). - // In case floater was just hidden and it isn't reset the mode - // just update state to current one. Else go to previous. - if ( !mClosed ) - updateState(); - else - toPrevMode(); - mClosed = FALSE; + // Returns to previous mode, see EXT-2727(View tool should remember state). + // In case floater was just hidden and it isn't reset the mode + // just update state to current one. Else go to previous. + if ( !mClosed ) + updateState(); + else + toPrevMode(); + mClosed = FALSE; } void LLFloaterCamera::onClose(bool app_quitting) { - //We don't care of camera mode if app is quitting - if(app_quitting) - return; - // It is necessary to reset mCurrMode to CAMERA_CTRL_MODE_PAN so - // to avoid seeing an empty floater when reopening the control. - if (mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA) - mCurrMode = CAMERA_CTRL_MODE_PAN; - // When mCurrMode is in CAMERA_CTRL_MODE_PAN - // switchMode won't modify mPrevMode, so force it here. - // It is needed to correctly return to previous mode on open, see EXT-2727. - if (mCurrMode == CAMERA_CTRL_MODE_PAN) - mPrevMode = CAMERA_CTRL_MODE_PAN; + //We don't care of camera mode if app is quitting + if(app_quitting) + return; + // It is necessary to reset mCurrMode to CAMERA_CTRL_MODE_PAN so + // to avoid seeing an empty floater when reopening the control. + if (mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA) + mCurrMode = CAMERA_CTRL_MODE_PAN; + // When mCurrMode is in CAMERA_CTRL_MODE_PAN + // switchMode won't modify mPrevMode, so force it here. + // It is needed to correctly return to previous mode on open, see EXT-2727. + if (mCurrMode == CAMERA_CTRL_MODE_PAN) + mPrevMode = CAMERA_CTRL_MODE_PAN; - switchMode(CAMERA_CTRL_MODE_PAN); - mClosed = TRUE; + switchMode(CAMERA_CTRL_MODE_PAN); + mClosed = TRUE; - gAgent.setMovementLocked(FALSE); + gAgent.setMovementLocked(FALSE); } LLFloaterCamera::LLFloaterCamera(const LLSD& val) -: LLFloater(val), - mClosed(FALSE), - mCurrMode(CAMERA_CTRL_MODE_PAN), - mPrevMode(CAMERA_CTRL_MODE_PAN) +: LLFloater(val), + mClosed(FALSE), + mCurrMode(CAMERA_CTRL_MODE_PAN), + mPrevMode(CAMERA_CTRL_MODE_PAN) { - LLHints::registerHintTarget("view_popup", getHandle()); - mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2)); - mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLFloaterCamera::onViewButtonClick, this, _2)); + LLHints::registerHintTarget("view_popup", getHandle()); + mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2)); + mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLFloaterCamera::onViewButtonClick, this, _2)); } // virtual BOOL LLFloaterCamera::postBuild() { - updateTransparency(TT_ACTIVE); // force using active floater transparency (STORM-730) + updateTransparency(TT_ACTIVE); // force using active floater transparency (STORM-730) - mRotate = getChild<LLJoystickCameraRotate>(ORBIT); - mZoom = findChild<LLPanelCameraZoom>(ZOOM); - mTrack = getChild<LLJoystickCameraTrack>(PAN); + mRotate = getChild<LLJoystickCameraRotate>(ORBIT); + mZoom = findChild<LLPanelCameraZoom>(ZOOM); + mTrack = getChild<LLJoystickCameraTrack>(PAN); - assignButton2Mode(CAMERA_CTRL_MODE_MODES, "avatarview_btn"); - assignButton2Mode(CAMERA_CTRL_MODE_PAN, "pan_btn"); - assignButton2Mode(CAMERA_CTRL_MODE_PRESETS, "presets_btn"); + assignButton2Mode(CAMERA_CTRL_MODE_MODES, "avatarview_btn"); + assignButton2Mode(CAMERA_CTRL_MODE_PAN, "pan_btn"); + assignButton2Mode(CAMERA_CTRL_MODE_PRESETS, "presets_btn"); - update(); + update(); - // ensure that appearance mode is handled while building. See EXT-7796. - handleAvatarEditingAppearance(sAppearanceEditing); + // ensure that appearance mode is handled while building. See EXT-7796. + handleAvatarEditingAppearance(sAppearanceEditing); - return LLFloater::postBuild(); + return LLFloater::postBuild(); } -F32 LLFloaterCamera::getCurrentTransparency() +F32 LLFloaterCamera::getCurrentTransparency() { - static LLCachedControl<F32> camera_opacity(gSavedSettings, "CameraOpacity"); - static LLCachedControl<F32> active_floater_transparency(gSavedSettings, "ActiveFloaterTransparency"); - return llmin(camera_opacity(), active_floater_transparency()); + static LLCachedControl<F32> camera_opacity(gSavedSettings, "CameraOpacity"); + static LLCachedControl<F32> active_floater_transparency(gSavedSettings, "ActiveFloaterTransparency"); + return llmin(camera_opacity(), active_floater_transparency()); } void LLFloaterCamera::onViewButtonClick(const LLSD& user_data) { - // bring up the prefs floater - LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences"); - if (prefsfloater) - { - // grab the 'view' panel from the preferences floater and - // bring it the front! - LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core"); - LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view"); - if (tabcontainer && graphicspanel) - { - tabcontainer->selectTabPanel(graphicspanel); - } - } + // bring up the prefs floater + LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences"); + if (prefsfloater) + { + // grab the 'view' panel from the preferences floater and + // bring it the front! + LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core"); + LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view"); + if (tabcontainer && graphicspanel) + { + tabcontainer->selectTabPanel(graphicspanel); + } + } } void LLFloaterCamera::fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel) { - // copying child list and then iterating over a copy, because list itself - // is changed in process - const child_list_t child_list = *panel->getChildList(); - child_list_t::const_reverse_iterator iter = child_list.rbegin(); - child_list_t::const_reverse_iterator end = child_list.rend(); - for ( ; iter != end; ++iter) - { - LLView* view = *iter; - LLPanel* item = dynamic_cast<LLPanel*>(view); - if (panel) - list->addItem(item); - } + // copying child list and then iterating over a copy, because list itself + // is changed in process + const child_list_t child_list = *panel->getChildList(); + child_list_t::const_reverse_iterator iter = child_list.rbegin(); + child_list_t::const_reverse_iterator end = child_list.rend(); + for ( ; iter != end; ++iter) + { + LLView* view = *iter; + LLPanel* item = dynamic_cast<LLPanel*>(view); + if (panel) + list->addItem(item); + } } ECameraControlMode LLFloaterCamera::determineMode() { - if (sAppearanceEditing) - { - // this is the only enabled camera mode while editing agent appearance. - return CAMERA_CTRL_MODE_PAN; - } + if (sAppearanceEditing) + { + // this is the only enabled camera mode while editing agent appearance. + return CAMERA_CTRL_MODE_PAN; + } - LLTool* curr_tool = LLToolMgr::getInstance()->getCurrentTool(); - if (curr_tool == LLToolCamera::getInstance()) - { - return CAMERA_CTRL_MODE_FREE_CAMERA; - } + LLTool* curr_tool = LLToolMgr::getInstance()->getCurrentTool(); + if (curr_tool == LLToolCamera::getInstance()) + { + return CAMERA_CTRL_MODE_FREE_CAMERA; + } - if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK) - { - return CAMERA_CTRL_MODE_PRESETS; - } + if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK) + { + return CAMERA_CTRL_MODE_PRESETS; + } - return CAMERA_CTRL_MODE_PAN; + return CAMERA_CTRL_MODE_PAN; } void clear_camera_tool() { - LLToolMgr* tool_mgr = LLToolMgr::getInstance(); - if (tool_mgr->usingTransientTool() && - tool_mgr->getCurrentTool() == LLToolCamera::getInstance()) - { - tool_mgr->clearTransientTool(); - } + LLToolMgr* tool_mgr = LLToolMgr::getInstance(); + if (tool_mgr->usingTransientTool() && + tool_mgr->getCurrentTool() == LLToolCamera::getInstance()) + { + tool_mgr->clearTransientTool(); + } } void LLFloaterCamera::setMode(ECameraControlMode mode) { - if (mode != mCurrMode) - { - mPrevMode = mCurrMode; - mCurrMode = mode; - } - - updateState(); + if (mode != mCurrMode) + { + mPrevMode = mCurrMode; + mCurrMode = mode; + } + + updateState(); } void LLFloaterCamera::switchMode(ECameraControlMode mode) { - setMode(mode); + setMode(mode); - switch (mode) - { - case CAMERA_CTRL_MODE_MODES: - if(sFreeCamera) - { - switchMode(CAMERA_CTRL_MODE_FREE_CAMERA); - } - break; + switch (mode) + { + case CAMERA_CTRL_MODE_MODES: + if(sFreeCamera) + { + switchMode(CAMERA_CTRL_MODE_FREE_CAMERA); + } + break; - case CAMERA_CTRL_MODE_PAN: - sFreeCamera = false; - clear_camera_tool(); - break; + case CAMERA_CTRL_MODE_PAN: + sFreeCamera = false; + clear_camera_tool(); + break; - case CAMERA_CTRL_MODE_FREE_CAMERA: - sFreeCamera = true; - activate_camera_tool(); - break; + case CAMERA_CTRL_MODE_FREE_CAMERA: + sFreeCamera = true; + activate_camera_tool(); + break; - case CAMERA_CTRL_MODE_PRESETS: - if(sFreeCamera) - { - switchMode(CAMERA_CTRL_MODE_FREE_CAMERA); - } - break; + case CAMERA_CTRL_MODE_PRESETS: + if(sFreeCamera) + { + switchMode(CAMERA_CTRL_MODE_FREE_CAMERA); + } + break; - default: - //normally we won't occur here - llassert_always(FALSE); - } + default: + //normally we won't occur here + llassert_always(FALSE); + } } void LLFloaterCamera::onClickBtn(ECameraControlMode mode) { - // check for a click on active button - if (mCurrMode == mode) mMode2Button[mode]->setToggleState(TRUE); - - switchMode(mode); + // check for a click on active button + if (mCurrMode == mode) mMode2Button[mode]->setToggleState(TRUE); + + switchMode(mode); } void LLFloaterCamera::assignButton2Mode(ECameraControlMode mode, const std::string& button_name) { - LLButton* button = getChild<LLButton>(button_name); - - button->setClickedCallback(boost::bind(&LLFloaterCamera::onClickBtn, this, mode)); - mMode2Button[mode] = button; + LLButton* button = getChild<LLButton>(button_name); + + button->setClickedCallback(boost::bind(&LLFloaterCamera::onClickBtn, this, mode)); + mMode2Button[mode] = button; } void LLFloaterCamera::updateState() { - getChildView(ZOOM)->setVisible(CAMERA_CTRL_MODE_PAN == mCurrMode); - - bool show_presets = (CAMERA_CTRL_MODE_PRESETS == mCurrMode) || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode - && CAMERA_CTRL_MODE_PRESETS == mPrevMode); - getChildView(PRESETS)->setVisible(show_presets); - - bool show_camera_modes = CAMERA_CTRL_MODE_MODES == mCurrMode || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode - && CAMERA_CTRL_MODE_MODES == mPrevMode); - getChildView("camera_modes_list")->setVisible( show_camera_modes); + getChildView(ZOOM)->setVisible(CAMERA_CTRL_MODE_PAN == mCurrMode); + + bool show_presets = (CAMERA_CTRL_MODE_PRESETS == mCurrMode) || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode + && CAMERA_CTRL_MODE_PRESETS == mPrevMode); + getChildView(PRESETS)->setVisible(show_presets); + + bool show_camera_modes = CAMERA_CTRL_MODE_MODES == mCurrMode || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode + && CAMERA_CTRL_MODE_MODES == mPrevMode); + getChildView("camera_modes_list")->setVisible( show_camera_modes); - updateItemsSelection(); + updateItemsSelection(); - if (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode) - { - return; - } + if (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode) + { + return; + } - //updating buttons - std::map<ECameraControlMode, LLButton*>::const_iterator iter = mMode2Button.begin(); - for (; iter != mMode2Button.end(); ++iter) - { - iter->second->setToggleState(iter->first == mCurrMode); - } + //updating buttons + std::map<ECameraControlMode, LLButton*>::const_iterator iter = mMode2Button.begin(); + for (; iter != mMode2Button.end(); ++iter) + { + iter->second->setToggleState(iter->first == mCurrMode); + } } void LLFloaterCamera::updateItemsSelection() { - ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); - LLSD argument; - argument["selected"] = preset == CAMERA_PRESET_REAR_VIEW; - getChild<LLPanelCameraItem>("rear_view")->setValue(argument); - argument["selected"] = preset == CAMERA_PRESET_GROUP_VIEW; - getChild<LLPanelCameraItem>("group_view")->setValue(argument); - argument["selected"] = preset == CAMERA_PRESET_FRONT_VIEW; - getChild<LLPanelCameraItem>("front_view")->setValue(argument); - argument["selected"] = gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK; - getChild<LLPanelCameraItem>("mouselook_view")->setValue(argument); - argument["selected"] = mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA; - getChild<LLPanelCameraItem>("object_view")->setValue(argument); + ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); + LLSD argument; + argument["selected"] = preset == CAMERA_PRESET_REAR_VIEW; + getChild<LLPanelCameraItem>("rear_view")->setValue(argument); + argument["selected"] = preset == CAMERA_PRESET_GROUP_VIEW; + getChild<LLPanelCameraItem>("group_view")->setValue(argument); + argument["selected"] = preset == CAMERA_PRESET_FRONT_VIEW; + getChild<LLPanelCameraItem>("front_view")->setValue(argument); + argument["selected"] = gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK; + getChild<LLPanelCameraItem>("mouselook_view")->setValue(argument); + argument["selected"] = mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA; + getChild<LLPanelCameraItem>("object_view")->setValue(argument); } void LLFloaterCamera::onClickCameraItem(const LLSD& param) { - std::string name = param.asString(); - - if ("mouselook_view" == name) - { - gAgentCamera.changeCameraToMouselook(); - } - else if ("object_view" == name) - { - LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); - if (camera_floater) - camera_floater->switchMode(CAMERA_CTRL_MODE_FREE_CAMERA); - } - else - { - switchToPreset(name); - } - - LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); - if (camera_floater) - { - camera_floater->updateItemsSelection(); - camera_floater->fromFreeToPresets(); - } + std::string name = param.asString(); + + if ("mouselook_view" == name) + { + gAgentCamera.changeCameraToMouselook(); + } + else if ("object_view" == name) + { + LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); + if (camera_floater) + camera_floater->switchMode(CAMERA_CTRL_MODE_FREE_CAMERA); + } + else + { + switchToPreset(name); + } + + LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); + if (camera_floater) + { + camera_floater->updateItemsSelection(); + camera_floater->fromFreeToPresets(); + } } /*static*/ void LLFloaterCamera::switchToPreset(const std::string& name) { - sFreeCamera = false; - clear_camera_tool(); - if ("rear_view" == name) - { - gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW); - } - else if ("group_view" == name) - { - gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW); - } - else if ("front_view" == name) - { - gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW); - } + sFreeCamera = false; + clear_camera_tool(); + if ("rear_view" == name) + { + gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW); + } + else if ("group_view" == name) + { + gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW); + } + else if ("front_view" == name) + { + gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW); + } } void LLFloaterCamera::fromFreeToPresets() { - if (!sFreeCamera && mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && mPrevMode == CAMERA_CTRL_MODE_PRESETS) - { - switchMode(CAMERA_CTRL_MODE_PRESETS); - } + if (!sFreeCamera && mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && mPrevMode == CAMERA_CTRL_MODE_PRESETS) + { + switchMode(CAMERA_CTRL_MODE_PRESETS); + } } diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h index 481e9aec1b..1b24b143bf 100644 --- a/indra/newview/llfloatercamera.h +++ b/indra/newview/llfloatercamera.h @@ -39,95 +39,95 @@ class LLPanelCameraZoom; enum ECameraControlMode { - CAMERA_CTRL_MODE_MODES, - CAMERA_CTRL_MODE_PAN, - CAMERA_CTRL_MODE_FREE_CAMERA, - CAMERA_CTRL_MODE_PRESETS + CAMERA_CTRL_MODE_MODES, + CAMERA_CTRL_MODE_PAN, + CAMERA_CTRL_MODE_FREE_CAMERA, + CAMERA_CTRL_MODE_PRESETS }; class LLFloaterCamera : public LLFloater { - friend class LLFloaterReg; - + friend class LLFloaterReg; + public: - /* whether in free camera mode */ - static bool inFreeCameraMode(); - /* callback for camera items selection changing */ - static void onClickCameraItem(const LLSD& param); + /* whether in free camera mode */ + static bool inFreeCameraMode(); + /* callback for camera items selection changing */ + static void onClickCameraItem(const LLSD& param); - static void onLeavingMouseLook(); + static void onLeavingMouseLook(); - /** resets current camera mode to orbit mode */ - static void resetCameraMode(); + /** resets current camera mode to orbit mode */ + static void resetCameraMode(); - /** Called when Avatar is entered/exited editing appearance mode */ - static void onAvatarEditingAppearance(bool editing); + /** Called when Avatar is entered/exited editing appearance mode */ + static void onAvatarEditingAppearance(bool editing); - /* determines actual mode and updates ui */ - void update(); + /* determines actual mode and updates ui */ + void update(); - /*switch to one of the camera presets (front, rear, side)*/ - static void switchToPreset(const std::string& name); + /*switch to one of the camera presets (front, rear, side)*/ + static void switchToPreset(const std::string& name); - /* move to CAMERA_CTRL_MODE_PRESETS from CAMERA_CTRL_MODE_FREE_CAMERA if we are on presets panel and - are not in free camera mode*/ - void fromFreeToPresets(); + /* move to CAMERA_CTRL_MODE_PRESETS from CAMERA_CTRL_MODE_FREE_CAMERA if we are on presets panel and + are not in free camera mode*/ + void fromFreeToPresets(); - virtual void onOpen(const LLSD& key); - virtual void onClose(bool app_quitting); + virtual void onOpen(const LLSD& key); + virtual void onClose(bool app_quitting); - LLJoystickCameraRotate* mRotate; - LLPanelCameraZoom* mZoom; - LLJoystickCameraTrack* mTrack; + LLJoystickCameraRotate* mRotate; + LLPanelCameraZoom* mZoom; + LLJoystickCameraTrack* mTrack; private: - LLFloaterCamera(const LLSD& val); - ~LLFloaterCamera() {}; + LLFloaterCamera(const LLSD& val); + ~LLFloaterCamera() {}; - /* return instance if it exists - created by LLFloaterReg */ - static LLFloaterCamera* findInstance(); + /* return instance if it exists - created by LLFloaterReg */ + static LLFloaterCamera* findInstance(); - /*virtual*/ BOOL postBuild(); + /*virtual*/ BOOL postBuild(); - F32 getCurrentTransparency(); + F32 getCurrentTransparency(); - void onViewButtonClick(const LLSD& user_data); + void onViewButtonClick(const LLSD& user_data); - ECameraControlMode determineMode(); + ECameraControlMode determineMode(); - /* resets to the previous mode */ - void toPrevMode(); + /* resets to the previous mode */ + void toPrevMode(); - /* sets a new mode and performs related actions */ - void switchMode(ECameraControlMode mode); + /* sets a new mode and performs related actions */ + void switchMode(ECameraControlMode mode); - /* sets a new mode preserving previous one and updates ui*/ - void setMode(ECameraControlMode mode); + /* sets a new mode preserving previous one and updates ui*/ + void setMode(ECameraControlMode mode); - /* updates the state (UI) according to the current mode */ - void updateState(); + /* updates the state (UI) according to the current mode */ + void updateState(); - /* update camera modes items selection and camera preset items selection according to the currently selected preset */ - void updateItemsSelection(); + /* update camera modes items selection and camera preset items selection according to the currently selected preset */ + void updateItemsSelection(); - void onClickBtn(ECameraControlMode mode); - void assignButton2Mode(ECameraControlMode mode, const std::string& button_name); - - // fills flatlist with items from given panel - void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel); + void onClickBtn(ECameraControlMode mode); + void assignButton2Mode(ECameraControlMode mode, const std::string& button_name); + + // fills flatlist with items from given panel + void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel); - void handleAvatarEditingAppearance(bool editing); + void handleAvatarEditingAppearance(bool editing); - // set to true when free camera mode is selected in modes list - // remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed - static bool sFreeCamera; - static bool sAppearanceEditing; - BOOL mClosed; - ECameraControlMode mPrevMode; - ECameraControlMode mCurrMode; - std::map<ECameraControlMode, LLButton*> mMode2Button; + // set to true when free camera mode is selected in modes list + // remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed + static bool sFreeCamera; + static bool sAppearanceEditing; + BOOL mClosed; + ECameraControlMode mPrevMode; + ECameraControlMode mCurrMode; + std::map<ECameraControlMode, LLButton*> mMode2Button; }; /** @@ -138,33 +138,33 @@ private: * it's items are used inside of flatlist. */ class LLPanelCameraItem - : public LLPanel + : public LLPanel { public: - struct Params : public LLInitParam::Block<Params, LLPanel::Params> - { - Optional<LLIconCtrl::Params> icon_over; - Optional<LLIconCtrl::Params> icon_selected; - Optional<LLIconCtrl::Params> picture; - Optional<LLIconCtrl::Params> selected_picture; - - Optional<LLTextBox::Params> text; - Optional<CommitCallbackParam> mousedown_callback; - Params(); - }; - /*virtual*/ BOOL postBuild(); - /** setting on/off background icon to indicate selected state */ - /*virtual*/ void setValue(const LLSD& value); - // sends commit signal - void onAnyMouseClick(); + struct Params : public LLInitParam::Block<Params, LLPanel::Params> + { + Optional<LLIconCtrl::Params> icon_over; + Optional<LLIconCtrl::Params> icon_selected; + Optional<LLIconCtrl::Params> picture; + Optional<LLIconCtrl::Params> selected_picture; + + Optional<LLTextBox::Params> text; + Optional<CommitCallbackParam> mousedown_callback; + Params(); + }; + /*virtual*/ BOOL postBuild(); + /** setting on/off background icon to indicate selected state */ + /*virtual*/ void setValue(const LLSD& value); + // sends commit signal + void onAnyMouseClick(); protected: - friend class LLUICtrlFactory; - LLPanelCameraItem(const Params&); - LLIconCtrl* mIconOver; - LLIconCtrl* mIconSelected; - LLIconCtrl* mPicture; - LLIconCtrl* mPictureSelected; - LLTextBox* mText; + friend class LLUICtrlFactory; + LLPanelCameraItem(const Params&); + LLIconCtrl* mIconOver; + LLIconCtrl* mIconSelected; + LLIconCtrl* mPicture; + LLIconCtrl* mPictureSelected; + LLTextBox* mText; }; #endif diff --git a/indra/newview/llfloaterdeleteprefpreset.cpp b/indra/newview/llfloaterdeleteprefpreset.cpp index bd62849b42..dd8117f95f 100644 --- a/indra/newview/llfloaterdeleteprefpreset.cpp +++ b/indra/newview/llfloaterdeleteprefpreset.cpp @@ -37,65 +37,65 @@ #include "llfloaterreg.h" LLFloaterDeletePrefPreset::LLFloaterDeletePrefPreset(const LLSD &key) -: LLFloater(key) +: LLFloater(key) { } // virtual BOOL LLFloaterDeletePrefPreset::postBuild() { - LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences"); - if (preferences) - { - preferences->addDependentFloater(this); - } - getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnDelete, this)); - getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnCancel, this)); - LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeletePrefPreset::onPresetsListChange, this)); - - return TRUE; + LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences"); + if (preferences) + { + preferences->addDependentFloater(this); + } + getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnDelete, this)); + getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnCancel, this)); + LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeletePrefPreset::onPresetsListChange, this)); + + return TRUE; } void LLFloaterDeletePrefPreset::onOpen(const LLSD& key) { - mSubdirectory = key.asString(); - std::string floater_title = getString(std::string("title_") + mSubdirectory); - setTitle(floater_title); + mSubdirectory = key.asString(); + std::string floater_title = getString(std::string("title_") + mSubdirectory); + setTitle(floater_title); - LLComboBox* combo = getChild<LLComboBox>("preset_combo"); - EDefaultOptions option = DEFAULT_HIDE; - bool action; - action = LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option); + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + EDefaultOptions option = DEFAULT_HIDE; + bool action; + action = LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option); - LLButton* delete_btn = getChild<LLButton>("delete"); - delete_btn->setEnabled(action); + LLButton* delete_btn = getChild<LLButton>("delete"); + delete_btn->setEnabled(action); } void LLFloaterDeletePrefPreset::onBtnDelete() { - LLComboBox* combo = getChild<LLComboBox>("preset_combo"); - std::string name = combo->getSimple(); + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + std::string name = combo->getSimple(); - if (!LLPresetsManager::getInstance()->deletePreset(mSubdirectory, name)) - { - LLSD args; - args["NAME"] = name; - LLNotificationsUtil::add("PresetNotDeleted", args); - } + if (!LLPresetsManager::getInstance()->deletePreset(mSubdirectory, name)) + { + LLSD args; + args["NAME"] = name; + LLNotificationsUtil::add("PresetNotDeleted", args); + } - closeFloater(); + closeFloater(); } void LLFloaterDeletePrefPreset::onPresetsListChange() { - LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); - EDefaultOptions option = DEFAULT_HIDE; + EDefaultOptions option = DEFAULT_HIDE; - LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option); + LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option); } void LLFloaterDeletePrefPreset::onBtnCancel() { - closeFloater(); + closeFloater(); } diff --git a/indra/newview/llfloaterloadprefpreset.cpp b/indra/newview/llfloaterloadprefpreset.cpp index fa17a9d40e..0584bf7e09 100644 --- a/indra/newview/llfloaterloadprefpreset.cpp +++ b/indra/newview/llfloaterloadprefpreset.cpp @@ -36,57 +36,57 @@ #include "llviewercontrol.h" LLFloaterLoadPrefPreset::LLFloaterLoadPrefPreset(const LLSD &key) -: LLFloater(key) +: LLFloater(key) { } // virtual BOOL LLFloaterLoadPrefPreset::postBuild() { - LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences"); - if (preferences) - { - preferences->addDependentFloater(this); - } - getChild<LLButton>("ok")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnOk, this)); - getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnCancel, this)); - LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterLoadPrefPreset::onPresetsListChange, this)); - - return TRUE; + LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences"); + if (preferences) + { + preferences->addDependentFloater(this); + } + getChild<LLButton>("ok")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnOk, this)); + getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnCancel, this)); + LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterLoadPrefPreset::onPresetsListChange, this)); + + return TRUE; } void LLFloaterLoadPrefPreset::onOpen(const LLSD& key) { - mSubdirectory = key.asString(); - std::string floater_title = getString(std::string("title_") + mSubdirectory); + mSubdirectory = key.asString(); + std::string floater_title = getString(std::string("title_") + mSubdirectory); - setTitle(floater_title); + setTitle(floater_title); - LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); - EDefaultOptions option = DEFAULT_TOP; - LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option); + EDefaultOptions option = DEFAULT_TOP; + LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option); } void LLFloaterLoadPrefPreset::onPresetsListChange() { - LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); - EDefaultOptions option = DEFAULT_TOP; - LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option); + EDefaultOptions option = DEFAULT_TOP; + LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option); } void LLFloaterLoadPrefPreset::onBtnCancel() { - closeFloater(); + closeFloater(); } void LLFloaterLoadPrefPreset::onBtnOk() { - LLComboBox* combo = getChild<LLComboBox>("preset_combo"); - std::string name = combo->getSimple(); + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + std::string name = combo->getSimple(); - LLPresetsManager::getInstance()->loadPreset(mSubdirectory, name); + LLPresetsManager::getInstance()->loadPreset(mSubdirectory, name); - closeFloater(); + closeFloater(); } diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 6b4e4ceeac..ee85a46405 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -139,35 +139,35 @@ static const F32 ARC_LIMIT_MAP_SCALE = (MAX_ARC_LOG - MIN_ARC_LOG) / (MAX_INDIRE class LLVoiceSetKeyDialog : public LLModalDialog { public: - LLVoiceSetKeyDialog(const LLSD& key); - ~LLVoiceSetKeyDialog(); - - /*virtual*/ BOOL postBuild(); - - void setParent(LLFloaterPreference* parent) { mParent = parent; } - - BOOL handleKeyHere(KEY key, MASK mask); - static void onCancel(void* user_data); - + LLVoiceSetKeyDialog(const LLSD& key); + ~LLVoiceSetKeyDialog(); + + /*virtual*/ BOOL postBuild(); + + void setParent(LLFloaterPreference* parent) { mParent = parent; } + + BOOL handleKeyHere(KEY key, MASK mask); + static void onCancel(void* user_data); + private: - LLFloaterPreference* mParent; + LLFloaterPreference* mParent; }; LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key) : LLModalDialog(key), - mParent(NULL) + mParent(NULL) { } //virtual BOOL LLVoiceSetKeyDialog::postBuild() { - childSetAction("Cancel", onCancel, this); - getChild<LLUICtrl>("Cancel")->setFocus(TRUE); - - gFocusMgr.setKeystrokesOnly(TRUE); - - return TRUE; + childSetAction("Cancel", onCancel, this); + getChild<LLUICtrl>("Cancel")->setFocus(TRUE); + + gFocusMgr.setKeystrokesOnly(TRUE); + + return TRUE; } LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog() @@ -176,25 +176,25 @@ LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog() BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) { - BOOL result = TRUE; - - if (key == 'Q' && mask == MASK_CONTROL) - { - result = FALSE; - } - else if (mParent) - { - mParent->setKey(key); - } - closeFloater(); - return result; + BOOL result = TRUE; + + if (key == 'Q' && mask == MASK_CONTROL) + { + result = FALSE; + } + else if (mParent) + { + mParent->setKey(key); + } + closeFloater(); + return result; } //static void LLVoiceSetKeyDialog::onCancel(void* user_data) { - LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data; - self->closeFloater(); + LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data; + self->closeFloater(); } @@ -204,8 +204,8 @@ void LLVoiceSetKeyDialog::onCancel(void* user_data) // if creating/destroying these is too slow, we'll need to create // a static member and update all our static callbacks -void handleNameTagOptionChanged(const LLSD& newvalue); -void handleDisplayNamesOptionChanged(const LLSD& newvalue); +void handleNameTagOptionChanged(const LLSD& newvalue); +void handleDisplayNamesOptionChanged(const LLSD& newvalue); bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response); bool callback_clear_cache(const LLSD& notification, const LLSD& response); @@ -216,110 +216,110 @@ void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator); bool callback_clear_cache(const LLSD& notification, const LLSD& response) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if ( option == 0 ) // YES - { - // flag client texture cache for clearing next time the client runs - gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); - LLNotificationsUtil::add("CacheWillClear"); - } + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if ( option == 0 ) // YES + { + // flag client texture cache for clearing next time the client runs + gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); + LLNotificationsUtil::add("CacheWillClear"); + } - return false; + return false; } bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if ( option == 0 ) // YES - { - // clean web - LLViewerMedia::clearAllCaches(); - LLViewerMedia::clearAllCookies(); - - // clean nav bar history - LLNavigationBar::getInstance()->clearHistoryCache(); - - // flag client texture cache for clearing next time the client runs - gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); - LLNotificationsUtil::add("CacheWillClear"); - - LLSearchHistory::getInstance()->clearHistory(); - LLSearchHistory::getInstance()->save(); - LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box"); - search_ctrl->clearHistory(); - - LLTeleportHistoryStorage::getInstance()->purgeItems(); - LLTeleportHistoryStorage::getInstance()->save(); - } - - return false; + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if ( option == 0 ) // YES + { + // clean web + LLViewerMedia::clearAllCaches(); + LLViewerMedia::clearAllCookies(); + + // clean nav bar history + LLNavigationBar::getInstance()->clearHistoryCache(); + + // flag client texture cache for clearing next time the client runs + gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); + LLNotificationsUtil::add("CacheWillClear"); + + LLSearchHistory::getInstance()->clearHistory(); + LLSearchHistory::getInstance()->save(); + LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box"); + search_ctrl->clearHistory(); + + LLTeleportHistoryStorage::getInstance()->purgeItems(); + LLTeleportHistoryStorage::getInstance()->save(); + } + + return false; } void handleNameTagOptionChanged(const LLSD& newvalue) { - LLAvatarNameCache::setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames")); - LLVOAvatar::invalidateNameTags(); + LLAvatarNameCache::setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames")); + LLVOAvatar::invalidateNameTags(); } void handleDisplayNamesOptionChanged(const LLSD& newvalue) { - LLAvatarNameCache::setUseDisplayNames(newvalue.asBoolean()); - LLVOAvatar::invalidateNameTags(); + LLAvatarNameCache::setUseDisplayNames(newvalue.asBoolean()); + LLVOAvatar::invalidateNameTags(); } void handleAppearanceCameraMovementChanged(const LLSD& newvalue) { - if(!newvalue.asBoolean() && gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR) - { - gAgentCamera.changeCameraToDefault(); - gAgentCamera.resetView(); - } + if(!newvalue.asBoolean() && gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR) + { + gAgentCamera.changeCameraToDefault(); + gAgentCamera.resetView(); + } } /*bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (0 == option && floater ) - { - if ( floater ) - { - floater->setAllIgnored(); - // LLFirstUse::disableFirstUse(); - floater->buildPopupLists(); - } - } - return false; + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (0 == option && floater ) + { + if ( floater ) + { + floater->setAllIgnored(); + // LLFirstUse::disableFirstUse(); + floater->buildPopupLists(); + } + } + return false; } bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if ( 0 == option && floater ) - { - if ( floater ) - { - floater->resetAllIgnored(); - //LLFirstUse::resetFirstUse(); - floater->buildPopupLists(); - } - } - return false; + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if ( 0 == option && floater ) + { + if ( floater ) + { + floater->resetAllIgnored(); + //LLFirstUse::resetFirstUse(); + floater->buildPopupLists(); + } + } + return false; } */ void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator) { - numerator = 0; - denominator = 0; - for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f) - { - if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f) - { - numerator = ll_round(decimal_val * test_denominator); - denominator = ll_round(test_denominator); - break; - } - } + numerator = 0; + denominator = 0; + for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f) + { + if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f) + { + numerator = ll_round(decimal_val * test_denominator); + denominator = ll_round(test_denominator); + break; + } + } } // static std::string LLFloaterPreference::sSkin = ""; @@ -327,1537 +327,1537 @@ std::string LLFloaterPreference::sSkin = ""; // LLFloaterPreference LLFloaterPreference::LLFloaterPreference(const LLSD& key) - : LLFloater(key), - mGotPersonalInfo(false), - mOriginalIMViaEmail(false), - mLanguageChanged(false), - mAvatarDataInitialized(false), - mClickActionDirty(false) -{ - LLConversationLog::instance().addObserver(this); - - //Build Floater is now Called from LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>); - - static bool registered_dialog = false; - if (!registered_dialog) - { - LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>); - registered_dialog = true; - } - - mCommitCallbackRegistrar.add("Pref.Cancel", boost::bind(&LLFloaterPreference::onBtnCancel, this, _2)); - mCommitCallbackRegistrar.add("Pref.OK", boost::bind(&LLFloaterPreference::onBtnOK, this, _2)); - - mCommitCallbackRegistrar.add("Pref.ClearCache", boost::bind(&LLFloaterPreference::onClickClearCache, this)); - mCommitCallbackRegistrar.add("Pref.WebClearCache", boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this)); - mCommitCallbackRegistrar.add("Pref.SetCache", boost::bind(&LLFloaterPreference::onClickSetCache, this)); - mCommitCallbackRegistrar.add("Pref.ResetCache", boost::bind(&LLFloaterPreference::onClickResetCache, this)); - mCommitCallbackRegistrar.add("Pref.ClickSkin", boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2)); - mCommitCallbackRegistrar.add("Pref.SelectSkin", boost::bind(&LLFloaterPreference::onSelectSkin, this)); - mCommitCallbackRegistrar.add("Pref.VoiceSetKey", boost::bind(&LLFloaterPreference::onClickSetKey, this)); - mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse", boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this)); - mCommitCallbackRegistrar.add("Pref.SetSounds", boost::bind(&LLFloaterPreference::onClickSetSounds, this)); - mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this)); - mCommitCallbackRegistrar.add("Pref.ClickDisablePopup", boost::bind(&LLFloaterPreference::onClickDisablePopup, this)); - mCommitCallbackRegistrar.add("Pref.LogPath", boost::bind(&LLFloaterPreference::onClickLogPath, this)); - mCommitCallbackRegistrar.add("Pref.RenderExceptions", boost::bind(&LLFloaterPreference::onClickRenderExceptions, this)); - mCommitCallbackRegistrar.add("Pref.HardwareDefaults", boost::bind(&LLFloaterPreference::setHardwareDefaults, this)); - mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable", boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this)); - mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreference::updateMaxComplexity, this)); - mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreference::onVertexShaderEnable, this)); - mCommitCallbackRegistrar.add("Pref.WindowedMod", boost::bind(&LLFloaterPreference::onCommitWindowedMode, this)); - mCommitCallbackRegistrar.add("Pref.UpdateSliderText", boost::bind(&LLFloaterPreference::refreshUI,this)); - mCommitCallbackRegistrar.add("Pref.QualityPerformance", boost::bind(&LLFloaterPreference::onChangeQuality, this, _2)); - mCommitCallbackRegistrar.add("Pref.applyUIColor", boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2)); - mCommitCallbackRegistrar.add("Pref.getUIColor", boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2)); - mCommitCallbackRegistrar.add("Pref.MaturitySettings", boost::bind(&LLFloaterPreference::onChangeMaturity, this)); - mCommitCallbackRegistrar.add("Pref.BlockList", boost::bind(&LLFloaterPreference::onClickBlockList, this)); - mCommitCallbackRegistrar.add("Pref.Proxy", boost::bind(&LLFloaterPreference::onClickProxySettings, this)); - mCommitCallbackRegistrar.add("Pref.TranslationSettings", boost::bind(&LLFloaterPreference::onClickTranslationSettings, this)); - mCommitCallbackRegistrar.add("Pref.AutoReplace", boost::bind(&LLFloaterPreference::onClickAutoReplace, this)); - mCommitCallbackRegistrar.add("Pref.PermsDefault", boost::bind(&LLFloaterPreference::onClickPermsDefault, this)); - mCommitCallbackRegistrar.add("Pref.SpellChecker", boost::bind(&LLFloaterPreference::onClickSpellChecker, this)); - mCommitCallbackRegistrar.add("Pref.Advanced", boost::bind(&LLFloaterPreference::onClickAdvanced, this)); - - sSkin = gSavedSettings.getString("SkinCurrent"); - - mCommitCallbackRegistrar.add("Pref.ClickActionChange", boost::bind(&LLFloaterPreference::onClickActionChange, this)); - - gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); - gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); - gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged, _2)); - - gSavedSettings.getControl("AppearanceCameraMovement")->getCommitSignal()->connect(boost::bind(&handleAppearanceCameraMovementChanged, _2)); - - LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this ); - - mCommitCallbackRegistrar.add("Pref.ClearLog", boost::bind(&LLConversationLog::onClearLog, &LLConversationLog::instance())); - mCommitCallbackRegistrar.add("Pref.DeleteTranscripts", boost::bind(&LLFloaterPreference::onDeleteTranscripts, this)); + : LLFloater(key), + mGotPersonalInfo(false), + mOriginalIMViaEmail(false), + mLanguageChanged(false), + mAvatarDataInitialized(false), + mClickActionDirty(false) +{ + LLConversationLog::instance().addObserver(this); + + //Build Floater is now Called from LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>); + + static bool registered_dialog = false; + if (!registered_dialog) + { + LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>); + registered_dialog = true; + } + + mCommitCallbackRegistrar.add("Pref.Cancel", boost::bind(&LLFloaterPreference::onBtnCancel, this, _2)); + mCommitCallbackRegistrar.add("Pref.OK", boost::bind(&LLFloaterPreference::onBtnOK, this, _2)); + + mCommitCallbackRegistrar.add("Pref.ClearCache", boost::bind(&LLFloaterPreference::onClickClearCache, this)); + mCommitCallbackRegistrar.add("Pref.WebClearCache", boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this)); + mCommitCallbackRegistrar.add("Pref.SetCache", boost::bind(&LLFloaterPreference::onClickSetCache, this)); + mCommitCallbackRegistrar.add("Pref.ResetCache", boost::bind(&LLFloaterPreference::onClickResetCache, this)); + mCommitCallbackRegistrar.add("Pref.ClickSkin", boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2)); + mCommitCallbackRegistrar.add("Pref.SelectSkin", boost::bind(&LLFloaterPreference::onSelectSkin, this)); + mCommitCallbackRegistrar.add("Pref.VoiceSetKey", boost::bind(&LLFloaterPreference::onClickSetKey, this)); + mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse", boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this)); + mCommitCallbackRegistrar.add("Pref.SetSounds", boost::bind(&LLFloaterPreference::onClickSetSounds, this)); + mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this)); + mCommitCallbackRegistrar.add("Pref.ClickDisablePopup", boost::bind(&LLFloaterPreference::onClickDisablePopup, this)); + mCommitCallbackRegistrar.add("Pref.LogPath", boost::bind(&LLFloaterPreference::onClickLogPath, this)); + mCommitCallbackRegistrar.add("Pref.RenderExceptions", boost::bind(&LLFloaterPreference::onClickRenderExceptions, this)); + mCommitCallbackRegistrar.add("Pref.HardwareDefaults", boost::bind(&LLFloaterPreference::setHardwareDefaults, this)); + mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable", boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this)); + mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreference::updateMaxComplexity, this)); + mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreference::onVertexShaderEnable, this)); + mCommitCallbackRegistrar.add("Pref.WindowedMod", boost::bind(&LLFloaterPreference::onCommitWindowedMode, this)); + mCommitCallbackRegistrar.add("Pref.UpdateSliderText", boost::bind(&LLFloaterPreference::refreshUI,this)); + mCommitCallbackRegistrar.add("Pref.QualityPerformance", boost::bind(&LLFloaterPreference::onChangeQuality, this, _2)); + mCommitCallbackRegistrar.add("Pref.applyUIColor", boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2)); + mCommitCallbackRegistrar.add("Pref.getUIColor", boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2)); + mCommitCallbackRegistrar.add("Pref.MaturitySettings", boost::bind(&LLFloaterPreference::onChangeMaturity, this)); + mCommitCallbackRegistrar.add("Pref.BlockList", boost::bind(&LLFloaterPreference::onClickBlockList, this)); + mCommitCallbackRegistrar.add("Pref.Proxy", boost::bind(&LLFloaterPreference::onClickProxySettings, this)); + mCommitCallbackRegistrar.add("Pref.TranslationSettings", boost::bind(&LLFloaterPreference::onClickTranslationSettings, this)); + mCommitCallbackRegistrar.add("Pref.AutoReplace", boost::bind(&LLFloaterPreference::onClickAutoReplace, this)); + mCommitCallbackRegistrar.add("Pref.PermsDefault", boost::bind(&LLFloaterPreference::onClickPermsDefault, this)); + mCommitCallbackRegistrar.add("Pref.SpellChecker", boost::bind(&LLFloaterPreference::onClickSpellChecker, this)); + mCommitCallbackRegistrar.add("Pref.Advanced", boost::bind(&LLFloaterPreference::onClickAdvanced, this)); + + sSkin = gSavedSettings.getString("SkinCurrent"); + + mCommitCallbackRegistrar.add("Pref.ClickActionChange", boost::bind(&LLFloaterPreference::onClickActionChange, this)); + + gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); + gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); + gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged, _2)); + + gSavedSettings.getControl("AppearanceCameraMovement")->getCommitSignal()->connect(boost::bind(&handleAppearanceCameraMovementChanged, _2)); + + LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this ); + + mCommitCallbackRegistrar.add("Pref.ClearLog", boost::bind(&LLConversationLog::onClearLog, &LLConversationLog::instance())); + mCommitCallbackRegistrar.add("Pref.DeleteTranscripts", boost::bind(&LLFloaterPreference::onDeleteTranscripts, this)); } void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType type ) { - if ( APT_PROPERTIES == type ) - { - const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>( pData ); - if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null)) - { - storeAvatarProperties( pAvatarData ); - processProfileProperties( pAvatarData ); - } - } + if ( APT_PROPERTIES == type ) + { + const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>( pData ); + if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null)) + { + storeAvatarProperties( pAvatarData ); + processProfileProperties( pAvatarData ); + } + } } void LLFloaterPreference::storeAvatarProperties( const LLAvatarData* pAvatarData ) { - if (LLStartUp::getStartupState() == STATE_STARTED) - { - mAvatarProperties.avatar_id = pAvatarData->avatar_id; - mAvatarProperties.image_id = pAvatarData->image_id; - mAvatarProperties.fl_image_id = pAvatarData->fl_image_id; - mAvatarProperties.about_text = pAvatarData->about_text; - mAvatarProperties.fl_about_text = pAvatarData->fl_about_text; - mAvatarProperties.profile_url = pAvatarData->profile_url; - mAvatarProperties.flags = pAvatarData->flags; - mAvatarProperties.allow_publish = pAvatarData->flags & AVATAR_ALLOW_PUBLISH; - - mAvatarDataInitialized = true; - } + if (LLStartUp::getStartupState() == STATE_STARTED) + { + mAvatarProperties.avatar_id = pAvatarData->avatar_id; + mAvatarProperties.image_id = pAvatarData->image_id; + mAvatarProperties.fl_image_id = pAvatarData->fl_image_id; + mAvatarProperties.about_text = pAvatarData->about_text; + mAvatarProperties.fl_about_text = pAvatarData->fl_about_text; + mAvatarProperties.profile_url = pAvatarData->profile_url; + mAvatarProperties.flags = pAvatarData->flags; + mAvatarProperties.allow_publish = pAvatarData->flags & AVATAR_ALLOW_PUBLISH; + + mAvatarDataInitialized = true; + } } void LLFloaterPreference::processProfileProperties(const LLAvatarData* pAvatarData ) { - getChild<LLUICtrl>("online_searchresults")->setValue( (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH) ); + getChild<LLUICtrl>("online_searchresults")->setValue( (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH) ); } void LLFloaterPreference::saveAvatarProperties( void ) { - const BOOL allowPublish = getChild<LLUICtrl>("online_searchresults")->getValue(); + const BOOL allowPublish = getChild<LLUICtrl>("online_searchresults")->getValue(); - if (allowPublish) - { - mAvatarProperties.flags |= AVATAR_ALLOW_PUBLISH; - } + if (allowPublish) + { + mAvatarProperties.flags |= AVATAR_ALLOW_PUBLISH; + } - // - // NOTE: We really don't want to send the avatar properties unless we absolutely - // need to so we can avoid the accidental profile reset bug, so, if we're - // logged in, the avatar data has been initialized and we have a state change - // for the "allow publish" flag, then set the flag to its new value and send - // the properties update. - // - // NOTE: The only reason we can not remove this update altogether is because of the - // "allow publish" flag, the last remaining profile setting in the viewer - // that doesn't exist in the web profile. - // - if ((LLStartUp::getStartupState() == STATE_STARTED) && mAvatarDataInitialized && (allowPublish != mAvatarProperties.allow_publish)) - { - mAvatarProperties.allow_publish = allowPublish; + // + // NOTE: We really don't want to send the avatar properties unless we absolutely + // need to so we can avoid the accidental profile reset bug, so, if we're + // logged in, the avatar data has been initialized and we have a state change + // for the "allow publish" flag, then set the flag to its new value and send + // the properties update. + // + // NOTE: The only reason we can not remove this update altogether is because of the + // "allow publish" flag, the last remaining profile setting in the viewer + // that doesn't exist in the web profile. + // + if ((LLStartUp::getStartupState() == STATE_STARTED) && mAvatarDataInitialized && (allowPublish != mAvatarProperties.allow_publish)) + { + mAvatarProperties.allow_publish = allowPublish; - LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate( &mAvatarProperties ); - } + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate( &mAvatarProperties ); + } } BOOL LLFloaterPreference::postBuild() { - gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false)); + gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false)); - gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged)); + gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged)); - gSavedSettings.getControl("ChatBubbleOpacity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onNameTagOpacityChange, this, _2)); + gSavedSettings.getControl("ChatBubbleOpacity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onNameTagOpacityChange, this, _2)); - gSavedSettings.getControl("PreferredMaturity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeMaturity, this)); + gSavedSettings.getControl("PreferredMaturity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeMaturity, this)); - gSavedPerAccountSettings.getControl("ModelUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeModelFolder, this)); - gSavedPerAccountSettings.getControl("TextureUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeTextureFolder, this)); - gSavedPerAccountSettings.getControl("SoundUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeSoundFolder, this)); - gSavedPerAccountSettings.getControl("AnimationUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeAnimationFolder, this)); + gSavedPerAccountSettings.getControl("ModelUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeModelFolder, this)); + gSavedPerAccountSettings.getControl("TextureUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeTextureFolder, this)); + gSavedPerAccountSettings.getControl("SoundUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeSoundFolder, this)); + gSavedPerAccountSettings.getControl("AnimationUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeAnimationFolder, this)); - LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); - if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab"))) - tabcontainer->selectFirstTab(); + LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); + if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab"))) + tabcontainer->selectFirstTab(); - getChild<LLUICtrl>("cache_location")->setEnabled(FALSE); // make it read-only but selectable (STORM-227) - std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""); - setCacheLocation(cache_location); + getChild<LLUICtrl>("cache_location")->setEnabled(FALSE); // make it read-only but selectable (STORM-227) + std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""); + setCacheLocation(cache_location); - getChild<LLUICtrl>("log_path_string")->setEnabled(FALSE); // make it read-only but selectable + getChild<LLUICtrl>("log_path_string")->setEnabled(FALSE); // make it read-only but selectable - getChild<LLComboBox>("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this)); + getChild<LLComboBox>("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this)); - getChild<LLComboBox>("FriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"FriendIMOptions")); - getChild<LLComboBox>("NonFriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NonFriendIMOptions")); - getChild<LLComboBox>("ConferenceIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ConferenceIMOptions")); - getChild<LLComboBox>("GroupChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"GroupChatOptions")); - getChild<LLComboBox>("NearbyChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NearbyChatOptions")); - getChild<LLComboBox>("ObjectIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ObjectIMOptions")); + getChild<LLComboBox>("FriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"FriendIMOptions")); + getChild<LLComboBox>("NonFriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NonFriendIMOptions")); + getChild<LLComboBox>("ConferenceIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ConferenceIMOptions")); + getChild<LLComboBox>("GroupChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"GroupChatOptions")); + getChild<LLComboBox>("NearbyChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NearbyChatOptions")); + getChild<LLComboBox>("ObjectIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ObjectIMOptions")); - // if floater is opened before login set default localized do not disturb message - if (LLStartUp::getStartupState() < STATE_STARTED) - { - gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault")); - } + // if floater is opened before login set default localized do not disturb message + if (LLStartUp::getStartupState() < STATE_STARTED) + { + gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault")); + } - // set 'enable' property for 'Clear log...' button - changed(); + // set 'enable' property for 'Clear log...' button + changed(); - LLLogChat::setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this)); + LLLogChat::setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this)); - LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov"); - fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView()); - fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView()); + LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov"); + fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView()); + fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView()); - return TRUE; + return TRUE; } void LLFloaterPreference::updateDeleteTranscriptsButton() { - std::vector<std::string> list_of_transcriptions_file_names; - LLLogChat::getListOfTranscriptFiles(list_of_transcriptions_file_names); - getChild<LLButton>("delete_transcripts")->setEnabled(list_of_transcriptions_file_names.size() > 0); + std::vector<std::string> list_of_transcriptions_file_names; + LLLogChat::getListOfTranscriptFiles(list_of_transcriptions_file_names); + getChild<LLButton>("delete_transcripts")->setEnabled(list_of_transcriptions_file_names.size() > 0); } void LLFloaterPreference::onDoNotDisturbResponseChanged() { - // set "DoNotDisturbResponseChanged" TRUE if user edited message differs from default, FALSE otherwise - bool response_changed_flag = - LLTrans::getString("DoNotDisturbModeResponseDefault") - != getChild<LLUICtrl>("do_not_disturb_response")->getValue().asString(); + // set "DoNotDisturbResponseChanged" TRUE if user edited message differs from default, FALSE otherwise + bool response_changed_flag = + LLTrans::getString("DoNotDisturbModeResponseDefault") + != getChild<LLUICtrl>("do_not_disturb_response")->getValue().asString(); - gSavedPerAccountSettings.setBOOL("DoNotDisturbResponseChanged", response_changed_flag ); + gSavedPerAccountSettings.setBOOL("DoNotDisturbResponseChanged", response_changed_flag ); } LLFloaterPreference::~LLFloaterPreference() { - LLConversationLog::instance().removeObserver(this); + LLConversationLog::instance().removeObserver(this); } void LLFloaterPreference::draw() { - BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL); - gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected); - - has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL); - gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected); - - LLFloater::draw(); + BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL); + gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected); + + has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL); + gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected); + + LLFloater::draw(); } void LLFloaterPreference::saveSettings() { - LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); - child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); - child_list_t::const_iterator end = tabcontainer->getChildList()->end(); - for ( ; iter != end; ++iter) - { - LLView* view = *iter; - LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); - if (panel) - panel->saveSettings(); - } -} + LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); + child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); + child_list_t::const_iterator end = tabcontainer->getChildList()->end(); + for ( ; iter != end; ++iter) + { + LLView* view = *iter; + LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); + if (panel) + panel->saveSettings(); + } +} void LLFloaterPreference::apply() { - LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this ); - - LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); - if (sSkin != gSavedSettings.getString("SkinCurrent")) - { - LLNotificationsUtil::add("ChangeSkin"); - refreshSkin(this); - } - // Call apply() on all panels that derive from LLPanelPreference - for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); - iter != tabcontainer->getChildList()->end(); ++iter) - { - LLView* view = *iter; - LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); - if (panel) - panel->apply(); - } - - gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor - - LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov"); - fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView()); - fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView()); - - std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""); - setCacheLocation(cache_location); - - LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue()); - - if (hasChild("web_proxy_enabled", TRUE) &&hasChild("web_proxy_editor", TRUE) && hasChild("web_proxy_port", TRUE)) - { - bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue(); - std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue(); - int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue(); - LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port); - } - - if (mGotPersonalInfo) - { - bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean(); - bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean(); - - if ((new_im_via_email != mOriginalIMViaEmail) - ||(new_hide_online != mOriginalHideOnlineStatus)) - { - // This hack is because we are representing several different - // possible strings with a single checkbox. Since most users - // can only select between 2 values, we represent it as a - // checkbox. This breaks down a little bit for liaisons, but - // works out in the end. - if (new_hide_online != mOriginalHideOnlineStatus) - { - if (new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN; - else mDirectoryVisibility = VISIBILITY_DEFAULT; - //Update showonline value, otherwise multiple applys won't work - mOriginalHideOnlineStatus = new_hide_online; - } - gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility); - } - } - - saveAvatarProperties(); - - if (mClickActionDirty) - { - updateClickActionSettings(); - mClickActionDirty = false; - } + LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this ); + + LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); + if (sSkin != gSavedSettings.getString("SkinCurrent")) + { + LLNotificationsUtil::add("ChangeSkin"); + refreshSkin(this); + } + // Call apply() on all panels that derive from LLPanelPreference + for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); + iter != tabcontainer->getChildList()->end(); ++iter) + { + LLView* view = *iter; + LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); + if (panel) + panel->apply(); + } + + gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor + + LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov"); + fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView()); + fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView()); + + std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""); + setCacheLocation(cache_location); + + LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue()); + + if (hasChild("web_proxy_enabled", TRUE) &&hasChild("web_proxy_editor", TRUE) && hasChild("web_proxy_port", TRUE)) + { + bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue(); + std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue(); + int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue(); + LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port); + } + + if (mGotPersonalInfo) + { + bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean(); + bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean(); + + if ((new_im_via_email != mOriginalIMViaEmail) + ||(new_hide_online != mOriginalHideOnlineStatus)) + { + // This hack is because we are representing several different + // possible strings with a single checkbox. Since most users + // can only select between 2 values, we represent it as a + // checkbox. This breaks down a little bit for liaisons, but + // works out in the end. + if (new_hide_online != mOriginalHideOnlineStatus) + { + if (new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN; + else mDirectoryVisibility = VISIBILITY_DEFAULT; + //Update showonline value, otherwise multiple applys won't work + mOriginalHideOnlineStatus = new_hide_online; + } + gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility); + } + } + + saveAvatarProperties(); + + if (mClickActionDirty) + { + updateClickActionSettings(); + mClickActionDirty = false; + } } void LLFloaterPreference::cancel() { - LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); - // Call cancel() on all panels that derive from LLPanelPreference - for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); - iter != tabcontainer->getChildList()->end(); ++iter) - { - LLView* view = *iter; - LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); - if (panel) - panel->cancel(); - } - // hide joystick pref floater - LLFloaterReg::hideInstance("pref_joystick"); - - // hide translation settings floater - LLFloaterReg::hideInstance("prefs_translation"); - - // hide autoreplace settings floater - LLFloaterReg::hideInstance("prefs_autoreplace"); - - // hide spellchecker settings folder - LLFloaterReg::hideInstance("prefs_spellchecker"); - - // hide advanced graphics floater - LLFloaterReg::hideInstance("prefs_graphics_advanced"); - - // reverts any changes to current skin - gSavedSettings.setString("SkinCurrent", sSkin); - - if (mClickActionDirty) - { - updateClickActionControls(); - mClickActionDirty = false; - } - - LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance<LLFloaterPreferenceProxy>("prefs_proxy"); - if (advanced_proxy_settings) - { - advanced_proxy_settings->cancel(); - } - //Need to reload the navmesh if the pathing console is up - LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle(); - if ( !pathfindingConsoleHandle.isDead() ) - { - LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get(); - pPathfindingConsole->onRegionBoundaryCross(); - } - - if (!mSavedGraphicsPreset.empty()) - { - gSavedSettings.setString("PresetGraphicActive", mSavedGraphicsPreset); - LLPresetsManager::getInstance()->triggerChangeSignal(); - } + LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); + // Call cancel() on all panels that derive from LLPanelPreference + for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); + iter != tabcontainer->getChildList()->end(); ++iter) + { + LLView* view = *iter; + LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); + if (panel) + panel->cancel(); + } + // hide joystick pref floater + LLFloaterReg::hideInstance("pref_joystick"); + + // hide translation settings floater + LLFloaterReg::hideInstance("prefs_translation"); + + // hide autoreplace settings floater + LLFloaterReg::hideInstance("prefs_autoreplace"); + + // hide spellchecker settings folder + LLFloaterReg::hideInstance("prefs_spellchecker"); + + // hide advanced graphics floater + LLFloaterReg::hideInstance("prefs_graphics_advanced"); + + // reverts any changes to current skin + gSavedSettings.setString("SkinCurrent", sSkin); + + if (mClickActionDirty) + { + updateClickActionControls(); + mClickActionDirty = false; + } + + LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance<LLFloaterPreferenceProxy>("prefs_proxy"); + if (advanced_proxy_settings) + { + advanced_proxy_settings->cancel(); + } + //Need to reload the navmesh if the pathing console is up + LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle(); + if ( !pathfindingConsoleHandle.isDead() ) + { + LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get(); + pPathfindingConsole->onRegionBoundaryCross(); + } + + if (!mSavedGraphicsPreset.empty()) + { + gSavedSettings.setString("PresetGraphicActive", mSavedGraphicsPreset); + LLPresetsManager::getInstance()->triggerChangeSignal(); + } } void LLFloaterPreference::onOpen(const LLSD& key) { - // this variable and if that follows it are used to properly handle do not disturb mode response message - static bool initialized = FALSE; - // if user is logged in and we haven't initialized do not disturb mode response yet, do it - if (!initialized && LLStartUp::getStartupState() == STATE_STARTED) - { - // Special approach is used for do not disturb response localization, because "DoNotDisturbModeResponse" is - // in non-localizable xml, and also because it may be changed by user and in this case it shouldn't be localized. - // To keep track of whether do not disturb response is default or changed by user additional setting DoNotDisturbResponseChanged - // was added into per account settings. - - // initialization should happen once,so setting variable to TRUE - initialized = TRUE; - // this connection is needed to properly set "DoNotDisturbResponseChanged" setting when user makes changes in - // do not disturb response message. - gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->getSignal()->connect(boost::bind(&LLFloaterPreference::onDoNotDisturbResponseChanged, this)); - } - gAgent.sendAgentUserInfoRequest(); - - /////////////////////////// From LLPanelGeneral ////////////////////////// - // if we have no agent, we can't let them choose anything - // if we have an agent, then we only let them choose if they have a choice - bool can_choose_maturity = - gAgent.getID().notNull() && - (gAgent.isMature() || gAgent.isGodlike()); - - LLComboBox* maturity_combo = getChild<LLComboBox>("maturity_desired_combobox"); - LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest( gAgent.getID() ); - if (can_choose_maturity) - { - // if they're not adult or a god, they shouldn't see the adult selection, so delete it - if (!gAgent.isAdult() && !gAgent.isGodlikeWithoutAdminMenuFakery()) - { - // we're going to remove the adult entry from the combo - LLScrollListCtrl* maturity_list = maturity_combo->findChild<LLScrollListCtrl>("ComboBox"); - if (maturity_list) - { - maturity_list->deleteItems(LLSD(SIM_ACCESS_ADULT)); - } - } - getChildView("maturity_desired_combobox")->setEnabled( true); - getChildView("maturity_desired_textbox")->setVisible( false); - } - else - { - getChild<LLUICtrl>("maturity_desired_textbox")->setValue(maturity_combo->getSelectedItemLabel()); - getChildView("maturity_desired_combobox")->setEnabled( false); - } - - // Forget previous language changes. - mLanguageChanged = false; - - // Display selected maturity icons. - onChangeMaturity(); - - onChangeModelFolder(); - onChangeTextureFolder(); - onChangeSoundFolder(); - onChangeAnimationFolder(); - - // Load (double-)click to walk/teleport settings. - updateClickActionControls(); - - // Enabled/disabled popups, might have been changed by user actions - // while preferences floater was closed. - buildPopupLists(); - - - //get the options that were checked - onNotificationsChange("FriendIMOptions"); - onNotificationsChange("NonFriendIMOptions"); - onNotificationsChange("ConferenceIMOptions"); - onNotificationsChange("GroupChatOptions"); - onNotificationsChange("NearbyChatOptions"); - onNotificationsChange("ObjectIMOptions"); - - LLPanelLogin::setAlwaysRefresh(true); - refresh(); - - // Make sure the current state of prefs are saved away when - // when the floater is opened. That will make cancel do its - // job - saveSettings(); - - // Make sure there is a default preference file - LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA); - LLPresetsManager::getInstance()->createMissingDefault(PRESETS_GRAPHIC); - - bool started = (LLStartUp::getStartupState() == STATE_STARTED); - - LLButton* load_btn = findChild<LLButton>("PrefLoadButton"); - LLButton* save_btn = findChild<LLButton>("PrefSaveButton"); - LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton"); - LLButton* exceptions_btn = findChild<LLButton>("RenderExceptionsButton"); - - if (load_btn && save_btn && delete_btn && exceptions_btn) - { - load_btn->setEnabled(started); - save_btn->setEnabled(started); - delete_btn->setEnabled(started); - exceptions_btn->setEnabled(started); - } - - LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton"); - LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton"); - LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton"); - - if (load_camera_btn && save_camera_btn && delete_camera_btn) - { - load_camera_btn->setEnabled(started); - save_camera_btn->setEnabled(started); - delete_camera_btn->setEnabled(started); - } + // this variable and if that follows it are used to properly handle do not disturb mode response message + static bool initialized = FALSE; + // if user is logged in and we haven't initialized do not disturb mode response yet, do it + if (!initialized && LLStartUp::getStartupState() == STATE_STARTED) + { + // Special approach is used for do not disturb response localization, because "DoNotDisturbModeResponse" is + // in non-localizable xml, and also because it may be changed by user and in this case it shouldn't be localized. + // To keep track of whether do not disturb response is default or changed by user additional setting DoNotDisturbResponseChanged + // was added into per account settings. + + // initialization should happen once,so setting variable to TRUE + initialized = TRUE; + // this connection is needed to properly set "DoNotDisturbResponseChanged" setting when user makes changes in + // do not disturb response message. + gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->getSignal()->connect(boost::bind(&LLFloaterPreference::onDoNotDisturbResponseChanged, this)); + } + gAgent.sendAgentUserInfoRequest(); + + /////////////////////////// From LLPanelGeneral ////////////////////////// + // if we have no agent, we can't let them choose anything + // if we have an agent, then we only let them choose if they have a choice + bool can_choose_maturity = + gAgent.getID().notNull() && + (gAgent.isMature() || gAgent.isGodlike()); + + LLComboBox* maturity_combo = getChild<LLComboBox>("maturity_desired_combobox"); + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest( gAgent.getID() ); + if (can_choose_maturity) + { + // if they're not adult or a god, they shouldn't see the adult selection, so delete it + if (!gAgent.isAdult() && !gAgent.isGodlikeWithoutAdminMenuFakery()) + { + // we're going to remove the adult entry from the combo + LLScrollListCtrl* maturity_list = maturity_combo->findChild<LLScrollListCtrl>("ComboBox"); + if (maturity_list) + { + maturity_list->deleteItems(LLSD(SIM_ACCESS_ADULT)); + } + } + getChildView("maturity_desired_combobox")->setEnabled( true); + getChildView("maturity_desired_textbox")->setVisible( false); + } + else + { + getChild<LLUICtrl>("maturity_desired_textbox")->setValue(maturity_combo->getSelectedItemLabel()); + getChildView("maturity_desired_combobox")->setEnabled( false); + } + + // Forget previous language changes. + mLanguageChanged = false; + + // Display selected maturity icons. + onChangeMaturity(); + + onChangeModelFolder(); + onChangeTextureFolder(); + onChangeSoundFolder(); + onChangeAnimationFolder(); + + // Load (double-)click to walk/teleport settings. + updateClickActionControls(); + + // Enabled/disabled popups, might have been changed by user actions + // while preferences floater was closed. + buildPopupLists(); + + + //get the options that were checked + onNotificationsChange("FriendIMOptions"); + onNotificationsChange("NonFriendIMOptions"); + onNotificationsChange("ConferenceIMOptions"); + onNotificationsChange("GroupChatOptions"); + onNotificationsChange("NearbyChatOptions"); + onNotificationsChange("ObjectIMOptions"); + + LLPanelLogin::setAlwaysRefresh(true); + refresh(); + + // Make sure the current state of prefs are saved away when + // when the floater is opened. That will make cancel do its + // job + saveSettings(); + + // Make sure there is a default preference file + LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA); + LLPresetsManager::getInstance()->createMissingDefault(PRESETS_GRAPHIC); + + bool started = (LLStartUp::getStartupState() == STATE_STARTED); + + LLButton* load_btn = findChild<LLButton>("PrefLoadButton"); + LLButton* save_btn = findChild<LLButton>("PrefSaveButton"); + LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton"); + LLButton* exceptions_btn = findChild<LLButton>("RenderExceptionsButton"); + + if (load_btn && save_btn && delete_btn && exceptions_btn) + { + load_btn->setEnabled(started); + save_btn->setEnabled(started); + delete_btn->setEnabled(started); + exceptions_btn->setEnabled(started); + } + + LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton"); + LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton"); + LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton"); + + if (load_camera_btn && save_camera_btn && delete_camera_btn) + { + load_camera_btn->setEnabled(started); + save_camera_btn->setEnabled(started); + delete_camera_btn->setEnabled(started); + } } void LLFloaterPreference::onVertexShaderEnable() { - refreshEnabledGraphics(); + refreshEnabledGraphics(); } void LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable() { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { - instance->refresh(); - } + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->refresh(); + } - refreshEnabledGraphics(); + refreshEnabledGraphics(); } void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledGraphics() { - refreshEnabledState(); + refreshEnabledState(); } void LLFloaterPreference::onAvatarImpostorsEnable() { - refreshEnabledGraphics(); + refreshEnabledGraphics(); } //static void LLFloaterPreference::initDoNotDisturbResponse() - { - if (!gSavedPerAccountSettings.getBOOL("DoNotDisturbResponseChanged")) - { - //LLTrans::getString("DoNotDisturbModeResponseDefault") is used here for localization (EXT-5885) - gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault")); - } - } + { + if (!gSavedPerAccountSettings.getBOOL("DoNotDisturbResponseChanged")) + { + //LLTrans::getString("DoNotDisturbModeResponseDefault") is used here for localization (EXT-5885) + gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault")); + } + } //static void LLFloaterPreference::updateShowFavoritesCheckbox(bool val) { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { - instance->getChild<LLUICtrl>("favorites_on_login_check")->setValue(val); - } + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->getChild<LLUICtrl>("favorites_on_login_check")->setValue(val); + } } void LLFloaterPreference::setHardwareDefaults() { - std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive"); - if (!preset_graphic_active.empty()) - { - saveGraphicsPreset(preset_graphic_active); - saveSettings(); // save here to be able to return to the previous preset by Cancel - } + std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive"); + if (!preset_graphic_active.empty()) + { + saveGraphicsPreset(preset_graphic_active); + saveSettings(); // save here to be able to return to the previous preset by Cancel + } - LLFeatureManager::getInstance()->applyRecommendedSettings(); + LLFeatureManager::getInstance()->applyRecommendedSettings(); - // reset indirects before refresh because we may have changed what they control - LLAvatarComplexityControls::setIndirectControls(); + // reset indirects before refresh because we may have changed what they control + LLAvatarComplexityControls::setIndirectControls(); - refreshEnabledGraphics(); - gSavedSettings.setString("PresetGraphicActive", ""); - LLPresetsManager::getInstance()->triggerChangeSignal(); + refreshEnabledGraphics(); + gSavedSettings.setString("PresetGraphicActive", ""); + LLPresetsManager::getInstance()->triggerChangeSignal(); - LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); - child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); - child_list_t::const_iterator end = tabcontainer->getChildList()->end(); - for ( ; iter != end; ++iter) - { - LLView* view = *iter; - LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); - if (panel) - { - panel->setHardwareDefaults(); - } - } + LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); + child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); + child_list_t::const_iterator end = tabcontainer->getChildList()->end(); + for ( ; iter != end; ++iter) + { + LLView* view = *iter; + LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); + if (panel) + { + panel->setHardwareDefaults(); + } + } } void LLFloaterPreference::getControlNames(std::vector<std::string>& names) { - LLView* view = findChild<LLView>("display"); - LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); - if (view && advanced) - { - std::list<LLView*> stack; - stack.push_back(view); - stack.push_back(advanced); - while(!stack.empty()) - { - // Process view on top of the stack - LLView* curview = stack.front(); - stack.pop_front(); - - LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); - if (ctrl) - { - LLControlVariable* control = ctrl->getControlVariable(); - if (control) - { - std::string control_name = control->getName(); - if (std::find(names.begin(), names.end(), control_name) == names.end()) - { - names.push_back(control_name); - } - } - } - - for (child_list_t::const_iterator iter = curview->getChildList()->begin(); - iter != curview->getChildList()->end(); ++iter) - { - stack.push_back(*iter); - } - } - } + LLView* view = findChild<LLView>("display"); + LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); + if (view && advanced) + { + std::list<LLView*> stack; + stack.push_back(view); + stack.push_back(advanced); + while(!stack.empty()) + { + // Process view on top of the stack + LLView* curview = stack.front(); + stack.pop_front(); + + LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); + if (ctrl) + { + LLControlVariable* control = ctrl->getControlVariable(); + if (control) + { + std::string control_name = control->getName(); + if (std::find(names.begin(), names.end(), control_name) == names.end()) + { + names.push_back(control_name); + } + } + } + + for (child_list_t::const_iterator iter = curview->getChildList()->begin(); + iter != curview->getChildList()->end(); ++iter) + { + stack.push_back(*iter); + } + } + } } //virtual void LLFloaterPreference::onClose(bool app_quitting) { - gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex()); - LLPanelLogin::setAlwaysRefresh(false); - if (!app_quitting) - { - cancel(); - } + gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex()); + LLPanelLogin::setAlwaysRefresh(false); + if (!app_quitting) + { + cancel(); + } } // static void LLFloaterPreference::onBtnOK(const LLSD& userdata) { - // commit any outstanding text entry - if (hasFocus()) - { - LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); - if (cur_focus && cur_focus->acceptsTextInput()) - { - cur_focus->onCommit(); - } - } - - if (canClose()) - { - saveSettings(); - apply(); - - if (userdata.asString() == "closeadvanced") - { - LLFloaterReg::hideInstance("prefs_graphics_advanced"); - } - else - { - closeFloater(false); - } - - //Conversation transcript and log path changed so reload conversations based on new location - if(mPriorInstantMessageLogPath.length()) - { - if(moveTranscriptsAndLog()) - { - //When floaters are empty but have a chat history files, reload chat history into them - LLFloaterIMSessionTab::reloadEmptyFloaters(); - } - //Couldn't move files so restore the old path and show a notification - else - { - gSavedPerAccountSettings.setString("InstantMessageLogPath", mPriorInstantMessageLogPath); - LLNotificationsUtil::add("PreferenceChatPathChanged"); - } - mPriorInstantMessageLogPath.clear(); - } - - LLUIColorTable::instance().saveUserSettings(); - gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); - - //Only save once logged in and loaded per account settings - if(mGotPersonalInfo) - { - gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE); - } - } - else - { - // Show beep, pop up dialog, etc. - LL_INFOS() << "Can't close preferences!" << LL_ENDL; - } - - LLPanelLogin::updateLocationSelectorsVisibility(); - //Need to reload the navmesh if the pathing console is up - LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle(); - if ( !pathfindingConsoleHandle.isDead() ) - { - LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get(); - pPathfindingConsole->onRegionBoundaryCross(); - } + // commit any outstanding text entry + if (hasFocus()) + { + LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); + if (cur_focus && cur_focus->acceptsTextInput()) + { + cur_focus->onCommit(); + } + } + + if (canClose()) + { + saveSettings(); + apply(); + + if (userdata.asString() == "closeadvanced") + { + LLFloaterReg::hideInstance("prefs_graphics_advanced"); + } + else + { + closeFloater(false); + } + + //Conversation transcript and log path changed so reload conversations based on new location + if(mPriorInstantMessageLogPath.length()) + { + if(moveTranscriptsAndLog()) + { + //When floaters are empty but have a chat history files, reload chat history into them + LLFloaterIMSessionTab::reloadEmptyFloaters(); + } + //Couldn't move files so restore the old path and show a notification + else + { + gSavedPerAccountSettings.setString("InstantMessageLogPath", mPriorInstantMessageLogPath); + LLNotificationsUtil::add("PreferenceChatPathChanged"); + } + mPriorInstantMessageLogPath.clear(); + } + + LLUIColorTable::instance().saveUserSettings(); + gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); + + //Only save once logged in and loaded per account settings + if(mGotPersonalInfo) + { + gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE); + } + } + else + { + // Show beep, pop up dialog, etc. + LL_INFOS() << "Can't close preferences!" << LL_ENDL; + } + + LLPanelLogin::updateLocationSelectorsVisibility(); + //Need to reload the navmesh if the pathing console is up + LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle(); + if ( !pathfindingConsoleHandle.isDead() ) + { + LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get(); + pPathfindingConsole->onRegionBoundaryCross(); + } } // static void LLFloaterPreference::onBtnCancel(const LLSD& userdata) { - if (hasFocus()) - { - LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); - if (cur_focus && cur_focus->acceptsTextInput()) - { - cur_focus->onCommit(); - } - refresh(); - } - cancel(); - - if (userdata.asString() == "closeadvanced") - { - LLFloaterReg::hideInstance("prefs_graphics_advanced"); - } - else - { - closeFloater(); - } + if (hasFocus()) + { + LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); + if (cur_focus && cur_focus->acceptsTextInput()) + { + cur_focus->onCommit(); + } + refresh(); + } + cancel(); + + if (userdata.asString() == "closeadvanced") + { + LLFloaterReg::hideInstance("prefs_graphics_advanced"); + } + else + { + closeFloater(); + } } // static void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email) { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { instance->setPersonalInfo(visibility, im_via_email, is_verified_email); - } + } } void LLFloaterPreference::refreshEnabledGraphics() { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { - instance->refresh(); - } + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->refresh(); + } - LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); - if (advanced) - { - advanced->refresh(); - } + LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); + if (advanced) + { + advanced->refresh(); + } } void LLFloaterPreference::onClickClearCache() { - LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache); + LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache); } void LLFloaterPreference::onClickBrowserClearCache() { - LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache); + LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache); } // Called when user changes language via the combobox. void LLFloaterPreference::onLanguageChange() { - // Let the user know that the change will only take effect after restart. - // Do it only once so that we're not too irritating. - if (!mLanguageChanged) - { - LLNotificationsUtil::add("ChangeLanguage"); - mLanguageChanged = true; - } + // Let the user know that the change will only take effect after restart. + // Do it only once so that we're not too irritating. + if (!mLanguageChanged) + { + LLNotificationsUtil::add("ChangeLanguage"); + mLanguageChanged = true; + } } void LLFloaterPreference::onNotificationsChange(const std::string& OptionName) { - mNotificationOptions[OptionName] = getChild<LLComboBox>(OptionName)->getSelectedItemLabel(); + mNotificationOptions[OptionName] = getChild<LLComboBox>(OptionName)->getSelectedItemLabel(); - bool show_notifications_alert = true; - for (notifications_map::iterator it_notification = mNotificationOptions.begin(); it_notification != mNotificationOptions.end(); it_notification++) - { - if(it_notification->second != "No action") - { - show_notifications_alert = false; - break; - } - } + bool show_notifications_alert = true; + for (notifications_map::iterator it_notification = mNotificationOptions.begin(); it_notification != mNotificationOptions.end(); it_notification++) + { + if(it_notification->second != "No action") + { + show_notifications_alert = false; + break; + } + } - getChild<LLTextBox>("notifications_alert")->setVisible(show_notifications_alert); + getChild<LLTextBox>("notifications_alert")->setVisible(show_notifications_alert); } void LLFloaterPreference::onNameTagOpacityChange(const LLSD& newvalue) { - LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("background"); - if (color_swatch) - { - LLColor4 new_color = color_swatch->get(); - color_swatch->set( new_color.setAlpha(newvalue.asReal()) ); - } + LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("background"); + if (color_swatch) + { + LLColor4 new_color = color_swatch->get(); + color_swatch->set( new_color.setAlpha(newvalue.asReal()) ); + } } void LLFloaterPreference::onClickSetCache() { - std::string cur_name(gSavedSettings.getString("CacheLocation")); -// std::string cur_top_folder(gDirUtilp->getBaseFileName(cur_name)); - - std::string proposed_name(cur_name); + std::string cur_name(gSavedSettings.getString("CacheLocation")); +// std::string cur_top_folder(gDirUtilp->getBaseFileName(cur_name)); + + std::string proposed_name(cur_name); - (new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeCachePath, this, _1, _2), proposed_name))->getFile(); + (new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeCachePath, this, _1, _2), proposed_name))->getFile(); } void LLFloaterPreference::changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name) { - std::string dir_name = filenames[0]; - if (!dir_name.empty() && dir_name != proposed_name) - { - std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name)); - LLNotificationsUtil::add("CacheWillBeMoved"); - gSavedSettings.setString("NewCacheLocation", dir_name); - gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder); - } - else - { - std::string cache_location = gDirUtilp->getCacheDir(); - gSavedSettings.setString("CacheLocation", cache_location); - std::string top_folder(gDirUtilp->getBaseFileName(cache_location)); - gSavedSettings.setString("CacheLocationTopFolder", top_folder); - } + std::string dir_name = filenames[0]; + if (!dir_name.empty() && dir_name != proposed_name) + { + std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name)); + LLNotificationsUtil::add("CacheWillBeMoved"); + gSavedSettings.setString("NewCacheLocation", dir_name); + gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder); + } + else + { + std::string cache_location = gDirUtilp->getCacheDir(); + gSavedSettings.setString("CacheLocation", cache_location); + std::string top_folder(gDirUtilp->getBaseFileName(cache_location)); + gSavedSettings.setString("CacheLocationTopFolder", top_folder); + } } void LLFloaterPreference::onClickResetCache() { - if (gDirUtilp->getCacheDir(false) == gDirUtilp->getCacheDir(true)) - { - // The cache location was already the default. - return; - } - gSavedSettings.setString("NewCacheLocation", ""); - gSavedSettings.setString("NewCacheLocationTopFolder", ""); - LLNotificationsUtil::add("CacheWillBeMoved"); - std::string cache_location = gDirUtilp->getCacheDir(false); - gSavedSettings.setString("CacheLocation", cache_location); - std::string top_folder(gDirUtilp->getBaseFileName(cache_location)); - gSavedSettings.setString("CacheLocationTopFolder", top_folder); + if (gDirUtilp->getCacheDir(false) == gDirUtilp->getCacheDir(true)) + { + // The cache location was already the default. + return; + } + gSavedSettings.setString("NewCacheLocation", ""); + gSavedSettings.setString("NewCacheLocationTopFolder", ""); + LLNotificationsUtil::add("CacheWillBeMoved"); + std::string cache_location = gDirUtilp->getCacheDir(false); + gSavedSettings.setString("CacheLocation", cache_location); + std::string top_folder(gDirUtilp->getBaseFileName(cache_location)); + gSavedSettings.setString("CacheLocationTopFolder", top_folder); } void LLFloaterPreference::onClickSkin(LLUICtrl* ctrl, const LLSD& userdata) { - gSavedSettings.setString("SkinCurrent", userdata.asString()); - ctrl->setValue(userdata.asString()); + gSavedSettings.setString("SkinCurrent", userdata.asString()); + ctrl->setValue(userdata.asString()); } void LLFloaterPreference::onSelectSkin() { - std::string skin_selection = getChild<LLRadioGroup>("skin_selection")->getValue().asString(); - gSavedSettings.setString("SkinCurrent", skin_selection); + std::string skin_selection = getChild<LLRadioGroup>("skin_selection")->getValue().asString(); + gSavedSettings.setString("SkinCurrent", skin_selection); } void LLFloaterPreference::refreshSkin(void* data) { - LLPanel*self = (LLPanel*)data; - sSkin = gSavedSettings.getString("SkinCurrent"); - self->getChild<LLRadioGroup>("skin_selection", true)->setValue(sSkin); + LLPanel*self = (LLPanel*)data; + sSkin = gSavedSettings.getString("SkinCurrent"); + self->getChild<LLRadioGroup>("skin_selection", true)->setValue(sSkin); } void LLFloaterPreference::buildPopupLists() { - LLScrollListCtrl& disabled_popups = - getChildRef<LLScrollListCtrl>("disabled_popups"); - LLScrollListCtrl& enabled_popups = - getChildRef<LLScrollListCtrl>("enabled_popups"); - - disabled_popups.deleteAllItems(); - enabled_popups.deleteAllItems(); - - for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin(); - iter != LLNotifications::instance().templatesEnd(); - ++iter) - { - LLNotificationTemplatePtr templatep = iter->second; - LLNotificationFormPtr formp = templatep->mForm; - - LLNotificationForm::EIgnoreType ignore = formp->getIgnoreType(); - if (ignore == LLNotificationForm::IGNORE_NO) - continue; - - LLSD row; - row["columns"][0]["value"] = formp->getIgnoreMessage(); - row["columns"][0]["font"] = "SANSSERIF_SMALL"; - row["columns"][0]["width"] = 400; - - LLScrollListItem* item = NULL; - - bool show_popup = !formp->getIgnored(); - if (!show_popup) - { - if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE) - { - LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName); - if (!last_response.isUndefined()) - { - for (LLSD::map_const_iterator it = last_response.beginMap(); - it != last_response.endMap(); - ++it) - { - if (it->second.asBoolean()) - { - row["columns"][1]["value"] = formp->getElement(it->first)["ignore"].asString(); - break; - } - } - } - row["columns"][1]["font"] = "SANSSERIF_SMALL"; - row["columns"][1]["width"] = 360; - } - item = disabled_popups.addElement(row); - } - else - { - item = enabled_popups.addElement(row); - } - - if (item) - { - item->setUserdata((void*)&iter->first); - } - } + LLScrollListCtrl& disabled_popups = + getChildRef<LLScrollListCtrl>("disabled_popups"); + LLScrollListCtrl& enabled_popups = + getChildRef<LLScrollListCtrl>("enabled_popups"); + + disabled_popups.deleteAllItems(); + enabled_popups.deleteAllItems(); + + for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin(); + iter != LLNotifications::instance().templatesEnd(); + ++iter) + { + LLNotificationTemplatePtr templatep = iter->second; + LLNotificationFormPtr formp = templatep->mForm; + + LLNotificationForm::EIgnoreType ignore = formp->getIgnoreType(); + if (ignore == LLNotificationForm::IGNORE_NO) + continue; + + LLSD row; + row["columns"][0]["value"] = formp->getIgnoreMessage(); + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + row["columns"][0]["width"] = 400; + + LLScrollListItem* item = NULL; + + bool show_popup = !formp->getIgnored(); + if (!show_popup) + { + if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE) + { + LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName); + if (!last_response.isUndefined()) + { + for (LLSD::map_const_iterator it = last_response.beginMap(); + it != last_response.endMap(); + ++it) + { + if (it->second.asBoolean()) + { + row["columns"][1]["value"] = formp->getElement(it->first)["ignore"].asString(); + break; + } + } + } + row["columns"][1]["font"] = "SANSSERIF_SMALL"; + row["columns"][1]["width"] = 360; + } + item = disabled_popups.addElement(row); + } + else + { + item = enabled_popups.addElement(row); + } + + if (item) + { + item->setUserdata((void*)&iter->first); + } + } } void LLFloaterPreference::refreshEnabledState() { - LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders"); - LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders"); + LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders"); + LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders"); - // if vertex shaders off, disable all shader related products - if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") || - !LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) - { - ctrl_wind_light->setEnabled(FALSE); - ctrl_wind_light->setValue(FALSE); - } - else - { - ctrl_wind_light->setEnabled(gSavedSettings.getBOOL("VertexShaderEnable")); - } + // if vertex shaders off, disable all shader related products + if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") || + !LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) + { + ctrl_wind_light->setEnabled(FALSE); + ctrl_wind_light->setValue(FALSE); + } + else + { + ctrl_wind_light->setEnabled(gSavedSettings.getBOOL("VertexShaderEnable")); + } - //Deferred/SSAO/Shadows - BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump"); - BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders") && gSavedSettings.getBOOL("VertexShaderEnable"); - BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && - bumpshiny && - shaders && - gGLManager.mHasFramebufferObject && - gSavedSettings.getBOOL("RenderAvatarVP") && - (ctrl_wind_light->get()) ? TRUE : FALSE; + //Deferred/SSAO/Shadows + BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump"); + BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders") && gSavedSettings.getBOOL("VertexShaderEnable"); + BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && + bumpshiny && + shaders && + gGLManager.mHasFramebufferObject && + gSavedSettings.getBOOL("RenderAvatarVP") && + (ctrl_wind_light->get()) ? TRUE : FALSE; - ctrl_deferred->setEnabled(enabled); + ctrl_deferred->setEnabled(enabled); - // Cannot have floater active until caps have been received - getChild<LLButton>("default_creation_permissions")->setEnabled(LLStartUp::getStartupState() < STATE_STARTED ? false : true); + // Cannot have floater active until caps have been received + getChild<LLButton>("default_creation_permissions")->setEnabled(LLStartUp::getStartupState() < STATE_STARTED ? false : true); - getChildView("block_list")->setEnabled(LLLoginInstance::getInstance()->authSuccess()); + getChildView("block_list")->setEnabled(LLLoginInstance::getInstance()->authSuccess()); } void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() { - LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections"); - LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText"); - - // Reflections - BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable") - && gGLManager.mHasCubeMap - && LLCubeMap::sUseCubeMaps; - ctrl_reflections->setEnabled(reflections); - reflections_text->setEnabled(reflections); - - // Bump & Shiny - LLCheckBoxCtrl* bumpshiny_ctrl = getChild<LLCheckBoxCtrl>("BumpShiny"); - bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump"); - bumpshiny_ctrl->setEnabled(bumpshiny ? TRUE : FALSE); + LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections"); + LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText"); + + // Reflections + BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable") + && gGLManager.mHasCubeMap + && LLCubeMap::sUseCubeMaps; + ctrl_reflections->setEnabled(reflections); + reflections_text->setEnabled(reflections); + + // Bump & Shiny + LLCheckBoxCtrl* bumpshiny_ctrl = getChild<LLCheckBoxCtrl>("BumpShiny"); + bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump"); + bumpshiny_ctrl->setEnabled(bumpshiny ? TRUE : FALSE); + + // Avatar Mode + // Enable Avatar Shaders + LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram"); + // Avatar Render Mode + LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth"); - // Avatar Mode - // Enable Avatar Shaders - LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram"); - // Avatar Render Mode - LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth"); - - bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"); - if (LLViewerShaderMgr::sInitialized) - { - S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel; - avatar_vp_enabled = (max_avatar_shader > 0) ? TRUE : FALSE; - } - - ctrl_avatar_vp->setEnabled(avatar_vp_enabled); - - if (gSavedSettings.getBOOL("VertexShaderEnable") == FALSE || - gSavedSettings.getBOOL("RenderAvatarVP") == FALSE) - { - ctrl_avatar_cloth->setEnabled(FALSE); - } - else - { - ctrl_avatar_cloth->setEnabled(TRUE); - } - - // Vertex Shaders - // Global Shader Enable - LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders"); - LLSliderCtrl* terrain_detail = getChild<LLSliderCtrl>("TerrainDetail"); // can be linked with control var - LLTextBox* terrain_text = getChild<LLTextBox>("TerrainDetailText"); - - ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")); - - BOOL shaders = ctrl_shader_enable->get(); - if (shaders) - { - terrain_detail->setEnabled(FALSE); - terrain_text->setEnabled(FALSE); - } - else - { - terrain_detail->setEnabled(TRUE); - terrain_text->setEnabled(TRUE); - } - - // WindLight - LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders"); - LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail"); - LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText"); - - // *HACK just checks to see if we can use shaders... - // maybe some cards that use shaders, but don't support windlight - ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders); - - sky->setEnabled(ctrl_wind_light->get() && shaders); - sky_text->setEnabled(ctrl_wind_light->get() && shaders); - - //Deferred/SSAO/Shadows - LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders"); - - BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && - ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) && - shaders && - gGLManager.mHasFramebufferObject && - gSavedSettings.getBOOL("RenderAvatarVP") && - (ctrl_wind_light->get()) ? TRUE : FALSE; - - ctrl_deferred->setEnabled(enabled); - - LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO"); - LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF"); - LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail"); - LLTextBox* shadow_text = getChild<LLTextBox>("RenderShadowDetailText"); - - // note, okay here to get from ctrl_deferred as it's twin, ctrl_deferred2 will alway match it - enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE); - - ctrl_deferred->set(gSavedSettings.getBOOL("RenderDeferred")); - - ctrl_ssao->setEnabled(enabled); - ctrl_dof->setEnabled(enabled); - - enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"); - - ctrl_shadow->setEnabled(enabled); - shadow_text->setEnabled(enabled); - - // Hardware settings - F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); - S32Megabytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting(); - S32Megabytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier); - getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value()); - getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value()); - - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") || - !gGLManager.mHasVertexBufferObject) - { - getChildView("vbo")->setEnabled(FALSE); - } - - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures") || - !gGLManager.mHasVertexBufferObject) - { - getChildView("texture compression")->setEnabled(FALSE); - } - - // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance - LLUICtrl* gamma_ctrl = getChild<LLUICtrl>("gamma"); - gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders()); - getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders()); - getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders()); - getChildView("antialiasing restart")->setVisible(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred")); - - // now turn off any features that are unavailable - disableUnavailableSettings(); + bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"); + if (LLViewerShaderMgr::sInitialized) + { + S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel; + avatar_vp_enabled = (max_avatar_shader > 0) ? TRUE : FALSE; + } + + ctrl_avatar_vp->setEnabled(avatar_vp_enabled); + + if (gSavedSettings.getBOOL("VertexShaderEnable") == FALSE || + gSavedSettings.getBOOL("RenderAvatarVP") == FALSE) + { + ctrl_avatar_cloth->setEnabled(FALSE); + } + else + { + ctrl_avatar_cloth->setEnabled(TRUE); + } + + // Vertex Shaders + // Global Shader Enable + LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders"); + LLSliderCtrl* terrain_detail = getChild<LLSliderCtrl>("TerrainDetail"); // can be linked with control var + LLTextBox* terrain_text = getChild<LLTextBox>("TerrainDetailText"); + + ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")); + + BOOL shaders = ctrl_shader_enable->get(); + if (shaders) + { + terrain_detail->setEnabled(FALSE); + terrain_text->setEnabled(FALSE); + } + else + { + terrain_detail->setEnabled(TRUE); + terrain_text->setEnabled(TRUE); + } + + // WindLight + LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders"); + LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail"); + LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText"); + + // *HACK just checks to see if we can use shaders... + // maybe some cards that use shaders, but don't support windlight + ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders); + + sky->setEnabled(ctrl_wind_light->get() && shaders); + sky_text->setEnabled(ctrl_wind_light->get() && shaders); + + //Deferred/SSAO/Shadows + LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders"); + + BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && + ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) && + shaders && + gGLManager.mHasFramebufferObject && + gSavedSettings.getBOOL("RenderAvatarVP") && + (ctrl_wind_light->get()) ? TRUE : FALSE; + + ctrl_deferred->setEnabled(enabled); + + LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO"); + LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF"); + LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail"); + LLTextBox* shadow_text = getChild<LLTextBox>("RenderShadowDetailText"); + + // note, okay here to get from ctrl_deferred as it's twin, ctrl_deferred2 will alway match it + enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE); + + ctrl_deferred->set(gSavedSettings.getBOOL("RenderDeferred")); + + ctrl_ssao->setEnabled(enabled); + ctrl_dof->setEnabled(enabled); + + enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"); + + ctrl_shadow->setEnabled(enabled); + shadow_text->setEnabled(enabled); + + // Hardware settings + F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); + S32Megabytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting(); + S32Megabytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier); + getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value()); + getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value()); + + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") || + !gGLManager.mHasVertexBufferObject) + { + getChildView("vbo")->setEnabled(FALSE); + } + + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures") || + !gGLManager.mHasVertexBufferObject) + { + getChildView("texture compression")->setEnabled(FALSE); + } + + // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance + LLUICtrl* gamma_ctrl = getChild<LLUICtrl>("gamma"); + gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders()); + getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders()); + getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders()); + getChildView("antialiasing restart")->setVisible(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred")); + + // now turn off any features that are unavailable + disableUnavailableSettings(); } // static void LLAvatarComplexityControls::setIndirectControls() { - /* - * We have controls that have an indirect relationship between the control - * values and adjacent text and the underlying setting they influence. - * In each case, the control and its associated setting are named Indirect<something> - * This method interrogates the controlled setting and establishes the - * appropriate value for the indirect control. It must be called whenever the - * underlying setting may have changed other than through the indirect control, - * such as when the 'Reset all to recommended settings' button is used... - */ - setIndirectMaxNonImpostors(); - setIndirectMaxArc(); + /* + * We have controls that have an indirect relationship between the control + * values and adjacent text and the underlying setting they influence. + * In each case, the control and its associated setting are named Indirect<something> + * This method interrogates the controlled setting and establishes the + * appropriate value for the indirect control. It must be called whenever the + * underlying setting may have changed other than through the indirect control, + * such as when the 'Reset all to recommended settings' button is used... + */ + setIndirectMaxNonImpostors(); + setIndirectMaxArc(); } // static void LLAvatarComplexityControls::setIndirectMaxNonImpostors() { - U32 max_non_impostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors"); - // for this one, we just need to make zero, which means off, the max value of the slider - U32 indirect_max_non_impostors = (0 == max_non_impostors) ? LLVOAvatar::IMPOSTORS_OFF : max_non_impostors; - gSavedSettings.setU32("IndirectMaxNonImpostors", indirect_max_non_impostors); + U32 max_non_impostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors"); + // for this one, we just need to make zero, which means off, the max value of the slider + U32 indirect_max_non_impostors = (0 == max_non_impostors) ? LLVOAvatar::IMPOSTORS_OFF : max_non_impostors; + gSavedSettings.setU32("IndirectMaxNonImpostors", indirect_max_non_impostors); } void LLAvatarComplexityControls::setIndirectMaxArc() { - U32 max_arc = gSavedSettings.getU32("RenderAvatarMaxComplexity"); - U32 indirect_max_arc; - if (0 == max_arc) - { - // the off position is all the way to the right, so set to control max - indirect_max_arc = INDIRECT_MAX_ARC_OFF; - } - else - { - // This is the inverse of the calculation in updateMaxComplexity - indirect_max_arc = (U32)ll_round(((log(F32(max_arc)) - MIN_ARC_LOG) / ARC_LIMIT_MAP_SCALE)) + MIN_INDIRECT_ARC_LIMIT; - } - gSavedSettings.setU32("IndirectMaxComplexity", indirect_max_arc); + U32 max_arc = gSavedSettings.getU32("RenderAvatarMaxComplexity"); + U32 indirect_max_arc; + if (0 == max_arc) + { + // the off position is all the way to the right, so set to control max + indirect_max_arc = INDIRECT_MAX_ARC_OFF; + } + else + { + // This is the inverse of the calculation in updateMaxComplexity + indirect_max_arc = (U32)ll_round(((log(F32(max_arc)) - MIN_ARC_LOG) / ARC_LIMIT_MAP_SCALE)) + MIN_INDIRECT_ARC_LIMIT; + } + gSavedSettings.setU32("IndirectMaxComplexity", indirect_max_arc); } void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings() -{ - LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections"); - LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText"); - LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram"); - LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth"); - LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders"); - LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders"); - LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders"); - LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail"); - LLTextBox* shadows_text = getChild<LLTextBox>("RenderShadowDetailText"); - LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO"); - LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF"); - LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail"); - LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText"); - - // if vertex shaders off, disable all shader related products - if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")) - { - ctrl_shader_enable->setEnabled(FALSE); - ctrl_shader_enable->setValue(FALSE); - - ctrl_wind_light->setEnabled(FALSE); - ctrl_wind_light->setValue(FALSE); - - sky->setEnabled(FALSE); - sky_text->setEnabled(FALSE); - - ctrl_reflections->setEnabled(FALSE); - ctrl_reflections->setValue(0); - reflections_text->setEnabled(FALSE); - - ctrl_avatar_vp->setEnabled(FALSE); - ctrl_avatar_vp->setValue(FALSE); - - ctrl_avatar_cloth->setEnabled(FALSE); - ctrl_avatar_cloth->setValue(FALSE); - - ctrl_shadows->setEnabled(FALSE); - ctrl_shadows->setValue(0); - shadows_text->setEnabled(FALSE); - - ctrl_ssao->setEnabled(FALSE); - ctrl_ssao->setValue(FALSE); - - ctrl_dof->setEnabled(FALSE); - ctrl_dof->setValue(FALSE); - - ctrl_deferred->setEnabled(FALSE); - ctrl_deferred->setValue(FALSE); - } - - // disabled windlight - if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) - { - ctrl_wind_light->setEnabled(FALSE); - ctrl_wind_light->setValue(FALSE); - - sky->setEnabled(FALSE); - sky_text->setEnabled(FALSE); - - //deferred needs windlight, disable deferred - ctrl_shadows->setEnabled(FALSE); - ctrl_shadows->setValue(0); - shadows_text->setEnabled(FALSE); - - ctrl_ssao->setEnabled(FALSE); - ctrl_ssao->setValue(FALSE); - - ctrl_dof->setEnabled(FALSE); - ctrl_dof->setValue(FALSE); - - ctrl_deferred->setEnabled(FALSE); - ctrl_deferred->setValue(FALSE); - } - - // disabled deferred - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") || - !gGLManager.mHasFramebufferObject) - { - ctrl_shadows->setEnabled(FALSE); - ctrl_shadows->setValue(0); - shadows_text->setEnabled(FALSE); - - ctrl_ssao->setEnabled(FALSE); - ctrl_ssao->setValue(FALSE); - - ctrl_dof->setEnabled(FALSE); - ctrl_dof->setValue(FALSE); - - ctrl_deferred->setEnabled(FALSE); - ctrl_deferred->setValue(FALSE); - } - - // disabled deferred SSAO - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO")) - { - ctrl_ssao->setEnabled(FALSE); - ctrl_ssao->setValue(FALSE); - } - - // disabled deferred shadows - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail")) - { - ctrl_shadows->setEnabled(FALSE); - ctrl_shadows->setValue(0); - shadows_text->setEnabled(FALSE); - } - - // disabled reflections - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail")) - { - ctrl_reflections->setEnabled(FALSE); - ctrl_reflections->setValue(FALSE); - reflections_text->setEnabled(FALSE); - } - - // disabled av - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP")) - { - ctrl_avatar_vp->setEnabled(FALSE); - ctrl_avatar_vp->setValue(FALSE); - - ctrl_avatar_cloth->setEnabled(FALSE); - ctrl_avatar_cloth->setValue(FALSE); - - //deferred needs AvatarVP, disable deferred - ctrl_shadows->setEnabled(FALSE); - ctrl_shadows->setValue(0); - shadows_text->setEnabled(FALSE); - - ctrl_ssao->setEnabled(FALSE); - ctrl_ssao->setValue(FALSE); - - ctrl_dof->setEnabled(FALSE); - ctrl_dof->setValue(FALSE); - - ctrl_deferred->setEnabled(FALSE); - ctrl_deferred->setValue(FALSE); - } - - // disabled cloth - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth")) - { - ctrl_avatar_cloth->setEnabled(FALSE); - ctrl_avatar_cloth->setValue(FALSE); - } +{ + LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections"); + LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText"); + LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram"); + LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth"); + LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders"); + LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders"); + LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders"); + LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail"); + LLTextBox* shadows_text = getChild<LLTextBox>("RenderShadowDetailText"); + LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO"); + LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF"); + LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail"); + LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText"); + + // if vertex shaders off, disable all shader related products + if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")) + { + ctrl_shader_enable->setEnabled(FALSE); + ctrl_shader_enable->setValue(FALSE); + + ctrl_wind_light->setEnabled(FALSE); + ctrl_wind_light->setValue(FALSE); + + sky->setEnabled(FALSE); + sky_text->setEnabled(FALSE); + + ctrl_reflections->setEnabled(FALSE); + ctrl_reflections->setValue(0); + reflections_text->setEnabled(FALSE); + + ctrl_avatar_vp->setEnabled(FALSE); + ctrl_avatar_vp->setValue(FALSE); + + ctrl_avatar_cloth->setEnabled(FALSE); + ctrl_avatar_cloth->setValue(FALSE); + + ctrl_shadows->setEnabled(FALSE); + ctrl_shadows->setValue(0); + shadows_text->setEnabled(FALSE); + + ctrl_ssao->setEnabled(FALSE); + ctrl_ssao->setValue(FALSE); + + ctrl_dof->setEnabled(FALSE); + ctrl_dof->setValue(FALSE); + + ctrl_deferred->setEnabled(FALSE); + ctrl_deferred->setValue(FALSE); + } + + // disabled windlight + if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) + { + ctrl_wind_light->setEnabled(FALSE); + ctrl_wind_light->setValue(FALSE); + + sky->setEnabled(FALSE); + sky_text->setEnabled(FALSE); + + //deferred needs windlight, disable deferred + ctrl_shadows->setEnabled(FALSE); + ctrl_shadows->setValue(0); + shadows_text->setEnabled(FALSE); + + ctrl_ssao->setEnabled(FALSE); + ctrl_ssao->setValue(FALSE); + + ctrl_dof->setEnabled(FALSE); + ctrl_dof->setValue(FALSE); + + ctrl_deferred->setEnabled(FALSE); + ctrl_deferred->setValue(FALSE); + } + + // disabled deferred + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") || + !gGLManager.mHasFramebufferObject) + { + ctrl_shadows->setEnabled(FALSE); + ctrl_shadows->setValue(0); + shadows_text->setEnabled(FALSE); + + ctrl_ssao->setEnabled(FALSE); + ctrl_ssao->setValue(FALSE); + + ctrl_dof->setEnabled(FALSE); + ctrl_dof->setValue(FALSE); + + ctrl_deferred->setEnabled(FALSE); + ctrl_deferred->setValue(FALSE); + } + + // disabled deferred SSAO + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO")) + { + ctrl_ssao->setEnabled(FALSE); + ctrl_ssao->setValue(FALSE); + } + + // disabled deferred shadows + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail")) + { + ctrl_shadows->setEnabled(FALSE); + ctrl_shadows->setValue(0); + shadows_text->setEnabled(FALSE); + } + + // disabled reflections + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail")) + { + ctrl_reflections->setEnabled(FALSE); + ctrl_reflections->setValue(FALSE); + reflections_text->setEnabled(FALSE); + } + + // disabled av + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP")) + { + ctrl_avatar_vp->setEnabled(FALSE); + ctrl_avatar_vp->setValue(FALSE); + + ctrl_avatar_cloth->setEnabled(FALSE); + ctrl_avatar_cloth->setValue(FALSE); + + //deferred needs AvatarVP, disable deferred + ctrl_shadows->setEnabled(FALSE); + ctrl_shadows->setValue(0); + shadows_text->setEnabled(FALSE); + + ctrl_ssao->setEnabled(FALSE); + ctrl_ssao->setValue(FALSE); + + ctrl_dof->setEnabled(FALSE); + ctrl_dof->setValue(FALSE); + + ctrl_deferred->setEnabled(FALSE); + ctrl_deferred->setValue(FALSE); + } + + // disabled cloth + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth")) + { + ctrl_avatar_cloth->setEnabled(FALSE); + ctrl_avatar_cloth->setValue(FALSE); + } } void LLFloaterPreference::refresh() { - LLPanel::refresh(); + LLPanel::refresh(); LLAvatarComplexityControls::setText( gSavedSettings.getU32("RenderAvatarMaxComplexity"), getChild<LLTextBox>("IndirectMaxComplexityText", true)); - refreshEnabledState(); - LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); - if (advanced) - { - advanced->refresh(); - } + refreshEnabledState(); + LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); + if (advanced) + { + advanced->refresh(); + } } void LLFloaterPreferenceGraphicsAdvanced::refresh() { - getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer) gSavedSettings.getU32("RenderFSAASamples")); - - // sliders and their text boxes - // mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow"); - // slider text boxes - updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail", true), getChild<LLTextBox>("ObjectMeshDetailText", true)); - updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail", true), getChild<LLTextBox>("FlexibleMeshDetailText", true)); - updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail", true), getChild<LLTextBox>("TreeMeshDetailText", true)); - updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail", true), getChild<LLTextBox>("AvatarMeshDetailText", true)); - updateSliderText(getChild<LLSliderCtrl>("AvatarPhysicsDetail", true), getChild<LLTextBox>("AvatarPhysicsDetailText", true)); - updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail", true), getChild<LLTextBox>("TerrainMeshDetailText", true)); - updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess", true), getChild<LLTextBox>("PostProcessText", true)); - updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail", true), getChild<LLTextBox>("SkyMeshDetailText", true)); - updateSliderText(getChild<LLSliderCtrl>("TerrainDetail", true), getChild<LLTextBox>("TerrainDetailText", true)); + getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer) gSavedSettings.getU32("RenderFSAASamples")); + + // sliders and their text boxes + // mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow"); + // slider text boxes + updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail", true), getChild<LLTextBox>("ObjectMeshDetailText", true)); + updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail", true), getChild<LLTextBox>("FlexibleMeshDetailText", true)); + updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail", true), getChild<LLTextBox>("TreeMeshDetailText", true)); + updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail", true), getChild<LLTextBox>("AvatarMeshDetailText", true)); + updateSliderText(getChild<LLSliderCtrl>("AvatarPhysicsDetail", true), getChild<LLTextBox>("AvatarPhysicsDetailText", true)); + updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail", true), getChild<LLTextBox>("TerrainMeshDetailText", true)); + updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess", true), getChild<LLTextBox>("PostProcessText", true)); + updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail", true), getChild<LLTextBox>("SkyMeshDetailText", true)); + updateSliderText(getChild<LLSliderCtrl>("TerrainDetail", true), getChild<LLTextBox>("TerrainDetailText", true)); LLAvatarComplexityControls::setIndirectControls(); - setMaxNonImpostorsText( + setMaxNonImpostorsText( gSavedSettings.getU32("RenderAvatarMaxNonImpostors"), getChild<LLTextBox>("IndirectMaxNonImpostorsText", true)); LLAvatarComplexityControls::setText( gSavedSettings.getU32("RenderAvatarMaxComplexity"), getChild<LLTextBox>("IndirectMaxComplexityText", true)); - refreshEnabledState(); + refreshEnabledState(); } void LLFloaterPreference::onCommitWindowedMode() { - refresh(); + refresh(); } void LLFloaterPreference::onChangeQuality(const LLSD& data) { - U32 level = (U32)(data.asReal()); - LLFeatureManager::getInstance()->setGraphicsLevel(level, true); - refreshEnabledGraphics(); - refresh(); + U32 level = (U32)(data.asReal()); + LLFeatureManager::getInstance()->setGraphicsLevel(level, true); + refreshEnabledGraphics(); + refresh(); } void LLFloaterPreference::onClickSetKey() { - LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE); - if (dialog) - { - dialog->setParent(this); - } + LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE); + if (dialog) + { + dialog->setParent(this); + } } void LLFloaterPreference::setKey(KEY key) { - getChild<LLUICtrl>("modifier_combo")->setValue(LLKeyboard::stringFromKey(key)); - // update the control right away since we no longer wait for apply - getChild<LLUICtrl>("modifier_combo")->onCommit(); + getChild<LLUICtrl>("modifier_combo")->setValue(LLKeyboard::stringFromKey(key)); + // update the control right away since we no longer wait for apply + getChild<LLUICtrl>("modifier_combo")->onCommit(); } void LLFloaterPreference::onClickSetMiddleMouse() { - LLUICtrl* p2t_line_editor = getChild<LLUICtrl>("modifier_combo"); + LLUICtrl* p2t_line_editor = getChild<LLUICtrl>("modifier_combo"); - // update the control right away since we no longer wait for apply - p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV); + // update the control right away since we no longer wait for apply + p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV); - //push2talk button "middle mouse" control value is in English, need to localize it for presentation - LLPanel* advanced_preferences = dynamic_cast<LLPanel*>(p2t_line_editor->getParent()); - if (advanced_preferences) - { - p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse")); - } + //push2talk button "middle mouse" control value is in English, need to localize it for presentation + LLPanel* advanced_preferences = dynamic_cast<LLPanel*>(p2t_line_editor->getParent()); + if (advanced_preferences) + { + p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse")); + } } void LLFloaterPreference::onClickSetSounds() { - // Disable Enable gesture sounds checkbox if the master sound is disabled - // or if sound effects are disabled. - getChild<LLCheckBoxCtrl>("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds")); + // Disable Enable gesture sounds checkbox if the master sound is disabled + // or if sound effects are disabled. + getChild<LLCheckBoxCtrl>("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds")); } /* void LLFloaterPreference::onClickSkipDialogs() { - LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this)); + LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this)); } void LLFloaterPreference::onClickResetDialogs() { - LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this)); + LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this)); } */ void LLFloaterPreference::onClickEnablePopup() -{ - LLScrollListCtrl& disabled_popups = getChildRef<LLScrollListCtrl>("disabled_popups"); - - std::vector<LLScrollListItem*> items = disabled_popups.getAllSelected(); - std::vector<LLScrollListItem*>::iterator itor; - for (itor = items.begin(); itor != items.end(); ++itor) - { - LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata())); - //gSavedSettings.setWarning(templatep->mName, TRUE); - std::string notification_name = templatep->mName; - LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE); - } - - buildPopupLists(); +{ + LLScrollListCtrl& disabled_popups = getChildRef<LLScrollListCtrl>("disabled_popups"); + + std::vector<LLScrollListItem*> items = disabled_popups.getAllSelected(); + std::vector<LLScrollListItem*>::iterator itor; + for (itor = items.begin(); itor != items.end(); ++itor) + { + LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata())); + //gSavedSettings.setWarning(templatep->mName, TRUE); + std::string notification_name = templatep->mName; + LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE); + } + + buildPopupLists(); } void LLFloaterPreference::onClickDisablePopup() -{ - LLScrollListCtrl& enabled_popups = getChildRef<LLScrollListCtrl>("enabled_popups"); - - std::vector<LLScrollListItem*> items = enabled_popups.getAllSelected(); - std::vector<LLScrollListItem*>::iterator itor; - for (itor = items.begin(); itor != items.end(); ++itor) - { - LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata())); - templatep->mForm->setIgnored(true); - } - - buildPopupLists(); +{ + LLScrollListCtrl& enabled_popups = getChildRef<LLScrollListCtrl>("enabled_popups"); + + std::vector<LLScrollListItem*> items = enabled_popups.getAllSelected(); + std::vector<LLScrollListItem*>::iterator itor; + for (itor = items.begin(); itor != items.end(); ++itor) + { + LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata())); + templatep->mForm->setIgnored(true); + } + + buildPopupLists(); } void LLFloaterPreference::resetAllIgnored() { - for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin(); - iter != LLNotifications::instance().templatesEnd(); - ++iter) - { - if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) - { - iter->second->mForm->setIgnored(false); - } - } + for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin(); + iter != LLNotifications::instance().templatesEnd(); + ++iter) + { + if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) + { + iter->second->mForm->setIgnored(false); + } + } } void LLFloaterPreference::setAllIgnored() { - for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin(); - iter != LLNotifications::instance().templatesEnd(); - ++iter) - { - if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) - { - iter->second->mForm->setIgnored(true); - } - } + for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin(); + iter != LLNotifications::instance().templatesEnd(); + ++iter) + { + if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) + { + iter->second->mForm->setIgnored(true); + } + } } void LLFloaterPreference::onClickLogPath() { - std::string proposed_name(gSavedPerAccountSettings.getString("InstantMessageLogPath")); - mPriorInstantMessageLogPath.clear(); - + std::string proposed_name(gSavedPerAccountSettings.getString("InstantMessageLogPath")); + mPriorInstantMessageLogPath.clear(); + - (new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeLogPath, this, _1, _2), proposed_name))->getFile(); + (new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeLogPath, this, _1, _2), proposed_name))->getFile(); } void LLFloaterPreference::changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name) { - //Path changed - if (proposed_name != filenames[0]) - { - gSavedPerAccountSettings.setString("InstantMessageLogPath", filenames[0]); - mPriorInstantMessageLogPath = proposed_name; + //Path changed + if (proposed_name != filenames[0]) + { + gSavedPerAccountSettings.setString("InstantMessageLogPath", filenames[0]); + mPriorInstantMessageLogPath = proposed_name; - // enable/disable 'Delete transcripts button - updateDeleteTranscriptsButton(); - } + // enable/disable 'Delete transcripts button + updateDeleteTranscriptsButton(); + } } bool LLFloaterPreference::moveTranscriptsAndLog() { - std::string instantMessageLogPath(gSavedPerAccountSettings.getString("InstantMessageLogPath")); - std::string chatLogPath = gDirUtilp->add(instantMessageLogPath, gDirUtilp->getUserName()); - - bool madeDirectory = false; - - //Does the directory really exist, if not then make it - if(!LLFile::isdir(chatLogPath)) - { - //mkdir success is defined as zero - if(LLFile::mkdir(chatLogPath) != 0) - { - return false; - } - madeDirectory = true; - } - - std::string originalConversationLogDir = LLConversationLog::instance().getFileName(); - std::string targetConversationLogDir = gDirUtilp->add(chatLogPath, "conversation.log"); - //Try to move the conversation log - if(!LLConversationLog::instance().moveLog(originalConversationLogDir, targetConversationLogDir)) - { - //Couldn't move the log and created a new directory so remove the new directory - if(madeDirectory) - { - LLFile::rmdir(chatLogPath); - } - return false; - } - - //Attempt to move transcripts - std::vector<std::string> listOfTranscripts; - std::vector<std::string> listOfFilesMoved; - - LLLogChat::getListOfTranscriptFiles(listOfTranscripts); - - if(!LLLogChat::moveTranscripts(gDirUtilp->getChatLogsDir(), - instantMessageLogPath, - listOfTranscripts, - listOfFilesMoved)) - { - //Couldn't move all the transcripts so restore those that moved back to their old location - LLLogChat::moveTranscripts(instantMessageLogPath, - gDirUtilp->getChatLogsDir(), - listOfFilesMoved); - - //Move the conversation log back - LLConversationLog::instance().moveLog(targetConversationLogDir, originalConversationLogDir); - - if(madeDirectory) - { - LLFile::rmdir(chatLogPath); - } - - return false; - } - - gDirUtilp->setChatLogsDir(instantMessageLogPath); - gDirUtilp->updatePerAccountChatLogsDir(); - - return true; + std::string instantMessageLogPath(gSavedPerAccountSettings.getString("InstantMessageLogPath")); + std::string chatLogPath = gDirUtilp->add(instantMessageLogPath, gDirUtilp->getUserName()); + + bool madeDirectory = false; + + //Does the directory really exist, if not then make it + if(!LLFile::isdir(chatLogPath)) + { + //mkdir success is defined as zero + if(LLFile::mkdir(chatLogPath) != 0) + { + return false; + } + madeDirectory = true; + } + + std::string originalConversationLogDir = LLConversationLog::instance().getFileName(); + std::string targetConversationLogDir = gDirUtilp->add(chatLogPath, "conversation.log"); + //Try to move the conversation log + if(!LLConversationLog::instance().moveLog(originalConversationLogDir, targetConversationLogDir)) + { + //Couldn't move the log and created a new directory so remove the new directory + if(madeDirectory) + { + LLFile::rmdir(chatLogPath); + } + return false; + } + + //Attempt to move transcripts + std::vector<std::string> listOfTranscripts; + std::vector<std::string> listOfFilesMoved; + + LLLogChat::getListOfTranscriptFiles(listOfTranscripts); + + if(!LLLogChat::moveTranscripts(gDirUtilp->getChatLogsDir(), + instantMessageLogPath, + listOfTranscripts, + listOfFilesMoved)) + { + //Couldn't move all the transcripts so restore those that moved back to their old location + LLLogChat::moveTranscripts(instantMessageLogPath, + gDirUtilp->getChatLogsDir(), + listOfFilesMoved); + + //Move the conversation log back + LLConversationLog::instance().moveLog(targetConversationLogDir, originalConversationLogDir); + + if(madeDirectory) + { + LLFile::rmdir(chatLogPath); + } + + return false; + } + + gDirUtilp->setChatLogsDir(instantMessageLogPath); + gDirUtilp->updatePerAccountChatLogsDir(); + + return true; } void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email) { - mGotPersonalInfo = true; - mOriginalIMViaEmail = im_via_email; - mDirectoryVisibility = visibility; - - if (visibility == VISIBILITY_DEFAULT) - { - mOriginalHideOnlineStatus = false; - getChildView("online_visibility")->setEnabled(TRUE); - } - else if (visibility == VISIBILITY_HIDDEN) - { - mOriginalHideOnlineStatus = true; - getChildView("online_visibility")->setEnabled(TRUE); - } - else - { - mOriginalHideOnlineStatus = true; - } - - getChild<LLUICtrl>("online_searchresults")->setEnabled(TRUE); - getChildView("friends_online_notify_checkbox")->setEnabled(TRUE); - getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus); - getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility); - getChildView("send_im_to_email")->setEnabled(is_verified_email); + mGotPersonalInfo = true; + mOriginalIMViaEmail = im_via_email; + mDirectoryVisibility = visibility; + + if (visibility == VISIBILITY_DEFAULT) + { + mOriginalHideOnlineStatus = false; + getChildView("online_visibility")->setEnabled(TRUE); + } + else if (visibility == VISIBILITY_HIDDEN) + { + mOriginalHideOnlineStatus = true; + getChildView("online_visibility")->setEnabled(TRUE); + } + else + { + mOriginalHideOnlineStatus = true; + } + + getChild<LLUICtrl>("online_searchresults")->setEnabled(TRUE); + getChildView("friends_online_notify_checkbox")->setEnabled(TRUE); + getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus); + getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility); + getChildView("send_im_to_email")->setEnabled(is_verified_email); std::string tooltip; if (!is_verified_email) @@ -1867,115 +1867,115 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im // *TODO: Show or hide verify email text here based on is_verified_email getChild<LLUICtrl>("send_im_to_email")->setValue(im_via_email); - getChildView("favorites_on_login_check")->setEnabled(TRUE); - getChildView("log_path_button")->setEnabled(TRUE); - getChildView("chat_font_size")->setEnabled(TRUE); - getChildView("conversation_log_combo")->setEnabled(TRUE); + getChildView("favorites_on_login_check")->setEnabled(TRUE); + getChildView("log_path_button")->setEnabled(TRUE); + getChildView("chat_font_size")->setEnabled(TRUE); + getChildView("conversation_log_combo")->setEnabled(TRUE); } void LLFloaterPreference::refreshUI() { - refresh(); + refresh(); } void LLFloaterPreferenceGraphicsAdvanced::updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box) { - if (text_box == NULL || ctrl== NULL) - return; - - // get range and points when text should change - F32 value = (F32)ctrl->getValue().asReal(); - F32 min = ctrl->getMinValue(); - F32 max = ctrl->getMaxValue(); - F32 range = max - min; - llassert(range > 0); - F32 midPoint = min + range / 3.0f; - F32 highPoint = min + (2.0f * range / 3.0f); - - // choose the right text - if (value < midPoint) - { - text_box->setText(LLTrans::getString("GraphicsQualityLow")); - } - else if (value < highPoint) - { - text_box->setText(LLTrans::getString("GraphicsQualityMid")); - } - else - { - text_box->setText(LLTrans::getString("GraphicsQualityHigh")); - } + if (text_box == NULL || ctrl== NULL) + return; + + // get range and points when text should change + F32 value = (F32)ctrl->getValue().asReal(); + F32 min = ctrl->getMinValue(); + F32 max = ctrl->getMaxValue(); + F32 range = max - min; + llassert(range > 0); + F32 midPoint = min + range / 3.0f; + F32 highPoint = min + (2.0f * range / 3.0f); + + // choose the right text + if (value < midPoint) + { + text_box->setText(LLTrans::getString("GraphicsQualityLow")); + } + else if (value < highPoint) + { + text_box->setText(LLTrans::getString("GraphicsQualityMid")); + } + else + { + text_box->setText(LLTrans::getString("GraphicsQualityHigh")); + } } void LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors() { - // Called when the IndirectMaxNonImpostors control changes - // Responsible for fixing the slider label (IndirectMaxNonImpostorsText) and setting RenderAvatarMaxNonImpostors - LLSliderCtrl* ctrl = getChild<LLSliderCtrl>("IndirectMaxNonImpostors",true); - U32 value = ctrl->getValue().asInteger(); + // Called when the IndirectMaxNonImpostors control changes + // Responsible for fixing the slider label (IndirectMaxNonImpostorsText) and setting RenderAvatarMaxNonImpostors + LLSliderCtrl* ctrl = getChild<LLSliderCtrl>("IndirectMaxNonImpostors",true); + U32 value = ctrl->getValue().asInteger(); - if (0 == value || LLVOAvatar::IMPOSTORS_OFF <= value) - { - value=0; - } - gSavedSettings.setU32("RenderAvatarMaxNonImpostors", value); - LLVOAvatar::updateImpostorRendering(value); // make it effective immediately - setMaxNonImpostorsText(value, getChild<LLTextBox>("IndirectMaxNonImpostorsText")); + if (0 == value || LLVOAvatar::IMPOSTORS_OFF <= value) + { + value=0; + } + gSavedSettings.setU32("RenderAvatarMaxNonImpostors", value); + LLVOAvatar::updateImpostorRendering(value); // make it effective immediately + setMaxNonImpostorsText(value, getChild<LLTextBox>("IndirectMaxNonImpostorsText")); } void LLFloaterPreferenceGraphicsAdvanced::setMaxNonImpostorsText(U32 value, LLTextBox* text_box) { - if (0 == value) - { - text_box->setText(LLTrans::getString("no_limit")); - } - else - { - text_box->setText(llformat("%d", value)); - } + if (0 == value) + { + text_box->setText(LLTrans::getString("no_limit")); + } + else + { + text_box->setText(llformat("%d", value)); + } } void LLAvatarComplexityControls::updateMax(LLSliderCtrl* slider, LLTextBox* value_label) { - // Called when the IndirectMaxComplexity control changes - // Responsible for fixing the slider label (IndirectMaxComplexityText) and setting RenderAvatarMaxComplexity - U32 indirect_value = slider->getValue().asInteger(); - U32 max_arc; - - if (INDIRECT_MAX_ARC_OFF == indirect_value) - { - // The 'off' position is when the slider is all the way to the right, - // which is a value of INDIRECT_MAX_ARC_OFF, - // so it is necessary to set max_arc to 0 disable muted avatars. - max_arc = 0; - } - else - { - // if this is changed, the inverse calculation in setIndirectMaxArc - // must be changed to match - max_arc = (U32)ll_round(exp(MIN_ARC_LOG + (ARC_LIMIT_MAP_SCALE * (indirect_value - MIN_INDIRECT_ARC_LIMIT)))); - } - - gSavedSettings.setU32("RenderAvatarMaxComplexity", (U32)max_arc); - setText(max_arc, value_label); + // Called when the IndirectMaxComplexity control changes + // Responsible for fixing the slider label (IndirectMaxComplexityText) and setting RenderAvatarMaxComplexity + U32 indirect_value = slider->getValue().asInteger(); + U32 max_arc; + + if (INDIRECT_MAX_ARC_OFF == indirect_value) + { + // The 'off' position is when the slider is all the way to the right, + // which is a value of INDIRECT_MAX_ARC_OFF, + // so it is necessary to set max_arc to 0 disable muted avatars. + max_arc = 0; + } + else + { + // if this is changed, the inverse calculation in setIndirectMaxArc + // must be changed to match + max_arc = (U32)ll_round(exp(MIN_ARC_LOG + (ARC_LIMIT_MAP_SCALE * (indirect_value - MIN_INDIRECT_ARC_LIMIT)))); + } + + gSavedSettings.setU32("RenderAvatarMaxComplexity", (U32)max_arc); + setText(max_arc, value_label); } void LLAvatarComplexityControls::setText(U32 value, LLTextBox* text_box) { - if (0 == value) - { - text_box->setText(LLTrans::getString("no_limit")); - } - else - { - text_box->setText(llformat("%d", value)); - } + if (0 == value) + { + text_box->setText(LLTrans::getString("no_limit")); + } + else + { + text_box->setText(llformat("%d", value)); + } } void LLFloaterPreference::updateMaxComplexity() { - // Called when the IndirectMaxComplexity control changes + // Called when the IndirectMaxComplexity control changes LLAvatarComplexityControls::updateMax( getChild<LLSliderCtrl>("IndirectMaxComplexity"), getChild<LLTextBox>("IndirectMaxComplexityText")); @@ -1983,7 +1983,7 @@ void LLFloaterPreference::updateMaxComplexity() void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity() { - // Called when the IndirectMaxComplexity control changes + // Called when the IndirectMaxComplexity control changes LLAvatarComplexityControls::updateMax( getChild<LLSliderCtrl>("IndirectMaxComplexity"), getChild<LLTextBox>("IndirectMaxComplexityText")); @@ -1991,16 +1991,16 @@ void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity() void LLFloaterPreference::onChangeMaturity() { - U8 sim_access = gSavedSettings.getU32("PreferredMaturity"); + U8 sim_access = gSavedSettings.getU32("PreferredMaturity"); - getChild<LLIconCtrl>("rating_icon_general")->setVisible(sim_access == SIM_ACCESS_PG - || sim_access == SIM_ACCESS_MATURE - || sim_access == SIM_ACCESS_ADULT); + getChild<LLIconCtrl>("rating_icon_general")->setVisible(sim_access == SIM_ACCESS_PG + || sim_access == SIM_ACCESS_MATURE + || sim_access == SIM_ACCESS_ADULT); - getChild<LLIconCtrl>("rating_icon_moderate")->setVisible(sim_access == SIM_ACCESS_MATURE - || sim_access == SIM_ACCESS_ADULT); + getChild<LLIconCtrl>("rating_icon_moderate")->setVisible(sim_access == SIM_ACCESS_MATURE + || sim_access == SIM_ACCESS_ADULT); - getChild<LLIconCtrl>("rating_icon_adult")->setVisible(sim_access == SIM_ACCESS_ADULT); + getChild<LLIconCtrl>("rating_icon_adult")->setVisible(sim_access == SIM_ACCESS_ADULT); } std::string get_category_path(LLUUID cat_id) @@ -2064,23 +2064,23 @@ void LLFloaterPreference::onChangeAnimationFolder() // but the UI for this will still be enabled void LLFloaterPreference::onClickBlockList() { - LLFloaterSidePanelContainer::showPanel("people", "panel_people", - LLSD().with("people_panel_tab_name", "blocked_panel")); + LLFloaterSidePanelContainer::showPanel("people", "panel_people", + LLSD().with("people_panel_tab_name", "blocked_panel")); } void LLFloaterPreference::onClickProxySettings() { - LLFloaterReg::showInstance("prefs_proxy"); + LLFloaterReg::showInstance("prefs_proxy"); } void LLFloaterPreference::onClickTranslationSettings() { - LLFloaterReg::showInstance("prefs_translation"); + LLFloaterReg::showInstance("prefs_translation"); } void LLFloaterPreference::onClickAutoReplace() { - LLFloaterReg::showInstance("prefs_autoreplace"); + LLFloaterReg::showInstance("prefs_autoreplace"); } void LLFloaterPreference::onClickSpellChecker() @@ -2095,141 +2095,141 @@ void LLFloaterPreference::onClickRenderExceptions() void LLFloaterPreference::onClickAdvanced() { - LLFloaterReg::showInstance("prefs_graphics_advanced"); + LLFloaterReg::showInstance("prefs_graphics_advanced"); - LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); - for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); - iter != tabcontainer->getChildList()->end(); ++iter) - { - LLView* view = *iter; - LLPanelPreferenceGraphics* panel = dynamic_cast<LLPanelPreferenceGraphics*>(view); - if (panel) - { - panel->resetDirtyChilds(); - } - } + LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); + for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); + iter != tabcontainer->getChildList()->end(); ++iter) + { + LLView* view = *iter; + LLPanelPreferenceGraphics* panel = dynamic_cast<LLPanelPreferenceGraphics*>(view); + if (panel) + { + panel->resetDirtyChilds(); + } + } } void LLFloaterPreference::onClickActionChange() { - mClickActionDirty = true; + mClickActionDirty = true; } void LLFloaterPreference::onClickPermsDefault() { - LLFloaterReg::showInstance("perms_default"); + LLFloaterReg::showInstance("perms_default"); } void LLFloaterPreference::onDeleteTranscripts() { - LLSD args; - args["FOLDER"] = gDirUtilp->getUserName(); + LLSD args; + args["FOLDER"] = gDirUtilp->getUserName(); - LLNotificationsUtil::add("PreferenceChatDeleteTranscripts", args, LLSD(), boost::bind(&LLFloaterPreference::onDeleteTranscriptsResponse, this, _1, _2)); + LLNotificationsUtil::add("PreferenceChatDeleteTranscripts", args, LLSD(), boost::bind(&LLFloaterPreference::onDeleteTranscriptsResponse, this, _1, _2)); } void LLFloaterPreference::onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response) { - if (0 == LLNotificationsUtil::getSelectedOption(notification, response)) - { - LLLogChat::deleteTranscripts(); - updateDeleteTranscriptsButton(); - } + if (0 == LLNotificationsUtil::getSelectedOption(notification, response)) + { + LLLogChat::deleteTranscripts(); + updateDeleteTranscriptsButton(); + } } void LLFloaterPreference::onLogChatHistorySaved() { - LLButton * delete_transcripts_buttonp = getChild<LLButton>("delete_transcripts"); + LLButton * delete_transcripts_buttonp = getChild<LLButton>("delete_transcripts"); - if (!delete_transcripts_buttonp->getEnabled()) - { - delete_transcripts_buttonp->setEnabled(true); - } + if (!delete_transcripts_buttonp->getEnabled()) + { + delete_transcripts_buttonp->setEnabled(true); + } } void LLFloaterPreference::updateClickActionSettings() { - const int single_clk_action = getChild<LLComboBox>("single_click_action_combo")->getValue().asInteger(); - const int double_clk_action = getChild<LLComboBox>("double_click_action_combo")->getValue().asInteger(); + const int single_clk_action = getChild<LLComboBox>("single_click_action_combo")->getValue().asInteger(); + const int double_clk_action = getChild<LLComboBox>("double_click_action_combo")->getValue().asInteger(); - gSavedSettings.setBOOL("ClickToWalk", single_clk_action == 1); - gSavedSettings.setBOOL("DoubleClickAutoPilot", double_clk_action == 1); - gSavedSettings.setBOOL("DoubleClickTeleport", double_clk_action == 2); + gSavedSettings.setBOOL("ClickToWalk", single_clk_action == 1); + gSavedSettings.setBOOL("DoubleClickAutoPilot", double_clk_action == 1); + gSavedSettings.setBOOL("DoubleClickTeleport", double_clk_action == 2); } void LLFloaterPreference::updateClickActionControls() { - const bool click_to_walk = gSavedSettings.getBOOL("ClickToWalk"); - const bool dbl_click_to_walk = gSavedSettings.getBOOL("DoubleClickAutoPilot"); - const bool dbl_click_to_teleport = gSavedSettings.getBOOL("DoubleClickTeleport"); + const bool click_to_walk = gSavedSettings.getBOOL("ClickToWalk"); + const bool dbl_click_to_walk = gSavedSettings.getBOOL("DoubleClickAutoPilot"); + const bool dbl_click_to_teleport = gSavedSettings.getBOOL("DoubleClickTeleport"); - getChild<LLComboBox>("single_click_action_combo")->setValue((int)click_to_walk); - getChild<LLComboBox>("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk); + getChild<LLComboBox>("single_click_action_combo")->setValue((int)click_to_walk); + getChild<LLComboBox>("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk); } void LLFloaterPreference::applyUIColor(LLUICtrl* ctrl, const LLSD& param) { - LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue())); + LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue())); } void LLFloaterPreference::getUIColor(LLUICtrl* ctrl, const LLSD& param) { - LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*) ctrl; - color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString())); + LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*) ctrl; + color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString())); } void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location) { - LLUICtrl* cache_location_editor = getChild<LLUICtrl>("cache_location"); - cache_location_editor->setValue(location); - cache_location_editor->setToolTip(location); + LLUICtrl* cache_location_editor = getChild<LLUICtrl>("cache_location"); + cache_location_editor->setValue(location); + cache_location_editor->setToolTip(location); } void LLFloaterPreference::selectPanel(const LLSD& name) { - LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core"); - LLPanel * panel = tab_containerp->getPanelByName(name); - if (NULL != panel) - { - tab_containerp->selectTabPanel(panel); - } + LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core"); + LLPanel * panel = tab_containerp->getPanelByName(name); + if (NULL != panel) + { + tab_containerp->selectTabPanel(panel); + } } void LLFloaterPreference::selectPrivacyPanel() { - selectPanel("im"); + selectPanel("im"); } void LLFloaterPreference::selectChatPanel() { - selectPanel("chat"); + selectPanel("chat"); } void LLFloaterPreference::changed() { - getChild<LLButton>("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0); + getChild<LLButton>("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0); - // set 'enable' property for 'Delete transcripts...' button - updateDeleteTranscriptsButton(); + // set 'enable' property for 'Delete transcripts...' button + updateDeleteTranscriptsButton(); } void LLFloaterPreference::saveCameraPreset(std::string& preset) { - mSavedCameraPreset = preset; + mSavedCameraPreset = preset; } void LLFloaterPreference::saveGraphicsPreset(std::string& preset) { - mSavedGraphicsPreset = preset; + mSavedGraphicsPreset = preset; } //------------------------------Updater--------------------------------------- static bool handleBandwidthChanged(const LLSD& newvalue) { - gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal()); - return true; + gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal()); + return true; } class LLPanelPreference::Updater : public LLEventTimer @@ -2237,37 +2237,37 @@ class LLPanelPreference::Updater : public LLEventTimer public: - typedef boost::function<bool(const LLSD&)> callback_t; + typedef boost::function<bool(const LLSD&)> callback_t; - Updater(callback_t cb, F32 period) - :LLEventTimer(period), - mCallback(cb) - { - mEventTimer.stop(); - } + Updater(callback_t cb, F32 period) + :LLEventTimer(period), + mCallback(cb) + { + mEventTimer.stop(); + } - virtual ~Updater(){} + virtual ~Updater(){} - void update(const LLSD& new_value) - { - mNewValue = new_value; - mEventTimer.start(); - } + void update(const LLSD& new_value) + { + mNewValue = new_value; + mEventTimer.start(); + } protected: - BOOL tick() - { - mCallback(mNewValue); - mEventTimer.stop(); + BOOL tick() + { + mCallback(mNewValue); + mEventTimer.stop(); - return FALSE; - } + return FALSE; + } private: - LLSD mNewValue; - callback_t mCallback; + LLSD mNewValue; + callback_t mCallback; }; //---------------------------------------------------------------------------- static LLPanelInjector<LLPanelPreference> t_places("panel_preference"); @@ -2275,169 +2275,169 @@ LLPanelPreference::LLPanelPreference() : LLPanel(), mBandWidthUpdater(NULL) { - mCommitCallbackRegistrar.add("Pref.setControlFalse", boost::bind(&LLPanelPreference::setControlFalse,this, _2)); - mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1)); - mCommitCallbackRegistrar.add("Pref.PrefDelete", boost::bind(&LLPanelPreference::deletePreset, this, _2)); - mCommitCallbackRegistrar.add("Pref.PrefSave", boost::bind(&LLPanelPreference::savePreset, this, _2)); - mCommitCallbackRegistrar.add("Pref.PrefLoad", boost::bind(&LLPanelPreference::loadPreset, this, _2)); + mCommitCallbackRegistrar.add("Pref.setControlFalse", boost::bind(&LLPanelPreference::setControlFalse,this, _2)); + mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1)); + mCommitCallbackRegistrar.add("Pref.PrefDelete", boost::bind(&LLPanelPreference::deletePreset, this, _2)); + mCommitCallbackRegistrar.add("Pref.PrefSave", boost::bind(&LLPanelPreference::savePreset, this, _2)); + mCommitCallbackRegistrar.add("Pref.PrefLoad", boost::bind(&LLPanelPreference::loadPreset, this, _2)); } //virtual BOOL LLPanelPreference::postBuild() { - ////////////////////// PanelGeneral /////////////////// - if (hasChild("display_names_check", TRUE)) - { - BOOL use_people_api = gSavedSettings.getBOOL("UsePeopleAPI"); - LLCheckBoxCtrl* ctrl_display_name = getChild<LLCheckBoxCtrl>("display_names_check"); - ctrl_display_name->setEnabled(use_people_api); - if (!use_people_api) - { - ctrl_display_name->setValue(FALSE); - } - } - - ////////////////////// PanelVoice /////////////////// - if (hasChild("voice_unavailable", TRUE)) - { - BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice"); - getChildView("voice_unavailable")->setVisible( voice_disabled); - getChildView("enable_voice_check")->setVisible( !voice_disabled); - } - - //////////////////////PanelSkins /////////////////// - - if (hasChild("skin_selection", TRUE)) - { - LLFloaterPreference::refreshSkin(this); - - // if skin is set to a skin that no longer exists (silver) set back to default - if (getChild<LLRadioGroup>("skin_selection")->getSelectedIndex() < 0) - { - gSavedSettings.setString("SkinCurrent", "default"); - LLFloaterPreference::refreshSkin(this); - } - - } - - //////////////////////PanelPrivacy /////////////////// - if (hasChild("media_enabled", TRUE)) - { - bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia"); - - getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled); - getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled); - } - if (hasChild("music_enabled", TRUE)) - { - getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic")); - } - if (hasChild("voice_call_friends_only_check", TRUE)) - { - getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2)); - } - if (hasChild("allow_multiple_viewer_check", TRUE)) - { - getChild<LLCheckBoxCtrl>("allow_multiple_viewer_check")->setCommitCallback(boost::bind(&showMultipleViewersWarning, _1, _2)); - } - if (hasChild("favorites_on_login_check", TRUE)) - { - getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2)); - bool show_favorites_at_login = LLPanelLogin::getShowFavorites(); - getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login); - } - if (hasChild("mute_chb_label", TRUE)) - { - getChild<LLTextBox>("mute_chb_label")->setShowCursorHand(false); - getChild<LLTextBox>("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized)); - } - - //////////////////////PanelAdvanced /////////////////// - if (hasChild("modifier_combo", TRUE)) - { - //localizing if push2talk button is set to middle mouse - if (MIDDLE_MOUSE_CV == getChild<LLUICtrl>("modifier_combo")->getValue().asString()) - { - getChild<LLUICtrl>("modifier_combo")->setValue(getString("middle_mouse")); - } - } - - //////////////////////PanelSetup /////////////////// - if (hasChild("max_bandwidth"), TRUE) - { - mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), BANDWIDTH_UPDATER_TIMEOUT); - gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2)); - } + ////////////////////// PanelGeneral /////////////////// + if (hasChild("display_names_check", TRUE)) + { + BOOL use_people_api = gSavedSettings.getBOOL("UsePeopleAPI"); + LLCheckBoxCtrl* ctrl_display_name = getChild<LLCheckBoxCtrl>("display_names_check"); + ctrl_display_name->setEnabled(use_people_api); + if (!use_people_api) + { + ctrl_display_name->setValue(FALSE); + } + } + + ////////////////////// PanelVoice /////////////////// + if (hasChild("voice_unavailable", TRUE)) + { + BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice"); + getChildView("voice_unavailable")->setVisible( voice_disabled); + getChildView("enable_voice_check")->setVisible( !voice_disabled); + } + + //////////////////////PanelSkins /////////////////// + + if (hasChild("skin_selection", TRUE)) + { + LLFloaterPreference::refreshSkin(this); + + // if skin is set to a skin that no longer exists (silver) set back to default + if (getChild<LLRadioGroup>("skin_selection")->getSelectedIndex() < 0) + { + gSavedSettings.setString("SkinCurrent", "default"); + LLFloaterPreference::refreshSkin(this); + } + + } + + //////////////////////PanelPrivacy /////////////////// + if (hasChild("media_enabled", TRUE)) + { + bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia"); + + getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled); + getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled); + } + if (hasChild("music_enabled", TRUE)) + { + getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic")); + } + if (hasChild("voice_call_friends_only_check", TRUE)) + { + getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2)); + } + if (hasChild("allow_multiple_viewer_check", TRUE)) + { + getChild<LLCheckBoxCtrl>("allow_multiple_viewer_check")->setCommitCallback(boost::bind(&showMultipleViewersWarning, _1, _2)); + } + if (hasChild("favorites_on_login_check", TRUE)) + { + getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2)); + bool show_favorites_at_login = LLPanelLogin::getShowFavorites(); + getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login); + } + if (hasChild("mute_chb_label", TRUE)) + { + getChild<LLTextBox>("mute_chb_label")->setShowCursorHand(false); + getChild<LLTextBox>("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized)); + } + + //////////////////////PanelAdvanced /////////////////// + if (hasChild("modifier_combo", TRUE)) + { + //localizing if push2talk button is set to middle mouse + if (MIDDLE_MOUSE_CV == getChild<LLUICtrl>("modifier_combo")->getValue().asString()) + { + getChild<LLUICtrl>("modifier_combo")->setValue(getString("middle_mouse")); + } + } + + //////////////////////PanelSetup /////////////////// + if (hasChild("max_bandwidth"), TRUE) + { + mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), BANDWIDTH_UPDATER_TIMEOUT); + gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2)); + } #ifdef EXTERNAL_TOS - LLRadioGroup* ext_browser_settings = getChild<LLRadioGroup>("preferred_browser_behavior"); - if (ext_browser_settings) - { - // turn off ability to set external/internal browser - ext_browser_settings->setSelectedByValue(LLWeb::BROWSER_EXTERNAL_ONLY, true); - ext_browser_settings->setEnabled(false); - } + LLRadioGroup* ext_browser_settings = getChild<LLRadioGroup>("preferred_browser_behavior"); + if (ext_browser_settings) + { + // turn off ability to set external/internal browser + ext_browser_settings->setSelectedByValue(LLWeb::BROWSER_EXTERNAL_ONLY, true); + ext_browser_settings->setEnabled(false); + } #endif - apply(); - return true; + apply(); + return true; } LLPanelPreference::~LLPanelPreference() { - if (mBandWidthUpdater) - { - delete mBandWidthUpdater; - } + if (mBandWidthUpdater) + { + delete mBandWidthUpdater; + } } void LLPanelPreference::apply() { - // no-op + // no-op } void LLPanelPreference::saveSettings() { - LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); - - // Save the value of all controls in the hierarchy - mSavedValues.clear(); - std::list<LLView*> view_stack; - view_stack.push_back(this); - if (advanced) - { - view_stack.push_back(advanced); - } - while(!view_stack.empty()) - { - // Process view on top of the stack - LLView* curview = view_stack.front(); - view_stack.pop_front(); - - LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview); - if (color_swatch) - { - mSavedColors[color_swatch->getName()] = color_swatch->get(); - } - else - { - LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); - if (ctrl) - { - LLControlVariable* control = ctrl->getControlVariable(); - if (control) - { - mSavedValues[control] = control->getValue(); - } - } - } - - // Push children onto the end of the work stack - for (child_list_t::const_iterator iter = curview->getChildList()->begin(); - iter != curview->getChildList()->end(); ++iter) - { - view_stack.push_back(*iter); - } - } + LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); + + // Save the value of all controls in the hierarchy + mSavedValues.clear(); + std::list<LLView*> view_stack; + view_stack.push_back(this); + if (advanced) + { + view_stack.push_back(advanced); + } + while(!view_stack.empty()) + { + // Process view on top of the stack + LLView* curview = view_stack.front(); + view_stack.pop_front(); + + LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview); + if (color_swatch) + { + mSavedColors[color_swatch->getName()] = color_swatch->get(); + } + else + { + LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); + if (ctrl) + { + LLControlVariable* control = ctrl->getControlVariable(); + if (control) + { + mSavedValues[control] = control->getValue(); + } + } + } + + // Push children onto the end of the work stack + for (child_list_t::const_iterator iter = curview->getChildList()->begin(); + iter != curview->getChildList()->end(); ++iter) + { + view_stack.push_back(*iter); + } + } } void LLPanelPreference::showMultipleViewersWarning(LLUICtrl* checkbox, const LLSD& value) @@ -2450,104 +2450,104 @@ void LLPanelPreference::showMultipleViewersWarning(LLUICtrl* checkbox, const LLS void LLPanelPreference::showFriendsOnlyWarning(LLUICtrl* checkbox, const LLSD& value) { - if (checkbox && checkbox->getValue()) - { - LLNotificationsUtil::add("FriendsAndGroupsOnly"); - } + if (checkbox && checkbox->getValue()) + { + LLNotificationsUtil::add("FriendsAndGroupsOnly"); + } } void LLPanelPreference::handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value) { - if (checkbox) - { - LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean()); - if(checkbox->getValue()) - { - LLNotificationsUtil::add("FavoritesOnLogin"); - } - } + if (checkbox) + { + LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean()); + if(checkbox->getValue()) + { + LLNotificationsUtil::add("FavoritesOnLogin"); + } + } } void LLPanelPreference::toggleMuteWhenMinimized() { - std::string mute("MuteWhenMinimized"); - gSavedSettings.setBOOL(mute, !gSavedSettings.getBOOL(mute)); + std::string mute("MuteWhenMinimized"); + gSavedSettings.setBOOL(mute, !gSavedSettings.getBOOL(mute)); } void LLPanelPreference::cancel() { - for (control_values_map_t::iterator iter = mSavedValues.begin(); - iter != mSavedValues.end(); ++iter) - { - LLControlVariable* control = iter->first; - LLSD ctrl_value = iter->second; + for (control_values_map_t::iterator iter = mSavedValues.begin(); + iter != mSavedValues.end(); ++iter) + { + LLControlVariable* control = iter->first; + LLSD ctrl_value = iter->second; - if((control->getName() == "InstantMessageLogPath") && (ctrl_value.asString() == "")) - { - continue; - } + if((control->getName() == "InstantMessageLogPath") && (ctrl_value.asString() == "")) + { + continue; + } - control->set(ctrl_value); - } + control->set(ctrl_value); + } - for (string_color_map_t::iterator iter = mSavedColors.begin(); - iter != mSavedColors.end(); ++iter) - { - LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first); - if (color_swatch) - { - color_swatch->set(iter->second); - color_swatch->onCommit(); - } - } + for (string_color_map_t::iterator iter = mSavedColors.begin(); + iter != mSavedColors.end(); ++iter) + { + LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first); + if (color_swatch) + { + color_swatch->set(iter->second); + color_swatch->onCommit(); + } + } } void LLPanelPreference::setControlFalse(const LLSD& user_data) { - std::string control_name = user_data.asString(); - LLControlVariable* control = findControl(control_name); - - if (control) - control->set(LLSD(FALSE)); + std::string control_name = user_data.asString(); + LLControlVariable* control = findControl(control_name); + + if (control) + control->set(LLSD(FALSE)); } void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl) { - std::string name = ctrl->getName(); + std::string name = ctrl->getName(); - // Disable "Allow Media to auto play" only when both - // "Streaming Music" and "Media" are unchecked. STORM-513. - if ((name == "enable_music") || (name == "enable_media")) - { - bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get(); - bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get(); + // Disable "Allow Media to auto play" only when both + // "Streaming Music" and "Media" are unchecked. STORM-513. + if ((name == "enable_music") || (name == "enable_media")) + { + bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get(); + bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get(); - getChild<LLCheckBoxCtrl>("media_auto_play_btn")->setEnabled(music_enabled || media_enabled); - } + getChild<LLCheckBoxCtrl>("media_auto_play_btn")->setEnabled(music_enabled || media_enabled); + } } void LLPanelPreference::deletePreset(const LLSD& user_data) { - std::string subdirectory = user_data.asString(); - LLFloaterReg::hideInstance("load_pref_preset", subdirectory); - LLFloaterReg::hideInstance("save_pref_preset", subdirectory); - LLFloaterReg::showInstance("delete_pref_preset", subdirectory); + std::string subdirectory = user_data.asString(); + LLFloaterReg::hideInstance("load_pref_preset", subdirectory); + LLFloaterReg::hideInstance("save_pref_preset", subdirectory); + LLFloaterReg::showInstance("delete_pref_preset", subdirectory); } void LLPanelPreference::savePreset(const LLSD& user_data) { - std::string subdirectory = user_data.asString(); - LLFloaterReg::hideInstance("delete_pref_preset", subdirectory); - LLFloaterReg::hideInstance("load_pref_preset", subdirectory); - LLFloaterReg::showInstance("save_pref_preset", subdirectory); + std::string subdirectory = user_data.asString(); + LLFloaterReg::hideInstance("delete_pref_preset", subdirectory); + LLFloaterReg::hideInstance("load_pref_preset", subdirectory); + LLFloaterReg::showInstance("save_pref_preset", subdirectory); } void LLPanelPreference::loadPreset(const LLSD& user_data) { - std::string subdirectory = user_data.asString(); - LLFloaterReg::hideInstance("delete_pref_preset", subdirectory); - LLFloaterReg::hideInstance("save_pref_preset", subdirectory); - LLFloaterReg::showInstance("load_pref_preset", subdirectory); + std::string subdirectory = user_data.asString(); + LLFloaterReg::hideInstance("delete_pref_preset", subdirectory); + LLFloaterReg::hideInstance("save_pref_preset", subdirectory); + LLFloaterReg::showInstance("load_pref_preset", subdirectory); } void LLPanelPreference::setHardwareDefaults() @@ -2557,39 +2557,39 @@ void LLPanelPreference::setHardwareDefaults() class LLPanelPreferencePrivacy : public LLPanelPreference { public: - LLPanelPreferencePrivacy() - { - mAccountIndependentSettings.push_back("VoiceCallsFriendsOnly"); - mAccountIndependentSettings.push_back("AutoDisengageMic"); - } - - /*virtual*/ void saveSettings() - { - LLPanelPreference::saveSettings(); - - // Don't save (=erase from the saved values map) per-account privacy settings - // if we're not logged in, otherwise they will be reset to defaults on log off. - if (LLStartUp::getStartupState() != STATE_STARTED) - { - // Erase only common settings, assuming there are no color settings on Privacy page. - for (control_values_map_t::iterator it = mSavedValues.begin(); it != mSavedValues.end(); ) - { - const std::string setting = it->first->getName(); - if (find(mAccountIndependentSettings.begin(), - mAccountIndependentSettings.end(), setting) == mAccountIndependentSettings.end()) - { - mSavedValues.erase(it++); - } - else - { - ++it; - } - } - } - } + LLPanelPreferencePrivacy() + { + mAccountIndependentSettings.push_back("VoiceCallsFriendsOnly"); + mAccountIndependentSettings.push_back("AutoDisengageMic"); + } + + /*virtual*/ void saveSettings() + { + LLPanelPreference::saveSettings(); + + // Don't save (=erase from the saved values map) per-account privacy settings + // if we're not logged in, otherwise they will be reset to defaults on log off. + if (LLStartUp::getStartupState() != STATE_STARTED) + { + // Erase only common settings, assuming there are no color settings on Privacy page. + for (control_values_map_t::iterator it = mSavedValues.begin(); it != mSavedValues.end(); ) + { + const std::string setting = it->first->getName(); + if (find(mAccountIndependentSettings.begin(), + mAccountIndependentSettings.end(), setting) == mAccountIndependentSettings.end()) + { + mSavedValues.erase(it++); + } + else + { + ++it; + } + } + } + } private: - std::list<std::string> mAccountIndependentSettings; + std::list<std::string> mAccountIndependentSettings; }; static LLPanelInjector<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics"); @@ -2598,253 +2598,253 @@ static LLPanelInjector<LLPanelPreferenceView> t_pref_view("panel_preference_view BOOL LLPanelPreferenceView::postBuild() { - setPresetText(); + setPresetText(); - LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); - if (presetsMgr) - { - presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this)); - presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok - } + LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); + if (presetsMgr) + { + presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this)); + presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok + } - return LLPanelPreference::postBuild(); + return LLPanelPreference::postBuild(); } void LLPanelPreferenceView::onPresetsListChangeCamera() { - LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); - if (presetsMgr) - { - presetsMgr->setCameraDirty(false); - } + LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); + if (presetsMgr) + { + presetsMgr->setCameraDirty(false); + } - setPresetText(); + setPresetText(); - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance && !gSavedSettings.getString("PresetCameraActive").empty()) - { - instance->saveSettings(); //make cancel work correctly after changing the preset - } + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance && !gSavedSettings.getString("PresetCameraActive").empty()) + { + instance->saveSettings(); //make cancel work correctly after changing the preset + } } void LLPanelPreferenceView::draw() { - setPresetText(); - LLPanelPreference::draw(); + setPresetText(); + LLPanelPreference::draw(); } void LLPanelPreferenceView::setPresetText() { - LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text"); - - std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive"); - - if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText()) - { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { - instance->saveCameraPreset(preset_camera_active); - } - } - - LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); - if (presetsMgr) - { - if (presetsMgr->isCameraDirty() && !preset_camera_active.empty()) - { - preset_camera_active.clear(); - } - } - - if (!preset_camera_active.empty()) - { - if (preset_camera_active == PRESETS_DEFAULT) - { - preset_camera_active = LLTrans::getString(PRESETS_DEFAULT); - } - preset_text->setText(preset_camera_active); - } - else - { - preset_text->setText(LLTrans::getString("none_paren_cap")); - } + LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text"); + + std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive"); + + if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText()) + { + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->saveCameraPreset(preset_camera_active); + } + } + + LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); + if (presetsMgr) + { + if (presetsMgr->isCameraDirty() && !preset_camera_active.empty()) + { + preset_camera_active.clear(); + } + } + + if (!preset_camera_active.empty()) + { + if (preset_camera_active == PRESETS_DEFAULT) + { + preset_camera_active = LLTrans::getString(PRESETS_DEFAULT); + } + preset_text->setText(preset_camera_active); + } + else + { + preset_text->setText(LLTrans::getString("none_paren_cap")); + } } BOOL LLPanelPreferenceGraphics::postBuild() { - LLFloaterReg::showInstance("prefs_graphics_advanced"); - LLFloaterReg::hideInstance("prefs_graphics_advanced"); + LLFloaterReg::showInstance("prefs_graphics_advanced"); + LLFloaterReg::hideInstance("prefs_graphics_advanced"); - resetDirtyChilds(); - setPresetText(); + resetDirtyChilds(); + setPresetText(); - LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); + LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); presetsMgr->setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this)); presetsMgr->createMissingDefault(PRESETS_GRAPHIC); // a no-op after the first time, but that's ok - return LLPanelPreference::postBuild(); + return LLPanelPreference::postBuild(); } void LLPanelPreferenceGraphics::draw() { - setPresetText(); - LLPanelPreference::draw(); + setPresetText(); + LLPanelPreference::draw(); } void LLPanelPreferenceGraphics::onPresetsListChange() { - resetDirtyChilds(); - setPresetText(); + resetDirtyChilds(); + setPresetText(); - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance && !gSavedSettings.getString("PresetGraphicActive").empty()) - { - instance->saveSettings(); //make cancel work correctly after changing the preset - } + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance && !gSavedSettings.getString("PresetGraphicActive").empty()) + { + instance->saveSettings(); //make cancel work correctly after changing the preset + } } void LLPanelPreferenceGraphics::setPresetText() { - LLTextBox* preset_text = getChild<LLTextBox>("preset_text"); - - std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive"); - - if (!preset_graphic_active.empty() && preset_graphic_active != preset_text->getText()) - { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { - instance->saveGraphicsPreset(preset_graphic_active); - } - } - - if (hasDirtyChilds() && !preset_graphic_active.empty()) - { - gSavedSettings.setString("PresetGraphicActive", ""); - preset_graphic_active.clear(); - // This doesn't seem to cause an infinite recursion. This trigger is needed to cause the pulldown - // panel to update. - LLPresetsManager::getInstance()->triggerChangeSignal(); - } - - if (!preset_graphic_active.empty()) - { - if (preset_graphic_active == PRESETS_DEFAULT) - { - preset_graphic_active = LLTrans::getString(PRESETS_DEFAULT); - } - preset_text->setText(preset_graphic_active); - } - else - { - preset_text->setText(LLTrans::getString("none_paren_cap")); - } - - preset_text->resetDirty(); + LLTextBox* preset_text = getChild<LLTextBox>("preset_text"); + + std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive"); + + if (!preset_graphic_active.empty() && preset_graphic_active != preset_text->getText()) + { + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->saveGraphicsPreset(preset_graphic_active); + } + } + + if (hasDirtyChilds() && !preset_graphic_active.empty()) + { + gSavedSettings.setString("PresetGraphicActive", ""); + preset_graphic_active.clear(); + // This doesn't seem to cause an infinite recursion. This trigger is needed to cause the pulldown + // panel to update. + LLPresetsManager::getInstance()->triggerChangeSignal(); + } + + if (!preset_graphic_active.empty()) + { + if (preset_graphic_active == PRESETS_DEFAULT) + { + preset_graphic_active = LLTrans::getString(PRESETS_DEFAULT); + } + preset_text->setText(preset_graphic_active); + } + else + { + preset_text->setText(LLTrans::getString("none_paren_cap")); + } + + preset_text->resetDirty(); } bool LLPanelPreferenceGraphics::hasDirtyChilds() { - LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); - std::list<LLView*> view_stack; - view_stack.push_back(this); - if (advanced) - { - view_stack.push_back(advanced); - } - while(!view_stack.empty()) - { - // Process view on top of the stack - LLView* curview = view_stack.front(); - view_stack.pop_front(); - - LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); - if (ctrl) - { - if (ctrl->isDirty()) - { - LLControlVariable* control = ctrl->getControlVariable(); - if (control) - { - std::string control_name = control->getName(); - if (!control_name.empty()) - { - return true; - } - } - } - } - // Push children onto the end of the work stack - for (child_list_t::const_iterator iter = curview->getChildList()->begin(); - iter != curview->getChildList()->end(); ++iter) - { - view_stack.push_back(*iter); - } - } - - return false; + LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); + std::list<LLView*> view_stack; + view_stack.push_back(this); + if (advanced) + { + view_stack.push_back(advanced); + } + while(!view_stack.empty()) + { + // Process view on top of the stack + LLView* curview = view_stack.front(); + view_stack.pop_front(); + + LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); + if (ctrl) + { + if (ctrl->isDirty()) + { + LLControlVariable* control = ctrl->getControlVariable(); + if (control) + { + std::string control_name = control->getName(); + if (!control_name.empty()) + { + return true; + } + } + } + } + // Push children onto the end of the work stack + for (child_list_t::const_iterator iter = curview->getChildList()->begin(); + iter != curview->getChildList()->end(); ++iter) + { + view_stack.push_back(*iter); + } + } + + return false; } void LLPanelPreferenceGraphics::resetDirtyChilds() { - LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); - std::list<LLView*> view_stack; - view_stack.push_back(this); - if (advanced) - { - view_stack.push_back(advanced); - } - while(!view_stack.empty()) - { - // Process view on top of the stack - LLView* curview = view_stack.front(); - view_stack.pop_front(); - - LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); - if (ctrl) - { - ctrl->resetDirty(); - } - // Push children onto the end of the work stack - for (child_list_t::const_iterator iter = curview->getChildList()->begin(); - iter != curview->getChildList()->end(); ++iter) - { - view_stack.push_back(*iter); - } - } + LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced"); + std::list<LLView*> view_stack; + view_stack.push_back(this); + if (advanced) + { + view_stack.push_back(advanced); + } + while(!view_stack.empty()) + { + // Process view on top of the stack + LLView* curview = view_stack.front(); + view_stack.pop_front(); + + LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); + if (ctrl) + { + ctrl->resetDirty(); + } + // Push children onto the end of the work stack + for (child_list_t::const_iterator iter = curview->getChildList()->begin(); + iter != curview->getChildList()->end(); ++iter) + { + view_stack.push_back(*iter); + } + } } void LLPanelPreferenceGraphics::cancel() { - LLPanelPreference::cancel(); + LLPanelPreference::cancel(); } void LLPanelPreferenceGraphics::saveSettings() { - resetDirtyChilds(); - std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive"); - if (preset_graphic_active.empty()) - { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { - //don't restore previous preset after closing Preferences - instance->saveGraphicsPreset(preset_graphic_active); - } - } - LLPanelPreference::saveSettings(); + resetDirtyChilds(); + std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive"); + if (preset_graphic_active.empty()) + { + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + //don't restore previous preset after closing Preferences + instance->saveGraphicsPreset(preset_graphic_active); + } + } + LLPanelPreference::saveSettings(); } void LLPanelPreferenceGraphics::setHardwareDefaults() { - resetDirtyChilds(); + resetDirtyChilds(); } LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) - : LLFloater(key) + : LLFloater(key) { - mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this)); - mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this)); - mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this)); + mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this)); + mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this)); + mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this)); } LLFloaterPreferenceGraphicsAdvanced::~LLFloaterPreferenceGraphicsAdvanced() @@ -2852,12 +2852,12 @@ LLFloaterPreferenceGraphicsAdvanced::~LLFloaterPreferenceGraphicsAdvanced() } LLFloaterPreferenceProxy::LLFloaterPreferenceProxy(const LLSD& key) - : LLFloater(key), - mSocksSettingsDirty(false) + : LLFloater(key), + mSocksSettingsDirty(false) { - mCommitCallbackRegistrar.add("Proxy.OK", boost::bind(&LLFloaterPreferenceProxy::onBtnOk, this)); - mCommitCallbackRegistrar.add("Proxy.Cancel", boost::bind(&LLFloaterPreferenceProxy::onBtnCancel, this)); - mCommitCallbackRegistrar.add("Proxy.Change", boost::bind(&LLFloaterPreferenceProxy::onChangeSocksSettings, this)); + mCommitCallbackRegistrar.add("Proxy.OK", boost::bind(&LLFloaterPreferenceProxy::onBtnOk, this)); + mCommitCallbackRegistrar.add("Proxy.Cancel", boost::bind(&LLFloaterPreferenceProxy::onBtnCancel, this)); + mCommitCallbackRegistrar.add("Proxy.Change", boost::bind(&LLFloaterPreferenceProxy::onChangeSocksSettings, this)); } BOOL LLFloaterPreferenceGraphicsAdvanced::postBuild() @@ -2884,11 +2884,11 @@ void LLFloaterPreferenceGraphicsAdvanced::onOpen(const LLSD& key) void LLFloaterPreferenceGraphicsAdvanced::onClickCloseBtn(bool app_quitting) { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { - instance->cancel(); - } + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->cancel(); + } } LLFloaterPreferenceProxy::~LLFloaterPreferenceProxy() @@ -2897,182 +2897,182 @@ LLFloaterPreferenceProxy::~LLFloaterPreferenceProxy() BOOL LLFloaterPreferenceProxy::postBuild() { - LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type"); - if (!socksAuth) - { - return FALSE; - } - if (socksAuth->getSelectedValue().asString() == "None") - { - getChild<LLLineEditor>("socks5_username")->setEnabled(false); - getChild<LLLineEditor>("socks5_password")->setEnabled(false); - } - else - { - // Populate the SOCKS 5 credential fields with protected values. - LLPointer<LLCredential> socks_cred = gSecAPIHandler->loadCredential("SOCKS5"); - getChild<LLLineEditor>("socks5_username")->setValue(socks_cred->getIdentifier()["username"].asString()); - getChild<LLLineEditor>("socks5_password")->setValue(socks_cred->getAuthenticator()["creds"].asString()); - } - - return TRUE; + LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type"); + if (!socksAuth) + { + return FALSE; + } + if (socksAuth->getSelectedValue().asString() == "None") + { + getChild<LLLineEditor>("socks5_username")->setEnabled(false); + getChild<LLLineEditor>("socks5_password")->setEnabled(false); + } + else + { + // Populate the SOCKS 5 credential fields with protected values. + LLPointer<LLCredential> socks_cred = gSecAPIHandler->loadCredential("SOCKS5"); + getChild<LLLineEditor>("socks5_username")->setValue(socks_cred->getIdentifier()["username"].asString()); + getChild<LLLineEditor>("socks5_password")->setValue(socks_cred->getAuthenticator()["creds"].asString()); + } + + return TRUE; } void LLFloaterPreferenceProxy::onOpen(const LLSD& key) { - saveSettings(); + saveSettings(); } void LLFloaterPreferenceProxy::onClose(bool app_quitting) { - if(app_quitting) - { - cancel(); - } + if(app_quitting) + { + cancel(); + } - if (mSocksSettingsDirty) - { + if (mSocksSettingsDirty) + { - // If the user plays with the Socks proxy settings after login, it's only fair we let them know - // it will not be updated until next restart. - if (LLStartUp::getStartupState()>STATE_LOGIN_WAIT) - { - LLNotifications::instance().add("ChangeProxySettings", LLSD(), LLSD()); - mSocksSettingsDirty = false; // we have notified the user now be quiet again - } - } + // If the user plays with the Socks proxy settings after login, it's only fair we let them know + // it will not be updated until next restart. + if (LLStartUp::getStartupState()>STATE_LOGIN_WAIT) + { + LLNotifications::instance().add("ChangeProxySettings", LLSD(), LLSD()); + mSocksSettingsDirty = false; // we have notified the user now be quiet again + } + } } void LLFloaterPreferenceProxy::saveSettings() { - // Save the value of all controls in the hierarchy - mSavedValues.clear(); - std::list<LLView*> view_stack; - view_stack.push_back(this); - while(!view_stack.empty()) - { - // Process view on top of the stack - LLView* curview = view_stack.front(); - view_stack.pop_front(); - - LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); - if (ctrl) - { - LLControlVariable* control = ctrl->getControlVariable(); - if (control) - { - mSavedValues[control] = control->getValue(); - } - } - - // Push children onto the end of the work stack - for (child_list_t::const_iterator iter = curview->getChildList()->begin(); - iter != curview->getChildList()->end(); ++iter) - { - view_stack.push_back(*iter); - } - } + // Save the value of all controls in the hierarchy + mSavedValues.clear(); + std::list<LLView*> view_stack; + view_stack.push_back(this); + while(!view_stack.empty()) + { + // Process view on top of the stack + LLView* curview = view_stack.front(); + view_stack.pop_front(); + + LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview); + if (ctrl) + { + LLControlVariable* control = ctrl->getControlVariable(); + if (control) + { + mSavedValues[control] = control->getValue(); + } + } + + // Push children onto the end of the work stack + for (child_list_t::const_iterator iter = curview->getChildList()->begin(); + iter != curview->getChildList()->end(); ++iter) + { + view_stack.push_back(*iter); + } + } } void LLFloaterPreferenceProxy::onBtnOk() { - // commit any outstanding text entry - if (hasFocus()) - { - LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); - if (cur_focus && cur_focus->acceptsTextInput()) - { - cur_focus->onCommit(); - } - } - - // Save SOCKS proxy credentials securely if password auth is enabled - LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type"); - if (socksAuth->getSelectedValue().asString() == "UserPass") - { - LLSD socks_id = LLSD::emptyMap(); - socks_id["type"] = "SOCKS5"; - socks_id["username"] = getChild<LLLineEditor>("socks5_username")->getValue().asString(); - - LLSD socks_authenticator = LLSD::emptyMap(); - socks_authenticator["type"] = "SOCKS5"; - socks_authenticator["creds"] = getChild<LLLineEditor>("socks5_password")->getValue().asString(); - - // Using "SOCKS5" as the "grid" argument since the same proxy - // settings will be used for all grids and because there is no - // way to specify the type of credential. - LLPointer<LLCredential> socks_cred = gSecAPIHandler->createCredential("SOCKS5", socks_id, socks_authenticator); - gSecAPIHandler->saveCredential(socks_cred, true); - } - else - { - // Clear SOCKS5 credentials since they are no longer needed. - LLPointer<LLCredential> socks_cred = new LLCredential("SOCKS5"); - gSecAPIHandler->deleteCredential(socks_cred); - } - - closeFloater(false); + // commit any outstanding text entry + if (hasFocus()) + { + LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); + if (cur_focus && cur_focus->acceptsTextInput()) + { + cur_focus->onCommit(); + } + } + + // Save SOCKS proxy credentials securely if password auth is enabled + LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type"); + if (socksAuth->getSelectedValue().asString() == "UserPass") + { + LLSD socks_id = LLSD::emptyMap(); + socks_id["type"] = "SOCKS5"; + socks_id["username"] = getChild<LLLineEditor>("socks5_username")->getValue().asString(); + + LLSD socks_authenticator = LLSD::emptyMap(); + socks_authenticator["type"] = "SOCKS5"; + socks_authenticator["creds"] = getChild<LLLineEditor>("socks5_password")->getValue().asString(); + + // Using "SOCKS5" as the "grid" argument since the same proxy + // settings will be used for all grids and because there is no + // way to specify the type of credential. + LLPointer<LLCredential> socks_cred = gSecAPIHandler->createCredential("SOCKS5", socks_id, socks_authenticator); + gSecAPIHandler->saveCredential(socks_cred, true); + } + else + { + // Clear SOCKS5 credentials since they are no longer needed. + LLPointer<LLCredential> socks_cred = new LLCredential("SOCKS5"); + gSecAPIHandler->deleteCredential(socks_cred); + } + + closeFloater(false); } void LLFloaterPreferenceProxy::onBtnCancel() { - if (hasFocus()) - { - LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); - if (cur_focus && cur_focus->acceptsTextInput()) - { - cur_focus->onCommit(); - } - refresh(); - } + if (hasFocus()) + { + LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); + if (cur_focus && cur_focus->acceptsTextInput()) + { + cur_focus->onCommit(); + } + refresh(); + } - cancel(); + cancel(); } void LLFloaterPreferenceProxy::onClickCloseBtn(bool app_quitting) { - cancel(); + cancel(); } void LLFloaterPreferenceProxy::cancel() { - for (control_values_map_t::iterator iter = mSavedValues.begin(); - iter != mSavedValues.end(); ++iter) - { - LLControlVariable* control = iter->first; - LLSD ctrl_value = iter->second; - control->set(ctrl_value); - } - mSocksSettingsDirty = false; - closeFloater(); + for (control_values_map_t::iterator iter = mSavedValues.begin(); + iter != mSavedValues.end(); ++iter) + { + LLControlVariable* control = iter->first; + LLSD ctrl_value = iter->second; + control->set(ctrl_value); + } + mSocksSettingsDirty = false; + closeFloater(); } void LLFloaterPreferenceProxy::onChangeSocksSettings() { - mSocksSettingsDirty = true; - - LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type"); - if (socksAuth->getSelectedValue().asString() == "None") - { - getChild<LLLineEditor>("socks5_username")->setEnabled(false); - getChild<LLLineEditor>("socks5_password")->setEnabled(false); - } - else - { - getChild<LLLineEditor>("socks5_username")->setEnabled(true); - getChild<LLLineEditor>("socks5_password")->setEnabled(true); - } - - // Check for invalid states for the other HTTP proxy radio - LLRadioGroup* otherHttpProxy = getChild<LLRadioGroup>("other_http_proxy_type"); - if ((otherHttpProxy->getSelectedValue().asString() == "Socks" && - getChild<LLCheckBoxCtrl>("socks_proxy_enabled")->get() == FALSE )||( - otherHttpProxy->getSelectedValue().asString() == "Web" && - getChild<LLCheckBoxCtrl>("web_proxy_enabled")->get() == FALSE ) ) - { - otherHttpProxy->selectFirstItem(); - } + mSocksSettingsDirty = true; + + LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type"); + if (socksAuth->getSelectedValue().asString() == "None") + { + getChild<LLLineEditor>("socks5_username")->setEnabled(false); + getChild<LLLineEditor>("socks5_password")->setEnabled(false); + } + else + { + getChild<LLLineEditor>("socks5_username")->setEnabled(true); + getChild<LLLineEditor>("socks5_password")->setEnabled(true); + } + + // Check for invalid states for the other HTTP proxy radio + LLRadioGroup* otherHttpProxy = getChild<LLRadioGroup>("other_http_proxy_type"); + if ((otherHttpProxy->getSelectedValue().asString() == "Socks" && + getChild<LLCheckBoxCtrl>("socks_proxy_enabled")->get() == FALSE )||( + otherHttpProxy->getSelectedValue().asString() == "Web" && + getChild<LLCheckBoxCtrl>("web_proxy_enabled")->get() == FALSE ) ) + { + otherHttpProxy->selectFirstItem(); + } } diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index da96e68f5e..0d383c1da0 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -50,308 +50,308 @@ class LLTextBox; typedef std::map<std::string, std::string> notifications_map; typedef enum - { - GS_LOW_GRAPHICS, - GS_MID_GRAPHICS, - GS_HIGH_GRAPHICS, - GS_ULTRA_GRAPHICS - - } EGraphicsSettings; + { + GS_LOW_GRAPHICS, + GS_MID_GRAPHICS, + GS_HIGH_GRAPHICS, + GS_ULTRA_GRAPHICS + + } EGraphicsSettings; // Floater to control preferences (display, audio, bandwidth, general. class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver, public LLConversationLogObserver { public: - LLFloaterPreference(const LLSD& key); - ~LLFloaterPreference(); - - void apply(); - void cancel(); - /*virtual*/ void draw(); - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClose(bool app_quitting); - /*virtual*/ void changed(); - /*virtual*/ void changed(const LLUUID& session_id, U32 mask) {}; - - // static data update, called from message handler - static void updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email); - - // refresh all the graphics preferences menus - static void refreshEnabledGraphics(); - - // translate user's do not disturb response message according to current locale if message is default, otherwise do nothing - static void initDoNotDisturbResponse(); - - // update Show Favorites checkbox - static void updateShowFavoritesCheckbox(bool val); - - void processProperties( void* pData, EAvatarProcessorType type ); - void processProfileProperties(const LLAvatarData* pAvatarData ); - void storeAvatarProperties( const LLAvatarData* pAvatarData ); - void saveAvatarProperties( void ); - void selectPrivacyPanel(); - void selectChatPanel(); - void getControlNames(std::vector<std::string>& names); - -protected: - void onBtnOK(const LLSD& userdata); - void onBtnCancel(const LLSD& userdata); - - void onClickClearCache(); // Clear viewer texture cache, vfs, and VO cache on next startup - void onClickBrowserClearCache(); // Clear web history and caches as well as viewer caches above - void onLanguageChange(); - void onNotificationsChange(const std::string& OptionName); - void onNameTagOpacityChange(const LLSD& newvalue); - - // set value of "DoNotDisturbResponseChanged" in account settings depending on whether do not disturb response - // string differs from default after user changes. - void onDoNotDisturbResponseChanged(); - // if the custom settings box is clicked - void onChangeCustom(); - void updateMeterText(LLUICtrl* ctrl); - // callback for defaults - void setHardwareDefaults(); - void setRecommended(); - // callback for when client turns on shaders - void onVertexShaderEnable(); - // callback for when client turns on impostors - void onAvatarImpostorsEnable(); - - // callback for commit in the "Single click on land" and "Double click on land" comboboxes. - void onClickActionChange(); - // updates click/double-click action settings depending on controls values - void updateClickActionSettings(); - // updates click/double-click action controls depending on values from settings.xml - void updateClickActionControls(); + LLFloaterPreference(const LLSD& key); + ~LLFloaterPreference(); + + void apply(); + void cancel(); + /*virtual*/ void draw(); + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + /*virtual*/ void onClose(bool app_quitting); + /*virtual*/ void changed(); + /*virtual*/ void changed(const LLUUID& session_id, U32 mask) {}; + + // static data update, called from message handler + static void updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email); + + // refresh all the graphics preferences menus + static void refreshEnabledGraphics(); + + // translate user's do not disturb response message according to current locale if message is default, otherwise do nothing + static void initDoNotDisturbResponse(); + + // update Show Favorites checkbox + static void updateShowFavoritesCheckbox(bool val); + + void processProperties( void* pData, EAvatarProcessorType type ); + void processProfileProperties(const LLAvatarData* pAvatarData ); + void storeAvatarProperties( const LLAvatarData* pAvatarData ); + void saveAvatarProperties( void ); + void selectPrivacyPanel(); + void selectChatPanel(); + void getControlNames(std::vector<std::string>& names); + +protected: + void onBtnOK(const LLSD& userdata); + void onBtnCancel(const LLSD& userdata); + + void onClickClearCache(); // Clear viewer texture cache, vfs, and VO cache on next startup + void onClickBrowserClearCache(); // Clear web history and caches as well as viewer caches above + void onLanguageChange(); + void onNotificationsChange(const std::string& OptionName); + void onNameTagOpacityChange(const LLSD& newvalue); + + // set value of "DoNotDisturbResponseChanged" in account settings depending on whether do not disturb response + // string differs from default after user changes. + void onDoNotDisturbResponseChanged(); + // if the custom settings box is clicked + void onChangeCustom(); + void updateMeterText(LLUICtrl* ctrl); + // callback for defaults + void setHardwareDefaults(); + void setRecommended(); + // callback for when client turns on shaders + void onVertexShaderEnable(); + // callback for when client turns on impostors + void onAvatarImpostorsEnable(); + + // callback for commit in the "Single click on land" and "Double click on land" comboboxes. + void onClickActionChange(); + // updates click/double-click action settings depending on controls values + void updateClickActionSettings(); + // updates click/double-click action controls depending on values from settings.xml + void updateClickActionControls(); public: - // This function squirrels away the current values of the controls so that - // cancel() can restore them. - void saveSettings(); - - void setCacheLocation(const LLStringExplicit& location); - - void onClickSetCache(); - void changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name); - void onClickResetCache(); - void onClickSkin(LLUICtrl* ctrl,const LLSD& userdata); - void onSelectSkin(); - void onClickSetKey(); - void setKey(KEY key); - void onClickSetMiddleMouse(); - void onClickSetSounds(); - void onClickEnablePopup(); - void onClickDisablePopup(); - void resetAllIgnored(); - void setAllIgnored(); - void onClickLogPath(); - void changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name); - bool moveTranscriptsAndLog(); - void enableHistory(); - void setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email); - void refreshEnabledState(); - void onCommitWindowedMode(); - void refresh(); // Refresh enable/disable - // if the quality radio buttons are changed - void onChangeQuality(const LLSD& data); - - void refreshUI(); - - void onCommitParcelMediaAutoPlayEnable(); - void onCommitMediaEnabled(); - void onCommitMusicEnabled(); - void applyResolution(); - void onChangeMaturity(); - void onChangeModelFolder(); - void onChangeTextureFolder(); - void onChangeSoundFolder(); - void onChangeAnimationFolder(); - void onClickBlockList(); - void onClickProxySettings(); - void onClickTranslationSettings(); - void onClickPermsDefault(); - void onClickAutoReplace(); - void onClickSpellChecker(); - void onClickRenderExceptions(); - void onClickAdvanced(); - void applyUIColor(LLUICtrl* ctrl, const LLSD& param); - void getUIColor(LLUICtrl* ctrl, const LLSD& param); - void onLogChatHistorySaved(); - void buildPopupLists(); - static void refreshSkin(void* data); - void selectPanel(const LLSD& name); - void saveCameraPreset(std::string& preset); - void saveGraphicsPreset(std::string& preset); + // This function squirrels away the current values of the controls so that + // cancel() can restore them. + void saveSettings(); + + void setCacheLocation(const LLStringExplicit& location); + + void onClickSetCache(); + void changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name); + void onClickResetCache(); + void onClickSkin(LLUICtrl* ctrl,const LLSD& userdata); + void onSelectSkin(); + void onClickSetKey(); + void setKey(KEY key); + void onClickSetMiddleMouse(); + void onClickSetSounds(); + void onClickEnablePopup(); + void onClickDisablePopup(); + void resetAllIgnored(); + void setAllIgnored(); + void onClickLogPath(); + void changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name); + bool moveTranscriptsAndLog(); + void enableHistory(); + void setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email); + void refreshEnabledState(); + void onCommitWindowedMode(); + void refresh(); // Refresh enable/disable + // if the quality radio buttons are changed + void onChangeQuality(const LLSD& data); + + void refreshUI(); + + void onCommitParcelMediaAutoPlayEnable(); + void onCommitMediaEnabled(); + void onCommitMusicEnabled(); + void applyResolution(); + void onChangeMaturity(); + void onChangeModelFolder(); + void onChangeTextureFolder(); + void onChangeSoundFolder(); + void onChangeAnimationFolder(); + void onClickBlockList(); + void onClickProxySettings(); + void onClickTranslationSettings(); + void onClickPermsDefault(); + void onClickAutoReplace(); + void onClickSpellChecker(); + void onClickRenderExceptions(); + void onClickAdvanced(); + void applyUIColor(LLUICtrl* ctrl, const LLSD& param); + void getUIColor(LLUICtrl* ctrl, const LLSD& param); + void onLogChatHistorySaved(); + void buildPopupLists(); + static void refreshSkin(void* data); + void selectPanel(const LLSD& name); + void saveCameraPreset(std::string& preset); + void saveGraphicsPreset(std::string& preset); private: - void onDeleteTranscripts(); - void onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response); - void updateDeleteTranscriptsButton(); - void updateMaxComplexity(); - - static std::string sSkin; - notifications_map mNotificationOptions; - bool mClickActionDirty; ///< Set to true when the click/double-click options get changed by user. - bool mGotPersonalInfo; - bool mOriginalIMViaEmail; - bool mLanguageChanged; - bool mAvatarDataInitialized; - std::string mPriorInstantMessageLogPath; - - bool mOriginalHideOnlineStatus; - std::string mDirectoryVisibility; - - LLAvatarData mAvatarProperties; - std::string mSavedCameraPreset; - std::string mSavedGraphicsPreset; - LOG_CLASS(LLFloaterPreference); + void onDeleteTranscripts(); + void onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response); + void updateDeleteTranscriptsButton(); + void updateMaxComplexity(); + + static std::string sSkin; + notifications_map mNotificationOptions; + bool mClickActionDirty; ///< Set to true when the click/double-click options get changed by user. + bool mGotPersonalInfo; + bool mOriginalIMViaEmail; + bool mLanguageChanged; + bool mAvatarDataInitialized; + std::string mPriorInstantMessageLogPath; + + bool mOriginalHideOnlineStatus; + std::string mDirectoryVisibility; + + LLAvatarData mAvatarProperties; + std::string mSavedCameraPreset; + std::string mSavedGraphicsPreset; + LOG_CLASS(LLFloaterPreference); }; class LLPanelPreference : public LLPanel { public: - LLPanelPreference(); - /*virtual*/ BOOL postBuild(); - - virtual ~LLPanelPreference(); + LLPanelPreference(); + /*virtual*/ BOOL postBuild(); + + virtual ~LLPanelPreference(); - virtual void apply(); - virtual void cancel(); - void setControlFalse(const LLSD& user_data); - virtual void setHardwareDefaults(); + virtual void apply(); + virtual void cancel(); + void setControlFalse(const LLSD& user_data); + virtual void setHardwareDefaults(); - // Disables "Allow Media to auto play" check box only when both - // "Streaming Music" and "Media" are unchecked. Otherwise enables it. - void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl); + // Disables "Allow Media to auto play" check box only when both + // "Streaming Music" and "Media" are unchecked. Otherwise enables it. + void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl); - // This function squirrels away the current values of the controls so that - // cancel() can restore them. - virtual void saveSettings(); + // This function squirrels away the current values of the controls so that + // cancel() can restore them. + virtual void saveSettings(); - void deletePreset(const LLSD& user_data); - void savePreset(const LLSD& user_data); - void loadPreset(const LLSD& user_data); + void deletePreset(const LLSD& user_data); + void savePreset(const LLSD& user_data); + void loadPreset(const LLSD& user_data); - class Updater; + class Updater; protected: - typedef std::map<LLControlVariable*, LLSD> control_values_map_t; - control_values_map_t mSavedValues; + typedef std::map<LLControlVariable*, LLSD> control_values_map_t; + control_values_map_t mSavedValues; private: - //for "Only friends and groups can call or IM me" - static void showFriendsOnlyWarning(LLUICtrl*, const LLSD&); + //for "Only friends and groups can call or IM me" + static void showFriendsOnlyWarning(LLUICtrl*, const LLSD&); //for "Allow Multiple Viewers" static void showMultipleViewersWarning(LLUICtrl*, const LLSD&); - //for "Show my Favorite Landmarks at Login" - static void handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value); + //for "Show my Favorite Landmarks at Login" + static void handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value); - static void toggleMuteWhenMinimized(); - typedef std::map<std::string, LLColor4> string_color_map_t; - string_color_map_t mSavedColors; + static void toggleMuteWhenMinimized(); + typedef std::map<std::string, LLColor4> string_color_map_t; + string_color_map_t mSavedColors; - Updater* mBandWidthUpdater; - LOG_CLASS(LLPanelPreference); + Updater* mBandWidthUpdater; + LOG_CLASS(LLPanelPreference); }; class LLPanelPreferenceView : public LLPanelPreference { public: - BOOL postBuild(); - void draw(); - void setPresetText(); + BOOL postBuild(); + void draw(); + void setPresetText(); private: - void onPresetsListChangeCamera(); - LOG_CLASS(LLPanelPreferenceView); + void onPresetsListChangeCamera(); + LOG_CLASS(LLPanelPreferenceView); }; class LLPanelPreferenceGraphics : public LLPanelPreference { public: - BOOL postBuild(); - void draw(); - void cancel(); - void saveSettings(); - void resetDirtyChilds(); - void setHardwareDefaults(); - void setPresetText(); + BOOL postBuild(); + void draw(); + void cancel(); + void saveSettings(); + void resetDirtyChilds(); + void setHardwareDefaults(); + void setPresetText(); - static const std::string getPresetsPath(); + static const std::string getPresetsPath(); protected: - bool hasDirtyChilds(); + bool hasDirtyChilds(); private: - void onPresetsListChange(); - LOG_CLASS(LLPanelPreferenceGraphics); + void onPresetsListChange(); + LOG_CLASS(LLPanelPreferenceGraphics); }; class LLFloaterPreferenceGraphicsAdvanced : public LLFloater { public: - LLFloaterPreferenceGraphicsAdvanced(const LLSD& key); - ~LLFloaterPreferenceGraphicsAdvanced(); - /*virtual*/ BOOL postBuild(); - void onOpen(const LLSD& key); - void onClickCloseBtn(bool app_quitting); - void disableUnavailableSettings(); - void refreshEnabledGraphics(); - void refreshEnabledState(); - void updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box); - void updateMaxNonImpostors(); - void setMaxNonImpostorsText(U32 value, LLTextBox* text_box); - void updateMaxComplexity(); - void setMaxComplexityText(U32 value, LLTextBox* text_box); - static void setIndirectControls(); - static void setIndirectMaxNonImpostors(); - static void setIndirectMaxArc(); - void refresh(); - // callback for when client turns on shaders - void onVertexShaderEnable(); - LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced); + LLFloaterPreferenceGraphicsAdvanced(const LLSD& key); + ~LLFloaterPreferenceGraphicsAdvanced(); + /*virtual*/ BOOL postBuild(); + void onOpen(const LLSD& key); + void onClickCloseBtn(bool app_quitting); + void disableUnavailableSettings(); + void refreshEnabledGraphics(); + void refreshEnabledState(); + void updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box); + void updateMaxNonImpostors(); + void setMaxNonImpostorsText(U32 value, LLTextBox* text_box); + void updateMaxComplexity(); + void setMaxComplexityText(U32 value, LLTextBox* text_box); + static void setIndirectControls(); + static void setIndirectMaxNonImpostors(); + static void setIndirectMaxArc(); + void refresh(); + // callback for when client turns on shaders + void onVertexShaderEnable(); + LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced); }; class LLAvatarComplexityControls { public: - static void updateMax(LLSliderCtrl* slider, LLTextBox* value_label); - static void setText(U32 value, LLTextBox* text_box); - static void setIndirectControls(); - static void setIndirectMaxNonImpostors(); - static void setIndirectMaxArc(); - LOG_CLASS(LLAvatarComplexityControls); + static void updateMax(LLSliderCtrl* slider, LLTextBox* value_label); + static void setText(U32 value, LLTextBox* text_box); + static void setIndirectControls(); + static void setIndirectMaxNonImpostors(); + static void setIndirectMaxArc(); + LOG_CLASS(LLAvatarComplexityControls); }; class LLFloaterPreferenceProxy : public LLFloater { public: - LLFloaterPreferenceProxy(const LLSD& key); - ~LLFloaterPreferenceProxy(); + LLFloaterPreferenceProxy(const LLSD& key); + ~LLFloaterPreferenceProxy(); - /// show off our menu - static void show(); - void cancel(); - + /// show off our menu + static void show(); + void cancel(); + protected: - BOOL postBuild(); - void onOpen(const LLSD& key); - void onClose(bool app_quitting); - void saveSettings(); - void onBtnOk(); - void onBtnCancel(); - void onClickCloseBtn(bool app_quitting = false); + BOOL postBuild(); + void onOpen(const LLSD& key); + void onClose(bool app_quitting); + void saveSettings(); + void onBtnOk(); + void onBtnCancel(); + void onClickCloseBtn(bool app_quitting = false); - void onChangeSocksSettings(); + void onChangeSocksSettings(); private: - - bool mSocksSettingsDirty; - typedef std::map<LLControlVariable*, LLSD> control_values_map_t; - control_values_map_t mSavedValues; - LOG_CLASS(LLFloaterPreferenceProxy); + + bool mSocksSettingsDirty; + typedef std::map<LLControlVariable*, LLSD> control_values_map_t; + control_values_map_t mSavedValues; + LOG_CLASS(LLFloaterPreferenceProxy); }; diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp index 791ff79d87..e740a3a9cf 100644 --- a/indra/newview/llfloaterpreferenceviewadvanced.cpp +++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp @@ -34,11 +34,11 @@ LLFloaterPreferenceViewAdvanced::LLFloaterPreferenceViewAdvanced(const LLSD& key) -: LLFloater(key) +: LLFloater(key) { - mCommitCallbackRegistrar.add("Cancel", boost::bind(&LLFloaterPreferenceViewAdvanced::onClickCancel, this)); - mCommitCallbackRegistrar.add("CommitSettings", boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this)); - mCommitCallbackRegistrar.add("Ok", boost::bind(&LLFloaterPreferenceViewAdvanced::onClickOk, this)); + mCommitCallbackRegistrar.add("Cancel", boost::bind(&LLFloaterPreferenceViewAdvanced::onClickCancel, this)); + mCommitCallbackRegistrar.add("CommitSettings", boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this)); + mCommitCallbackRegistrar.add("Ok", boost::bind(&LLFloaterPreferenceViewAdvanced::onClickOk, this)); } @@ -47,66 +47,66 @@ LLFloaterPreferenceViewAdvanced::~LLFloaterPreferenceViewAdvanced() void LLFloaterPreferenceViewAdvanced::onClickOk() { - closeFloater(); + closeFloater(); } void LLFloaterPreferenceViewAdvanced::onClickCancel() { - gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved); - gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved); + gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved); + gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved); - updateCameraControl(mCameraSaved); - updateFocusControl(mFocusSaved); + updateCameraControl(mCameraSaved); + updateFocusControl(mFocusSaved); } BOOL LLFloaterPreferenceViewAdvanced::postBuild() { - mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView"); - mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView"); + mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView"); + mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView"); - updateCameraControl(mCameraSaved); - updateFocusControl(mFocusSaved); + updateCameraControl(mCameraSaved); + updateFocusControl(mFocusSaved); - return TRUE; + return TRUE; } void LLFloaterPreferenceViewAdvanced::updateCameraControl(const LLVector3& vector) { - getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]); - getChild<LLSpinCtrl>("camera_y")->setValue(vector[VY]); - getChild<LLSpinCtrl>("camera_z")->setValue(vector[VZ]); + getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]); + getChild<LLSpinCtrl>("camera_y")->setValue(vector[VY]); + getChild<LLSpinCtrl>("camera_z")->setValue(vector[VZ]); } void LLFloaterPreferenceViewAdvanced::updateFocusControl(const LLVector3d& vector3d) { - getChild<LLSpinCtrl>("focus_x")->setValue(vector3d[VX]); - getChild<LLSpinCtrl>("focus_y")->setValue(vector3d[VY]); - getChild<LLSpinCtrl>("focus_z")->setValue(vector3d[VZ]); + getChild<LLSpinCtrl>("focus_x")->setValue(vector3d[VX]); + getChild<LLSpinCtrl>("focus_y")->setValue(vector3d[VY]); + getChild<LLSpinCtrl>("focus_z")->setValue(vector3d[VZ]); } void LLFloaterPreferenceViewAdvanced::draw() { - static LLCachedControl<LLVector3> camera(gSavedSettings, "CameraOffsetRearView"); - static LLCachedControl<LLVector3d> focus(gSavedSettings, "FocusOffsetRearView"); + static LLCachedControl<LLVector3> camera(gSavedSettings, "CameraOffsetRearView"); + static LLCachedControl<LLVector3d> focus(gSavedSettings, "FocusOffsetRearView"); - updateCameraControl(camera); - updateFocusControl(focus); + updateCameraControl(camera); + updateFocusControl(focus); - LLFloater::draw(); + LLFloater::draw(); } void LLFloaterPreferenceViewAdvanced::onCommitSettings() { - LLVector3 vector; - LLVector3d vector3d; - - vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal(); - vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal(); - vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal(); - gSavedSettings.setVector3("CameraOffsetRearView", vector); - - vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal(); - vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal(); - vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal(); - gSavedSettings.setVector3d("FocusOffsetRearView", vector3d); + LLVector3 vector; + LLVector3d vector3d; + + vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal(); + vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal(); + vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal(); + gSavedSettings.setVector3("CameraOffsetRearView", vector); + + vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal(); + vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal(); + vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal(); + gSavedSettings.setVector3d("FocusOffsetRearView", vector3d); } diff --git a/indra/newview/llfloaterpreferenceviewadvanced.h b/indra/newview/llfloaterpreferenceviewadvanced.h index 8f4b594605..9113949273 100644 --- a/indra/newview/llfloaterpreferenceviewadvanced.h +++ b/indra/newview/llfloaterpreferenceviewadvanced.h @@ -31,27 +31,27 @@ #include "llfloater.h" class LLFloaterPreferenceViewAdvanced -: public LLFloater +: public LLFloater { - friend class LLFloaterReg; + friend class LLFloaterReg; public: - LLFloaterPreferenceViewAdvanced(const LLSD& key); - virtual BOOL postBuild(); - virtual void draw(); + LLFloaterPreferenceViewAdvanced(const LLSD& key); + virtual BOOL postBuild(); + virtual void draw(); - void onCommitSettings(); - void onClickCancel(); - void onClickOk(); - void updateCameraControl(const LLVector3& vector); - void updateFocusControl(const LLVector3d& vector3d); + void onCommitSettings(); + void onClickCancel(); + void onClickOk(); + void updateCameraControl(const LLVector3& vector); + void updateFocusControl(const LLVector3d& vector3d); private: - virtual ~LLFloaterPreferenceViewAdvanced(); + virtual ~LLFloaterPreferenceViewAdvanced(); - LLVector3 mCameraSaved; - LLVector3d mFocusSaved; - + LLVector3 mCameraSaved; + LLVector3d mFocusSaved; + }; #endif //LLFLOATERPREFERENCEVIEWADVANCED_H diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp index bae7602566..149451c8c4 100644 --- a/indra/newview/llfloatersaveprefpreset.cpp +++ b/indra/newview/llfloatersaveprefpreset.cpp @@ -37,78 +37,78 @@ #include "lltrans.h" LLFloaterSavePrefPreset::LLFloaterSavePrefPreset(const LLSD &key) -: LLFloater(key) +: LLFloater(key) { } // virtual BOOL LLFloaterSavePrefPreset::postBuild() { - LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences"); - if (preferences) - { - preferences->addDependentFloater(this); - } - getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); - getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); - getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this)); - getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this)); - - LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this)); - - mSaveButton = getChild<LLButton>("save"); - mPresetCombo = getChild<LLComboBox>("preset_combo"); - - return TRUE; + LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences"); + if (preferences) + { + preferences->addDependentFloater(this); + } + getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); + getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); + getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this)); + getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this)); + + LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this)); + + mSaveButton = getChild<LLButton>("save"); + mPresetCombo = getChild<LLComboBox>("preset_combo"); + + return TRUE; } void LLFloaterSavePrefPreset::onPresetNameEdited() { - // Disable saving a preset having empty name. - std::string name = mPresetCombo->getSimple(); + // Disable saving a preset having empty name. + std::string name = mPresetCombo->getSimple(); - mSaveButton->setEnabled(!name.empty()); + mSaveButton->setEnabled(!name.empty()); } void LLFloaterSavePrefPreset::onOpen(const LLSD& key) { - mSubdirectory = key.asString(); + mSubdirectory = key.asString(); - std::string floater_title = getString(std::string("title_") + mSubdirectory); + std::string floater_title = getString(std::string("title_") + mSubdirectory); - setTitle(floater_title); + setTitle(floater_title); - EDefaultOptions option = DEFAULT_HIDE; - LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option); + EDefaultOptions option = DEFAULT_HIDE; + LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option); - onPresetNameEdited(); + onPresetNameEdited(); } void LLFloaterSavePrefPreset::onBtnSave() { - std::string name = mPresetCombo->getSimple(); - - if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT)) - { - LLNotificationsUtil::add("DefaultPresetNotSaved"); - } - else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name)) - { - LLSD args; - args["NAME"] = name; - LLNotificationsUtil::add("PresetNotSaved", args); - } - - closeFloater(); + std::string name = mPresetCombo->getSimple(); + + if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT)) + { + LLNotificationsUtil::add("DefaultPresetNotSaved"); + } + else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name)) + { + LLSD args; + args["NAME"] = name; + LLNotificationsUtil::add("PresetNotSaved", args); + } + + closeFloater(); } void LLFloaterSavePrefPreset::onPresetsListChange() { - EDefaultOptions option = DEFAULT_HIDE; - LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option); + EDefaultOptions option = DEFAULT_HIDE; + LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option); } void LLFloaterSavePrefPreset::onBtnCancel() { - closeFloater(); + closeFloater(); } diff --git a/indra/newview/llnavigationbar.h b/indra/newview/llnavigationbar.h index a44c6dd699..a9d0f1a82e 100755 --- a/indra/newview/llnavigationbar.h +++ b/indra/newview/llnavigationbar.h @@ -47,113 +47,113 @@ class LLSearchComboBox; class LLPullButton: public LLButton { - LOG_CLASS(LLPullButton); + LOG_CLASS(LLPullButton); public: - struct Params: public LLInitParam::Block<Params, LLButton::Params> - { - Optional<std::string> direction; // left, right, down, up + struct Params: public LLInitParam::Block<Params, LLButton::Params> + { + Optional<std::string> direction; // left, right, down, up - Params() - : direction("direction", "down") - { - } - }; - - /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); + Params() + : direction("direction", "down") + { + } + }; + + /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); - /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); + /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); - boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb); + boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb); protected: - friend class LLUICtrlFactory; - // convert string name into direction vector - void setDirectionFromName(const std::string& name); - LLPullButton(const LLPullButton::Params& params); - - commit_signal_t mClickDraggingSignal; - LLVector2 mLastMouseDown; - LLVector2 mDraggingDirection; + friend class LLUICtrlFactory; + // convert string name into direction vector + void setDirectionFromName(const std::string& name); + LLPullButton(const LLPullButton::Params& params); + + commit_signal_t mClickDraggingSignal; + LLVector2 mLastMouseDown; + LLVector2 mDraggingDirection; }; /** * Web browser-like navigation bar. */ class LLNavigationBar - : public LLPanel, public LLSingleton<LLNavigationBar>, private LLDestroyClass<LLNavigationBar> + : public LLPanel, public LLSingleton<LLNavigationBar>, private LLDestroyClass<LLNavigationBar> { - LLSINGLETON(LLNavigationBar); - virtual ~LLNavigationBar(); - LOG_CLASS(LLNavigationBar); - friend class LLDestroyClass<LLNavigationBar>; + LLSINGLETON(LLNavigationBar); + virtual ~LLNavigationBar(); + LOG_CLASS(LLNavigationBar); + friend class LLDestroyClass<LLNavigationBar>; public: - - /*virtual*/ void draw(); - /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL postBuild(); - /*virtual*/ void setVisible(BOOL visible); - - void handleLoginComplete(); - void clearHistoryCache(); - - int getDefNavBarHeight(); - int getDefFavBarHeight(); - + + /*virtual*/ void draw(); + /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL postBuild(); + /*virtual*/ void setVisible(BOOL visible); + + void handleLoginComplete(); + void clearHistoryCache(); + + int getDefNavBarHeight(); + int getDefFavBarHeight(); + private: - // the distance between navigation panel and favorites panel in pixels - const static S32 FAVBAR_TOP_PADDING = 10; - - void rebuildTeleportHistoryMenu(); - void showTeleportHistoryMenu(LLUICtrl* btn_ctrl); - void invokeSearch(std::string search_text); - void resizeLayoutPanel(); - // callbacks - void onTeleportHistoryMenuItemClicked(const LLSD& userdata); - void onTeleportHistoryChanged(); - void onBackButtonClicked(); - void onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param); - void onNavigationButtonHeldUp(LLButton* nav_button); - void onForwardButtonClicked(); - void onHomeButtonClicked(); - void onLocationSelection(); - void onLocationPrearrange(const LLSD& data); - void onTeleportFinished(const LLVector3d& global_agent_pos); - void onTeleportFailed(); - void onNavbarResized(); - void onRegionNameResponse( - std::string typed_location, - std::string region_name, - LLVector3 local_coords, - U64 region_handle, const std::string& url, - const LLUUID& snapshot_id, bool teleport); - - static void destroyClass() - { - if (LLNavigationBar::instanceExists()) - { - LLNavigationBar::getInstance()->setEnabled(FALSE); - } - } - - S32 mNavPanWidth; - LLMenuGL* mTeleportHistoryMenu; - LLPullButton* mBtnBack; - LLPullButton* mBtnForward; - LLButton* mBtnHome; - LLLocationInputCtrl* mCmbLocation; - LLRect mDefaultNbRect; - LLRect mDefaultFpRect; - LLLayoutPanel* mNavigationPanel; - LLLayoutPanel* mFavoritePanel; - boost::signals2::connection mTeleportFailedConnection; - boost::signals2::connection mTeleportFinishConnection; - boost::signals2::connection mHistoryMenuConnection; - // if true, save location to location history when teleport finishes - bool mSaveToLocationHistory; + // the distance between navigation panel and favorites panel in pixels + const static S32 FAVBAR_TOP_PADDING = 10; + + void rebuildTeleportHistoryMenu(); + void showTeleportHistoryMenu(LLUICtrl* btn_ctrl); + void invokeSearch(std::string search_text); + void resizeLayoutPanel(); + // callbacks + void onTeleportHistoryMenuItemClicked(const LLSD& userdata); + void onTeleportHistoryChanged(); + void onBackButtonClicked(); + void onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param); + void onNavigationButtonHeldUp(LLButton* nav_button); + void onForwardButtonClicked(); + void onHomeButtonClicked(); + void onLocationSelection(); + void onLocationPrearrange(const LLSD& data); + void onTeleportFinished(const LLVector3d& global_agent_pos); + void onTeleportFailed(); + void onNavbarResized(); + void onRegionNameResponse( + std::string typed_location, + std::string region_name, + LLVector3 local_coords, + U64 region_handle, const std::string& url, + const LLUUID& snapshot_id, bool teleport); + + static void destroyClass() + { + if (LLNavigationBar::instanceExists()) + { + LLNavigationBar::getInstance()->setEnabled(FALSE); + } + } + + S32 mNavPanWidth; + LLMenuGL* mTeleportHistoryMenu; + LLPullButton* mBtnBack; + LLPullButton* mBtnForward; + LLButton* mBtnHome; + LLLocationInputCtrl* mCmbLocation; + LLRect mDefaultNbRect; + LLRect mDefaultFpRect; + LLLayoutPanel* mNavigationPanel; + LLLayoutPanel* mFavoritePanel; + boost::signals2::connection mTeleportFailedConnection; + boost::signals2::connection mTeleportFinishConnection; + boost::signals2::connection mHistoryMenuConnection; + // if true, save location to location history when teleport finishes + bool mSaveToLocationHistory; }; #endif diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp index 7612c428d9..7cdb91388a 100644 --- a/indra/newview/llpanelpresetscamerapulldown.cpp +++ b/indra/newview/llpanelpresetscamerapulldown.cpp @@ -50,85 +50,85 @@ // Default constructor LLPanelPresetsCameraPulldown::LLPanelPresetsCameraPulldown() { - mHoverTimer.stop(); + mHoverTimer.stop(); - mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2)); - mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2)); + mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2)); + mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2)); - buildFromFile( "panel_presets_camera_pulldown.xml"); + buildFromFile( "panel_presets_camera_pulldown.xml"); } BOOL LLPanelPresetsCameraPulldown::postBuild() { - LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); - if (presetsMgr) - { - // Make sure there is a default preference file - presetsMgr->createMissingDefault(PRESETS_CAMERA); + LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); + if (presetsMgr) + { + // Make sure there is a default preference file + presetsMgr->createMissingDefault(PRESETS_CAMERA); - presetsMgr->startWatching(PRESETS_CAMERA); + presetsMgr->startWatching(PRESETS_CAMERA); - presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this)); - } + presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this)); + } - populatePanel(); + populatePanel(); - return LLPanel::postBuild(); + return LLPanel::postBuild(); } void LLPanelPresetsCameraPulldown::populatePanel() { - std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA); - LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP); + std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA); + LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP); - LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list"); + LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list"); - if (scroll && mPresetNames.begin() != mPresetNames.end()) - { - scroll->clearRows(); + if (scroll && mPresetNames.begin() != mPresetNames.end()) + { + scroll->clearRows(); - std::string active_preset = gSavedSettings.getString("PresetCameraActive"); - if (active_preset == PRESETS_DEFAULT) - { - active_preset = LLTrans::getString(PRESETS_DEFAULT); - } + std::string active_preset = gSavedSettings.getString("PresetCameraActive"); + if (active_preset == PRESETS_DEFAULT) + { + active_preset = LLTrans::getString(PRESETS_DEFAULT); + } - for (std::list<std::string>::const_iterator it = mPresetNames.begin(); it != mPresetNames.end(); ++it) - { - const std::string& name = *it; + for (std::list<std::string>::const_iterator it = mPresetNames.begin(); it != mPresetNames.end(); ++it) + { + const std::string& name = *it; LL_DEBUGS() << "adding '" << name << "'" << LL_ENDL; - LLSD row; - row["columns"][0]["column"] = "preset_name"; - row["columns"][0]["value"] = name; - - bool is_selected_preset = false; - if (name == active_preset) - { - row["columns"][1]["column"] = "icon"; - row["columns"][1]["type"] = "icon"; - row["columns"][1]["value"] = "Check_Mark"; - - is_selected_preset = true; - } - - LLScrollListItem* new_item = scroll->addElement(row); - new_item->setSelected(is_selected_preset); - } - } + LLSD row; + row["columns"][0]["column"] = "preset_name"; + row["columns"][0]["value"] = name; + + bool is_selected_preset = false; + if (name == active_preset) + { + row["columns"][1]["column"] = "icon"; + row["columns"][1]["type"] = "icon"; + row["columns"][1]["value"] = "Check_Mark"; + + is_selected_preset = true; + } + + LLScrollListItem* new_item = scroll->addElement(row); + new_item->setSelected(is_selected_preset); + } + } } /*virtual*/ void LLPanelPresetsCameraPulldown::onMouseEnter(S32 x, S32 y, MASK mask) { - mHoverTimer.stop(); - LLPanel::onMouseEnter(x,y,mask); + mHoverTimer.stop(); + LLPanel::onMouseEnter(x,y,mask); } /*virtual*/ void LLPanelPresetsCameraPulldown::onTopLost() { - setVisible(FALSE); + setVisible(FALSE); } /*virtual*/ @@ -155,45 +155,45 @@ BOOL LLPanelPresetsCameraPulldown::handleDoubleClick(S32 x, S32 y, MASK mask) /*virtual*/ void LLPanelPresetsCameraPulldown::onMouseLeave(S32 x, S32 y, MASK mask) { - mHoverTimer.start(); - LLPanel::onMouseLeave(x,y,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(); - - } + 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<LLScrollListCtrl>("preset_camera_list"); + LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list"); - if (scroll) - { - LLScrollListItem* item = scroll->getFirstSelected(); - if (item) - { - std::string name = item->getColumn(1)->getValue().asString(); + if (scroll) + { + LLScrollListItem* item = scroll->getFirstSelected(); + if (item) + { + std::string name = item->getColumn(1)->getValue().asString(); LL_DEBUGS() << "selected '" << name << "'" << LL_ENDL; - LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name); + LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name); - setVisible(FALSE); - } + setVisible(FALSE); + } else { LL_DEBUGS() << "none selected" << LL_ENDL; } - } + } else { LL_DEBUGS() << "no scroll" << LL_ENDL; @@ -202,36 +202,36 @@ void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data) void LLPanelPresetsCameraPulldown::onViewButtonClick(const LLSD& user_data) { - // close the minicontrol, we're bringing up the big one - setVisible(FALSE); - - // bring up the prefs floater - LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences"); - if (prefsfloater) - { - // grab the 'view' panel from the preferences floater and - // bring it the front! - LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core"); - LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view"); - if (tabcontainer && graphicspanel) - { - tabcontainer->selectTabPanel(graphicspanel); - } - } + // close the minicontrol, we're bringing up the big one + setVisible(FALSE); + + // bring up the prefs floater + LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences"); + if (prefsfloater) + { + // grab the 'view' panel from the preferences floater and + // bring it the front! + LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core"); + LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view"); + if (tabcontainer && graphicspanel) + { + tabcontainer->selectTabPanel(graphicspanel); + } + } } //virtual void LLPanelPresetsCameraPulldown::draw() { - F32 alpha = mHoverTimer.getStarted() - ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f) - : 1.0f; - LLViewDrawContext context(alpha); + F32 alpha = mHoverTimer.getStarted() + ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f) + : 1.0f; + LLViewDrawContext context(alpha); - LLPanel::draw(); + LLPanel::draw(); - if (alpha == 0.f) - { - setVisible(FALSE); - } + if (alpha == 0.f) + { + setVisible(FALSE); + } } diff --git a/indra/newview/llpanelpresetscamerapulldown.h b/indra/newview/llpanelpresetscamerapulldown.h index 12d9bc26ec..069d587086 100644 --- a/indra/newview/llpanelpresetscamerapulldown.h +++ b/indra/newview/llpanelpresetscamerapulldown.h @@ -36,26 +36,26 @@ class LLFrameTimer; class LLPanelPresetsCameraPulldown : public LLPanel { public: - LLPanelPresetsCameraPulldown(); - /*virtual*/ void draw(); - /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); - /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); + 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(); - + /*virtual*/ void onTopLost(); + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); + /*virtual*/ BOOL postBuild(); + void populatePanel(); + private: - void onViewButtonClick(const LLSD& user_data); - void onRowClick(const LLSD& user_data); + void onViewButtonClick(const LLSD& user_data); + void onRowClick(const LLSD& user_data); - std::list<std::string> mPresetNames; - LLFrameTimer mHoverTimer; - static const F32 sAutoCloseFadeStartTimeSec; - static const F32 sAutoCloseTotalTimeSec; + std::list<std::string> mPresetNames; + LLFrameTimer mHoverTimer; + static const F32 sAutoCloseFadeStartTimeSec; + static const F32 sAutoCloseTotalTimeSec; LOG_CLASS(LLPanelPresetsCameraPulldown); }; diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index c1702b4132..fb36c5875d 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -48,35 +48,35 @@ LLPresetsManager::LLPresetsManager() LLPresetsManager::~LLPresetsManager() { - mCameraChangedSignal.disconnect(); + mCameraChangedSignal.disconnect(); } void LLPresetsManager::triggerChangeCameraSignal() { - mPresetListChangeCameraSignal(); + mPresetListChangeCameraSignal(); } void LLPresetsManager::triggerChangeSignal() { - mPresetListChangeSignal(); + mPresetListChangeSignal(); } void LLPresetsManager::createMissingDefault(const std::string& subdirectory) { - if(gDirUtilp->getLindenUserDir().empty()) - { - return; - } - - std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, - subdirectory, PRESETS_DEFAULT + ".xml"); - if (!gDirUtilp->fileExists(default_file)) - { - LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL; - - // Write current settings as the default + if(gDirUtilp->getLindenUserDir().empty()) + { + return; + } + + std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, + subdirectory, PRESETS_DEFAULT + ".xml"); + if (!gDirUtilp->fileExists(default_file)) + { + LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL; + + // Write current settings as the default savePreset(subdirectory, PRESETS_DEFAULT, true); - } + } else { LL_DEBUGS() << "default preset exists; no-op" << LL_ENDL; @@ -85,330 +85,330 @@ void LLPresetsManager::createMissingDefault(const std::string& subdirectory) void LLPresetsManager::startWatching(const std::string& subdirectory) { - if (PRESETS_CAMERA == subdirectory) - { - std::vector<std::string> name_list; - getControlNames(name_list); - - for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it) - { - std::string ctrl_name = *it; - if (gSavedSettings.controlExists(ctrl_name)) - { - LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name); - if (cntrl_ptr.isNull()) - { - LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name - << "'" << LL_ENDL; - } - else - { - mCameraChangedSignal = cntrl_ptr->getCommitSignal()->connect(boost::bind(&settingChanged)); - } - } - } - } + if (PRESETS_CAMERA == subdirectory) + { + std::vector<std::string> name_list; + getControlNames(name_list); + + for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it) + { + std::string ctrl_name = *it; + if (gSavedSettings.controlExists(ctrl_name)) + { + LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name); + if (cntrl_ptr.isNull()) + { + LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name + << "'" << LL_ENDL; + } + else + { + mCameraChangedSignal = cntrl_ptr->getCommitSignal()->connect(boost::bind(&settingChanged)); + } + } + } + } } std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory) { - std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR); - - LLFile::mkdir(presets_path); - - std::string dest_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, subdirectory); - if (!gDirUtilp->fileExists(dest_path)) - LLFile::mkdir(dest_path); - - if (PRESETS_CAMERA == subdirectory) - { - std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA); - LLDirIterator dir_iter(source_dir, "*.xml"); - bool found = true; - while (found) - { - std::string file; - found = dir_iter.next(file); - - if (found) - { - std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file); - file = LLURI::escape(file); - std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file); - LLFile::copy(source, dest); - } - } - } - - return dest_path; + std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR); + + LLFile::mkdir(presets_path); + + std::string dest_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, subdirectory); + if (!gDirUtilp->fileExists(dest_path)) + LLFile::mkdir(dest_path); + + if (PRESETS_CAMERA == subdirectory) + { + std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA); + LLDirIterator dir_iter(source_dir, "*.xml"); + bool found = true; + while (found) + { + std::string file; + found = dir_iter.next(file); + + if (found) + { + std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file); + file = LLURI::escape(file); + std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file); + LLFile::copy(source, dest); + } + } + } + + return dest_path; } void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option) { - LL_INFOS("AppInit") << "Loading list of preset names from " << dir << LL_ENDL; + LL_INFOS("AppInit") << "Loading list of preset names from " << dir << LL_ENDL; - mPresetNames.clear(); + mPresetNames.clear(); - LLDirIterator dir_iter(dir, "*.xml"); - bool found = true; - while (found) - { - std::string file; - found = dir_iter.next(file); + LLDirIterator dir_iter(dir, "*.xml"); + bool found = true; + while (found) + { + std::string file; + found = dir_iter.next(file); - if (found) - { - std::string path = gDirUtilp->add(dir, file); - std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true)); + if (found) + { + std::string path = gDirUtilp->add(dir, file); + std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true)); LL_DEBUGS() << " Found preset '" << name << "'" << LL_ENDL; - if (PRESETS_DEFAULT != name) - { - mPresetNames.push_back(name); - } - else - { - switch (default_option) - { - case DEFAULT_SHOW: - mPresetNames.push_back(LLTrans::getString(PRESETS_DEFAULT)); - break; - - case DEFAULT_TOP: - mPresetNames.push_front(LLTrans::getString(PRESETS_DEFAULT)); - break; - - case DEFAULT_HIDE: - default: - break; - } - } - } - } - - presets = mPresetNames; + if (PRESETS_DEFAULT != name) + { + mPresetNames.push_back(name); + } + else + { + switch (default_option) + { + case DEFAULT_SHOW: + mPresetNames.push_back(LLTrans::getString(PRESETS_DEFAULT)); + break; + + case DEFAULT_TOP: + mPresetNames.push_front(LLTrans::getString(PRESETS_DEFAULT)); + break; + + case DEFAULT_HIDE: + default: + break; + } + } + } + } + + presets = mPresetNames; } bool LLPresetsManager::mCameraDirty = false; void LLPresetsManager::setCameraDirty(bool dirty) { - mCameraDirty = dirty; + mCameraDirty = dirty; } bool LLPresetsManager::isCameraDirty() { - return mCameraDirty; + return mCameraDirty; } void LLPresetsManager::settingChanged() { - setCameraDirty(true); + setCameraDirty(true); - gSavedSettings.setString("PresetCameraActive", ""); + gSavedSettings.setString("PresetCameraActive", ""); // Hack call because this is a static routine - LLPresetsManager::getInstance()->triggerChangeCameraSignal(); + LLPresetsManager::getInstance()->triggerChangeCameraSignal(); } void LLPresetsManager::getControlNames(std::vector<std::string>& names) { - const std::vector<std::string> camera_controls = boost::assign::list_of - // From panel_preferences_move.xml - ("CameraAngle") - ("CameraOffsetScale") - ("EditCameraMovement") - ("AppearanceCameraMovement") - // From llagentcamera.cpp - ("CameraOffsetBuild") - ("CameraOffsetRearView") - ("FocusOffsetRearView") - ("CameraOffsetScale") - ("TrackFocusObject") + const std::vector<std::string> camera_controls = boost::assign::list_of + // From panel_preferences_move.xml + ("CameraAngle") + ("CameraOffsetScale") + ("EditCameraMovement") + ("AppearanceCameraMovement") + // From llagentcamera.cpp + ("CameraOffsetBuild") + ("CameraOffsetRearView") + ("FocusOffsetRearView") + ("CameraOffsetScale") + ("TrackFocusObject") ; names = camera_controls; } bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault) { - if (LLTrans::getString(PRESETS_DEFAULT) == name) - { - name = PRESETS_DEFAULT; - } - if (!createDefault && name == PRESETS_DEFAULT) - { - LL_WARNS() << "Should not overwrite default" << LL_ENDL; - return false; - } - - bool saved = false; - std::vector<std::string> name_list; - - if(PRESETS_GRAPHIC == subdirectory) - { - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance && !createDefault) - { - gSavedSettings.setString("PresetGraphicActive", name); - instance->getControlNames(name_list); - LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL; - name_list.push_back("PresetGraphicActive"); - } - else + if (LLTrans::getString(PRESETS_DEFAULT) == name) + { + name = PRESETS_DEFAULT; + } + if (!createDefault && name == PRESETS_DEFAULT) + { + LL_WARNS() << "Should not overwrite default" << LL_ENDL; + return false; + } + + bool saved = false; + std::vector<std::string> name_list; + + if(PRESETS_GRAPHIC == subdirectory) + { + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance && !createDefault) + { + gSavedSettings.setString("PresetGraphicActive", name); + instance->getControlNames(name_list); + LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL; + name_list.push_back("PresetGraphicActive"); + } + else { - LL_WARNS("Presets") << "preferences floater instance not found" << LL_ENDL; - } - } - else if(PRESETS_CAMERA == subdirectory) - { - gSavedSettings.setString("PresetGraphicActive", name); - - name_list.clear(); - getControlNames(name_list); - name_list.push_back("PresetCameraActive"); - } - else - { - LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL; - } + LL_WARNS("Presets") << "preferences floater instance not found" << LL_ENDL; + } + } + else if(PRESETS_CAMERA == subdirectory) + { + gSavedSettings.setString("PresetGraphicActive", name); + + name_list.clear(); + getControlNames(name_list); + name_list.push_back("PresetCameraActive"); + } + else + { + LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL; + } - // make an empty llsd - LLSD paramsData(LLSD::emptyMap()); - - // Create a default graphics preset from hw recommended settings - if (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC) - { - paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap(); - if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0) - { - // use the recommended setting as an initial one (MAINT-6435) - gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger()); - } - } - else - { - for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it) - { - std::string ctrl_name = *it; - LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get(); - std::string comment = ctrl->getComment(); - std::string type = LLControlGroup::typeEnumToString(ctrl->type()); - LLSD value = ctrl->getValue(); - - paramsData[ctrl_name]["Comment"] = comment; - paramsData[ctrl_name]["Persist"] = 1; - paramsData[ctrl_name]["Type"] = type; - paramsData[ctrl_name]["Value"] = value; - } - } - - std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml"); + // make an empty llsd + LLSD paramsData(LLSD::emptyMap()); + + // Create a default graphics preset from hw recommended settings + if (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC) + { + paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap(); + if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0) + { + // use the recommended setting as an initial one (MAINT-6435) + gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger()); + } + } + else + { + for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it) + { + std::string ctrl_name = *it; + LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get(); + std::string comment = ctrl->getComment(); + std::string type = LLControlGroup::typeEnumToString(ctrl->type()); + LLSD value = ctrl->getValue(); + + paramsData[ctrl_name]["Comment"] = comment; + paramsData[ctrl_name]["Persist"] = 1; + paramsData[ctrl_name]["Type"] = type; + paramsData[ctrl_name]["Value"] = value; + } + } + + std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml"); // If the active preset name is the only thing in the list, don't save the list - if (paramsData.size() > 1) - { - // write to file - llofstream presetsXML(pathName.c_str()); - if (presetsXML.is_open()) - { - LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); - formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); - presetsXML.close(); - saved = true; + if (paramsData.size() > 1) + { + // write to file + llofstream presetsXML(pathName.c_str()); + if (presetsXML.is_open()) + { + LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); + formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); + presetsXML.close(); + saved = true; - LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL; - - if (subdirectory == PRESETS_GRAPHIC) - { - gSavedSettings.setString("PresetGraphicActive", name); - // signal interested parties - triggerChangeSignal(); - } - - if (subdirectory == PRESETS_CAMERA) - { - gSavedSettings.setString("PresetCameraActive", name); - setCameraDirty(false); - // signal interested parties - triggerChangeCameraSignal(); - } - } - else - { - LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL; - } - } + LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL; + + if (subdirectory == PRESETS_GRAPHIC) + { + gSavedSettings.setString("PresetGraphicActive", name); + // signal interested parties + triggerChangeSignal(); + } + + if (subdirectory == PRESETS_CAMERA) + { + gSavedSettings.setString("PresetCameraActive", name); + setCameraDirty(false); + // signal interested parties + triggerChangeCameraSignal(); + } + } + else + { + LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL; + } + } else - { - LL_INFOS() << "No settings available to be saved" << LL_ENDL; - } + { + LL_INFOS() << "No settings available to be saved" << LL_ENDL; + } - return saved; + return saved; } bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option) { - bool sts = true; - - combo->clearRows(); - - std::string presets_dir = getPresetsDir(subdirectory); - - if (!presets_dir.empty()) - { - std::list<std::string> preset_names; - loadPresetNamesFromDir(presets_dir, preset_names, default_option); - - std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive"); - - if (preset_names.begin() != preset_names.end()) - { - for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it) - { - const std::string& name = *it; - combo->add(name, LLSD().with(0, name)); - } - } - else - { - combo->setLabel(LLTrans::getString("preset_combo_label")); - sts = false; - } - } - return sts; + bool sts = true; + + combo->clearRows(); + + std::string presets_dir = getPresetsDir(subdirectory); + + if (!presets_dir.empty()) + { + std::list<std::string> preset_names; + loadPresetNamesFromDir(presets_dir, preset_names, default_option); + + std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive"); + + if (preset_names.begin() != preset_names.end()) + { + for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it) + { + const std::string& name = *it; + combo->add(name, LLSD().with(0, name)); + } + } + else + { + combo->setLabel(LLTrans::getString("preset_combo_label")); + sts = false; + } + } + return sts; } void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string name) { - if (LLTrans::getString(PRESETS_DEFAULT) == name) - { - name = PRESETS_DEFAULT; - } + if (LLTrans::getString(PRESETS_DEFAULT) == name) + { + name = PRESETS_DEFAULT; + } - std::string full_path(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml"); + std::string full_path(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml"); LL_DEBUGS() << "attempting to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL; - if(gSavedSettings.loadFromFile(full_path, false, true) > 0) - { - if(PRESETS_GRAPHIC == subdirectory) - { - gSavedSettings.setString("PresetGraphicActive", name); - - LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); - if (instance) - { - instance->refreshEnabledGraphics(); - } - triggerChangeSignal(); - } - if(PRESETS_CAMERA == subdirectory) - { - gSavedSettings.setString("PresetCameraActive", name); - triggerChangeCameraSignal(); - } - } + if(gSavedSettings.loadFromFile(full_path, false, true) > 0) + { + if(PRESETS_GRAPHIC == subdirectory) + { + gSavedSettings.setString("PresetGraphicActive", name); + + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->refreshEnabledGraphics(); + } + triggerChangeSignal(); + } + if(PRESETS_CAMERA == subdirectory) + { + gSavedSettings.setString("PresetCameraActive", name); + triggerChangeCameraSignal(); + } + } else { LL_WARNS("Presets") << "failed to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL; @@ -417,56 +417,56 @@ void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string n bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string name) { - if (LLTrans::getString(PRESETS_DEFAULT) == name) - { - name = PRESETS_DEFAULT; - } - - bool sts = true; - - if (PRESETS_DEFAULT == name) - { - // This code should never execute - LL_WARNS("Presets") << "You are not allowed to delete the default preset." << LL_ENDL; - sts = false; - } - - if (gDirUtilp->deleteFilesInDir(getPresetsDir(subdirectory), LLURI::escape(name) + ".xml") < 1) - { - LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL; - sts = false; - } - - // If you delete the preset that is currently marked as loaded then also indicate that no preset is loaded. - if(PRESETS_GRAPHIC == subdirectory) - { - if (gSavedSettings.getString("PresetGraphicActive") == name) - { - gSavedSettings.setString("PresetGraphicActive", ""); - } - // signal interested parties - triggerChangeSignal(); - } - - if(PRESETS_CAMERA == subdirectory) - { - if (gSavedSettings.getString("PresetCameraActive") == name) - { - gSavedSettings.setString("PresetCameraActive", ""); - } - // signal interested parties - triggerChangeCameraSignal(); - } - - return sts; + if (LLTrans::getString(PRESETS_DEFAULT) == name) + { + name = PRESETS_DEFAULT; + } + + bool sts = true; + + if (PRESETS_DEFAULT == name) + { + // This code should never execute + LL_WARNS("Presets") << "You are not allowed to delete the default preset." << LL_ENDL; + sts = false; + } + + if (gDirUtilp->deleteFilesInDir(getPresetsDir(subdirectory), LLURI::escape(name) + ".xml") < 1) + { + LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL; + sts = false; + } + + // If you delete the preset that is currently marked as loaded then also indicate that no preset is loaded. + if(PRESETS_GRAPHIC == subdirectory) + { + if (gSavedSettings.getString("PresetGraphicActive") == name) + { + gSavedSettings.setString("PresetGraphicActive", ""); + } + // signal interested parties + triggerChangeSignal(); + } + + if(PRESETS_CAMERA == subdirectory) + { + if (gSavedSettings.getString("PresetCameraActive") == name) + { + gSavedSettings.setString("PresetCameraActive", ""); + } + // signal interested parties + triggerChangeCameraSignal(); + } + + return sts; } boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb) { - return mPresetListChangeCameraSignal.connect(cb); + return mPresetListChangeCameraSignal.connect(cb); } boost::signals2::connection LLPresetsManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) { - return mPresetListChangeSignal.connect(cb); + return mPresetListChangeSignal.connect(cb); } diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h index 7370e0a3b1..c3a6c0795c 100644 --- a/indra/newview/llpresetsmanager.h +++ b/indra/newview/llpresetsmanager.h @@ -39,54 +39,54 @@ static const std::string PRESETS_CAMERA = "camera"; enum EDefaultOptions { - DEFAULT_SHOW, - DEFAULT_TOP, - DEFAULT_HIDE // Do not display "Default" in a list + DEFAULT_SHOW, + DEFAULT_TOP, + DEFAULT_HIDE // Do not display "Default" in a list }; class LLPresetsManager : public LLSingleton<LLPresetsManager> { - LLSINGLETON(LLPresetsManager); - ~LLPresetsManager(); + LLSINGLETON(LLPresetsManager); + ~LLPresetsManager(); public: - typedef std::list<std::string> preset_name_list_t; - typedef boost::signals2::signal<void()> preset_list_signal_t; + typedef std::list<std::string> preset_name_list_t; + typedef boost::signals2::signal<void()> preset_list_signal_t; - void createMissingDefault(const std::string& subdirectory); - void startWatching(const std::string& subdirectory); - void triggerChangeCameraSignal(); - void triggerChangeSignal(); - static std::string getPresetsDir(const std::string& subdirectory); - bool setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option); - void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option); - bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false); - void loadPreset(const std::string& subdirectory, std::string name); - bool deletePreset(const std::string& subdirectory, std::string name); - bool isCameraDirty(); - static void setCameraDirty(bool dirty); + void createMissingDefault(const std::string& subdirectory); + void startWatching(const std::string& subdirectory); + void triggerChangeCameraSignal(); + void triggerChangeSignal(); + static std::string getPresetsDir(const std::string& subdirectory); + bool setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option); + void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option); + bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false); + void loadPreset(const std::string& subdirectory, std::string name); + bool deletePreset(const std::string& subdirectory, std::string name); + bool isCameraDirty(); + static void setCameraDirty(bool dirty); - // Emitted when a preset gets loaded, deleted, or saved. - boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb); - boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); + // Emitted when a preset gets loaded, deleted, or saved. + boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb); + boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); - // Emitted when a preset gets loaded or saved. + // Emitted when a preset gets loaded or saved. - preset_name_list_t mPresetNames; + preset_name_list_t mPresetNames; - preset_list_signal_t mPresetListChangeCameraSignal; - preset_list_signal_t mPresetListChangeSignal; + preset_list_signal_t mPresetListChangeCameraSignal; + preset_list_signal_t mPresetListChangeSignal; private: - LOG_CLASS(LLPresetsManager); + LOG_CLASS(LLPresetsManager); - void getControlNames(std::vector<std::string>& names); - static void settingChanged(); + void getControlNames(std::vector<std::string>& names); + static void settingChanged(); - boost::signals2::connection mCameraChangedSignal; + boost::signals2::connection mCameraChangedSignal; - static bool mCameraDirty; + static bool mCameraDirty; }; #endif // LL_PRESETSMANAGER_H diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 398ec953d7..da495cbf21 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -63,7 +63,7 @@ #include "llworld.h" #include "llstatgraph.h" #include "llviewermedia.h" -#include "llviewermenu.h" // for gMenuBarView +#include "llviewermenu.h" // for gMenuBarView #include "llviewerparcelmgr.h" #include "llviewerthrottle.h" #include "lluictrlfactory.h" @@ -100,42 +100,42 @@ const S32 SIM_STAT_WIDTH = 8; const LLColor4 SIM_OK_COLOR(0.f, 1.f, 0.f, 1.f); const LLColor4 SIM_WARN_COLOR(1.f, 1.f, 0.f, 1.f); const LLColor4 SIM_FULL_COLOR(1.f, 0.f, 0.f, 1.f); -const F32 ICON_TIMER_EXPIRY = 3.f; // How long the balance and health icons should flash after a change. +const F32 ICON_TIMER_EXPIRY = 3.f; // How long the balance and health icons should flash after a change. static void onClickVolume(void*); LLStatusBar::LLStatusBar(const LLRect& rect) -: LLPanel(), - mTextTime(NULL), - mSGBandwidth(NULL), - mSGPacketLoss(NULL), - mBtnVolume(NULL), - mBoxBalance(NULL), - mBalance(0), - mHealth(100), - mSquareMetersCredit(0), - mSquareMetersCommitted(0) +: LLPanel(), + mTextTime(NULL), + mSGBandwidth(NULL), + mSGPacketLoss(NULL), + mBtnVolume(NULL), + mBoxBalance(NULL), + mBalance(0), + mHealth(100), + mSquareMetersCredit(0), + mSquareMetersCommitted(0) { - setRect(rect); - - // status bar can possible overlay menus? - setMouseOpaque(FALSE); + setRect(rect); + + // status bar can possible overlay menus? + setMouseOpaque(FALSE); - mBalanceTimer = new LLFrameTimer(); - mHealthTimer = new LLFrameTimer(); + mBalanceTimer = new LLFrameTimer(); + mHealthTimer = new LLFrameTimer(); - buildFromFile("panel_status_bar.xml"); + buildFromFile("panel_status_bar.xml"); } LLStatusBar::~LLStatusBar() { - delete mBalanceTimer; - mBalanceTimer = NULL; + delete mBalanceTimer; + mBalanceTimer = NULL; - delete mHealthTimer; - mHealthTimer = NULL; + delete mHealthTimer; + mHealthTimer = NULL; - // LLView destructor cleans up children + // LLView destructor cleans up children } //----------------------------------------------------------------------- @@ -145,465 +145,465 @@ LLStatusBar::~LLStatusBar() // virtual void LLStatusBar::draw() { - refresh(); - LLPanel::draw(); + refresh(); + LLPanel::draw(); } BOOL LLStatusBar::handleRightMouseDown(S32 x, S32 y, MASK mask) { - show_navbar_context_menu(this,x,y); - return TRUE; + show_navbar_context_menu(this,x,y); + return TRUE; } BOOL LLStatusBar::postBuild() { - gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3)); + gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3)); - mTextTime = getChild<LLTextBox>("TimeText" ); - - getChild<LLUICtrl>("buyL")->setCommitCallback( - boost::bind(&LLStatusBar::onClickBuyCurrency, this)); + mTextTime = getChild<LLTextBox>("TimeText" ); + + getChild<LLUICtrl>("buyL")->setCommitCallback( + boost::bind(&LLStatusBar::onClickBuyCurrency, this)); getChild<LLUICtrl>("goShop")->setCommitCallback(boost::bind(&LLWeb::loadURL, gSavedSettings.getString("MarketplaceURL"), LLStringUtil::null, LLStringUtil::null)); - mBoxBalance = getChild<LLTextBox>("balance"); - mBoxBalance->setClickedCallback( &LLStatusBar::onClickBalance, this ); - - mIconPresetsCamera = getChild<LLIconCtrl>( "presets_icon_camera" ); - mIconPresetsCamera->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresetsCamera, this)); - - mIconPresetsGraphic = getChild<LLIconCtrl>( "presets_icon_graphic" ); - mIconPresetsGraphic->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this)); - - mBtnVolume = getChild<LLButton>( "volume_btn" ); - mBtnVolume->setClickedCallback( onClickVolume, this ); - mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this)); - - mMediaToggle = getChild<LLButton>("media_toggle_btn"); - mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this ); - mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this)); - - LLHints::registerHintTarget("linden_balance", getChild<LLView>("balance_bg")->getHandle()); - - gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2)); - - // Adding Net Stat Graph - S32 x = getRect().getWidth() - 2; - S32 y = 0; - LLRect r; - r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1); - LLStatGraph::Params sgp; - sgp.name("BandwidthGraph"); - sgp.rect(r); - sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); - sgp.mouse_opaque(false); - sgp.stat.count_stat_float(&LLStatViewer::ACTIVE_MESSAGE_DATA_RECEIVED); - sgp.units("Kbps"); - sgp.precision(0); - sgp.per_sec(true); - mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp); - addChild(mSGBandwidth); - x -= SIM_STAT_WIDTH + 2; - - r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1); - //these don't seem to like being reused - LLStatGraph::Params pgp; - pgp.name("PacketLossPercent"); - pgp.rect(r); - pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); - pgp.mouse_opaque(false); - pgp.stat.sample_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT); - pgp.units("%"); - pgp.min(0.f); - pgp.max(5.f); - pgp.precision(1); - pgp.per_sec(false); - LLStatGraph::Thresholds thresholds; - thresholds.threshold.add(LLStatGraph::ThresholdParams().value(0.1).color(LLColor4::green)) - .add(LLStatGraph::ThresholdParams().value(0.25f).color(LLColor4::yellow)) - .add(LLStatGraph::ThresholdParams().value(0.6f).color(LLColor4::red)); - - pgp.thresholds(thresholds); - - mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp); - addChild(mSGPacketLoss); - - mPanelPresetsCameraPulldown = new LLPanelPresetsCameraPulldown(); - addChild(mPanelPresetsCameraPulldown); - mPanelPresetsCameraPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); - mPanelPresetsCameraPulldown->setVisible(FALSE); - - mPanelPresetsPulldown = new LLPanelPresetsPulldown(); - addChild(mPanelPresetsPulldown); - mPanelPresetsPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); - mPanelPresetsPulldown->setVisible(FALSE); - - mPanelVolumePulldown = new LLPanelVolumePulldown(); - addChild(mPanelVolumePulldown); - mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); - mPanelVolumePulldown->setVisible(FALSE); - - mPanelNearByMedia = new LLPanelNearByMedia(); - addChild(mPanelNearByMedia); - mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); - mPanelNearByMedia->setVisible(FALSE); - - return TRUE; + mBoxBalance = getChild<LLTextBox>("balance"); + mBoxBalance->setClickedCallback( &LLStatusBar::onClickBalance, this ); + + mIconPresetsCamera = getChild<LLIconCtrl>( "presets_icon_camera" ); + mIconPresetsCamera->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresetsCamera, this)); + + mIconPresetsGraphic = getChild<LLIconCtrl>( "presets_icon_graphic" ); + mIconPresetsGraphic->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this)); + + mBtnVolume = getChild<LLButton>( "volume_btn" ); + mBtnVolume->setClickedCallback( onClickVolume, this ); + mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this)); + + mMediaToggle = getChild<LLButton>("media_toggle_btn"); + mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this ); + mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this)); + + LLHints::registerHintTarget("linden_balance", getChild<LLView>("balance_bg")->getHandle()); + + gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2)); + + // Adding Net Stat Graph + S32 x = getRect().getWidth() - 2; + S32 y = 0; + LLRect r; + r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1); + LLStatGraph::Params sgp; + sgp.name("BandwidthGraph"); + sgp.rect(r); + sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); + sgp.mouse_opaque(false); + sgp.stat.count_stat_float(&LLStatViewer::ACTIVE_MESSAGE_DATA_RECEIVED); + sgp.units("Kbps"); + sgp.precision(0); + sgp.per_sec(true); + mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp); + addChild(mSGBandwidth); + x -= SIM_STAT_WIDTH + 2; + + r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1); + //these don't seem to like being reused + LLStatGraph::Params pgp; + pgp.name("PacketLossPercent"); + pgp.rect(r); + pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); + pgp.mouse_opaque(false); + pgp.stat.sample_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT); + pgp.units("%"); + pgp.min(0.f); + pgp.max(5.f); + pgp.precision(1); + pgp.per_sec(false); + LLStatGraph::Thresholds thresholds; + thresholds.threshold.add(LLStatGraph::ThresholdParams().value(0.1).color(LLColor4::green)) + .add(LLStatGraph::ThresholdParams().value(0.25f).color(LLColor4::yellow)) + .add(LLStatGraph::ThresholdParams().value(0.6f).color(LLColor4::red)); + + pgp.thresholds(thresholds); + + mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp); + addChild(mSGPacketLoss); + + mPanelPresetsCameraPulldown = new LLPanelPresetsCameraPulldown(); + addChild(mPanelPresetsCameraPulldown); + mPanelPresetsCameraPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); + mPanelPresetsCameraPulldown->setVisible(FALSE); + + mPanelPresetsPulldown = new LLPanelPresetsPulldown(); + addChild(mPanelPresetsPulldown); + mPanelPresetsPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); + mPanelPresetsPulldown->setVisible(FALSE); + + mPanelVolumePulldown = new LLPanelVolumePulldown(); + addChild(mPanelVolumePulldown); + mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); + mPanelVolumePulldown->setVisible(FALSE); + + mPanelNearByMedia = new LLPanelNearByMedia(); + addChild(mPanelNearByMedia); + mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); + mPanelNearByMedia->setVisible(FALSE); + + return TRUE; } // Per-frame updates of visibility void LLStatusBar::refresh() { - static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false); - bool net_stats_visible = show_net_stats; - - if (net_stats_visible) - { - // Adding Net Stat Meter back in - F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f; - mSGBandwidth->setMin(0.f); - mSGBandwidth->setMax(bwtotal*1.25f); - //mSGBandwidth->setThreshold(0, bwtotal*0.75f); - //mSGBandwidth->setThreshold(1, bwtotal); - //mSGBandwidth->setThreshold(2, bwtotal); - } - - // update clock every 10 seconds - if(mClockUpdateTimer.getElapsedTimeF32() > 10.f) - { - mClockUpdateTimer.reset(); - - // Get current UTC time, adjusted for the user's clock - // being off. - time_t utc_time; - utc_time = time_corrected(); - - std::string timeStr = getString("time"); - LLSD substitution; - substitution["datetime"] = (S32) utc_time; - LLStringUtil::format (timeStr, substitution); - mTextTime->setText(timeStr); - - // set the tooltip to have the date - std::string dtStr = getString("timeTooltip"); - LLStringUtil::format (dtStr, substitution); - mTextTime->setToolTip (dtStr); - } - - LLRect r; - const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge(); - - // reshape menu bar to its content's width - if (MENU_RIGHT != gMenuBarView->getRect().getWidth()) - { - gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight()); - } - - mSGBandwidth->setVisible(net_stats_visible); - mSGPacketLoss->setVisible(net_stats_visible); - - // update the master volume button state - bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute(); - mBtnVolume->setToggleState(mute_audio); - - // Disable media toggle if there's no media, parcel media, and no parcel audio - // (or if media is disabled) - bool button_enabled = (gSavedSettings.getBOOL("AudioStreamingMusic")||gSavedSettings.getBOOL("AudioStreamingMedia")) && - (LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio()); - mMediaToggle->setEnabled(button_enabled); - // Note the "sense" of the toggle is opposite whether media is playing or not - bool any_media_playing = (LLViewerMedia::isAnyMediaPlaying() || - LLViewerMedia::isParcelMediaPlaying() || - LLViewerMedia::isParcelAudioPlaying()); - mMediaToggle->setValue(!any_media_playing); + static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false); + bool net_stats_visible = show_net_stats; + + if (net_stats_visible) + { + // Adding Net Stat Meter back in + F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f; + mSGBandwidth->setMin(0.f); + mSGBandwidth->setMax(bwtotal*1.25f); + //mSGBandwidth->setThreshold(0, bwtotal*0.75f); + //mSGBandwidth->setThreshold(1, bwtotal); + //mSGBandwidth->setThreshold(2, bwtotal); + } + + // update clock every 10 seconds + if(mClockUpdateTimer.getElapsedTimeF32() > 10.f) + { + mClockUpdateTimer.reset(); + + // Get current UTC time, adjusted for the user's clock + // being off. + time_t utc_time; + utc_time = time_corrected(); + + std::string timeStr = getString("time"); + LLSD substitution; + substitution["datetime"] = (S32) utc_time; + LLStringUtil::format (timeStr, substitution); + mTextTime->setText(timeStr); + + // set the tooltip to have the date + std::string dtStr = getString("timeTooltip"); + LLStringUtil::format (dtStr, substitution); + mTextTime->setToolTip (dtStr); + } + + LLRect r; + const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge(); + + // reshape menu bar to its content's width + if (MENU_RIGHT != gMenuBarView->getRect().getWidth()) + { + gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight()); + } + + mSGBandwidth->setVisible(net_stats_visible); + mSGPacketLoss->setVisible(net_stats_visible); + + // update the master volume button state + bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute(); + mBtnVolume->setToggleState(mute_audio); + + // Disable media toggle if there's no media, parcel media, and no parcel audio + // (or if media is disabled) + bool button_enabled = (gSavedSettings.getBOOL("AudioStreamingMusic")||gSavedSettings.getBOOL("AudioStreamingMedia")) && + (LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio()); + mMediaToggle->setEnabled(button_enabled); + // Note the "sense" of the toggle is opposite whether media is playing or not + bool any_media_playing = (LLViewerMedia::isAnyMediaPlaying() || + LLViewerMedia::isParcelMediaPlaying() || + LLViewerMedia::isParcelAudioPlaying()); + mMediaToggle->setValue(!any_media_playing); } void LLStatusBar::setVisibleForMouselook(bool visible) { - mTextTime->setVisible(visible); - getChild<LLUICtrl>("balance_bg")->setVisible(visible); - mBoxBalance->setVisible(visible); - mBtnVolume->setVisible(visible); - mMediaToggle->setVisible(visible); - mSGBandwidth->setVisible(visible); - mSGPacketLoss->setVisible(visible); - setBackgroundVisible(visible); - mIconPresetsCamera->setVisible(visible); - mIconPresetsGraphic->setVisible(visible); + mTextTime->setVisible(visible); + getChild<LLUICtrl>("balance_bg")->setVisible(visible); + mBoxBalance->setVisible(visible); + mBtnVolume->setVisible(visible); + mMediaToggle->setVisible(visible); + mSGBandwidth->setVisible(visible); + mSGPacketLoss->setVisible(visible); + setBackgroundVisible(visible); + mIconPresetsCamera->setVisible(visible); + mIconPresetsGraphic->setVisible(visible); } void LLStatusBar::debitBalance(S32 debit) { - setBalance(getBalance() - debit); + setBalance(getBalance() - debit); } void LLStatusBar::creditBalance(S32 credit) { - setBalance(getBalance() + credit); + setBalance(getBalance() + credit); } void LLStatusBar::setBalance(S32 balance) { - if (balance > getBalance() && getBalance() != 0) - { - LLFirstUse::receiveLindens(); - } - - std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance ); - - LLStringUtil::format_map_t string_args; - string_args["[AMT]"] = llformat("%s", money_str.c_str()); - std::string label_str = getString("buycurrencylabel", string_args); - mBoxBalance->setValue(label_str); - - // Resize the L$ balance background to be wide enough for your balance plus the buy button - { - const S32 HPAD = 24; - LLRect balance_rect = mBoxBalance->getTextBoundingRect(); - LLRect buy_rect = getChildView("buyL")->getRect(); - LLRect shop_rect = getChildView("goShop")->getRect(); - LLView* balance_bg_view = getChildView("balance_bg"); - LLRect balance_bg_rect = balance_bg_view->getRect(); - balance_bg_rect.mLeft = balance_bg_rect.mRight - (buy_rect.getWidth() + shop_rect.getWidth() + balance_rect.getWidth() + HPAD); - balance_bg_view->setShape(balance_bg_rect); - } - - if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold"))) - { - if (mBalance > balance) - make_ui_sound("UISndMoneyChangeDown"); - else - make_ui_sound("UISndMoneyChangeUp"); - } - - if( balance != mBalance ) - { - mBalanceTimer->reset(); - mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY ); - mBalance = balance; - } + if (balance > getBalance() && getBalance() != 0) + { + LLFirstUse::receiveLindens(); + } + + std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance ); + + LLStringUtil::format_map_t string_args; + string_args["[AMT]"] = llformat("%s", money_str.c_str()); + std::string label_str = getString("buycurrencylabel", string_args); + mBoxBalance->setValue(label_str); + + // Resize the L$ balance background to be wide enough for your balance plus the buy button + { + const S32 HPAD = 24; + LLRect balance_rect = mBoxBalance->getTextBoundingRect(); + LLRect buy_rect = getChildView("buyL")->getRect(); + LLRect shop_rect = getChildView("goShop")->getRect(); + LLView* balance_bg_view = getChildView("balance_bg"); + LLRect balance_bg_rect = balance_bg_view->getRect(); + balance_bg_rect.mLeft = balance_bg_rect.mRight - (buy_rect.getWidth() + shop_rect.getWidth() + balance_rect.getWidth() + HPAD); + balance_bg_view->setShape(balance_bg_rect); + } + + if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold"))) + { + if (mBalance > balance) + make_ui_sound("UISndMoneyChangeDown"); + else + make_ui_sound("UISndMoneyChangeUp"); + } + + if( balance != mBalance ) + { + mBalanceTimer->reset(); + mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY ); + mBalance = balance; + } } // static void LLStatusBar::sendMoneyBalanceRequest() { - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_MoneyBalanceRequest); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_MoneyData); - msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); - gAgent.sendReliableMessage(); + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_MoneyBalanceRequest); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_MoneyData); + msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); + gAgent.sendReliableMessage(); } void LLStatusBar::setHealth(S32 health) { - //LL_INFOS() << "Setting health to: " << buffer << LL_ENDL; - if( mHealth > health ) - { - if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold"))) - { - if (isAgentAvatarValid()) - { - if (gAgentAvatarp->getSex() == SEX_FEMALE) - { - make_ui_sound("UISndHealthReductionF"); - } - else - { - make_ui_sound("UISndHealthReductionM"); - } - } - } - - mHealthTimer->reset(); - mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY ); - } - - mHealth = health; + //LL_INFOS() << "Setting health to: " << buffer << LL_ENDL; + if( mHealth > health ) + { + if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold"))) + { + if (isAgentAvatarValid()) + { + if (gAgentAvatarp->getSex() == SEX_FEMALE) + { + make_ui_sound("UISndHealthReductionF"); + } + else + { + make_ui_sound("UISndHealthReductionM"); + } + } + } + + mHealthTimer->reset(); + mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY ); + } + + mHealth = health; } S32 LLStatusBar::getBalance() const { - return mBalance; + return mBalance; } S32 LLStatusBar::getHealth() const { - return mHealth; + return mHealth; } void LLStatusBar::setLandCredit(S32 credit) { - mSquareMetersCredit = credit; + mSquareMetersCredit = credit; } void LLStatusBar::setLandCommitted(S32 committed) { - mSquareMetersCommitted = committed; + mSquareMetersCommitted = committed; } BOOL LLStatusBar::isUserTiered() const { - return (mSquareMetersCredit > 0); + return (mSquareMetersCredit > 0); } S32 LLStatusBar::getSquareMetersCredit() const { - return mSquareMetersCredit; + return mSquareMetersCredit; } S32 LLStatusBar::getSquareMetersCommitted() const { - return mSquareMetersCommitted; + return mSquareMetersCommitted; } S32 LLStatusBar::getSquareMetersLeft() const { - return mSquareMetersCredit - mSquareMetersCommitted; + return mSquareMetersCredit - mSquareMetersCommitted; } void LLStatusBar::onClickBuyCurrency() { - // open a currency floater - actual one open depends on - // value specified in settings.xml - LLBuyCurrencyHTML::openCurrencyFloater(); - LLFirstUse::receiveLindens(false); + // open a currency floater - actual one open depends on + // value specified in settings.xml + LLBuyCurrencyHTML::openCurrencyFloater(); + LLFirstUse::receiveLindens(false); } void LLStatusBar::onMouseEnterPresetsCamera() { - LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); - LLIconCtrl* icon = getChild<LLIconCtrl>( "presets_icon_camera" ); - LLRect icon_rect = icon->getRect(); - LLRect pulldown_rect = mPanelPresetsCameraPulldown->getRect(); - pulldown_rect.setLeftTopAndSize(icon_rect.mLeft - - (pulldown_rect.getWidth() - icon_rect.getWidth()), - icon_rect.mBottom, - pulldown_rect.getWidth(), - pulldown_rect.getHeight()); - - pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0); - mPanelPresetsCameraPulldown->setShape(pulldown_rect); - - // show the master presets pull-down - LLUI::clearPopups(); - LLUI::addPopup(mPanelPresetsCameraPulldown); - mPanelNearByMedia->setVisible(FALSE); - mPanelVolumePulldown->setVisible(FALSE); - mPanelPresetsPulldown->setVisible(FALSE); - mPanelPresetsCameraPulldown->setVisible(TRUE); + LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); + LLIconCtrl* icon = getChild<LLIconCtrl>( "presets_icon_camera" ); + LLRect icon_rect = icon->getRect(); + LLRect pulldown_rect = mPanelPresetsCameraPulldown->getRect(); + pulldown_rect.setLeftTopAndSize(icon_rect.mLeft - + (pulldown_rect.getWidth() - icon_rect.getWidth()), + icon_rect.mBottom, + pulldown_rect.getWidth(), + pulldown_rect.getHeight()); + + pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0); + mPanelPresetsCameraPulldown->setShape(pulldown_rect); + + // show the master presets pull-down + LLUI::clearPopups(); + LLUI::addPopup(mPanelPresetsCameraPulldown); + mPanelNearByMedia->setVisible(FALSE); + mPanelVolumePulldown->setVisible(FALSE); + mPanelPresetsPulldown->setVisible(FALSE); + mPanelPresetsCameraPulldown->setVisible(TRUE); } void LLStatusBar::onMouseEnterPresets() { - LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); - LLIconCtrl* icon = getChild<LLIconCtrl>( "presets_icon_graphic" ); - LLRect icon_rect = icon->getRect(); - LLRect pulldown_rect = mPanelPresetsPulldown->getRect(); - pulldown_rect.setLeftTopAndSize(icon_rect.mLeft - - (pulldown_rect.getWidth() - icon_rect.getWidth()), - icon_rect.mBottom, - pulldown_rect.getWidth(), - pulldown_rect.getHeight()); - - pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0); - mPanelPresetsPulldown->setShape(pulldown_rect); - - // show the master presets pull-down - LLUI::clearPopups(); - LLUI::addPopup(mPanelPresetsPulldown); - mPanelNearByMedia->setVisible(FALSE); - mPanelVolumePulldown->setVisible(FALSE); - mPanelPresetsPulldown->setVisible(TRUE); + LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); + LLIconCtrl* icon = getChild<LLIconCtrl>( "presets_icon_graphic" ); + LLRect icon_rect = icon->getRect(); + LLRect pulldown_rect = mPanelPresetsPulldown->getRect(); + pulldown_rect.setLeftTopAndSize(icon_rect.mLeft - + (pulldown_rect.getWidth() - icon_rect.getWidth()), + icon_rect.mBottom, + pulldown_rect.getWidth(), + pulldown_rect.getHeight()); + + pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0); + mPanelPresetsPulldown->setShape(pulldown_rect); + + // show the master presets pull-down + LLUI::clearPopups(); + LLUI::addPopup(mPanelPresetsPulldown); + mPanelNearByMedia->setVisible(FALSE); + mPanelVolumePulldown->setVisible(FALSE); + mPanelPresetsPulldown->setVisible(TRUE); } void LLStatusBar::onMouseEnterVolume() { - LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); - LLButton* volbtn = getChild<LLButton>( "volume_btn" ); - LLRect vol_btn_rect = volbtn->getRect(); - LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect(); - volume_pulldown_rect.setLeftTopAndSize(vol_btn_rect.mLeft - - (volume_pulldown_rect.getWidth() - vol_btn_rect.getWidth()), - vol_btn_rect.mBottom, - volume_pulldown_rect.getWidth(), - volume_pulldown_rect.getHeight()); - - volume_pulldown_rect.translate(popup_holder->getRect().getWidth() - volume_pulldown_rect.mRight, 0); - mPanelVolumePulldown->setShape(volume_pulldown_rect); - - - // show the master volume pull-down - LLUI::clearPopups(); - LLUI::addPopup(mPanelVolumePulldown); - mPanelPresetsCameraPulldown->setVisible(FALSE); - mPanelPresetsPulldown->setVisible(FALSE); - mPanelNearByMedia->setVisible(FALSE); - mPanelVolumePulldown->setVisible(TRUE); + LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); + LLButton* volbtn = getChild<LLButton>( "volume_btn" ); + LLRect vol_btn_rect = volbtn->getRect(); + LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect(); + volume_pulldown_rect.setLeftTopAndSize(vol_btn_rect.mLeft - + (volume_pulldown_rect.getWidth() - vol_btn_rect.getWidth()), + vol_btn_rect.mBottom, + volume_pulldown_rect.getWidth(), + volume_pulldown_rect.getHeight()); + + volume_pulldown_rect.translate(popup_holder->getRect().getWidth() - volume_pulldown_rect.mRight, 0); + mPanelVolumePulldown->setShape(volume_pulldown_rect); + + + // show the master volume pull-down + LLUI::clearPopups(); + LLUI::addPopup(mPanelVolumePulldown); + mPanelPresetsCameraPulldown->setVisible(FALSE); + mPanelPresetsPulldown->setVisible(FALSE); + mPanelNearByMedia->setVisible(FALSE); + mPanelVolumePulldown->setVisible(TRUE); } void LLStatusBar::onMouseEnterNearbyMedia() { - LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); - LLRect nearby_media_rect = mPanelNearByMedia->getRect(); - LLButton* nearby_media_btn = getChild<LLButton>( "media_toggle_btn" ); - LLRect nearby_media_btn_rect = nearby_media_btn->getRect(); - nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - - (nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2, - nearby_media_btn_rect.mBottom, - nearby_media_rect.getWidth(), - nearby_media_rect.getHeight()); - // force onscreen - nearby_media_rect.translate(popup_holder->getRect().getWidth() - nearby_media_rect.mRight, 0); - - // show the master volume pull-down - mPanelNearByMedia->setShape(nearby_media_rect); - LLUI::clearPopups(); - LLUI::addPopup(mPanelNearByMedia); - - mPanelPresetsCameraPulldown->setVisible(FALSE); - mPanelPresetsPulldown->setVisible(FALSE); - mPanelVolumePulldown->setVisible(FALSE); - mPanelNearByMedia->setVisible(TRUE); + LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); + LLRect nearby_media_rect = mPanelNearByMedia->getRect(); + LLButton* nearby_media_btn = getChild<LLButton>( "media_toggle_btn" ); + LLRect nearby_media_btn_rect = nearby_media_btn->getRect(); + nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - + (nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2, + nearby_media_btn_rect.mBottom, + nearby_media_rect.getWidth(), + nearby_media_rect.getHeight()); + // force onscreen + nearby_media_rect.translate(popup_holder->getRect().getWidth() - nearby_media_rect.mRight, 0); + + // show the master volume pull-down + mPanelNearByMedia->setShape(nearby_media_rect); + LLUI::clearPopups(); + LLUI::addPopup(mPanelNearByMedia); + + mPanelPresetsCameraPulldown->setVisible(FALSE); + mPanelPresetsPulldown->setVisible(FALSE); + mPanelVolumePulldown->setVisible(FALSE); + mPanelNearByMedia->setVisible(TRUE); } static void onClickVolume(void* data) { - // toggle the master mute setting - bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute(); - LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio); + // toggle the master mute setting + bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute(); + LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio); } //static void LLStatusBar::onClickBalance(void* ) { - // Force a balance request message: - LLStatusBar::sendMoneyBalanceRequest(); - // The refresh of the display (call to setBalance()) will be done by process_money_balance_reply() + // Force a balance request message: + LLStatusBar::sendMoneyBalanceRequest(); + // The refresh of the display (call to setBalance()) will be done by process_money_balance_reply() } //static void LLStatusBar::onClickMediaToggle(void* data) { - LLStatusBar *status_bar = (LLStatusBar*)data; - // "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media - bool pause = status_bar->mMediaToggle->getValue(); - LLViewerMedia::setAllMediaPaused(pause); + LLStatusBar *status_bar = (LLStatusBar*)data; + // "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media + bool pause = status_bar->mMediaToggle->getValue(); + LLViewerMedia::setAllMediaPaused(pause); } BOOL can_afford_transaction(S32 cost) { - return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost))); + return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost))); } void LLStatusBar::onVolumeChanged(const LLSD& newvalue) { - refresh(); + refresh(); } // Implements secondlife:///app/balance/request to request a L$ balance @@ -611,18 +611,18 @@ void LLStatusBar::onVolumeChanged(const LLSD& newvalue) class LLBalanceHandler : public LLCommandHandler { public: - // Requires "trusted" browser/URL source - LLBalanceHandler() : LLCommandHandler("balance", UNTRUSTED_BLOCK) { } - bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web) - { - if (tokens.size() == 1 - && tokens[0].asString() == "request") - { - LLStatusBar::sendMoneyBalanceRequest(); - return true; - } - return false; - } + // Requires "trusted" browser/URL source + LLBalanceHandler() : LLCommandHandler("balance", UNTRUSTED_BLOCK) { } + bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web) + { + if (tokens.size() == 1 + && tokens[0].asString() == "request") + { + LLStatusBar::sendMoneyBalanceRequest(); + return true; + } + return false; + } }; // register with command dispatch system LLBalanceHandler gBalanceHandler; diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h index 040b7bc949..e9be398601 100644 --- a/indra/newview/llstatusbar.h +++ b/indra/newview/llstatusbar.h @@ -48,82 +48,82 @@ class LLPanelNearByMedia; class LLIconCtrl; class LLStatusBar -: public LLPanel +: public LLPanel { public: - LLStatusBar(const LLRect& rect ); - /*virtual*/ ~LLStatusBar(); - - /*virtual*/ void draw(); + LLStatusBar(const LLRect& rect ); + /*virtual*/ ~LLStatusBar(); + + /*virtual*/ void draw(); - /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL postBuild(); + /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL postBuild(); - // MANIPULATORS - void setBalance(S32 balance); - void debitBalance(S32 debit); - void creditBalance(S32 credit); + // MANIPULATORS + void setBalance(S32 balance); + void debitBalance(S32 debit); + void creditBalance(S32 credit); - // Request the latest currency balance from the server - static void sendMoneyBalanceRequest(); + // Request the latest currency balance from the server + static void sendMoneyBalanceRequest(); - void setHealth(S32 percent); + void setHealth(S32 percent); - void setLandCredit(S32 credit); - void setLandCommitted(S32 committed); + void setLandCredit(S32 credit); + void setLandCommitted(S32 committed); - void refresh(); - void setVisibleForMouselook(bool visible); - // some elements should hide in mouselook + void refresh(); + void setVisibleForMouselook(bool visible); + // some elements should hide in mouselook - // ACCESSORS - S32 getBalance() const; - S32 getHealth() const; + // ACCESSORS + S32 getBalance() const; + S32 getHealth() const; - BOOL isUserTiered() const; - S32 getSquareMetersCredit() const; - S32 getSquareMetersCommitted() const; - S32 getSquareMetersLeft() const; + BOOL isUserTiered() const; + S32 getSquareMetersCredit() const; + S32 getSquareMetersCommitted() const; + S32 getSquareMetersLeft() const; - LLPanelNearByMedia* getNearbyMediaPanel() { return mPanelNearByMedia; } + LLPanelNearByMedia* getNearbyMediaPanel() { return mPanelNearByMedia; } private: - - void onClickBuyCurrency(); - void onVolumeChanged(const LLSD& newvalue); + + void onClickBuyCurrency(); + void onVolumeChanged(const LLSD& newvalue); - void onMouseEnterPresetsCamera(); - void onMouseEnterPresets(); - void onMouseEnterVolume(); - void onMouseEnterNearbyMedia(); - void onClickScreen(S32 x, S32 y); + void onMouseEnterPresetsCamera(); + void onMouseEnterPresets(); + void onMouseEnterVolume(); + void onMouseEnterNearbyMedia(); + void onClickScreen(S32 x, S32 y); - static void onClickMediaToggle(void* data); - static void onClickBalance(void* data); + static void onClickMediaToggle(void* data); + static void onClickBalance(void* data); private: - LLTextBox *mTextTime; - - LLStatGraph *mSGBandwidth; - LLStatGraph *mSGPacketLoss; - - LLIconCtrl *mIconPresetsCamera; - LLIconCtrl *mIconPresetsGraphic; - LLButton *mBtnVolume; - LLTextBox *mBoxBalance; - LLButton *mMediaToggle; - LLFrameTimer mClockUpdateTimer; - - S32 mBalance; - S32 mHealth; - S32 mSquareMetersCredit; - S32 mSquareMetersCommitted; - LLFrameTimer* mBalanceTimer; - LLFrameTimer* mHealthTimer; - LLPanelPresetsCameraPulldown* mPanelPresetsCameraPulldown; - LLPanelPresetsPulldown* mPanelPresetsPulldown; - LLPanelVolumePulldown* mPanelVolumePulldown; - LLPanelNearByMedia* mPanelNearByMedia; + LLTextBox *mTextTime; + + LLStatGraph *mSGBandwidth; + LLStatGraph *mSGPacketLoss; + + LLIconCtrl *mIconPresetsCamera; + LLIconCtrl *mIconPresetsGraphic; + LLButton *mBtnVolume; + LLTextBox *mBoxBalance; + LLButton *mMediaToggle; + LLFrameTimer mClockUpdateTimer; + + S32 mBalance; + S32 mHealth; + S32 mSquareMetersCredit; + S32 mSquareMetersCommitted; + LLFrameTimer* mBalanceTimer; + LLFrameTimer* mHealthTimer; + LLPanelPresetsCameraPulldown* mPanelPresetsCameraPulldown; + LLPanelPresetsPulldown* mPanelPresetsPulldown; + LLPanelVolumePulldown* mPanelVolumePulldown; + LLPanelNearByMedia* mPanelNearByMedia; }; // *HACK: Status bar owns your cached money balance. JC diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 5237986cd6..968472fe4c 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -166,216 +166,216 @@ class LLFloaterOpenHandler : public LLCommandHandler { public: - // requires trusted browser to trigger - LLFloaterOpenHandler() : LLCommandHandler("openfloater", UNTRUSTED_THROTTLE) { } + // requires trusted browser to trigger + LLFloaterOpenHandler() : LLCommandHandler("openfloater", UNTRUSTED_THROTTLE) { } - bool handle(const LLSD& params, const LLSD& query_map, - LLMediaCtrl* web) - { - if (params.size() != 1) - { - return false; - } + bool handle(const LLSD& params, const LLSD& query_map, + LLMediaCtrl* web) + { + if (params.size() != 1) + { + return false; + } - const std::string floater_name = LLURI::unescape(params[0].asString()); - LLFloaterReg::showInstance(floater_name); + const std::string floater_name = LLURI::unescape(params[0].asString()); + LLFloaterReg::showInstance(floater_name); - return true; - } + return true; + } }; LLFloaterOpenHandler gFloaterOpenHandler; void LLViewerFloaterReg::registerFloaters() { - // *NOTE: Please keep these alphabetized for easier merges + // *NOTE: Please keep these alphabetized for easier merges - LLFloaterAboutUtil::registerFloater(); - LLFloaterReg::add("block_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>); - LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>); - LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); - LLFloaterReg::add("associate_listing", "floater_associate_listing.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAssociateListing>); - LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAuction>); - LLFloaterReg::add("avatar", "floater_avatar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatar>); - LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarPicker>); - LLFloaterReg::add("avatar_render_settings", "floater_avatar_render_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarRenderSettings>); - LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarTextures>); + LLFloaterAboutUtil::registerFloater(); + LLFloaterReg::add("block_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>); + LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>); + LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); + LLFloaterReg::add("associate_listing", "floater_associate_listing.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAssociateListing>); + LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAuction>); + LLFloaterReg::add("avatar", "floater_avatar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatar>); + LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarPicker>); + LLFloaterReg::add("avatar_render_settings", "floater_avatar_render_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarRenderSettings>); + LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarTextures>); - LLFloaterReg::add("beacons", "floater_beacons.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBeacons>); - LLFloaterReg::add("bulk_perms", "floater_bulk_perms.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBulkPermission>); - LLFloaterReg::add("buy_currency", "floater_buy_currency.xml", &LLFloaterBuyCurrency::buildFloater); - LLFloaterReg::add("buy_currency_html", "floater_buy_currency_html.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyCurrencyHTML>); - LLFloaterReg::add("buy_land", "floater_buy_land.xml", &LLFloaterBuyLand::buildFloater); - LLFloaterReg::add("buy_object", "floater_buy_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuy>); - LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyContents>); - LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTools>); - LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuildOptions>); - LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>); + LLFloaterReg::add("beacons", "floater_beacons.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBeacons>); + LLFloaterReg::add("bulk_perms", "floater_bulk_perms.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBulkPermission>); + LLFloaterReg::add("buy_currency", "floater_buy_currency.xml", &LLFloaterBuyCurrency::buildFloater); + LLFloaterReg::add("buy_currency_html", "floater_buy_currency_html.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyCurrencyHTML>); + LLFloaterReg::add("buy_land", "floater_buy_land.xml", &LLFloaterBuyLand::buildFloater); + LLFloaterReg::add("buy_object", "floater_buy_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuy>); + LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyContents>); + LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTools>); + LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuildOptions>); + LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>); - LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>); - LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>); - LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater); - LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>); - LLFloaterReg::add("conversation", "floater_conversation_log.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationLog>); + LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>); + LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>); + LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater); + LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>); + LLFloaterReg::add("conversation", "floater_conversation_log.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationLog>); - LLFloaterReg::add("delete_pref_preset", "floater_delete_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeletePrefPreset>); - LLFloaterReg::add("destinations", "floater_destinations.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDestinations>); + LLFloaterReg::add("delete_pref_preset", "floater_delete_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeletePrefPreset>); + LLFloaterReg::add("destinations", "floater_destinations.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDestinations>); - LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostProcess>); - LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEnvironmentSettings>); - LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteEnvPreset>); - LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditSky>); - LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>); - LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>); + LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostProcess>); + LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEnvironmentSettings>); + LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteEnvPreset>); + LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditSky>); + LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>); + LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>); LLFloaterReg::add("event", "floater_event.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEvent>); LLFloaterReg::add("experiences", "floater_experiences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiences>); - LLFloaterReg::add("experience_profile", "floater_experienceprofile.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperienceProfile>); - LLFloaterReg::add("experience_search", "floater_experience_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiencePicker>); + LLFloaterReg::add("experience_profile", "floater_experienceprofile.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperienceProfile>); + LLFloaterReg::add("experience_search", "floater_experience_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiencePicker>); - LLFloaterReg::add("font_test", "floater_font_test.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFontTest>); + LLFloaterReg::add("font_test", "floater_font_test.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFontTest>); - LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGesture>); - LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGodTools>); - LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGridStatus>); - LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGroupPicker>); + LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGesture>); + LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGodTools>); + LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGridStatus>); + LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGroupPicker>); - LLFloaterReg::add("help_browser", "floater_help_browser.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHelpBrowser>); - LLFloaterReg::add("edit_hover_height", "floater_edit_hover_height.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHoverHeight>); - LLFloaterReg::add("hud", "floater_hud.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHUD>); + LLFloaterReg::add("help_browser", "floater_help_browser.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHelpBrowser>); + LLFloaterReg::add("edit_hover_height", "floater_edit_hover_height.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHoverHeight>); + LLFloaterReg::add("hud", "floater_hud.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHUD>); - LLFloaterReg::add("impanel", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMSession>); - LLFloaterReg::add("im_container", "floater_im_container.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMContainer>); - LLFloaterReg::add("im_well_window", "floater_sys_well.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMWellWindow>); - LLFloaterReg::add("incoming_call", "floater_incoming_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>); - LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); - LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>); - LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>); - LLInspectAvatarUtil::registerFloater(); - LLInspectGroupUtil::registerFloater(); - LLInspectObjectUtil::registerFloater(); - LLInspectRemoteObjectUtil::registerFloater(); - LLFloaterVoiceVolumeUtil::registerFloater(); - LLNotificationsUI::registerFloater(); - - LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>); - LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>); - LLFloaterReg::add("linkreplace", "floater_linkreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLinkReplace>); - LLFloaterReg::add("load_pref_preset", "floater_load_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLoadPrefPreset>); - - LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>); + LLFloaterReg::add("impanel", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMSession>); + LLFloaterReg::add("im_container", "floater_im_container.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMContainer>); + LLFloaterReg::add("im_well_window", "floater_sys_well.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMWellWindow>); + LLFloaterReg::add("incoming_call", "floater_incoming_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>); + LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); + LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>); + LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>); + LLInspectAvatarUtil::registerFloater(); + LLInspectGroupUtil::registerFloater(); + LLInspectObjectUtil::registerFloater(); + LLInspectRemoteObjectUtil::registerFloater(); + LLFloaterVoiceVolumeUtil::registerFloater(); + LLNotificationsUI::registerFloater(); + + LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>); + LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>); + LLFloaterReg::add("linkreplace", "floater_linkreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLinkReplace>); + LLFloaterReg::add("load_pref_preset", "floater_load_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLoadPrefPreset>); + + LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>); - if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled")) - { - LLFloaterReg::add("tex_fetch_debugger", "floater_texture_fetch_debugger.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTextureFetchDebugger>); - } - LLFloaterReg::add("media_settings", "floater_media_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMediaSettings>); - LLFloaterReg::add("marketplace_listings", "floater_marketplace_listings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceListings>); - LLFloaterReg::add("marketplace_validation", "floater_marketplace_validation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceValidation>); - LLFloaterReg::add("message_critical", "floater_critical.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>); - LLFloaterReg::add("message_tos", "floater_tos.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>); - LLFloaterReg::add("moveview", "floater_moveview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMove>); - LLFloaterReg::add("mute_object_by_name", "floater_mute_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGetBlockedObjectName>); - LLFloaterReg::add("mini_map", "floater_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMap>); + if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled")) + { + LLFloaterReg::add("tex_fetch_debugger", "floater_texture_fetch_debugger.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTextureFetchDebugger>); + } + LLFloaterReg::add("media_settings", "floater_media_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMediaSettings>); + LLFloaterReg::add("marketplace_listings", "floater_marketplace_listings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceListings>); + LLFloaterReg::add("marketplace_validation", "floater_marketplace_validation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceValidation>); + LLFloaterReg::add("message_critical", "floater_critical.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>); + LLFloaterReg::add("message_tos", "floater_tos.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>); + LLFloaterReg::add("moveview", "floater_moveview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMove>); + LLFloaterReg::add("mute_object_by_name", "floater_mute_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGetBlockedObjectName>); + LLFloaterReg::add("mini_map", "floater_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMap>); - LLFloaterReg::add("notifications_console", "floater_notifications_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationConsole>); - - LLFloaterReg::add("notification_well_window", "floater_notifications_tabbed.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationsTabbed>); + LLFloaterReg::add("notifications_console", "floater_notifications_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationConsole>); + + LLFloaterReg::add("notification_well_window", "floater_notifications_tabbed.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationsTabbed>); - LLFloaterReg::add("object_weights", "floater_object_weights.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterObjectWeights>); - LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOpenObject>); - LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLOutgoingCallDialog>); - LLFloaterReg::add("outfit_photo_preview", "floater_outfit_photo_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitPhotoPreview>); - LLFloaterPayUtil::registerFloater(); + LLFloaterReg::add("object_weights", "floater_object_weights.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterObjectWeights>); + LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOpenObject>); + LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLOutgoingCallDialog>); + LLFloaterReg::add("outfit_photo_preview", "floater_outfit_photo_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitPhotoPreview>); + LLFloaterPayUtil::registerFloater(); - LLFloaterReg::add("pathfinding_characters", "floater_pathfinding_characters.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingCharacters>); - LLFloaterReg::add("pathfinding_linksets", "floater_pathfinding_linksets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingLinksets>); - LLFloaterReg::add("pathfinding_console", "floater_pathfinding_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingConsole>); - LLFloaterReg::add("people", "floater_people.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); - LLFloaterReg::add("perms_default", "floater_perms_default.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPermsDefault>); - LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); - LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>); - LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceGraphicsAdvanced>); - LLFloaterReg::add("prefs_view_advanced", "floater_preferences_view_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceViewAdvanced>); - LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>); - LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerImport>); - LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>); - LLFloaterReg::add("prefs_spellchecker", "floater_spellcheck.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerSettings>); - LLFloaterReg::add("prefs_autoreplace", "floater_autoreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAutoReplaceSettings>); - LLFloaterReg::add("picks", "floater_picks.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); - LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterJoystick>); - LLFloaterReg::add("preview_anim", "floater_preview_animation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewAnim>, "preview"); - LLFloaterReg::add("preview_conversation", "floater_conversation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationPreview>); - LLFloaterReg::add("preview_gesture", "floater_preview_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewGesture>, "preview"); - LLFloaterReg::add("preview_notecard", "floater_preview_notecard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewNotecard>, "preview"); - LLFloaterReg::add("preview_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewLSL>, "preview"); - LLFloaterReg::add("preview_scriptedit", "floater_live_lsleditor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLLiveLSLEditor>, "preview"); - LLFloaterReg::add("preview_sound", "floater_preview_sound.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewSound>, "preview"); - LLFloaterReg::add("preview_texture", "floater_preview_texture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewTexture>, "preview"); - LLFloaterReg::add("preview_trash", "floater_preview_trash.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreviewTrash>); - LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProperties>); - LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPublishClassifiedFloater>); - LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSavePrefPreset>); - LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptEdPrefs>); + LLFloaterReg::add("pathfinding_characters", "floater_pathfinding_characters.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingCharacters>); + LLFloaterReg::add("pathfinding_linksets", "floater_pathfinding_linksets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingLinksets>); + LLFloaterReg::add("pathfinding_console", "floater_pathfinding_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingConsole>); + LLFloaterReg::add("people", "floater_people.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); + LLFloaterReg::add("perms_default", "floater_perms_default.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPermsDefault>); + LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); + LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>); + LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceGraphicsAdvanced>); + LLFloaterReg::add("prefs_view_advanced", "floater_preferences_view_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceViewAdvanced>); + LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>); + LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerImport>); + LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>); + LLFloaterReg::add("prefs_spellchecker", "floater_spellcheck.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerSettings>); + LLFloaterReg::add("prefs_autoreplace", "floater_autoreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAutoReplaceSettings>); + LLFloaterReg::add("picks", "floater_picks.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); + LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterJoystick>); + LLFloaterReg::add("preview_anim", "floater_preview_animation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewAnim>, "preview"); + LLFloaterReg::add("preview_conversation", "floater_conversation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationPreview>); + LLFloaterReg::add("preview_gesture", "floater_preview_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewGesture>, "preview"); + LLFloaterReg::add("preview_notecard", "floater_preview_notecard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewNotecard>, "preview"); + LLFloaterReg::add("preview_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewLSL>, "preview"); + LLFloaterReg::add("preview_scriptedit", "floater_live_lsleditor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLLiveLSLEditor>, "preview"); + LLFloaterReg::add("preview_sound", "floater_preview_sound.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewSound>, "preview"); + LLFloaterReg::add("preview_texture", "floater_preview_texture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewTexture>, "preview"); + LLFloaterReg::add("preview_trash", "floater_preview_trash.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreviewTrash>); + LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProperties>); + LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPublishClassifiedFloater>); + LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSavePrefPreset>); + LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptEdPrefs>); - LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build<LLFloaterTelehub>); - LLFloaterReg::add("test_inspectors", "floater_test_inspectors.xml", &LLFloaterReg::build<LLFloaterTestInspectors>); - //LLFloaterReg::add("test_list_view", "floater_test_list_view.xml",&LLFloaterReg::build<LLFloaterTestListView>); - LLFloaterReg::add("test_textbox", "floater_test_textbox.xml", &LLFloaterReg::build<LLFloater>); - LLFloaterReg::add("test_text_editor", "floater_test_text_editor.xml", &LLFloaterReg::build<LLFloater>); - LLFloaterReg::add("test_widgets", "floater_test_widgets.xml", &LLFloaterReg::build<LLFloater>); - LLFloaterReg::add("top_objects", "floater_top_objects.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTopObjects>); - LLFloaterReg::add("toybox", "floater_toybox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterToybox>); - - LLFloaterReg::add("reporter", "floater_report_abuse.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterReporter>); - LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterResetQueue>); - LLFloaterReg::add("region_debug_console", "floater_region_debug_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionDebugConsole>); - LLFloaterReg::add("region_info", "floater_region_info.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionInfo>); - LLFloaterReg::add("region_restarting", "floater_region_restarting.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionRestarting>); - - LLFloaterReg::add("script_debug", "floater_script_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebug>); - LLFloaterReg::add("script_debug_output", "floater_script_debug_panel.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebugOutput>); - LLFloaterReg::add("script_floater", "floater_script.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLScriptFloater>); - LLFloaterReg::add("script_limits", "floater_script_limits.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptLimits>); - LLFloaterReg::add("sell_land", "floater_sell_land.xml", &LLFloaterSellLand::buildFloater); - LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSettingsDebug>); - LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundDevices>); - LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>); - LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRunQueue>); - LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSceneLoadStats>); - LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>); - LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>); + LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build<LLFloaterTelehub>); + LLFloaterReg::add("test_inspectors", "floater_test_inspectors.xml", &LLFloaterReg::build<LLFloaterTestInspectors>); + //LLFloaterReg::add("test_list_view", "floater_test_list_view.xml",&LLFloaterReg::build<LLFloaterTestListView>); + LLFloaterReg::add("test_textbox", "floater_test_textbox.xml", &LLFloaterReg::build<LLFloater>); + LLFloaterReg::add("test_text_editor", "floater_test_text_editor.xml", &LLFloaterReg::build<LLFloater>); + LLFloaterReg::add("test_widgets", "floater_test_widgets.xml", &LLFloaterReg::build<LLFloater>); + LLFloaterReg::add("top_objects", "floater_top_objects.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTopObjects>); + LLFloaterReg::add("toybox", "floater_toybox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterToybox>); + + LLFloaterReg::add("reporter", "floater_report_abuse.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterReporter>); + LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterResetQueue>); + LLFloaterReg::add("region_debug_console", "floater_region_debug_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionDebugConsole>); + LLFloaterReg::add("region_info", "floater_region_info.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionInfo>); + LLFloaterReg::add("region_restarting", "floater_region_restarting.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionRestarting>); + + LLFloaterReg::add("script_debug", "floater_script_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebug>); + LLFloaterReg::add("script_debug_output", "floater_script_debug_panel.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebugOutput>); + LLFloaterReg::add("script_floater", "floater_script.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLScriptFloater>); + LLFloaterReg::add("script_limits", "floater_script_limits.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptLimits>); + LLFloaterReg::add("sell_land", "floater_sell_land.xml", &LLFloaterSellLand::buildFloater); + LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSettingsDebug>); + LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundDevices>); + LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>); + LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRunQueue>); + LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSceneLoadStats>); + LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>); + LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>); LLFloaterReg::add("outfit_snapshot", "floater_outfit_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitSnapshot>); LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSearch>); - LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); - LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); - LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); + LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); + LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); + LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); - LLFloaterReg::add("fbc_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); - LLFloaterReg::add("flickr_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); - LLFloaterReg::add("twitter_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); - - LLFloaterReg::add("facebook", "floater_facebook.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFacebook>); - LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFlickr>); - LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTwitter>); - LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBigPreview>); - - LLFloaterUIPreviewUtil::registerFloater(); - LLFloaterReg::add("upload_anim_bvh", "floater_animation_bvh_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBvhPreview>, "upload"); - LLFloaterReg::add("upload_anim_anim", "floater_animation_anim_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload"); - LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload"); - LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload"); - LLFloaterReg::add("upload_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptPreview>, "upload"); - LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload"); + LLFloaterReg::add("fbc_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); + LLFloaterReg::add("flickr_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); + LLFloaterReg::add("twitter_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); + + LLFloaterReg::add("facebook", "floater_facebook.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFacebook>); + LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFlickr>); + LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTwitter>); + LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBigPreview>); + + LLFloaterUIPreviewUtil::registerFloater(); + LLFloaterReg::add("upload_anim_bvh", "floater_animation_bvh_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBvhPreview>, "upload"); + LLFloaterReg::add("upload_anim_anim", "floater_animation_anim_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload"); + LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload"); + LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload"); + LLFloaterReg::add("upload_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptPreview>, "upload"); + LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload"); - LLFloaterReg::add("voice_effect", "floater_voice_effect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceEffect>); + LLFloaterReg::add("voice_effect", "floater_voice_effect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceEffect>); - LLFloaterReg::add("web_content", "floater_web_content.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); - LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>); - LLFloaterReg::add("window_size", "floater_window_size.xml", &LLFloaterReg::build<LLFloaterWindowSize>); - LLFloaterReg::add("world_map", "floater_world_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWorldMap>); + LLFloaterReg::add("web_content", "floater_web_content.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); + LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>); + LLFloaterReg::add("window_size", "floater_window_size.xml", &LLFloaterReg::build<LLFloaterWindowSize>); + LLFloaterReg::add("world_map", "floater_world_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWorldMap>); - // *NOTE: Please keep these alphabetized for easier merges - - LLFloaterReg::registerControlVariables(); // Make sure visibility and rect controls get preserved when saving + // *NOTE: Please keep these alphabetized for easier merges + + LLFloaterReg::registerControlVariables(); // Make sure visibility and rect controls get preserved when saving } |