diff options
Diffstat (limited to 'indra/newview/lloutfitgallery.cpp')
-rw-r--r-- | indra/newview/lloutfitgallery.cpp | 376 |
1 files changed, 281 insertions, 95 deletions
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 0b127b1b93..72f361c4d9 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -81,9 +81,16 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) mItemsInRow(p.items_in_row), mRowPanWidthFactor(p.row_panel_width_factor), mGalleryWidthFactor(p.gallery_width_factor), - mTextureSelected(NULL) + mTextureSelected(NULL), + mSortMenu(nullptr) { updateGalleryWidth(); + + LLControlVariable* ctrl = gSavedSettings.getControl("InventoryFavoritesColorText"); + if (ctrl) + { + mSavedSettingInvFavColor = ctrl->getSignal()->connect(boost::bind(&LLOutfitGallery::handleInvFavColorChange, this)); + } } LLOutfitGallery::Params::Params() @@ -105,12 +112,10 @@ const LLOutfitGallery::Params& LLOutfitGallery::getDefaultParams() return LLUICtrlFactory::getDefaultParams<LLOutfitGallery>(); } -BOOL LLOutfitGallery::postBuild() +bool LLOutfitGallery::postBuild() { - BOOL rv = LLOutfitListBase::postBuild(); + bool rv = LLOutfitListBase::postBuild(); mScrollPanel = getChild<LLScrollContainer>("gallery_scroll_panel"); - LLPanel::Params params = LLPanel::getDefaultParams(); // Don't parse XML when creating dummy LLPanel - mGalleryPanel = LLUICtrlFactory::create<LLPanel>(params); mMessageTextBox = getChild<LLTextBox>("no_outfits_txt"); mOutfitGalleryMenu = new LLOutfitGalleryContextMenu(this); return rv; @@ -123,12 +128,12 @@ void LLOutfitGallery::onOpen(const LLSD& info) { uuid_vec_t cats; getCurrentCategories(cats); - int n = cats.size(); + int n = static_cast<int>(cats.size()); buildGalleryPanel(n); mScrollPanel->addChild(mGalleryPanel); for (int i = 0; i < n; i++) { - addToGallery(mOutfitMap[cats[i]]); + addToGallery(getItem(cats[i])); } reArrangeRows(); mGalleryCreated = true; @@ -144,9 +149,9 @@ void LLOutfitGallery::draw() } } -BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask) +bool LLOutfitGallery::handleKeyHere(KEY key, MASK mask) { - BOOL handled = FALSE; + bool handled = false; switch (key) { case KEY_RETURN: @@ -156,7 +161,7 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask) // Or should it wearSelectedOutfit? getSelectedItem()->openOutfitsContent(); } - handled = TRUE; + handled = true; break; case KEY_DELETE: #if LL_DARWIN @@ -168,12 +173,12 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask) { onRemoveOutfit(mSelectedOutfitUUID); } - handled = TRUE; + handled = true; break; case KEY_F2: LLAppearanceMgr::instance().renameOutfit(mSelectedOutfitUUID); - handled = TRUE; + handled = true; break; case KEY_PAGE_UP: @@ -181,7 +186,7 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask) { mScrollPanel->pageUp(30); } - handled = TRUE; + handled = true; break; case KEY_PAGE_DOWN: @@ -189,7 +194,7 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask) { mScrollPanel->pageDown(30); } - handled = TRUE; + handled = true; break; case KEY_HOME: @@ -197,7 +202,7 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask) { mScrollPanel->goToTop(); } - handled = TRUE; + handled = true; break; case KEY_END: @@ -205,27 +210,27 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask) { mScrollPanel->goToBottom(); } - handled = TRUE; + handled = true; break; case KEY_LEFT: moveLeft(); - handled = TRUE; + handled = true; break; case KEY_RIGHT: moveRight(); - handled = TRUE; + handled = true; break; case KEY_UP: moveUp(); - handled = TRUE; + handled = true; break; case KEY_DOWN: moveDown(); - handled = TRUE; + handled = true; break; default: @@ -254,7 +259,7 @@ void LLOutfitGallery::moveUp() item = mIndexToItemMap[n]; LLUUID item_id = item->getUUID(); ChangeOutfitSelection(nullptr, item_id); - item->setFocus(TRUE); + item->setFocus(true); scrollToShowItem(mSelectedOutfitUUID); } @@ -276,7 +281,7 @@ void LLOutfitGallery::moveDown() item = mIndexToItemMap[n]; LLUUID item_id = item->getUUID(); ChangeOutfitSelection(nullptr, item_id); - item->setFocus(TRUE); + item->setFocus(true); scrollToShowItem(mSelectedOutfitUUID); } @@ -301,7 +306,7 @@ void LLOutfitGallery::moveLeft() item = mIndexToItemMap[n]; LLUUID item_id = item->getUUID(); ChangeOutfitSelection(nullptr, item_id); - item->setFocus(TRUE); + item->setFocus(true); scrollToShowItem(mSelectedOutfitUUID); } @@ -324,7 +329,7 @@ void LLOutfitGallery::moveRight() item = mIndexToItemMap[n]; LLUUID item_id = item->getUUID(); ChangeOutfitSelection(nullptr, item_id); - item->setFocus(TRUE); + item->setFocus(true); scrollToShowItem(mSelectedOutfitUUID); } @@ -377,7 +382,7 @@ void LLOutfitGallery::onOutfitsRemovalConfirmation(const LLSD& notification, con void LLOutfitGallery::scrollToShowItem(const LLUUID& item_id) { - LLOutfitGalleryItem* item = mOutfitMap[item_id]; + LLOutfitGalleryItem* item = getItem(item_id); if (item) { const LLRect visible_content_rect = mScrollPanel->getVisibleContentRect(); @@ -416,18 +421,28 @@ void LLOutfitGallery::updateRowsIfNeeded() bool compareGalleryItem(LLOutfitGalleryItem* item1, LLOutfitGalleryItem* item2) { - if(gSavedSettings.getBOOL("OutfitGallerySortByName") || - ((item1->isDefaultImage() && item2->isDefaultImage()) || (!item1->isDefaultImage() && !item2->isDefaultImage()))) + LLCachedControl<S32> sort_by_name(gSavedSettings, "OutfitGallerySortOrder", 0); + switch (sort_by_name()) { - std::string name1 = item1->getItemName(); - std::string name2 = item2->getItemName(); - - return (LLStringUtil::compareDict(name1, name2) < 0); - } - else - { - return item2->isDefaultImage(); + case 2: + if (item1->isFavorite() != item2->isFavorite()) + { + return item1->isFavorite(); + } + break; + case 1: + if (item1->isDefaultImage() != item2->isDefaultImage()) + { + return item2->isDefaultImage(); + } + break; + default: + break; } + + std::string name1 = item1->getItemName(); + std::string name2 = item2->getItemName(); + return (LLStringUtil::compareDict(name1, name2) < 0); } void LLOutfitGallery::reArrangeRows(S32 row_diff) @@ -470,6 +485,20 @@ void LLOutfitGallery::updateGalleryWidth() mGalleryWidth = mGalleryWidthFactor * mItemsInRow - mItemHorizontalGap; } +void LLOutfitGallery::handleInvFavColorChange() +{ + for (outfit_map_t::iterator iter = mOutfitMap.begin(); + iter != mOutfitMap.end(); + ++iter) + { + if (!iter->second) continue; + LLOutfitGalleryItem* item = (LLOutfitGalleryItem*)iter->second; + + // refresh font color + item->setOutfitFavorite(item->isFavorite()); + } +} + LLPanel* LLOutfitGallery::addLastRow() { mRowCount++; @@ -524,6 +553,10 @@ LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item) { + if (!item) + { + return; + } if(item->isHidden()) { mHiddenItems.push_back(item); @@ -601,8 +634,8 @@ void LLOutfitGallery::removeFromGalleryMiddle(LLOutfitGalleryItem* item) removeFromGalleryLast(mItems[i]); } removeFromGalleryLast(mItems[n]); - int saved_count = saved.size(); - for (int i = 0; i < saved_count; i++) + auto saved_count = saved.size(); + for (size_t i = 0; i < saved_count; i++) { addToGallery(saved.back()); saved.pop_back(); @@ -617,7 +650,7 @@ void LLOutfitGallery::removeFromLastRow(LLOutfitGalleryItem* item) mItemPanels.pop_back(); } -LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID outfit_id) +LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID outfit_id, bool is_favorite) { LLOutfitGalleryItem::Params giparams; LLOutfitGalleryItem* gitem = LLUICtrlFactory::create<LLOutfitGalleryItem>(giparams); @@ -626,14 +659,25 @@ LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID gitem->setFollowsLeft(); gitem->setFollowsTop(); gitem->setOutfitName(name); + gitem->setOutfitFavorite(is_favorite); gitem->setUUID(outfit_id); gitem->setGallery(this); return gitem; } -LLOutfitGalleryItem* LLOutfitGallery::getSelectedItem() +LLOutfitGalleryItem* LLOutfitGallery::getSelectedItem() const +{ + return getItem(mSelectedOutfitUUID); +} + +LLOutfitGalleryItem* LLOutfitGallery::getItem(const LLUUID& id) const { - return mOutfitMap[mSelectedOutfitUUID]; + auto it = mOutfitMap.find(id); + if (it != mOutfitMap.end()) + { + return it->second; + } + return nullptr; } void LLOutfitGallery::buildGalleryPanel(int row_count) @@ -738,13 +782,16 @@ void LLOutfitGallery::onFilterSubStringChanged(const std::string& new_string, co void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id) { - if (mOutfitMap[base_id]) + auto base_it = mOutfitMap.find(base_id); + if (base_it != mOutfitMap.end()) { - mOutfitMap[base_id]->setOutfitWorn(true); + base_it->second->setOutfitWorn(true); } - if (mOutfitMap[prev_id]) + + auto prev_it = mOutfitMap.find(prev_id); + if (prev_it != mOutfitMap.end()) { - mOutfitMap[prev_id]->setOutfitWorn(false); + prev_it->second->setOutfitWorn(false); } } @@ -770,8 +817,7 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); if (!cat) return; - std::string name = cat->getName(); - LLOutfitGalleryItem* item = buildGalleryItem(name, cat_id); + LLOutfitGalleryItem* item = buildGalleryItem(cat->getName(), cat_id, cat->getIsFavorite()); mOutfitMap.insert(LLOutfitGallery::outfit_map_value_t(cat_id, item)); item->setRightMouseDownCallback(boost::bind(&LLOutfitListBase::outfitRightClickCallBack, this, _1, _2, _3, cat_id)); @@ -840,6 +886,7 @@ void LLOutfitGallery::updateChangedCategoryName(LLViewerInventoryCategory *cat, if (item) { item->setOutfitName(name); + item->setOutfitFavorite(cat->getIsFavorite()); } } } @@ -858,13 +905,16 @@ void LLOutfitGallery::onChangeOutfitSelection(LLWearableItemsList* list, const L { if (mSelectedOutfitUUID == category_id) return; - if (mOutfitMap[mSelectedOutfitUUID]) + + auto selected_it = mOutfitMap.find(mSelectedOutfitUUID); + if (selected_it != mOutfitMap.end()) { - mOutfitMap[mSelectedOutfitUUID]->setSelected(FALSE); + selected_it->second->setSelected(false); } - if (mOutfitMap[category_id]) + auto category_it = mOutfitMap.find(category_id); + if (category_it != mOutfitMap.end()) { - mOutfitMap[category_id]->setSelected(TRUE); + category_it->second->setSelected(true); } // mSelectedOutfitUUID will be set in LLOutfitListBase::ChangeOutfitSelection } @@ -886,9 +936,10 @@ bool LLOutfitGallery::canWearSelected() bool LLOutfitGallery::hasDefaultImage(const LLUUID& outfit_cat_id) { - if (mOutfitMap[outfit_cat_id]) + auto outfit_it = mOutfitMap.find(outfit_cat_id); + if (outfit_it != mOutfitMap.end()) { - return mOutfitMap[outfit_cat_id]->isDefaultImage(); + return outfit_it->second->isDefaultImage(); } return false; } @@ -897,15 +948,15 @@ void LLOutfitGallery::updateMessageVisibility() { if (mItems.empty()) { - mMessageTextBox->setVisible(TRUE); - mScrollPanel->setVisible(FALSE); + mMessageTextBox->setVisible(true); + mScrollPanel->setVisible(false); std::string message = getString(getFilterSubString().empty() ? "no_outfits_msg" : "no_matched_outfits_msg"); mMessageTextBox->setValue(message); } else { - mScrollPanel->setVisible(TRUE); - mMessageTextBox->setVisible(FALSE); + mScrollPanel->setVisible(true); + mMessageTextBox->setVisible(false); } } @@ -916,6 +967,10 @@ LLOutfitListGearMenuBase* LLOutfitGallery::createGearMenu() static LLDefaultChildRegistry::Register<LLOutfitGalleryItem> r("outfit_gallery_item"); +bool LLOutfitGalleryItem::sColorSetInitialized = false; +LLUIColor LLOutfitGalleryItem::sDefaultTextColor; +LLUIColor LLOutfitGalleryItem::sDefaultFavoriteColor; + LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p) : LLPanel(p), mGallery(nullptr), @@ -927,6 +982,12 @@ LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p) mUUID(LLUUID()) { buildFromFile("panel_outfit_gallery_item.xml"); + if (!sColorSetInitialized) + { + sDefaultTextColor = LLUIColorTable::instance().getColor("White", LLColor4::white); + sDefaultFavoriteColor = LLUIColorTable::instance().getColor("InventoryFavoriteColor", LLColor4::white); + sColorSetInitialized = true; + } } LLOutfitGalleryItem::~LLOutfitGalleryItem() @@ -934,8 +995,9 @@ LLOutfitGalleryItem::~LLOutfitGalleryItem() } -BOOL LLOutfitGalleryItem::postBuild() +bool LLOutfitGalleryItem::postBuild() { + mPreviewIcon = getChild<LLIconCtrl>("preview_outfit"); setDefaultImage(); mOutfitNameText = getChild<LLTextBox>("outfit_name"); @@ -943,7 +1005,7 @@ BOOL LLOutfitGalleryItem::postBuild() mTextBgPanel = getChild<LLPanel>("text_bg_panel"); setOutfitWorn(false); mHidden = false; - return TRUE; + return true; } void LLOutfitGalleryItem::draw() @@ -951,10 +1013,12 @@ void LLOutfitGalleryItem::draw() LLPanel::draw(); // Draw border - LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "OutfitGalleryItemSelected" : "OutfitGalleryItemUnselected", LLColor4::white); - LLRect border = getChildView("preview_outfit")->getRect(); + static LLUIColor selected_color = LLUIColorTable::instance().getColor("OutfitGalleryItemSelected", LLColor4::white); + static LLUIColor unselected_color = LLUIColorTable::instance().getColor("OutfitGalleryItemUnselected", LLColor4::white); + const LLColor4& border_color = mSelected ? selected_color : unselected_color; + LLRect border = mPreviewIcon->getRect(); border.mRight = border.mRight + 1; - gl_rect_2d(border, border_color.get(), FALSE); + gl_rect_2d(border, border_color, false); // If the floater is focused, don't apply its alpha to the texture (STORM-677). const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); @@ -980,6 +1044,18 @@ void LLOutfitGalleryItem::draw() } } + static LLUICachedControl<bool> draw_star("InventoryFavoritesUseStar", true); + if(mFavorite && draw_star()) + { + const S32 HPAD = 3; + const S32 VPAD = 6; // includes padding for text and for the image + const S32 image_size = 14; + static LLPointer<LLUIImage> fav_img = LLRender2D::getInstance()->getUIImage("Inv_Favorite_Star_Full"); + + gl_draw_scaled_image( + border.getWidth() - image_size - HPAD, image_size + VPAD + mOutfitNameText->getRect().getHeight(), + image_size, image_size, fav_img->getImage(), UI_VERTEX_COLOR % alpha); + } } void LLOutfitGalleryItem::setOutfitName(std::string name) @@ -989,18 +1065,27 @@ void LLOutfitGalleryItem::setOutfitName(std::string name) mOutfitName = name; } +void LLOutfitGalleryItem::setOutfitFavorite(bool is_favorite) +{ + mFavorite = is_favorite; + + LLCachedControl<bool> use_color(gSavedSettings, "InventoryFavoritesColorText"); + mOutfitNameText->setReadOnlyColor((mFavorite && use_color()) ? sDefaultFavoriteColor.get() : sDefaultTextColor.get()); +} + void LLOutfitGalleryItem::setOutfitWorn(bool value) { mWorn = value; LLStringUtil::format_map_t worn_string_args; std::string worn_string = getString("worn_string", worn_string_args); - LLUIColor text_color = LLUIColorTable::instance().getColor("White", LLColor4::white); - mOutfitWornText->setReadOnlyColor(text_color.get()); - mOutfitNameText->setReadOnlyColor(text_color.get()); + mOutfitWornText->setReadOnlyColor(sDefaultTextColor.get()); mOutfitWornText->setFont(value ? LLFontGL::getFontSansSerifBold() : LLFontGL::getFontSansSerifSmall()); mOutfitNameText->setFont(value ? LLFontGL::getFontSansSerifBold() : LLFontGL::getFontSansSerifSmall()); mOutfitWornText->setValue(value ? worn_string : ""); mOutfitNameText->setText(mOutfitName); // refresh LLTextViewModel to pick up font changes + + LLCachedControl<bool> use_color(gSavedSettings, "InventoryFavoritesColorText"); + mOutfitNameText->setReadOnlyColor((mFavorite && use_color()) ? sDefaultFavoriteColor.get() : sDefaultTextColor.get()); } void LLOutfitGalleryItem::setSelected(bool value) @@ -1010,31 +1095,31 @@ void LLOutfitGalleryItem::setSelected(bool value) setOutfitWorn(mWorn); } -BOOL LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) +bool LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) { - setFocus(TRUE); + setFocus(true); return LLUICtrl::handleMouseDown(x, y, mask); } -BOOL LLOutfitGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) +bool LLOutfitGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) { - setFocus(TRUE); + setFocus(true); return LLUICtrl::handleRightMouseDown(x, y, mask); } -BOOL LLOutfitGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask) +bool LLOutfitGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask) { return openOutfitsContent() || LLPanel::handleDoubleClick(x, y, mask); } -BOOL LLOutfitGalleryItem::handleKeyHere(KEY key, MASK mask) +bool LLOutfitGalleryItem::handleKeyHere(KEY key, MASK mask) { if (!mGallery) { - return FALSE; + return false; } - BOOL handled = FALSE; + bool handled = false; switch (key) { case KEY_LEFT: @@ -1110,7 +1195,7 @@ bool LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) { mImageAssetId = image_asset_id; mTexturep = texture; - getChildView("preview_outfit")->setVisible(FALSE); + mPreviewIcon->setVisible(false); mDefaultImage = false; mImageUpdatePending = (texture->getDiscardLevel() == -1); return true; @@ -1127,14 +1212,14 @@ void LLOutfitGalleryItem::setDefaultImage() { mTexturep = NULL; mImageAssetId.setNull(); - getChildView("preview_outfit")->setVisible(TRUE); + mPreviewIcon->setVisible(true); mDefaultImage = true; mImageUpdatePending = false; } LLContextMenu* LLOutfitGalleryContextMenu::createMenu() { - LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::ScopedRegistrarHelper registrar; LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; LLUUID selected_id = mUUIDs.front(); @@ -1146,9 +1231,10 @@ LLContextMenu* LLOutfitGalleryContextMenu::createMenu() boost::bind(&LLAppearanceMgr::takeOffOutfit, &LLAppearanceMgr::instance(), selected_id)); registrar.add("Outfit.Edit", boost::bind(editOutfit)); registrar.add("Outfit.Rename", boost::bind(renameOutfit, selected_id)); - registrar.add("Outfit.Delete", boost::bind(LLOutfitGallery::onRemoveOutfit, selected_id)); - registrar.add("Outfit.Create", boost::bind(&LLOutfitGalleryContextMenu::onCreate, this, _2)); + registrar.add("Outfit.Delete", boost::bind(LLOutfitGallery::onRemoveOutfit, selected_id), LLUICtrl::cb_info::UNTRUSTED_BLOCK); + registrar.add("Outfit.Create", boost::bind(&LLOutfitGalleryContextMenu::onCreate, this, _2), LLUICtrl::cb_info::UNTRUSTED_BLOCK); registrar.add("Outfit.Thumbnail", boost::bind(&LLOutfitGalleryContextMenu::onThumbnail, this, selected_id)); + registrar.add("Outfit.Favorite", boost::bind(&LLOutfitGalleryContextMenu::onFavorite, this, selected_id)); registrar.add("Outfit.Save", boost::bind(&LLOutfitGalleryContextMenu::onSave, this, selected_id)); enable_registrar.add("Outfit.OnEnable", boost::bind(&LLOutfitGalleryContextMenu::onEnable, this, _2)); enable_registrar.add("Outfit.OnVisible", boost::bind(&LLOutfitGalleryContextMenu::onVisible, this, _2)); @@ -1187,24 +1273,18 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() { if (!mMenu) return; bool have_selection = getSelectedOutfitID().notNull(); - mMenu->setItemVisible("expand", FALSE); - mMenu->setItemVisible("collapse", FALSE); + mMenu->setItemVisible("expand", false); + mMenu->setItemVisible("collapse", false); mMenu->setItemVisible("thumbnail", have_selection); - mMenu->setItemVisible("sort_folders_by_name", TRUE); + mMenu->setItemVisible("inventory_settings", false); + mMenu->setItemVisible("inv_settings_separator", false); + mMenu->setItemVisible("sort_order_separator", true); + mMenu->setItemVisible("sort_order_by_image", true); + mMenu->setItemVisible("sepatator3", true); + mMenu->setItemVisible("sort_folders_by_name", true); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } -void LLOutfitGalleryGearMenu::onChangeSortOrder() -{ - bool sort_by_name = !gSavedSettings.getBOOL("OutfitGallerySortByName"); - gSavedSettings.setBOOL("OutfitGallerySortByName", sort_by_name); - LLOutfitGallery* gallery = dynamic_cast<LLOutfitGallery*>(mOutfitList); - if (gallery) - { - gallery->reArrangeRows(); - } -} - bool LLOutfitGalleryGearMenu::hasDefaultImage() { LLOutfitGallery* gallery = dynamic_cast<LLOutfitGallery*>(mOutfitList); @@ -1263,7 +1343,15 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } if (asset_id.notNull()) { - photo_loaded |= mOutfitMap[category_id]->setImageAssetId(asset_id); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + photo_loaded |= item->setImageAssetId(asset_id); + } + else + { + photo_loaded = true; + } // Rename links if (!mOutfitRenamePending.isNull() && mOutfitRenamePending.asString() == item_name) { @@ -1278,7 +1366,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) LLFloater* appearance_floater = LLFloaterReg::getInstance("appearance"); if (appearance_floater) { - appearance_floater->setFocus(TRUE); + appearance_floater->setFocus(true); } } if (item_name == LLAppearanceMgr::sExpectedTextureName) @@ -1289,13 +1377,21 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } if (!photo_loaded) { - mOutfitMap[category_id]->setDefaultImage(); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + item->setDefaultImage(); + } } } } else { - mOutfitMap[category_id]->setImageAssetId(asset_id); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + item->setImageAssetId(asset_id); + } } } @@ -1305,6 +1401,15 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } } +LLToggleableMenu* LLOutfitGallery::getSortMenu() +{ + if (!mSortMenu) + { + mSortMenu = new LLOutfitGallerySortMenu(this); + } + return mSortMenu->getMenu(); +} + LLUUID LLOutfitGallery::getPhotoAssetId(const LLUUID& outfit_id) { outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); @@ -1320,3 +1425,84 @@ LLUUID LLOutfitGallery::getDefaultPhoto() return LLUUID(); } + +//////////////////// LLOutfitGallerySortMenu //////////////////// + +LLOutfitGallerySortMenu::LLOutfitGallerySortMenu(LLOutfitListBase* parent_panel) + : mPanelHandle(parent_panel->getHandle()) +{ + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + registrar.add("Sort.OnSort", { boost::bind(&LLOutfitGallerySortMenu::onSort, this, _2) }); + enable_registrar.add("Sort.OnEnable", boost::bind(&LLOutfitGallerySortMenu::onEnable, this, _2)); + + mMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>( + "menu_outfit_gallery_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + llassert(mMenu); +} + + +LLToggleableMenu* LLOutfitGallerySortMenu::getMenu() +{ + return mMenu; +} + +void LLOutfitGallerySortMenu::updateItemsVisibility() +{ + onUpdateItemsVisibility(); +} + +void LLOutfitGallerySortMenu::onUpdateItemsVisibility() +{ + if (!mMenu) return; +} + +bool LLOutfitGallerySortMenu::onEnable(LLSD::String param) +{ + LLCachedControl<S32> sort_order(gSavedSettings, "OutfitGallerySortOrder", 0); + if ("favorites_to_top" == param) + { + return sort_order == 2; + } + else if ("images_to_top" == param) + { + return sort_order == 1; + } + else if ("by_name" == param) + { + return sort_order == 0; + } + + return false; +} + +void LLOutfitGallerySortMenu::onSort(LLSD::String param) +{ + S32 sort_order = gSavedSettings.getS32("OutfitGallerySortOrder"); + S32 new_sort_order = 0; + if ("favorites_to_top" == param) + { + new_sort_order = 2; + } + else if ("images_to_top" == param) + { + new_sort_order = 1; + } + else if ("by_name" == param) + { + new_sort_order = 0; + } + if (sort_order == new_sort_order) + { + new_sort_order = sort_order ? 0 : 1; + } + gSavedSettings.setS32("OutfitGallerySortOrder", new_sort_order); + + LLOutfitGallery* gallery = dynamic_cast<LLOutfitGallery*>(mPanelHandle.get()); + if (gallery) + { + gallery->reArrangeRows(); + } +} + |