summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llchiclet.cpp45
-rw-r--r--indra/newview/llchiclet.h23
2 files changed, 43 insertions, 25 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index caf6917d90..e27afc31e6 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -914,34 +914,45 @@ void LLChicletPanel::onCurrentVoiceChannelChanged(const LLUUID& session_id)
s_previous_active_voice_session_id = session_id;
}
-S32 LLChicletPanel::calcChickletPanleWidth()
-{
- S32 res = 0;
-
- for (chiclet_list_t::iterator it = mChicletList.begin(); it
- != mChicletList.end(); it++)
- {
- res = (*it)->getRect().getWidth() + getChicletPadding();
- }
- return res;
-}
-
bool LLChicletPanel::addChiclet(LLChiclet* chiclet, S32 index)
{
if(mScrollArea->addChild(chiclet))
{
- // chicklets should be aligned to right edge of scroll panel
- S32 offset = 0;
+ // chiclets should be aligned to right edge of scroll panel
+ S32 left_shift = 0;
if (!canScrollLeft())
{
- offset = mScrollArea->getRect().getWidth()
- - chiclet->getRect().getWidth() - calcChickletPanleWidth();
+ // init left shift for the first chiclet in the list...
+ if (mChicletList.empty())
+ {
+ // ...start from the right border of the scroll area for the first added chiclet
+ left_shift = mScrollArea->getRect().getWidth();
+ }
+ else
+ {
+ // ... start from the left border of the first chiclet minus padding
+ left_shift = getChiclet(0)->getRect().mLeft - getChicletPadding();
+ }
+
+ // take into account width of the being added chiclet
+ left_shift -= chiclet->getRequiredRect().getWidth();
+
+ // if we overflow the scroll area we do not need to shift chiclets
+ if (left_shift < 0)
+ {
+ left_shift = 0;
+ }
}
mChicletList.insert(mChicletList.begin() + index, chiclet);
- getChiclet(0)->translate(offset, 0);
+ // shift first chiclet to place it in correct position.
+ // rest ones will be placed in arrange()
+ if (!canScrollLeft())
+ {
+ getChiclet(0)->translate(left_shift - getChiclet(0)->getRect().mLeft, 0);
+ }
chiclet->setLeftButtonClickCallback(boost::bind(&LLChicletPanel::onChicletClick, this, _1, _2));
chiclet->setChicletSizeChangedCallback(boost::bind(&LLChicletPanel::onChicletSizeChanged, this, _1, index));
diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h
index bb5dc1e550..c0e8a6c70f 100644
--- a/indra/newview/llchiclet.h
+++ b/indra/newview/llchiclet.h
@@ -769,16 +769,23 @@ protected:
LLChicletPanel(const Params&p);
friend class LLUICtrlFactory;
- S32 calcChickletPanleWidth();
-
- /*
- * Adds chiclet to list and rearranges all chiclets.
- */
+ /**
+ * Adds chiclet to list and rearranges all chiclets.
+ * They should be right aligned, most recent right. See EXT-1293
+ *
+ * It calculates position of the first chiclet in the list. Other chiclets are placed in arrange().
+ *
+ * @see arrange()
+ */
bool addChiclet(LLChiclet*, S32 index);
- /*
- * Arranges chiclets.
- */
+ /**
+ * Arranges chiclets to have them in correct positions.
+ *
+ * Method bases on assumption that first chiclet has correct rect and starts from the its position.
+ *
+ * @see addChiclet()
+ */
void arrange();
/*