diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lltoolbar.cpp | 14 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 5 |
2 files changed, 18 insertions, 1 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 515605200e..b0a072c00e 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -112,6 +112,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mStartDragItemCallback(NULL), mHandleDragItemCallback(NULL), mHandleDropCallback(NULL), + mButtonAddSignal(NULL), mDragAndDropTarget(false) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; @@ -121,6 +122,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) LLToolBar::~LLToolBar() { delete mPopupMenuHandle.get(); + delete mButtonAddSignal; } void LLToolBar::createContextMenu() @@ -212,7 +214,6 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) mButtonPanel->addChild(button); mButtonMap.insert(std::make_pair(commandId.uuid(), button)); - // Insert the command and button in the right place in their respective lists if ((rank >= mButtonCommands.size()) || (rank == RANK_NONE)) { @@ -236,6 +237,11 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) mButtons.insert(it_button,button); } + if (mButtonAddSignal) + { + (*mButtonAddSignal)(button); + } + mNeedsLayout = true; return true; @@ -898,6 +904,12 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) return button; } +boost::signals2::connection LLToolBar::setButtonAddCallback(const button_add_signal_t::slot_type& cb) +{ + if (!mButtonAddSignal) mButtonAddSignal = new button_add_signal_t(); + return mButtonAddSignal->connect(cb); +} + BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index e634e57f93..68fc44ee8e 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -195,6 +195,9 @@ public: LLToolBarButton* createButton(const LLCommandId& id); + typedef boost::signals2::signal<void (LLView* button)> button_add_signal_t; + boost::signals2::connection setButtonAddCallback(const button_add_signal_t::slot_type& cb); + bool hasButtons() const { return !mButtons.empty(); } bool isModified() const { return mModified; } @@ -255,6 +258,8 @@ private: LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; LLHandle<class LLContextMenu> mPopupMenuHandle; + + button_add_signal_t* mButtonAddSignal; }; |