diff options
Diffstat (limited to 'indra/llui/lluictrl.cpp')
-rwxr-xr-x | indra/llui/lluictrl.cpp | 188 |
1 files changed, 98 insertions, 90 deletions
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); } |