summaryrefslogtreecommitdiff
path: root/indra/newview/llfavoritesbar.cpp
diff options
context:
space:
mode:
authorRichard Linden <none@none>2010-09-22 19:11:29 -0700
committerRichard Linden <none@none>2010-09-22 19:11:29 -0700
commitabe758d45fa3dd3524a4c7a9667e4f02c3de8eac (patch)
tree7ac140c51c22a42c693b0930898e0996a807ecb8 /indra/newview/llfavoritesbar.cpp
parent264b549bcb991f4cdd6889f06b8f7fbe8740e32a (diff)
parentb124d45b4ef714acfe629af554768950dcdd5f2c (diff)
merge
Diffstat (limited to 'indra/newview/llfavoritesbar.cpp')
-rw-r--r--indra/newview/llfavoritesbar.cpp61
1 files changed, 28 insertions, 33 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 5796e67618..dd1f92a25c 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -161,22 +161,13 @@ public:
if (!region_name.empty())
{
- LLToolTip::Params params;
std::string extra_message = llformat("%s (%d, %d, %d)", region_name.c_str(),
mLandmarkInfoGetter.getPosX(), mLandmarkInfoGetter.getPosY(), mLandmarkInfoGetter.getPosZ());
+ LLToolTip::Params params;
params.message = llformat("%s\n%s", getLabelSelected().c_str(), extra_message.c_str());
-
- LLRect rect = calcScreenRect();
- LLFontGL* standart_font = LLFontGL::getFontSansSerif();
- if(standart_font)
- {
- S32 w = llmax((S32)(standart_font->getWidthF32(getLabelSelected())+0.5),(S32)(standart_font->getWidthF32(extra_message)+0.5));
- rect.mRight = rect.mLeft + w;
- params.max_width = w;
- }
-
- params.sticky_rect = rect;
+ params.max_width = 1000;
+ params.sticky_rect = calcScreenRect();
LLToolTipMgr::instance().show(params);
}
@@ -661,16 +652,23 @@ void LLFavoritesBarCtrl::draw()
}
}
-LLXMLNodePtr LLFavoritesBarCtrl::getButtonXMLNode()
+const LLButton::Params& LLFavoritesBarCtrl::getButtonParams()
{
- LLXMLNodePtr buttonXMLNode = NULL;
- bool success = LLUICtrlFactory::getLayeredXMLNode("favorites_bar_button.xml", buttonXMLNode);
- if (!success)
+ static LLButton::Params button_params;
+ static bool params_initialized = false;
+
+ if (!params_initialized)
{
- llwarns << "Failed to create Favorites Bar button from favorites_bar_button.xml" << llendl;
- buttonXMLNode = NULL;
+ LLXMLNodePtr button_xml_node;
+ if(LLUICtrlFactory::getLayeredXMLNode("favorites_bar_button.xml", button_xml_node))
+ {
+ LLXUIParser parser;
+ parser.readXUI(button_xml_node, button_params, "favorites_bar_button.xml");
+ }
+ params_initialized = true;
}
- return buttonXMLNode;
+
+ return button_params;
}
void LLFavoritesBarCtrl::updateButtons()
@@ -682,11 +680,8 @@ void LLFavoritesBarCtrl::updateButtons()
return;
}
- static LLXMLNodePtr buttonXMLNode = getButtonXMLNode();
- if (buttonXMLNode.isNull())
- {
- return;
- }
+ const LLButton::Params& button_params = getButtonParams();
+
if(mItems.empty())
{
mBarLabel->setVisible(TRUE);
@@ -762,7 +757,7 @@ void LLFavoritesBarCtrl::updateButtons()
int j = first_changed_item_index;
for (; j < mItems.count(); j++)
{
- last_new_button = createButton(mItems[j], buttonXMLNode, last_right_edge);
+ last_new_button = createButton(mItems[j], button_params, last_right_edge);
if (!last_new_button)
{
break;
@@ -780,8 +775,7 @@ void LLFavoritesBarCtrl::updateButtons()
//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 = 2; // default value
- buttonXMLNode->getAttributeS32("left", buttonHGap);
+ S32 buttonHGap = button_params.rect.left; // default value
LLRect rect;
// Chevron button should stay right aligned
rect.setOriginAndSize(getRect().mRight - mChevronButton->getRect().getWidth() - buttonHGap, 0,
@@ -808,12 +802,10 @@ void LLFavoritesBarCtrl::updateButtons()
}
}
-LLButton* LLFavoritesBarCtrl::createButton(const LLPointer<LLViewerInventoryItem> item, LLXMLNodePtr &buttonXMLNode, S32 x_offset)
+LLButton* LLFavoritesBarCtrl::createButton(const LLPointer<LLViewerInventoryItem> item, const LLButton::Params& button_params, S32 x_offset)
{
- S32 def_button_width = 120;
- buttonXMLNode->getAttributeS32("width", def_button_width);
- S32 button_x_delta = 2; // default value
- buttonXMLNode->getAttributeS32("left", button_x_delta);
+ S32 def_button_width = button_params.rect.width;
+ S32 button_x_delta = button_params.rect.left; // default value
S32 curr_x = x_offset;
/**
@@ -831,13 +823,16 @@ LLButton* LLFavoritesBarCtrl::createButton(const LLPointer<LLViewerInventoryItem
{
return NULL;
}
- fav_btn = LLUICtrlFactory::defaultBuilder<LLFavoriteLandmarkButton>(buttonXMLNode, this, NULL);
+ LLButton::Params fav_btn_params(button_params);
+ fav_btn = LLUICtrlFactory::create<LLFavoriteLandmarkButton>(fav_btn_params);
if (NULL == fav_btn)
{
llwarns << "Unable to create LLFavoriteLandmarkButton widget: " << item->getName() << llendl;
return NULL;
}
+ addChild(fav_btn);
+
LLRect butt_rect (fav_btn->getRect());
fav_btn->setLandmarkID(item->getUUID());
butt_rect.setOriginAndSize(curr_x + button_x_delta, fav_btn->getRect().mBottom, width, fav_btn->getRect().getHeight());