summaryrefslogtreecommitdiff
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
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
-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();
/*