diff options
Diffstat (limited to 'indra/llui')
95 files changed, 1301 insertions, 736 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 34a08603fa..b3864b3711 100755 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -61,7 +61,6 @@ set(llui_SOURCE_FILES llfolderview.cpp llfolderviewitem.cpp llfolderviewmodel.cpp - llfunctorregistry.cpp lliconctrl.cpp llkeywords.cpp lllayoutstack.cpp @@ -143,6 +142,7 @@ set(llui_HEADER_FILES llbutton.h llcallbackmap.h llchatentry.h + llchat.h llcheckboxctrl.h llclipboard.h llcombobox.h @@ -282,7 +282,9 @@ if(LL_TESTS) include(LLAddBuildTest) SET(llui_TEST_SOURCE_FILES llurlmatch.cpp - llurlentry.cpp ) LL_ADD_PROJECT_UNIT_TESTS(llui "${llui_TEST_SOURCE_FILES}") + # INTEGRATION TESTS + set(test_libs llui llmessage llcommon ${LLCOMMON_LIBRARIES} ${WINDOWS_LIBRARIES}) + LL_ADD_INTEGRATION_TEST(llurlentry llurlentry.cpp "${test_libs}") endif(LL_TESTS) diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index d636161baf..b787794b95 100755 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -69,7 +69,7 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params) mSingleExpansion = params.single_expansion; if(mFitParent && !mSingleExpansion) { - llinfos << "fit_parent works best when combined with single_expansion" << llendl; + LL_INFOS() << "fit_parent works best when combined with single_expansion" << LL_ENDL; } } @@ -845,7 +845,7 @@ void LLAccordionCtrl::sort() { if (!mTabComparator) { - llwarns << "No comparator specified for sorting accordion tabs." << llendl; + LL_WARNS() << "No comparator specified for sorting accordion tabs." << LL_ENDL; return; } diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index 43462bd244..53720a6044 100755 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -444,9 +444,9 @@ void LLAccordionCtrlTab::changeOpenClose(bool is_open) } } -void LLAccordionCtrlTab::handleVisibilityChange(BOOL new_visibility) +void LLAccordionCtrlTab::onVisibilityChange(BOOL new_visibility) { - LLUICtrl::handleVisibilityChange(new_visibility); + LLUICtrl::onVisibilityChange(new_visibility); notifyParent(LLSD().with("child_visibility_change", new_visibility)); } diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h index dddaa581e6..7a78700e0f 100755 --- a/indra/llui/llaccordionctrltab.h +++ b/indra/llui/llaccordionctrltab.h @@ -158,7 +158,7 @@ public: /** * Raises notifyParent event with "child_visibility_change" = new_visibility */ - void handleVisibilityChange(BOOL new_visibility); + void onVisibilityChange(BOOL new_visibility); // Changes expand/collapse state and triggers expand/collapse callbacks virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index 8ede4e3468..30cb18812b 100755 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -105,7 +105,7 @@ LLBadge::LLBadge(const LLBadge::Params& p) { if (mImage.isNull()) { - llwarns << "Badge: " << getName() << " with no image!" << llendl; + LL_WARNS() << "Badge: " << getName() << " with no image!" << LL_ENDL; } if (p.location_offset_hcenter.isProvided()) @@ -335,7 +335,7 @@ void LLBadge::draw() } else { - lldebugs << "No image for badge " << getName() << " on owner " << owner_view->getName() << llendl; + LL_DEBUGS() << "No image for badge " << getName() << " on owner " << owner_view->getName() << LL_ENDL; renderBadgeBackground(badge_center_x, badge_center_y, badge_width, badge_height, diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index a8149a9a1d..913793803c 100755 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -252,7 +252,7 @@ LLButton::LLButton(const LLButton::Params& p) if (mImageUnselected.isNull()) { - llwarns << "Button: " << getName() << " with no image!" << llendl; + LL_WARNS() << "Button: " << getName() << " with no image!" << LL_ENDL; } if (p.click_callback.isProvided()) @@ -591,7 +591,7 @@ BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) // We only handle the click if the click both started and ended within us getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << LL_ENDL; } return TRUE; } @@ -779,11 +779,11 @@ void LLButton::draw() { mCurGlowStrength = lerp(mCurGlowStrength, mFlashing ? (mFlashingTimer->isCurrentlyHighlighted() || !mFlashingTimer->isFlashingInProgress() || mNeedsHighlight? 1.0 : 0.0) : mHoverGlowStrength, - LLCriticalDamp::getInterpolant(0.05f)); + LLSmoothInterpolation::getInterpolant(0.05f)); } else { - mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f)); + mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLSmoothInterpolation::getInterpolant(0.05f)); } // Draw button image, if available. @@ -816,7 +816,7 @@ void LLButton::draw() else { // no image - lldebugs << "No image for button " << getName() << llendl; + LL_DEBUGS() << "No image for button " << getName() << LL_ENDL; // draw it in pink so we can find it gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1 % alpha, FALSE); } @@ -1039,7 +1039,7 @@ void LLButton::setImageUnselected(LLPointer<LLUIImage> image) mImageUnselected = image; if (mImageUnselected.isNull()) { - llwarns << "Setting default button image for: " << getName() << " to NULL" << llendl; + LL_WARNS() << "Setting default button image for: " << getName() << " to NULL" << LL_ENDL; } } diff --git a/indra/llui/llchat.h b/indra/llui/llchat.h new file mode 100755 index 0000000000..f5b242fdfc --- /dev/null +++ b/indra/llui/llchat.h @@ -0,0 +1,109 @@ +/** + * @file llchat.h + * @author James Cook + * @brief Chat constants and data structures. + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLCHAT_H +#define LL_LLCHAT_H + +#include "lluuid.h" +#include "v3math.h" + +// enumerations used by the chat system +typedef enum e_chat_source_type +{ + CHAT_SOURCE_SYSTEM = 0, + CHAT_SOURCE_AGENT = 1, + CHAT_SOURCE_OBJECT = 2, + CHAT_SOURCE_UNKNOWN = 3 +} EChatSourceType; + +typedef enum e_chat_type +{ + CHAT_TYPE_WHISPER = 0, + CHAT_TYPE_NORMAL = 1, + CHAT_TYPE_SHOUT = 2, + CHAT_TYPE_START = 4, + CHAT_TYPE_STOP = 5, + CHAT_TYPE_DEBUG_MSG = 6, + CHAT_TYPE_REGION = 7, + CHAT_TYPE_OWNER = 8, + CHAT_TYPE_DIRECT = 9 // From llRegionSayTo() +} EChatType; + +typedef enum e_chat_audible_level +{ + CHAT_AUDIBLE_NOT = -1, + CHAT_AUDIBLE_BARELY = 0, + CHAT_AUDIBLE_FULLY = 1 +} EChatAudible; + +typedef enum e_chat_style +{ + CHAT_STYLE_NORMAL, + CHAT_STYLE_IRC, + CHAT_STYLE_HISTORY +}EChatStyle; + +// A piece of chat +class LLChat +{ +public: + LLChat(const std::string& text = std::string()) + : mText(text), + mFromName(), + mFromID(), + mNotifId(), + mOwnerID(), + mSourceType(CHAT_SOURCE_AGENT), + mChatType(CHAT_TYPE_NORMAL), + mAudible(CHAT_AUDIBLE_FULLY), + mMuted(FALSE), + mTime(0.0), + mTimeStr(), + mPosAgent(), + mURL(), + mChatStyle(CHAT_STYLE_NORMAL), + mSessionID() + { } + + std::string mText; // UTF-8 line of text + std::string mFromName; // agent or object name + LLUUID mFromID; // agent id or object id + LLUUID mNotifId; + LLUUID mOwnerID; + EChatSourceType mSourceType; + EChatType mChatType; + EChatAudible mAudible; + BOOL mMuted; // pass muted chat to maintain list of chatters + F64 mTime; // viewer only, seconds from viewer start + std::string mTimeStr; + LLVector3 mPosAgent; + std::string mURL; + EChatStyle mChatStyle; + LLUUID mSessionID; +}; + +#endif diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 14173fdbb0..1d18cb2bb0 100755 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -88,6 +88,7 @@ bool LLClipboard::pasteFromClipboard(std::vector<LLUUID>& inv_objects) const { bool res = false; S32 count = mObjects.size(); + inv_objects.reserve(inv_objects.size() + count); if (count > 0) { res = true; diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index fd2e7610df..58d80e2687 100755 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -31,7 +31,6 @@ #include "llstring.h" #include "lluuid.h" -#include "stdenums.h" #include "llsingleton.h" #include "llassettype.h" #include "llinventory.h" diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 625fb8e870..74ef8dd0c3 100755 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -137,7 +137,7 @@ void LLCommandManager::addCommand(LLCommand * command) mCommandIndices[command_id.uuid()] = mCommands.size(); mCommands.push_back(command); - lldebugs << "Successfully added command: " << command->name() << llendl; + LL_DEBUGS() << "Successfully added command: " << command->name() << LL_ENDL; } //static @@ -153,13 +153,13 @@ bool LLCommandManager::load() if (!parser.readXUI(commands_file, commandsParams)) { - llerrs << "Unable to load xml file: " << commands_file << llendl; + LL_ERRS() << "Unable to load xml file: " << commands_file << LL_ENDL; return false; } if (!commandsParams.validateBlock()) { - llerrs << "Invalid commands file: " << commands_file << llendl; + LL_ERRS() << "Invalid commands file: " << commands_file << LL_ENDL; return false; } diff --git a/indra/llui/llcontainerview.cpp b/indra/llui/llcontainerview.cpp index e08ccb0b78..727fbe850e 100755 --- a/indra/llui/llcontainerview.cpp +++ b/indra/llui/llcontainerview.cpp @@ -49,7 +49,6 @@ LLContainerView::LLContainerView(const LLContainerView::Params& p) mLabel(p.label), mDisplayChildren(p.display_children) { - mCollapsible = TRUE; mScrollContainer = NULL; } @@ -75,6 +74,11 @@ bool LLContainerView::addChild(LLView* child, S32 tab_group) return res; } +BOOL LLContainerView::handleDoubleClick(S32 x, S32 y, MASK mask) +{ + return handleMouseDown(x, y, mask); +} + BOOL LLContainerView::handleMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; @@ -84,7 +88,7 @@ BOOL LLContainerView::handleMouseDown(S32 x, S32 y, MASK mask) } if (!handled) { - if( mCollapsible && mShowLabel && (y >= getRect().getHeight() - 10) ) + if( mShowLabel && (y >= getRect().getHeight() - 10) ) { setDisplayChildren(!mDisplayChildren); reshape(getRect().getWidth(), getRect().getHeight(), FALSE); @@ -163,7 +167,7 @@ void LLContainerView::arrange(S32 width, S32 height, BOOL called_from_parent) //LLView *childp; // These will be used for the children - left = 4; + left = 10; top = getRect().getHeight() - 4; right = width - 2; bottom = top; @@ -184,7 +188,7 @@ void LLContainerView::arrange(S32 width, S32 height, BOOL called_from_parent) LLView *childp = *child_iter; if (!childp->getVisible()) { - llwarns << "Incorrect visibility!" << llendl; + LL_WARNS() << "Incorrect visibility!" << LL_ENDL; } LLRect child_rect = childp->getRequiredRect(); child_height += child_rect.getHeight(); diff --git a/indra/llui/llcontainerview.h b/indra/llui/llcontainerview.h index e81600fd6c..ac92b19977 100755 --- a/indra/llui/llcontainerview.h +++ b/indra/llui/llcontainerview.h @@ -66,6 +66,7 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ bool addChild(LLView* view, S32 tab_group = 0); + /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -87,8 +88,5 @@ public: protected: BOOL mDisplayChildren; std::string mLabel; -public: - BOOL mCollapsible; - }; #endif // LL_CONTAINERVIEW_ diff --git a/indra/llui/llctrlselectioninterface.h b/indra/llui/llctrlselectioninterface.h index 2cdcbd88fe..a7b089c8f9 100755 --- a/indra/llui/llctrlselectioninterface.h +++ b/indra/llui/llctrlselectioninterface.h @@ -28,8 +28,8 @@ #define LLCTRLSELECTIONINTERFACE_H #include "stdtypes.h" -#include "stdenums.h" #include "llstring.h" +#include "llui.h" class LLSD; class LLUUID; diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index 5f69c6af31..b7f67f8556 100755 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -365,13 +365,13 @@ BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask) mDragLastScreenY += delta_y; getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" <<llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (active)" <<LL_ENDL; handled = TRUE; } else { getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (inactive)" << LL_ENDL; handled = TRUE; } diff --git a/indra/llui/llflashtimer.h b/indra/llui/llflashtimer.h index c60f99a8ea..db8d49f009 100755 --- a/indra/llui/llflashtimer.h +++ b/indra/llui/llflashtimer.h @@ -28,6 +28,7 @@ #define LL_FLASHTIMER_H #include "lleventtimer.h" +#include "boost/function.hpp" class LLFlashTimer : public LLEventTimer { diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 97a52fada4..299f5e42d4 100755 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -347,7 +347,7 @@ void LLFlatListView::sort() { if (!mItemComparator) { - llwarns << "No comparator specified for sorting FlatListView items." << llendl; + LL_WARNS() << "No comparator specified for sorting FlatListView items." << LL_ENDL; return; } @@ -520,7 +520,7 @@ void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask) if (!item_pair->first) { - llwarning("Attempt to selet an item pair containing null panel item", 0); + LL_WARNS() << "Attempt to selet an item pair containing null panel item" << LL_ENDL; return; } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 09e27a264a..7d0779d88d 100755 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -133,7 +133,7 @@ bool LLFloater::KeyCompare::compare(const LLSD& a, const LLSD& b) { if (a.type() != b.type()) { - //llerrs << "Mismatched LLSD types: (" << a << ") mismatches (" << b << ")" << llendl; + //LL_ERRS() << "Mismatched LLSD types: (" << a << ") mismatches (" << b << ")" << LL_ENDL; return false; } else if (a.isUndefined()) @@ -598,7 +598,7 @@ LLControlGroup* LLFloater::getControlGroup() void LLFloater::setVisible( BOOL visible ) { - LLPanel::setVisible(visible); // calls handleVisibilityChange() + LLPanel::setVisible(visible); // calls onVisibilityChange() if( visible && mFirstLook ) { mFirstLook = FALSE; @@ -641,21 +641,21 @@ void LLFloater::setIsSingleInstance(BOOL is_single_instance) // virtual -void LLFloater::handleVisibilityChange ( BOOL new_visibility ) +void LLFloater::onVisibilityChange ( BOOL new_visibility ) { if (new_visibility) { if (getHost()) getHost()->setFloaterFlashing(this, FALSE); } - LLPanel::handleVisibilityChange ( new_visibility ); + LLPanel::onVisibilityChange ( new_visibility ); } void LLFloater::openFloater(const LLSD& key) { - llinfos << "Opening floater " << getName() << llendl; + LL_INFOS() << "Opening floater " << getName() << LL_ENDL; mKey = key; // in case we need to open ourselves again - + if (getSoundFlags() != SILENT // don't play open sound for hosted (tabbed) windows && !getHost() @@ -706,7 +706,7 @@ void LLFloater::openFloater(const LLSD& key) void LLFloater::closeFloater(bool app_quitting) { - llinfos << "Closing floater " << getName() << llendl; + LL_INFOS() << "Closing floater " << getName() << LL_ENDL; if (app_quitting) { LLFloater::sQuitting = true; @@ -803,7 +803,7 @@ void LLFloater::closeFloater(bool app_quitting) } else { - setVisible(FALSE); // hide before destroying (so handleVisibilityChange() gets called) + setVisible(FALSE); // hide before destroying (so onVisibilityChange() gets called) if (!mReuseInstance) { destroy(); @@ -1102,7 +1102,7 @@ BOOL LLFloater::canSnapTo(const LLView* other_view) { if (NULL == other_view) { - llwarns << "other_view is NULL" << llendl; + LL_WARNS() << "other_view is NULL" << LL_ENDL; return FALSE; } @@ -1157,11 +1157,11 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) { setDocked( false, false); } - storeRectControl(); - mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; - LLRect screen_rect = calcScreenRect(); - mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); - } + storeRectControl(); + mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; + LLRect screen_rect = calcScreenRect(); + mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); + } // gather all snapped dependents for(handle_set_iter_t dependent_it = mDependents.begin(); @@ -3149,7 +3149,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName()); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); return TRUE; } @@ -3158,7 +3158,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str LLFastTimer _(FTM_EXTERNAL_FLOATER_LOAD); if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml)) { - llwarns << "Couldn't parse panel from: " << xml_filename << llendl; + LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL; return FALSE; } @@ -3179,9 +3179,8 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str { Params output_params(params); setupParamsForExport(output_params, parent); - Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>()); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); } // Default floater position to top-left corner of screen @@ -3240,7 +3239,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str if (!result) { - llerrs << "Failed to construct floater " << getName() << llendl; + LL_ERRS() << "Failed to construct floater " << getName() << LL_ENDL; } applyRectControl(); // If we have a saved rect control, apply it @@ -3285,20 +3284,20 @@ bool LLFloater::buildFromFile(const std::string& filename) if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { - llwarns << "Couldn't find (or parse) floater from: " << filename << llendl; + 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")) ) { - llwarns << "Root node should be named floater in: " << filename << llendl; + LL_WARNS() << "Root node should be named floater in: " << filename << LL_ENDL; return false; } bool res = true; - lldebugs << "Building floater " << filename << llendl; + LL_DEBUGS() << "Building floater " << filename << LL_ENDL; LLUICtrlFactory::instance().pushFileName(filename); { if (!getFactoryMap().empty()) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 4dba1e645f..ad0b800f1c 100755 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -302,7 +302,7 @@ public: virtual BOOL canClose() { return TRUE; } /*virtual*/ void setVisible(BOOL visible); // do not override - /*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); // do not override + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); // do not override void setFrontmost(BOOL take_focus = TRUE); virtual void setVisibleAndFrontmost(BOOL take_focus=TRUE, const LLSD& key = LLSD()); diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 1cdddf0d5b..072addfa4a 100755 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -151,13 +151,13 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) res = build_func(key); if (!res) { - llwarns << "Failed to build floater type: '" << name << "'." << llendl; + LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; return NULL; } bool success = res->buildFromFile(xui_file); if (!success) { - llwarns << "Failed to build floater type: '" << name << "'." << llendl; + LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; return NULL; } @@ -179,7 +179,7 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) } if (!res) { - llwarns << "Floater type: '" << name << "' not registered." << llendl; + LL_WARNS() << "Floater type: '" << name << "' not registered." << LL_ENDL; } } return res; @@ -475,7 +475,7 @@ void LLFloaterReg::toggleInstanceOrBringToFront(const LLSD& sdname, const LLSD& if (!instance) { - lldebugs << "Unable to get instance of floater '" << name << "'" << llendl; + LL_DEBUGS() << "Unable to get instance of floater '" << name << "'" << LL_ENDL; return; } diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index a1e1f8a988..e3b17dcb4f 100755 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -30,6 +30,7 @@ #include "llrect.h" #include "llsd.h" +#include <list> #include <boost/function.hpp> //******************************************************* diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index 724d190307..c1fe70bc26 100755 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -358,11 +358,11 @@ void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor ) { if (new_captor) { - llinfos << "New mouse captor: " << new_captor->getName() << llendl; + LL_INFOS() << "New mouse captor: " << new_captor->getName() << LL_ENDL; } else { - llinfos << "New mouse captor: NULL" << llendl; + LL_INFOS() << "New mouse captor: NULL" << LL_ENDL; } } diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp index 8aa1eb7cd5..5628baa4a1 100755 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -255,8 +255,6 @@ LLFolderView::~LLFolderView( void ) mRenamer = NULL; mStatusTextBox = NULL; - mAutoOpenItems.removeAllNodes(); - if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die(); mAutoOpenItems.removeAllNodes(); @@ -736,7 +734,7 @@ void LLFolderView::removeSelectedItems() } else { - llinfos << "Cannot delete " << item->getName() << llendl; + LL_INFOS() << "Cannot delete " << item->getName() << LL_ENDL; return; } } @@ -762,20 +760,21 @@ void LLFolderView::removeSelectedItems() } else if (count > 1) { - LLDynamicArray<LLFolderViewModelItem*> listeners; + std::vector<LLFolderViewModelItem*> listeners; LLFolderViewModelItem* listener; setSelection(item_to_select, item_to_select ? item_to_select->isOpen() : false, mParentPanel->hasFocus()); + listeners.reserve(count); for(S32 i = 0; i < count; ++i) { listener = items[i]->getViewModelItem(); - if(listener && (listeners.find(listener) == LLDynamicArray<LLFolderViewModelItem*>::FAIL)) + if(listener && (std::find(listeners.begin(), listeners.end(), listener) == listeners.end())) { - listeners.put(listener); + listeners.push_back(listener); } } - listener = static_cast<LLFolderViewModelItem*>(listeners.get(0)); + listener = static_cast<LLFolderViewModelItem*>(listeners.at(0)); if(listener) { listener->removeBatch(listeners); @@ -1282,7 +1281,7 @@ BOOL LLFolderView::handleUnicodeCharHere(llwchar uni_char) if (uni_char > 0x7f) { - llwarns << "LLFolderView::handleUnicodeCharHere - Don't handle non-ascii yet, aborting" << llendl; + LL_WARNS() << "LLFolderView::handleUnicodeCharHere - Don't handle non-ascii yet, aborting" << LL_ENDL; return FALSE; } @@ -1744,14 +1743,14 @@ void LLFolderView::update() void LLFolderView::dumpSelectionInformation() { - llinfos << "LLFolderView::dumpSelectionInformation()" << llendl; - llinfos << "****************************************" << llendl; + LL_INFOS() << "LLFolderView::dumpSelectionInformation()" << LL_NEWLINE + << "****************************************" << LL_ENDL; selected_items_t::iterator item_it; for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it) { - llinfos << " " << (*item_it)->getName() << llendl; + LL_INFOS() << " " << (*item_it)->getName() << LL_ENDL; } - llinfos << "****************************************" << llendl; + LL_INFOS() << "****************************************" << LL_ENDL; } void LLFolderView::updateRenamerPosition() diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h index 11fccdace4..652e22c7bc 100755 --- a/indra/llui/llfolderview.h +++ b/indra/llui/llfolderview.h @@ -39,7 +39,6 @@ #include "lluictrl.h" #include "v4color.h" -#include "stdenums.h" #include "lldepthstack.h" #include "lleditmenuhandler.h" #include "llfontgl.h" diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index fdb4108afb..92504ba8c2 100755..100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -489,7 +489,7 @@ BOOL LLFolderViewItem::handleMouseDown( S32 x, S32 y, MASK mask ) // No handler needed for focus lost since this class has no // state that depends on it. gFocusMgr.setMouseCapture( this ); - + if (!mIsSelected) { if(mask & MASK_CONTROL) @@ -636,7 +636,7 @@ BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, } if (handled) { - lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLFolderViewItem" << llendl; + LL_DEBUGS("UserInput") << "dragAndDrop handled by LLFolderViewItem" << LL_ENDL; } return handled; @@ -706,7 +706,7 @@ void LLFolderViewItem::drawHighlight(const BOOL showContent, const BOOL hasKeybo bg_color.mV[VALPHA] = clamp_rescale(fade_time, 0.f, 0.4f, 0.f, bg_color.mV[VALPHA]); } gl_rect_2d(FOCUS_LEFT, - focus_top, + focus_top, getRect().getWidth() - 2, focus_bottom, bg_color, hasKeyboardFocus); @@ -860,7 +860,7 @@ void LLFolderViewItem::draw() LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &right_x, FALSE ); } - + //--------------------------------------------------------------------------------// // Highlight string match // @@ -882,7 +882,7 @@ const LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) c { return getRoot()->getFolderViewModel(); } - + LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) { return getRoot()->getFolderViewModel(); @@ -919,11 +919,11 @@ void LLFolderViewFolder::updateLabelRotation() } else if (isOpen()) { - mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(0.04f)); + mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLSmoothInterpolation::getInterpolant(0.04f)); } else { - mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(0.025f)); + mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLSmoothInterpolation::getInterpolant(0.025f)); } } @@ -1056,7 +1056,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height ) // animate current height towards target height if (llabs(mCurHeight - mTargetHeight) > 1.f) { - mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(isOpen() ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT)); + mCurHeight = lerp(mCurHeight, mTargetHeight, LLSmoothInterpolation::getInterpolant(isOpen() ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT)); requestArrange(); @@ -1577,7 +1577,7 @@ void LLFolderViewFolder::addItem(LLFolderViewItem* item) item->setVisible(FALSE); addChild(item); - + // When the model is already hooked into a hierarchy (i.e. has a parent), do not reparent it // Note: this happens when models are created before views or shared between views if (!item->getViewModelItem()->hasParent()) @@ -1753,7 +1753,7 @@ BOOL LLFolderViewFolder::handleDragAndDrop(S32 x, S32 y, MASK mask, { handleDragAndDropToThisFolder(mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLFolderViewFolder" << llendl; + LL_DEBUGS("UserInput") << "dragAndDrop handled by LLFolderViewFolder" << LL_ENDL; } return TRUE; diff --git a/indra/llui/llfunctorregistry.cpp b/indra/llui/llfunctorregistry.cpp deleted file mode 100755 index 8003324973..0000000000 --- a/indra/llui/llfunctorregistry.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file llfunctorregistry.cpp - * @author Kent Quirk - * @brief Maintains a registry of named callback functors taking a single LLSD parameter - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - **/ - -#include "linden_common.h" -#include "llfunctorregistry.h" - -// This is a default functor always resident in the system. -// It's used whenever a functor isn't found in the registry, so that -// we at least log the data relating to the user response. diff --git a/indra/llui/llfunctorregistry.h b/indra/llui/llfunctorregistry.h index beac212441..f5364f4863 100755 --- a/indra/llui/llfunctorregistry.h +++ b/indra/llui/llfunctorregistry.h @@ -75,7 +75,7 @@ public: } else { - llerrs << "attempt to store duplicate name '" << name << "' in LLFunctorRegistry. NOT ADDED." << llendl; + LL_ERRS() << "attempt to store duplicate name '" << name << "' in LLFunctorRegistry. NOT ADDED." << LL_ENDL; retval = false; } @@ -86,7 +86,7 @@ public: { if (mMap.count(name) == 0) { - llwarns << "trying to remove '" << name << "' from LLFunctorRegistry but it's not there." << llendl; + LL_WARNS() << "trying to remove '" << name << "' from LLFunctorRegistry but it's not there." << LL_ENDL; return false; } mMap.erase(name); @@ -101,7 +101,7 @@ public: } else { - lldebugs << "tried to find '" << name << "' in LLFunctorRegistry, but it wasn't there." << llendl; + LL_DEBUGS() << "tried to find '" << name << "' in LLFunctorRegistry, but it wasn't there." << LL_ENDL; return mMap[LOGFUNCTOR]; } } @@ -113,7 +113,7 @@ private: static void log_functor(const LLSD& notification, const LLSD& payload) { - lldebugs << "log_functor called with payload: " << payload << llendl; + LL_DEBUGS() << "log_functor called with payload: " << payload << LL_ENDL; } static void do_nothing(const LLSD& notification, const LLSD& payload) diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index efa0925a4a..a19bb99d9d 100755 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -31,7 +31,6 @@ #include "v4color.h" #include "lluictrl.h" #include "lluiimage.h" -#include "stdenums.h" class LLTextBox; class LLUICtrlFactory; diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 795dacdbb0..0d232cc2cf 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -94,7 +94,7 @@ BOOL LLKeywords::loadFromFile( const std::string& filename ) file.open(filename); /* Flawfinder: ignore */ if( file.fail() ) { - llinfos << "LLKeywords::loadFromFile() Unable to open file: " << filename << llendl; + LL_INFOS() << "LLKeywords::loadFromFile() Unable to open file: " << filename << LL_ENDL; return mLoaded; } @@ -102,7 +102,7 @@ BOOL LLKeywords::loadFromFile( const std::string& filename ) file >> buffer; if( strcmp( buffer, "llkeywords" ) ) { - llinfos << filename << " does not appear to be a keyword file" << llendl; + LL_INFOS() << filename << " does not appear to be a keyword file" << LL_ENDL; return mLoaded; } @@ -112,7 +112,7 @@ BOOL LLKeywords::loadFromFile( const std::string& filename ) file >> version_num; if( strcmp(buffer, "version") || version_num != (U32)KEYWORD_FILE_CURRENT_VERSION ) { - llinfos << filename << " does not appear to be a version " << KEYWORD_FILE_CURRENT_VERSION << " keyword file" << llendl; + LL_INFOS() << filename << " does not appear to be a version " << KEYWORD_FILE_CURRENT_VERSION << " keyword file" << LL_ENDL; return mLoaded; } @@ -342,7 +342,7 @@ LLColor3 LLKeywords::readColor( const std::string& s ) S32 values_read = sscanf(s.c_str(), "%f, %f, %f]", &r, &g, &b ); if( values_read != 3 ) { - llinfos << " poorly formed color in keyword file" << llendl; + LL_INFOS() << " poorly formed color in keyword file" << LL_ENDL; } return LLColor3( r, g, b ); } @@ -553,7 +553,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW S32 seg_start = cur - base; S32 seg_end = seg_start + seg_len; - // llinfos << "Seg: [" << word.c_str() << "]" << llendl; + // LL_INFOS() << "Seg: [" << word.c_str() << "]" << LL_ENDL; insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, defaultColor, editor); } @@ -620,10 +620,10 @@ void LLKeywords::insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSe #ifdef _DEBUG void LLKeywords::dump() { - llinfos << "LLKeywords" << llendl; + LL_INFOS() << "LLKeywords" << LL_ENDL; - llinfos << "LLKeywords::sWordTokenMap" << llendl; + LL_INFOS() << "LLKeywords::sWordTokenMap" << LL_ENDL; word_token_map_t::iterator word_token_iter = mWordTokenMap.begin(); while( word_token_iter != mWordTokenMap.end() ) { @@ -632,7 +632,7 @@ void LLKeywords::dump() ++word_token_iter; } - llinfos << "LLKeywords::sLineTokenList" << llendl; + LL_INFOS() << "LLKeywords::sLineTokenList" << LL_ENDL; for (token_list_t::iterator iter = mLineTokenList.begin(); iter != mLineTokenList.end(); ++iter) { @@ -641,7 +641,7 @@ void LLKeywords::dump() } - llinfos << "LLKeywords::sDelimiterTokenList" << llendl; + LL_INFOS() << "LLKeywords::sDelimiterTokenList" << LL_ENDL; for (token_list_t::iterator iter = mDelimiterTokenList.begin(); iter != mDelimiterTokenList.end(); ++iter) { @@ -652,12 +652,12 @@ void LLKeywords::dump() void LLKeywordToken::dump() { - llinfos << "[" << + LL_INFOS() << "[" << mColor.mV[VX] << ", " << mColor.mV[VY] << ", " << mColor.mV[VZ] << "] [" << wstring_to_utf8str(mToken) << "]" << - llendl; + LL_ENDL; } #endif // DEBUG diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index e33ac1d5c2..edb32954c6 100755 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -41,12 +41,6 @@ static const F32 MAX_FRACTIONAL_SIZE = 1.f; static LLDefaultChildRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack"); static LLLayoutStack::LayoutStackRegistry::Register<LLLayoutPanel> register_layout_panel("layout_panel"); -void LLLayoutStack::OrientationNames::declareValues() -{ - declare("horizontal", HORIZONTAL); - declare("vertical", VERTICAL); -} - // // LLLayoutPanel // @@ -140,7 +134,7 @@ S32 LLLayoutPanel::getVisibleDim() const + (((F32)mTargetDim - min_dim) * (1.f - mCollapseAmt)))); } -void LLLayoutPanel::setOrientation( LLLayoutStack::ELayoutOrientation orientation ) +void LLLayoutPanel::setOrientation( LLView::EOrientation orientation ) { mOrientation = orientation; S32 layout_dim = llround((F32)((mOrientation == LLLayoutStack::HORIZONTAL) @@ -590,7 +584,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(mOpenTimeConstant)); + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLSmoothInterpolation::getInterpolant(mOpenTimeConstant)); if (panelp->mVisibleAmt > 0.99f) { panelp->mVisibleAmt = 1.f; @@ -615,7 +609,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLSmoothInterpolation::getInterpolant(mCloseTimeConstant)); if (panelp->mVisibleAmt < 0.001f) { panelp->mVisibleAmt = 0.f; @@ -642,7 +636,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); + panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLSmoothInterpolation::getInterpolant(mCloseTimeConstant)); } if (llabs(panelp->mCollapseAmt - collapse_state) < 0.001f) diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 02c664f1a0..dbc4999678 100755 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -38,24 +38,13 @@ class LLLayoutPanel; class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack> { public: - typedef enum e_layout_orientation - { - HORIZONTAL, - VERTICAL - } ELayoutOrientation; - - struct OrientationNames - : public LLInitParam::TypeValuesHelper<ELayoutOrientation, OrientationNames> - { - static void declareValues(); - }; struct LayoutStackRegistry : public LLChildRegistry<LayoutStackRegistry> {}; struct Params : public LLInitParam::Block<Params, LLView::Params> { - Mandatory<ELayoutOrientation, OrientationNames> orientation; + Mandatory<EOrientation> orientation; Optional<S32> border_size; Optional<bool> animate, clip; @@ -73,7 +62,7 @@ public: /*virtual*/ void draw(); /*virtual*/ void removeChild(LLView*); /*virtual*/ BOOL postBuild(); - /*virtual*/ bool addChild(LLView* child, S32 tab_groupdatefractuiona = 0); + /*virtual*/ bool addChild(LLView* child, S32 tab_group = 0); /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); @@ -105,7 +94,7 @@ private: bool animatePanels(); void createResizeBar(LLLayoutPanel* panel); - const ELayoutOrientation mOrientation; + const EOrientation mOrientation; typedef std::vector<LLLayoutPanel*> e_panel_list_t; e_panel_list_t mPanels; @@ -183,7 +172,7 @@ public: bool isCollapsed() const { return mCollapsed;} - void setOrientation(LLLayoutStack::ELayoutOrientation orientation); + void setOrientation(LLView::EOrientation orientation); void storeOriginalDim(); void setIgnoreReshape(bool ignore) { mIgnoreReshape = ignore; } @@ -202,7 +191,7 @@ protected: F32 mFractionalSize; S32 mTargetDim; bool mIgnoreReshape; - LLLayoutStack::ELayoutOrientation mOrientation; + LLView::EOrientation mOrientation; class LLResizeBar* mResizeBar; }; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 5478e85e13..d410a2de33 100755 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -785,7 +785,7 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLLineEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask) { - // llinfos << "MiddleMouseDown" << llendl; + // LL_INFOS() << "MiddleMouseDown" << LL_ENDL; setFocus( TRUE ); if( canPastePrimary() ) { @@ -855,14 +855,14 @@ BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) mKeystrokeTimer.reset(); getWindow()->setCursor(UI_CURSOR_IBEAM); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (active)" << LL_ENDL; handled = TRUE; } if( !handled ) { getWindow()->setCursor(UI_CURSOR_IBEAM); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (inactive)" << LL_ENDL; handled = TRUE; } @@ -1347,7 +1347,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) case KEY_BACKSPACE: if (!mReadOnly) { - //llinfos << "Handling backspace" << llendl; + //LL_INFOS() << "Handling backspace" << LL_ENDL; if( hasSelection() ) { deleteSelection(); @@ -2379,7 +2379,7 @@ void LLLineEditor::resetPreedit() { if (hasPreeditString()) { - llwarns << "Preedit and selection!" << llendl; + LL_WARNS() << "Preedit and selection!" << LL_ENDL; deselect(); } else @@ -2543,7 +2543,7 @@ void LLLineEditor::markAsPreedit(S32 position, S32 length) setCursor(position); if (hasPreeditString()) { - llwarns << "markAsPreedit invoked when hasPreeditString is true." << llendl; + LL_WARNS() << "markAsPreedit invoked when hasPreeditString is true." << LL_ENDL; } mPreeditWString.assign( LLWString( mText.getWString(), position, length ) ); if (length > 0) diff --git a/indra/llui/llmenubutton.cpp b/indra/llui/llmenubutton.cpp index 746ade4648..0609cd8b42 100755 --- a/indra/llui/llmenubutton.cpp +++ b/indra/llui/llmenubutton.cpp @@ -96,7 +96,7 @@ void LLMenuButton::setMenu(const std::string& menu_filename, EMenuPosition posit LLToggleableMenu* menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(menu_filename, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (!menu) { - llwarns << "Error loading menu_button menu" << llendl; + LL_WARNS() << "Error loading menu_button menu" << LL_ENDL; return; } diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index f7bf39c897..38afee9b79 100755 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -280,7 +280,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp) // warning.append("\n "); // warning.append(mLabel); - // llwarns << warning << llendl; + // LL_WARNS() << warning << LL_ENDL; // LLAlertDialog::modalAlert(warning); return FALSE; } @@ -549,13 +549,13 @@ BOOL LLMenuItemGL::setLabelArg( const std::string& key, const LLStringExplicit& return TRUE; } -void LLMenuItemGL::handleVisibilityChange(BOOL new_visibility) +void LLMenuItemGL::onVisibilityChange(BOOL new_visibility) { if (getMenu()) { getMenu()->needsArrange(); } - LLView::handleVisibilityChange(new_visibility); + LLView::onVisibilityChange(new_visibility); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1146,13 +1146,13 @@ void LLMenuItemBranchGL::updateBranchParent(LLView* parentp) } } -void LLMenuItemBranchGL::handleVisibilityChange( BOOL new_visibility ) +void LLMenuItemBranchGL::onVisibilityChange( BOOL new_visibility ) { if (new_visibility == FALSE && getBranch() && !getBranch()->getTornOff()) { getBranch()->setVisible(FALSE); } - LLMenuItemGL::handleVisibilityChange(new_visibility); + LLMenuItemGL::onVisibilityChange(new_visibility); } BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask ) @@ -1794,7 +1794,7 @@ bool LLMenuGL::addContextChild(LLView* view, S32 tab_group) { return appendMenu(menup); } - + return false; } @@ -1962,7 +1962,7 @@ bool LLMenuGL::scrollItems(EScrollingDirection direction) break; } default: - llwarns << "Unknown scrolling direction: " << direction << llendl; + LL_WARNS() << "Unknown scrolling direction: " << direction << LL_ENDL; } mNeedsArrange = TRUE; @@ -2562,8 +2562,8 @@ BOOL LLMenuGL::appendMenu( LLMenuGL* menu ) { if( menu == this ) { - llerrs << "** Attempt to attach menu to itself. This is certainly " - << "a logic error." << llendl; + LL_ERRS() << "** Attempt to attach menu to itself. This is certainly " + << "a logic error." << LL_ENDL; } BOOL success = TRUE; @@ -2591,7 +2591,7 @@ BOOL LLMenuGL::appendContextSubMenu(LLMenuGL *menu) { if (menu == this) { - llerrs << "Can't attach a context menu to itself" << llendl; + LL_ERRS() << "Can't attach a context menu to itself" << LL_ENDL; } LLContextMenuBranch *item; @@ -3114,7 +3114,7 @@ LLMenuGL* LLMenuGL::findChildMenuByName(const std::string& name, BOOL recurse) c return menup; } } - llwarns << "Child Menu " << name << " not found in menu " << getName() << llendl; + LL_WARNS() << "Child Menu " << name << " not found in menu " << getName() << LL_ENDL; return NULL; } @@ -3419,8 +3419,8 @@ BOOL LLMenuBarGL::appendMenu( LLMenuGL* menu ) { if( menu == this ) { - llerrs << "** Attempt to attach menu to itself. This is certainly " - << "a logic error." << llendl; + LL_ERRS() << "** Attempt to attach menu to itself. This is certainly " + << "a logic error." << LL_ENDL; } BOOL success = TRUE; @@ -3749,7 +3749,7 @@ void LLTearOffMenu::draw() if (getRect().getHeight() != mTargetHeight) { // animate towards target height - reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(0.05f)))); + reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLSmoothInterpolation::getInterpolant(0.05f)))); } LLFloater::draw(); } diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 51df5df1f8..feafaab199 100755 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -82,7 +82,7 @@ protected: friend class LLUICtrlFactory; public: // LLView overrides - /*virtual*/ void handleVisibilityChange(BOOL new_visibility); + /*virtual*/ void onVisibilityChange(BOOL new_visibility); /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); @@ -637,7 +637,7 @@ public: virtual void updateBranchParent( LLView* parentp ); // LLView Functionality - virtual void handleVisibilityChange( BOOL curVisibilityIn ); + virtual void onVisibilityChange( BOOL curVisibilityIn ); virtual void draw(); diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp index 8c2be44904..45505e232e 100755 --- a/indra/llui/llmodaldialog.cpp +++ b/indra/llui/llmodaldialog.cpp @@ -65,7 +65,7 @@ LLModalDialog::~LLModalDialog() std::list<LLModalDialog*>::iterator iter = std::find(sModalStack.begin(), sModalStack.end(), this); if (iter != sModalStack.end()) { - llerrs << "Attempt to delete dialog while still in sModalStack!" << llendl; + LL_ERRS() << "Attempt to delete dialog while still in sModalStack!" << LL_ENDL; } } @@ -126,7 +126,7 @@ void LLModalDialog::stopModal() } else { - llwarns << "LLModalDialog::stopModal not in list!" << llendl; + LL_WARNS() << "LLModalDialog::stopModal not in list!" << LL_ENDL; } } if (!sModalStack.empty()) @@ -181,7 +181,7 @@ BOOL LLModalDialog::handleHover(S32 x, S32 y, MASK mask) if( childrenHandleHover(x, y, mask) == NULL ) { getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << LL_ENDL; } return TRUE; } @@ -300,7 +300,7 @@ void LLModalDialog::shutdownModals() // app, we shouldn't have to care WHAT's open. Put differently, if a modal // dialog is so crucial that we can't let the user terminate until s/he // addresses it, we should reject a termination request. The current state - // of affairs is that we accept it, but then produce an llerrs popup that + // of affairs is that we accept it, but then produce an LL_ERRS() popup that // simply makes our software look unreliable. sModalStack.clear(); } diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp index 179b251cdb..48b5b08c1b 100755 --- a/indra/llui/llmultifloater.cpp +++ b/indra/llui/llmultifloater.cpp @@ -159,7 +159,7 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater, if (!mTabContainer) { - llerrs << "Tab Container used without having been initialized." << llendl; + LL_ERRS() << "Tab Container used without having been initialized." << LL_ENDL; return; } diff --git a/indra/llui/llmultifloater.h b/indra/llui/llmultifloater.h index d992212650..c1b1a357ed 100755 --- a/indra/llui/llmultifloater.h +++ b/indra/llui/llmultifloater.h @@ -100,6 +100,3 @@ private: }; #endif // LL_MULTI_FLOATER_H - - - diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 70bcfb5b4f..0aa3e17075 100755 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -301,7 +301,7 @@ bool LLMultiSlider::findUnusedValue(F32& initVal) // stop if it's filled if(initVal == mInitialValue && !firstTry) { - llwarns << "Whoa! Too many multi slider elements to add one to" << llendl; + LL_WARNS() << "Whoa! Too many multi slider elements to add one to" << LL_ENDL; return false; } @@ -356,12 +356,12 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask) onCommit(); getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (active)" << LL_ENDL; } else { getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (inactive)" << LL_ENDL; } return TRUE; } diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp index 91e5b6b9de..c460a08afc 100755 --- a/indra/llui/llmultisliderctrl.cpp +++ b/indra/llui/llmultisliderctrl.cpp @@ -450,7 +450,7 @@ void LLMultiSliderCtrl::setPrecision(S32 precision) { if (precision < 0 || precision > 10) { - llerrs << "LLMultiSliderCtrl::setPrecision - precision out of range" << llendl; + LL_ERRS() << "LLMultiSliderCtrl::setPrecision - precision out of range" << LL_ENDL; return; } diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 1789f003b9..fbeb8355db 100755 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -246,7 +246,7 @@ LLNotificationForm::LLNotificationForm(const LLSD& sd) } else { - llwarns << "Invalid form data " << sd << llendl; + LL_WARNS() << "Invalid form data " << sd << LL_ENDL; mFormData = LLSD::emptyArray(); } } @@ -438,11 +438,11 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mUniqueContext.push_back(context.value); } - lldebugs << "notification \"" << mName << "\": tag count is " << p.tags.size() << llendl; + LL_DEBUGS() << "notification \"" << mName << "\": tag count is " << p.tags.size() << LL_ENDL; BOOST_FOREACH(const LLNotificationTemplate::Tag& tag, p.tags) { - lldebugs << " tag \"" << std::string(tag.value) << "\"" << llendl; + LL_DEBUGS() << " tag \"" << std::string(tag.value) << "\"" << LL_ENDL; mTags.push_back(tag.value); } @@ -516,7 +516,7 @@ LLNotification::LLNotification(const LLSDParamAdapter<Params>& p) : LLSD LLNotification::asLLSD(bool excludeTemplateElements) -{ +{ LLParamSDParser parser; Params p; @@ -544,12 +544,12 @@ LLSD LLNotification::asLLSD(bool excludeTemplateElements) mForm->getElements(dynamicElements, templateForm->getNumElements()); p.form_elements = dynamicElements; } - + if(mResponder) { p.functor.responder_sd = mResponder->asLLSD(); } - + if(!mResponseFunctorName.empty()) { p.functor.name = mResponseFunctorName; @@ -1207,6 +1207,9 @@ LLNotifications::LLNotifications() mIgnoreAllNotifications(false) { LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Notification.Show", boost::bind(&LLNotifications::addFromCallback, this, _2)); + + // touch the instance tracker for notification channels, so that it will still be around in our destructor + LLInstanceTracker<LLNotificationChannel, std::string>::instanceCount(); } @@ -1402,7 +1405,7 @@ void LLNotifications::forceResponse(const LLNotification::Params& params, S32 op if (selected_item.isUndefined()) { - llwarns << "Invalid option" << option << " for notification " << (std::string)params.name << llendl; + LL_WARNS() << "Invalid option" << option << " for notification " << (std::string)params.name << LL_ENDL; return; } response[selected_item["name"].asString()] = true; @@ -1436,12 +1439,12 @@ void replaceSubstitutionStrings(LLXMLNodePtr node, StringMap& replacements) if (found != replacements.end()) { replacement = found->second; - lldebugs << "replaceSubstitutionStrings: value: \"" << value << "\" repl: \"" << replacement << "\"." << llendl; + LL_DEBUGS() << "replaceSubstitutionStrings: value: \"" << value << "\" repl: \"" << replacement << "\"." << LL_ENDL; it->second->setValue(replacement); } else { - llwarns << "replaceSubstitutionStrings FAILURE: could not find replacement \"" << value << "\"." << llendl; + LL_WARNS() << "replaceSubstitutionStrings FAILURE: could not find replacement \"" << value << "\"." << LL_ENDL; } } } @@ -1480,7 +1483,7 @@ void addPathIfExists(const std::string& new_path, std::vector<std::string>& path bool LLNotifications::loadTemplates() { - llinfos << "Reading notifications template" << llendl; + LL_INFOS() << "Reading notifications template" << LL_ENDL; // Passing findSkinnedFilenames(constraint=LLDir::ALL_SKINS) makes it // output all relevant pathnames instead of just the ones from the most // specific skin. @@ -1493,7 +1496,7 @@ bool LLNotifications::loadTemplates() if (!success || root.isNull() || !root->hasName( "notifications" )) { - llerrs << "Problem reading XML from UI Notifications file: " << base_filename << llendl; + LL_ERRS() << "Problem reading XML from UI Notifications file: " << base_filename << LL_ENDL; return false; } @@ -1503,7 +1506,7 @@ bool LLNotifications::loadTemplates() if(!params.validateBlock()) { - llerrs << "Problem reading XUI from UI Notifications file: " << base_filename << llendl; + LL_ERRS() << "Problem reading XUI from UI Notifications file: " << base_filename << LL_ENDL; return false; } @@ -1551,7 +1554,7 @@ bool LLNotifications::loadTemplates() mTemplates[notification.name] = LLNotificationTemplatePtr(new LLNotificationTemplate(notification)); } - llinfos << "...done" << llendl; + LL_INFOS() << "...done" << LL_ENDL; return true; } @@ -1569,7 +1572,7 @@ bool LLNotifications::loadVisibilityRules() if(!params.validateBlock()) { - llerrs << "Problem reading UI Notification Visibility Rules file: " << full_filename << llendl; + LL_ERRS() << "Problem reading UI Notification Visibility Rules file: " << full_filename << LL_ENDL; return false; } @@ -1634,7 +1637,7 @@ void LLNotifications::add(const LLNotificationPtr pNotif) LLNotificationSet::iterator it=mItems.find(pNotif); if (it != mItems.end()) { - llerrs << "Notification added a second time to the master notification channel." << llendl; + LL_ERRS() << "Notification added a second time to the master notification channel." << LL_ENDL; } updateItem(LLSD().with("sigtype", "add").with("id", pNotif->id()), pNotif); @@ -1692,7 +1695,7 @@ LLNotificationPtr LLNotifications::find(LLUUID uuid) LLNotificationSet::iterator it=mItems.find(target); if (it == mItems.end()) { - LL_DEBUGS("Notifications") << "Tried to dereference uuid '" << uuid << "' as a notification key but didn't find it." << llendl; + LL_DEBUGS("Notifications") << "Tried to dereference uuid '" << uuid << "' as a notification key but didn't find it." << LL_ENDL; return LLNotificationPtr((LLNotification*)NULL); } else @@ -1743,13 +1746,13 @@ bool LLNotifications::isVisibleByRules(LLNotificationPtr n) for(it = mVisibilityRules.begin(); it != mVisibilityRules.end(); it++) { // An empty type/tag/name string will match any notification, so only do the comparison when the string is non-empty in the rule. - lldebugs + LL_DEBUGS() << "notification \"" << n->getName() << "\" " << "testing against " << ((*it)->mVisible?"show":"hide") << " rule, " << "name = \"" << (*it)->mName << "\" " << "tag = \"" << (*it)->mTag << "\" " << "type = \"" << (*it)->mType << "\" " - << llendl; + << LL_ENDL; if(!(*it)->mType.empty()) { @@ -1788,7 +1791,7 @@ bool LLNotifications::isVisibleByRules(LLNotificationPtr n) if((*it)->mResponse.empty()) { // Response property is empty. Cancel this notification. - lldebugs << "cancelling notification " << n->getName() << llendl; + LL_DEBUGS() << "cancelling notification " << n->getName() << LL_ENDL; cancel(n); } @@ -1799,7 +1802,7 @@ bool LLNotifications::isVisibleByRules(LLNotificationPtr n) // TODO: verify that the response template has an item with the correct name response[(*it)->mResponse] = true; - lldebugs << "responding to notification " << n->getName() << " with response = " << response << llendl; + LL_DEBUGS() << "responding to notification " << n->getName() << " with response = " << response << LL_ENDL; n->respond(response); } @@ -1811,7 +1814,7 @@ bool LLNotifications::isVisibleByRules(LLNotificationPtr n) break; } - lldebugs << "allowing notification " << n->getName() << llendl; + LL_DEBUGS() << "allowing notification " << n->getName() << LL_ENDL; return true; } @@ -1872,7 +1875,7 @@ void LLPostponedNotification::onAvatarNameCache(const LLUUID& agent_id, // from PE merge - we should figure out if this is the right thing to do if (name.empty()) { - llwarns << "Empty name received for Id: " << agent_id << llendl; + LL_WARNS() << "Empty name received for Id: " << agent_id << LL_ENDL; name = SYSTEM_FROM; } diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 87573c2a56..f9089b8cc9 100755 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -92,6 +92,7 @@ #include "llevents.h" #include "llfunctorregistry.h" #include "llinitparam.h" +#include "llinstancetracker.h" #include "llmortician.h" #include "llnotificationptr.h" #include "llpointer.h" @@ -845,7 +846,7 @@ public: Iterator begin(); Iterator end(); size_t size(); - + std::string summarize(); private: @@ -1055,15 +1056,13 @@ class LLPersistentNotificationChannel : public LLNotificationChannel public: LLPersistentNotificationChannel() : LLNotificationChannel("Persistent", "Visible", ¬ificationFilter) - { - } + {} typedef std::vector<LLNotificationPtr> history_list_t; history_list_t::iterator beginHistory() { sortHistory(); return mHistory.begin(); } history_list_t::iterator endHistory() { return mHistory.end(); } private: - struct sortByTime { S32 operator ()(const LLNotificationPtr& a, const LLNotificationPtr& b) @@ -1077,7 +1076,6 @@ private: std::sort(mHistory.begin(), mHistory.end(), sortByTime()); } - // The channel gets all persistent notifications except those that have been canceled static bool notificationFilter(LLNotificationPtr pNotification) { diff --git a/indra/llui/llnotificationsutil.h b/indra/llui/llnotificationsutil.h index 4093324d0c..9f29087b4a 100755 --- a/indra/llui/llnotificationsutil.h +++ b/indra/llui/llnotificationsutil.h @@ -30,6 +30,7 @@ // to avoid including the heavyweight llnotifications.h #include "llnotificationptr.h" +#include "lluuid.h" #include <boost/function.hpp> diff --git a/indra/llui/llnotificationtemplate.h b/indra/llui/llnotificationtemplate.h index 18a82190b5..0315ddbea8 100755 --- a/indra/llui/llnotificationtemplate.h +++ b/indra/llui/llnotificationtemplate.h @@ -28,32 +28,9 @@ #ifndef LL_LLNOTIFICATION_TEMPLATE_H #define LL_LLNOTIFICATION_TEMPLATE_H -//#include <string> -//#include <list> -//#include <vector> -//#include <map> -//#include <set> -//#include <iomanip> -//#include <sstream> -// -//#include <boost/utility.hpp> -//#include <boost/shared_ptr.hpp> -//#include <boost/enable_shared_from_this.hpp> -//#include <boost/type_traits.hpp> -// -//// we want to minimize external dependencies, but this one is important -//#include "llsd.h" -// -//// and we need this to manage the notification callbacks -//#include "llevents.h" -//#include "llfunctorregistry.h" -//#include "llpointer.h" #include "llinitparam.h" -//#include "llnotificationptr.h" -//#include "llcachename.h" #include "llnotifications.h" - typedef boost::shared_ptr<LLNotificationForm> LLNotificationFormPtr; // This is the class of object read from the XML file (notifications.xml, diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 67472ad166..389d18a350 100755 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -342,9 +342,9 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask ) return handled; } -void LLPanel::handleVisibilityChange ( BOOL new_visibility ) +void LLPanel::onVisibilityChange ( BOOL new_visibility ) { - LLUICtrl::handleVisibilityChange ( new_visibility ); + LLUICtrl::onVisibilityChange ( new_visibility ); if (mVisibleSignal) (*mVisibleSignal)(this, LLSD(new_visibility) ); // Pass BOOL as LLSD } @@ -391,7 +391,7 @@ LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLXMLNodePtr output_ panelp = LLRegisterPanelClass::instance().createPanelClass(class_attr); if (!panelp) { - llwarns << "Panel class \"" << class_attr << "\" not registered." << llendl; + LL_WARNS() << "Panel class \"" << class_attr << "\" not registered." << LL_ENDL; } } @@ -520,7 +520,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); return TRUE; } @@ -529,7 +529,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu LLFastTimer timer(FTM_EXTERNAL_PANEL_LOAD); if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml)) { - llwarns << "Couldn't parse panel from: " << xml_filename << llendl; + LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL; return FALSE; } @@ -551,7 +551,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); } params.from_xui = true; @@ -599,11 +599,11 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate if(LLUI::sSettingGroups["config"]->getBOOL("QAMode")) { - llerrs << err_str << llendl; + LL_ERRS() << err_str << LL_ENDL; } else { - llwarns << err_str << llendl; + LL_WARNS() << err_str << LL_ENDL; } return LLStringUtil::null; } @@ -618,11 +618,11 @@ std::string LLPanel::getString(const std::string& name) const std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate if(LLUI::sSettingGroups["config"]->getBOOL("QAMode")) { - llerrs << err_str << llendl; + LL_ERRS() << err_str << LL_ENDL; } else { - llwarns << err_str << llendl; + LL_WARNS() << err_str << LL_ENDL; } return LLStringUtil::null; } @@ -976,18 +976,18 @@ BOOL LLPanel::buildFromFile(const std::string& filename, const LLPanel::Params& if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { - llwarns << "Couldn't parse panel from: " << filename << llendl; + LL_WARNS() << "Couldn't parse panel from: " << filename << LL_ENDL; return didPost; } // root must be called panel if( !root->hasName("panel" ) ) { - llwarns << "Root node should be named panel in : " << filename << llendl; + LL_WARNS() << "Root node should be named panel in : " << filename << LL_ENDL; return didPost; } - lldebugs << "Building panel " << filename << llendl; + LL_DEBUGS() << "Building panel " << filename << LL_ENDL; LLUICtrlFactory::instance().pushFileName(filename); { diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index e63b41f97c..ac8583ece9 100755 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -115,7 +115,7 @@ public: /*virtual*/ BOOL isPanel() const; /*virtual*/ void draw(); /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask ); - /*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); // From LLFocusableElement /*virtual*/ void setFocus( BOOL b ); diff --git a/indra/llui/llradiogroup.cpp b/indra/llui/llradiogroup.cpp index 95a7d09382..b53bb16d97 100755 --- a/indra/llui/llradiogroup.cpp +++ b/indra/llui/llradiogroup.cpp @@ -289,7 +289,7 @@ BOOL LLRadioGroup::handleMouseDown(S32 x, S32 y, MASK mask) void LLRadioGroup::onClickButton(LLUICtrl* ctrl) { - // llinfos << "LLRadioGroup::onClickButton" << llendl; + // LL_INFOS() << "LLRadioGroup::onClickButton" << LL_ENDL; LLRadioCtrl* clicked_radio = dynamic_cast<LLRadioCtrl*>(ctrl); if (!clicked_radio) return; @@ -319,7 +319,7 @@ void LLRadioGroup::onClickButton(LLUICtrl* ctrl) index++; } - llwarns << "LLRadioGroup::onClickButton - clicked button that isn't a child" << llendl; + LL_WARNS() << "LLRadioGroup::onClickButton - clicked button that isn't a child" << LL_ENDL; } void LLRadioGroup::setValue( const LLSD& value ) diff --git a/indra/llui/llresmgr.cpp b/indra/llui/llresmgr.cpp index 820e7cb26a..6e924c1f19 100755 --- a/indra/llui/llresmgr.cpp +++ b/indra/llui/llresmgr.cpp @@ -45,33 +45,6 @@ LLResMgr::LLResMgr() void LLResMgr::setLocale( LLLOCALE_ID locale_id ) { mLocale = locale_id; - - //RN: for now, use normal 'C' locale for everything but specific UI input/output routines -// switch( locale_id ) -// { -// case LLLOCALE_USA: -//#if LL_WINDOWS -// // Windows doesn't use ISO country codes. -// llinfos << "Setting locale to " << setlocale( LC_ALL, "english-usa" ) << llendl; -//#else -// // posix version should work everywhere else. -// llinfos << "Setting locale to " << setlocale( LC_ALL, "en_US" ) << llendl; -//#endif -// break; -// case LLLOCALE_UK: -//#if LL_WINDOWS -// // Windows doesn't use ISO country codes. -// llinfos << "Setting locale to " << setlocale( LC_ALL, "english-uk" ) << llendl; -//#else -// // posix version should work everywhere else. -// llinfos << "Setting locale to " << setlocale( LC_ALL, "en_GB" ) << llendl; -//#endif -// break; -// default: -// llassert(0); -// setLocale(LLLOCALE_USA); -// break; -// } } char LLResMgr::getDecimalPoint() const @@ -342,7 +315,7 @@ LLLocale::LLLocale(const std::string& locale_string) } //else //{ - // llinfos << "Set locale to " << new_locale_string << llendl; + // LL_INFOS() << "Set locale to " << new_locale_string << LL_ENDL; //} } diff --git a/indra/llui/llrngwriter.cpp b/indra/llui/llrngwriter.cpp index 5e6840d7df..cd9fe3610e 100755 --- a/indra/llui/llrngwriter.cpp +++ b/indra/llui/llrngwriter.cpp @@ -29,6 +29,7 @@ #include "llrngwriter.h" #include "lluicolor.h" #include "lluictrlfactory.h" +#include "boost/bind.hpp" static LLInitParam::Parser::parser_read_func_map_t sReadFuncs; static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs; diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index 13887cbe73..76134144a0 100755 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -381,7 +381,7 @@ BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask) } getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (active)" << LL_ENDL; handled = TRUE; } else @@ -393,7 +393,7 @@ BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask) if( !handled ) { getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (inactive)" << LL_ENDL; handled = TRUE; } @@ -493,11 +493,11 @@ void LLScrollbar::draw() BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y)); if (hovered) { - mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f)); + mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLSmoothInterpolation::getInterpolant(0.05f)); } else { - mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f)); + mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLSmoothInterpolation::getInterpolant(0.05f)); } // Draw background and thumb. diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h index 21fd2d631e..e2bf52c14b 100755 --- a/indra/llui/llscrollbar.h +++ b/indra/llui/llscrollbar.h @@ -40,13 +40,11 @@ class LLScrollbar { public: - enum ORIENTATION { HORIZONTAL, VERTICAL }; - typedef boost::function<void (S32, LLScrollbar*)> callback_t; struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { - Mandatory<ORIENTATION> orientation; + Mandatory<EOrientation> orientation; Mandatory<S32> doc_size; Mandatory<S32> doc_pos; Mandatory<S32> page_size; @@ -124,7 +122,7 @@ public: void onLineUpBtnPressed(const LLSD& data); void onLineDownBtnPressed(const LLSD& data); - + S32 getThickness() const { return mThickness; } void setThickness(S32 thickness); @@ -134,7 +132,7 @@ private: callback_t mChangeCallback; - const ORIENTATION mOrientation; + const EOrientation mOrientation; S32 mDocSize; // Size of the document that the scrollbar is modeling. Units depend on the user. 0 <= mDocSize. S32 mDocPos; // Position within the doc that the scrollbar is modeling, in "lines" (user size) S32 mPageSize; // Maximum number of lines that can be seen at one time. diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index cbcce0ece5..e1d401d94a 100755 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -144,7 +144,7 @@ LLScrollContainer::~LLScrollContainer( void ) { // mScrolledView and mScrollbar are child views, so the LLView // destructor takes care of memory deallocation. - for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) + for( S32 i = 0; i < ORIENTATION_COUNT; i++ ) { mScrollbar[i] = NULL; } @@ -155,7 +155,6 @@ LLScrollContainer::~LLScrollContainer( void ) // virtual void LLScrollContainer::scrollHorizontal( S32 new_pos ) { - //llinfos << "LLScrollContainer::scrollHorizontal()" << llendl; if( mScrolledView ) { LLRect doc_rect = mScrolledView->getRect(); @@ -167,7 +166,6 @@ void LLScrollContainer::scrollHorizontal( S32 new_pos ) // virtual void LLScrollContainer::scrollVertical( S32 new_pos ) { - // llinfos << "LLScrollContainer::scrollVertical() " << new_pos << llendl; if( mScrolledView ) { LLRect doc_rect = mScrolledView->getRect(); @@ -215,7 +213,7 @@ BOOL LLScrollContainer::handleKeyHere(KEY key, MASK mask) { return TRUE; } - for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) + for( S32 i = 0; i < ORIENTATION_COUNT; i++ ) { if( mScrollbar[i]->handleKeyHere(key, mask) ) { @@ -645,7 +643,7 @@ void LLScrollContainer::scrollToShowRect(const LLRect& rect, const LLRect& const { if (!mScrolledView) { - llwarns << "LLScrollContainer::scrollToShowRect with no view!" << llendl; + LL_WARNS() << "LLScrollContainer::scrollToShowRect with no view!" << LL_ENDL; return; } diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h index 4eb43539b8..f64cf43a8e 100755 --- a/indra/llui/llscrollcontainer.h +++ b/indra/llui/llscrollcontainer.h @@ -31,7 +31,6 @@ #ifndef LL_V4COLOR_H #include "v4color.h" #endif -#include "stdenums.h" #include "llcoord.h" #include "llscrollbar.h" @@ -56,7 +55,6 @@ class LLScrollContainer : public LLUICtrl public: // Note: vertical comes before horizontal because vertical // scrollbars have priority for mouse and keyboard events. - enum SCROLL_ORIENTATION { VERTICAL, HORIZONTAL, SCROLLBAR_COUNT }; struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { @@ -130,7 +128,7 @@ private: void updateScroll(); void calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const; - LLScrollbar* mScrollbar[SCROLLBAR_COUNT]; + LLScrollbar* mScrollbar[ORIENTATION_COUNT]; S32 mSize; BOOL mIsOpaque; LLUIColor mBackgroundColor; diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp index 9b65c2b79d..b6f2eb8ba2 100755 --- a/indra/llui/llscrollingpanellist.cpp +++ b/indra/llui/llscrollingpanellist.cpp @@ -111,7 +111,7 @@ void LLScrollingPanelList::removePanel( U32 panel_index ) { if ( mPanelList.empty() || panel_index >= mPanelList.size() ) { - llwarns << "Panel index " << panel_index << " is out of range!" << llendl; + LL_WARNS() << "Panel index " << panel_index << " is out of range!" << LL_ENDL; return; } else diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 4adfd42edd..f54fb36abe 100755 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1447,7 +1447,7 @@ void LLScrollListCtrl::drawItems() LLColor4 highlight_color = LLColor4::white; static LLUICachedControl<F32> type_ahead_timeout ("TypeAheadTimeout", 0); - highlight_color.mV[VALPHA] = clamp_rescale(mSearchTimer.getElapsedTimeF32(), type_ahead_timeout * 0.7f, type_ahead_timeout, 0.4f, 0.f); + highlight_color.mV[VALPHA] = clamp_rescale(mSearchTimer.getElapsedTimeF32(), type_ahead_timeout * 0.7f, type_ahead_timeout(), 0.4f, 0.f); S32 first_line = mScrollLines; S32 last_line = llmin((S32)mItemList.size() - 1, mScrollLines + getLinesPerPage()); @@ -1468,8 +1468,6 @@ void LLScrollListCtrl::drawItems() mLineHeight ); item->setRect(item_rect); - //llinfos << item_rect.getWidth() << llendl; - max_columns = llmax(max_columns, item->getNumColumns()); LLColor4 fg_color; diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index 7bc558f742..679aab3fe5 100755 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -34,7 +34,6 @@ #include "lluictrl.h" #include "llctrlselectioninterface.h" -//#include "lldarray.h" #include "llfontgl.h" #include "llui.h" #include "llstring.h" // LLWString diff --git a/indra/llui/llscrolllistitem.cpp b/indra/llui/llscrolllistitem.cpp index 5a1e96ab03..87cd71c505 100755 --- a/indra/llui/llscrolllistitem.cpp +++ b/indra/llui/llscrolllistitem.cpp @@ -82,7 +82,7 @@ void LLScrollListItem::setColumn( S32 column, LLScrollListCell *cell ) } else { - llerrs << "LLScrollListItem::setColumn: bad column: " << column << llendl; + LL_ERRS() << "LLScrollListItem::setColumn: bad column: " << column << LL_ENDL; } } diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp index db72234f94..ebbb951ee6 100755 --- a/indra/llui/llslider.cpp +++ b/indra/llui/llslider.cpp @@ -188,12 +188,12 @@ BOOL LLSlider::handleHover(S32 x, S32 y, MASK mask) setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue ); } getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (active)" << LL_ENDL; } else { getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (inactive)" << LL_ENDL; } return TRUE; } diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h index 700c17ea3e..3b492d8182 100755 --- a/indra/llui/llslider.h +++ b/indra/llui/llslider.h @@ -34,8 +34,6 @@ class LLSlider : public LLF32UICtrl { public: - enum ORIENTATION { HORIZONTAL, VERTICAL }; - struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params> { Optional<std::string> orientation; @@ -98,7 +96,7 @@ private: LLPointer<LLUIImage> mTrackHighlightHorizontalImage; LLPointer<LLUIImage> mTrackHighlightVerticalImage; - const ORIENTATION mOrientation; + const EOrientation mOrientation; LLRect mThumbRect; LLUIColor mTrackColor; diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp index 583ed1ed2e..62c5ecb8f1 100755 --- a/indra/llui/llsliderctrl.cpp +++ b/indra/llui/llsliderctrl.cpp @@ -403,7 +403,7 @@ void LLSliderCtrl::setPrecision(S32 precision) { if (precision < 0 || precision > 10) { - llerrs << "LLSliderCtrl::setPrecision - precision out of range" << llendl; + LL_ERRS() << "LLSliderCtrl::setPrecision - precision out of range" << LL_ENDL; return; } diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index 8a728df2e7..ebdbdf59c0 100755 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -384,7 +384,7 @@ void LLSpinCtrl::setPrecision(S32 precision) { if (precision < 0 || precision > 10) { - llerrs << "LLSpinCtrl::setPrecision - precision out of range" << llendl; + LL_ERRS() << "LLSpinCtrl::setPrecision - precision out of range" << LL_ENDL; return; } @@ -400,7 +400,7 @@ void LLSpinCtrl::setLabel(const LLStringExplicit& label) } else { - llwarns << "Attempting to set label on LLSpinCtrl constructed without one " << getName() << llendl; + LL_WARNS() << "Attempting to set label on LLSpinCtrl constructed without one " << getName() << LL_ENDL; } updateLabelColor(); } diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 04cce7878e..4c64cc944e 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -34,234 +34,516 @@ #include "llgl.h" #include "llfontgl.h" -#include "llstat.h" #include "lluictrlfactory.h" +#include "lltracerecording.h" +#include "llcriticaldamp.h" +#include "lltooltip.h" +#include "lllocalcliprect.h" +#include <iostream> + +// rate at which to update display of value that is rapidly changing +const F32 MEAN_VALUE_UPDATE_TIME = 1.f / 4.f; +// time between value changes that qualifies as a "rapid change" +const F32Seconds RAPID_CHANGE_THRESHOLD(0.2f); +// maximum number of rapid changes in RAPID_CHANGE_WINDOW before switching over to displaying the mean +// instead of latest value +const S32 MAX_RAPID_CHANGES_PER_SEC = 10; +// period of time over which to measure rapid changes +const F32Seconds RAPID_CHANGE_WINDOW(1.f); + +F32 calc_tick_value(F32 min, F32 max) +{ + F32 range = max - min; + const S32 DIVISORS[] = {6, 8, 10, 4, 5}; + // try storing + S32 best_decimal_digit_count = S32_MAX; + S32 best_divisor = 10; + for (U32 divisor_idx = 0; divisor_idx < LL_ARRAY_SIZE(DIVISORS); divisor_idx++) + { + S32 divisor = DIVISORS[divisor_idx]; + F32 possible_tick_value = range / divisor; + S32 num_whole_digits = llceil(logf(min + possible_tick_value) * OO_LN10); + for (S32 digit_count = -(num_whole_digits - 1); digit_count < 6; digit_count++) + { + F32 test_tick_value = min + (possible_tick_value * pow(10.0, digit_count)); + + if (is_approx_equal((F32)(S32)test_tick_value, test_tick_value)) + { + if (digit_count < best_decimal_digit_count) + { + best_decimal_digit_count = digit_count; + best_divisor = divisor; + } + break; + } + } + } + + return is_approx_equal(range, 0.f) ? 0.f : range / best_divisor; +} + +void calc_auto_scale_range(F32& min, F32& max, F32& tick) +{ + min = llmin(0.f, min, max); + max = llmax(0.f, min, max); + + const F32 RANGES[] = {0.f, 1.f, 1.5f, 2.f, 3.f, 5.f, 10.f}; + const F32 TICKS[] = {0.f, 0.25f, 0.5f, 1.f, 1.f, 1.f, 2.f }; + + const S32 num_digits_max = is_approx_equal(llabs(max), 0.f) + ? S32_MIN + 1 + : llceil(logf(llabs(max)) * OO_LN10); + const S32 num_digits_min = is_approx_equal(llabs(min), 0.f) + ? S32_MIN + 1 + : llceil(logf(llabs(min)) * OO_LN10); + + const S32 num_digits = llmax(num_digits_max, num_digits_min); + const F32 power_of_10 = pow(10.0, num_digits - 1); + const F32 starting_max = power_of_10 * ((max < 0.f) ? -1 : 1); + const F32 starting_min = power_of_10 * ((min < 0.f) ? -1 : 1); + + F32 cur_max = starting_max; + F32 cur_min = starting_min; + F32 out_max = max; + F32 out_min = min; + + F32 cur_tick_min = 0.f; + F32 cur_tick_max = 0.f; + + for (S32 range_idx = 0; range_idx < LL_ARRAY_SIZE(RANGES); range_idx++) + { + cur_max = starting_max * RANGES[range_idx]; + cur_min = starting_min * RANGES[range_idx]; + + if (min > 0.f && cur_min <= min) + { + out_min = cur_min; + cur_tick_min = TICKS[range_idx]; + } + if (max < 0.f && cur_max >= max) + { + out_max = cur_max; + cur_tick_max = TICKS[range_idx]; + } + } + + cur_max = starting_max; + cur_min = starting_min; + for (S32 range_idx = LL_ARRAY_SIZE(RANGES) - 1; range_idx >= 0; range_idx--) + { + cur_max = starting_max * RANGES[range_idx]; + cur_min = starting_min * RANGES[range_idx]; + + if (min < 0.f && cur_min <= min) + { + out_min = cur_min; + cur_tick_min = TICKS[range_idx]; + } + if (max > 0.f && cur_max >= max) + { + out_max = cur_max; + cur_tick_max = TICKS[range_idx]; + } + } + + tick = power_of_10 * llmax(cur_tick_min, cur_tick_max); + min = out_min; + max = out_max; +} + +LLStatBar::Params::Params() +: label("label"), + unit_label("unit_label"), + bar_min("bar_min", 0.f), + bar_max("bar_max", 0.f), + tick_spacing("tick_spacing", 0.f), + decimal_digits("decimal_digits", 3), + show_bar("show_bar", false), + show_history("show_history", false), + scale_range("scale_range", true), + num_frames("num_frames", 200), + num_frames_short("num_frames_short", 20), + max_height("max_height", 100), + stat("stat"), + orientation("orientation", VERTICAL) +{ + changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT); +} /////////////////////////////////////////////////////////////////////////////////// LLStatBar::LLStatBar(const Params& p) - : LLView(p), - mLabel(p.label), - mUnitLabel(p.unit_label), - mMinBar(p.bar_min), - mMaxBar(p.bar_max), - mStatp(LLStat::getStat(p.stat)), - mTickSpacing(p.tick_spacing), - mLabelSpacing(p.label_spacing), - mPrecision(p.precision), - mUpdatesPerSec(p.update_rate), - mPerSec(p.show_per_sec), - mDisplayBar(p.show_bar), - mDisplayHistory(p.show_history), - mDisplayMean(p.show_mean) +: LLView(p), + mLabel(p.label), + mUnitLabel(p.unit_label), + mMinBar(llmin(p.bar_min, p.bar_max)), + mMaxBar(llmax(p.bar_max, p.bar_min)), + mCurMaxBar(p.bar_max), + mCurMinBar(0), + mDecimalDigits(p.decimal_digits), + mNumHistoryFrames(p.num_frames), + mNumShortHistoryFrames(p.num_frames_short), + mMaxHeight(p.max_height), + mDisplayBar(p.show_bar), + mDisplayHistory(p.show_history), + mOrientation(p.orientation), + mAutoScaleMax(!p.bar_max.isProvided()), + mAutoScaleMin(!p.bar_min.isProvided()), + mTickValue(p.tick_spacing), + mLastDisplayValue(0.f) { + // tick value will be automatically calculated later + if (!p.tick_spacing.isProvided() && p.bar_min.isProvided() && p.bar_max.isProvided()) + { + mTickValue = calc_tick_value(mMinBar, mMaxBar); + } + + setStat(p.stat); +} + +BOOL LLStatBar::handleHover(S32 x, S32 y, MASK mask) +{ + if (mCountFloatp) + { + LLToolTipMgr::instance().show(LLToolTip::Params().message(mCountFloatp->getDescription()).sticky_rect(calcScreenRect())); + } + else if ( mEventFloatp) + { + LLToolTipMgr::instance().show(LLToolTip::Params().message(mEventFloatp->getDescription()).sticky_rect(calcScreenRect())); + } + else if (mSampleFloatp) + { + LLToolTipMgr::instance().show(LLToolTip::Params().message(mSampleFloatp->getDescription()).sticky_rect(calcScreenRect())); + } + return TRUE; } BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) { - if (mDisplayBar) + BOOL handled = LLView::handleMouseDown(x, y, mask); + if (!handled) { - if (mDisplayHistory) + if (mDisplayBar) { - mDisplayBar = FALSE; - mDisplayHistory = FALSE; + if (mDisplayHistory || mOrientation == HORIZONTAL) + { + mDisplayBar = FALSE; + mDisplayHistory = FALSE; + } + else + { + mDisplayHistory = TRUE; + } } else { - mDisplayHistory = TRUE; + mDisplayBar = TRUE; + if (mOrientation == HORIZONTAL) + { + mDisplayHistory = TRUE; + } } + LLView* parent = getParent(); + parent->reshape(parent->getRect().getWidth(), parent->getRect().getHeight(), FALSE); } - else + return TRUE; +} + +template<typename T> +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const F32Seconds time_period) +{ + F32Seconds elapsed_time, + time_since_value_changed; + S32 num_rapid_changes = 0; + const F32Seconds RAPID_CHANGE_THRESHOLD = F32Seconds(0.3f); + + F64 last_value = periodic_recording.getPrevRecording(1).getLastValue(stat); + for (S32 i = 2; i < periodic_recording.getNumRecordedPeriods(); i++) { - mDisplayBar = TRUE; - } + LLTrace::Recording& recording = periodic_recording.getPrevRecording(i); + F64 cur_value = recording.getLastValue(stat); + + if (last_value != cur_value) + { + if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; + time_since_value_changed = 0; + } + last_value = cur_value; - LLView* parent = getParent(); - parent->reshape(parent->getRect().getWidth(), parent->getRect().getHeight(), FALSE); + elapsed_time += recording.getDuration(); + if (elapsed_time > time_period) break; + } - return FALSE; + return num_rapid_changes; } -void LLStatBar::draw() +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType<LLTrace::CountAccumulator>& stat, const F32Seconds time_period) { - if (!mStatp) + F32Seconds elapsed_time, + time_since_value_changed; + S32 num_rapid_changes = 0; + + F64 last_value = periodic_recording.getPrevRecording(1).getSum(stat); + for (S32 i = 1; i < periodic_recording.getNumRecordedPeriods(); i++) { -// llinfos << "No stats for statistics bar!" << llendl; - return; + LLTrace::Recording& recording = periodic_recording.getPrevRecording(i); + F64 cur_value = recording.getSum(stat); + + if (last_value != cur_value) + { + if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; + time_since_value_changed = 0; + } + last_value = cur_value; + + elapsed_time += recording.getDuration(); + if (elapsed_time > time_period) break; } - // Get the values. - F32 current, min, max, mean; - if (mPerSec) + return num_rapid_changes; +} + +void LLStatBar::draw() +{ + LLLocalClipRect _(getLocalRect()); + + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + + std::string unit_label; + F32 current = 0, + min = 0, + max = 0, + mean = 0, + display_value = 0; + S32 num_frames = mDisplayHistory + ? mNumHistoryFrames + : mNumShortHistoryFrames; + S32 num_rapid_changes = 0; + + if (mCountFloatp) { - current = mStatp->getCurrentPerSec(); - min = mStatp->getMinPerSec(); - max = mStatp->getMaxPerSec(); - mean = mStatp->getMeanPerSec(); + const LLTrace::TraceType<LLTrace::CountAccumulator>& count_stat = *mCountFloatp; + + unit_label = mUnitLabel.empty() ? (std::string(count_stat.getUnitLabel()) + "/s") : mUnitLabel; + current = last_frame_recording.getPerSec(count_stat); + min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); + max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); + mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames); + display_value = mean; } - else + else if (mEventFloatp) { - current = mStatp->getCurrent(); - min = mStatp->getMin(); - max = mStatp->getMax(); - mean = mStatp->getMean(); + const LLTrace::TraceType<LLTrace::EventAccumulator>& event_stat = *mEventFloatp; + + unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; + current = last_frame_recording.getLastValue(event_stat); + min = frame_recording.getPeriodMin(event_stat, num_frames); + max = frame_recording.getPeriodMax(event_stat, num_frames); + mean = frame_recording.getPeriodMean(event_stat, num_frames); + num_rapid_changes = calc_num_rapid_changes(frame_recording, event_stat, RAPID_CHANGE_WINDOW); + display_value = mean; } + else if (mSampleFloatp) + { + const LLTrace::TraceType<LLTrace::SampleAccumulator>& sample_stat = *mSampleFloatp; + unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; + current = last_frame_recording.getLastValue(sample_stat); + min = frame_recording.getPeriodMin(sample_stat, num_frames); + max = frame_recording.getPeriodMax(sample_stat, num_frames); + mean = frame_recording.getPeriodMean(sample_stat, num_frames); + num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW); - if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) - { - if (mDisplayMean) + if (num_rapid_changes / RAPID_CHANGE_WINDOW > MAX_RAPID_CHANGES_PER_SEC) { - mValue = mean; + display_value = mean; } else { - mValue = current; + display_value = current; + // always display current value, don't rate limit + mLastDisplayValue = current; } - mUpdateTimer.reset(); } - S32 width = getRect().getWidth() - 40; - S32 max_width = width; - S32 bar_top = getRect().getHeight() - 15; // 16 pixels from top. - S32 bar_height = bar_top - 20; - S32 tick_height = 4; - S32 tick_width = 1; - S32 left, top, right, bottom; - - F32 value_scale = max_width/(mMaxBar - mMinBar); + LLRect bar_rect; + if (mOrientation == HORIZONTAL) + { + bar_rect.mTop = llmax(5, getRect().getHeight() - 15); + bar_rect.mLeft = 0; + bar_rect.mRight = getRect().getWidth() - 40; + bar_rect.mBottom = llmin(bar_rect.mTop - 5, 0); + } + else // VERTICAL + { + bar_rect.mTop = llmax(5, getRect().getHeight() - 15); + bar_rect.mLeft = 0; + bar_rect.mRight = getRect().getWidth(); + bar_rect.mBottom = llmin(bar_rect.mTop - 5, 20); + } - LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), - LLFontGL::LEFT, LLFontGL::TOP); + mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); + mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); - std::string value_format; - std::string value_str; - if (!mUnitLabel.empty()) + // rate limited updates + if (mLastDisplayValueTimer.getElapsedTimeF32() > MEAN_VALUE_UPDATE_TIME) { - value_format = llformat( "%%.%df%%s", mPrecision); - value_str = llformat( value_format.c_str(), mValue, mUnitLabel.c_str()); + mLastDisplayValueTimer.reset(); + drawLabelAndValue(display_value, unit_label, bar_rect); + mLastDisplayValue = display_value; } else { - value_format = llformat( "%%.%df", mPrecision); - value_str = llformat( value_format.c_str(), mValue); + drawLabelAndValue(mLastDisplayValue, unit_label, bar_rect); } - // Draw the value. - LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, width, getRect().getHeight(), - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::RIGHT, LLFontGL::TOP); - - value_format = llformat( "%%.%df", mPrecision); - if (mDisplayBar) + if (mDisplayBar + && (mCountFloatp || mEventFloatp || mSampleFloatp)) { - std::string tick_label; - // Draw the tick marks. - F32 tick_value; - top = bar_top; - bottom = bar_top - bar_height - tick_height/2; - LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - for (tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mTickSpacing) + F32 value_scale; + if (mCurMaxBar == mCurMinBar) { - left = llfloor((tick_value - mMinBar)*value_scale); - right = left + tick_width; - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.1f)); + value_scale = 0.f; } - - // Draw the tick labels (and big ticks). - bottom = bar_top - bar_height - tick_height; - for (tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mLabelSpacing) + else { - left = llfloor((tick_value - mMinBar)*value_scale); - right = left + tick_width; - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.25f)); - - tick_label = llformat( value_format.c_str(), tick_value); - // draw labels for the tick marks - LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, left - 1, bar_top - bar_height - tick_height, - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::LEFT, LLFontGL::TOP); + value_scale = (mOrientation == HORIZONTAL) + ? (bar_rect.getHeight())/(mCurMaxBar - mCurMinBar) + : (bar_rect.getWidth())/(mCurMaxBar - mCurMinBar); } - // Now, draw the bars - top = bar_top; - bottom = bar_top - bar_height; + drawTicks(min, max, value_scale, bar_rect); // draw background bar. - left = 0; - right = width; - gl_rect_2d(left, top, right, bottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); + gl_rect_2d(bar_rect.mLeft, bar_rect.mTop, bar_rect.mRight, bar_rect.mBottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); - if (mStatp->getNumValues() == 0) + // draw values + if (!llisnan(display_value) && frame_recording.getNumRecordedPeriods() != 0) { - // No data, don't draw anything... - return; - } - // draw min and max - left = (S32) ((min - mMinBar) * value_scale); + // draw min and max + S32 begin = (S32) ((min - mCurMinBar) * value_scale); - if (left < 0) - { - left = 0; - llwarns << "Min:" << min << llendl; - } + if (begin < 0) + { + begin = 0; + } + + S32 end = (S32) ((max - mCurMinBar) * value_scale); + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight, begin, LLColor4(1.f, 0.f, 0.f, 0.25f)); + } + else // VERTICAL + { + gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); + } - right = (S32) ((max - mMinBar) * value_scale); - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); + F32 span = (mOrientation == HORIZONTAL) + ? (bar_rect.getWidth()) + : (bar_rect.getHeight()); - S32 num_values = mStatp->getNumValues() - 1; - if (mDisplayHistory) - { - S32 i; - for (i = 0; i < num_values; i++) + if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) { - if (i == mStatp->getNextBin()) + const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; + F32 value = 0; + S32 i; + gGL.color4f( 1.f, 0.f, 0.f, 1.f ); + gGL.begin( LLRender::QUADS ); + const S32 max_frame = llmin(num_frames, num_values); + U32 num_samples = 0; + for (i = 1; i <= max_frame; i++) { - continue; + F32 offset = ((F32)i / (F32)num_frames) * span; + LLTrace::Recording& recording = frame_recording.getPrevRecording(i); + + if (mCountFloatp) + { + value = recording.getPerSec(*mCountFloatp); + num_samples = recording.getSampleCount(*mCountFloatp); + } + else if (mEventFloatp) + { + value = recording.getMean(*mEventFloatp); + num_samples = recording.getSampleCount(*mEventFloatp); + } + else if (mSampleFloatp) + { + value = recording.getMean(*mSampleFloatp); + num_samples = recording.getSampleCount(*mSampleFloatp); + } + + if (!num_samples) continue; + + F32 begin = (value - mCurMinBar) * value_scale; + if (mOrientation == HORIZONTAL) + { + gGL.vertex2f((F32)bar_rect.mRight - offset, begin + 1); + gGL.vertex2f((F32)bar_rect.mRight - offset, begin); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, begin); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, begin + 1); + } + else + { + gGL.vertex2f(begin, (F32)bar_rect.mBottom + offset + 1); + gGL.vertex2f(begin, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(begin + 1, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(begin + 1, (F32)bar_rect.mBottom + offset + 1 ); + } } - if (mPerSec) + gGL.end(); + } + else + { + S32 begin = (S32) ((current - mCurMinBar) * value_scale) - 1; + S32 end = (S32) ((current - mCurMinBar) * value_scale) + 1; + // draw current + if (mOrientation == HORIZONTAL) { - left = (S32)((mStatp->getPrevPerSec(i) - mMinBar) * value_scale); - right = (S32)((mStatp->getPrevPerSec(i) - mMinBar) * value_scale) + 1; - gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); + gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight, begin, LLColor4(1.f, 0.f, 0.f, 1.f)); } else { - left = (S32)((mStatp->getPrev(i) - mMinBar) * value_scale); - right = (S32)((mStatp->getPrev(i) - mMinBar) * value_scale) + 1; - gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); + gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom, LLColor4(1.f, 0.f, 0.f, 1.f)); } } - } - else - { - // draw current - left = (S32) ((current - mMinBar) * value_scale) - 1; - right = (S32) ((current - mMinBar) * value_scale) + 1; - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 1.f)); - } - // draw mean bar - top = bar_top + 2; - bottom = bar_top - bar_height - 2; - left = (S32) ((mean - mMinBar) * value_scale) - 1; - right = (S32) ((mean - mMinBar) * value_scale) + 1; - gl_rect_2d(left, top, right, bottom, LLColor4(0.f, 1.f, 0.f, 1.f)); + // draw mean bar + { + const S32 begin = (S32) ((mean - mCurMinBar) * value_scale) - 1; + const S32 end = (S32) ((mean - mCurMinBar) * value_scale) + 1; + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_rect.mLeft - 2, begin, bar_rect.mRight + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f)); + } + else + { + gl_rect_2d(begin, bar_rect.mTop + 2, end, bar_rect.mBottom - 2, LLColor4(0.f, 1.f, 0.f, 1.f)); + } + } + } } LLView::draw(); } -void LLStatBar::setRange(F32 bar_min, F32 bar_max, F32 tick_spacing, F32 label_spacing) +void LLStatBar::setStat(const std::string& stat_name) +{ + mCountFloatp = LLTrace::TraceType<LLTrace::CountAccumulator>::getInstance(stat_name); + mEventFloatp = LLTrace::TraceType<LLTrace::EventAccumulator>::getInstance(stat_name); + mSampleFloatp = LLTrace::TraceType<LLTrace::SampleAccumulator>::getInstance(stat_name); +} + + +void LLStatBar::setRange(F32 bar_min, F32 bar_max) { - mMinBar = bar_min; - mMaxBar = bar_max; - mTickSpacing = tick_spacing; - mLabelSpacing = label_spacing; + mMinBar = llmin(bar_min, bar_max); + mMaxBar = llmax(bar_min, bar_max); + mTickValue = calc_tick_value(mMinBar, mMaxBar); } LLRect LLStatBar::getRequiredRect() @@ -272,7 +554,7 @@ LLRect LLStatBar::getRequiredRect() { if (mDisplayHistory) { - rect.mTop = 35 + mStatp->getNumBins(); + rect.mTop = mMaxHeight; } else { @@ -285,3 +567,125 @@ LLRect LLStatBar::getRequiredRect() } return rect; } + +void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_rect ) +{ + LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), + LLFontGL::LEFT, LLFontGL::TOP); + + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)value, value)) + { + decimal_digits = 0; + } + std::string value_str = !llisnan(value) + ? llformat("%10.*f %s", decimal_digits, value, label.c_str()) + : "n/a"; + + // Draw the current value. + if (mOrientation == HORIZONTAL) + { + LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_rect.mRight, getRect().getHeight(), + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + } + else + { + LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_rect.mRight, getRect().getHeight(), + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + } +} + +void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) +{ + if ((mAutoScaleMax && max >= mCurMaxBar)|| (mAutoScaleMin && min <= mCurMinBar)) + { + F32 range_min = mAutoScaleMin ? llmin(mMinBar, min) : mMinBar; + F32 range_max = mAutoScaleMax ? llmax(mMaxBar, max) : mMaxBar; + F32 tick_value = 0.f; + calc_auto_scale_range(range_min, range_max, tick_value); + if (mAutoScaleMin) { mMinBar = range_min; } + if (mAutoScaleMax) { mMaxBar = range_max; } + if (mAutoScaleMin && mAutoScaleMax) + { + mTickValue = tick_value; + } + else + { + mTickValue = calc_tick_value(mMinBar, mMaxBar); + } + } + + // start counting from actual min, not current, animating min, so that ticks don't float between numbers + // ensure ticks always hit 0 + S32 last_tick = 0; + S32 last_label = 0; + if (mTickValue > 0.f && value_scale > 0.f) + { + const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; + const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 30 : 60; + const S32 TICK_LENGTH = 4; + const S32 TICK_WIDTH = 1; + + F32 start = mCurMinBar < 0.f + ? llceil(-mCurMinBar / mTickValue) * -mTickValue + : 0.f; + for (F32 tick_value = start; ;tick_value += mTickValue) + { + const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale); + const S32 end = begin + TICK_WIDTH; + if (begin - last_tick < MIN_TICK_SPACING) + { + continue; + } + last_tick = begin; + + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)tick_value, tick_value)) + { + decimal_digits = 0; + } + std::string tick_string = llformat("%10.*f", decimal_digits, tick_value); + + if (mOrientation == HORIZONTAL) + { + if (begin - last_label > MIN_LABEL_SPACING) + { + gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight - TICK_LENGTH, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_rect.mRight, begin, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::LEFT, LLFontGL::VCENTER); + last_label = begin; + } + else + { + gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight - TICK_LENGTH/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } + } + else + { + if (begin - last_label > MIN_LABEL_SPACING) + { + gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_rect.mBottom - TICK_LENGTH, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + last_label = begin; + } + else + { + gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom - TICK_LENGTH/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } + } + // always draw one tick value past end, so we can see part of the text, if possible + if (tick_value > mCurMaxBar) + { + break; + } + } + } +} + + + diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 513fff3234..bf2bd3e259 100755 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -29,74 +29,76 @@ #include "llview.h" #include "llframetimer.h" - -class LLStat; +#include "lltracerecording.h" class LLStatBar : public LLView { public: + struct Params : public LLInitParam::Block<Params, LLView::Params> { - Optional<std::string> label; - Optional<std::string> unit_label; - Optional<F32> bar_min; - Optional<F32> bar_max; - Optional<F32> tick_spacing; - Optional<F32> label_spacing; - Optional<U32> precision; - Optional<F32> update_rate; - Optional<bool> show_per_sec; - Optional<bool> show_bar; - Optional<bool> show_history; - Optional<bool> show_mean; - Optional<std::string> stat; - Params() - : label("label"), - unit_label("unit_label"), - bar_min("bar_min", 0.0f), - bar_max("bar_max", 50.0f), - tick_spacing("tick_spacing", 10.0f), - label_spacing("label_spacing", 10.0f), - precision("precision", 0), - update_rate("update_rate", 5.0f), - show_per_sec("show_per_sec", TRUE), - show_bar("show_bar", TRUE), - show_history("show_history", FALSE), - show_mean("show_mean", TRUE), - stat("stat") - { - changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT); - } + Optional<std::string> label, + unit_label; + + Optional<F32> bar_min, + bar_max, + tick_spacing; + + Optional<U32> decimal_digits; + + Optional<bool> show_bar, + show_history, + scale_range; + + Optional<S32> num_frames, + num_frames_short, + max_height; + Optional<std::string> stat; + Optional<EOrientation> orientation; + + Params(); }; LLStatBar(const Params&); virtual void draw(); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); + virtual BOOL handleHover(S32 x, S32 y, MASK mask); + + void setStat(const std::string& stat_name); - void setStat(LLStat* stat) { mStatp = stat; } - void setRange(F32 bar_min, F32 bar_max, F32 tick_spacing, F32 label_spacing); + void setRange(F32 bar_min, F32 bar_max); void getRange(F32& bar_min, F32& bar_max) { bar_min = mMinBar; bar_max = mMaxBar; } /*virtual*/ LLRect getRequiredRect(); // Return the height of this object, given the set options. private: - F32 mMinBar; - F32 mMaxBar; - F32 mTickSpacing; - F32 mLabelSpacing; - U32 mPrecision; - F32 mUpdatesPerSec; - BOOL mPerSec; // Use the per sec stats. - BOOL mDisplayBar; // Display the bar graph. - BOOL mDisplayHistory; - BOOL mDisplayMean; // If true, display mean, if false, display current value - - LLStat* mStatp; - - LLFrameTimer mUpdateTimer; - LLUIString mLabel; - std::string mUnitLabel; - F32 mValue; + void drawLabelAndValue( F32 mean, std::string &unit_label, LLRect &bar_rect ); + void drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ); + + F32 mMinBar, + mMaxBar, + mCurMaxBar, + mCurMinBar, + mLabelSpacing; + F32 mTickValue; + U32 mDecimalDigits; + S32 mNumHistoryFrames, + mNumShortHistoryFrames; + S32 mMaxHeight; + bool mDisplayBar, // Display the bar graph. + mDisplayHistory, + mAutoScaleMax, + mAutoScaleMin; + EOrientation mOrientation; + F32 mLastDisplayValue; + LLFrameTimer mLastDisplayValueTimer; + + const LLTrace::TraceType<LLTrace::CountAccumulator>* mCountFloatp; + const LLTrace::TraceType<LLTrace::EventAccumulator>* mEventFloatp; + const LLTrace::TraceType<LLTrace::SampleAccumulator>* mSampleFloatp; + + LLUIString mLabel; + std::string mUnitLabel; }; #endif diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index e44887ebf0..a44bc18733 100755 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -32,48 +32,51 @@ #include "llmath.h" #include "llui.h" -#include "llstat.h" #include "llgl.h" #include "llglheaders.h" +#include "lltracerecording.h" +#include "lltracethreadrecorder.h" //#include "llviewercontrol.h" /////////////////////////////////////////////////////////////////////////////////// -LLStatGraph::LLStatGraph(const LLView::Params& p) -: LLView(p) +LLStatGraph::LLStatGraph(const Params& p) +: LLView(p), + mMin(p.min), + mMax(p.max), + mPerSec(true), + mPrecision(p.precision), + mValue(p.value), + mNewStatFloatp(p.stat.count_stat_float) { - mStatp = NULL; setToolTip(p.name()); - mNumThresholds = 3; - mThresholdColors[0] = LLColor4(0.f, 1.f, 0.f, 1.f); - mThresholdColors[1] = LLColor4(1.f, 1.f, 0.f, 1.f); - mThresholdColors[2] = LLColor4(1.f, 0.f, 0.f, 1.f); - mThresholdColors[3] = LLColor4(1.f, 0.f, 0.f, 1.f); - mThresholds[0] = 50.f; - mThresholds[1] = 75.f; - mThresholds[2] = 100.f; - mMin = 0.f; - mMax = 125.f; - mPerSec = TRUE; - mValue = 0.f; - mPrecision = 0; + + for(LLInitParam::ParamIterator<ThresholdParams>::const_iterator it = p.thresholds.threshold.begin(), end_it = p.thresholds.threshold.end(); + it != end_it; + ++it) + { + mThresholds.push_back(Threshold(it->value(), it->color)); + } } void LLStatGraph::draw() { F32 range, frac; range = mMax - mMin; - if (mStatp) + if (mNewStatFloatp) { + LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecording(); + if (mPerSec) { - mValue = mStatp->getMeanPerSec(); + mValue = recording.getPerSec(*mNewStatFloatp); } else { - mValue = mStatp->getMean(); + mValue = recording.getSum(*mNewStatFloatp); } } + frac = (mValue - mMin) / range; frac = llmax(0.f, frac); frac = llmin(1.f, frac); @@ -91,19 +94,13 @@ void LLStatGraph::draw() LLColor4 color; - S32 i; - for (i = 0; i < mNumThresholds - 1; i++) + threshold_vec_t::iterator it = std::lower_bound(mThresholds.begin(), mThresholds.end(), Threshold(mValue / mMax, LLUIColor())); + + if (it != mThresholds.begin()) { - if (mThresholds[i] > mValue) - { - break; - } + it--; } - //gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0, - // LLUIColorTable::instance().getColor("ColorDropShadow"), - // (S32) gSavedSettings.getF32("DropShadowFloater") ); - color = LLUIColorTable::instance().getColor( "MenuDefaultBgColor" ); gGL.color4fv(color.mV); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, TRUE); @@ -111,16 +108,11 @@ void LLStatGraph::draw() gGL.color4fv(LLColor4::black.mV); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, FALSE); - color = mThresholdColors[i]; + color = it->mColor; gGL.color4fv(color.mV); gl_rect_2d(1, llround(frac*getRect().getHeight()), getRect().getWidth() - 1, 0, TRUE); } -void LLStatGraph::setValue(const LLSD& value) -{ - mValue = (F32)value.asReal(); -} - void LLStatGraph::setMin(const F32 min) { mMin = min; @@ -131,27 +123,3 @@ void LLStatGraph::setMax(const F32 max) mMax = max; } -void LLStatGraph::setStat(LLStat *statp) -{ - mStatp = statp; -} - -void LLStatGraph::setLabel(const std::string& label) -{ - mLabel = label; -} - -void LLStatGraph::setUnits(const std::string& units) -{ - mUnits = units; -} - -void LLStatGraph::setPrecision(const S32 precision) -{ - mPrecision = precision; -} - -void LLStatGraph::setThreshold(const S32 i, F32 value) -{ - mThresholds[i] = value; -} diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index 757525e232..38fe12d18b 100755 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -30,29 +30,84 @@ #include "llview.h" #include "llframetimer.h" #include "v4color.h" - -class LLStat; +#include "lltrace.h" class LLStatGraph : public LLView { public: - LLStatGraph(const LLView::Params&); + struct ThresholdParams : public LLInitParam::Block<ThresholdParams> + { + Mandatory<F32> value; + Optional<LLUIColor> color; - virtual void draw(); + ThresholdParams() + : value("value"), + color("color", LLColor4::white) + {} + }; + + struct Thresholds : public LLInitParam::Block<Thresholds> + { + Multiple<ThresholdParams> threshold; + + Thresholds() + : threshold("threshold") + {} + }; + + struct StatParams : public LLInitParam::ChoiceBlock<StatParams> + { + Alternative<LLTrace::TraceType<LLTrace::CountAccumulator>* > count_stat_float; + Alternative<LLTrace::TraceType<LLTrace::EventAccumulator>* > event_stat_float; + Alternative<LLTrace::TraceType<LLTrace::SampleAccumulator>* > sample_stat_float; + }; + + struct Params : public LLInitParam::Block<Params, LLView::Params> + { + Mandatory<StatParams> stat; + Optional<std::string> label, + units; + Optional<S32> precision; + Optional<F32> min, + max; + Optional<bool> per_sec; + Optional<F32> value; + + Optional<Thresholds> thresholds; + + Params() + : stat("stat"), + label("label"), + units("units"), + precision("precision", 0), + min("min", 0.f), + max("max", 125.f), + per_sec("per_sec", true), + value("value", 0.f), + thresholds("thresholds") + { + Thresholds _thresholds; + _thresholds.threshold.add(ThresholdParams().value(0.f).color(LLColor4::green)) + .add(ThresholdParams().value(0.33f).color(LLColor4::yellow)) + .add(ThresholdParams().value(0.5f).color(LLColor4::red)) + .add(ThresholdParams().value(0.75f).color(LLColor4::red)); + thresholds = _thresholds; + } + }; + LLStatGraph(const Params&); - void setLabel(const std::string& label); - void setUnits(const std::string& units); - void setPrecision(const S32 precision); - void setStat(LLStat *statp); - void setThreshold(const S32 i, F32 value); void setMin(const F32 min); void setMax(const F32 max); + virtual void draw(); + /*virtual*/ void setValue(const LLSD& value); - LLStat *mStatp; - BOOL mPerSec; private: + LLTrace::TraceType<LLTrace::CountAccumulator>* mNewStatFloatp; + + BOOL mPerSec; + F32 mValue; F32 mMin; @@ -62,9 +117,25 @@ private: std::string mUnits; S32 mPrecision; // Num of digits of precision after dot - S32 mNumThresholds; - F32 mThresholds[4]; - LLColor4 mThresholdColors[4]; + struct Threshold + { + Threshold(F32 value, const LLUIColor& color) + : mValue(value), + mColor(color) + {} + + F32 mValue; + LLUIColor mColor; + bool operator <(const Threshold& other) + { + return mValue < other.mValue; + } + }; + typedef std::vector<Threshold> threshold_vec_t; + threshold_vec_t mThresholds; + //S32 mNumThresholds; + //F32 mThresholds[4]; + //LLColor4 mThresholdColors[4]; }; #endif // LL_LLSTATGRAPH_H diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index fd98155704..180120c0cb 100755 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -406,7 +406,7 @@ void LLTabContainer::draw() } } - setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(0.08f))); + setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLSmoothInterpolation::getInterpolant(0.08f))); BOOL has_scroll_arrows = !getTabsHidden() && ((mMaxScrollPos > 0) || (mScrollPosPixels > 0)); if (!mIsVertical) @@ -1572,7 +1572,7 @@ BOOL LLTabContainer::selectTabByName(const std::string& name) LLPanel* panel = getPanelByName(name); if (!panel) { - llwarns << "LLTabContainer::selectTabByName(" << name << ") failed" << llendl; + LL_WARNS() << "LLTabContainer::selectTabByName(" << name << ") failed" << LL_ENDL; return FALSE; } diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index a45c4ced2e..94cf93bd3c 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -48,6 +48,8 @@ const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds const S32 CURSOR_THICKNESS = 2; const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click. +LLTrace::MemStatHandle LLTextSegment::sMemStat("LLTextSegment"); + LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num) : mDocIndexStart(index_start), mDocIndexEnd(index_end), @@ -575,7 +577,7 @@ void LLTextBase::drawText() if ( (mSpellCheckStart != start) || (mSpellCheckEnd != end) ) { const LLWString& wstrText = getWText(); - mMisspellRanges.clear(); + memDisclaim(mMisspellRanges).clear(); segment_set_t::const_iterator seg_it = getSegIterContaining(start); while (mSegments.end() != seg_it) @@ -651,6 +653,7 @@ void LLTextBase::drawText() mSpellCheckStart = start; mSpellCheckEnd = end; + memClaim(mMisspellRanges); } } @@ -684,7 +687,7 @@ void LLTextBase::drawText() seg_iter++; if (seg_iter == mSegments.end()) { - llwarns << "Ran off the segmentation end!" << llendl; + LL_WARNS() << "Ran off the segmentation end!" << LL_ENDL; return; } @@ -916,9 +919,11 @@ void LLTextBase::createDefaultSegment() if (mSegments.empty()) { LLStyleConstSP sp(new LLStyle(getStyleParams())); + memDisclaim(mSegments); LLTextSegmentPtr default_segment = new LLNormalTextSegment( sp, 0, getLength() + 1, *this); mSegments.insert(default_segment); default_segment->linkToDocument(this); + memClaim(mSegments); } } @@ -929,6 +934,8 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert) return; } + memDisclaim(mSegments); + segment_set_t::iterator cur_seg_iter = getSegIterContaining(segment_to_insert->getStart()); S32 reflow_start_index = 0; @@ -1001,6 +1008,7 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert) // layout potentially changed needsReflow(reflow_start_index); + memClaim(mSegments); } BOOL LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask) @@ -1254,13 +1262,13 @@ void LLTextBase::setReadOnlyColor(const LLColor4 &c) } //virtual -void LLTextBase::handleVisibilityChange( BOOL new_visibility ) +void LLTextBase::onVisibilityChange( BOOL new_visibility ) { if(!new_visibility && mPopupMenu) { mPopupMenu->hide(); } - LLUICtrl::handleVisibilityChange(new_visibility); + LLUICtrl::onVisibilityChange(new_visibility); } //virtual @@ -1311,8 +1319,11 @@ void LLTextBase::replaceWithSuggestion(U32 index) removeStringNoUndo(it->first, it->second - it->first); // Insert the suggestion in its place + memDisclaim(mSuggestionList); LLWString suggestion = utf8str_to_wstring(mSuggestionList[index]); insertStringNoUndo(it->first, utf8str_to_wstring(mSuggestionList[index])); + memClaim(mSuggestionList); + setCursorPos(it->first + (S32)suggestion.length()); break; @@ -1374,7 +1385,7 @@ bool LLTextBase::isMisspelledWord(U32 pos) const void LLTextBase::onSpellCheckSettingsChange() { // Recheck the spelling on every change - mMisspellRanges.clear(); + memDisclaim(mMisspellRanges).clear(); mSpellCheckStart = mSpellCheckEnd = -1; } @@ -1476,7 +1487,7 @@ void LLTextBase::reflow() // use an even number of iterations to avoid user visible oscillation of the layout if(++reflow_count > 2) { - lldebugs << "Breaking out of reflow due to possible infinite loop in " << getName() << llendl; + LL_DEBUGS() << "Breaking out of reflow due to possible infinite loop in " << getName() << LL_ENDL; break; } @@ -1652,7 +1663,7 @@ LLRect LLTextBase::getTextBoundingRect() void LLTextBase::clearSegments() { - mSegments.clear(); + memDisclaim(mSegments).clear(); createDefaultSegment(); } @@ -2109,7 +2120,7 @@ void LLTextBase::setFont(const LLFontGL* font) void LLTextBase::needsReflow(S32 index) { - lldebugs << "reflow on object " << (void*)this << " index = " << mReflowIndex << ", new index = " << index << llendl; + LL_DEBUGS() << "reflow on object " << (void*)this << " index = " << mReflowIndex << ", new index = " << index << LL_ENDL; mReflowIndex = llmin(mReflowIndex, index); } @@ -3151,10 +3162,12 @@ void LLNormalTextSegment::setToolTip(const std::string& tooltip) // we cannot replace a keyword tooltip that's loaded from a file if (mToken) { - llwarns << "LLTextSegment::setToolTip: cannot replace keyword tooltip." << llendl; + LL_WARNS() << "LLTextSegment::setToolTip: cannot replace keyword tooltip." << LL_ENDL; return; } + memDisclaim(mTooltip); mTooltip = tooltip; + memClaim(mTooltip); } bool LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const @@ -3207,14 +3220,14 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin if(getLength() < segment_offset + mStart) { - llinfos << "getLength() < segment_offset + mStart\t getLength()\t" << getLength() << "\tsegment_offset:\t" - << segment_offset << "\tmStart:\t" << mStart << "\tsegments\t" << mEditor.mSegments.size() << "\tmax_chars\t" << max_chars << llendl; + LL_INFOS() << "getLength() < segment_offset + mStart\t getLength()\t" << getLength() << "\tsegment_offset:\t" + << segment_offset << "\tmStart:\t" << mStart << "\tsegments\t" << mEditor.mSegments.size() << "\tmax_chars\t" << max_chars << LL_ENDL; } if(offsetString.length() + 1 < max_chars) { - llinfos << "offsetString.length() + 1 < max_chars\t max_chars:\t" << max_chars << "\toffsetString.length():\t" << offsetString.length() << " getLength() : " - << getLength() << "\tsegment_offset:\t" << segment_offset << "\tmStart:\t" << mStart << "\tsegments\t" << mEditor.mSegments.size() << llendl; + LL_INFOS() << "offsetString.length() + 1 < max_chars\t max_chars:\t" << max_chars << "\toffsetString.length():\t" << offsetString.length() << " getLength() : " + << getLength() << "\tsegment_offset:\t" << segment_offset << "\tmStart:\t" << mStart << "\tsegments\t" << mEditor.mSegments.size() << LL_ENDL; } S32 num_chars = mStyle->getFont()->maxDrawableChars(offsetString.c_str(), @@ -3244,13 +3257,13 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin void LLNormalTextSegment::dump() const { - llinfos << "Segment [" << + LL_INFOS() << "Segment [" << // mColor.mV[VX] << ", " << // mColor.mV[VY] << ", " << // mColor.mV[VZ] << "]\t[" << mStart << ", " << getEnd() << "]" << - llendl; + LL_ENDL; } /*virtual*/ diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 20a73387b5..74dc7f9693 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -51,7 +51,10 @@ class LLUrlMatch; /// includes a start/end offset from the start of the string, a /// style to render with, an optional tooltip, etc. /// -class LLTextSegment : public LLRefCount, public LLMouseHandler +class LLTextSegment +: public LLRefCount, + public LLMouseHandler, + public LLTrace::MemTrackable<LLTextSegment> { public: LLTextSegment(S32 start, S32 end) : mStart(start), mEnd(end){}; @@ -92,10 +95,12 @@ public: /*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const; /*virtual*/ BOOL hasMouseCapture(); - S32 getStart() const { return mStart; } - void setStart(S32 start) { mStart = start; } - S32 getEnd() const { return mEnd; } - void setEnd( S32 end ) { mEnd = end; } + S32 getStart() const { return mStart; } + void setStart(S32 start) { mStart = start; } + S32 getEnd() const { return mEnd; } + void setEnd( S32 end ) { mEnd = end; } + + static LLTrace::MemStatHandle sMemStat; protected: S32 mStart; @@ -325,7 +330,7 @@ public: /*virtual*/ BOOL acceptsTextInput() const { return !mReadOnly; } /*virtual*/ void setColor( const LLColor4& c ); virtual void setReadOnlyColor(const LLColor4 &c); - virtual void handleVisibilityChange( BOOL new_visibility ); + virtual void onVisibilityChange( BOOL new_visibility ); /*virtual*/ void setValue(const LLSD& value ); /*virtual*/ LLTextViewModel* getViewModel() const; @@ -603,7 +608,7 @@ protected: S32 mSelectionStart; S32 mSelectionEnd; LLTimer mTripleClickTimer; - + BOOL mIsSelecting; // Are we in the middle of a drag-select? // spell checking diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 834f213097..36431d3723 100755 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -781,7 +781,7 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) setCursorAtLocalPos( clamped_x, clamped_y, true ); mSelectionEnd = mCursorPos; } - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; + LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (active)" << LL_ENDL; getWindow()->setCursor(UI_CURSOR_IBEAM); handled = TRUE; } @@ -2586,20 +2586,20 @@ BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) instream.getline(tbuf, MAX_STRING); if( 1 != sscanf(tbuf, "Linden text version %d", &version) ) { - llwarns << "Invalid Linden text file header " << llendl; + LL_WARNS() << "Invalid Linden text file header " << LL_ENDL; return FALSE; } if( 1 != version ) { - llwarns << "Invalid Linden text file version: " << version << llendl; + LL_WARNS() << "Invalid Linden text file version: " << version << LL_ENDL; return FALSE; } instream.getline(tbuf, MAX_STRING); if( 0 != sscanf(tbuf, "{") ) { - llwarns << "Invalid Linden text file format" << llendl; + LL_WARNS() << "Invalid Linden text file format" << LL_ENDL; return FALSE; } @@ -2607,13 +2607,13 @@ BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) instream.getline(tbuf, MAX_STRING); if( 1 != sscanf(tbuf, "Text length %d", &text_len) ) { - llwarns << "Invalid Linden text length field" << llendl; + LL_WARNS() << "Invalid Linden text length field" << LL_ENDL; return FALSE; } if( text_len > mMaxTextByteLength ) { - llwarns << "Invalid Linden text length: " << text_len << llendl; + LL_WARNS() << "Invalid Linden text length: " << text_len << LL_ENDL; return FALSE; } @@ -2622,21 +2622,21 @@ BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) char* text = new char[ text_len + 1]; if (text == NULL) { - llerrs << "Memory allocation failure." << llendl; + LL_ERRS() << "Memory allocation failure." << LL_ENDL; return FALSE; } instream.get(text, text_len + 1, '\0'); text[text_len] = '\0'; if( text_len != (S32)strlen(text) )/* Flawfinder: ignore */ { - llwarns << llformat("Invalid text length: %d != %d ",strlen(text),text_len) << llendl;/* Flawfinder: ignore */ + LL_WARNS() << llformat("Invalid text length: %d != %d ",strlen(text),text_len) << LL_ENDL;/* Flawfinder: ignore */ success = FALSE; } instream.getline(tbuf, MAX_STRING); if( success && (0 != sscanf(tbuf, "}")) ) { - llwarns << "Invalid Linden text file format: missing terminal }" << llendl; + LL_WARNS() << "Invalid Linden text file format: missing terminal }" << LL_ENDL; success = FALSE; } @@ -2699,7 +2699,7 @@ void LLTextEditor::resetPreedit() { if (hasSelection()) { - llwarns << "Preedit and selection!" << llendl; + LL_WARNS() << "Preedit and selection!" << LL_ENDL; deselect(); } @@ -2889,7 +2889,7 @@ void LLTextEditor::markAsPreedit(S32 position, S32 length) setCursorPos(position); if (hasPreeditString()) { - llwarns << "markAsPreedit invoked when hasPreeditString is true." << llendl; + LL_WARNS() << "markAsPreedit invoked when hasPreeditString is true." << LL_ENDL; } mPreeditWString = LLWString( getWText(), position, length ); if (length > 0) diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 969e072704..49b6980c81 100755 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -32,10 +32,8 @@ #include "llrect.h" #include "llkeywords.h" #include "llframetimer.h" -#include "lldarray.h" #include "llstyle.h" #include "lleditmenuhandler.h" -#include "lldarray.h" #include "llviewborder.h" // for params #include "lltextbase.h" #include "lltextvalidate.h" diff --git a/indra/llui/lltextparser.cpp b/indra/llui/lltextparser.cpp index 8a85f99e0c..0b36241da0 100755 --- a/indra/llui/lltextparser.cpp +++ b/indra/llui/lltextparser.cpp @@ -228,7 +228,7 @@ bool LLTextParser::saveToDisk(LLSD highlights) std::string filename=getFileName(); if (filename.empty()) { - llwarns << "LLTextParser::saveToDisk() no valid user directory." << llendl; + LL_WARNS() << "LLTextParser::saveToDisk() no valid user directory." << LL_ENDL; return FALSE; } llofstream file; diff --git a/indra/llui/lltoggleablemenu.cpp b/indra/llui/lltoggleablemenu.cpp index 00d52fe10d..ccb92ffbb2 100755 --- a/indra/llui/lltoggleablemenu.cpp +++ b/indra/llui/lltoggleablemenu.cpp @@ -52,7 +52,7 @@ boost::signals2::connection LLToggleableMenu::setVisibilityChangeCallback(const } // virtual -void LLToggleableMenu::handleVisibilityChange (BOOL curVisibilityIn) +void LLToggleableMenu::onVisibilityChange (BOOL curVisibilityIn) { S32 x,y; LLUI::getMousePositionLocal(LLUI::getRootView(), &x, &y); diff --git a/indra/llui/lltoggleablemenu.h b/indra/llui/lltoggleablemenu.h index dfe70cbf54..55a6483021 100755 --- a/indra/llui/lltoggleablemenu.h +++ b/indra/llui/lltoggleablemenu.h @@ -45,7 +45,7 @@ public: boost::signals2::connection setVisibilityChangeCallback( const commit_signal_t::slot_type& cb ); - virtual void handleVisibilityChange (BOOL curVisibilityIn); + virtual void onVisibilityChange (BOOL curVisibilityIn); virtual bool addChild (LLView* view, S32 tab_group = 0); diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 3d9f5cbbc2..8d1017c1b4 100755 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -42,9 +42,9 @@ namespace LLToolBarEnums { - LLLayoutStack::ELayoutOrientation getOrientation(SideType sideType) + LLView::EOrientation getOrientation(SideType sideType) { - LLLayoutStack::ELayoutOrientation orientation = LLLayoutStack::HORIZONTAL; + LLView::EOrientation orientation = LLLayoutStack::HORIZONTAL; if ((sideType == SIDE_LEFT) || (sideType == SIDE_RIGHT)) { @@ -157,7 +157,7 @@ void LLToolBar::createContextMenu() } else { - llwarns << "Unable to load toolbars context menu." << llendl; + LL_WARNS() << "Unable to load toolbars context menu." << LL_ENDL; } } @@ -173,7 +173,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) // Initialize the base object LLUICtrl::initFromParams(p); - LLLayoutStack::ELayoutOrientation orientation = getOrientation(p.side); + LLView::EOrientation orientation = getOrientation(p.side); LLLayoutStack::Params centering_stack_p; centering_stack_p.name = "centering_stack"; @@ -525,7 +525,7 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) int rank = 0; // Convert the toolbar coord into button panel coords - LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); + LLView::EOrientation orientation = getOrientation(mSideType); S32 button_panel_x = 0; S32 button_panel_y = 0; localPointToOtherView(x, y, &button_panel_x, &button_panel_y, mButtonPanel); @@ -644,7 +644,7 @@ void LLToolBar::updateLayoutAsNeeded() { if (!mNeedsLayout) return; - LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); + LLView::EOrientation orientation = getOrientation(mSideType); // our terminology for orientation-agnostic layout is such that // length refers to a distance in the direction we stack the buttons @@ -1063,7 +1063,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, mDragRank = getRankFromPosition(x, y); // Don't DaD if we're dragging a command on itself mDragAndDropTarget = ((orig_rank != RANK_NONE) && ((mDragRank == orig_rank) || ((mDragRank-1) == orig_rank)) ? false : true); - //llinfos << "Merov debug : DaD, rank = " << mDragRank << ", dragged uui = " << inv_item->getUUID() << llendl; + //LL_INFOS() << "Merov debug : DaD, rank = " << mDragRank << ", dragged uui = " << inv_item->getUUID() << LL_ENDL; /* Do the following if you want to animate the button itself LLCommandId dragged_command(inv_item->getUUID()); removeCommand(dragged_command); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 31424a36d4..6936cb37f7 100755 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -125,7 +125,7 @@ namespace LLToolBarEnums SIDE_TOP, }; - LLLayoutStack::ELayoutOrientation getOrientation(SideType sideType); + LLView::EOrientation getOrientation(SideType sideType); } // NOTE: This needs to occur before Param block declaration for proper compilation. diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index f52a3b3323..5e1f12996e 100755 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -476,12 +476,15 @@ void LLToolTipMgr::show(const std::string& msg) void LLToolTipMgr::show(const LLToolTip::Params& params) { + if (!params.styled_message.isProvided() + && (!params.message.isProvided() || params.message().empty())) return; + // fill in default tooltip params from tool_tip.xml LLToolTip::Params params_with_defaults(params); params_with_defaults.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLToolTip>()); if (!params_with_defaults.validateBlock()) { - llwarns << "Could not display tooltip!" << llendl; + LL_WARNS() << "Could not display tooltip!" << LL_ENDL; return; } diff --git a/indra/llui/lltrans.cpp b/indra/llui/lltrans.cpp index 5388069c24..5131f6b704 100755 --- a/indra/llui/lltrans.cpp +++ b/indra/llui/lltrans.cpp @@ -63,8 +63,8 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa std::string xml_filename = "(strings file)"; if (!root->hasName("strings")) { - llerrs << "Invalid root node name in " << xml_filename - << ": was " << root->getName() << ", expected \"strings\"" << llendl; + LL_ERRS() << "Invalid root node name in " << xml_filename + << ": was " << root->getName() << ", expected \"strings\"" << LL_ENDL; } StringTable string_table; @@ -73,7 +73,7 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa if (!string_table.validateBlock()) { - llerrs << "Problem reading strings: " << xml_filename << llendl; + LL_ERRS() << "Problem reading strings: " << xml_filename << LL_ENDL; return false; } @@ -107,8 +107,8 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) std::string xml_filename = "(language strings file)"; if (!root->hasName("strings")) { - llerrs << "Invalid root node name in " << xml_filename - << ": was " << root->getName() << ", expected \"strings\"" << llendl; + LL_ERRS() << "Invalid root node name in " << xml_filename + << ": was " << root->getName() << ", expected \"strings\"" << LL_ENDL; } StringTable string_table; @@ -117,7 +117,7 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) if (!string_table.validateBlock()) { - llerrs << "Problem reading strings: " << xml_filename << llendl; + LL_ERRS() << "Problem reading strings: " << xml_filename << LL_ENDL; return false; } diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h index 128b51d383..a47ce94f08 100755 --- a/indra/llui/lltrans.h +++ b/indra/llui/lltrans.h @@ -28,6 +28,7 @@ #define LL_TRANS_H #include <map> +#include <set> #include "llpointer.h" #include "llstring.h" diff --git a/indra/llui/lltransutil.cpp b/indra/llui/lltransutil.cpp index 80d079cbc8..220cee4c90 100755 --- a/indra/llui/lltransutil.cpp +++ b/indra/llui/lltransutil.cpp @@ -44,7 +44,7 @@ bool LLTransUtil::parseStrings(const std::string& xml_filename, const std::set<s bool success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root, LLDir::ALL_SKINS); if (!success) { - llerrs << "Couldn't load string table " << xml_filename << llendl; + LL_ERRS() << "Couldn't load string table " << xml_filename << LL_ENDL; return false; } @@ -59,7 +59,7 @@ bool LLTransUtil::parseLanguageStrings(const std::string& xml_filename) if (!success) { - llerrs << "Couldn't load localization table " << xml_filename << llendl; + LL_ERRS() << "Couldn't load localization table " << xml_filename << LL_ENDL; return false; } diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 0ddb149738..1f570edd88 100755 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -107,7 +107,7 @@ LLUUID find_ui_sound(const char * namep) LLUUID uuid = LLUUID(NULL); if (!LLUI::sSettingGroups["config"]->controlExists(name)) { - llwarns << "tried to make UI sound for unknown sound name: " << name << llendl; + LL_WARNS() << "tried to make UI sound for unknown sound name: " << name << LL_ENDL; } else { @@ -118,19 +118,19 @@ LLUUID find_ui_sound(const char * namep) { if (LLUI::sSettingGroups["config"]->getBOOL("UISndDebugSpamToggle")) { - llinfos << "UI sound name: " << name << " triggered but silent (null uuid)" << llendl; + LL_INFOS() << "UI sound name: " << name << " triggered but silent (null uuid)" << LL_ENDL; } } else { - llwarns << "UI sound named: " << name << " does not translate to a valid uuid" << llendl; + LL_WARNS() << "UI sound named: " << name << " does not translate to a valid uuid" << LL_ENDL; } } else if (LLUI::sAudioCallback != NULL) { if (LLUI::sSettingGroups["config"]->getBOOL("UISndDebugSpamToggle")) { - llinfos << "UI sound name: " << name << llendl; + LL_INFOS() << "UI sound name: " << name << LL_ENDL; } } } @@ -170,7 +170,7 @@ void LLUI::initClass(const settings_map_t& settings, (get_ptr_in_map(sSettingGroups, std::string("floater")) == NULL) || (get_ptr_in_map(sSettingGroups, std::string("ignores")) == NULL)) { - llerrs << "Failure to initialize configuration groups" << llendl; + LL_ERRS() << "Failure to initialize configuration groups" << LL_ENDL; } sAudioCallback = audio_callback; diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 0a0e0e164e..f7426a703a 100755 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -29,9 +29,11 @@ #define LL_LLUI_H #include "llrect.h" +#include "llcoord.h" #include "llcontrol.h" #include "llcoord.h" -#include "v2math.h" +#include "llcontrol.h" +#include "llglslshader.h" #include "llinitparam.h" #include "llregistry.h" #include "llrender2dutils.h" @@ -40,8 +42,8 @@ #include "lluicolortable.h" #include "lluiimage.h" #include <boost/signals2.hpp> -#include "lllazyvalue.h" #include "llframetimer.h" +#include "v2math.h" #include <limits> // for initparam specialization @@ -53,6 +55,52 @@ class LLWindow; class LLView; class LLHelp; + +// this enum is used by the llview.h (viewer) and the llassetstorage.h (viewer and sim) +enum EDragAndDropType +{ + DAD_NONE = 0, + DAD_TEXTURE = 1, + DAD_SOUND = 2, + DAD_CALLINGCARD = 3, + DAD_LANDMARK = 4, + DAD_SCRIPT = 5, + DAD_CLOTHING = 6, + DAD_OBJECT = 7, + DAD_NOTECARD = 8, + DAD_CATEGORY = 9, + DAD_ROOT_CATEGORY = 10, + DAD_BODYPART = 11, + DAD_ANIMATION = 12, + DAD_GESTURE = 13, + DAD_LINK = 14, + DAD_MESH = 15, + DAD_WIDGET = 16, + DAD_PERSON = 17, + DAD_COUNT = 18, // number of types in this enum +}; + +// Reasons for drags to be denied. +// ordered by priority for multi-drag +enum EAcceptance +{ + ACCEPT_POSTPONED, // we are asynchronously determining acceptance + ACCEPT_NO, // Uninformative, general purpose denial. + ACCEPT_NO_LOCKED, // Operation would be valid, but permissions are set to disallow it. + ACCEPT_YES_COPY_SINGLE, // We'll take a copy of a single item + ACCEPT_YES_SINGLE, // Accepted. OK to drag and drop single item here. + ACCEPT_YES_COPY_MULTI, // We'll take a copy of multiple items + ACCEPT_YES_MULTI // Accepted. OK to drag and drop multiple items here. +}; + +enum EAddPosition +{ + ADD_TOP, + ADD_BOTTOM, + ADD_DEFAULT +}; + + void make_ui_sound(const char* name); void make_ui_sound_deferred(const char * name); @@ -123,7 +171,7 @@ public: { if (mMin > mMax) { - llwarns << "Bad interval range (" << mMin << ", " << mMax << ")" << llendl; + LL_WARNS() << "Bad interval range (" << mMin << ", " << mMax << ")" << LL_ENDL; // since max is usually the most dangerous one to ignore (buffer overflow, etc), prefer it // in the case of a malformed range mMin = mMax; @@ -362,7 +410,7 @@ private: static void initClass() { - llerrs << "No static initClass() method defined for " << typeid(T).name() << llendl; + LL_ERRS() << "No static initClass() method defined for " << typeid(T).name() << LL_ENDL; } }; @@ -377,7 +425,7 @@ private: static void destroyClass() { - llerrs << "No static destroyClass() method defined for " << typeid(T).name() << llendl; + LL_ERRS() << "No static destroyClass() method defined for " << typeid(T).name() << LL_ENDL; } }; diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp index ffeff15968..244f0c6f00 100755 --- a/indra/llui/lluicolortable.cpp +++ b/indra/llui/lluicolortable.cpp @@ -117,7 +117,7 @@ void LLUIColorTable::insertFromParams(const Params& p, string_color_map_t& table unresolved_refs.erase(iter->second); } - llwarns << warning + ending_ref << llendl; + LL_WARNS() << warning + ending_ref << LL_ENDL; break; } @@ -156,7 +156,7 @@ void LLUIColorTable::insertFromParams(const Params& p, string_color_map_t& table iter != visited_refs.end(); ++iter) { - llwarns << iter->first << " references a non-existent color" << llendl; + LL_WARNS() << iter->first << " references a non-existent color" << LL_ENDL; unresolved_refs.erase(iter->second); } @@ -293,13 +293,13 @@ bool LLUIColorTable::loadFromFilename(const std::string& filename, string_color_ if(!LLXMLNode::parseFile(filename, root, NULL)) { - llwarns << "Unable to parse color file " << filename << llendl; + LL_WARNS() << "Unable to parse color file " << filename << LL_ENDL; return false; } if(!root->hasName("colors")) { - llwarns << filename << " is not a valid color definition file" << llendl; + LL_WARNS() << filename << " is not a valid color definition file" << LL_ENDL; return false; } @@ -313,7 +313,7 @@ bool LLUIColorTable::loadFromFilename(const std::string& filename, string_color_ } else { - llwarns << filename << " failed to load" << llendl; + LL_WARNS() << filename << " failed to load" << LL_ENDL; return false; } diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index b9c843e931..abcd5da6c4 100755 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -118,6 +118,7 @@ LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) mDoubleClickSignal(NULL), mTransparencyType(TT_DEFAULT) { + memClaim(viewmodel.get()); } void LLUICtrl::initFromParams(const Params& p) @@ -211,7 +212,7 @@ LLUICtrl::~LLUICtrl() if( gFocusMgr.getTopCtrl() == this ) { - llwarns << "UI Control holding top ctrl deleted: " << getName() << ". Top view removed." << llendl; + LL_WARNS() << "UI Control holding top ctrl deleted: " << getName() << ". Top view removed." << LL_ENDL; gFocusMgr.removeTopCtrlWithoutCallback( this ); } @@ -257,7 +258,7 @@ LLUICtrl::commit_signal_t::slot_type LLUICtrl::initCommitCallback(const CommitCa } else if (!function_name.empty()) { - llwarns << "No callback found for: '" << function_name << "' in control: " << getName() << llendl; + LL_WARNS() << "No callback found for: '" << function_name << "' in control: " << getName() << LL_ENDL; } } return default_commit_handler; @@ -451,7 +452,7 @@ void LLUICtrl::setControlVariable(LLControlVariable* control) if (mControlVariable) { //RN: this will happen in practice, should we try to avoid it? - //llwarns << "setControlName called twice on same control!" << llendl; + //LL_WARNS() << "setControlName called twice on same control!" << LL_ENDL; mControlConnection.disconnect(); // disconnect current signal mControlVariable = NULL; } @@ -940,7 +941,7 @@ boost::signals2::connection LLUICtrl::setCommitCallback( boost::function<void (L } boost::signals2::connection LLUICtrl::setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb ) { - if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + if (!mValidateSignal) mValidateSignal = memClaim(new enable_signal_t()); return mValidateSignal->connect(boost::bind(cb, _2)); } @@ -1003,55 +1004,55 @@ boost::signals2::connection LLUICtrl::setValidateCallback(const EnableCallbackPa boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb ) { - if (!mCommitSignal) mCommitSignal = new commit_signal_t(); + if (!mCommitSignal) mCommitSignal = memClaim(new commit_signal_t()); return mCommitSignal->connect(cb); } boost::signals2::connection LLUICtrl::setValidateCallback( const enable_signal_t::slot_type& cb ) { - if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + if (!mValidateSignal) mValidateSignal = memClaim(new enable_signal_t()); return mValidateSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { - if (!mMouseEnterSignal) mMouseEnterSignal = new commit_signal_t(); + if (!mMouseEnterSignal) mMouseEnterSignal = memClaim(new commit_signal_t()); return mMouseEnterSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { - if (!mMouseLeaveSignal) mMouseLeaveSignal = new commit_signal_t(); + if (!mMouseLeaveSignal) mMouseLeaveSignal = memClaim(new commit_signal_t()); return mMouseLeaveSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseDownCallback( const mouse_signal_t::slot_type& cb ) { - if (!mMouseDownSignal) mMouseDownSignal = new mouse_signal_t(); + if (!mMouseDownSignal) mMouseDownSignal = memClaim(new mouse_signal_t()); return mMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseUpCallback( const mouse_signal_t::slot_type& cb ) { - if (!mMouseUpSignal) mMouseUpSignal = new mouse_signal_t(); + if (!mMouseUpSignal) mMouseUpSignal = memClaim(new mouse_signal_t()); return mMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ) { - if (!mRightMouseDownSignal) mRightMouseDownSignal = new mouse_signal_t(); + if (!mRightMouseDownSignal) mRightMouseDownSignal = memClaim(new mouse_signal_t()); return mRightMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ) { - if (!mRightMouseUpSignal) mRightMouseUpSignal = new mouse_signal_t(); + if (!mRightMouseUpSignal) mRightMouseUpSignal = memClaim(new mouse_signal_t()); return mRightMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setDoubleClickCallback( const mouse_signal_t::slot_type& cb ) { - if (!mDoubleClickSignal) mDoubleClickSignal = new mouse_signal_t(); + if (!mDoubleClickSignal) mDoubleClickSignal = memClaim(new mouse_signal_t()); return mDoubleClickSignal->connect(cb); } diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 60fee47ae0..291da2ce48 100755 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -131,11 +131,11 @@ void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, const wid // for the child widget // You might need to add something like: // static ParentWidgetRegistry::Register<ChildWidgetType> register("child_widget_name"); - llwarns << child_name << " is not a valid child of " << node->getName()->mString << llendl; + LL_WARNS() << child_name << " is not a valid child of " << node->getName()->mString << LL_ENDL; } else { - llwarns << "Could not create widget named " << child_node->getName()->mString << llendl; + LL_WARNS() << "Could not create widget named " << child_node->getName()->mString << LL_ENDL; } } diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 876bb5ef46..87b3937417 100755 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -170,8 +170,8 @@ public: LLXMLNodePtr root_node; if (!LLUICtrlFactory::getLayeredXMLNode(filename, root_node)) - { - llwarns << "Couldn't parse XUI file: " << instance().getCurFileName() << llendl; + { + LL_WARNS() << "Couldn't parse XUI file: " << instance().getCurFileName() << LL_ENDL; goto fail; } @@ -182,7 +182,7 @@ public: // not of right type, so delete it if (!widget) { - llwarns << "Widget in " << filename << " was of type " << typeid(view).name() << " instead of expected type " << typeid(T).name() << llendl; + LL_WARNS() << "Widget in " << filename << " was of type " << typeid(view).name() << " instead of expected type " << typeid(T).name() << LL_ENDL; delete view; view = NULL; } @@ -225,7 +225,7 @@ private: if (!params.validateBlock()) { - llwarns << getInstance()->getCurFileName() << ": Invalid parameter block for " << typeid(T).name() << llendl; + LL_WARNS() << getInstance()->getCurFileName() << ": Invalid parameter block for " << typeid(T).name() << LL_ENDL; //return NULL; } @@ -259,10 +259,8 @@ private: // We always want to output top-left coordinates typename T::Params output_params(params); T::setupParamsForExport(output_params, parent); - // Export only the differences between this any default params - typename T::Params default_params(getDefaultParams<T>()); copyName(node, output_node); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &getDefaultParams<T>()); } // Apply layout transformations, usually munging rect diff --git a/indra/llui/lluistring.cpp b/indra/llui/lluistring.cpp index c4e073ccdb..23fc53ea88 100755 --- a/indra/llui/lluistring.cpp +++ b/indra/llui/lluistring.cpp @@ -26,6 +26,8 @@ #include "linden_common.h" #include "lluistring.h" + +#include "llfasttimer.h" #include "llsd.h" #include "lltrans.h" diff --git a/indra/llui/lluistring.h b/indra/llui/lluistring.h index cb40c85582..07e02de6d8 100755 --- a/indra/llui/lluistring.h +++ b/indra/llui/lluistring.h @@ -42,12 +42,12 @@ // LLUIString mMessage("Welcome [USERNAME] to [SECONDLIFE]!"); // mMessage.setArg("[USERNAME]", "Steve"); // mMessage.setArg("[SECONDLIFE]", "Second Life"); -// llinfos << mMessage.getString() << llendl; // outputs "Welcome Steve to Second Life" +// LL_INFOS() << mMessage.getString() << LL_ENDL; // outputs "Welcome Steve to Second Life" // mMessage.setArg("[USERNAME]", "Joe"); -// llinfos << mMessage.getString() << llendl; // outputs "Welcome Joe to Second Life" +// LL_INFOS() << mMessage.getString() << LL_ENDL; // outputs "Welcome Joe to Second Life" // mMessage = "Bienvenido a la [SECONDLIFE] [USERNAME]" // mMessage.setArg("[SECONDLIFE]", "Segunda Vida"); -// llinfos << mMessage.getString() << llendl; // outputs "Bienvenido a la Segunda Vida Joe" +// LL_INFOS() << mMessage.getString() << LL_ENDL; // outputs "Bienvenido a la Segunda Vida Joe" // Implementation Notes: // Attempting to have operator[](const std::string& s) return mArgs[s] fails because we have diff --git a/indra/llui/llundo.cpp b/indra/llui/llundo.cpp index 06b0514223..7c4c183a30 100755 --- a/indra/llui/llundo.cpp +++ b/indra/llui/llundo.cpp @@ -51,7 +51,7 @@ LLUndoBuffer::LLUndoBuffer( LLUndoAction (*create_func()), S32 initial_count ) mActions[i] = create_func(); if (!mActions[i]) { - llerrs << "Unable to create action for undo buffer" << llendl; + LL_ERRS() << "Unable to create action for undo buffer" << LL_ENDL; } } } diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 99ee688888..bef9034e55 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -785,7 +785,7 @@ std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelC if (path_parts < 3) // no parcel id { - llwarns << "Failed to parse url [" << url << "]" << llendl; + LL_WARNS() << "Failed to parse url [" << url << "]" << LL_ENDL; return url; } @@ -925,7 +925,7 @@ std::string LLUrlEntryRegion::getLabel(const std::string &url, const LLUrlLabelC if (path_parts < 3) // no region name { - llwarns << "Failed to parse url [" << url << "]" << llendl; + LL_WARNS() << "Failed to parse url [" << url << "]" << LL_ENDL; return url; } diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index 8c6c32178a..d4684e2e1e 100755 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -32,6 +32,7 @@ #include "lluicolor.h" #include "llstyle.h" +#include "llavatarname.h" #include "llhost.h" // for resolving parcel name by parcel id #include <boost/signals2.hpp> diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 3613a40e2c..ae62d72f73 100755 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -30,7 +30,6 @@ #define LLVIEW_CPP #include "llview.h" -#include <cassert> #include <sstream> #include <boost/tokenizer.hpp> #include <boost/foreach.hpp> @@ -70,6 +69,7 @@ LLView* LLView::sPreviewClickedElement = NULL; BOOL LLView::sDrawPreviewHighlights = FALSE; S32 LLView::sLastLeftXML = S32_MIN; S32 LLView::sLastBottomXML = S32_MIN; +LLTrace::MemStatHandle LLView::sMemStat("LLView"); std::vector<LLViewDrawContext*> LLViewDrawContext::sDrawContextStack; LLView::DrilldownFunc LLView::sDrilldown = @@ -85,6 +85,16 @@ template class LLView* LLView::getChild<class LLView>( static LLDefaultChildRegistry::Register<LLView> r("view"); +namespace LLInitParam +{ + void TypeValues<LLView::EOrientation>::declareValues() + { + declare("horizontal", LLView::HORIZONTAL); + declare("vertical", LLView::VERTICAL); + } +} + + LLView::Follows::Follows() : string(""), flags("flags", FOLLOWS_LEFT | FOLLOWS_TOP) @@ -149,10 +159,10 @@ LLView::LLView(const LLView::Params& p) LLView::~LLView() { dirtyRect(); - //llinfos << "Deleting view " << mName << ":" << (void*) this << llendl; + //LL_INFOS() << "Deleting view " << mName << ":" << (void*) this << LL_ENDL; if (LLView::sIsDrawing) { - lldebugs << "Deleting view " << mName << " during UI draw() phase" << llendl; + LL_DEBUGS() << "Deleting view " << mName << " during UI draw() phase" << LL_ENDL; } // llassert(LLView::sIsDrawing == FALSE); @@ -160,7 +170,7 @@ LLView::~LLView() if( hasMouseCapture() ) { - //llwarns << "View holding mouse capture deleted: " << getName() << ". Mouse capture removed." << llendl; + //LL_WARNS() << "View holding mouse capture deleted: " << getName() << ". Mouse capture removed." << LL_ENDL; gFocusMgr.removeMouseCaptureWithoutCallback( this ); } @@ -290,7 +300,7 @@ bool LLView::addChild(LLView* child, S32 tab_group) } if (mParentView == child) { - llerrs << "Adding view " << child->getName() << " as child of itself" << llendl; + LL_ERRS() << "Adding view " << child->getName() << " as child of itself" << LL_ENDL; } // remove from current parent @@ -351,7 +361,7 @@ void LLView::removeChild(LLView* child) } else { - llwarns << "\"" << child->getName() << "\" is not a child of " << getName() << llendl; + LL_WARNS() << "\"" << child->getName() << "\" is not a child of " << getName() << LL_ENDL; } updateBoundingRect(); } @@ -633,21 +643,21 @@ void LLView::setVisible(BOOL visible) { // tell all children of this view that the visibility may have changed dirtyRect(); - handleVisibilityChange( visible ); + onVisibilityChange( visible ); } updateBoundingRect(); } } // virtual -void LLView::handleVisibilityChange ( BOOL new_visibility ) +void LLView::onVisibilityChange ( BOOL new_visibility ) { BOOST_FOREACH(LLView* viewp, mChildList) { // only views that are themselves visible will have their overall visibility affected by their ancestors if (viewp->getVisible()) { - viewp->handleVisibilityChange ( new_visibility ); + viewp->onVisibilityChange ( new_visibility ); } } } @@ -677,12 +687,12 @@ BOOL LLView::handleHover(S32 x, S32 y, MASK mask) void LLView::onMouseEnter(S32 x, S32 y, MASK mask) { - //llinfos << "Mouse entered " << getName() << llendl; + //LL_INFOS() << "Mouse entered " << getName() << LL_ENDL; } void LLView::onMouseLeave(S32 x, S32 y, MASK mask) { - //llinfos << "Mouse left " << getName() << llendl; + //LL_INFOS() << "Mouse left " << getName() << LL_ENDL; } bool LLView::visibleAndContains(S32 local_x, S32 local_y) @@ -717,7 +727,7 @@ LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& m { if (LLView::sDebugKeys) { - llinfos << desc << " handled by " << viewp->getName() << llendl; + LL_INFOS() << desc << " handled by " << viewp->getName() << LL_ENDL; } return viewp; } @@ -910,7 +920,7 @@ BOOL LLView::handleKey(KEY key, MASK mask, BOOL called_from_parent) handled = handleKeyHere( key, mask ); if (handled && LLView::sDebugKeys) { - llinfos << "Key handled by " << getName() << llendl; + LL_INFOS() << "Key handled by " << getName() << LL_ENDL; } } } @@ -947,7 +957,7 @@ BOOL LLView::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent) handled = handleUnicodeCharHere(uni_char); if (handled && LLView::sDebugKeys) { - llinfos << "Unicode key handled by " << getName() << llendl; + LL_INFOS() << "Unicode key handled by " << getName() << LL_ENDL; } } } @@ -1120,7 +1130,7 @@ void LLView::drawChildren() // Check for bogus rectangle if (!getRect().isValid()) { - llwarns << "Bogus rectangle for " << getName() << " with " << mRect << llendl; + LL_WARNS() << "Bogus rectangle for " << getName() << " with " << mRect << LL_ENDL; } } } @@ -1990,7 +2000,7 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna } break; default: - llerrs << "Invalid snap edge" << llendl; + LL_ERRS() << "Invalid snap edge" << LL_ENDL; } } @@ -2092,7 +2102,7 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna } break; default: - llerrs << "Invalid snap edge" << llendl; + LL_ERRS() << "Invalid snap edge" << LL_ENDL; } } } @@ -2419,7 +2429,7 @@ static S32 invert_vertical(S32 y, LLView* parent) } else { - llwarns << "Attempting to convert layout to top-left with no parent" << llendl; + LL_WARNS() << "Attempting to convert layout to top-left with no parent" << LL_ENDL; return y; } } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 15b85a6418..e224233c3c 100755 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -42,7 +42,6 @@ #include "llui.h" #include "lluistring.h" #include "llviewquery.h" -#include "stdenums.h" #include "lluistring.h" #include "llcursortypes.h" #include "lluictrlfactory.h" @@ -67,6 +66,7 @@ const BOOL NOT_MOUSE_OPAQUE = FALSE; const U32 GL_NAME_UI_RESERVED = 2; + // maintains render state during traversal of UI tree class LLViewDrawContext { @@ -100,9 +100,13 @@ class LLView : public LLMouseHandler, // handles mouse events public LLFocusableElement, // handles keyboard events public LLMortician, // lazy deletion - public LLHandleProvider<LLView> // passes out weak references to self + public LLHandleProvider<LLView>, // passes out weak references to self + public LLTrace::MemTrackable<LLView> // track memory usage { public: + + enum EOrientation { HORIZONTAL, VERTICAL, ORIENTATION_COUNT }; + struct Follows : public LLInitParam::ChoiceBlock<Follows> { Alternative<std::string> string; @@ -303,7 +307,7 @@ public: virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); - virtual void handleVisibilityChange ( BOOL new_visibility ); + virtual void onVisibilityChange ( BOOL new_visibility ); void pushVisible(BOOL visible) { mLastVisible = mVisible; setVisible(visible); } void popVisible() { setVisible(mLastVisible); } @@ -671,8 +675,19 @@ public: static S32 sLastLeftXML; static S32 sLastBottomXML; static BOOL sForceReshape; + static LLTrace::MemStatHandle sMemStat; }; +namespace LLInitParam +{ +template<> +struct TypeValues<LLView::EOrientation> : public LLInitParam::TypeValuesHelper<LLView::EOrientation> +{ + static void declareValues(); +}; +} + + class LLCompareByTabOrder { public: @@ -694,7 +709,7 @@ template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) co // did we find *something* with that name? if (child) { - llwarns << "Found child named \"" << name << "\" but of wrong type " << typeid(*child).name() << ", expecting " << typeid(T*).name() << llendl; + LL_WARNS() << "Found child named \"" << name << "\" but of wrong type " << typeid(*child).name() << ", expecting " << typeid(T*).name() << LL_ENDL; } result = getDefaultWidget<T>(name); if (!result) @@ -706,11 +721,11 @@ template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) co // *NOTE: You cannot call mFoo = getChild<LLFoo>("bar") // in a floater or panel constructor. The widgets will not // be ready. Instead, put it in postBuild(). - llwarns << "Making dummy " << typeid(T).name() << " named \"" << name << "\" in " << getName() << llendl; + LL_WARNS() << "Making dummy " << typeid(T).name() << " named \"" << name << "\" in " << getName() << LL_ENDL; } else { - llwarns << "Failed to create dummy " << typeid(T).name() << llendl; + LL_WARNS() << "Failed to create dummy " << typeid(T).name() << LL_ENDL; return NULL; } diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index a9f8acc440..901260bec8 100755 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -35,6 +35,8 @@ // external library headers // other Linden headers +LLTrace::MemStatHandle LLViewModel::sMemStat("LLViewModel"); + /// LLViewModel::LLViewModel() : mDirty(false) @@ -80,7 +82,10 @@ LLTextViewModel::LLTextViewModel(const LLSD& value) void LLTextViewModel::setValue(const LLSD& value) { LLViewModel::setValue(value); + memDisclaim(mDisplay); mDisplay = utf8str_to_wstring(value.asString()); + memClaim(mDisplay); + // mDisplay and mValue agree mUpdateFromDisplay = false; } @@ -91,7 +96,9 @@ void LLTextViewModel::setDisplay(const LLWString& value) // and do the utf8str_to_wstring() to get the corresponding mDisplay // value. But a text editor might want to edit the display string // directly, then convert back to UTF8 on commit. + memDisclaim(mDisplay); mDisplay = value; + memClaim(mDisplay); mDirty = true; // Don't immediately convert to UTF8 -- do it lazily -- we expect many // more setDisplay() calls than getValue() calls. Just flag that it needs diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index ef2e314799..a0a13267ac 100755 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -37,8 +37,9 @@ #include "llpointer.h" #include "llsd.h" #include "llrefcount.h" -#include "stdenums.h" #include "llstring.h" +#include "lltrace.h" +#include "llui.h" #include <string> class LLScrollListItem; @@ -60,7 +61,9 @@ typedef LLPointer<LLListViewModel> LLListViewModelPtr; * LLViewModel data. This way, the LLViewModel is quietly deleted when the * last referencing widget is destroyed. */ -class LLViewModel: public LLRefCount +class LLViewModel +: public LLRefCount, + public LLTrace::MemTrackable<LLViewModel> { public: LLViewModel(); @@ -80,6 +83,8 @@ public: // void setDirty() { mDirty = true; } + static LLTrace::MemStatHandle sMemStat; + protected: LLSD mValue; bool mDirty; diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 6322da9123..6a1f937340 100755 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -29,7 +29,7 @@ #include "llxuiparser.h" #include "llxmlnode.h" - +#include "llfasttimer.h" #ifdef LL_STANDALONE #include <expat.h> #else @@ -38,6 +38,7 @@ #include <fstream> #include <boost/tokenizer.hpp> +#include <boost/bind.hpp> //#include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/classic_core.hpp> @@ -334,6 +335,8 @@ LLXSDWriter::LLXSDWriter() registerInspectFunc<LLSD>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:string", _1, _2, _3, _4)); } +LLXSDWriter::~LLXSDWriter() {} + void LLXSDWriter::writeXSD(const std::string& type_name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace) { Schema schema(xml_namespace); @@ -858,11 +861,11 @@ bool LLXUIParser::readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& blo return any_parsed; } -void LLXUIParser::writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock &block, const LLInitParam::BaseBlock* diff_block) +void LLXUIParser::writeXUIImpl(LLXMLNodePtr node, const LLInitParam::BaseBlock &block, const LLInitParam::predicate_rule_t rules, const LLInitParam::BaseBlock* diff_block) { mWriteRootNode = node; name_stack_t name_stack = Parser::name_stack_t(); - block.serializeBlock(*this, name_stack, diff_block); + block.serializeBlock(*this, name_stack, rules, diff_block); mOutNodes.clear(); } @@ -1310,7 +1313,7 @@ void LLXUIParser::parserWarning(const std::string& message) { #ifdef LL_WINDOWS // use Visual Studio friendly formatting of output message for easy access to originating xml - LL_WINDOWS_OUTPUT_DEBUG(llformat("%s(%d):\t%s", mCurFileName.c_str(), mCurReadNode->getLineNumber(), message.c_str())); + LL_INFOS() << llformat("%s(%d):\t%s", mCurFileName.c_str(), mCurReadNode->getLineNumber(), message.c_str()) << LL_ENDL; #else Parser::parserWarning(message); #endif @@ -1319,8 +1322,8 @@ void LLXUIParser::parserWarning(const std::string& message) void LLXUIParser::parserError(const std::string& message) { #ifdef LL_WINDOWS - // use Visual Studio friendly formatting of output message for easy access to originating xml - LL_WINDOWS_OUTPUT_DEBUG(llformat("%s(%d):\t%s", mCurFileName.c_str(), mCurReadNode->getLineNumber(), message.c_str())); + // use Visual Studio friendly formatting of output message for easy access to originating xml + LL_INFOS() << llformat("%s(%d):\t%s", mCurFileName.c_str(), mCurReadNode->getLineNumber(), message.c_str()) << LL_ENDL; #else Parser::parserError(message); #endif @@ -1638,7 +1641,7 @@ void LLSimpleXUIParser::parserWarning(const std::string& message) { #ifdef LL_WINDOWS // use Visual Studio friendly formatting of output message for easy access to originating xml - LL_WINDOWS_OUTPUT_DEBUG(llformat("%s(%d):\t%s", mCurFileName.c_str(), LINE_NUMBER_HERE, message.c_str())); + LL_INFOS() << llformat("%s(%d):\t%s", mCurFileName.c_str(), LINE_NUMBER_HERE, message.c_str()) << LL_ENDL; #else Parser::parserWarning(message); #endif @@ -1648,7 +1651,7 @@ void LLSimpleXUIParser::parserError(const std::string& message) { #ifdef LL_WINDOWS // use Visual Studio friendly formatting of output message for easy access to originating xml - LL_WINDOWS_OUTPUT_DEBUG(llformat("%s(%d):\t%s", mCurFileName.c_str(), LINE_NUMBER_HERE, message.c_str())); + LL_INFOS() << llformat("%s(%d):\t%s", mCurFileName.c_str(), LINE_NUMBER_HERE, message.c_str()) << LL_ENDL; #else Parser::parserError(message); #endif diff --git a/indra/llui/llxuiparser.h b/indra/llui/llxuiparser.h index e48663e5cc..ad2a39cab7 100755 --- a/indra/llui/llxuiparser.h +++ b/indra/llui/llxuiparser.h @@ -29,21 +29,15 @@ #include "llinitparam.h" #include "llregistry.h" -#include "llpointer.h" +#include "llxmlnode.h" #include <boost/function.hpp> #include <iosfwd> #include <stack> #include <set> - - class LLView; - -typedef LLPointer<class LLXMLNode> LLXMLNodePtr; - - // lookup widget type by name class LLWidgetTypeRegistry : public LLRegistrySingleton<std::string, const std::type_info*, LLWidgetTypeRegistry> @@ -59,8 +53,6 @@ class LLChildRegistryRegistry : public LLRegistrySingleton<const std::type_info*, widget_registry_t, LLChildRegistryRegistry> {}; - - class LLXSDWriter : public LLInitParam::Parser { LOG_CLASS(LLXSDWriter); @@ -70,6 +62,7 @@ public: /*virtual*/ std::string getCurrentElementName() { return LLStringUtil::null; } LLXSDWriter(); + ~LLXSDWriter(); protected: void writeAttribute(const std::string& type, const Parser::name_stack_t&, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values); @@ -109,9 +102,26 @@ public: /*virtual*/ void parserError(const std::string& message); void readXUI(LLXMLNodePtr node, LLInitParam::BaseBlock& block, const std::string& filename = LLStringUtil::null, bool silent=false); - void writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const LLInitParam::BaseBlock* diff_block = NULL); + template<typename BLOCK> + void writeXUI(LLXMLNodePtr node, + const BLOCK& block, + const LLInitParam::predicate_rule_t rules = LLInitParam::default_parse_rules(), + const LLInitParam::BaseBlock* diff_block = NULL) + { + if (!diff_block + && !rules.isAmbivalent(LLInitParam::HAS_DEFAULT_VALUE)) + { + diff_block = &LLInitParam::defaultValue<BLOCK>(); + } + writeXUIImpl(node, block, rules, diff_block); + } private: + LLXUIParser(const LLXUIParser& other); // no-copy + void writeXUIImpl(LLXMLNodePtr node, + const LLInitParam::BaseBlock& block, + const LLInitParam::predicate_rule_t rules, + const LLInitParam::BaseBlock* diff_block); bool readXUIImpl(LLXMLNodePtr node, LLInitParam::BaseBlock& block); bool readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block); |