diff options
Diffstat (limited to 'indra/newview/llfavoritesbar.cpp')
-rw-r--r-- | indra/newview/llfavoritesbar.cpp | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 48fcb6b6de..b06b4855ad 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -164,33 +164,6 @@ private: LLSLURLGetter mUrlGetter; }; -class LLFavoritesToggleableMenu : public LLToggleableMenu -{ -public: - virtual BOOL handleHover(S32 x, S32 y, MASK mask) - { - if (fb) - { - fb->handleHover(x, y, mask); - } - - return LLToggleableMenu::handleHover(x, y, mask); - } - - void initFavoritesBarPointer(LLFavoritesBarCtrl* fb) { this->fb = fb; } - -protected: - LLFavoritesToggleableMenu(const LLToggleableMenu::Params& p): - LLToggleableMenu(p) - { - } - - friend class LLUICtrlFactory; - -private: - LLFavoritesBarCtrl* fb; -}; - /** * This class is needed to override LLMenuItemCallGL default handleToolTip function and * show SLURL as button tooltip. @@ -221,6 +194,18 @@ public: return LLMenuItemCallGL::handleMouseUp(x, y, mask); } + virtual BOOL handleHover(S32 x, S32 y, MASK mask) + { + if (fb) + { + fb->handleHover(x, y, mask); + } + + return LLMenuItemCallGL::handleHover(x, y, mask); + } + + void initFavoritesBarPointer(LLFavoritesBarCtrl* fb) { this->fb = fb; } + protected: LLFavoriteLandmarkMenuItem(const LLMenuItemCallGL::Params& p) : LLMenuItemCallGL(p) {} @@ -228,6 +213,7 @@ protected: private: LLSLURLGetter mUrlGetter; + LLFavoritesBarCtrl* fb; }; /** @@ -312,8 +298,8 @@ LLFavoritesBarCtrl::LLFavoritesBarCtrl(const LLFavoritesBarCtrl::Params& p) boost::bind(&LLFavoritesBarCtrl::doToSelected, this, _2)); // Add this if we need to selectively enable items - //LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Favorites.EnableSelected", - // boost::bind(&LLFavoritesBarCtrl::enableSelected, this, _2)); + LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Favorites.EnableSelected", + boost::bind(&LLFavoritesBarCtrl::enableSelected, this, _2)); gInventory.addObserver(this); } @@ -433,7 +419,7 @@ void LLFavoritesBarCtrl::handleExistingFavoriteDragAndDrop(S32 x, S32 y) saveItemsOrder(mItems); - LLFavoritesToggleableMenu* menu = (LLFavoritesToggleableMenu*) mPopupMenuHandle.get(); + LLToggleableMenu* menu = (LLToggleableMenu*) mPopupMenuHandle.get(); if (menu && menu->getVisible()) { @@ -794,7 +780,7 @@ void LLFavoritesBarCtrl::showDropDownMenu() { if (mPopupMenuHandle.isDead()) { - LLFavoritesToggleableMenu::Params menu_p; + LLToggleableMenu::Params menu_p; menu_p.name("favorites menu"); menu_p.can_tear_off(false); menu_p.visible(false); @@ -802,12 +788,11 @@ void LLFavoritesBarCtrl::showDropDownMenu() menu_p.max_scrollable_items = 10; menu_p.preferred_width = DROP_DOWN_MENU_WIDTH; - LLFavoritesToggleableMenu* menu = LLUICtrlFactory::create<LLFavoritesToggleableMenu>(menu_p); - menu->initFavoritesBarPointer(this); + LLToggleableMenu* menu = LLUICtrlFactory::create<LLToggleableMenu>(menu_p); mPopupMenuHandle = menu->getHandle(); } - LLFavoritesToggleableMenu* menu = (LLFavoritesToggleableMenu*)mPopupMenuHandle.get(); + LLToggleableMenu* menu = (LLToggleableMenu*)mPopupMenuHandle.get(); if(menu) { @@ -873,6 +858,7 @@ void LLFavoritesBarCtrl::showDropDownMenu() item_params.on_click.function(boost::bind(&LLFavoritesBarCtrl::onButtonClick, this, item->getUUID())); LLFavoriteLandmarkMenuItem *menu_item = LLUICtrlFactory::create<LLFavoriteLandmarkMenuItem>(item_params); + menu_item->initFavoritesBarPointer(this); menu_item->setRightMouseDownCallback(boost::bind(&LLFavoritesBarCtrl::onButtonRightClick, this,item->getUUID(),_1,_2,_3,_4)); menu_item->LLUICtrl::setMouseDownCallback(boost::bind(&LLFavoritesBarCtrl::onButtonMouseDown, this, item->getUUID(), _1, _2, _3, _4)); menu_item->LLUICtrl::setMouseUpCallback(boost::bind(&LLFavoritesBarCtrl::onButtonMouseUp, this, item->getUUID(), _1, _2, _3, _4)); @@ -951,6 +937,18 @@ void copy_slurl_to_clipboard_cb(std::string& slurl) } +bool LLFavoritesBarCtrl::enableSelected(const LLSD& userdata) +{ + std::string param = userdata.asString(); + + if (param == std::string("can_paste")) + { + return isClipboardPasteable(); + } + + return false; +} + void LLFavoritesBarCtrl::doToSelected(const LLSD& userdata) { std::string action = userdata.asString(); @@ -1072,6 +1070,7 @@ void LLFavoritesBarCtrl::pastFromClipboard() const void LLFavoritesBarCtrl::onButtonMouseDown(LLUUID id, LLUICtrl* ctrl, S32 x, S32 y, MASK mask) { mDragItemId = id; + mStartDrag = TRUE; S32 screenX, screenY; localPointToScreen(x, y, &screenX, &screenY); @@ -1081,6 +1080,7 @@ void LLFavoritesBarCtrl::onButtonMouseDown(LLUUID id, LLUICtrl* ctrl, S32 x, S32 void LLFavoritesBarCtrl::onButtonMouseUp(LLUUID id, LLUICtrl* ctrl, S32 x, S32 y, MASK mask) { + mStartDrag = FALSE; mDragItemId = LLUUID::null; } @@ -1095,7 +1095,7 @@ void LLFavoritesBarCtrl::onEndDrag() BOOL LLFavoritesBarCtrl::handleHover(S32 x, S32 y, MASK mask) { - if (mDragItemId != LLUUID::null) + if (mDragItemId != LLUUID::null && mStartDrag) { S32 screenX, screenY; localPointToScreen(x, y, &screenX, &screenY); @@ -1106,6 +1106,8 @@ BOOL LLFavoritesBarCtrl::handleHover(S32 x, S32 y, MASK mask) DAD_LANDMARK, mDragItemId, LLToolDragAndDrop::SOURCE_LIBRARY); + mStartDrag = FALSE; + return LLToolDragAndDrop::getInstance()->handleHover(x, y, mask); } } |