summaryrefslogtreecommitdiff
path: root/indra/newview/llchiclet.cpp
diff options
context:
space:
mode:
authorMike Antipov <mantipov@productengine.com>2009-11-19 15:19:49 +0200
committerMike Antipov <mantipov@productengine.com>2009-11-19 15:19:49 +0200
commitef292e6a8b19160de7cf91d07f48daa68a56453e (patch)
tree6e98c0493940686c61d6c8506b35690068f64edd /indra/newview/llchiclet.cpp
parent88cce61b09d225df0bcd8aab9dbd2c5a01ee7e19 (diff)
Fixed major bug EXT-2620 (IM Chiclet Panel goes crazy when new IM chiclets are added (chiclet scrolling appears with no need))
- refactored algotithm of caclulating position of the first chiclet in the list when adding new one. - added comments for LLChicketPanel::addChiclet() & LLChicketPanel::arrange() methods --HG-- branch : product-engine
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r--indra/newview/llchiclet.cpp45
1 files changed, 28 insertions, 17 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));