diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llpanel.cpp | 6 | ||||
-rw-r--r-- | indra/llui/llpanel.h | 2 | ||||
-rw-r--r-- | indra/llui/lltabcontainer.cpp | 47 | ||||
-rw-r--r-- | indra/llui/lltabcontainer.h | 10 |
4 files changed, 55 insertions, 10 deletions
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 76664d93a7..92d045d114 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -907,7 +907,7 @@ LLPanel *LLPanel::childGetVisibleTab(const std::string& id) const return NULL; } -void LLPanel::childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata) +void LLPanel::childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata, void (*on_precommit)(void*,bool)) { LLTabContainer* child = getChild<LLTabContainer>(id); if (child) @@ -917,6 +917,10 @@ void LLPanel::childSetTabChangeCallback(const std::string& id, const std::string { child->setTabChangeCallback(panel, on_tab_clicked); child->setTabUserData(panel, userdata); + if (on_precommit) + { + child->setTabPrecommitChangeCallback(panel, on_precommit); + } } } } diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index b8cb8f1417..756d02ef7d 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -196,7 +196,7 @@ public: // LLTabContainer void childShowTab(const std::string& id, const std::string& tabname, bool visible = true); LLPanel *childGetVisibleTab(const std::string& id) const; - void childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata); + void childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata, void (*on_precommit)(void*,bool) = NULL); // LLTextBox void childSetWrappedText(const std::string& id, const std::string& text, bool visible = true); diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 1796dd1150..e3ebd0057d 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -71,6 +71,7 @@ LLTabContainer::LLTabContainer(const std::string& name, const LLRect& rect, TabP : LLPanel(name, rect, bordered), mCurrentTabIdx(-1), + mNextTabIdx(-1), mTabsHidden(FALSE), mScrolled(FALSE), mScrollPos(0), @@ -1150,9 +1151,37 @@ BOOL LLTabContainer::selectTab(S32 which) { return FALSE; } - + + if (!selected_tuple->mPrecommitChangeCallback) + { + return setTab(which); + } + + mNextTabIdx = which; + selected_tuple->mPrecommitChangeCallback(selected_tuple->mUserData, false); + return TRUE; +} + +BOOL LLTabContainer::setTab(S32 which) +{ + if (which == -1) + { + if (mNextTabIdx == -1) + { + return FALSE; + } + which = mNextTabIdx; + mNextTabIdx = -1; + } + + LLTabTuple* selected_tuple = getTab(which); + if (!selected_tuple) + { + return FALSE; + } + BOOL is_visible = FALSE; - if (getTab(which)->mButton->getEnabled()) + if (selected_tuple->mButton->getEnabled()) { setCurrentPanelIndex(which); @@ -1332,6 +1361,15 @@ void LLTabContainer::setTabChangeCallback(LLPanel* tab, void (*on_tab_clicked)(v } } +void LLTabContainer::setTabPrecommitChangeCallback(LLPanel* tab, void (*on_precommit)(void*, bool)) +{ + LLTabTuple* tuplep = getTabByPanel(tab); + if (tuplep) + { + tuplep->mPrecommitChangeCallback = on_precommit; + } +} + void LLTabContainer::setTabUserData(LLPanel* tab, void* userdata) { LLTabTuple* tuplep = getTabByPanel(tab); @@ -1371,11 +1409,6 @@ void LLTabContainer::onTabBtn( void* userdata ) LLTabTuple* tuple = (LLTabTuple*) userdata; LLTabContainer* self = tuple->mTabContainer; self->selectTabPanel( tuple->mTabPanel ); - - if( tuple->mOnChangeCallback ) - { - tuple->mOnChangeCallback( tuple->mUserData, true ); - } tuple->mTabPanel->setFocus(TRUE); } diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index 001b399938..8117cdee9b 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -108,6 +108,7 @@ public: BOOL selectTabPanel( LLPanel* child ); BOOL selectTab(S32 which); BOOL selectTabByName(const std::string& title); + BOOL setTab(S32 which); BOOL getTabPanelFlashing(LLPanel* child); void setTabPanelFlashing(LLPanel* child, BOOL state); @@ -119,6 +120,7 @@ public: S32 getTopBorderHeight() const; void setTabChangeCallback(LLPanel* tab, void (*on_tab_clicked)(void*,bool)); + void setTabPrecommitChangeCallback(LLPanel* tab, void (*on_precommit)(void*, bool)); void setTabUserData(LLPanel* tab, void* userdata); void setRightTabBtnOffset( S32 offset ); @@ -148,12 +150,14 @@ private: struct LLTabTuple { LLTabTuple( LLTabContainer* c, LLPanel* p, LLButton* b, - void (*cb)(void*,bool), void* userdata, LLTextBox* placeholder = NULL ) + void (*cb)(void*,bool), void* userdata, LLTextBox* placeholder = NULL, + void (*pcb)(void*,bool) = NULL) : mTabContainer(c), mTabPanel(p), mButton(b), mOnChangeCallback( cb ), + mPrecommitChangeCallback( pcb ), mUserData( userdata ), mOldState(FALSE), mPlaceholderText(placeholder), @@ -164,6 +168,9 @@ private: LLPanel* mTabPanel; LLButton* mButton; void (*mOnChangeCallback)(void*, bool); + void (*mPrecommitChangeCallback)(void*,bool); // Precommit callback gets called before tab is changed and + // can prevent it from being changed. onChangeCallback is called + // immediately after tab is actually changed - Nyx void* mUserData; BOOL mOldState; LLTextBox* mPlaceholderText; @@ -200,6 +207,7 @@ private: tuple_list_t mTabList; S32 mCurrentTabIdx; + S32 mNextTabIdx; BOOL mTabsHidden; BOOL mScrolled; |