MAINT-6303 Outfit browser should add columns after window is resized

meow-7.2.2
Mnikolenko ProductEngine 2016-04-19 19:08:25 +03:00
parent bb06bcb1ea
commit 8c98c8e1cb
2 changed files with 48 additions and 3 deletions

View File

@ -65,10 +65,12 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p)
mItemWidth(p.item_width),
mItemHeight(p.item_height),
mItemHorizontalGap(p.item_horizontal_gap),
mItemsInRow(p.items_in_row)
mItemsInRow(p.items_in_row),
mRowPanWidthFactor(p.row_panel_width_factor),
mGalleryWidthFactor(p.gallery_width_factor)
{
mRowPanelWidth = p.row_panel_width_factor * mItemsInRow;
mGalleryWidth = p.gallery_width_factor * mItemsInRow;
mRowPanelWidth = mRowPanWidthFactor * mItemsInRow;
mGalleryWidth = mGalleryWidthFactor * mItemsInRow;
}
LLOutfitGallery::Params::Params()
@ -117,6 +119,44 @@ void LLOutfitGallery::onOpen(const LLSD& info)
}
}
void LLOutfitGallery::draw()
{
LLPanel::draw();
updateRowsIfNeeded();
}
void LLOutfitGallery::updateRowsIfNeeded()
{
if(((getRect().getWidth() - mRowPanelWidth) > mItemWidth) && mRowCount > 1)
{
reArrangeRows(1);
}
else if((mRowPanelWidth > (getRect().getWidth() + mItemHorizontalGap)) && mItemsInRow > 3)
{
reArrangeRows(-1);
}
}
void LLOutfitGallery::reArrangeRows(S32 row_diff)
{
std::vector<LLOutfitGalleryItem*> buf_items = mItems;
for (std::vector<LLOutfitGalleryItem*>::const_reverse_iterator it = buf_items.rbegin(); it != buf_items.rend(); ++it)
{
removeFromGalleryLast(*it);
}
mItemsInRow+= row_diff;
mRowPanelWidth = mRowPanWidthFactor * mItemsInRow;
mGalleryWidth = mGalleryWidthFactor * mItemsInRow;
for (std::vector<LLOutfitGalleryItem*>::const_iterator it = buf_items.begin(); it != buf_items.end(); ++it)
{
addToGallery(*it);
}
}
LLPanel* LLOutfitGallery::addLastRow()
{
mRowCount++;

View File

@ -82,6 +82,7 @@ public:
/*virtual*/ BOOL postBuild();
/*virtual*/ void onOpen(const LLSD& info);
/*virtual*/ void draw();
void onSelectPhoto(LLUUID selected_outfit_id);
@ -128,6 +129,8 @@ 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 updateRowsIfNeeded();
LLOutfitGalleryItem* buildGalleryItem(std::string name);
@ -159,6 +162,8 @@ private:
int mItemsInRow;
int mRowPanelWidth;
int mGalleryWidth;
int mRowPanWidthFactor;
int mGalleryWidthFactor;
LLHandle<LLFloater> mFloaterHandle;