summaryrefslogtreecommitdiff
path: root/indra/newview/llfavoritesbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfavoritesbar.cpp')
-rw-r--r--indra/newview/llfavoritesbar.cpp433
1 files changed, 267 insertions, 166 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index d3c9cd26d7..906d04691f 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -79,7 +79,7 @@ public:
}
void setLandmarkID(const LLUUID& id) { mLandmarkID = id; }
- const LLUUID& getLandmarkId() const { return mLandmarkID; }
+ const LLUUID& getLandmarkID() const { return mLandmarkID; }
const std::string& getName()
{
@@ -160,7 +160,7 @@ class LLFavoriteLandmarkButton : public LLButton
{
public:
- BOOL handleToolTip(S32 x, S32 y, MASK mask)
+ bool handleToolTip(S32 x, S32 y, MASK mask)
{
std::string region_name = mLandmarkInfoGetter.getName();
@@ -176,10 +176,10 @@ public:
LLToolTipMgr::instance().show(params);
}
- return TRUE;
+ return true;
}
- /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask)
+ /*virtual*/ bool handleHover(S32 x, S32 y, MASK mask)
{
LLFavoritesBarCtrl* fb = dynamic_cast<LLFavoritesBarCtrl*>(getParent());
@@ -192,7 +192,7 @@ public:
}
void setLandmarkID(const LLUUID& id){ mLandmarkInfoGetter.setLandmarkID(id); }
- const LLUUID& getLandmarkId() const { return mLandmarkInfoGetter.getLandmarkId(); }
+ const LLUUID& getLandmarkID() const { return mLandmarkInfoGetter.getLandmarkID(); }
void onMouseEnter(S32 x, S32 y, MASK mask)
{
@@ -224,7 +224,7 @@ private:
class LLFavoriteLandmarkMenuItem : public LLMenuItemCallGL
{
public:
- BOOL handleToolTip(S32 x, S32 y, MASK mask)
+ bool handleToolTip(S32 x, S32 y, MASK mask)
{
std::string region_name = mLandmarkInfoGetter.getName();
if (!region_name.empty())
@@ -234,33 +234,34 @@ public:
params.sticky_rect = calcScreenRect();
LLToolTipMgr::instance().show(params);
}
- return TRUE;
+ return true;
}
- void setLandmarkID(const LLUUID& id){ mLandmarkInfoGetter.setLandmarkID(id); }
+ const LLUUID& getLandmarkID() const { return mLandmarkInfoGetter.getLandmarkID(); }
+ void setLandmarkID(const LLUUID& id) { mLandmarkInfoGetter.setLandmarkID(id); }
- virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask)
+ virtual bool handleMouseDown(S32 x, S32 y, MASK mask)
{
if (mMouseDownSignal)
(*mMouseDownSignal)(this, x, y, mask);
return LLMenuItemCallGL::handleMouseDown(x, y, mask);
}
- virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask)
+ virtual bool handleMouseUp(S32 x, S32 y, MASK mask)
{
if (mMouseUpSignal)
(*mMouseUpSignal)(this, x, y, mask);
return LLMenuItemCallGL::handleMouseUp(x, y, mask);
}
- virtual BOOL handleHover(S32 x, S32 y, MASK mask)
+ virtual bool handleHover(S32 x, S32 y, MASK mask)
{
if (fb)
{
fb->handleHover(x, y, mask);
}
- return TRUE;
+ return true;
}
void initFavoritesBarPointer(LLFavoritesBarCtrl* fb) { this->fb = fb; }
@@ -278,21 +279,50 @@ private:
/**
* This class was introduced just for fixing the following issue:
* EXT-836 Nav bar: Favorites overflow menu passes left-mouse click through.
- * We must explicitly handle drag and drop event by returning TRUE
+ * We must explicitly handle drag and drop event by returning true
* because otherwise LLToolDragAndDrop will initiate drag and drop operation
* with the world.
*/
class LLFavoriteLandmarkToggleableMenu : public LLToggleableMenu
{
public:
- virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
- EDragAndDropType cargo_type,
- void* cargo_data,
- EAcceptance* accept,
- std::string& tooltip_msg)
+ // virtual
+ bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType cargo_type,
+ void* cargo_data, EAcceptance* accept, std::string& tooltip_msg) override
+ {
+ mToolbar->handleDragAndDropToMenu(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
+ return true;
+ }
+
+ // virtual
+ bool handleHover(S32 x, S32 y, MASK mask) override
+ {
+ mIsHovering = true;
+ LLToggleableMenu::handleHover(x, y, mask);
+ mIsHovering = false;
+ return true;
+ }
+
+ // virtual
+ void setVisible(bool visible) override
{
- *accept = ACCEPT_NO;
- return TRUE;
+ // Avoid of hiding the menu during hovering
+ if (visible || !mIsHovering)
+ {
+ LLToggleableMenu::setVisible(visible);
+ }
+ }
+
+ void setToolbar(LLFavoritesBarCtrl* toolbar)
+ {
+ mToolbar = toolbar;
+ }
+
+ ~LLFavoriteLandmarkToggleableMenu()
+ {
+ // Enable subsequent setVisible(false)
+ mIsHovering = false;
+ setVisible(false);
}
protected:
@@ -301,6 +331,10 @@ protected:
{
}
+private:
+ LLFavoritesBarCtrl* mToolbar { nullptr };
+ bool mIsHovering { false };
+
friend class LLUICtrlFactory;
};
@@ -323,8 +357,8 @@ public:
LLFavoritesBarCtrl::sWaitingForCallabck = 0.f;
LLFavoritesOrderStorage::instance().setSortIndex(item, mSortField);
- item->setComplete(TRUE);
- item->updateServer(FALSE);
+ item->setComplete(true);
+ item->updateServer(false);
gInventory.updateItem(item);
gInventory.notifyObservers();
@@ -382,12 +416,13 @@ LLFavoritesBarCtrl::LLFavoritesBarCtrl(const LLFavoritesBarCtrl::Params& p)
mOverflowMenuHandle(),
mContextMenuHandle(),
mImageDragIndication(p.image_drag_indication),
- mShowDragMarker(FALSE),
+ mShowDragMarker(false),
mLandingTab(NULL),
mLastTab(NULL),
mItemsListDirty(false),
mUpdateDropDownItems(true),
mRestoreOverflowMenu(false),
+ mDragToOverflowMenu(false),
mGetPrevItems(true),
mMouseX(0),
mMouseY(0),
@@ -422,20 +457,19 @@ LLFavoritesBarCtrl::~LLFavoritesBarCtrl()
{
gInventory.removeObserver(this);
- if (mOverflowMenuHandle.get()) mOverflowMenuHandle.get()->die();
- if (mContextMenuHandle.get()) mContextMenuHandle.get()->die();
+ if (mOverflowMenuHandle.get())
+ mOverflowMenuHandle.get()->die();
+ if (mContextMenuHandle.get())
+ mContextMenuHandle.get()->die();
}
-BOOL LLFavoritesBarCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
- EDragAndDropType cargo_type,
- void* cargo_data,
- EAcceptance* accept,
- std::string& tooltip_msg)
+bool LLFavoritesBarCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
+ EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, std::string& tooltip_msg)
{
*accept = ACCEPT_NO;
LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource();
- if (LLToolDragAndDrop::SOURCE_AGENT != source && LLToolDragAndDrop::SOURCE_LIBRARY != source) return FALSE;
+ if (LLToolDragAndDrop::SOURCE_AGENT != source && LLToolDragAndDrop::SOURCE_LIBRARY != source) return false;
switch (cargo_type)
{
@@ -456,26 +490,52 @@ BOOL LLFavoritesBarCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
// Copy the item into the favorites folder (if it's not already there).
LLInventoryItem *item = (LLInventoryItem *)cargo_data;
- if (LLFavoriteLandmarkButton* dest = dynamic_cast<LLFavoriteLandmarkButton*>(findChildByLocalCoords(x, y)))
+ if (mDragToOverflowMenu)
{
- setLandingTab(dest);
+ LLView* overflow_menu = mOverflowMenuHandle.get();
+ if (overflow_menu && !overflow_menu->isDead() && overflow_menu->getVisible())
+ {
+ overflow_menu->handleHover(x, y, mask);
+ }
}
- else if (mLastTab && (x >= mLastTab->getRect().mRight))
+ else // Drag to the toolbar itself
{
- /*
- * the condition dest == NULL can be satisfied not only in the case
- * of dragging to the right from the last tab of the favbar. there is a
- * small gap between each tab. if the user drags something exactly there
- * then mLandingTab will be set to NULL and the dragged item will be pushed
- * to the end of the favorites bar. this is incorrect behavior. that's why
- * we need an additional check which excludes the case described previously
- * making sure that the mouse pointer is beyond the last tab.
- */
- setLandingTab(NULL);
+ // Drag to a landmark button?
+ if (LLFavoriteLandmarkButton* dest = dynamic_cast<LLFavoriteLandmarkButton*>(findChildByLocalCoords(x, y)))
+ {
+ setLandingTab(dest);
+ }
+ else
+ {
+ // Drag to the "More" button?
+ if (mMoreTextBox && mMoreTextBox->getVisible() && mMoreTextBox->getRect().pointInRect(x, y))
+ {
+ LLView* overflow_menu = mOverflowMenuHandle.get();
+ if (!overflow_menu || overflow_menu->isDead() || !overflow_menu->getVisible())
+ {
+ showDropDownMenu();
+ }
+ }
+
+ // Drag to the right of the last landmark button?
+ if (mLastTab && (x >= mLastTab->getRect().mRight))
+ {
+ /*
+ * the condition dest == NULL can be satisfied not only in the case
+ * of dragging to the right from the last tab of the favbar. there is a
+ * small gap between each tab. if the user drags something exactly there
+ * then mLandingTab will be set to NULL and the dragged item will be pushed
+ * to the end of the favorites bar. this is incorrect behavior. that's why
+ * we need an additional check which excludes the case described previously
+ * making sure that the mouse pointer is beyond the last tab.
+ */
+ setLandingTab(NULL);
+ }
+ }
}
- // check if we are dragging an existing item from the favorites bar
- bool existing_drop = false;
+ // Check whether we are dragging an existing item from the favorites bar
+ bool existing_item = false;
if (item && mDragItemId == item->getUUID())
{
// There is a chance of mDragItemId being obsolete
@@ -483,21 +543,19 @@ BOOL LLFavoritesBarCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
// results in viewer not geting a 'mouse up' signal
for (LLInventoryModel::item_array_t::iterator i = mItems.begin(); i != mItems.end(); ++i)
{
- LLViewerInventoryItem* currItem = *i;
-
- if (currItem->getUUID() == mDragItemId)
+ if ((*i)->getUUID() == mDragItemId)
{
- existing_drop = true;
+ existing_item = true;
break;
}
}
}
- if (existing_drop)
+ if (existing_item)
{
*accept = ACCEPT_YES_SINGLE;
- showDragMarker(TRUE);
+ showDragMarker(true);
if (drop)
{
@@ -515,7 +573,7 @@ BOOL LLFavoritesBarCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
*accept = ACCEPT_YES_COPY_MULTI;
- showDragMarker(TRUE);
+ showDragMarker(true);
if (drop)
{
@@ -533,85 +591,59 @@ BOOL LLFavoritesBarCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
break;
}
- return TRUE;
+ return true;
+}
+
+bool LLFavoritesBarCtrl::handleDragAndDropToMenu(S32 x, S32 y, MASK mask, bool drop,
+ EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, std::string& tooltip_msg)
+{
+ mDragToOverflowMenu = true;
+ bool handled = handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
+ mDragToOverflowMenu = false;
+ return handled;
}
void LLFavoritesBarCtrl::handleExistingFavoriteDragAndDrop(S32 x, S32 y)
{
- if (mItems.empty())
- {
- // Isn't supposed to be empty
+ if (LL_UNLIKELY(mItems.empty()))
return;
- }
- // Identify the button hovered and the side to drop
- LLFavoriteLandmarkButton* dest = dynamic_cast<LLFavoriteLandmarkButton*>(mLandingTab);
- bool insert_before = true;
- if (!dest)
- {
- insert_before = false;
- dest = dynamic_cast<LLFavoriteLandmarkButton*>(mLastTab);
- }
+ LLUUID target_id;
+ bool insert_before = false;
+ if (!findDragAndDropTarget(target_id, insert_before, x, y))
+ return;
// There is no need to handle if an item was dragged onto itself
- if (dest && dest->getLandmarkId() == mDragItemId)
- {
+ if (target_id == mDragItemId)
return;
- }
-
- // Insert the dragged item in the right place
- if (dest)
- {
- LLInventoryModel::updateItemsOrder(mItems, mDragItemId, dest->getLandmarkId(), insert_before);
- }
- else
- {
- // This can happen when the item list is empty
- mItems.push_back(gInventory.getItem(mDragItemId));
- }
+ // Move the dragged item to the right place in the array
+ LLInventoryModel::updateItemsOrder(mItems, mDragItemId, target_id, insert_before);
LLFavoritesOrderStorage::instance().saveItemsOrder(mItems);
- LLToggleableMenu* menu = (LLToggleableMenu*) mOverflowMenuHandle.get();
-
- if (menu && menu->getVisible())
+ LLView* menu = mOverflowMenuHandle.get();
+ if (menu && !menu->isDead() && menu->getVisible())
{
- menu->setVisible(FALSE);
- showDropDownMenu();
+ updateOverflowMenuItems();
+ positionAndShowOverflowMenu();
}
}
void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, const LLUUID& favorites_id, S32 x, S32 y)
{
// Identify the button hovered and the side to drop
- LLFavoriteLandmarkButton* dest = NULL;
- bool insert_before = true;
- if (!mItems.empty())
- {
- // [MAINT-2386] When multiple landmarks are selected and dragged onto an empty favorites bar,
- // the viewer would crash when casting mLastTab below, as mLastTab is still null when the
- // second landmark is being added.
- // To ensure mLastTab is valid, we need to call updateButtons() at the end of this function
- dest = dynamic_cast<LLFavoriteLandmarkButton*>(mLandingTab);
- if (!dest)
- {
- insert_before = false;
- dest = dynamic_cast<LLFavoriteLandmarkButton*>(mLastTab);
- }
- }
-
+ LLUUID target_id;
+ bool insert_before = false;
// There is no need to handle if an item was dragged onto itself
- if (dest && dest->getLandmarkId() == mDragItemId)
- {
+ if (findDragAndDropTarget(target_id, insert_before, x, y) && (target_id == mDragItemId))
return;
- }
LLPointer<LLViewerInventoryItem> viewer_item = new LLViewerInventoryItem(item);
- // Insert the dragged item in the right place
- if (dest)
+ // Insert the dragged item to the right place
+ if (target_id.notNull())
{
- insertItem(mItems, dest->getLandmarkId(), viewer_item, insert_before);
+ insertItem(mItems, target_id, viewer_item, insert_before);
}
else
{
@@ -638,8 +670,8 @@ void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, con
{
LLFavoritesOrderStorage::instance().setSortIndex(currItem, ++sortField);
- currItem->setComplete(TRUE);
- currItem->updateServer(FALSE);
+ currItem->setComplete(true);
+ currItem->updateServer(false);
gInventory.updateItem(currItem);
}
@@ -671,9 +703,74 @@ void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, con
// landmarks to an empty favorites bar.
updateButtons();
+ LLView* overflow_menu = mOverflowMenuHandle.get();
+ if (overflow_menu && !overflow_menu->isDead() && overflow_menu->getVisible())
+ {
+ updateOverflowMenuItems();
+ positionAndShowOverflowMenu();
+ }
+
LL_INFOS("FavoritesBar") << "Copied inventory item #" << item->getUUID() << " to favorites." << LL_ENDL;
}
+bool LLFavoritesBarCtrl::findDragAndDropTarget(LLUUID& target_id, bool& insert_before, S32 x, S32 y)
+{
+ if (mItems.empty())
+ return false;
+
+ if (mDragToOverflowMenu)
+ {
+ LLView* overflow_menu = mOverflowMenuHandle.get();
+ if (LL_UNLIKELY(!overflow_menu || overflow_menu->isDead() || !overflow_menu->getVisible()))
+ return false;
+
+ // Identify the menu item hovered and the side to drop
+ LLFavoriteLandmarkMenuItem* target_item = dynamic_cast<LLFavoriteLandmarkMenuItem*>(overflow_menu->childFromPoint(x, y));
+ if (target_item)
+ {
+ insert_before = true;
+ }
+ else
+ {
+ // Choose the bottom landmark menu item
+ auto begin = overflow_menu->getChildList()->begin();
+ auto end = overflow_menu->getChildList()->end();
+ auto check = [](const LLView* child) -> bool
+ {
+ return dynamic_cast<const LLFavoriteLandmarkMenuItem*>(child);
+ };
+ // Menu items are placed in the backward order, so the bottom goes first
+ auto it = std::find_if(begin, end, check);
+ if (LL_UNLIKELY(it == end))
+ return false;
+ target_item = (LLFavoriteLandmarkMenuItem*)*it;
+ insert_before = false;
+ }
+ target_id = target_item->getLandmarkID();
+ }
+ else
+ {
+ // Identify the button hovered and the side to drop
+ LLFavoriteLandmarkButton* hovered_button = dynamic_cast<LLFavoriteLandmarkButton*>(mLandingTab);
+ if (hovered_button)
+ {
+ insert_before = true;
+ }
+ else
+ {
+ // Choose the right landmark button
+ hovered_button = dynamic_cast<LLFavoriteLandmarkButton*>(mLastTab);
+ if (LL_UNLIKELY(!hovered_button))
+ return false;
+
+ insert_before = false;
+ }
+ target_id = hovered_button->getLandmarkID();
+ }
+
+ return true;
+}
+
//virtual
void LLFavoritesBarCtrl::changed(U32 mask)
{
@@ -718,7 +815,7 @@ void LLFavoritesBarCtrl::changed(U32 mask)
}
//virtual
-void LLFavoritesBarCtrl::reshape(S32 width, S32 height, BOOL called_from_parent)
+void LLFavoritesBarCtrl::reshape(S32 width, S32 height, bool called_from_parent)
{
S32 delta_width = width - getRect().getWidth();
S32 delta_height = height - getRect().getHeight();
@@ -750,7 +847,7 @@ void LLFavoritesBarCtrl::draw()
mImageDragIndication->draw(rect.mRight, rect.getHeight(), w, h);
}
// Once drawn, mark this false so we won't draw it again (unless we hit the favorite bar again)
- mShowDragMarker = FALSE;
+ mShowDragMarker = false;
}
if (mItemsChangedTimer.getStarted())
{
@@ -837,12 +934,12 @@ void LLFavoritesBarCtrl::updateButtons(bool force_update)
if(mItems.empty())
{
- mBarLabel->setVisible(TRUE);
+ mBarLabel->setVisible(true);
mLastTab = NULL;
}
else
{
- mBarLabel->setVisible(FALSE);
+ mBarLabel->setVisible(false);
}
const child_list_t* childs = getChildList();
child_list_const_iter_t child_it = childs->begin();
@@ -859,7 +956,7 @@ void LLFavoritesBarCtrl::updateButtons(bool force_update)
if (item)
{
// an child's order and mItems should be same
- if (button->getLandmarkId() != item->getUUID() // sort order has been changed
+ if (button->getLandmarkID() != item->getUUID() // sort order has been changed
|| button->getLabelSelected() != item->getName()) // favorite's name has been changed
{
break;
@@ -933,11 +1030,7 @@ void LLFavoritesBarCtrl::updateButtons(bool force_update)
{
// mMoreTextBox was removed, so LLFavoriteLandmarkButtons
// should be the only ones in the list
- LLFavoriteLandmarkButton* button = dynamic_cast<LLFavoriteLandmarkButton*> (childs->back());
- if (button)
- {
- mLastTab = button;
- }
+ mLastTab = dynamic_cast<LLFavoriteLandmarkButton*>(childs->back());
}
mFirstDropDownItem = j;
@@ -945,25 +1038,23 @@ void LLFavoritesBarCtrl::updateButtons(bool force_update)
if (mFirstDropDownItem < mItems.size())
{
// if updateButton had been called it means:
- //or there are some new favorites, or width had been changed
+ // or there are some new favorites, or width had been changed
// so if we need to display chevron button, we must update dropdown items too.
mUpdateDropDownItems = true;
S32 buttonHGap = button_params.rect.left; // default value
- LLRect rect;
// Chevron button should stay right aligned
- rect.setOriginAndSize(getRect().mRight - mMoreTextBox->getRect().getWidth() - buttonHGap, 0,
- mMoreTextBox->getRect().getWidth(),
- mMoreTextBox->getRect().getHeight());
+ LLRect rect(mMoreTextBox->getRect());
+ rect.translate(getRect().mRight - rect.mRight - buttonHGap, 0);
addChild(mMoreTextBox);
mMoreTextBox->setRect(rect);
- mMoreTextBox->setVisible(TRUE);
+ mMoreTextBox->setVisible(true);
}
// Update overflow menu
LLToggleableMenu* overflow_menu = static_cast <LLToggleableMenu*> (mOverflowMenuHandle.get());
if (overflow_menu && overflow_menu->getVisible() && (overflow_menu->getItemCount() != mDropDownItemsCount))
{
- overflow_menu->setVisible(FALSE);
+ overflow_menu->setVisible(false);
if (mUpdateDropDownItems)
{
showDropDownMenu();
@@ -1027,7 +1118,7 @@ LLButton* LLFavoritesBarCtrl::createButton(const LLPointer<LLViewerInventoryItem
}
-BOOL LLFavoritesBarCtrl::postBuild()
+bool LLFavoritesBarCtrl::postBuild()
{
// make the popup menu available
LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_favorites.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
@@ -1038,14 +1129,14 @@ BOOL LLFavoritesBarCtrl::postBuild()
menu->setBackgroundColor(LLUIColorTable::instance().getColor("MenuPopupBgColor"));
mContextMenuHandle = menu->getHandle();
- return TRUE;
+ return true;
}
-BOOL LLFavoritesBarCtrl::collectFavoriteItems(LLInventoryModel::item_array_t &items)
+bool LLFavoritesBarCtrl::collectFavoriteItems(LLInventoryModel::item_array_t &items)
{
if (mFavoriteFolderId.isNull())
- return FALSE;
+ return false;
LLInventoryModel::cat_array_t cats;
@@ -1065,7 +1156,7 @@ BOOL LLFavoritesBarCtrl::collectFavoriteItems(LLInventoryModel::item_array_t &it
LLFavoritesOrderStorage::instance().mSaveOnExit = true;
}
- return TRUE;
+ return true;
}
void LLFavoritesBarCtrl::onMoreTextBoxClicked()
@@ -1086,14 +1177,16 @@ void LLFavoritesBarCtrl::showDropDownMenu()
{
if (mUpdateDropDownItems)
{
- updateMenuItems(menu);
+ updateOverflowMenuItems();
+ }
+ else
+ {
+ menu->buildDrawLabels();
}
- menu->buildDrawLabels();
menu->updateParent(LLMenuGL::sMenuContainer);
menu->setButtonRect(mMoreTextBox->getRect(), this);
- positionAndShowMenu(menu);
- mDropDownItemsCount = menu->getItemCount();
+ positionAndShowOverflowMenu();
}
}
@@ -1107,12 +1200,14 @@ void LLFavoritesBarCtrl::createOverflowMenu()
menu_p.max_scrollable_items = 10;
menu_p.preferred_width = DROP_DOWN_MENU_WIDTH;
- LLToggleableMenu* menu = LLUICtrlFactory::create<LLFavoriteLandmarkToggleableMenu>(menu_p);
+ LLFavoriteLandmarkToggleableMenu* menu = LLUICtrlFactory::create<LLFavoriteLandmarkToggleableMenu>(menu_p);
+ menu->setToolbar(this);
mOverflowMenuHandle = menu->getHandle();
}
-void LLFavoritesBarCtrl::updateMenuItems(LLToggleableMenu* menu)
+void LLFavoritesBarCtrl::updateOverflowMenuItems()
{
+ LLToggleableMenu* menu = (LLToggleableMenu*)mOverflowMenuHandle.get();
menu->empty();
U32 widest_item = 0;
@@ -1141,6 +1236,8 @@ void LLFavoritesBarCtrl::updateMenuItems(LLToggleableMenu* menu)
menu->addChild(menu_item);
}
+ menu->buildDrawLabels();
+ mDropDownItemsCount = menu->getItemCount();
addOpenLandmarksMenuItem(menu);
mUpdateDropDownItems = false;
}
@@ -1197,8 +1294,9 @@ void LLFavoritesBarCtrl::addOpenLandmarksMenuItem(LLToggleableMenu* menu)
menu->addChild(menu_item);
}
-void LLFavoritesBarCtrl::positionAndShowMenu(LLToggleableMenu* menu)
+void LLFavoritesBarCtrl::positionAndShowOverflowMenu()
{
+ LLToggleableMenu* menu = (LLToggleableMenu*)mOverflowMenuHandle.get();
U32 max_width = llmin(DROP_DOWN_MENU_WIDTH, getRect().getWidth());
S32 menu_x = getRect().getWidth() - max_width;
@@ -1264,9 +1362,9 @@ void LLFavoritesBarCtrl::onButtonRightClick( LLUUID item_id,LLView* fav_button,S
LLMenuGL::showPopup(fav_button, menu, x, y);
}
-BOOL LLFavoritesBarCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask)
+bool LLFavoritesBarCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
- BOOL handled = childrenHandleRightMouseDown( x, y, mask) != NULL;
+ bool handled = childrenHandleRightMouseDown( x, y, mask) != NULL;
if(!handled && !gMenuHolder->hasVisibleMenu())
{
show_navbar_context_menu(this,x,y);
@@ -1407,7 +1505,7 @@ bool LLFavoritesBarCtrl::onRenameCommit(const LLSD& notification, const LLSD& re
{
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
new_item->rename(landmark_name);
- new_item->updateServer(FALSE);
+ new_item->updateServer(false);
gInventory.updateItem(new_item);
}
}
@@ -1415,11 +1513,11 @@ bool LLFavoritesBarCtrl::onRenameCommit(const LLSD& notification, const LLSD& re
return false;
}
-BOOL LLFavoritesBarCtrl::isClipboardPasteable() const
+bool LLFavoritesBarCtrl::isClipboardPasteable() const
{
if (!LLClipboard::instance().hasContents())
{
- return FALSE;
+ return false;
}
std::vector<LLUUID> objects;
@@ -1433,16 +1531,16 @@ BOOL LLFavoritesBarCtrl::isClipboardPasteable() const
const LLInventoryCategory *cat = gInventory.getCategory(item_id);
if (cat)
{
- return FALSE;
+ return false;
}
const LLInventoryItem *item = gInventory.getItem(item_id);
if (item && LLAssetType::AT_LANDMARK != item->getType())
{
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
void LLFavoritesBarCtrl::pasteFromClipboard() const
@@ -1482,11 +1580,11 @@ void LLFavoritesBarCtrl::onButtonMouseDown(LLUUID id, LLUICtrl* ctrl, S32 x, S32
LLMenuGL* menu = (LLMenuGL*)mContextMenuHandle.get();
if(menu && menu->getVisible())
{
- menu->setVisible(FALSE);
+ menu->setVisible(false);
}
mDragItemId = id;
- mStartDrag = TRUE;
+ mStartDrag = true;
S32 screenX, screenY;
localPointToScreen(x, y, &screenX, &screenY);
@@ -1496,7 +1594,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;
+ mStartDrag = false;
mDragItemId = LLUUID::null;
}
@@ -1504,12 +1602,12 @@ void LLFavoritesBarCtrl::onEndDrag()
{
mEndDragConnection.disconnect();
- showDragMarker(FALSE);
+ showDragMarker(false);
mDragItemId = LLUUID::null;
LLView::getWindow()->setCursor(UI_CURSOR_ARROW);
}
-BOOL LLFavoritesBarCtrl::handleHover(S32 x, S32 y, MASK mask)
+bool LLFavoritesBarCtrl::handleHover(S32 x, S32 y, MASK mask)
{
if (mDragItemId != LLUUID::null && mStartDrag)
{
@@ -1522,13 +1620,13 @@ BOOL LLFavoritesBarCtrl::handleHover(S32 x, S32 y, MASK mask)
DAD_LANDMARK, mDragItemId,
LLToolDragAndDrop::SOURCE_LIBRARY);
- mStartDrag = FALSE;
+ mStartDrag = false;
return LLToolDragAndDrop::getInstance()->handleHover(x, y, mask);
}
}
- return TRUE;
+ return true;
}
LLUICtrl* LLFavoritesBarCtrl::findChildByLocalCoords(S32 x, S32 y)
@@ -1551,19 +1649,20 @@ LLUICtrl* LLFavoritesBarCtrl::findChildByLocalCoords(S32 x, S32 y)
}
}
}
+
return ctrl;
}
-BOOL LLFavoritesBarCtrl::needToSaveItemsOrder(const LLInventoryModel::item_array_t& items)
+bool LLFavoritesBarCtrl::needToSaveItemsOrder(const LLInventoryModel::item_array_t& items)
{
- BOOL result = FALSE;
+ bool result = false;
// if there is an item without sort order field set, we need to save items order
for (LLInventoryModel::item_array_t::const_iterator i = items.begin(); i != items.end(); ++i)
{
if (LLFavoritesOrderStorage::instance().getSortIndex((*i)->getUUID()) < 0)
{
- result = TRUE;
+ result = true;
break;
}
}
@@ -1967,8 +2066,8 @@ void LLFavoritesOrderStorage::saveItemsOrder( const LLInventoryModel::item_array
setSortIndex(item, ++sortField);
- item->setComplete(TRUE);
- item->updateServer(FALSE);
+ item->setComplete(true);
+ item->updateServer(false);
gInventory.updateItem(item);
@@ -1999,7 +2098,7 @@ void LLFavoritesOrderStorage::rearrangeFavoriteLandmarks(const LLUUID& source_it
saveItemsOrder(items);
}
-BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed)
+bool LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed)
{
pref_changed |= mRecreateFavoriteStorage;
mRecreateFavoriteStorage = false;
@@ -2007,13 +2106,13 @@ BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed)
// Can get called before inventory is done initializing.
if (!gInventory.isInventoryUsable())
{
- return FALSE;
+ return false;
}
LLUUID favorite_folder= gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
if (favorite_folder.isNull())
{
- return FALSE;
+ return false;
}
LLInventoryModel::item_array_t items;
@@ -2125,11 +2224,11 @@ BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed)
mPrevFavorites = items;
}
- return TRUE;
+ return true;
}
-void LLFavoritesOrderStorage::showFavoritesOnLoginChanged(BOOL show)
+void LLFavoritesOrderStorage::showFavoritesOnLoginChanged(bool show)
{
if (show)
{
@@ -2160,8 +2259,10 @@ bool LLFavoritesOrderStorage::isStorageUpdateNeeded()
void AddFavoriteLandmarkCallback::fire(const LLUUID& inv_item_id)
{
- if (mTargetLandmarkId.isNull()) return;
-
- LLFavoritesOrderStorage::instance().rearrangeFavoriteLandmarks(inv_item_id, mTargetLandmarkId);
+ if (!mTargetLandmarkId.isNull())
+ {
+ LLFavoritesOrderStorage::instance().rearrangeFavoriteLandmarks(inv_item_id, mTargetLandmarkId);
+ }
}
+
// EOF