summaryrefslogtreecommitdiff
path: root/indra/newview/llfavoritesbar.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-07-30 23:22:41 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-07-30 23:22:41 +0000
commite97f7728a90dd66014f6b3f0cd5e8d4c71f48691 (patch)
tree4be178df6b50a3395105cdd3ac0044d6467a9fa3 /indra/newview/llfavoritesbar.cpp
parentd5aa10143a0e6457b3326ba839c81b7c956a015e (diff)
merge https://svn.aws.productengine.com/secondlife/export-from-ll/viewer-2-0/indra@1170 https://svn.aws.productengine.com/secondlife/pe/stable-1/indra@1187 -> viewer-2.0.0-3
Diffstat (limited to 'indra/newview/llfavoritesbar.cpp')
-rw-r--r--indra/newview/llfavoritesbar.cpp179
1 files changed, 99 insertions, 80 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 00d4f80054..72bfac70fc 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -216,6 +216,8 @@ void LLFavoritesBarCtrl::updateButtons(U32 bar_width)
}
}
+ bool recreate_buttons = true;
+
// If inventory items are not changed up to mFirstDropDownItem, no need to recreate them
if (mFirstDropDownItem == first_drop_down_item && (mItemNamesCache.size() == count || mItemNamesCache.size() == mFirstDropDownItem))
{
@@ -229,97 +231,113 @@ void LLFavoritesBarCtrl::updateButtons(U32 bar_width)
}
if (i == mFirstDropDownItem)
{
- // Chevron button should stay right aligned
- LLView *chevron_button = getChildView(std::string(">>"), FALSE, FALSE);
- if (chevron_button)
+ recreate_buttons = false;
+ }
+ }
+
+ if (recreate_buttons)
+ {
+ mFirstDropDownItem = first_drop_down_item;
+
+ mItemNamesCache.clear();
+ for (S32 i = 0; i < mFirstDropDownItem; i++)
+ {
+ mItemNamesCache.put(items.get(i)->getName());
+ }
+
+ // Rebuild the buttons only
+ // child_list_t is a linked list, so safe to erase from the middle if we pre-incrament the iterator
+ for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); )
+ {
+ child_list_const_iter_t cur_it = child_it++;
+ LLView* viewp = *cur_it;
+ LLButton* button = dynamic_cast<LLButton*>(viewp);
+ if (button)
{
- LLRect rect;
- rect.setOriginAndSize(bar_width - chevron_button_width - buttonHGap, buttonVGap, chevron_button_width, getRect().getHeight()-buttonVGap);
- chevron_button->setRect(rect);
- mChevronRect = rect;
+ removeChild(button);
+ delete button;
}
- return;
}
- }
- mFirstDropDownItem = first_drop_down_item;
+ // Adding buttons
+ for(S32 i = mFirstDropDownItem -1; i >= 0; i--)
+ {
- mItemNamesCache.clear();
- for (S32 i = 0; i < mFirstDropDownItem; i++)
- {
- mItemNamesCache.put(items.get(i)->getName());
- }
+ LLInventoryItem* item = items.get(i);
- // Rebuild the buttons only
- // child_list_t is a linked list, so safe to erase from the middle if we pre-incrament the iterator
- for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); )
- {
- child_list_const_iter_t cur_it = child_it++;
- LLView* viewp = *cur_it;
- LLButton* button = dynamic_cast<LLButton*>(viewp);
- if (button)
- {
- removeChild(button);
- delete button;
- }
- }
-
- // Adding buttons
- for(S32 i = 0; i < mFirstDropDownItem; i++)
- {
-
- LLInventoryItem* item = items.get(i);
-
- S32 buttonWidth = mFont->getWidth(item->getName()) + buttonHPad * 2;
-
- LLRect rect;
- rect.setOriginAndSize(curr_x, buttonVGap, buttonWidth, getRect().getHeight()-buttonVGap);
-
- LLButton::Params bparams;
- bparams.image_unselected.name(flat_icon);
- bparams.image_disabled.name(flat_icon);
- bparams.image_selected.name(hover_icon_selected);
- bparams.image_hover_selected.name(hover_icon_selected);
- bparams.image_disabled_selected.name(hover_icon_selected);
- bparams.image_hover_unselected.name(hover_icon);
- bparams.follows.flags (FOLLOWS_LEFT | FOLLOWS_BOTTOM);
- bparams.rect (rect);
- bparams.tab_stop(false);
- bparams.font(mFont);
- bparams.name(item->getName());
- bparams.tool_tip(item->getName());
- bparams.click_callback.function(boost::bind(&LLFavoritesBarCtrl::onButtonClick, this, item->getUUID()));
- bparams.rightclick_callback.function(boost::bind(&LLFavoritesBarCtrl::onButtonRightClick, this, item->getUUID()));
-
- addChildInBack(LLUICtrlFactory::create<LLButton> (bparams));
-
- curr_x += buttonWidth + buttonHGap;
+ S32 buttonWidth = mFont->getWidth(item->getName()) + buttonHPad * 2;
+
+ LLRect rect;
+ rect.setOriginAndSize(curr_x, buttonVGap, buttonWidth, getRect().getHeight()-buttonVGap);
+
+ LLButton::Params bparams;
+ bparams.image_unselected.name(flat_icon);
+ bparams.image_disabled.name(flat_icon);
+ bparams.image_selected.name(hover_icon_selected);
+ bparams.image_hover_selected.name(hover_icon_selected);
+ bparams.image_disabled_selected.name(hover_icon_selected);
+ bparams.image_hover_unselected.name(hover_icon);
+ bparams.follows.flags (FOLLOWS_LEFT | FOLLOWS_BOTTOM);
+ bparams.rect (rect);
+ bparams.tab_stop(false);
+ bparams.font(mFont);
+ bparams.name(item->getName());
+ bparams.tool_tip(item->getName());
+ bparams.click_callback.function(boost::bind(&LLFavoritesBarCtrl::onButtonClick, this, item->getUUID()));
+ bparams.rightclick_callback.function(boost::bind(&LLFavoritesBarCtrl::onButtonRightClick, this, item->getUUID()));
+
+ addChildInBack(LLUICtrlFactory::create<LLButton> (bparams));
+
+ curr_x += buttonWidth + buttonHGap;
+ }
}
// Chevron button
if (mFirstDropDownItem != count)
{
- LLButton::Params bparams;
-
- LLRect rect;
- rect.setOriginAndSize(bar_width - chevron_button_width - buttonHGap, buttonVGap, chevron_button_width, getRect().getHeight()-buttonVGap);
-
- bparams.follows.flags (FOLLOWS_LEFT | FOLLOWS_BOTTOM);
- bparams.image_unselected.name(flat_icon);
- bparams.image_disabled.name(flat_icon);
- bparams.image_selected.name(hover_icon_selected);
- bparams.image_hover_selected.name(hover_icon_selected);
- bparams.image_disabled_selected.name(hover_icon_selected);
- bparams.image_hover_unselected.name(hover_icon);
- bparams.rect (rect);
- bparams.tab_stop(false);
- bparams.font(mFont);
- bparams.name(">>");
- bparams.click_callback.function(boost::bind(&LLFavoritesBarCtrl::showDropDownMenu, this));
-
- addChildInBack(LLUICtrlFactory::create<LLButton> (bparams));
-
- mChevronRect = rect;
+ // Chevron button should stay right aligned
+ LLView *chevron_button = getChildView(std::string(">>"), FALSE, FALSE);
+ if (chevron_button)
+ {
+ LLRect rect;
+ rect.setOriginAndSize(bar_width - chevron_button_width - buttonHGap, buttonVGap, chevron_button_width, getRect().getHeight()-buttonVGap);
+ chevron_button->setRect(rect);
+ chevron_button->setVisible(TRUE);
+ mChevronRect = rect;
+ }
+ else
+ {
+ LLButton::Params bparams;
+
+ LLRect rect;
+ rect.setOriginAndSize(bar_width - chevron_button_width - buttonHGap, buttonVGap, chevron_button_width, getRect().getHeight()-buttonVGap);
+
+ bparams.follows.flags (FOLLOWS_LEFT | FOLLOWS_BOTTOM);
+ bparams.image_unselected.name(flat_icon);
+ bparams.image_disabled.name(flat_icon);
+ bparams.image_selected.name(hover_icon_selected);
+ bparams.image_hover_selected.name(hover_icon_selected);
+ bparams.image_disabled_selected.name(hover_icon_selected);
+ bparams.image_hover_unselected.name(hover_icon);
+ bparams.rect (rect);
+ bparams.tab_stop(false);
+ bparams.font(mFont);
+ bparams.name(">>");
+ bparams.click_callback.function(boost::bind(&LLFavoritesBarCtrl::showDropDownMenu, this));
+
+ addChildInBack(LLUICtrlFactory::create<LLButton> (bparams));
+
+ mChevronRect = rect;
+ }
+ }
+ else
+ {
+ // Hide chevron button if all items are visible on bar
+ LLView *chevron_button = getChildView(std::string(">>"), FALSE, FALSE);
+ if (chevron_button)
+ {
+ chevron_button->setVisible(FALSE);
+ }
}
}
@@ -444,6 +462,7 @@ void LLFavoritesBarCtrl::showDropDownMenu()
item_params.label(item_name);
item_params.on_click.function(boost::bind(&LLFavoritesBarCtrl::onButtonClick, this, item->getUUID()));
+ item_params.rightclick_callback.function(boost::bind(&LLFavoritesBarCtrl::onButtonRightClick, this, item->getUUID()));
LLMenuItemCallGL *menu_item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params);