diff options
author | Mnikolenko ProductEngine <mnikolenko@productengine.com> | 2016-04-19 19:08:25 +0300 |
---|---|---|
committer | Mnikolenko ProductEngine <mnikolenko@productengine.com> | 2016-04-19 19:08:25 +0300 |
commit | 8c98c8e1cb3a040bef7b2c93111034358099bca2 (patch) | |
tree | 16784fa065e29edbcf474cfa91996c1901dcfa6b /indra | |
parent | bb06bcb1eae78ce3811761f057c8060e7575192d (diff) |
MAINT-6303 Outfit browser should add columns after window is resized
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/lloutfitgallery.cpp | 46 | ||||
-rw-r--r-- | indra/newview/lloutfitgallery.h | 5 |
2 files changed, 48 insertions, 3 deletions
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 175fd652c5..dfb5a3d5a8 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -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++; diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index e874776e3e..1b6878bce3 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -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; |