diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-05-13 15:06:26 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-05-13 15:07:33 -0600 |
commit | 1f5f9385fe7383dd5b71baac10b209349f3823ce (patch) | |
tree | dc591e2f3864904f66dc7bbf6ec77c41bde868ec | |
parent | b5ad7e490f0f429a5abac2acae48ecf25485256f (diff) | |
download | mana-1f5f9385fe7383dd5b71baac10b209349f3823ce.tar.gz mana-1f5f9385fe7383dd5b71baac10b209349f3823ce.tar.bz2 mana-1f5f9385fe7383dd5b71baac10b209349f3823ce.tar.xz mana-1f5f9385fe7383dd5b71baac10b209349f3823ce.zip |
Fix how the PartyWindow lays out Avatars
Also fix the height of Avatars
-rw-r--r-- | src/gui/partywindow.cpp | 21 | ||||
-rw-r--r-- | src/gui/partywindow.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/avatar.cpp | 12 |
3 files changed, 30 insertions, 5 deletions
diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 996073bd..1260a2c3 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -92,9 +92,10 @@ PartyMember *PartyWindow::findOrCreateMember(int id) { member = new PartyMember; mMembers[id] = member; - add(member->avatar, 0, (mMembers.size() - 1) * 14); } + buildLayout(); + return member; } @@ -148,6 +149,8 @@ void PartyWindow::removeMember(int id) void PartyWindow::removeMember(const std::string &name) { removeMember(findMember(name)); + + buildLayout(); } void PartyWindow::updateOnlne(int id, bool online) @@ -225,3 +228,19 @@ void PartyWindow::clearMembers() delete_all(mMembers); mMembers.clear(); } + +void PartyWindow::buildLayout() +{ + clearLayout(); + int lastPos = 0; + + PartyList::iterator it; + PartyMember *member; + + for (it = mMembers.begin(); it != mMembers.end(); it++) + { + member = (*it).second; + add(member->avatar, 0, lastPos); + lastPos += member->avatar->getHeight() + 2; + } +} diff --git a/src/gui/partywindow.h b/src/gui/partywindow.h index 8cea500f..19e611ed 100644 --- a/src/gui/partywindow.h +++ b/src/gui/partywindow.h @@ -125,6 +125,8 @@ class PartyWindow : public Window, gcn::ActionListener */ PartyMember *findOrCreateMember(int id); + void buildLayout(); + typedef std::map<int, PartyMember*> PartyList; PartyList mMembers; std::string mPartyInviter; diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp index 0bbdc468..16c77233 100644 --- a/src/gui/widgets/avatar.cpp +++ b/src/gui/widgets/avatar.cpp @@ -42,7 +42,6 @@ Avatar::Avatar(): mMaxHp(0) { setOpaque(false); - setSize(250, 12); if (avatarCount == 0) { @@ -54,12 +53,17 @@ Avatar::Avatar(): avatarStatusOffline->incRef(); avatarStatusOnline->incRef(); - mStatus = new Icon(avatarStatusOffline); - mStatus->setSize(12, 12); - add(mStatus, 1, 0); mLabel = new Label; mLabel->adjustSize(); + + mStatus = new Icon(avatarStatusOffline); + mStatus->setSize(12, 12); + + add(mStatus, 1, (mLabel->getHeight() - 12) / 2); add(mLabel, 16, 0); + + setSize(250, mLabel->getHeight()); + } Avatar::~Avatar() |