summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Polunin <apolunin@productengine.com>2009-12-19 18:35:38 +0200
committerAndrew Polunin <apolunin@productengine.com>2009-12-19 18:35:38 +0200
commitdc8cd05082e4d82a578d4a20278725cdf5e0450f (patch)
tree10c95eff04dbf67b7d2c6fc0dec0fd0be7b830a5
parent75a4c5a6dd0cdaf9755bf40821d23c45296181d4 (diff)
implemented minor task EXT-3455 Code Improvements: Improve LLAvatarListItem not to calculate constant values in each constructing
--HG-- branch : product-engine
-rw-r--r--indra/newview/llavatarlistitem.cpp19
-rw-r--r--indra/newview/llavatarlistitem.h10
2 files changed, 21 insertions, 8 deletions
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index 072eebdf2d..08b359d26e 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -43,6 +43,12 @@
#include "lltextutil.h"
#include "llbutton.h"
+bool LLAvatarListItem::mStaticInitialized = false;
+S32 LLAvatarListItem::mIconWidth = 0;
+S32 LLAvatarListItem::mInfoBtnWidth = 0;
+S32 LLAvatarListItem::mProfileBtnWidth = 0;
+S32 LLAvatarListItem::mSpeakingIndicatorWidth = 0;
+
LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/)
: LLPanel(),
mAvatarIcon(NULL),
@@ -88,10 +94,15 @@ BOOL LLAvatarListItem::postBuild()
// Remember avatar icon width including its padding from the name text box,
// so that we can hide and show the icon again later.
- mIconWidth = mAvatarName->getRect().mLeft - mAvatarIcon->getRect().mLeft;
- mInfoBtnWidth = mInfoBtn->getRect().mRight - mSpeakingIndicator->getRect().mRight;
- mProfileBtnWidth = mProfileBtn->getRect().mRight - mInfoBtn->getRect().mRight;
- mSpeakingIndicatorWidth = mSpeakingIndicator->getRect().mRight - mAvatarName->getRect().mRight;
+ if (!mStaticInitialized)
+ {
+ mIconWidth = mAvatarName->getRect().mLeft - mAvatarIcon->getRect().mLeft;
+ mInfoBtnWidth = mInfoBtn->getRect().mRight - mSpeakingIndicator->getRect().mRight;
+ mProfileBtnWidth = mProfileBtn->getRect().mRight - mInfoBtn->getRect().mRight;
+ mSpeakingIndicatorWidth = mSpeakingIndicator->getRect().mRight - mAvatarName->getRect().mRight;
+
+ mStaticInitialized = true;
+ }
/*
if(!p.buttons.profile)
diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h
index aa1b7593f5..1272bdf7a9 100644
--- a/indra/newview/llavatarlistitem.h
+++ b/indra/newview/llavatarlistitem.h
@@ -135,10 +135,12 @@ private:
//Speaker indicator and avatar name coords are translated accordingly
bool mShowInfoBtn;
bool mShowProfileBtn;
- S32 mIconWidth; // icon width + padding
- S32 mInfoBtnWidth; //info btn width + padding
- S32 mProfileBtnWidth; //profile btn width + padding
- S32 mSpeakingIndicatorWidth; //speaking indicator width + padding
+
+ static bool mStaticInitialized; // this variable is introduced to improve code readability
+ static S32 mIconWidth; // icon width + padding
+ static S32 mInfoBtnWidth; //info btn width + padding
+ static S32 mProfileBtnWidth; //profile btn width + padding
+ static S32 mSpeakingIndicatorWidth; //speaking indicator width + padding
};
#endif //LL_LLAVATARLISTITEM_H