diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-05-09 23:22:26 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-05-09 23:50:02 +0300 |
commit | a420e84f4822d19388241f99a916dacc4d1eab61 (patch) | |
tree | bf6c185584af53cc183434cc35cbf77d1a426ae9 /indra/newview | |
parent | 5c78396b64c985a7e58d045ff3f343bccc81c8d3 (diff) |
viewer#1424 Favorites in Appearance floater #2
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 28 | ||||
-rw-r--r-- | indra/newview/llinventoryobserver.cpp | 29 | ||||
-rw-r--r-- | indra/newview/llinventoryobserver.h | 18 | ||||
-rw-r--r-- | indra/newview/lloutfitslist.cpp | 37 | ||||
-rw-r--r-- | indra/newview/lloutfitslist.h | 9 | ||||
-rwxr-xr-x | indra/newview/skins/default/xui/en/menu_gallery_outfit_tab.xml | 32 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_outfit_gear.xml | 12 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_outfit_tab.xml | 6 |
8 files changed, 140 insertions, 31 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 604adea125..123d47b474 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2364,8 +2364,21 @@ void set_favorite(const LLUUID& obj_id, bool favorite) LLInventoryObject* obj = gInventory.getObject(obj_id); if (obj->getIsFavorite() != favorite) { + LLSD val; + if (favorite) + { + val = true; + } // else leave undefined to remove unneeded metadata field + LLSD updates; - updates["favorite"] = LLSD().with("toggled", favorite); + if (favorite) + { + updates["favorite"] = LLSD().with("toggled", true); + } + else + { + updates["favorite"] = LLSD(); + } LLPointer<LLInventoryCallback> cb = new LLUpdateFavorite(obj_id); @@ -2385,9 +2398,20 @@ void set_favorite(const LLUUID& obj_id, bool favorite) void toggle_favorite(const LLUUID& obj_id) { LLInventoryObject* obj = gInventory.getObject(obj_id); + if (!obj) + { + return; + } LLSD updates; - updates["favorite"] = LLSD().with("toggled", !obj->getIsFavorite()); + if (!obj->getIsFavorite()) + { + updates["favorite"] = LLSD().with("toggled", true); + } + else + { + updates["favorite"] = LLSD(); + } LLPointer<LLInventoryCallback> cb = new LLUpdateFavorite(obj_id); diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 15cd7957a2..4676d8a411 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -749,6 +749,13 @@ void LLInventoryCategoriesObserver::changed(U32 mask) cat_changed = true; } + bool is_favorite = category->getIsFavorite(); + if (cat_data.mIsFavorite != is_favorite) + { + cat_data.mIsFavorite = is_favorite; + cat_changed = true; + } + // If anything has changed above, fire the callback. if (cat_changed) cat_data.mCallback(); @@ -766,6 +773,7 @@ bool LLInventoryCategoriesObserver::addCategory(const LLUUID& cat_id, callback_t S32 version = LLViewerInventoryCategory::VERSION_UNKNOWN; S32 current_num_known_descendents = LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN; bool can_be_added = true; + bool favorite = false; LLUUID thumbnail_id; LLViewerInventoryCategory* category = gInventory.getCategory(cat_id); @@ -779,6 +787,7 @@ bool LLInventoryCategoriesObserver::addCategory(const LLUUID& cat_id, callback_t // to a category have been made. version = category->getVersion(); thumbnail_id = category->getThumbnailUUID(); + favorite = category->getIsFavorite(); LLInventoryModel::cat_array_t* cats; LLInventoryModel::item_array_t* items; @@ -804,11 +813,11 @@ bool LLInventoryCategoriesObserver::addCategory(const LLUUID& cat_id, callback_t if(init_name_hash) { digest_t item_name_hash = gInventory.hashDirectDescendentNames(cat_id); - mCategoryMap.insert(category_map_value_t(cat_id,LLCategoryData(cat_id, thumbnail_id, cb, version, current_num_known_descendents,item_name_hash))); + mCategoryMap.insert(category_map_value_t(cat_id,LLCategoryData(cat_id, thumbnail_id, favorite, cb, version, current_num_known_descendents,item_name_hash))); } else { - mCategoryMap.insert(category_map_value_t(cat_id,LLCategoryData(cat_id, thumbnail_id, cb, version, current_num_known_descendents))); + mCategoryMap.insert(category_map_value_t(cat_id,LLCategoryData(cat_id, thumbnail_id, favorite, cb, version, current_num_known_descendents))); } } @@ -821,25 +830,37 @@ void LLInventoryCategoriesObserver::removeCategory(const LLUUID& cat_id) } LLInventoryCategoriesObserver::LLCategoryData::LLCategoryData( - const LLUUID& cat_id, const LLUUID& thumbnail_id, callback_t cb, S32 version, S32 num_descendents) + const LLUUID& cat_id, + const LLUUID& thumbnail_id, + bool is_favorite, + callback_t cb, + S32 version, + S32 num_descendents) : mCatID(cat_id) , mCallback(cb) , mVersion(version) , mDescendentsCount(num_descendents) , mThumbnailId(thumbnail_id) + , mIsFavorite(is_favorite) , mIsNameHashInitialized(false) { } LLInventoryCategoriesObserver::LLCategoryData::LLCategoryData( - const LLUUID& cat_id, const LLUUID& thumbnail_id, callback_t cb, S32 version, S32 num_descendents, const digest_t& name_hash) + const LLUUID& cat_id, + const LLUUID& thumbnail_id, + bool is_favorite, + callback_t cb, S32 version, + S32 num_descendents, + const digest_t& name_hash) : mCatID(cat_id) , mCallback(cb) , mVersion(version) , mDescendentsCount(num_descendents) , mThumbnailId(thumbnail_id) + , mIsFavorite(is_favorite) , mIsNameHashInitialized(true) , mItemNameHash(name_hash) { diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index 6cd630bcd2..7b7d8b06d9 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -277,12 +277,26 @@ protected: typedef LLUUID digest_t; // To clarify the actual usage of this "UUID" struct LLCategoryData { - LLCategoryData(const LLUUID& cat_id, const LLUUID& thumbnail_id, callback_t cb, S32 version, S32 num_descendents); - LLCategoryData(const LLUUID& cat_id, const LLUUID& thumbnail_id, callback_t cb, S32 version, S32 num_descendents, const digest_t& name_hash); + LLCategoryData( + const LLUUID& cat_id, + const LLUUID& thumbnail_id, + bool is_favorite, + callback_t cb, + S32 version, + S32 num_descendents); + LLCategoryData( + const LLUUID& cat_id, + const LLUUID& thumbnail_id, + bool is_favorite, + callback_t cb, + S32 version, + S32 num_descendents, + const digest_t& name_hash); callback_t mCallback; S32 mVersion; S32 mDescendentsCount; digest_t mItemNameHash; + bool mIsFavorite; bool mIsNameHashInitialized; LLUUID mCatID; LLUUID mThumbnailId; diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index c01e04f88d..ef38edfe3d 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -81,6 +81,9 @@ const outfit_accordion_tab_params& get_accordion_tab_params() { initialized = true; + LLOutfitAccordionCtrlTab::sFavoriteIcon = LLUI::getUIImage("Inv_Favorite_Star_Full"); + LLOutfitAccordionCtrlTab::sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", LLColor4U(255, 255, 255)); + LLXMLNodePtr xmlNode; if (LLUICtrlFactory::getLayeredXMLNode("outfit_accordion_tab.xml", xmlNode)) { @@ -155,6 +158,7 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_id) tab->setName(name); tab->setTitle(name); + tab->setFavorite(cat->getIsFavorite()); // *TODO: LLUICtrlFactory::defaultBuilder does not use "display_children" from xml. Should be investigated. tab->setDisplayChildren(false); @@ -426,11 +430,12 @@ void LLOutfitsList::updateChangedCategoryName(LLViewerInventoryCategory *cat, st if (outfits_iter != mOutfitsMap.end()) { // Update tab name with the new category name. - LLAccordionCtrlTab* tab = outfits_iter->second; + LLOutfitAccordionCtrlTab* tab = (LLOutfitAccordionCtrlTab*) outfits_iter->second; if (tab) { tab->setName(name); tab->setTitle(name); + tab->setFavorite(cat->getIsFavorite()); } } } @@ -1382,6 +1387,16 @@ void LLOutfitListGearMenu::onUpdateItemsVisibility() LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } + +LLUIImage* LLOutfitAccordionCtrlTab::sFavoriteIcon; +LLUIColor LLOutfitAccordionCtrlTab::sFgColor; + +void LLOutfitAccordionCtrlTab::draw() +{ + LLAccordionCtrlTab::draw(); + drawFavoriteIcon(); +} + BOOL LLOutfitAccordionCtrlTab::handleToolTip(S32 x, S32 y, MASK mask) { if (y >= getLocalRect().getHeight() - getHeaderHeight()) @@ -1402,4 +1417,24 @@ BOOL LLOutfitAccordionCtrlTab::handleToolTip(S32 x, S32 y, MASK mask) return LLAccordionCtrlTab::handleToolTip(x, y, mask); } + +void LLOutfitAccordionCtrlTab::drawFavoriteIcon() +{ + if (!mIsFavorite) + { + return; + } + static LLUICachedControl<bool> draw_star("InventoryFavoritesUseStar", true); + if (!draw_star) + { + return; + } + + const S32 PAD = 2; + const S32 image_size = 18; + + gl_draw_scaled_image( + getRect().getWidth() - image_size - PAD, getRect().getHeight() - image_size - PAD, + image_size, image_size, sFavoriteIcon->getImage(), sFgColor); +} // EOF diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index 86702cedfb..8975ac09d1 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -221,8 +221,14 @@ public: Params() : cat_id("cat_id") {} }; + virtual void draw(); virtual BOOL handleToolTip(S32 x, S32 y, MASK mask); + void setFavorite(bool is_favorite) { mIsFavorite = is_favorite; } + + static LLUIImage* sFavoriteIcon; + static LLUIColor sFgColor; + protected: LLOutfitAccordionCtrlTab(const LLOutfitAccordionCtrlTab::Params &p) : LLAccordionCtrlTab(p), @@ -230,7 +236,10 @@ public: {} friend class LLUICtrlFactory; + void drawFavoriteIcon(); + LLUUID mFolderID; + bool mIsFavorite = false; }; /** * @class LLOutfitsList diff --git a/indra/newview/skins/default/xui/en/menu_gallery_outfit_tab.xml b/indra/newview/skins/default/xui/en/menu_gallery_outfit_tab.xml index 77de521154..fb68193006 100755 --- a/indra/newview/skins/default/xui/en/menu_gallery_outfit_tab.xml +++ b/indra/newview/skins/default/xui/en/menu_gallery_outfit_tab.xml @@ -50,24 +50,24 @@ function="Outfit.Thumbnail" /> </menu_item_call> <menu_item_call - label="Add to favorites" - layout="topleft" - name="favorites_add"> + label="Add to favorites" + layout="topleft" + name="favorites_add"> <on_visible - function="Outfit.OnVisible" - parameter="favorites_add" /> - <on_click - function="Outfit.Favorite" /> + function="Outfit.OnVisible" + parameter="favorites_add" /> + <on_click + function="Outfit.Favorite" /> </menu_item_call> - <menu_item_call - label="Remove from favorites" - layout="topleft" - name="favorites_remove"> - <on_visible - function="Outfit.OnVisible" - parameter="favorites_remove" /> - <on_click - function="Outfit.Favorite" /> + <menu_item_call + label="Remove from favorites" + layout="topleft" + name="favorites_remove"> + <on_visible + function="Outfit.OnVisible" + parameter="favorites_remove" /> + <on_click + function="Outfit.Favorite" /> </menu_item_call> <menu_item_call label="Edit outfit" diff --git a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml index 794041c083..7eb03ce6d8 100644 --- a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml @@ -53,9 +53,9 @@ label="Add to favorite outfits" layout="topleft" name="favorites_add"> - <on_visible - function="Gear.OnVisible" - parameter="favorites_add" /> + <on_visible + function="Gear.OnVisible" + parameter="favorites_add" /> <on_click function="Gear.Favorite" /> </menu_item_call> @@ -63,9 +63,9 @@ label="Remove from favorite outfits" layout="topleft" name="favorites_remove"> - <on_visible - function="Gear.OnVisible" - parameter="favorites_remove" /> + <on_visible + function="Gear.OnVisible" + parameter="favorites_remove" /> <on_click function="Gear.Favorite" /> </menu_item_call> diff --git a/indra/newview/skins/default/xui/en/menu_outfit_tab.xml b/indra/newview/skins/default/xui/en/menu_outfit_tab.xml index 070efe9d78..0d45e7c95c 100644 --- a/indra/newview/skins/default/xui/en/menu_outfit_tab.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_tab.xml @@ -53,6 +53,9 @@ label="Add to favorites" layout="topleft" name="favorites_add"> + <on_visible + function="Outfit.OnVisible" + parameter="favorites_add" /> <on_click function="Outfit.Favorite" /> </menu_item_call> @@ -60,6 +63,9 @@ label="Remove from favorites" layout="topleft" name="favorites_remove"> + <on_visible + function="Outfit.OnVisible" + parameter="favorites_remove" /> <on_click function="Outfit.Favorite" /> </menu_item_call> |