diff options
Diffstat (limited to 'indra/newview/lloutfitgallery.cpp')
-rw-r--r-- | indra/newview/lloutfitgallery.cpp | 208 |
1 files changed, 31 insertions, 177 deletions
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 3adee9fa16..98b7d74cd2 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -87,16 +87,9 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) mItemsInRow(p.items_in_row), mRowPanWidthFactor(p.row_panel_width_factor), mGalleryWidthFactor(p.gallery_width_factor), - mTextureSelected(NULL), - mSortMenu(nullptr) + mTextureSelected(NULL) { updateGalleryWidth(); - - LLControlVariable* ctrl = gSavedSettings.getControl("InventoryFavoritesColorText"); - if (ctrl) - { - mSavedSettingInvFavColor = ctrl->getSignal()->connect(boost::bind(&LLOutfitGallery::handleInvFavColorChange, this)); - } } LLOutfitGallery::Params::Params() @@ -427,32 +420,19 @@ void LLOutfitGallery::updateRowsIfNeeded() bool compareGalleryItem(LLOutfitGalleryItem* item1, LLOutfitGalleryItem* item2) { - static LLCachedControl<S32> sort_by_name(gSavedSettings, "OutfitGallerySortOrder", 0); - switch (sort_by_name()) + static LLCachedControl<bool> outfit_gallery_sort_by_name(gSavedSettings, "OutfitGallerySortByName"); + if(outfit_gallery_sort_by_name || + ((item1->isDefaultImage() && item2->isDefaultImage()) || (!item1->isDefaultImage() && !item2->isDefaultImage()))) { - case 2: - // Sort by favorites - favorite items first, then alphabetically - if (item1->isFavorite() != item2->isFavorite()) - { - return item1->isFavorite(); - } - break; - case 1: - // Sort by images - items with non-default images first, then alphabetically - if (item1->isDefaultImage() != item2->isDefaultImage()) - { - return item2->isDefaultImage(); - } - break; - default: - // Sort alphabetically only - break; - } + std::string name1 = item1->getItemName(); + std::string name2 = item2->getItemName(); - // Final comparison is always alphabetical by name - std::string name1 = item1->getItemName(); - std::string name2 = item2->getItemName(); - return (LLStringUtil::compareDict(name1, name2) < 0); + return (LLStringUtil::compareDict(name1, name2) < 0); + } + else + { + return item2->isDefaultImage(); + } } void LLOutfitGallery::reArrangeRows(S32 row_diff) @@ -495,20 +475,6 @@ 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++; @@ -660,7 +626,7 @@ void LLOutfitGallery::removeFromLastRow(LLOutfitGalleryItem* item) mItemPanels.pop_back(); } -LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID outfit_id, bool is_favorite) +LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID outfit_id) { LLOutfitGalleryItem::Params giparams; LLOutfitGalleryItem* gitem = LLUICtrlFactory::create<LLOutfitGalleryItem>(giparams); @@ -669,7 +635,6 @@ 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; @@ -832,7 +797,8 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) return; } - LLOutfitGalleryItem* item = buildGalleryItem(cat->getName(), cat_id, cat->getIsFavorite()); + std::string name = cat->getName(); + LLOutfitGalleryItem* item = buildGalleryItem(name, cat_id); mOutfitMap.insert(LLOutfitGallery::outfit_map_value_t(cat_id, item)); item->setRightMouseDownCallback(boost::bind(&LLOutfitListBase::outfitRightClickCallBack, this, _1, _2, _3, cat_id)); @@ -895,7 +861,6 @@ void LLOutfitGallery::updateChangedCategoryName(LLViewerInventoryCategory *cat, if (item) { item->setOutfitName(name); - item->setOutfitFavorite(cat->getIsFavorite()); } } } @@ -976,10 +941,6 @@ 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), @@ -991,12 +952,6 @@ 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() @@ -1043,19 +998,6 @@ void LLOutfitGalleryItem::draw() gl_draw_scaled_image(interior.mLeft - 1, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha); } - 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"); - - const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); - 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) @@ -1065,28 +1007,18 @@ void LLOutfitGalleryItem::setOutfitName(std::string name) mOutfitName = name; } -void LLOutfitGalleryItem::setOutfitFavorite(bool is_favorite) -{ - mFavorite = is_favorite; - - static LLCachedControl<bool> use_color(gSavedSettings, "InventoryFavoritesColorText"); - mOutfitNameText->setReadOnlyColor((mFavorite && use_color()) ? sDefaultFavoriteColor : sDefaultTextColor); -} - void LLOutfitGalleryItem::setOutfitWorn(bool value) { mWorn = value; LLStringUtil::format_map_t worn_string_args; std::string worn_string = getString("worn_string", worn_string_args); - mOutfitWornText->setReadOnlyColor(sDefaultTextColor.get()); - mOutfitNameText->setReadOnlyColor(sDefaultTextColor.get()); + LLUIColor text_color = LLUIColorTable::instance().getColor("White", LLColor4::white); + mOutfitWornText->setReadOnlyColor(text_color); + mOutfitNameText->setReadOnlyColor(text_color); 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 - - static LLCachedControl<bool> use_color(gSavedSettings, "InventoryFavoritesColorText"); - mOutfitNameText->setReadOnlyColor((mFavorite && use_color()) ? sDefaultFavoriteColor : sDefaultTextColor); } void LLOutfitGalleryItem::setSelected(bool value) @@ -1238,7 +1170,6 @@ LLContextMenu* LLOutfitGalleryContextMenu::createMenu() registrar.add("Outfit.Delete", boost::bind(LLOutfitGallery::onRemoveOutfit, selected_id)); registrar.add("Outfit.Create", boost::bind(&LLOutfitGalleryContextMenu::onCreate, this, _2)); 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)); @@ -1277,12 +1208,25 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() { if (!mMenu) return; bool have_selection = getSelectedOutfitID().notNull(); + mMenu->setItemVisible("expand", false); + mMenu->setItemVisible("collapse", false); mMenu->setItemVisible("thumbnail", have_selection); 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); @@ -1399,15 +1343,6 @@ 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); @@ -1423,84 +1358,3 @@ 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) -{ - static 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(); - } -} - |