diff options
Diffstat (limited to 'indra/llui')
105 files changed, 1819 insertions, 1471 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 589ceac501..52738aeb6f 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 @@ -145,6 +144,7 @@ set(llui_HEADER_FILES llbutton.h llcallbackmap.h llchatentry.h + llchat.h llcheckboxctrl.h llclipboard.h llcombobox.h @@ -286,7 +286,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 3cfe5ac57f..093d91d44d 100755 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -253,7 +253,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()) @@ -595,7 +595,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; } @@ -782,12 +782,12 @@ void LLButton::draw() if (use_glow_effect) { mCurGlowStrength = lerp(mCurGlowStrength, - mFlashing ? (mFlashingTimer->isCurrentlyHighlighted() || !mFlashingTimer->isFlashingInProgress() || mNeedsHighlight? 1.0 : 0.0) : mHoverGlowStrength, - LLCriticalDamp::getInterpolant(0.05f)); + mFlashing ? (mFlashingTimer->isCurrentlyHighlighted() || !mFlashingTimer->isFlashingInProgress() || mNeedsHighlight? 1.f : 0.f) : 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 button image, if available. @@ -820,7 +820,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); } @@ -1044,7 +1044,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.cpp b/indra/llui/llflashtimer.cpp index e49628acd5..6d9c429b08 100755 --- a/indra/llui/llflashtimer.cpp +++ b/indra/llui/llflashtimer.cpp @@ -23,29 +23,27 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -#include "../newview/llviewerprecompiledheaders.h" - #include "llflashtimer.h" -#include "../newview/llviewercontrol.h" #include "lleventtimer.h" +#include "llui.h" LLFlashTimer::LLFlashTimer(callback_t cb, S32 count, F32 period) - : LLEventTimer(period) - , mCallback(cb) - , mCurrentTickCount(0) - , mIsFlashingInProgress(false) - , mIsCurrentlyHighlighted(false) - , mUnset(false) +: LLEventTimer(period), + mCallback(cb), + mCurrentTickCount(0), + mIsFlashingInProgress(false), + mIsCurrentlyHighlighted(false), + mUnset(false) { mEventTimer.stop(); // By default use settings from settings.xml to be able change them via Debug settings. See EXT-5973. // Due to Timer is implemented as derived class from EventTimer it is impossible to change period // in runtime. So, both settings are made as required restart. - mFlashCount = 2 * ((count > 0) ? count : gSavedSettings.getS32("FlashCount")); + mFlashCount = 2 * ((count > 0) ? count : LLUI::sSettingGroups["config"]->getS32("FlashCount")); if (mPeriod <= 0) { - mPeriod = gSavedSettings.getF32("FlashPeriod"); + mPeriod = LLUI::sSettingGroups["config"]->getF32("FlashPeriod"); } } 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 6e6bcd6ab5..8efd9ba3d0 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()) @@ -587,7 +587,7 @@ LLControlGroup* LLFloater::getControlGroup() void LLFloater::setVisible( BOOL visible ) { - LLPanel::setVisible(visible); // calls handleVisibilityChange() + LLPanel::setVisible(visible); // calls onVisibilityChange() if( visible && mFirstLook ) { mFirstLook = FALSE; @@ -630,24 +630,24 @@ 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() << " full path: " << getPathname() << llendl; + LL_INFOS() << "Opening floater " << getName() << " full path: " << getPathname() << LL_ENDL; LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), true,"floater"); // Last param is event subtype or empty string mKey = key; // in case we need to open ourselves again - + if (getSoundFlags() != SILENT // don't play open sound for hosted (tabbed) windows && !getHost() @@ -698,7 +698,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; LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), false,"floater"); // Last param is event subtype or empty string if (app_quitting) { @@ -796,7 +796,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(); @@ -1095,7 +1095,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; } @@ -1150,11 +1150,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(); @@ -1549,7 +1549,7 @@ BOOL LLFloater::handleScrollWheel(S32 x, S32 y, S32 clicks) // virtual BOOL LLFloater::handleMouseUp(S32 x, S32 y, MASK mask) { - lldebugs << "LLFloater::handleMouseUp calling LLPanel (really LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << llendl; + LL_DEBUGS() << "LLFloater::handleMouseUp calling LLPanel (really LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL; BOOL handled = LLPanel::handleMouseUp(x,y,mask); // Not implemented in LLPanel so this actually calls LLView if (handled) { LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); @@ -2924,13 +2924,6 @@ void LLFloaterView::syncFloaterTabOrder() } } } - - // sync draw order to tab order - for ( child_list_const_reverse_iter_t child_it = getChildList()->rbegin(); child_it != getChildList()->rend(); ++child_it) - { - LLFloater* floaterp = (LLFloater*)*child_it; - moveChildToFrontOfTabGroup(floaterp); - } } LLFloater* LLFloaterView::getParentFloater(LLView* viewp) const @@ -3133,8 +3126,8 @@ boost::signals2::connection LLFloater::setCloseCallback( const commit_signal_t:: return mCloseSignal.connect(cb); } -LLFastTimer::DeclareTimer POST_BUILD("Floater Post Build"); -static LLFastTimer::DeclareTimer FTM_EXTERNAL_FLOATER_LOAD("Load Extern Floater Reference"); +LLTrace::BlockTimerStatHandle POST_BUILD("Floater Post Build"); +static LLTrace::BlockTimerStatHandle FTM_EXTERNAL_FLOATER_LOAD("Load Extern Floater Reference"); bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node) { @@ -3158,16 +3151,16 @@ 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; } LLUICtrlFactory::instance().pushFileName(xml_filename); - LLFastTimer _(FTM_EXTERNAL_FLOATER_LOAD); + LL_RECORD_BLOCK_TIME(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; } @@ -3188,9 +3181,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 @@ -3242,14 +3234,14 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str BOOL result; { - LLFastTimer ft(POST_BUILD); + LL_RECORD_BLOCK_TIME(POST_BUILD); result = postBuild(); } 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 @@ -3290,29 +3282,29 @@ bool LLFloater::isVisible(const LLFloater* floater) return floater && floater->getVisible(); } -static LLFastTimer::DeclareTimer FTM_BUILD_FLOATERS("Build Floaters"); +static LLTrace::BlockTimerStatHandle FTM_BUILD_FLOATERS("Build Floaters"); bool LLFloater::buildFromFile(const std::string& filename) { - LLFastTimer timer(FTM_BUILD_FLOATERS); + LL_RECORD_BLOCK_TIME(FTM_BUILD_FLOATERS); LLXMLNodePtr root; 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 75715ef296..b3389dd2b0 100755 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -307,7 +307,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 b1b75776a7..9ef290abc0 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 f03c8d444b..547f0bd398 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 f32a52e6c6..0243e45e17 100755 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -174,6 +174,7 @@ LLFolderView::LLFolderView(const Params& p) mShowItemLinkOverlays(p.show_item_link_overlays), mViewModel(p.view_model) { + claimMem(mViewModel); mViewModel->setFolderView(this); mRoot = this; @@ -255,8 +256,6 @@ LLFolderView::~LLFolderView( void ) mRenamer = NULL; mStatusTextBox = NULL; - mAutoOpenItems.removeAllNodes(); - if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die(); mAutoOpenItems.removeAllNodes(); @@ -319,12 +318,11 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height ) return llround(mTargetHeight); } -static LLFastTimer::DeclareTimer FTM_FILTER("Filter Folder View"); +static LLTrace::BlockTimerStatHandle FTM_FILTER("Filter Folder View"); void LLFolderView::filter( LLFolderViewFilter& filter ) { - // Entry point of inventory filtering (CHUI-849) - LLFastTimer t2(FTM_FILTER); + LL_RECORD_BLOCK_TIME(FTM_FILTER); filter.resetTime(llclamp(LLUI::sSettingGroups["config"]->getS32(mParentPanel->getVisible() ? "FilterItemsMaxTimePerFrameVisible" : "FilterItemsMaxTimePerFrameUnvisible"), 1, 100)); // Note: we filter the model, not the view @@ -484,10 +482,10 @@ BOOL LLFolderView::changeSelection(LLFolderViewItem* selection, BOOL selected) return rv; } -static LLFastTimer::DeclareTimer FTM_SANITIZE_SELECTION("Sanitize Selection"); +static LLTrace::BlockTimerStatHandle FTM_SANITIZE_SELECTION("Sanitize Selection"); void LLFolderView::sanitizeSelection() { - LLFastTimer _(FTM_SANITIZE_SELECTION); + LL_RECORD_BLOCK_TIME(FTM_SANITIZE_SELECTION); // store off current item in case it is automatically deselected // and we want to preserve context LLFolderViewItem* original_selected_item = getCurSelectedItem(); @@ -738,7 +736,7 @@ void LLFolderView::removeSelectedItems() } else { - llinfos << "Cannot delete " << item->getName() << llendl; + LL_INFOS() << "Cannot delete " << item->getName() << LL_ENDL; return; } } @@ -764,20 +762,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); @@ -1284,7 +1283,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; } @@ -1580,7 +1579,7 @@ BOOL LLFolderView::getShowSelectionContext() return FALSE; } -void LLFolderView::setShowSingleSelection(BOOL show) +void LLFolderView::setShowSingleSelection(bool show) { if (show != mShowSingleSelection) { @@ -1589,15 +1588,15 @@ void LLFolderView::setShowSingleSelection(BOOL show) } } -static LLFastTimer::DeclareTimer FTM_AUTO_SELECT("Open and Select"); -static LLFastTimer::DeclareTimer FTM_INVENTORY("Inventory"); +static LLTrace::BlockTimerStatHandle FTM_AUTO_SELECT("Open and Select"); +static LLTrace::BlockTimerStatHandle FTM_INVENTORY("Inventory"); // Main idle routine void LLFolderView::update() { // If this is associated with the user's inventory, don't do anything // until that inventory is loaded up. - LLFastTimer t2(FTM_INVENTORY); + LL_RECORD_BLOCK_TIME(FTM_INVENTORY); if (getFolderViewModel()->getFilter().isModified() && getFolderViewModel()->getFilter().isNotDefault()) { @@ -1617,7 +1616,7 @@ void LLFolderView::update() // automatically show matching items, and select first one if we had a selection if (mNeedsAutoSelect) { - LLFastTimer t3(FTM_AUTO_SELECT); + LL_RECORD_BLOCK_TIME(FTM_AUTO_SELECT); // select new item only if a filtered item not currently selected LLFolderViewItem* selected_itemp = mSelectedItems.empty() ? NULL : mSelectedItems.back(); if (!mAutoSelectOverride && (!selected_itemp || !selected_itemp->getViewModelItem()->potentiallyVisible())) @@ -1750,14 +1749,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..4ef685ba0c 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" @@ -209,9 +208,9 @@ public: LLRect getVisibleRect(); BOOL search(LLFolderViewItem* first_item, const std::string &search_string, BOOL backward); - void setShowSelectionContext(BOOL show) { mShowSelectionContext = show; } + void setShowSelectionContext(bool show) { mShowSelectionContext = show; } BOOL getShowSelectionContext(); - void setShowSingleSelection(BOOL show); + void setShowSingleSelection(bool show); BOOL getShowSingleSelection() { return mShowSingleSelection; } F32 getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); } bool getUseEllipses() { return mUseEllipses; } @@ -261,31 +260,32 @@ protected: LLHandle<LLView> mPopupMenuHandle; selected_items_t mSelectedItems; - BOOL mKeyboardSelection; - BOOL mAllowMultiSelect; - BOOL mShowEmptyMessage; - BOOL mShowFolderHierarchy; + bool mKeyboardSelection, + mAllowMultiSelect, + mShowEmptyMessage, + mShowFolderHierarchy, + mNeedsScroll, + mPinningSelectedItem, + mNeedsAutoSelect, + mAutoSelectOverride, + mNeedsAutoRename, + mUseLabelSuffix, + mDragAndDropThisFrame, + mShowItemLinkOverlays, + mShowSelectionContext, + mShowSingleSelection; // Renaming variables and methods LLFolderViewItem* mRenameItem; // The item currently being renamed LLLineEditor* mRenamer; - BOOL mNeedsScroll; - BOOL mPinningSelectedItem; LLRect mScrollConstraintRect; - BOOL mNeedsAutoSelect; - BOOL mAutoSelectOverride; - BOOL mNeedsAutoRename; - bool mUseLabelSuffix; - bool mShowItemLinkOverlays; LLDepthStack<LLFolderViewFolder> mAutoOpenItems; LLFolderViewFolder* mAutoOpenCandidate; LLFrameTimer mAutoOpenTimer; LLFrameTimer mSearchTimer; std::string mSearchString; - BOOL mShowSelectionContext; - BOOL mShowSingleSelection; LLFrameTimer mMultiSelectionFadeTimer; S32 mArrangeGeneration; @@ -293,7 +293,6 @@ protected: signal_t mReshapeSignal; S32 mSignalSelectCallback; S32 mMinWidth; - BOOL mDragAndDropThisFrame; LLPanel* mParentPanel; diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index aa2343226c..83254c2840 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -495,7 +495,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) @@ -642,7 +642,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; @@ -712,7 +712,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); @@ -866,7 +866,7 @@ void LLFolderViewItem::draw() LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &right_x, FALSE ); } - + //--------------------------------------------------------------------------------// // Highlight string match // @@ -888,7 +888,7 @@ const LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) c { return getRoot()->getFolderViewModel(); } - + LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) { return getRoot()->getFolderViewModel(); @@ -925,11 +925,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)); } } @@ -952,7 +952,7 @@ void LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder) : 0; } -static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange"); +static LLTrace::BlockTimerStatHandle FTM_ARRANGE("Arrange"); // Make everything right and in the right place ready for drawing (CHUI-849) // * Sort everything correctly if necessary @@ -967,7 +967,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height ) // Note that we sort from the root (CHUI-849) getRoot()->getFolderViewModel()->sort(this); - LLFastTimer t2(FTM_ARRANGE); + LL_RECORD_BLOCK_TIME(FTM_ARRANGE); // evaluate mHasVisibleChildren mHasVisibleChildren = false; @@ -1073,7 +1073,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(); @@ -1594,7 +1594,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()) @@ -1767,7 +1767,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/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index b1bcc8bbb4..c665dce509 100755 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -108,9 +108,13 @@ public: virtual S32 getFirstRequiredGeneration() const = 0; }; -class LLFolderViewModelInterface +class LLFolderViewModelInterface : public LLTrace::MemTrackable<LLFolderViewModelInterface> { public: + LLFolderViewModelInterface() + : LLTrace::MemTrackable<LLFolderViewModelInterface>("LLFolderViewModelInterface") + {} + virtual ~LLFolderViewModelInterface() {} virtual void requestSortAll() = 0; @@ -128,10 +132,13 @@ public: // This is an abstract base class that users of the folderview classes // would use to bridge the folder view with the underlying data -class LLFolderViewModelItem : public LLRefCount +class LLFolderViewModelItem : public LLRefCount, public LLTrace::MemTrackable<LLFolderViewModelItem> { public: - LLFolderViewModelItem() { } + LLFolderViewModelItem() + : LLTrace::MemTrackable<LLFolderViewModelItem>("LLFolderViewModelItem") + {} + virtual ~LLFolderViewModelItem() { } virtual void update() {} //called when drawing @@ -336,18 +343,18 @@ protected: virtual void setParent(LLFolderViewModelItem* parent) { mParent = parent; } virtual bool hasParent() { return mParent != NULL; } - S32 mSortVersion; - bool mPassedFilter; - bool mPassedFolderFilter; - std::string::size_type mStringMatchOffsetFilter; - std::string::size_type mStringFilterSize; + S32 mSortVersion; + bool mPassedFilter; + bool mPassedFolderFilter; + std::string::size_type mStringMatchOffsetFilter; + std::string::size_type mStringFilterSize; - S32 mLastFilterGeneration; - S32 mLastFolderFilterGeneration; - S32 mMostFilteredDescendantGeneration; + S32 mLastFilterGeneration, + mLastFolderFilterGeneration, + mMostFilteredDescendantGeneration; - child_list_t mChildren; - LLFolderViewModelItem* mParent; + child_list_t mChildren; + LLFolderViewModelItem* mParent; LLFolderViewModelInterface& mRootViewModel; void setFolderViewItem(LLFolderViewItem* folder_view_item) { mFolderViewItem = folder_view_item;} 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.cpp b/indra/llui/lliconctrl.cpp index 30b79b4d20..58b66f60ca 100755 --- a/indra/llui/lliconctrl.cpp +++ b/indra/llui/lliconctrl.cpp @@ -42,7 +42,9 @@ LLIconCtrl::Params::Params() : image("image_name"), color("color"), use_draw_context_alpha("use_draw_context_alpha", true), - scale_image("scale_image") + scale_image("scale_image"), + min_width("min_width", 0), + min_height("min_height", 0) {} LLIconCtrl::LLIconCtrl(const LLIconCtrl::Params& p) @@ -51,8 +53,8 @@ LLIconCtrl::LLIconCtrl(const LLIconCtrl::Params& p) mImagep(p.image), mUseDrawContextAlpha(p.use_draw_context_alpha), mPriority(0), - mDrawWidth(0), - mDrawHeight(0) + mMinWidth(p.min_width), + mMinHeight(p.min_height) { if (mImagep.notNull()) { @@ -97,7 +99,13 @@ void LLIconCtrl::setValue(const LLSD& value ) mImagep = LLUI::getUIImage(tvalue.asString(), mPriority); } - setIconImageDrawSize(); + if(mImagep.notNull() + && mImagep->getImage().notNull() + && mMinWidth + && mMinHeight) + { + mImagep->getImage()->setKnownDrawSize(llmax(mMinWidth, mImagep->getWidth()), llmax(mMinHeight, mImagep->getHeight())); + } } std::string LLIconCtrl::getImageName() const @@ -108,14 +116,4 @@ std::string LLIconCtrl::getImageName() const return std::string(); } -void LLIconCtrl::setIconImageDrawSize() -{ - if(mImagep.notNull() && mDrawWidth && mDrawHeight) - { - if(mImagep->getImage().notNull()) - { - mImagep->getImage()->setKnownDrawSize(mDrawWidth, mDrawHeight) ; - } - } -} diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index efa0925a4a..8b1092df46 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; @@ -50,7 +49,10 @@ public: Optional<LLUIImage*> image; Optional<LLUIColor> color; Optional<bool> use_draw_context_alpha; + Optional<S32> min_width, + min_height; Ignored scale_image; + Params(); }; protected: @@ -72,15 +74,12 @@ public: void setImage(LLPointer<LLUIImage> image) { mImagep = image; } const LLPointer<LLUIImage> getImage() { return mImagep; } -private: - void setIconImageDrawSize() ; - protected: S32 mPriority; //the output size of the icon image if set. - S32 mDrawWidth ; - S32 mDrawHeight ; + S32 mMinWidth, + mMinHeight; // If set to true (default), use the draw context transparency. // If false, will use transparency returned by getCurrentTransparency(). See STORM-698. diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 26d27d1f34..d830df8772 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,18 +342,18 @@ 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 ); } -LLFastTimer::DeclareTimer FTM_SYNTAX_COLORING("Syntax Coloring"); +LLTrace::BlockTimerStatHandle FTM_SYNTAX_COLORING("Syntax Coloring"); // Walk through a string, applying the rules specified by the keyword token list and // create a list of color segments. void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLWString& wtext, const LLColor4 &defaultColor, LLTextEditor& editor) { - LLFastTimer ft(FTM_SYNTAX_COLORING); + LL_RECORD_BLOCK_TIME(FTM_SYNTAX_COLORING); seg_list->clear(); if( wtext.empty() ) @@ -552,7 +552,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); } @@ -619,10 +619,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() ) { @@ -631,7 +631,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) { @@ -640,7 +640,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) { @@ -651,12 +651,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 c89c0203b4..c59286fc60 100755 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -33,6 +33,7 @@ #include "lllocalcliprect.h" #include "llpanel.h" #include "llcriticaldamp.h" +#include "lliconctrl.h" #include "boost/foreach.hpp" static const F32 MIN_FRACTIONAL_SIZE = 0.00001f; @@ -41,12 +42,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 +135,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) @@ -274,25 +269,9 @@ void LLLayoutStack::draw() // only force drawing invisible children if visible amount is non-zero drawChild(panelp, 0, 0, !clip_rect.isEmpty()); } - } - - const LLView::child_list_t * child_listp = getChildList(); - BOOST_FOREACH(LLView * childp, * child_listp) - { - LLResizeBar * resize_barp = dynamic_cast<LLResizeBar*>(childp); - if (resize_barp && resize_barp->isShowDragHandle() && resize_barp->getVisible() && resize_barp->getRect().isValid()) + if (panelp->getResizeBar()->getVisible()) { - LLRect screen_rect = resize_barp->calcScreenRect(); - if (LLUI::getRootView()->getLocalRect().overlaps(screen_rect) && LLUI::sDirtyRect.overlaps(screen_rect)) - { - LLUI::pushMatrix(); - { - const LLRect& rb_rect(resize_barp->getRect()); - LLUI::translate(rb_rect.mLeft, rb_rect.mBottom); - resize_barp->draw(); - } - LLUI::popMatrix(); - } + drawChild(panelp->getResizeBar()); } } } @@ -355,11 +334,36 @@ void LLLayoutStack::collapsePanel(LLPanel* panel, BOOL collapsed) mNeedsLayout = true; } -static LLFastTimer::DeclareTimer FTM_UPDATE_LAYOUT("Update LayoutStacks"); +static LLTrace::BlockTimerStatHandle FTM_UPDATE_LAYOUT("Update LayoutStacks"); + +class LLImagePanel : public LLPanel +{ +public: + struct Params : public LLInitParam::Block<Params, LLPanel::Params> + { + Optional<bool> horizontal; + Params() : horizontal("horizontal", false) {} + }; + LLImagePanel(const Params& p) : LLPanel(p), mHorizontal(p.horizontal) {} + virtual ~LLImagePanel() {} + + void draw() + { + const LLRect& parent_rect = getParent()->getRect(); + const LLRect& rect = getRect(); + LLRect clip_rect( -rect.mLeft, parent_rect.getHeight() - rect.mBottom - 2 + , parent_rect.getWidth() - rect.mLeft - (mHorizontal ? 2 : 0), -rect.mBottom); + LLLocalClipRect clip(clip_rect); + LLPanel::draw(); + } + +private: + bool mHorizontal; +}; void LLLayoutStack::updateLayout() { - LLFastTimer ft(FTM_UPDATE_LAYOUT); + LL_RECORD_BLOCK_TIME(FTM_UPDATE_LAYOUT); if (!mNeedsLayout) return; @@ -441,8 +445,6 @@ void LLLayoutStack::updateLayout() } LLRect resize_bar_rect(panel_rect); - LLResizeBar * resize_barp = panelp->getResizeBar(); - bool show_drag_handle = resize_barp->isShowDragHandle(); F32 panel_spacing = (F32)mPanelSpacing * panelp->getVisibleAmount(); F32 panel_visible_dim = panelp->getVisibleDim(); S32 panel_spacing_round = (S32)(llround(panel_spacing)); @@ -451,7 +453,7 @@ void LLLayoutStack::updateLayout() { cur_pos += panel_visible_dim + panel_spacing; - if (show_drag_handle && panel_spacing_round > mDragHandleThickness) + if (mShowDragHandle && panel_spacing_round > mDragHandleThickness) { resize_bar_rect.mLeft = panel_rect.mRight + mDragHandleShift; resize_bar_rect.mRight = resize_bar_rect.mLeft + mDragHandleThickness; @@ -462,7 +464,7 @@ void LLLayoutStack::updateLayout() resize_bar_rect.mRight = panel_rect.mRight + panel_spacing_round + mResizeBarOverlap; } - if (show_drag_handle) + if (mShowDragHandle) { resize_bar_rect.mBottom += mDragHandleSecondIndent; resize_bar_rect.mTop -= mDragHandleFirstIndent; @@ -473,7 +475,7 @@ void LLLayoutStack::updateLayout() { cur_pos -= panel_visible_dim + panel_spacing; - if (show_drag_handle && panel_spacing_round > mDragHandleThickness) + if (mShowDragHandle && panel_spacing_round > mDragHandleThickness) { resize_bar_rect.mTop = panel_rect.mBottom - mDragHandleShift; resize_bar_rect.mBottom = resize_bar_rect.mTop - mDragHandleThickness; @@ -484,7 +486,7 @@ void LLLayoutStack::updateLayout() resize_bar_rect.mBottom = panel_rect.mBottom - panel_spacing_round - mResizeBarOverlap; } - if (show_drag_handle) + if (mShowDragHandle) { resize_bar_rect.mLeft += mDragHandleFirstIndent; resize_bar_rect.mRight -= mDragHandleSecondIndent; @@ -547,9 +549,69 @@ void LLLayoutStack::createResizeBar(LLLayoutPanel* panelp) resize_params.min_size(lp->getRelevantMinDim()); resize_params.side((mOrientation == HORIZONTAL) ? LLResizeBar::RIGHT : LLResizeBar::BOTTOM); resize_params.snapping_enabled(false); - resize_params.show_drag_handle(mShowDragHandle); LLResizeBar* resize_bar = LLUICtrlFactory::create<LLResizeBar>(resize_params); lp->mResizeBar = resize_bar; + + if (mShowDragHandle) + { + LLPanel::Params resize_bar_bg_panel_p; + resize_bar_bg_panel_p.name = "resize_handle_bg_panel"; + resize_bar_bg_panel_p.rect = lp->mResizeBar->getLocalRect(); + resize_bar_bg_panel_p.follows.flags = FOLLOWS_ALL; + resize_bar_bg_panel_p.tab_stop = false; + resize_bar_bg_panel_p.background_visible = true; + resize_bar_bg_panel_p.bg_alpha_color = LLUIColorTable::instance().getColor("ResizebarBody"); + resize_bar_bg_panel_p.has_border = true; + resize_bar_bg_panel_p.border.border_thickness = 1; + resize_bar_bg_panel_p.border.highlight_light_color = LLUIColorTable::instance().getColor("ResizebarBorderLight"); + resize_bar_bg_panel_p.border.shadow_dark_color = LLUIColorTable::instance().getColor("ResizebarBorderDark"); + + LLPanel* resize_bar_bg_panel = LLUICtrlFactory::create<LLPanel>(resize_bar_bg_panel_p); + + LLIconCtrl::Params icon_p; + icon_p.name = "resize_handle_image"; + icon_p.rect = lp->mResizeBar->getLocalRect(); + icon_p.follows.flags = FOLLOWS_ALL; + icon_p.image = LLUI::getUIImage(mOrientation == HORIZONTAL ? "Vertical Drag Handle" : "Horizontal Drag Handle"); + resize_bar_bg_panel->addChild(LLUICtrlFactory::create<LLIconCtrl>(icon_p)); + + lp->mResizeBar->addChild(resize_bar_bg_panel); + } + + /*if (mShowDragHandle) + { + LLViewBorder::Params border_params; + border_params.border_thickness = 1; + border_params.highlight_light_color = LLUIColorTable::instance().getColor("ResizebarBorderLight"); + border_params.shadow_dark_color = LLUIColorTable::instance().getColor("ResizebarBorderDark"); + + addBorder(border_params); + setBorderVisible(TRUE); + + LLImagePanel::Params image_panel; + mDragHandleImage = LLUI::getUIImage(LLResizeBar::RIGHT == mSide ? "Vertical Drag Handle" : "Horizontal Drag Handle"); + image_panel.bg_alpha_image = mDragHandleImage; + image_panel.background_visible = true; + image_panel.horizontal = (LLResizeBar::BOTTOM == mSide); + mImagePanel = LLUICtrlFactory::create<LLImagePanel>(image_panel); + setImagePanel(mImagePanel); + }*/ + + //if (mShowDragHandle) + //{ + // setBackgroundVisible(TRUE); + // setTransparentColor(LLUIColorTable::instance().getColor("ResizebarBody")); + //} + + /*if (mShowDragHandle) + { + S32 image_width = mDragHandleImage->getTextureWidth(); + S32 image_height = mDragHandleImage->getTextureHeight(); + const LLRect& panel_rect = getRect(); + S32 image_left = (panel_rect.getWidth() - image_width) / 2 - 1; + S32 image_bottom = (panel_rect.getHeight() - image_height) / 2; + mImagePanel->setRect(LLRect(image_left, image_bottom + image_height, image_left + image_width, image_bottom)); + }*/ LLView::addChild(resize_bar, 0); } } @@ -655,7 +717,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; @@ -680,7 +742,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; @@ -707,7 +769,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 add43fa741..a245ebe1b9 100755 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -39,24 +39,12 @@ 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; @@ -79,7 +67,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); @@ -111,7 +99,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; @@ -194,7 +182,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; } @@ -213,7 +201,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 f854e1785d..a0ef64467f 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; } @@ -3425,8 +3425,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; @@ -3755,7 +3755,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 4d6e189b92..33e66add18 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()) @@ -195,7 +195,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; } LLView* popup_menu = LLMenuGL::sMenuContainer->getVisibleMenu(); @@ -331,7 +331,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..d1a597511e 100755 --- a/indra/llui/llmultifloater.cpp +++ b/indra/llui/llmultifloater.cpp @@ -67,14 +67,13 @@ void LLMultiFloater::buildTabContainer() } } -void LLMultiFloater::onOpen(const LLSD& key) +void LLMultiFloater::onClose(bool app_quitting) { -// if (mTabContainer->getTabCount() <= 0) -// { -// // for now, don't allow multifloaters -// // without any child floaters -// closeFloater(); -// } + if(isMinimized()) + { + setMinimized(FALSE); + } + LLFloater::onClose(app_quitting); } void LLMultiFloater::draw() @@ -159,7 +158,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..c106a62527 100755 --- a/indra/llui/llmultifloater.h +++ b/indra/llui/llmultifloater.h @@ -44,7 +44,7 @@ public: void buildTabContainer(); virtual BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); + /*virtual*/ void onClose(bool app_quitting); virtual void draw(); virtual void setVisible(BOOL visible); /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); @@ -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 5c288c3f03..025cd81d92 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; @@ -1208,6 +1208,9 @@ LLNotifications::LLNotifications() { mListener.reset(new LLNotificationsListener(*this)); 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(); } void LLNotifications::clear() @@ -1407,7 +1410,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; @@ -1441,12 +1444,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; } } } @@ -1485,7 +1488,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. @@ -1498,7 +1501,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; } @@ -1508,7 +1511,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; } @@ -1556,7 +1559,7 @@ bool LLNotifications::loadTemplates() mTemplates[notification.name] = LLNotificationTemplatePtr(new LLNotificationTemplate(notification)); } - llinfos << "...done" << llendl; + LL_INFOS() << "...done" << LL_ENDL; return true; } @@ -1574,7 +1577,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; } @@ -1639,7 +1642,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); @@ -1697,7 +1700,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 @@ -1748,13 +1751,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()) { @@ -1793,7 +1796,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); } @@ -1804,7 +1807,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); } @@ -1816,7 +1819,7 @@ bool LLNotifications::isVisibleByRules(LLNotificationPtr n) break; } - lldebugs << "allowing notification " << n->getName() << llendl; + LL_DEBUGS() << "allowing notification " << n->getName() << LL_ENDL; return true; } @@ -1877,7 +1880,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 6ac4a98806..b0e8553a49 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" @@ -848,7 +849,7 @@ public: Iterator begin(); Iterator end(); size_t size(); - + std::string summarize(); private: @@ -1067,15 +1068,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) @@ -1089,7 +1088,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..ee90574161 100755 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -38,10 +38,8 @@ #include "lldir.h" #include "lltimer.h" -#include "llaccordionctrltab.h" #include "llbutton.h" #include "llmenugl.h" -//#include "llstatusbar.h" #include "llui.h" #include "llkeyboard.h" #include "lllineeditor.h" @@ -50,7 +48,6 @@ #include "lluictrl.h" #include "lluictrlfactory.h" #include "llviewborder.h" -#include "lltabcontainer.h" static LLDefaultChildRegistry::Register<LLPanel> r1("panel", &LLPanel::fromXML); LLPanel::factory_stack_t LLPanel::sFactoryStack; @@ -166,8 +163,8 @@ void LLPanel::removeBorder() // virtual void LLPanel::clearCtrls() { - LLView::ctrl_list_t ctrls = getCtrlList(); - for (LLView::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it) + LLPanel::ctrl_list_t ctrls = getCtrlList(); + for (LLPanel::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it) { LLUICtrl* ctrl = *ctrl_it; ctrl->setFocus( FALSE ); @@ -178,14 +175,29 @@ void LLPanel::clearCtrls() void LLPanel::setCtrlsEnabled( BOOL b ) { - LLView::ctrl_list_t ctrls = getCtrlList(); - for (LLView::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it) + LLPanel::ctrl_list_t ctrls = getCtrlList(); + for (LLPanel::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it) { LLUICtrl* ctrl = *ctrl_it; ctrl->setEnabled( b ); } } +LLPanel::ctrl_list_t LLPanel::getCtrlList() const +{ + ctrl_list_t controls; + for(child_list_t::const_iterator it = getChildList()->begin(), end_it = getChildList()->end(); it != end_it; ++it) + { + LLView* viewp = *it; + if(viewp->isCtrl()) + { + controls.push_back(static_cast<LLUICtrl*>(viewp)); + } + } + return controls; +} + + void LLPanel::draw() { F32 alpha = getDrawContext().mAlpha; @@ -342,9 +354,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 } @@ -372,7 +384,7 @@ void LLPanel::setBorderVisible(BOOL b) } } -LLFastTimer::DeclareTimer FTM_PANEL_CONSTRUCTION("Panel Construction"); +LLTrace::BlockTimerStatHandle FTM_PANEL_CONSTRUCTION("Panel Construction"); LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLXMLNodePtr output_node) { @@ -384,14 +396,14 @@ LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLXMLNodePtr output_ LLPanel* panelp = NULL; - { LLFastTimer _(FTM_PANEL_CONSTRUCTION); + { LL_RECORD_BLOCK_TIME(FTM_PANEL_CONSTRUCTION); if(!class_attr.empty()) { 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; } } @@ -488,15 +500,15 @@ void LLPanel::initFromParams(const LLPanel::Params& p) setAcceptsBadge(p.accepts_badge); } -static LLFastTimer::DeclareTimer FTM_PANEL_SETUP("Panel Setup"); -static LLFastTimer::DeclareTimer FTM_EXTERNAL_PANEL_LOAD("Load Extern Panel Reference"); -static LLFastTimer::DeclareTimer FTM_PANEL_POSTBUILD("Panel PostBuild"); +static LLTrace::BlockTimerStatHandle FTM_PANEL_SETUP("Panel Setup"); +static LLTrace::BlockTimerStatHandle FTM_EXTERNAL_PANEL_LOAD("Load Extern Panel Reference"); +static LLTrace::BlockTimerStatHandle FTM_PANEL_POSTBUILD("Panel PostBuild"); BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params) { Params params(default_params); { - LLFastTimer timer(FTM_PANEL_SETUP); + LL_RECORD_BLOCK_TIME(FTM_PANEL_SETUP); LLXMLNodePtr referenced_xml; std::string xml_filename = mXMLFilename; @@ -520,16 +532,16 @@ 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; } LLUICtrlFactory::instance().pushFileName(xml_filename); - LLFastTimer timer(FTM_EXTERNAL_PANEL_LOAD); + LL_RECORD_BLOCK_TIME(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,13 +563,13 @@ 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; applyXUILayout(params, parent); { - LLFastTimer timer(FTM_PANEL_CONSTRUCTION); + LL_RECORD_BLOCK_TIME(FTM_PANEL_CONSTRUCTION); initFromParams(params); } @@ -574,7 +586,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu } { - LLFastTimer timer(FTM_PANEL_POSTBUILD); + LL_RECORD_BLOCK_TIME(FTM_PANEL_POSTBUILD); postBuild(); } } @@ -599,11 +611,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 +630,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; } @@ -637,16 +649,6 @@ void LLPanel::childSetVisible(const std::string& id, bool visible) } } -bool LLPanel::childIsVisible(const std::string& id) const -{ - LLView* child = findChild<LLView>(id); - if (child) - { - return (bool)child->getVisible(); - } - return false; -} - void LLPanel::childSetEnabled(const std::string& id, bool enabled) { LLView* child = findChild<LLView>(id); @@ -656,55 +658,6 @@ void LLPanel::childSetEnabled(const std::string& id, bool enabled) } } -void LLPanel::childSetTentative(const std::string& id, bool tentative) -{ - LLUICtrl* child = findChild<LLUICtrl>(id); - if (child) - { - child->setTentative(tentative); - } -} - -bool LLPanel::childIsEnabled(const std::string& id) const -{ - LLView* child = findChild<LLView>(id); - if (child) - { - return (bool)child->getEnabled(); - } - return false; -} - - -void LLPanel::childSetToolTip(const std::string& id, const std::string& msg) -{ - LLView* child = findChild<LLView>(id); - if (child) - { - child->setToolTip(msg); - } -} - -void LLPanel::childSetRect(const std::string& id, const LLRect& rect) -{ - LLView* child = findChild<LLView>(id); - if (child) - { - child->setRect(rect); - } -} - -bool LLPanel::childGetRect(const std::string& id, LLRect& rect) const -{ - LLView* child = findChild<LLView>(id); - if (child) - { - rect = child->getRect(); - return true; - } - return false; -} - void LLPanel::childSetFocus(const std::string& id, BOOL focus) { LLUICtrl* child = findChild<LLUICtrl>(id); @@ -740,15 +693,6 @@ void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void } } -void LLPanel::childSetValidate(const std::string& id, boost::function<bool (const LLSD& data)> cb) -{ - LLUICtrl* child = findChild<LLUICtrl>(id); - if (child) - { - child->setValidateBeforeCommit(cb); - } -} - void LLPanel::childSetColor(const std::string& id, const LLColor4& color) { LLUICtrl* child = findChild<LLUICtrl>(id); @@ -828,95 +772,6 @@ BOOL LLPanel::childSetLabelArg(const std::string& id, const std::string& key, co return FALSE; } -BOOL LLPanel::childSetToolTipArg(const std::string& id, const std::string& key, const LLStringExplicit& text) -{ - LLView* child = findChild<LLView>(id); - if (child) - { - return child->setToolTipArg(key, text); - } - return FALSE; -} - -void LLPanel::childShowTab(const std::string& id, const std::string& tabname, bool visible) -{ - LLTabContainer* child = findChild<LLTabContainer>(id); - if (child) - { - child->selectTabByName(tabname); - } -} - -LLPanel *LLPanel::childGetVisibleTab(const std::string& id) const -{ - LLTabContainer* child = findChild<LLTabContainer>(id); - if (child) - { - return child->getCurrentPanel(); - } - return NULL; -} - -LLPanel* LLPanel::childGetVisibleTabWithHelp() -{ - LLView *child; - - bfs_tree_iterator_t it = beginTreeBFS(); - // skip ourselves - ++it; - for (; it != endTreeBFS(); ++it) - { - child = *it; - LLPanel *curTabPanel = NULL; - - // do we have a tab container? - LLTabContainer *tab = dynamic_cast<LLTabContainer *>(child); - if (tab && tab->getVisible()) - { - curTabPanel = tab->getCurrentPanel(); - } - - // do we have an accordion tab? - LLAccordionCtrlTab* accordion = dynamic_cast<LLAccordionCtrlTab *>(child); - if (accordion && accordion->getDisplayChildren()) - { - curTabPanel = dynamic_cast<LLPanel *>(accordion->getAccordionView()); - } - - // if we found a valid tab, does it have a help topic? - if (curTabPanel && !curTabPanel->getHelpTopic().empty()) - { - return curTabPanel; - } - } - - // couldn't find any active tabs with a help topic string - return NULL; -} - - -LLPanel *LLPanel::childGetVisiblePanelWithHelp() -{ - LLView *child; - - bfs_tree_iterator_t it = beginTreeBFS(); - // skip ourselves - ++it; - for (; it != endTreeBFS(); ++it) - { - child = *it; - // do we have a panel with a help topic? - LLPanel *panel = dynamic_cast<LLPanel *>(child); - if (panel && panel->isInVisibleChain() && !panel->getHelpTopic().empty()) - { - return panel; - } - } - - // couldn't find any active panels with a help topic string - return NULL; -} - void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function) { LLButton* button = findChild<LLButton>(id); @@ -935,24 +790,6 @@ void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> } } -void LLPanel::childSetActionTextbox(const std::string& id, boost::function<void(void*)> function, void* value) -{ - LLTextBox* textbox = findChild<LLTextBox>(id); - if (textbox) - { - textbox->setClickedCallback(boost::bind(function, value)); - } -} - -void LLPanel::childSetControlName(const std::string& id, const std::string& control_name) -{ - LLUICtrl* view = findChild<LLUICtrl>(id); - if (view) - { - view->setControlName(control_name, NULL); - } -} - boost::signals2::connection LLPanel::setVisibleCallback( const commit_signal_t::slot_type& cb ) { if (!mVisibleSignal) @@ -963,31 +800,31 @@ boost::signals2::connection LLPanel::setVisibleCallback( const commit_signal_t:: return mVisibleSignal->connect(cb); } -static LLFastTimer::DeclareTimer FTM_BUILD_PANELS("Build Panels"); +static LLTrace::BlockTimerStatHandle FTM_BUILD_PANELS("Build Panels"); //----------------------------------------------------------------------------- // buildPanel() //----------------------------------------------------------------------------- BOOL LLPanel::buildFromFile(const std::string& filename, const LLPanel::Params& default_params) { - LLFastTimer timer(FTM_BUILD_PANELS); + LL_RECORD_BLOCK_TIME(FTM_BUILD_PANELS); BOOL didPost = FALSE; LLXMLNodePtr root; 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..9f2a31e632 100755 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -105,6 +105,8 @@ protected: LLPanel(const LLPanel::Params& params = getDefaultParams()); public: + typedef std::vector<class LLUICtrl *> ctrl_list_t; + BOOL buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams()); static LLPanel* createFactoryPanel(const std::string& name); @@ -115,7 +117,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 ); @@ -154,6 +156,7 @@ public: std::string getHelpTopic() const { return mHelpTopic; } void setCtrlsEnabled(BOOL b); + ctrl_list_t getCtrlList() const; LLHandle<LLPanel> getHandle() const { return getDerivedHandle<LLPanel>(); } @@ -174,19 +177,10 @@ public: // LLView void childSetVisible(const std::string& name, bool visible); - void childShow(const std::string& name) { childSetVisible(name, true); } - void childHide(const std::string& name) { childSetVisible(name, false); } - bool childIsVisible(const std::string& id) const; - void childSetTentative(const std::string& name, bool tentative); void childSetEnabled(const std::string& name, bool enabled); void childEnable(const std::string& name) { childSetEnabled(name, true); } void childDisable(const std::string& name) { childSetEnabled(name, false); }; - bool childIsEnabled(const std::string& id) const; - - void childSetToolTip(const std::string& id, const std::string& msg); - void childSetRect(const std::string& id, const LLRect &rect); - bool childGetRect(const std::string& id, LLRect& rect) const; // LLUICtrl void childSetFocus(const std::string& id, BOOL focus = TRUE); @@ -197,9 +191,6 @@ public: // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. void childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data); - - void childSetValidate(const std::string& id, boost::function<bool (const LLSD& data)> cb ); - void childSetColor(const std::string& id, const LLColor4& color); LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; @@ -214,34 +205,11 @@ public: // Not implemented for all types, defaults to noop, returns FALSE if not applicaple BOOL childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); BOOL childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - BOOL childSetToolTipArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - // LLTabContainer - void childShowTab(const std::string& id, const std::string& tabname, bool visible = true); - LLPanel *childGetVisibleTab(const std::string& id) const; - - // Find a child with a nonempty Help topic - LLPanel *childGetVisibleTabWithHelp(); - LLPanel *childGetVisiblePanelWithHelp(); - - // LLTextBox/LLTextEditor/LLLineEditor - void childSetText(const std::string& id, const LLStringExplicit& text) { childSetValue(id, LLSD(text)); } - - // *NOTE: Does not return text from <string> tags, use getString() - std::string childGetText(const std::string& id) const { return childGetValue(id).asString(); } - - // LLLineEditor - void childSetPrevalidate(const std::string& id, bool (*func)(const LLWString &) ); - // LLButton void childSetAction(const std::string& id, boost::function<void(void*)> function, void* value); void childSetAction(const std::string& id, const commit_signal_t::slot_type& function); - // LLTextBox - void childSetActionTextbox(const std::string& id, boost::function<void(void*)> function, void* value = NULL); - - void childSetControlName(const std::string& id, const std::string& control_name); - static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL); //call onOpen to let panel know when it's about to be shown or activated 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/llresizebar.cpp b/indra/llui/llresizebar.cpp index e67b22c977..115c4e23be 100755 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -35,46 +35,18 @@ #include "llfocusmgr.h" #include "llwindow.h" -class LLImagePanel : public LLPanel -{ -public: - struct Params : public LLInitParam::Block<Params, LLPanel::Params> - { - Optional<bool> horizontal; - Params() : horizontal("horizontal", false) {} - }; - LLImagePanel(const Params& p) : LLPanel(p), mHorizontal(p.horizontal) {} - virtual ~LLImagePanel() {} - - void draw() - { - const LLRect& parent_rect = getParent()->getRect(); - const LLRect& rect = getRect(); - LLRect clip_rect( -rect.mLeft, parent_rect.getHeight() - rect.mBottom - 2 - , parent_rect.getWidth() - rect.mLeft - (mHorizontal ? 2 : 0), -rect.mBottom); - LLLocalClipRect clip(clip_rect); - LLPanel::draw(); - } - -private: - bool mHorizontal; -}; - -static LLDefaultChildRegistry::Register<LLImagePanel> t1("resize_bar_image_panel"); - LLResizeBar::Params::Params() : max_size("max_size", S32_MAX), snapping_enabled("snapping_enabled", true), resizing_view("resizing_view"), side("side"), - allow_double_click_snapping("allow_double_click_snapping", true), - show_drag_handle("show_drag_handle", false) + allow_double_click_snapping("allow_double_click_snapping", true) { name = "resize_bar"; } LLResizeBar::LLResizeBar(const LLResizeBar::Params& p) -: LLPanel(p), +: LLView(p), mDragLastScreenX( 0 ), mDragLastScreenY( 0 ), mLastMouseScreenX( 0 ), @@ -86,7 +58,6 @@ LLResizeBar::LLResizeBar(const LLResizeBar::Params& p) mAllowDoubleClickSnapping(p.allow_double_click_snapping), mResizingView(p.resizing_view), mResizeListener(NULL), - mShowDragHandle(p.show_drag_handle), mImagePanel(NULL) { setFollowsNone(); @@ -116,36 +87,6 @@ LLResizeBar::LLResizeBar(const LLResizeBar::Params& p) default: break; } - - if (mShowDragHandle) - { - LLViewBorder::Params border_params; - border_params.border_thickness = 1; - border_params.highlight_light_color = LLUIColorTable::instance().getColor("ResizebarBorderLight"); - border_params.shadow_dark_color = LLUIColorTable::instance().getColor("ResizebarBorderDark"); - - addBorder(border_params); - setBorderVisible(TRUE); - - LLImagePanel::Params image_panel; - mDragHandleImage = LLUI::getUIImage(LLResizeBar::RIGHT == mSide ? "Vertical Drag Handle" : "Horizontal Drag Handle"); - image_panel.bg_alpha_image = mDragHandleImage; - image_panel.background_visible = true; - image_panel.horizontal = (LLResizeBar::BOTTOM == mSide); - mImagePanel = LLUICtrlFactory::create<LLImagePanel>(image_panel); - setImagePanel(mImagePanel); - } -} - -BOOL LLResizeBar::postBuild() -{ - if (mShowDragHandle) - { - setBackgroundVisible(TRUE); - setTransparentColor(LLUIColorTable::instance().getColor("ResizebarBody")); - } - - return LLPanel::postBuild(); } BOOL LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask) @@ -433,18 +374,3 @@ LLPanel * LLResizeBar::getImagePanel() const { return getChildCount() > 0 ? (LLPanel *)getChildList()->back() : NULL; } - -void LLResizeBar::draw() -{ - if (mShowDragHandle) - { - S32 image_width = mDragHandleImage->getTextureWidth(); - S32 image_height = mDragHandleImage->getTextureHeight(); - const LLRect& panel_rect = getRect(); - S32 image_left = (panel_rect.getWidth() - image_width) / 2 - 1; - S32 image_bottom = (panel_rect.getHeight() - image_height) / 2; - mImagePanel->setRect(LLRect(image_left, image_bottom + image_height, image_left + image_width, image_bottom)); - } - - LLPanel::draw(); -} diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h index bcf8ea0b40..20a2406484 100755 --- a/indra/llui/llresizebar.h +++ b/indra/llui/llresizebar.h @@ -27,14 +27,14 @@ #ifndef LL_RESIZEBAR_H #define LL_RESIZEBAR_H -#include "llpanel.h" +#include "llview.h" -class LLResizeBar : public LLPanel +class LLResizeBar : public LLView { public: enum Side { LEFT, TOP, RIGHT, BOTTOM }; - struct Params : public LLInitParam::Block<Params, LLPanel::Params> + struct Params : public LLInitParam::Block<Params, LLView::Params> { Mandatory<LLView*> resizing_view; Mandatory<Side> side; @@ -43,7 +43,6 @@ public: Optional<S32> max_size; Optional<bool> snapping_enabled; Optional<bool> allow_double_click_snapping; - Optional<bool> show_drag_handle; Params(); }; @@ -52,10 +51,8 @@ protected: LLResizeBar(const LLResizeBar::Params& p); friend class LLUICtrlFactory; - /*virtual*/ BOOL postBuild(); public: - virtual void draw(); virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -66,7 +63,6 @@ public: void setAllowDoubleClickSnapping(BOOL allow) { mAllowDoubleClickSnapping = allow; } bool canResize() { return getEnabled() && mMaxSize > mMinSize; } void setResizeListener(boost::function<void(void*)> listener) {mResizeListener = listener;} - BOOL isShowDragHandle() const { return mShowDragHandle; } void setImagePanel(LLPanel * panelp); LLPanel * getImagePanel() const; @@ -79,9 +75,8 @@ private: S32 mMinSize; S32 mMaxSize; const Side mSide; - BOOL mSnappingEnabled; - BOOL mAllowDoubleClickSnapping; - BOOL mShowDragHandle; + bool mSnappingEnabled, + mAllowDoubleClickSnapping; LLView* mResizingView; boost::function<void(void*)> mResizeListener; LLPointer<LLUIImage> mDragHandleImage; 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 238eae21c2..8c506d76bb 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 6e03f604a2..b9c87cc631 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; @@ -2842,10 +2840,10 @@ LLScrollListColumn* LLScrollListCtrl::getColumn(const std::string& name) return NULL; } -LLFastTimer::DeclareTimer FTM_ADD_SCROLLLIST_ELEMENT("Add Scroll List Item"); +LLTrace::BlockTimerStatHandle FTM_ADD_SCROLLLIST_ELEMENT("Add Scroll List Item"); LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition pos, void* userdata) { - LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT); + LL_RECORD_BLOCK_TIME(FTM_ADD_SCROLLLIST_ELEMENT); LLScrollListItem::Params item_params; LLParamSDParser parser; parser.readSD(element, item_params); @@ -2855,14 +2853,14 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition LLScrollListItem* LLScrollListCtrl::addRow(const LLScrollListItem::Params& item_p, EAddPosition pos) { - LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT); + LL_RECORD_BLOCK_TIME(FTM_ADD_SCROLLLIST_ELEMENT); LLScrollListItem *new_item = new LLScrollListItem(item_p); return addRow(new_item, item_p, pos); } LLScrollListItem* LLScrollListCtrl::addRow(LLScrollListItem *new_item, const LLScrollListItem::Params& item_p, EAddPosition pos) { - LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT); + LL_RECORD_BLOCK_TIME(FTM_ADD_SCROLLLIST_ELEMENT); if (!item_p.validateBlock() || !new_item) return NULL; new_item->setNumColumns(mColumns.size()); diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index c61e281a31..6325a79cd5 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..1bd2bc06f4 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -34,234 +34,560 @@ #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(llabs(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; + } + } + } -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) -{ + return is_approx_equal(range, 0.f) ? 0.f : range / best_divisor; } -BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) +void calc_auto_scale_range(F32& min, F32& max, F32& tick) { - if (mDisplayBar) + 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++) { - if (mDisplayHistory) + cur_max = starting_max * RANGES[range_idx]; + cur_min = starting_min * RANGES[range_idx]; + + if (min > 0.f && cur_min <= min) { - mDisplayBar = FALSE; - mDisplayHistory = FALSE; + out_min = cur_min; + cur_tick_min = TICKS[range_idx]; } - else + if (max < 0.f && cur_max >= max) { - mDisplayHistory = TRUE; + out_max = cur_max; + cur_tick_max = TICKS[range_idx]; } } - else + + cur_max = starting_max; + cur_min = starting_min; + for (S32 range_idx = LL_ARRAY_SIZE(RANGES) - 1; range_idx >= 0; range_idx--) { - mDisplayBar = TRUE; + 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]; + } } - LLView* parent = getParent(); - parent->reshape(parent->getRect().getWidth(), parent->getRect().getHeight(), FALSE); + tick = power_of_10 * llmax(cur_tick_min, cur_tick_max); + min = out_min; + max = out_max; +} - return FALSE; +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); } -void LLStatBar::draw() +/////////////////////////////////////////////////////////////////////////////////// + +LLStatBar::LLStatBar(const Params& p) +: LLView(p), + mLabel(p.label), + mUnitLabel(p.unit_label), + mTargetMinBar(llmin(p.bar_min, p.bar_max)), + mTargetMaxBar(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()), + mTickSpacing(p.tick_spacing), + mLastDisplayValue(0.f), + mStatType(STAT_NONE) { - if (!mStatp) - { -// llinfos << "No stats for statistics bar!" << llendl; - return; - } + mFloatingTargetMinBar = mTargetMinBar; + mFloatingTargetMaxBar = mTargetMaxBar; - // Get the values. - F32 current, min, max, mean; - if (mPerSec) + mStat.valid = NULL; + // tick value will be automatically calculated later + if (!p.tick_spacing.isProvided() && p.bar_min.isProvided() && p.bar_max.isProvided()) { - current = mStatp->getCurrentPerSec(); - min = mStatp->getMinPerSec(); - max = mStatp->getMaxPerSec(); - mean = mStatp->getMeanPerSec(); + mTickSpacing = calc_tick_value(mTargetMinBar, mTargetMaxBar); } - else + + setStat(p.stat); +} + +BOOL LLStatBar::handleHover(S32 x, S32 y, MASK mask) +{ + switch(mStatType) { - current = mStatp->getCurrent(); - min = mStatp->getMin(); - max = mStatp->getMax(); - mean = mStatp->getMean(); + case STAT_COUNT: + LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.countStatp->getDescription()).sticky_rect(calcScreenRect())); + break; + case STAT_EVENT: + LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.eventStatp->getDescription()).sticky_rect(calcScreenRect())); + break; + case STAT_SAMPLE: + LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.sampleStatp->getDescription()).sticky_rect(calcScreenRect())); + break; + case STAT_MEM: + LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.memStatp->getDescription()).sticky_rect(calcScreenRect())); + break; + default: + break; } + return TRUE; +} - - if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) +BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) +{ + BOOL handled = LLView::handleMouseDown(x, y, mask); + if (!handled) { - if (mDisplayMean) + if (mDisplayBar) { - mValue = mean; + if (mDisplayHistory || mOrientation == HORIZONTAL) + { + mDisplayBar = FALSE; + mDisplayHistory = FALSE; + } + else + { + mDisplayHistory = TRUE; + } } else { - mValue = current; + mDisplayBar = TRUE; + if (mOrientation == HORIZONTAL) + { + mDisplayHistory = TRUE; + } } - mUpdateTimer.reset(); + LLView* parent = getParent(); + parent->reshape(parent->getRect().getWidth(), parent->getRect().getHeight(), FALSE); } + return TRUE; +} - 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; +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); - F32 value_scale = max_width/(mMaxBar - mMinBar); + for (S32 i = 2; i < periodic_recording.getNumRecordedPeriods(); i++) + { + LLTrace::Recording& recording = periodic_recording.getPrevRecording(i); + F64 cur_value = recording.getLastValue(stat); - LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), - LLFontGL::LEFT, LLFontGL::TOP); + if (last_value != cur_value) + { + if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; + time_since_value_changed = (F32Seconds)0; + } + last_value = cur_value; + + elapsed_time += recording.getDuration(); + if (elapsed_time > time_period) break; + } - std::string value_format; - std::string value_str; - if (!mUnitLabel.empty()) + 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; + S32 decimal_digits = mDecimalDigits; + + switch(mStatType) { - value_format = llformat( "%%.%df%%s", mPrecision); - value_str = llformat( value_format.c_str(), mValue, mUnitLabel.c_str()); + case STAT_COUNT: + { + const LLTrace::StatType<LLTrace::CountAccumulator>& count_stat = *mStat.countStatp; + + unit_label = std::string(count_stat.getUnitLabel()) + "/s"; + 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; + } + break; + case STAT_EVENT: + { + const LLTrace::StatType<LLTrace::EventAccumulator>& event_stat = *mStat.eventStatp; + + 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); + display_value = mean; + } + break; + case STAT_SAMPLE: + { + const LLTrace::StatType<LLTrace::SampleAccumulator>& sample_stat = *mStat.sampleStatp; + + 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 (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC) + { + display_value = mean; + } + else + { + display_value = current; + // always display current value, don't rate limit + mLastDisplayValue = current; + if (is_approx_equal((F32)(S32)display_value, display_value)) + { + decimal_digits = 0; + } + } + } + break; + case STAT_MEM: + { + const LLTrace::StatType<LLTrace::MemAccumulator>& mem_stat = *mStat.memStatp; + + unit_label = mUnitLabel.empty() ? mem_stat.getUnitLabel() : mUnitLabel; + current = last_frame_recording.getLastValue(mem_stat).value(); + min = frame_recording.getPeriodMin(mem_stat, num_frames).value(); + max = frame_recording.getPeriodMax(mem_stat, num_frames).value(); + mean = frame_recording.getPeriodMean(mem_stat, num_frames).value(); + display_value = current; + } + break; + default: + break; } - else + + LLRect bar_rect; + if (mOrientation == HORIZONTAL) { - value_format = llformat( "%%.%df", mPrecision); - value_str = llformat( value_format.c_str(), mValue); + 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); } - // 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); + mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mTargetMaxBar, 0.05f); + mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mTargetMinBar, 0.05f); - value_format = llformat( "%%.%df", mPrecision); - if (mDisplayBar) + // rate limited updates + if (mLastDisplayValueTimer.getElapsedTimeF32() < MEAN_VALUE_UPDATE_TIME) { - std::string tick_label; + display_value = mLastDisplayValue; + } + else + { + mLastDisplayValueTimer.reset(); + } + drawLabelAndValue(display_value, unit_label, bar_rect, decimal_digits); + mLastDisplayValue = display_value; + if (mDisplayBar && mStat.valid) + { // 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; + } - right = (S32) ((max - mMinBar) * value_scale); - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); + 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)); + } - S32 num_values = mStatp->getNumValues() - 1; - if (mDisplayHistory) - { - S32 i; - for (i = 0; i < num_values; i++) + F32 span = (mOrientation == HORIZONTAL) + ? (bar_rect.getWidth()) + : (bar_rect.getHeight()); + + if (mDisplayHistory && mStat.valid) { - if (i == mStatp->getNextBin()) + const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; + F32 min_value = 0.f, + max_value = 0.f; + + 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 (S32 i = 1; i <= max_frame; i++) { - continue; + F32 offset = ((F32)i / (F32)num_frames) * span; + LLTrace::Recording& recording = frame_recording.getPrevRecording(i); + + switch(mStatType) + { + case STAT_COUNT: + min_value = recording.getPerSec(*mStat.countStatp); + max_value = min_value; + num_samples = recording.getSampleCount(*mStat.countStatp); + break; + case STAT_EVENT: + min_value = recording.getMin(*mStat.eventStatp); + max_value = recording.getMax(*mStat.eventStatp); + num_samples = recording.getSampleCount(*mStat.eventStatp); + break; + case STAT_SAMPLE: + min_value = recording.getMin(*mStat.sampleStatp); + max_value = recording.getMax(*mStat.sampleStatp); + num_samples = recording.getSampleCount(*mStat.sampleStatp); + break; + case STAT_MEM: + min_value = recording.getMin(*mStat.memStatp).value(); + max_value = recording.getMax(*mStat.memStatp).value(); + num_samples = 1; + break; + default: + break; + } + + if (!num_samples) continue; + + F32 min = (min_value - mCurMinBar) * value_scale; + F32 max = llmax(min + 1, (max_value - mCurMinBar) * value_scale); + if (mOrientation == HORIZONTAL) + { + gGL.vertex2f((F32)bar_rect.mRight - offset, max); + gGL.vertex2f((F32)bar_rect.mRight - offset, min); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, min); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, max); + } + else + { + gGL.vertex2f(min, (F32)bar_rect.mBottom + offset + 1); + gGL.vertex2f(min, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(max, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(max, (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) +{ + using namespace LLTrace; + const StatType<CountAccumulator>* count_stat; + const StatType<EventAccumulator>* event_stat; + const StatType<SampleAccumulator>* sample_stat; + const StatType<MemAccumulator>* mem_stat; + + if ((count_stat = StatType<CountAccumulator>::getInstance(stat_name))) + { + mStat.countStatp = count_stat; + mStatType = STAT_COUNT; + } + else if ((event_stat = StatType<EventAccumulator>::getInstance(stat_name))) + { + mStat.eventStatp = event_stat; + mStatType = STAT_EVENT; + } + else if ((sample_stat = StatType<SampleAccumulator>::getInstance(stat_name))) + { + mStat.sampleStatp = sample_stat; + mStatType = STAT_SAMPLE; + } + else if ((mem_stat = StatType<MemAccumulator>::getInstance(stat_name))) + { + mStat.memStatp = mem_stat; + mStatType = STAT_MEM; + } +} + + +void LLStatBar::setRange(F32 bar_min, F32 bar_max) { - mMinBar = bar_min; - mMaxBar = bar_max; - mTickSpacing = tick_spacing; - mLabelSpacing = label_spacing; + mTargetMinBar = llmin(bar_min, bar_max); + mTargetMaxBar = llmax(bar_min, bar_max); + mFloatingTargetMinBar = mTargetMinBar; + mFloatingTargetMaxBar = mTargetMaxBar; + mTickSpacing = calc_tick_value(mTargetMinBar, mTargetMaxBar); } LLRect LLStatBar::getRequiredRect() @@ -272,7 +598,7 @@ LLRect LLStatBar::getRequiredRect() { if (mDisplayHistory) { - rect.mTop = 35 + mStatp->getNumBins(); + rect.mTop = mMaxHeight; } else { @@ -285,3 +611,122 @@ LLRect LLStatBar::getRequiredRect() } return rect; } + +void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_rect, S32 decimal_digits ) +{ + LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), + LLFontGL::LEFT, LLFontGL::TOP); + + 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 || mAutoScaleMin) + { + F32 u = LLSmoothInterpolation::getInterpolant(10.f); + mFloatingTargetMinBar = llmin(min, lerp(mFloatingTargetMinBar, min, u)); + mFloatingTargetMaxBar = llmax(max, lerp(mFloatingTargetMaxBar, max, u)); + F32 range_min = mAutoScaleMin ? mFloatingTargetMinBar : mTargetMinBar; + F32 range_max = mAutoScaleMax ? mFloatingTargetMaxBar : mTargetMaxBar; + F32 tick_value = 0.f; + calc_auto_scale_range(range_min, range_max, tick_value); + if (mAutoScaleMin) { mTargetMinBar = range_min; } + if (mAutoScaleMax) { mTargetMaxBar = range_max; } + if (mAutoScaleMin && mAutoScaleMax) + { + mTickSpacing = tick_value; + } + else + { + mTickSpacing = calc_tick_value(mTargetMinBar, mTargetMaxBar); + } + } + + // 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 = S32_MIN; + S32 last_label = S32_MIN; + if (mTickSpacing > 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 / mTickSpacing) * -mTickSpacing + : 0.f; + for (F32 tick_value = start; ;tick_value += mTickSpacing) + { + // clamp to S32_MAX / 2 to avoid floating point to integer overflow resulting in S32_MIN + const S32 tick_begin = llfloor(llmin((F32)(S32_MAX / 2), (tick_value - mCurMinBar)*value_scale)); + const S32 tick_end = tick_begin + TICK_WIDTH; + if (tick_begin < last_tick + MIN_TICK_SPACING) + { + continue; + } + last_tick = tick_begin; + + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)tick_value, tick_value)) + { + decimal_digits = 0; + } + std::string tick_label = llformat("%.*f", decimal_digits, tick_value); + S32 tick_label_width = LLFontGL::getFontMonospace()->getWidth(tick_label); + if (mOrientation == HORIZONTAL) + { + if (tick_begin > last_label + MIN_LABEL_SPACING) + { + gl_rect_2d(bar_rect.mLeft, tick_end, bar_rect.mRight - TICK_LENGTH, tick_begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_rect.mRight, tick_begin, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::LEFT, LLFontGL::VCENTER); + last_label = tick_begin; + } + else + { + gl_rect_2d(bar_rect.mLeft, tick_end, bar_rect.mRight - TICK_LENGTH/2, tick_begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } + } + else + { + if (tick_begin > last_label + MIN_LABEL_SPACING) + { + gl_rect_2d(tick_begin, bar_rect.mTop, tick_end, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.25f)); + S32 label_pos = tick_begin - llround((F32)tick_label_width * ((F32)tick_begin / (F32)bar_rect.getWidth())); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, label_pos, bar_rect.mBottom - TICK_LENGTH, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::LEFT, LLFontGL::TOP); + last_label = label_pos; + } + else + { + gl_rect_2d(tick_begin, bar_rect.mTop, tick_end, bar_rect.mBottom - TICK_LENGTH/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } + } + // always draw one tick value past tick_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..89d7ff24ed 100755 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -29,74 +29,92 @@ #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<bool> show_bar, + show_history, + scale_range; + + Optional<S32> decimal_digits, + 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 getRange(F32& bar_min, F32& bar_max) { bar_min = mMinBar; bar_max = mMaxBar; } + void setRange(F32 bar_min, F32 bar_max); + void getRange(F32& bar_min, F32& bar_max) { bar_min = mTargetMinBar; bar_max = mTargetMaxBar; } /*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, S32 decimal_digits ); + void drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ); + + F32 mTargetMinBar, + mTargetMaxBar, + mFloatingTargetMinBar, + mFloatingTargetMaxBar, + mCurMaxBar, + mCurMinBar, + mLabelSpacing, + mTickSpacing; + S32 mDecimalDigits, + mNumHistoryFrames, + mNumShortHistoryFrames; + S32 mMaxHeight; + EOrientation mOrientation; + F32 mLastDisplayValue; + LLFrameTimer mLastDisplayValueTimer; + + enum + { + STAT_NONE, + STAT_COUNT, + STAT_EVENT, + STAT_SAMPLE, + STAT_MEM + } mStatType; + + union + { + void* valid; + const LLTrace::StatType<LLTrace::CountAccumulator>* countStatp; + const LLTrace::StatType<LLTrace::EventAccumulator>* eventStatp; + const LLTrace::StatType<LLTrace::SampleAccumulator>* sampleStatp; + const LLTrace::StatType<LLTrace::MemAccumulator>* memStatp; + } mStat; + + LLUIString mLabel; + std::string mUnitLabel; + + bool mDisplayBar, // Display the bar graph. + mDisplayHistory, + mAutoScaleMax, + mAutoScaleMin; }; #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..f381e92a4d 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::StatType<LLTrace::CountAccumulator>* > count_stat_float; + Alternative<LLTrace::StatType<LLTrace::EventAccumulator>* > event_stat_float; + Alternative<LLTrace::StatType<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::StatType<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/llstatview.h b/indra/llui/llstatview.h index 5abdc42448..bc78d3b5fd 100755 --- a/indra/llui/llstatview.h +++ b/indra/llui/llstatview.h @@ -46,7 +46,8 @@ public: Params() : setting("setting") { - changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT); + changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT); + changeDefault(show_label, true); } }; diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 76ba53ec32..65df0e5b80 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) @@ -1584,7 +1584,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 5ec4cf4fe5..eb25b95263 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -689,7 +689,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; } @@ -1259,13 +1259,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 @@ -1318,6 +1318,7 @@ void LLTextBase::replaceWithSuggestion(U32 index) // Insert the suggestion in its place LLWString suggestion = utf8str_to_wstring(mSuggestionList[index]); insertStringNoUndo(it->first, utf8str_to_wstring(mSuggestionList[index])); + setCursorPos(it->first + (S32)suggestion.length()); break; @@ -1436,10 +1437,10 @@ S32 LLTextBase::getLeftOffset(S32 width) } -static LLFastTimer::DeclareTimer FTM_TEXT_REFLOW ("Text Reflow"); +static LLTrace::BlockTimerStatHandle FTM_TEXT_REFLOW ("Text Reflow"); void LLTextBase::reflow() { - LLFastTimer ft(FTM_TEXT_REFLOW); + LL_RECORD_BLOCK_TIME(FTM_TEXT_REFLOW); updateSegments(); @@ -1481,7 +1482,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; } @@ -1778,10 +1779,10 @@ void LLTextBase::removeDocumentChild(LLView* view) } -static LLFastTimer::DeclareTimer FTM_UPDATE_TEXT_SEGMENTS("Update Text Segments"); +static LLTrace::BlockTimerStatHandle FTM_UPDATE_TEXT_SEGMENTS("Update Text Segments"); void LLTextBase::updateSegments() { - LLFastTimer ft(FTM_UPDATE_TEXT_SEGMENTS); + LL_RECORD_BLOCK_TIME(FTM_UPDATE_TEXT_SEGMENTS); createDefaultSegment(); } @@ -1870,7 +1871,6 @@ LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index) // when there are no segments, we return the end iterator, which must be checked by caller if (mSegments.size() <= 1) { return mSegments.begin(); } - //FIXME: avoid operator new somehow (without running into refcount problems) index_segment->setStart(index); index_segment->setEnd(index); segment_set_t::iterator it = mSegments.upper_bound(index_segment); @@ -2020,7 +2020,7 @@ static LLUIImagePtr image_from_icon_name(const std::string& icon_name) } } -static LLFastTimer::DeclareTimer FTM_PARSE_HTML("Parse HTML"); +static LLTrace::BlockTimerStatHandle FTM_PARSE_HTML("Parse HTML"); void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params) { @@ -2030,7 +2030,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para S32 part = (S32)LLTextParser::WHOLE; if (mParseHTML && !style_params.is_link) // Don't search for URLs inside a link segment (STORM-358). { - LLFastTimer _(FTM_PARSE_HTML); + LL_RECORD_BLOCK_TIME(FTM_PARSE_HTML); S32 start=0,end=0; LLUrlMatch match; std::string text = new_text; @@ -2097,11 +2097,11 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para } } -static LLFastTimer::DeclareTimer FTM_APPEND_TEXT("Append Text"); +static LLTrace::BlockTimerStatHandle FTM_APPEND_TEXT("Append Text"); void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params) { - LLFastTimer _(FTM_APPEND_TEXT); + LL_RECORD_BLOCK_TIME(FTM_APPEND_TEXT); if (new_text.empty()) return; @@ -2150,7 +2150,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); } @@ -3197,7 +3197,7 @@ 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; } mTooltip = tooltip; @@ -3253,14 +3253,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( (offsetLength + 1) < max_chars) { - llinfos << "offsetString.length() + 1 < max_chars\t max_chars:\t" << max_chars << "\toffsetLength:\t" << offsetLength << " 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" << offsetLength << " getLength() : " + << getLength() << "\tsegment_offset:\t" << segment_offset << "\tmStart:\t" << mStart << "\tsegments\t" << mEditor.mSegments.size() << LL_ENDL; } S32 num_chars = mStyle->getFont()->maxDrawableChars( text.c_str() + (segment_offset + mStart), @@ -3290,13 +3290,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 a74e97cac8..87f1a10cc5 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -51,10 +51,15 @@ 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: - LLTextSegment(S32 start, S32 end) : mStart(start), mEnd(end){}; + LLTextSegment(S32 start, S32 end) + : mStart(start), + mEnd(end) + {} virtual ~LLTextSegment(); virtual bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; @@ -92,10 +97,10 @@ 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; } protected: S32 mStart; @@ -327,7 +332,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; @@ -606,7 +611,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 62140dd9d6..aa0d16115e 100755 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -792,7 +792,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; } @@ -2512,13 +2512,13 @@ BOOL LLTextEditor::tryToRevertToPristineState() } -static LLFastTimer::DeclareTimer FTM_SYNTAX_HIGHLIGHTING("Syntax Highlighting"); +static LLTrace::BlockTimerStatHandle FTM_SYNTAX_HIGHLIGHTING("Syntax Highlighting"); void LLTextEditor::loadKeywords(const std::string& filename, const std::vector<std::string>& funcs, const std::vector<std::string>& tooltips, const LLColor3& color) { - LLFastTimer ft(FTM_SYNTAX_HIGHLIGHTING); + LL_RECORD_BLOCK_TIME(FTM_SYNTAX_HIGHLIGHTING); if(mKeywords.loadFromFile(filename)) { S32 count = llmin(funcs.size(), tooltips.size()); @@ -2543,7 +2543,7 @@ void LLTextEditor::updateSegments() { if (mReflowIndex < S32_MAX && mKeywords.isLoaded() && mParseOnTheFly) { - LLFastTimer ft(FTM_SYNTAX_HIGHLIGHTING); + LL_RECORD_BLOCK_TIME(FTM_SYNTAX_HIGHLIGHTING); // HACK: No non-ascii keywords for now segment_vec_t segment_list; mKeywords.findSegments(&segment_list, getWText(), mDefaultColor.get(), *this); @@ -2614,20 +2614,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; } @@ -2635,13 +2635,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; } @@ -2650,21 +2650,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; } @@ -2727,7 +2727,7 @@ void LLTextEditor::resetPreedit() { if (hasPreeditString()) { - llwarns << "Preedit and selection!" << llendl; + LL_WARNS() << "Preedit and selection!" << LL_ENDL; deselect(); } else @@ -2737,6 +2737,12 @@ void LLTextEditor::resetPreedit() } if (hasPreeditString()) { + if (hasSelection()) + { + LL_WARNS() << "Preedit and selection!" << LL_ENDL; + deselect(); + } + setCursorPos(mPreeditPositions.front()); removeStringNoUndo(mCursorPos, mPreeditPositions.back() - mCursorPos); insertStringNoUndo(mCursorPos, mPreeditOverwrittenWString); @@ -2926,7 +2932,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 d3b7bc0eb7..3a96d8ed24 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 928e82cb8c..040930aea5 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 743951a41f..e58ab6fc81 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..4d4ff4236d 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; } @@ -135,14 +135,14 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) -static LLFastTimer::DeclareTimer FTM_GET_TRANS("Translate string"); +static LLTrace::BlockTimerStatHandle FTM_GET_TRANS("Translate string"); //static std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC - LLFastTimer timer(FTM_GET_TRANS); + LL_RECORD_BLOCK_TIME(FTM_GET_TRANS); template_map_t::iterator iter = sStringTemplates.find(xml_desc); if (iter != sStringTemplates.end()) @@ -166,7 +166,7 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC - LLFastTimer timer(FTM_GET_TRANS); + LL_RECORD_BLOCK_TIME(FTM_GET_TRANS); template_map_t::iterator iter = sStringTemplates.find(xml_desc); if (iter != sStringTemplates.end()) @@ -185,7 +185,7 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args //static bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) { - LLFastTimer timer(FTM_GET_TRANS); + LL_RECORD_BLOCK_TIME(FTM_GET_TRANS); template_map_t::iterator iter = sStringTemplates.find(xml_desc); if (iter != sStringTemplates.end()) @@ -207,7 +207,7 @@ bool LLTrans::findString(std::string &result, const std::string &xml_desc, const //static bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLSD& msg_args) { - LLFastTimer timer(FTM_GET_TRANS); + LL_RECORD_BLOCK_TIME(FTM_GET_TRANS); template_map_t::iterator iter = sStringTemplates.find(xml_desc); if (iter != sStringTemplates.end()) 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 0bc4424a8c..b162f25887 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 1722bf27bd..df74e113e9 100755 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -33,6 +33,8 @@ #include "llfocusmgr.h" #include "llpanel.h" #include "lluictrlfactory.h" +#include "lltabcontainer.h" +#include "llaccordionctrltab.h" static LLDefaultChildRegistry::Register<LLUICtrl> r("ui_ctrl"); @@ -118,6 +120,7 @@ LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) mDoubleClickSignal(NULL), mTransparencyType(TT_DEFAULT) { + claimMem(viewmodel.get()); } void LLUICtrl::initFromParams(const Params& p) @@ -211,7 +214,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 +260,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; @@ -309,7 +312,7 @@ void LLUICtrl::onMouseLeave(S32 x, S32 y, MASK mask) BOOL LLUICtrl::handleMouseDown(S32 x, S32 y, MASK mask) { - lldebugs << "LLUICtrl::handleMouseDown calling LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << llendl; + LL_DEBUGS() << "LLUICtrl::handleMouseDown calling LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL; BOOL handled = LLView::handleMouseDown(x,y,mask); @@ -317,7 +320,7 @@ BOOL LLUICtrl::handleMouseDown(S32 x, S32 y, MASK mask) { (*mMouseDownSignal)(this,x,y,mask); } - lldebugs << "LLUICtrl::handleMousedown - handled is returning as: " << handled << " " << llendl; + LL_DEBUGS() << "LLUICtrl::handleMousedown - handled is returning as: " << handled << " " << LL_ENDL; if (handled) { LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-56,-56,getPathname()); @@ -329,7 +332,7 @@ BOOL LLUICtrl::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLUICtrl::handleMouseUp(S32 x, S32 y, MASK mask) { - lldebugs << "LLUICtrl::handleMouseUp calling LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << llendl; + LL_DEBUGS() << "LLUICtrl::handleMouseUp calling LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL; BOOL handled = LLView::handleMouseUp(x,y,mask); if (handled) { @@ -340,7 +343,7 @@ BOOL LLUICtrl::handleMouseUp(S32 x, S32 y, MASK mask) (*mMouseUpSignal)(this,x,y,mask); } - lldebugs << "LLUICtrl::handleMouseUp - handled for xui " << getPathname() << " - is returning as: " << handled << " " << llendl; + LL_DEBUGS() << "LLUICtrl::handleMouseUp - handled for xui " << getPathname() << " - is returning as: " << handled << " " << LL_ENDL; return handled; } @@ -469,7 +472,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; } @@ -719,54 +722,19 @@ BOOL LLUICtrl::getIsChrome() const } } -// this comparator uses the crazy disambiguating logic of LLCompareByTabOrder, -// but to switch up the order so that children that have the default tab group come first -// and those that are prior to the default tab group come last -class CompareByDefaultTabGroup: public LLCompareByTabOrder -{ -public: - CompareByDefaultTabGroup(const LLView::child_tab_order_t& order, S32 default_tab_group): - LLCompareByTabOrder(order), - mDefaultTabGroup(default_tab_group) {} -private: - /*virtual*/ bool compareTabOrders(const LLView::tab_order_t & a, const LLView::tab_order_t & b) const - { - S32 ag = a.first; // tab group for a - S32 bg = b.first; // tab group for b - // these two ifs have the effect of moving elements prior to the default tab group to the end of the list - // (still sorted relative to each other, though) - if(ag < mDefaultTabGroup && bg >= mDefaultTabGroup) return false; - if(bg < mDefaultTabGroup && ag >= mDefaultTabGroup) return true; - return a < b; // sort correctly if they're both on the same side of the default tab group - } - S32 mDefaultTabGroup; -}; -// Sorter for plugging into the query. -// I'd have defined it local to the one method that uses it but that broke the VS 05 compiler. -MG -class LLUICtrl::DefaultTabGroupFirstSorter : public LLQuerySorter, public LLSingleton<DefaultTabGroupFirstSorter> -{ -public: - /*virtual*/ void operator() (LLView * parent, viewList_t &children) const - { - children.sort(CompareByDefaultTabGroup(parent->getCtrlOrder(), parent->getDefaultTabGroup())); - } -}; - -LLFastTimer::DeclareTimer FTM_FOCUS_FIRST_ITEM("Focus First Item"); +LLTrace::BlockTimerStatHandle FTM_FOCUS_FIRST_ITEM("Focus First Item"); BOOL LLUICtrl::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash) { - LLFastTimer _(FTM_FOCUS_FIRST_ITEM); + LL_RECORD_BLOCK_TIME(FTM_FOCUS_FIRST_ITEM); // try to select default tab group child - LLCtrlQuery query = getTabOrderQuery(); - // sort things such that the default tab group is at the front - query.setSorter(DefaultTabGroupFirstSorter::getInstance()); + LLViewQuery query = getTabOrderQuery(); child_list_t result = query(this); if(result.size() > 0) { - LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front()); + LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back()); if(!ctrl->hasFocus()) { ctrl->setFocus(TRUE); @@ -781,17 +749,20 @@ BOOL LLUICtrl::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash) // search for text field first if(prefer_text_fields) { - LLCtrlQuery query = getTabOrderQuery(); + LLViewQuery query = getTabOrderQuery(); query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance()); child_list_t result = query(this); if(result.size() > 0) { - LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front()); + LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back()); if(!ctrl->hasFocus()) { ctrl->setFocus(TRUE); ctrl->onTabInto(); - gFocusMgr.triggerFocusFlash(); + if(focus_flash) + { + gFocusMgr.triggerFocusFlash(); + } } return TRUE; } @@ -800,58 +771,26 @@ BOOL LLUICtrl::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash) result = getTabOrderQuery().run(this); if(result.size() > 0) { - LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front()); + LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back()); if(!ctrl->hasFocus()) { ctrl->setFocus(TRUE); ctrl->onTabInto(); - gFocusMgr.triggerFocusFlash(); - } - return TRUE; - } - return FALSE; -} - -BOOL LLUICtrl::focusLastItem(BOOL prefer_text_fields) -{ - // search for text field first - if(prefer_text_fields) - { - LLCtrlQuery query = getTabOrderQuery(); - query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance()); - child_list_t result = query(this); - if(result.size() > 0) - { - LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back()); - if(!ctrl->hasFocus()) + if(focus_flash) { - ctrl->setFocus(TRUE); - ctrl->onTabInto(); gFocusMgr.triggerFocusFlash(); } - return TRUE; - } - } - // no text field found, or we don't care about text fields - child_list_t result = getTabOrderQuery().run(this); - if(result.size() > 0) - { - LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back()); - if(!ctrl->hasFocus()) - { - ctrl->setFocus(TRUE); - ctrl->onTabInto(); - gFocusMgr.triggerFocusFlash(); } return TRUE; } return FALSE; } + BOOL LLUICtrl::focusNextItem(BOOL text_fields_only) { // this assumes that this method is called on the focus root. - LLCtrlQuery query = getTabOrderQuery(); + LLViewQuery query = getTabOrderQuery(); static LLUICachedControl<bool> tab_to_text_fields_only ("TabToTextFieldsOnly", false); if(text_fields_only || tab_to_text_fields_only) { @@ -864,7 +803,7 @@ BOOL LLUICtrl::focusNextItem(BOOL text_fields_only) BOOL LLUICtrl::focusPrevItem(BOOL text_fields_only) { // this assumes that this method is called on the focus root. - LLCtrlQuery query = getTabOrderQuery(); + LLViewQuery query = getTabOrderQuery(); static LLUICachedControl<bool> tab_to_text_fields_only ("TabToTextFieldsOnly", false); if(text_fields_only || tab_to_text_fields_only) { @@ -921,8 +860,26 @@ bool LLUICtrl::findHelpTopic(std::string& help_topic_out) if (panel) { + + LLView *child; + LLPanel *subpanel = NULL; + // does the panel have a sub-panel with a help topic? - LLPanel *subpanel = panel->childGetVisiblePanelWithHelp(); + bfs_tree_iterator_t it = beginTreeBFS(); + // skip ourselves + ++it; + for (; it != endTreeBFS(); ++it) + { + child = *it; + // do we have a panel with a help topic? + LLPanel *panel = dynamic_cast<LLPanel *>(child); + if (panel && panel->isInVisibleChain() && !panel->getHelpTopic().empty()) + { + subpanel = panel; + break; + } + } + if (subpanel) { help_topic_out = subpanel->getHelpTopic(); @@ -930,10 +887,41 @@ bool LLUICtrl::findHelpTopic(std::string& help_topic_out) } // does the panel have an active tab with a help topic? - LLPanel *tab = panel->childGetVisibleTabWithHelp(); - if (tab) + LLPanel *tab_panel = NULL; + + it = beginTreeBFS(); + // skip ourselves + ++it; + for (; it != endTreeBFS(); ++it) + { + child = *it; + LLPanel *curTabPanel = NULL; + + // do we have a tab container? + LLTabContainer *tab = dynamic_cast<LLTabContainer *>(child); + if (tab && tab->getVisible()) + { + curTabPanel = tab->getCurrentPanel(); + } + + // do we have an accordion tab? + LLAccordionCtrlTab* accordion = dynamic_cast<LLAccordionCtrlTab *>(child); + if (accordion && accordion->getDisplayChildren()) + { + curTabPanel = dynamic_cast<LLPanel *>(accordion->getAccordionView()); + } + + // if we found a valid tab, does it have a help topic? + if (curTabPanel && !curTabPanel->getHelpTopic().empty()) + { + tab_panel = curTabPanel; + break; + } + } + + if (tab_panel) { - help_topic_out = tab->getHelpTopic(); + help_topic_out = tab_panel->getHelpTopic(); return true; // success (tab) } @@ -959,6 +947,8 @@ 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(); + claimMem(mValidateSignal); + return mValidateSignal->connect(boost::bind(cb, _2)); } @@ -1022,54 +1012,72 @@ 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(); + claimMem(mCommitSignal); + return mCommitSignal->connect(cb); } boost::signals2::connection LLUICtrl::setValidateCallback( const enable_signal_t::slot_type& cb ) { if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + claimMem(mValidateSignal); + return mValidateSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { if (!mMouseEnterSignal) mMouseEnterSignal = new commit_signal_t(); + claimMem(mMouseEnterSignal); + return mMouseEnterSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { if (!mMouseLeaveSignal) mMouseLeaveSignal = new commit_signal_t(); + claimMem(mMouseLeaveSignal); + return mMouseLeaveSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseDownCallback( const mouse_signal_t::slot_type& cb ) { if (!mMouseDownSignal) mMouseDownSignal = new mouse_signal_t(); + claimMem(mMouseDownSignal); + return mMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseUpCallback( const mouse_signal_t::slot_type& cb ) { if (!mMouseUpSignal) mMouseUpSignal = new mouse_signal_t(); + claimMem(mMouseUpSignal); + return mMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ) { if (!mRightMouseDownSignal) mRightMouseDownSignal = new mouse_signal_t(); + claimMem(mRightMouseDownSignal); + return mRightMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ) { if (!mRightMouseUpSignal) mRightMouseUpSignal = new mouse_signal_t(); + claimMem(mRightMouseUpSignal); + return mRightMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setDoubleClickCallback( const mouse_signal_t::slot_type& cb ) { if (!mDoubleClickSignal) mDoubleClickSignal = new mouse_signal_t(); + claimMem(mDoubleClickSignal); + return mDoubleClickSignal->connect(cb); } diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index fb2196bb16..99553ee0d2 100755 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -220,7 +220,6 @@ public: BOOL focusNextItem(BOOL text_entry_only); BOOL focusPrevItem(BOOL text_entry_only); BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); - BOOL focusLastItem(BOOL prefer_text_fields = FALSE); // Non Virtuals LLHandle<LLUICtrl> getHandle() const { return getDerivedHandle<LLUICtrl>(); } @@ -315,8 +314,6 @@ private: BOOL mTentative; ETypeTransparency mTransparencyType; - - class DefaultTabGroupFirstSorter; }; // Build time optimization, generate once in .cpp file diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 60fee47ae0..4cc7da1267 100755 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -44,9 +44,9 @@ // this library includes #include "llpanel.h" -LLFastTimer::DeclareTimer FTM_WIDGET_CONSTRUCTION("Widget Construction"); -LLFastTimer::DeclareTimer FTM_INIT_FROM_PARAMS("Widget InitFromParams"); -LLFastTimer::DeclareTimer FTM_WIDGET_SETUP("Widget Setup"); +LLTrace::BlockTimerStatHandle FTM_WIDGET_CONSTRUCTION("Widget Construction"); +LLTrace::BlockTimerStatHandle FTM_INIT_FROM_PARAMS("Widget InitFromParams"); +LLTrace::BlockTimerStatHandle FTM_WIDGET_SETUP("Widget Setup"); //----------------------------------------------------------------------------- @@ -105,12 +105,12 @@ void LLUICtrlFactory::loadWidgetTemplate(const std::string& widget_tag, LLInitPa } } -static LLFastTimer::DeclareTimer FTM_CREATE_CHILDREN("Create XUI Children"); +static LLTrace::BlockTimerStatHandle FTM_CREATE_CHILDREN("Create XUI Children"); //static void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, const widget_registry_t& registry, LLXMLNodePtr output_node) { - LLFastTimer ft(FTM_CREATE_CHILDREN); + LL_RECORD_BLOCK_TIME(FTM_CREATE_CHILDREN); if (node.isNull()) return; for (LLXMLNodePtr child_node = node->getFirstChild(); child_node.notNull(); child_node = child_node->getNextSibling()) @@ -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; } } @@ -147,14 +147,14 @@ void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, const wid } -static LLFastTimer::DeclareTimer FTM_XML_PARSE("XML Reading/Parsing"); +static LLTrace::BlockTimerStatHandle FTM_XML_PARSE("XML Reading/Parsing"); //----------------------------------------------------------------------------- // getLayeredXMLNode() //----------------------------------------------------------------------------- bool LLUICtrlFactory::getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr& root, LLDir::ESkinConstraint constraint) { - LLFastTimer timer(FTM_XML_PARSE); + LL_RECORD_BLOCK_TIME(FTM_XML_PARSE); std::vector<std::string> paths = gDirUtilp->findSkinnedFilenames(LLDir::XUI, xui_filename, constraint); @@ -179,11 +179,11 @@ S32 LLUICtrlFactory::saveToXML(LLView* viewp, const std::string& filename) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -static LLFastTimer::DeclareTimer FTM_CREATE_FROM_XML("Create child widget"); +static LLTrace::BlockTimerStatHandle FTM_CREATE_FROM_XML("Create child widget"); LLView *LLUICtrlFactory::createFromXML(LLXMLNodePtr node, LLView* parent, const std::string& filename, const widget_registry_t& registry, LLXMLNodePtr output_node) { - LLFastTimer timer(FTM_CREATE_FROM_XML); + LL_RECORD_BLOCK_TIME(FTM_CREATE_FROM_XML); std::string ctrl_type = node->getName()->mString; LLStringUtil::toLower(ctrl_type); diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 876bb5ef46..a5796c8af2 100755 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -74,9 +74,9 @@ class LLWidgetNameRegistry //: public LLRegistrySingleton<const std::type_info*, empty_param_block_func_t, LLDefaultParamBlockRegistry> //{}; -extern LLFastTimer::DeclareTimer FTM_WIDGET_SETUP; -extern LLFastTimer::DeclareTimer FTM_WIDGET_CONSTRUCTION; -extern LLFastTimer::DeclareTimer FTM_INIT_FROM_PARAMS; +extern LLTrace::BlockTimerStatHandle FTM_WIDGET_SETUP; +extern LLTrace::BlockTimerStatHandle FTM_WIDGET_CONSTRUCTION; +extern LLTrace::BlockTimerStatHandle FTM_INIT_FROM_PARAMS; // Build time optimization, generate this once in .cpp file #ifndef LLUICTRLFACTORY_CPP @@ -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,14 +225,14 @@ 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; } - { LLFastTimer _(FTM_WIDGET_CONSTRUCTION); + { LL_RECORD_BLOCK_TIME(FTM_WIDGET_CONSTRUCTION); widget = new T(params); } - { LLFastTimer _(FTM_INIT_FROM_PARAMS); + { LL_RECORD_BLOCK_TIME(FTM_INIT_FROM_PARAMS); widget->initFromParams(params); } @@ -247,7 +247,7 @@ private: template<typename T> static T* defaultBuilder(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node) { - LLFastTimer timer(FTM_WIDGET_SETUP); + LL_RECORD_BLOCK_TIME(FTM_WIDGET_SETUP); typename T::Params params(getDefaultParams<T>()); @@ -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..98d0c215e6 100755 --- a/indra/llui/lluistring.cpp +++ b/indra/llui/lluistring.cpp @@ -26,10 +26,12 @@ #include "linden_common.h" #include "lluistring.h" + +#include "llfasttimer.h" #include "llsd.h" #include "lltrans.h" -LLFastTimer::DeclareTimer FTM_UI_STRING("UI String"); +LLTrace::BlockTimerStatHandle FTM_UI_STRING("UI String"); LLUIString::LLUIString(const std::string& instring, const LLStringUtil::format_map_t& args) @@ -54,7 +56,7 @@ void LLUIString::setArgList(const LLStringUtil::format_map_t& args) void LLUIString::setArgs(const LLSD& sd) { - LLFastTimer timer(FTM_UI_STRING); + LL_RECORD_BLOCK_TIME(FTM_UI_STRING); if (!sd.isMap()) return; for(LLSD::map_const_iterator sd_it = sd.beginMap(); @@ -117,7 +119,7 @@ void LLUIString::updateResult() const { mNeedsResult = false; - LLFastTimer timer(FTM_UI_STRING); + LL_RECORD_BLOCK_TIME(FTM_UI_STRING); // optimize for empty strings (don't attempt string replacement) if (mOrig.empty()) 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 b1cc502c4b..cfdc64d2bd 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -789,7 +789,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; } @@ -929,7 +929,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 20015dca1a..357948b6fe 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> @@ -87,6 +86,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) @@ -124,7 +133,8 @@ LLView::Params::Params() } LLView::LLView(const LLView::Params& p) -: mVisible(p.visible), +: LLTrace::MemTrackable<LLView>("LLView"), + mVisible(p.visible), mInDraw(false), mName(p.name), mParentView(NULL), @@ -132,7 +142,6 @@ LLView::LLView(const LLView::Params& p) mFromXUI(p.from_xui), mIsFocusRoot(p.focus_root), mLastVisible(FALSE), - mNextInsertionOrdinal(0), mHoverCursor(getCursorFromString(p.hover_cursor)), mEnabled(p.enabled), mMouseOpaque(p.mouse_opaque), @@ -151,10 +160,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); @@ -162,7 +171,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 ); } @@ -267,22 +276,6 @@ void LLView::sendChildToBack(LLView* child) } } -void LLView::moveChildToFrontOfTabGroup(LLUICtrl* child) -{ - if(mCtrlOrder.find(child) != mCtrlOrder.end()) - { - mCtrlOrder[child].second = -1 * mNextInsertionOrdinal++; - } -} - -void LLView::moveChildToBackOfTabGroup(LLUICtrl* child) -{ - if(mCtrlOrder.find(child) != mCtrlOrder.end()) - { - mCtrlOrder[child].second = mNextInsertionOrdinal++; - } -} - // virtual bool LLView::addChild(LLView* child, S32 tab_group) { @@ -290,9 +283,10 @@ bool LLView::addChild(LLView* child, S32 tab_group) { return false; } - if (mParentView == child) + + if (this == 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 @@ -304,14 +298,10 @@ bool LLView::addChild(LLView* child, S32 tab_group) // add to front of child list, as normal mChildList.push_front(child); - // add to ctrl list if is LLUICtrl - if (child->isCtrl()) + // add to tab order list + if (tab_group != 0) { - LLUICtrl* ctrl = static_cast<LLUICtrl*>(child); - mCtrlOrder.insert(tab_order_pair_t(ctrl, - tab_order_t(tab_group, mNextInsertionOrdinal))); - - mNextInsertionOrdinal++; + mTabOrder.insert(tab_order_pair_t(child, tab_group)); } child->mParentView = this; @@ -342,69 +332,19 @@ void LLView::removeChild(LLView* child) llassert(child->mInDraw == false); mChildList.remove( child ); child->mParentView = NULL; - if (child->isCtrl()) + child_tab_order_t::iterator found = mTabOrder.find(child); + if(found != mTabOrder.end()) { - child_tab_order_t::iterator found = mCtrlOrder.find(static_cast<LLUICtrl*>(child)); - if(found != mCtrlOrder.end()) - { - mCtrlOrder.erase(found); - } + mTabOrder.erase(found); } } else { - llwarns << "\"" << child->getName() << "\" is not a child of " << getName() << llendl; + LL_WARNS() << "\"" << child->getName() << "\" is not a child of " << getName() << LL_ENDL; } updateBoundingRect(); } -LLView::ctrl_list_t LLView::getCtrlList() const -{ - ctrl_list_t controls; - BOOST_FOREACH(LLView* viewp, mChildList) - { - if(viewp->isCtrl()) - { - controls.push_back(static_cast<LLUICtrl*>(viewp)); - } - } - return controls; -} - -LLView::ctrl_list_t LLView::getCtrlListSorted() const -{ - ctrl_list_t controls = getCtrlList(); - std::sort(controls.begin(), controls.end(), LLCompareByTabOrder(mCtrlOrder)); - return controls; -} - - -// This method compares two LLViews by the tab order specified in the comparator object. The -// code for this is a little convoluted because each argument can have four states: -// 1) not a control, 2) a control but not in the tab order, 3) a control in the tab order, 4) null -bool LLCompareByTabOrder::operator() (const LLView* const a, const LLView* const b) const -{ - S32 a_score = 0, b_score = 0; - if(a) a_score--; - if(b) b_score--; - if(a && a->isCtrl()) a_score--; - if(b && b->isCtrl()) b_score--; - if(a_score == -2 && b_score == -2) - { - const LLUICtrl * const a_ctrl = static_cast<const LLUICtrl*>(a); - const LLUICtrl * const b_ctrl = static_cast<const LLUICtrl*>(b); - LLView::child_tab_order_const_iter_t a_found = mTabOrder.find(a_ctrl), b_found = mTabOrder.find(b_ctrl); - if(a_found != mTabOrder.end()) a_score--; - if(b_found != mTabOrder.end()) b_score--; - if(a_score == -3 && b_score == -3) - { - // whew! Once we're in here, they're both in the tab order, and we can compare based on that - return compareTabOrders(a_found->second, b_found->second); - } - } - return (a_score == b_score) ? a < b : a_score < b_score; -} - BOOL LLView::isInVisibleChain() const { BOOL visible = TRUE; @@ -528,9 +468,9 @@ BOOL LLView::focusPrevRoot() // static BOOL LLView::focusNext(LLView::child_list_t & result) { - LLView::child_list_iter_t focused = result.end(); - for(LLView::child_list_iter_t iter = result.begin(); - iter != result.end(); + LLView::child_list_reverse_iter_t focused = result.rend(); + for(LLView::child_list_reverse_iter_t iter = result.rbegin(); + iter != result.rend(); ++iter) { if(gFocusMgr.childHasKeyboardFocus(*iter)) @@ -539,14 +479,14 @@ BOOL LLView::focusNext(LLView::child_list_t & result) break; } } - LLView::child_list_iter_t next = focused; - next = (next == result.end()) ? result.begin() : ++next; + LLView::child_list_reverse_iter_t next = focused; + next = (next == result.rend()) ? result.rbegin() : ++next; while(next != focused) { // wrap around to beginning if necessary - if(next == result.end()) + if(next == result.rend()) { - next = result.begin(); + next = result.rbegin(); } if((*next)->isCtrl()) { @@ -564,9 +504,9 @@ BOOL LLView::focusNext(LLView::child_list_t & result) // static BOOL LLView::focusPrev(LLView::child_list_t & result) { - LLView::child_list_reverse_iter_t focused = result.rend(); - for(LLView::child_list_reverse_iter_t iter = result.rbegin(); - iter != result.rend(); + LLView::child_list_iter_t focused = result.end(); + for(LLView::child_list_iter_t iter = result.begin(); + iter != result.end(); ++iter) { if(gFocusMgr.childHasKeyboardFocus(*iter)) @@ -575,14 +515,14 @@ BOOL LLView::focusPrev(LLView::child_list_t & result) break; } } - LLView::child_list_reverse_iter_t next = focused; - next = (next == result.rend()) ? result.rbegin() : ++next; + LLView::child_list_iter_t next = focused; + next = (next == result.end()) ? result.begin() : ++next; while(next != focused) { // wrap around to beginning if necessary - if(next == result.rend()) + if(next == result.end()) { - next = result.rbegin(); + next = result.begin(); } if((*next)->isCtrl()) { @@ -606,7 +546,7 @@ BOOL LLView::focusPrev(LLView::child_list_t & result) void LLView::deleteAllChildren() { // clear out the control ordering - mCtrlOrder.clear(); + mTabOrder.clear(); while (!mChildList.empty()) { @@ -635,14 +575,14 @@ 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 ) { BOOL old_visibility; BOOST_FOREACH(LLView* viewp, mChildList) @@ -657,13 +597,13 @@ void LLView::handleVisibilityChange ( BOOL new_visibility ) if (old_visibility) { - viewp->handleVisibilityChange ( new_visibility ); + viewp->onVisibilityChange ( new_visibility ); } // Consider changing returns to confirm success and know which widget grabbed it // For now assume success and log at highest xui possible // NOTE we log actual state - which may differ if it somehow failed to set visibility - lldebugs << "LLView::handleVisibilityChange - now: " << getVisible() << " xui: " << viewp->getPathname() << " name: " << viewp->getName() << llendl; + LL_DEBUGS() << "LLView::handleVisibilityChange - now: " << getVisible() << " xui: " << viewp->getPathname() << " name: " << viewp->getName() << LL_ENDL; } } @@ -693,12 +633,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) @@ -734,7 +674,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; } @@ -760,8 +700,8 @@ LLView* LLView::childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDA if ((viewp->*method)( local_x, local_y, extra ) || (allow_mouse_block && viewp->blockMouseEvent( local_x, local_y ))) { - lldebugs << "LLView::childrenHandleMouseEvent calling updatemouseeventinfo - local_x|global x "<< local_x << " " << x << "local/global y " << local_y << " " << y << llendl; - lldebugs << "LLView::childrenHandleMouseEvent getPathname for viewp result: " << viewp->getPathname() << "for this view: " << getPathname() << llendl; + LL_DEBUGS() << "LLView::childrenHandleMouseEvent calling updatemouseeventinfo - local_x|global x "<< local_x << " " << x << "local/global y " << local_y << " " << y << LL_ENDL; + LL_DEBUGS() << "LLView::childrenHandleMouseEvent getPathname for viewp result: " << viewp->getPathname() << "for this view: " << getPathname() << LL_ENDL; LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); @@ -938,7 +878,7 @@ BOOL LLView::handleKey(KEY key, MASK mask, BOOL called_from_parent) handled = handleKeyHere( key, mask ); if (handled) { - llwarns << "Key handled by " << getName() << llendl; + LL_WARNS() << "Key handled by " << getName() << LL_ENDL; } } } @@ -975,7 +915,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; } } } @@ -1157,7 +1097,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; } } } @@ -1531,11 +1471,11 @@ LLView* LLView::getChildView(const std::string& name, BOOL recurse) const return getChild<LLView>(name, recurse); } -static LLFastTimer::DeclareTimer FTM_FIND_VIEWS("Find Widgets"); +static LLTrace::BlockTimerStatHandle FTM_FIND_VIEWS("Find Widgets"); LLView* LLView::findChildView(const std::string& name, BOOL recurse) const { - LLFastTimer ft(FTM_FIND_VIEWS); + LL_RECORD_BLOCK_TIME(FTM_FIND_VIEWS); //richard: should we allow empty names? //if(name.empty()) // return NULL; @@ -1850,15 +1790,63 @@ BOOL LLView::localRectToOtherView( const LLRect& local, LLRect* other, const LLV return FALSE; } + +class CompareByTabOrder +{ +public: + CompareByTabOrder(const LLView::child_tab_order_t& order, S32 default_tab_group = 0) + : mTabOrder(order), + mDefaultTabGroup(default_tab_group) + {} + virtual ~CompareByTabOrder() {} + + // This method compares two LLViews by the tab order specified in the comparator object. The + // code for this is a little convoluted because each argument can have four states: + // 1) not a control, 2) a control but not in the tab order, 3) a control in the tab order, 4) null + bool operator() (const LLView* const a, const LLView* const b) const + { + S32 a_group = 0, b_group = 0; + if(!a) return false; + if(!b) return true; + + LLView::child_tab_order_const_iter_t a_found = mTabOrder.find(a), b_found = mTabOrder.find(b); + if(a_found != mTabOrder.end()) + { + a_group = a_found->second; + } + if(b_found != mTabOrder.end()) + { + b_group = b_found->second; + } + + if(a_group < mDefaultTabGroup && b_group >= mDefaultTabGroup) return true; + if(b_group < mDefaultTabGroup && a_group >= mDefaultTabGroup) return false; + return a_group > b_group; // sort correctly if they're both on the same side of the default tab groupreturn a > b; + } +private: + // ok to store a reference, as this should only be allocated on stack during view query operations + const LLView::child_tab_order_t& mTabOrder; + const S32 mDefaultTabGroup; +}; + +class SortByTabOrder : public LLQuerySorter, public LLSingleton<SortByTabOrder> +{ + /*virtual*/ void sort(LLView * parent, LLView::child_list_t &children) const + { + children.sort(CompareByTabOrder(parent->getTabOrder(), parent->getDefaultTabGroup())); + } +}; + // static -const LLCtrlQuery & LLView::getTabOrderQuery() +const LLViewQuery & LLView::getTabOrderQuery() { - static LLCtrlQuery query; + static LLViewQuery query; if(query.getPreFilters().size() == 0) { query.addPreFilter(LLVisibleFilter::getInstance()); query.addPreFilter(LLEnabledFilter::getInstance()); query.addPreFilter(LLTabStopFilter::getInstance()); query.addPostFilter(LLLeavesFilter::getInstance()); + query.setSorter(SortByTabOrder::getInstance()); } return query; } @@ -1873,9 +1861,9 @@ class LLFocusRootsFilter : public LLQueryFilter, public LLSingleton<LLFocusRoots }; // static -const LLCtrlQuery & LLView::getFocusRootsQuery() +const LLViewQuery & LLView::getFocusRootsQuery() { - static LLCtrlQuery query; + static LLViewQuery query; if(query.getPreFilters().size() == 0) { query.addPreFilter(LLVisibleFilter::getInstance()); query.addPreFilter(LLEnabledFilter::getInstance()); @@ -2027,7 +2015,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; } } @@ -2129,7 +2117,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; } } } @@ -2456,7 +2444,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..7861c8f729 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; @@ -163,7 +167,7 @@ protected: private: // widgets in general are not copyable - LLView(const LLView& other) {}; + LLView(const LLView& other); public: //#if LL_DEBUG static BOOL sIsDrawing; @@ -196,12 +200,9 @@ public: typedef child_list_t::reverse_iterator child_list_reverse_iter_t; typedef child_list_t::const_reverse_iterator child_list_const_reverse_iter_t; - typedef std::vector<class LLUICtrl *> ctrl_list_t; - - typedef std::pair<S32, S32> tab_order_t; - typedef std::pair<LLUICtrl *, tab_order_t> tab_order_pair_t; + typedef std::pair<LLView *, S32> tab_order_pair_t; // this structure primarily sorts by the tab group, secondarily by the insertion ordinal (lastly by the value of the pointer) - typedef std::map<const LLUICtrl*, tab_order_t> child_tab_order_t; + typedef std::map<const LLView*, S32> child_tab_order_t; typedef child_tab_order_t::iterator child_tab_order_iter_t; typedef child_tab_order_t::const_iterator child_tab_order_const_iter_t; typedef child_tab_order_t::reverse_iterator child_tab_order_reverse_iter_t; @@ -247,8 +248,6 @@ public: void sendChildToFront(LLView* child); void sendChildToBack(LLView* child); - void moveChildToFrontOfTabGroup(LLUICtrl* child); - void moveChildToBackOfTabGroup(LLUICtrl* child); virtual bool addChild(LLView* view, S32 tab_group = 0); @@ -260,9 +259,7 @@ public: virtual BOOL postBuild() { return TRUE; } - const child_tab_order_t& getCtrlOrder() const { return mCtrlOrder; } - ctrl_list_t getCtrlList() const; - ctrl_list_t getCtrlListSorted() const; + const child_tab_order_t& getTabOrder() const { return mTabOrder; } void setDefaultTabGroup(S32 d) { mDefaultTabGroup = d; } S32 getDefaultTabGroup() const { return mDefaultTabGroup; } @@ -303,7 +300,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); } @@ -496,9 +493,9 @@ public: static BOOL focusPrev(LLView::child_list_t & result); // returns query for iterating over controls in tab order - static const LLCtrlQuery & getTabOrderQuery(); + static const LLViewQuery & getTabOrderQuery(); // return query for iterating over focus roots in tab order - static const LLCtrlQuery & getFocusRootsQuery(); + static const LLViewQuery & getFocusRootsQuery(); static LLWindow* getWindow(void) { return LLUI::sWindow; } @@ -592,7 +589,7 @@ private: U32 mReshapeFlags; - child_tab_order_t mCtrlOrder; + child_tab_order_t mTabOrder; S32 mDefaultTabGroup; S32 mLastTabGroup; @@ -609,8 +606,6 @@ private: BOOL mLastVisible; - S32 mNextInsertionOrdinal; - bool mInDraw; static LLWindow* sWindow; // All root views must know about their window. @@ -673,17 +668,14 @@ public: static BOOL sForceReshape; }; -class LLCompareByTabOrder +namespace LLInitParam { -public: - LLCompareByTabOrder(const LLView::child_tab_order_t& order) : mTabOrder(order) {} - virtual ~LLCompareByTabOrder() {} - bool operator() (const LLView* const a, const LLView* const b) const; -private: - virtual bool compareTabOrders(const LLView::tab_order_t & a, const LLView::tab_order_t & b) const { return a < b; } - // ok to store a reference, as this should only be allocated on stack during view query operations - const LLView::child_tab_order_t& mTabOrder; +template<> +struct TypeValues<LLView::EOrientation> : public LLInitParam::TypeValuesHelper<LLView::EOrientation> +{ + static void declareValues(); }; +} template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) const { @@ -694,7 +686,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 +698,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/llviewereventrecorder.cpp b/indra/llui/llviewereventrecorder.cpp index a352f621eb..556b45a9ba 100644 --- a/indra/llui/llviewereventrecorder.cpp +++ b/indra/llui/llviewereventrecorder.cpp @@ -53,14 +53,14 @@ void LLViewerEventRecorder::setEventLoggingOn() { mLog.open(mLogFilename, llofstream::out); } logEvents=true; - lldebugs << "LLViewerEventRecorder::setEventLoggingOn event logging turned on" << llendl; + LL_DEBUGS() << "LLViewerEventRecorder::setEventLoggingOn event logging turned on" << LL_ENDL; } void LLViewerEventRecorder::setEventLoggingOff() { logEvents=false; mLog.flush(); mLog.close(); - lldebugs << "LLViewerEventRecorder::setEventLoggingOff event logging turned off" << llendl; + LL_DEBUGS() << "LLViewerEventRecorder::setEventLoggingOff event logging turned off" << LL_ENDL; } @@ -101,10 +101,10 @@ void LLViewerEventRecorder::updateMouseEventInfo(S32 local_x, S32 local_y, S32 g LLView * target_view = LLUI::resolvePath(LLUI::getRootView(), xui); if (! target_view) { - lldebugs << "LLViewerEventRecorder::updateMouseEventInfo - xui path on file at moment is NOT valid - so DO NOT record these local coords" << llendl; + LL_DEBUGS() << "LLViewerEventRecorder::updateMouseEventInfo - xui path on file at moment is NOT valid - so DO NOT record these local coords" << LL_ENDL; return; } - lldebugs << "LLViewerEventRecorder::updateMouseEventInfo b4 updatemouseeventinfo - local_x|global x "<< this->local_x << " " << this->global_x << "local/global y " << this->local_y << " " << this->global_y << " mname: " << mName << " xui: " << xui << llendl; + LL_DEBUGS() << "LLViewerEventRecorder::updateMouseEventInfo b4 updatemouseeventinfo - local_x|global x "<< this->local_x << " " << this->global_x << "local/global y " << this->local_y << " " << this->global_y << " mname: " << mName << " xui: " << xui << LL_ENDL; if (this->local_x < 1 && this->local_y<1 && local_x && local_y) { @@ -121,7 +121,7 @@ void LLViewerEventRecorder::updateMouseEventInfo(S32 local_x, S32 local_y, S32 g xui = mName; // TODO review confirm we never call with partial path - also cAN REMOVE CHECK FOR "" - ON OTHER HAND IT'S PRETTY HARMLESS } - lldebugs << "LLViewerEventRecorder::updateMouseEventInfo after updatemouseeventinfo - local_x|global x "<< this->local_x << " " << this->global_x << "local/global y " << this->local_y << " " << this->global_y << " mname: " << mName << " xui: " << xui << llendl; + LL_DEBUGS() << "LLViewerEventRecorder::updateMouseEventInfo after updatemouseeventinfo - local_x|global x "<< this->local_x << " " << this->global_x << "local/global y " << this->local_y << " " << this->global_y << " mname: " << mName << " xui: " << xui << LL_ENDL; } void LLViewerEventRecorder::logVisibilityChange(std::string xui, std::string name, BOOL visibility, std::string event_subtype) { @@ -158,10 +158,10 @@ std::string LLViewerEventRecorder::get_xui() { } void LLViewerEventRecorder::update_xui(std::string xui) { if (xui!="" && this->xui=="" ) { - lldebugs << "LLViewerEventRecorder::update_xui to " << xui << llendl; + LL_DEBUGS() << "LLViewerEventRecorder::update_xui to " << xui << LL_ENDL; this->xui=xui; } else { - lldebugs << "LLViewerEventRecorder::update_xui called with empty string" << llendl; + LL_DEBUGS() << "LLViewerEventRecorder::update_xui called with empty string" << LL_ENDL; } } @@ -200,11 +200,11 @@ void LLViewerEventRecorder::logKeyEvent(KEY key, MASK mask) { // (maybe it should) - instead it has a convenience method that generates the keydown and keyup events // Here we will use "type" as our event type - lldebugs << "LLVIewerEventRecorder::logKeyEvent Serialized LLSD for event " << event.asString() << "\n" << llendl; + LL_DEBUGS() << "LLVIewerEventRecorder::logKeyEvent Serialized LLSD for event " << event.asString() << "\n" << LL_ENDL; - //lldebugs << "[VITA] key_name: " << LLKeyboard::stringFromKey(key) << "mask: "<< mask << "handled by " << getName() << llendl; - lldebugs << "LLVIewerEventRecorder::logKeyEvent key_name: " << LLKeyboard::stringFromKey(key) << "mask: "<< mask << llendl; + //LL_DEBUGS() << "[VITA] key_name: " << LLKeyboard::stringFromKey(key) << "mask: "<< mask << "handled by " << getName() << LL_ENDL; + LL_DEBUGS() << "LLVIewerEventRecorder::logKeyEvent key_name: " << LLKeyboard::stringFromKey(key) << "mask: "<< mask << LL_ENDL; recordEvent(event); @@ -218,14 +218,14 @@ void LLViewerEventRecorder::playbackRecording() { // ivita sets this on startup, it also sends commands to the viewer to make start, stop, and playback menu items visible in viewer LeapCommand =LLUI::sSettingGroups["config"]->getLLSD("LeapPlaybackEventsCommand"); - lldebugs << "[VITA] launching playback - leap command is: " << LLSDXMLStreamer(LeapCommand) << llendl; + LL_DEBUGS() << "[VITA] launching playback - leap command is: " << LLSDXMLStreamer(LeapCommand) << LL_ENDL; LLLeap::create("", LeapCommand, false); // exception=false } void LLViewerEventRecorder::recordEvent(LLSD event) { - lldebugs << "LLViewerEventRecorder::recordEvent event written to log: " << LLSDXMLStreamer(event) << llendl; + LL_DEBUGS() << "LLViewerEventRecorder::recordEvent event written to log: " << LLSDXMLStreamer(event) << LL_ENDL; mLog << event << std::endl; } @@ -243,7 +243,7 @@ void LLViewerEventRecorder::logKeyUnicodeEvent(llwchar uni_char) { // keycode...or // char - lldebugs << "Wrapped in conversion to wstring " << wstring_to_utf8str(LLWString( 1, uni_char)) << "\n" << llendl; + LL_DEBUGS() << "Wrapped in conversion to wstring " << wstring_to_utf8str(LLWString( 1, uni_char)) << "\n" << LL_ENDL; event.insert("char", LLSD( wstring_to_utf8str(LLWString( 1,uni_char)) ) @@ -257,8 +257,8 @@ void LLViewerEventRecorder::logKeyUnicodeEvent(llwchar uni_char) { event.insert("event",LLSD("keyDown")); - lldebugs << "[VITA] unicode key: " << uni_char << llendl; - lldebugs << "[VITA] dumpxml " << LLSDXMLStreamer(event) << "\n" << llendl; + LL_DEBUGS() << "[VITA] unicode key: " << uni_char << LL_ENDL; + LL_DEBUGS() << "[VITA] dumpxml " << LLSDXMLStreamer(event) << "\n" << LL_ENDL; recordEvent(event); diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index a9f8acc440..282addf692 100755 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -37,13 +37,15 @@ /// LLViewModel::LLViewModel() - : mDirty(false) +: LLTrace::MemTrackable<LLViewModel>("LLViewModel"), + mDirty(false) { } /// Instantiate an LLViewModel with an existing data value LLViewModel::LLViewModel(const LLSD& value) - : mDirty(false) +: LLTrace::MemTrackable<LLViewModel>("LLViewModel"), + mDirty(false) { setValue(value); } @@ -79,8 +81,16 @@ LLTextViewModel::LLTextViewModel(const LLSD& value) /// Update the stored value void LLTextViewModel::setValue(const LLSD& value) { + // approximate LLSD storage usage + disclaimMem(mDisplay.size()); LLViewModel::setValue(value); + disclaimMem(mDisplay); mDisplay = utf8str_to_wstring(value.asString()); + + claimMem(mDisplay); + // approximate LLSD storage usage + claimMem(mDisplay.size()); + // mDisplay and mValue agree mUpdateFromDisplay = false; } @@ -91,7 +101,11 @@ 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. + disclaimMem(mDisplay.size()); + disclaimMem(mDisplay); mDisplay = value; + claimMem(mDisplay); + claimMem(mDisplay.size()); 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..49d7c322a3 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(); diff --git a/indra/llui/llviewquery.cpp b/indra/llui/llviewquery.cpp index d0b78ba186..66262609ae 100755 --- a/indra/llui/llviewquery.cpp +++ b/indra/llui/llviewquery.cpp @@ -30,7 +30,7 @@ #include "lluictrl.h" #include "llviewquery.h" -void LLQuerySorter::operator() (LLView * parent, viewList_t &children) const {} +void LLQuerySorter::sort(LLView * parent, viewList_t &children) const {} filterResult_t LLLeavesFilter::operator() (const LLView* const view, const viewList_t & children) const { @@ -89,8 +89,8 @@ viewList_t LLViewQuery::run(LLView* view) const if (pre.first) { post = runFilters(view, filtered_children, mPostFilters); - } } + } if(pre.first && post.first) { @@ -105,12 +105,12 @@ viewList_t LLViewQuery::run(LLView* view) const return result; } -void LLViewQuery::filterChildren(LLView * view, viewList_t & filtered_children) const +void LLViewQuery::filterChildren(LLView* parent_view, viewList_t & filtered_children) const { - LLView::child_list_t views(*(view->getChildList())); + LLView::child_list_t views(*(parent_view->getChildList())); if (mSorterp) { - (*mSorterp)(view, views); // sort the children per the sorter + mSorterp->sort(parent_view, views); // sort the children per the sorter } for(LLView::child_list_iter_t iter = views.begin(); iter != views.end(); @@ -134,18 +134,3 @@ filterResult_t LLViewQuery::runFilters(LLView * view, const viewList_t children, } return result; } - -class SortByTabOrder : public LLQuerySorter, public LLSingleton<SortByTabOrder> -{ - /*virtual*/ void operator() (LLView * parent, LLView::child_list_t &children) const - { - children.sort(LLCompareByTabOrder(parent->getCtrlOrder())); - } -}; - -LLCtrlQuery::LLCtrlQuery() : - LLViewQuery() -{ - setSorter(SortByTabOrder::getInstance()); -} - diff --git a/indra/llui/llviewquery.h b/indra/llui/llviewquery.h index 210f95162a..9044c4ff29 100755 --- a/indra/llui/llviewquery.h +++ b/indra/llui/llviewquery.h @@ -49,7 +49,7 @@ class LLQuerySorter { public: virtual ~LLQuerySorter() {}; - virtual void operator() (LLView * parent, viewList_t &children) const; + virtual void sort(LLView * parent, viewList_t &children) const; }; class LLLeavesFilter : public LLQueryFilter, public LLSingleton<LLLeavesFilter> @@ -127,10 +127,5 @@ private: const LLQuerySorter* mSorterp; }; -class LLCtrlQuery : public LLViewQuery -{ -public: - LLCtrlQuery(); -}; #endif // LL_LLVIEWQUERY_H diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 6322da9123..4390ca83e9 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); @@ -674,12 +677,12 @@ LLXUIParser::LLXUIParser() } } -static LLFastTimer::DeclareTimer FTM_PARSE_XUI("XUI Parsing"); +static LLTrace::BlockTimerStatHandle FTM_PARSE_XUI("XUI Parsing"); const LLXMLNodePtr DUMMY_NODE = new LLXMLNode(); void LLXUIParser::readXUI(LLXMLNodePtr node, LLInitParam::BaseBlock& block, const std::string& filename, bool silent) { - LLFastTimer timer(FTM_PARSE_XUI); + LL_RECORD_BLOCK_TIME(FTM_PARSE_XUI); mNameStack.clear(); mRootNodeName = node->getName()->mString; mCurFileName = filename; @@ -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 @@ -1391,7 +1394,7 @@ LLSimpleXUIParser::~LLSimpleXUIParser() bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBlock& block, bool silent) { - LLFastTimer timer(FTM_PARSE_XUI); + LL_RECORD_BLOCK_TIME(FTM_PARSE_XUI); mParser = XML_ParserCreate(NULL); XML_SetUserData(mParser, this); @@ -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); |