summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/lloutfitgallery.cpp32
-rw-r--r--indra/newview/lloutfitgallery.h24
2 files changed, 48 insertions, 8 deletions
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp
index dfb5a3d5a8..9a9993f58c 100644
--- a/indra/newview/lloutfitgallery.cpp
+++ b/indra/newview/lloutfitgallery.cpp
@@ -69,8 +69,7 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p)
mRowPanWidthFactor(p.row_panel_width_factor),
mGalleryWidthFactor(p.gallery_width_factor)
{
- mRowPanelWidth = mRowPanWidthFactor * mItemsInRow;
- mGalleryWidth = mGalleryWidthFactor * mItemsInRow;
+ updateGalleryWidth();
}
LLOutfitGallery::Params::Params()
@@ -115,6 +114,7 @@ void LLOutfitGallery::onOpen(const LLSD& info)
{
addToGallery(mOutfitMap[cats[i]]);
}
+ reArrangeRows();
mGalleryCreated = true;
}
}
@@ -122,7 +122,10 @@ void LLOutfitGallery::onOpen(const LLSD& info)
void LLOutfitGallery::draw()
{
LLPanel::draw();
- updateRowsIfNeeded();
+ if (mGalleryCreated)
+ {
+ updateRowsIfNeeded();
+ }
}
void LLOutfitGallery::updateRowsIfNeeded()
@@ -147,16 +150,21 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff)
}
mItemsInRow+= row_diff;
+ updateGalleryWidth();
+ std::sort(buf_items.begin(), buf_items.end(), LLOutfitGalleryItem::compareGalleryItem());
- mRowPanelWidth = mRowPanWidthFactor * mItemsInRow;
- mGalleryWidth = mGalleryWidthFactor * mItemsInRow;
-
for (std::vector<LLOutfitGalleryItem*>::const_iterator it = buf_items.begin(); it != buf_items.end(); ++it)
{
addToGallery(*it);
}
}
+void LLOutfitGallery::updateGalleryWidth()
+{
+ mRowPanelWidth = mRowPanWidthFactor * mItemsInRow;
+ mGalleryWidth = mGalleryWidthFactor * mItemsInRow;
+}
+
LLPanel* LLOutfitGallery::addLastRow()
{
mRowCount++;
@@ -515,7 +523,9 @@ LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p)
: LLPanel(p),
mTexturep(NULL),
mSelected(false),
- mWorn(false)
+ mWorn(false),
+ mDefaultImage(true),
+ mOutfitName("")
{
buildFromFile("panel_outfit_gallery_item.xml");
}
@@ -565,6 +575,7 @@ void LLOutfitGalleryItem::draw()
void LLOutfitGalleryItem::setOutfitName(std::string name)
{
mOutfitNameText->setText(name);
+ mOutfitName = name;
}
void LLOutfitGalleryItem::setOutfitWorn(bool value)
@@ -597,6 +608,7 @@ void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id)
mTexturep = LLViewerTextureManager::getFetchedTexture(image_asset_id);
mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW);
getChildView("preview_outfit")->setVisible(FALSE);
+ mDefaultImage = false;
}
LLUUID LLOutfitGalleryItem::getImageAssetId()
@@ -609,6 +621,7 @@ void LLOutfitGalleryItem::setDefaultImage()
mTexturep = NULL;
mImageAssetId.setNull();
getChildView("preview_outfit")->setVisible(TRUE);
+ mDefaultImage = true;
}
LLOutfitGalleryGearMenu::LLOutfitGalleryGearMenu(LLOutfitListBase* olist)
@@ -711,6 +724,11 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id)
}
}
}
+
+ if (mGalleryCreated)
+ {
+ reArrangeRows();
+ }
}
void LLOutfitGallery::refreshTextures(const LLUUID& category_id)
diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h
index 1b6878bce3..285c8baf59 100644
--- a/indra/newview/lloutfitgallery.h
+++ b/indra/newview/lloutfitgallery.h
@@ -129,8 +129,9 @@ private:
void moveRow(int row, int pos);
LLPanel* addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item, int pos, int hgap);
void removeFromLastRow(LLOutfitGalleryItem* item);
- void reArrangeRows(S32 row_diff);
+ void reArrangeRows(S32 row_diff = 0);
void updateRowsIfNeeded();
+ void updateGalleryWidth();
LLOutfitGalleryItem* buildGalleryItem(std::string name);
@@ -211,6 +212,25 @@ public:
void setOutfitName(std::string name);
void setOutfitWorn(bool value);
void setSelected(bool value);
+
+ std::string getItemName() {return mOutfitName;}
+ bool mIsDefaultImage() {return mDefaultImage;}
+
+ struct compareGalleryItem
+ {
+ bool operator()(LLOutfitGalleryItem* a, LLOutfitGalleryItem* b)
+ {
+ if((a->mIsDefaultImage() && b->mIsDefaultImage()) || (!a->mIsDefaultImage() && !b->mIsDefaultImage()))
+ {
+ return a->getItemName().compare(b->getItemName()) < 0;
+ }
+ else
+ {
+ return b->mIsDefaultImage();
+ }
+ }
+ };
+
private:
LLPointer<LLViewerTexture> mTexturep;
LLUUID mImageAssetId;
@@ -220,6 +240,8 @@ private:
LLPanel* mFotoBgPanel;
bool mSelected;
bool mWorn;
+ bool mDefaultImage;
+ std::string mOutfitName;
};
#endif // LL_LLOUTFITGALLERYCTRL_H