From 6a02f5bbcec2b1a530ceeacb0dc564cfeb7cbc7f Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Fri, 11 Dec 2015 19:58:08 +0200 Subject: Initial version of Visual Outfit Browser --- indra/newview/lloutfitgallery.cpp | 699 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 699 insertions(+) create mode 100644 indra/newview/lloutfitgallery.cpp (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp new file mode 100644 index 0000000000..2d8085e128 --- /dev/null +++ b/indra/newview/lloutfitgallery.cpp @@ -0,0 +1,699 @@ +/** + * @file lloutfitgallery.cpp + * @author Pavlo Kryvych + * @brief Visual gallery of agent's outfits for My Appearance side panel + * + * $LicenseInfo:firstyear=2015&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2015, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" // must be first include +#include "lloutfitgallery.h" + +#include + +// llcommon +#include "llcommonutils.h" +#include "llvfile.h" + +#include "llappearancemgr.h" +#include "lleconomy.h" +#include "llerror.h" +#include "llfilepicker.h" +#include "llfloaterperms.h" +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" +#include "lllocalbitmaps.h" +#include "llviewermenufile.h" +#include "llwearableitemslist.h" + + +static LLPanelInjector t_outfit_gallery("outfit_gallery"); +static LLOutfitGallery* gOutfitGallery = NULL; + +LLOutfitGallery::LLOutfitGallery() + : LLOutfitListBase(), + mTexturesObserver(NULL) +{ +// mGearMenu = new LLOutfitGalleryGearMenu(this); +} + +BOOL LLOutfitGallery::postBuild() +{ + BOOL rv = LLOutfitListBase::postBuild(); + return rv; +} + +void LLOutfitGallery::onOpen(const LLSD& info) +{ + LLOutfitListBase::onOpen(info); + rebuildGallery(); + loadPhotos(); +} + +#define LAYOUT_STACK_HEIGHT 180 +#define GALLERY_VERTICAL_GAP 10 +#define GALLERY_HORIZONTAL_GAP 10 +#define GALLERY_ITEM_WIDTH 150 +#define GALLERY_ITEM_HEIGHT 175 +#define GALLERY_ITEM_HGAP 16 +#define ITEMS_IN_ROW 3 +#define LAYOUT_STACK_WIDTH 166 * ITEMS_IN_ROW//498 +#define GALLERY_WIDTH 163 * ITEMS_IN_ROW//485//290 + +void LLOutfitGallery::rebuildGallery() +{ + LLView::child_list_t child_list(*getChild("gallery_panel")->getChildList()); + BOOST_FOREACH(LLView* view, child_list) + { + LLLayoutStack* lstack = dynamic_cast(view); + if (lstack != NULL) + { + LLView::child_list_t panel_list(*lstack->getChildList()); + BOOST_FOREACH(LLView* panel, panel_list) + { + //LLLayoutPanel* lpanel = dynamic_cast(panel); + //if (!lpanel) + // continue; + LLView::child_list_t panel_children(*panel->getChildList()); + if (panel_children.size() > 0) + { + //Assume OutfitGalleryItem is the only one child of layout panel + LLView* view_item = panel_children.back(); + LLOutfitGalleryItem* gallery_item = dynamic_cast(view_item); + if (gallery_item != NULL) + panel->removeChild(gallery_item); + } + lstack->removeChild(panel); + //delete panel; + } + getChild("gallery_panel")->removeChild(lstack); + delete lstack; + } + else + { + getChild("gallery_panel")->removeChild(view); + } + } + uuid_vec_t cats; + getCurrentCategories(cats); + int n = cats.size(); + int row_count = (n % ITEMS_IN_ROW) == 0 ? n / ITEMS_IN_ROW : n / ITEMS_IN_ROW + 1; + getChild("gallery_panel")->reshape( + GALLERY_WIDTH, row_count * (LAYOUT_STACK_HEIGHT + GALLERY_VERTICAL_GAP)); + int vgap = 0; + uuid_vec_t::reverse_iterator rit = cats.rbegin(); + for (int i = row_count - 1; i >= 0; i--) + { + LLLayoutStack* stack = buildLayoutStak(0, (row_count - 1 - i) * LAYOUT_STACK_HEIGHT + vgap); + getChild("gallery_panel")->addChild(stack); + int items_in_cur_row = (n % ITEMS_IN_ROW) == 0 ? ITEMS_IN_ROW : (i == row_count - 1 ? n % ITEMS_IN_ROW : ITEMS_IN_ROW); + int hgap = 0; + for (int j = 0; j < items_in_cur_row && rit != cats.rend(); j++) + { + LLLayoutPanel* lpanel = buildLayoutPanel(j * GALLERY_ITEM_WIDTH + hgap); + LLOutfitGalleryItem* item = mOutfitMap[*rit]; + lpanel->addChild(item); + stack->addChild(lpanel); + rit++; + hgap += GALLERY_HORIZONTAL_GAP; + } + vgap += GALLERY_VERTICAL_GAP; + } +} + +LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name) +{ + LLOutfitGalleryItem::Params giparams; + LLOutfitGalleryItem* gitem = LLUICtrlFactory::create(giparams); + LLRect girect = LLRect(0, GALLERY_ITEM_HEIGHT - GALLERY_ITEM_HEIGHT, + GALLERY_ITEM_WIDTH, 0); + //gitem->setRect(girect); + gitem->reshape(GALLERY_ITEM_WIDTH, GALLERY_ITEM_HEIGHT); + gitem->setVisible(true); + gitem->setFollowsLeft(); + gitem->setFollowsTop(); + gitem->setOutfitName(name); + return gitem; +} + +LLLayoutPanel* LLOutfitGallery::buildLayoutPanel(int left) +{ + LLLayoutPanel::Params lpparams; + int top = 0; + LLLayoutPanel* lpanel = LLUICtrlFactory::create(lpparams); + LLRect rect = LLRect(left, top + GALLERY_ITEM_HEIGHT, left + GALLERY_ITEM_WIDTH + GALLERY_ITEM_HGAP, top); + lpanel->setRect(rect); + lpanel->reshape(GALLERY_ITEM_WIDTH + GALLERY_ITEM_HGAP, GALLERY_ITEM_HEIGHT); + lpanel->setVisible(true); + lpanel->setFollowsLeft(); + lpanel->setFollowsTop(); + return lpanel; +} + +LLLayoutStack* LLOutfitGallery::buildLayoutStak(int left, int top) +{ + LLLayoutStack::Params sparams; + LLLayoutStack* stack = LLUICtrlFactory::create(sparams); + LLRect rect = LLRect(left, top + LAYOUT_STACK_HEIGHT, left + LAYOUT_STACK_WIDTH, top); + stack->setRect(rect); + stack->reshape(LAYOUT_STACK_WIDTH, LAYOUT_STACK_HEIGHT); + stack->setVisible(true); + stack->setFollowsLeft(); + stack->setFollowsTop(); + return stack; +} + + +LLOutfitGallery::~LLOutfitGallery() +{ + if (gInventory.containsObserver(mTexturesObserver)) + { + gInventory.removeObserver(mTexturesObserver); + } + delete mTexturesObserver; +} + +void LLOutfitGallery::setFilterSubString(const std::string& string) +{ + //TODO: Implement filtering + + sFilterSubString = string; +} + +void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id) +{ + if (mOutfitMap[base_id]) + { + mOutfitMap[base_id]->setOutfitWorn(true); + } + if (mOutfitMap[prev_id]) + { + mOutfitMap[prev_id]->setOutfitWorn(false); + } +} + +void LLOutfitGallery::onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid) +{ +} + +void LLOutfitGallery::getCurrentCategories(uuid_vec_t& vcur) +{ + for (outfit_map_t::const_iterator iter = mOutfitMap.begin(); + iter != mOutfitMap.end(); + iter++) + { + if ((*iter).second != NULL) + { + vcur.push_back((*iter).first); + } + } +} + +void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) +{ + LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); + if (!cat) return; + + std::string name = cat->getName(); + LLOutfitGalleryItem* item = buildGalleryItem(name); + mOutfitMap.insert(LLOutfitGallery::outfit_map_value_t(cat_id, item)); + item->setRightMouseDownCallback(boost::bind(&LLOutfitListBase::outfitRightClickCallBack, this, + _1, _2, _3, cat_id)); + LLWearableItemsList* list = NULL; + item->setFocusReceivedCallback(boost::bind(&LLOutfitListBase::ñhangeOutfitSelection, this, list, cat_id)); + +} + +void LLOutfitGallery::updateRemovedCategory(LLUUID cat_id) +{ + outfit_map_t::iterator outfits_iter = mOutfitMap.find(cat_id); + if (outfits_iter != mOutfitMap.end()) + { + //const LLUUID& outfit_id = outfits_iter->first; + LLOutfitGalleryItem* item = outfits_iter->second; + + // An outfit is removed from the list. Do the following: + // 2. Remove the outfit from selection. + //deselectOutfit(outfit_id); + + // 3. Remove category UUID to accordion tab mapping. + mOutfitMap.erase(outfits_iter); + + // 4. Remove outfit from gallery. + rebuildGallery(); + + // kill removed item + if (item != NULL) + { + item->die(); + } + } + +} + +void LLOutfitGallery::updateChangedCategoryName(LLViewerInventoryCategory *cat, std::string name) +{ + outfit_map_t::iterator outfit_iter = mOutfitMap.find(cat->getUUID()); + if (outfit_iter != mOutfitMap.end()) + { + // Update name of outfit in gallery + LLOutfitGalleryItem* item = outfit_iter->second; + if (item) + { + item->setOutfitName(name); + } + } +} + +void LLOutfitGallery::onOutfitRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id) +{ + if (mOutfitMenu && cat_id.notNull()) + { + uuid_vec_t selected_uuids; + selected_uuids.push_back(cat_id); + mOutfitMenu->show(ctrl, selected_uuids, x, y); + } +} + +void LLOutfitGallery::onChangeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id) +{ + if (mSelectedOutfitUUID == category_id) + return; + if (mOutfitMap[mSelectedOutfitUUID]) + { + mOutfitMap[mSelectedOutfitUUID]->setSelected(FALSE); + } + if (mOutfitMap[category_id]) + { + mOutfitMap[category_id]->setSelected(TRUE); + } +} + +bool LLOutfitGallery::hasItemSelected() +{ + return false; +} + +bool LLOutfitGallery::canWearSelected() +{ + return false; +} + +LLOutfitListGearMenuBase* LLOutfitGallery::createGearMenu() +{ + return new LLOutfitGalleryGearMenu(this); +} + +static LLDefaultChildRegistry::Register r("outfit_gallery_item"); + +LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p) + : LLPanel(p), + mTexturep(NULL) +{ + buildFromFile("panel_outfit_gallery_item.xml"); +} + +LLOutfitGalleryItem::~LLOutfitGalleryItem() +{ + +} + +BOOL LLOutfitGalleryItem::postBuild() +{ + setDefaultImage(); + + mOutfitNameText = getChild("outfit_name"); + mOutfitWornText = getChild("outfit_worn_text"); + setOutfitWorn(false); + return TRUE; +} + +void LLOutfitGalleryItem::draw() +{ + LLPanel::draw(); + + // In case texture is not set, don't draw it over default image + if (!mTexturep) + { + return; + } + + // Border + LLRect border = getChildView("preview_outfit")->getRect(); + //gl_rect_2d(border, LLColor4::black, FALSE); + + + // Interior + LLRect interior = border; + //interior.stretch(-1); + + // If the floater is focused, don't apply its alpha to the texture (STORM-677). + const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); + if (mTexturep) + { + if (mTexturep->getComponents() == 4) + { + gl_rect_2d_checkerboard(interior, alpha); + } + + gl_draw_scaled_image(interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha); + + // Pump the priority + mTexturep->addTextureStats((F32)(interior.getWidth() * interior.getHeight())); + } +} + +void LLOutfitGalleryItem::setOutfitName(std::string name) +{ + mOutfitNameText->setText(name); +} + +void LLOutfitGalleryItem::setOutfitWorn(bool value) +{ + //LLStringUtil::format_map_t string_args; + //std::string worn_text = getString("worn_text", string_args); + + if (value) + { + mOutfitWornText->setValue("(worn)"); + } + else + { + mOutfitWornText->setValue(""); + } +} + +void LLOutfitGalleryItem::setSelected(bool value) +{ + if (value) + { + mOutfitWornText->setValue("(selected)"); + } + else + { + mOutfitWornText->setValue(""); + } +} + +BOOL LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) +{ + setFocus(TRUE); + return LLUICtrl::handleMouseDown(x, y, mask); +} + +void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) +{ + mTexturep = LLViewerTextureManager::getFetchedTexture(image_asset_id); + mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); +} + +void LLOutfitGalleryItem::setDefaultImage() +{ + /* + LLUUID imageAssetID("e417f443-a199-bac1-86b0-0530e177fb54"); + mTexturep = LLViewerTextureManager::getFetchedTexture(imageAssetID); + mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); + */ + mTexturep = NULL; +} + +LLOutfitGalleryGearMenu::LLOutfitGalleryGearMenu(LLOutfitListBase* olist) + : LLOutfitListGearMenuBase(olist) +{ +} + +void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() +{ + if (!mMenu) return; + mMenu->setItemVisible("expand", FALSE); + mMenu->setItemVisible("collapse", FALSE); + mMenu->setItemVisible("upload_foto", TRUE); + mMenu->setItemVisible("load_assets", TRUE); + LLOutfitListGearMenuBase::onUpdateItemsVisibility(); +} + +void LLOutfitGalleryGearMenu::onUploadFoto() +{ + LLUUID selected_outfit_id = getSelectedOutfitID(); + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + if (gallery && selected_outfit_id.notNull()) + { + gallery->uploadPhoto(selected_outfit_id); + } + if (selected_outfit_id.notNull()) + { + + } +} + +void LLOutfitGalleryGearMenu::onLoadAssets() +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + if (gallery != NULL) + { + gallery->loadPhotos(); + } +} + +void LLOutfitGallery::loadPhotos() +{ + //Iterate over inventory + LLUUID textures = gInventory.findCategoryUUIDForType(LLFolderType::EType::FT_TEXTURE); + LLViewerInventoryCategory* category = gInventory.getCategory(textures); + if (!category) + return; + + if (mTexturesObserver == NULL) + { + mTexturesObserver = new LLInventoryCategoriesObserver(); + gInventory.addObserver(mTexturesObserver); + } + + // Start observing changes in "My Outfits" category. + mTexturesObserver->addCategory(textures, + boost::bind(&LLOutfitGallery::refreshTextures, this, textures)); + + category->fetch(); + refreshTextures(textures); +} + +void LLOutfitGallery::refreshTextures(const LLUUID& category_id) +{ + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + + // Collect all sub-categories of a given category. + LLIsType is_texture(LLAssetType::AT_TEXTURE); + gInventory.collectDescendentsIf( + category_id, + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + is_texture); + + //Find textures which contain outfit UUID string in description + LLInventoryModel::item_array_t uploaded_item_array; + BOOST_FOREACH(LLViewerInventoryItem* item, item_array) + { + std::string desc = item->getDescription(); + + LLUUID outfit_id(desc); + + //Check whether description contains correct UUID of outfit + if (outfit_id.isNull()) + continue; + + outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); + if (outfit_it != mOutfitMap.end() && !outfit_it->first.isNull()) + { + uploaded_item_array.push_back(item); + } + } + + uuid_vec_t vadded; + uuid_vec_t vremoved; + + // Create added and removed items vectors. + computeDifferenceOfTextures(uploaded_item_array, vadded, vremoved); + + BOOST_FOREACH(LLUUID item_id, vadded) + { + LLViewerInventoryItem* added_item = gInventory.getItem(item_id); + LLUUID asset_id = added_item->getAssetUUID(); + std::string desc = added_item->getDescription(); + LLUUID outfit_id(desc); + mOutfitMap[outfit_id]->setImageAssetId(asset_id); + mTextureMap[outfit_id] = added_item; + } + + BOOST_FOREACH(LLUUID item_id, vremoved) + { + LLViewerInventoryItem* rm_item = gInventory.getItem(item_id); + std::string desc = rm_item->getDescription(); + LLUUID outfit_id(desc); + mOutfitMap[outfit_id]->setDefaultImage(); + mTextureMap.erase(outfit_id); + } + + /* + LLInventoryModel::item_array_t::const_iterator it = item_array.begin(); + for ( ; it != item_array.end(); it++) + { + LLViewerInventoryItem* item = (*it); + LLUUID asset_id = item->getAssetUUID(); + + std::string desc = item->getDescription(); + + LLUUID outfit_id(desc); + + //Check whether description contains correct UUID of outfit + if (outfit_id.isNull()) + continue; + + outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); + if (outfit_it != mOutfitMap.end() && !outfit_it->first.isNull()) + { + outfit_it->second->setImageAssetId(asset_id); + mTextureMap[outfit_id] = item; + } + + + //LLUUID* item_idp = new LLUUID(); + + //gOutfitGallery = this; + //const BOOL high_priority = TRUE; + //gAssetStorage->getAssetData(asset_id, + // LLAssetType::AT_TEXTURE, + // onLoadComplete, + // (void**)item_idp, + // high_priority); + // + ////mAssetStatus = PREVIEW_ASSET_LOADING; + + } + */ +} + +void LLOutfitGallery::onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status) +{ + LL_WARNS() << "asset_uuid: " << asset_uuid.asString() << LL_ENDL; + + LLUUID* outfit_id = (LLUUID*)user_data; + if (!user_data) + return; + LL_WARNS() << "outfit_id: " << outfit_id->asString() << LL_ENDL; + + outfit_map_t::iterator it = gOutfitGallery->mOutfitMap.find(*outfit_id); + if (it != gOutfitGallery->mOutfitMap.end() && !it->first.isNull()) + { + } +} + +void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) +{ + outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); + if (outfit_it == mOutfitMap.end() || outfit_it->first.isNull()) + { + return; + } + + bool add_successful = false; + LLFilePicker& picker = LLFilePicker::instance(); + if (picker.getOpenFile(LLFilePicker::FFLOAD_IMAGE)) + { + std::string filename = picker.getFirstFile(); + LLLocalBitmap* unit = new LLLocalBitmap(filename); + if (unit->getValid()) + { + add_successful = true; + LLAssetStorage::LLStoreAssetCallback callback = NULL; + S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass). + void *nruserdata = NULL; + nruserdata = (void *)&outfit_id; + + LL_WARNS() << "selected_outfit_id: " << outfit_id.asString() << LL_ENDL; + + //LLViewerInventoryItem *outfit = gInventory.getItem(selected_outfit_id); + LLViewerInventoryCategory *outfit_cat = gInventory.getCategory(outfit_id); + if (!outfit_cat) return; + + checkRemovePhoto(outfit_id); + + LLStringUtil::format_map_t foto_string_args; + foto_string_args["OUTFIT_NAME"] = outfit_cat->getName(); + std::string display_name = getString("outfit_foto_string", foto_string_args); + + upload_new_resource(filename, // file + display_name, + outfit_id.asString(), + 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + LLFloaterPerms::getNextOwnerPerms("Uploads"), + LLFloaterPerms::getGroupPerms("Uploads"), + LLFloaterPerms::getEveryonePerms("Uploads"), + display_name, callback, expected_upload_cost, nruserdata); + } + } +} + +bool LLOutfitGallery::checkRemovePhoto(LLUUID outfit_id) +{ + //remove existing photo of outfit from inventory + texture_map_t::iterator texture_it = mTextureMap.find(outfit_id); + if (texture_it != mTextureMap.end()) { + gInventory.removeItem(texture_it->second->getUUID()); + return true; + } + return false; +} + +void LLOutfitGallery::setUploadedPhoto(LLUUID outfit_id, LLUUID asset_id) +{ + +} + +void LLOutfitGallery::computeDifferenceOfTextures( + const LLInventoryModel::item_array_t& vtextures, + uuid_vec_t& vadded, + uuid_vec_t& vremoved) +{ + uuid_vec_t vnew; + // Creating a vector of newly collected sub-categories UUIDs. + for (LLInventoryModel::item_array_t::const_iterator iter = vtextures.begin(); + iter != vtextures.end(); + iter++) + { + vnew.push_back((*iter)->getUUID()); + } + + uuid_vec_t vcur; + // Creating a vector of currently uploaded texture UUIDs. + for (texture_map_t::const_iterator iter = mTextureMap.begin(); + iter != mTextureMap.end(); + iter++) + { + vcur.push_back((*iter).second->getUUID()); + } +// getCurrentCategories(vcur); + + LLCommonUtils::computeDifference(vnew, vcur, vadded, vremoved); + +} -- cgit v1.3 From 749bb57cd19d51090d64cd2261048b9a0654807b Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Fri, 18 Dec 2015 19:20:32 +0200 Subject: MAINT-5194 Visual Outfit Browser Visual selection of outfit implemented --- indra/newview/lloutfitgallery.cpp | 48 ++++++-------- indra/newview/lloutfitgallery.h | 3 + .../default/xui/en/panel_outfit_gallery_item.xml | 77 ++++++++++++++-------- 3 files changed, 72 insertions(+), 56 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 2d8085e128..ec86e608f2 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -327,7 +327,8 @@ static LLDefaultChildRegistry::Register r("outfit_gallery_i LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p) : LLPanel(p), - mTexturep(NULL) + mTexturep(NULL), + mSelected(false) { buildFromFile("panel_outfit_gallery_item.xml"); } @@ -343,6 +344,8 @@ BOOL LLOutfitGalleryItem::postBuild() mOutfitNameText = getChild("outfit_name"); mOutfitWornText = getChild("outfit_worn_text"); + mFotoBgPanel = getChild("foto_bg_panel"); + mTextBgPanel = getChild("text_bg_panel"); setOutfitWorn(false); return TRUE; } @@ -351,35 +354,32 @@ void LLOutfitGalleryItem::draw() { LLPanel::draw(); - // In case texture is not set, don't draw it over default image - if (!mTexturep) - { - return; - } - - // Border + + // Draw border + LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "FrogGreen" : "MouseGray", LLColor4::white); LLRect border = getChildView("preview_outfit")->getRect(); - //gl_rect_2d(border, LLColor4::black, FALSE); - - - // Interior - LLRect interior = border; - //interior.stretch(-1); + border.mRight = border.mRight + 1; + gl_rect_2d(border, border_color.get(), 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(); if (mTexturep) { - if (mTexturep->getComponents() == 4) - { - gl_rect_2d_checkerboard(interior, alpha); - } + //if (mTexturep->getComponents() == 4) + //{ + // gl_rect_2d_checkerboard(interior, alpha); + //} - gl_draw_scaled_image(interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha); + // Interior + LLRect interior = border; + interior.stretch(-1); + + gl_draw_scaled_image(interior.mLeft - 1, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha); // Pump the priority mTexturep->addTextureStats((F32)(interior.getWidth() * interior.getHeight())); } + } void LLOutfitGalleryItem::setOutfitName(std::string name) @@ -404,14 +404,8 @@ void LLOutfitGalleryItem::setOutfitWorn(bool value) void LLOutfitGalleryItem::setSelected(bool value) { - if (value) - { - mOutfitWornText->setValue("(selected)"); - } - else - { - mOutfitWornText->setValue(""); - } + mSelected = value; + mTextBgPanel->setBackgroundVisible(value); } BOOL LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 93b9ba1e3f..61a2981a29 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -147,6 +147,9 @@ private: LLPointer mTexturep; LLTextBox* mOutfitNameText; LLTextBox* mOutfitWornText; + LLPanel* mTextBgPanel; + LLPanel* mFotoBgPanel; + bool mSelected; }; #endif // LL_LLOUTFITGALLERYCTRL_H diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml index acb72402cc..535960502e 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml @@ -1,49 +1,68 @@ - - Summer hipster, Pierce - - - (worn) - + + + Summer hipster, Pierce + + + (worn) + + -- cgit v1.3 From 5d576df19047ec45070f6571ebcada26e5c20756 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Tue, 22 Dec 2015 20:27:19 +0200 Subject: MAINT-5194 Visual Outfit Browser 1)Added visual hilighting of worn outfit 2)Fixed colors of selection borders to fit initial design --- indra/newview/lloutfitgallery.cpp | 22 +++++++++++----------- indra/newview/lloutfitgallery.h | 1 + indra/newview/skins/default/colors.xml | 9 +++++++++ .../default/xui/en/panel_outfit_gallery_item.xml | 5 ++++- 4 files changed, 25 insertions(+), 12 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index ec86e608f2..dc6db3307f 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -328,7 +328,8 @@ static LLDefaultChildRegistry::Register r("outfit_gallery_i LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p) : LLPanel(p), mTexturep(NULL), - mSelected(false) + mSelected(false), + mWorn(false) { buildFromFile("panel_outfit_gallery_item.xml"); } @@ -356,7 +357,7 @@ void LLOutfitGalleryItem::draw() // Draw border - LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "FrogGreen" : "MouseGray", LLColor4::white); + LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "OutfitGalleryItemSelected" : "OutfitGalleryItemUnselected", LLColor4::white); LLRect border = getChildView("preview_outfit")->getRect(); border.mRight = border.mRight + 1; gl_rect_2d(border, border_color.get(), FALSE); @@ -389,23 +390,22 @@ void LLOutfitGalleryItem::setOutfitName(std::string name) void LLOutfitGalleryItem::setOutfitWorn(bool value) { + mWorn = value; //LLStringUtil::format_map_t string_args; //std::string worn_text = getString("worn_text", string_args); - - if (value) - { - mOutfitWornText->setValue("(worn)"); - } - else - { - mOutfitWornText->setValue(""); - } + LLStringUtil::format_map_t worn_string_args; + std::string worn_string = getString("worn_string", worn_string_args); + LLUIColor text_color = LLUIColorTable::instance().getColor(mSelected ? "White" : (mWorn ? "OutfitGalleryItemWorn" : "White"), LLColor4::white); + mOutfitWornText->setReadOnlyColor(text_color.get()); + mOutfitNameText->setReadOnlyColor(text_color.get()); + mOutfitWornText->setValue(value ? worn_string : ""); } void LLOutfitGalleryItem::setSelected(bool value) { mSelected = value; mTextBgPanel->setBackgroundVisible(value); + setOutfitWorn(mWorn); } BOOL LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 61a2981a29..81a019f416 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -150,6 +150,7 @@ private: LLPanel* mTextBgPanel; LLPanel* mFotoBgPanel; bool mSelected; + bool mWorn; }; #endif // LL_LLOUTFITGALLERYCTRL_H diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index bdc884885f..1ee3d0ec0c 100755 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -945,4 +945,13 @@ + + + diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml index 535960502e..7c3e93fdae 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml @@ -15,6 +15,9 @@ left="0" top="0" > + + (worn) + Date: Wed, 27 Jan 2016 17:21:25 +0200 Subject: MAINT-5194 Visual Outfit Browser 1) Changed algorithm for building gallery, which fixed item cropping when switching between tabs in Appearance floater 2) Fixed gap between items in partially fille row --- indra/newview/lloutfitgallery.cpp | 232 +++++++++++++++------ indra/newview/lloutfitgallery.h | 45 ++-- .../skins/default/xui/en/panel_outfit_gallery.xml | 15 +- 3 files changed, 202 insertions(+), 90 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index dc6db3307f..92827a7b6f 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -51,22 +51,40 @@ static LLOutfitGallery* gOutfitGallery = NULL; LLOutfitGallery::LLOutfitGallery() : LLOutfitListBase(), - mTexturesObserver(NULL) + mTexturesObserver(NULL), + mScrollPanel(NULL), + mGalleryPanel(NULL), + galleryCreated(false), + mRowCount(0), + mItemsAddedCount(0) { -// mGearMenu = new LLOutfitGalleryGearMenu(this); } BOOL LLOutfitGallery::postBuild() { BOOL rv = LLOutfitListBase::postBuild(); + mScrollPanel = getChild("gallery_scroll_panel"); + mGalleryPanel = getChild("gallery_panel"); return rv; } void LLOutfitGallery::onOpen(const LLSD& info) { LLOutfitListBase::onOpen(info); - rebuildGallery(); - loadPhotos(); + if (!galleryCreated) + { + loadPhotos(); + uuid_vec_t cats; + getCurrentCategories(cats); + int n = cats.size(); + buildGalleryPanel(n); + mScrollPanel->addChild(mGalleryPanel); + for (int i = 0; i < n; i++) + { + addToGallery(mOutfitMap[cats[i]]); + } + galleryCreated = true; + } } #define LAYOUT_STACK_HEIGHT 180 @@ -79,67 +97,126 @@ void LLOutfitGallery::onOpen(const LLSD& info) #define LAYOUT_STACK_WIDTH 166 * ITEMS_IN_ROW//498 #define GALLERY_WIDTH 163 * ITEMS_IN_ROW//485//290 -void LLOutfitGallery::rebuildGallery() +LLPanel* LLOutfitGallery::addLastRow() { - LLView::child_list_t child_list(*getChild("gallery_panel")->getChildList()); - BOOST_FOREACH(LLView* view, child_list) + mRowCount++; + int row = 0; + int vgap = GALLERY_VERTICAL_GAP * row; + LLPanel* result = buildLayoutStak(0, row * LAYOUT_STACK_HEIGHT + vgap); + mGalleryPanel->addChild(result); + return result; +} + +void LLOutfitGallery::moveRowUp(int row) +{ + moveRow(row, mRowCount - 1 - row + 1); +} + +void LLOutfitGallery::moveRowDown(int row) +{ + moveRow(row, mRowCount - 1 - row - 1); +} + +void LLOutfitGallery::moveRow(int row, int pos) +{ + int vgap = GALLERY_VERTICAL_GAP * pos; + moveLayoutStak(mStacks[row], 0, pos * LAYOUT_STACK_HEIGHT + vgap); +} + +void LLOutfitGallery::removeLastRow() +{ + mRowCount--; + mGalleryPanel->removeChild(mLastRowStack); + mStacks.pop_back(); + mLastRowStack = mStacks.back(); +} + +LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item, int pos, int hgap) +{ + LLPanel* lpanel = buildLayoutPanel(pos * GALLERY_ITEM_WIDTH + hgap); + lpanel->addChild(item); + row_stack->addChild(lpanel); + mPanels.push_back(lpanel); + return lpanel; +} + +void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item) +{ + mItemsAddedCount++; + mItemIndexMap[item] = mItemsAddedCount - 1; + int n = mItemsAddedCount; + int row_count = (n % ITEMS_IN_ROW) == 0 ? n / ITEMS_IN_ROW : n / ITEMS_IN_ROW + 1; + int n_prev = n - 1; + int row_count_prev = (n_prev % ITEMS_IN_ROW) == 0 ? n_prev / ITEMS_IN_ROW : n_prev / ITEMS_IN_ROW + 1; + + bool add_row = row_count != row_count_prev; + int pos = 0; + if (add_row) { - LLLayoutStack* lstack = dynamic_cast(view); - if (lstack != NULL) + for (int i = 0; i < row_count_prev; i++) { - LLView::child_list_t panel_list(*lstack->getChildList()); - BOOST_FOREACH(LLView* panel, panel_list) - { - //LLLayoutPanel* lpanel = dynamic_cast(panel); - //if (!lpanel) - // continue; - LLView::child_list_t panel_children(*panel->getChildList()); - if (panel_children.size() > 0) - { - //Assume OutfitGalleryItem is the only one child of layout panel - LLView* view_item = panel_children.back(); - LLOutfitGalleryItem* gallery_item = dynamic_cast(view_item); - if (gallery_item != NULL) - panel->removeChild(gallery_item); - } - lstack->removeChild(panel); - //delete panel; - } - getChild("gallery_panel")->removeChild(lstack); - delete lstack; - } - else - { - getChild("gallery_panel")->removeChild(view); + moveRowUp(i); } + mLastRowStack = addLastRow(); + mStacks.push_back(mLastRowStack); } - uuid_vec_t cats; - getCurrentCategories(cats); - int n = cats.size(); + pos = (n - 1) % ITEMS_IN_ROW; + mItems.push_back(item); + addToRow(mLastRowStack, item, pos, GALLERY_HORIZONTAL_GAP * pos); + reshapeGalleryPanel(row_count); +} + + +void LLOutfitGallery::removeFromGalleryLast(LLOutfitGalleryItem* item) +{ + int n_prev = mItemsAddedCount; + int n = mItemsAddedCount - 1; int row_count = (n % ITEMS_IN_ROW) == 0 ? n / ITEMS_IN_ROW : n / ITEMS_IN_ROW + 1; - getChild("gallery_panel")->reshape( - GALLERY_WIDTH, row_count * (LAYOUT_STACK_HEIGHT + GALLERY_VERTICAL_GAP)); - int vgap = 0; - uuid_vec_t::reverse_iterator rit = cats.rbegin(); - for (int i = row_count - 1; i >= 0; i--) + int row_count_prev = (n_prev % ITEMS_IN_ROW) == 0 ? n_prev / ITEMS_IN_ROW : n_prev / ITEMS_IN_ROW + 1; + mItemsAddedCount--; + + bool remove_row = row_count != row_count_prev; + //int pos = (n_prev - 1) % ITEMS_IN_ROW; + removeFromLastRow(mItems[mItemsAddedCount]); + mItems.pop_back(); + if (remove_row) { - LLLayoutStack* stack = buildLayoutStak(0, (row_count - 1 - i) * LAYOUT_STACK_HEIGHT + vgap); - getChild("gallery_panel")->addChild(stack); - int items_in_cur_row = (n % ITEMS_IN_ROW) == 0 ? ITEMS_IN_ROW : (i == row_count - 1 ? n % ITEMS_IN_ROW : ITEMS_IN_ROW); - int hgap = 0; - for (int j = 0; j < items_in_cur_row && rit != cats.rend(); j++) + for (int i = 0; i < row_count_prev - 1; i++) { - LLLayoutPanel* lpanel = buildLayoutPanel(j * GALLERY_ITEM_WIDTH + hgap); - LLOutfitGalleryItem* item = mOutfitMap[*rit]; - lpanel->addChild(item); - stack->addChild(lpanel); - rit++; - hgap += GALLERY_HORIZONTAL_GAP; + moveRowDown(i); } - vgap += GALLERY_VERTICAL_GAP; + removeLastRow(); + } + reshapeGalleryPanel(row_count); +} + + +void LLOutfitGallery::removeFromGalleryMiddle(LLOutfitGalleryItem* item) +{ + int n = mItemIndexMap[item]; + mItemIndexMap.erase(item); + std::vector saved; + for (int i = mItemsAddedCount - 1; i > n; i--) + { + saved.push_back(mItems[i]); + removeFromGalleryLast(mItems[i]); + } + removeFromGalleryLast(mItems[n]); + int saved_count = saved.size(); + for (int i = 0; i < saved_count; i++) + { + addToGallery(saved.back()); + saved.pop_back(); } } +void LLOutfitGallery::removeFromLastRow(LLOutfitGalleryItem* item) +{ + mPanels.back()->removeChild(item); + mLastRowStack->removeChild(mPanels.back()); + mPanels.pop_back(); +} + LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name) { LLOutfitGalleryItem::Params giparams; @@ -155,11 +232,31 @@ LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name) return gitem; } -LLLayoutPanel* LLOutfitGallery::buildLayoutPanel(int left) +void LLOutfitGallery::buildGalleryPanel(int row_count) +{ + LLPanel::Params params; + mGalleryPanel = LLUICtrlFactory::create(params); + reshapeGalleryPanel(row_count); +} + +void LLOutfitGallery::reshapeGalleryPanel(int row_count) { - LLLayoutPanel::Params lpparams; + int bottom = 0; + int left = 0; + int height = row_count * (LAYOUT_STACK_HEIGHT + GALLERY_VERTICAL_GAP); + LLRect rect = LLRect(left, bottom + height, left + GALLERY_WIDTH, bottom); + mGalleryPanel->setRect(rect); + mGalleryPanel->reshape(GALLERY_WIDTH, height); + mGalleryPanel->setVisible(true); + mGalleryPanel->setFollowsLeft(); + mGalleryPanel->setFollowsTop(); +} + +LLPanel* LLOutfitGallery::buildLayoutPanel(int left) +{ + LLPanel::Params lpparams; int top = 0; - LLLayoutPanel* lpanel = LLUICtrlFactory::create(lpparams); + LLPanel* lpanel = LLUICtrlFactory::create(lpparams); LLRect rect = LLRect(left, top + GALLERY_ITEM_HEIGHT, left + GALLERY_ITEM_WIDTH + GALLERY_ITEM_HGAP, top); lpanel->setRect(rect); lpanel->reshape(GALLERY_ITEM_WIDTH + GALLERY_ITEM_HGAP, GALLERY_ITEM_HEIGHT); @@ -169,20 +266,24 @@ LLLayoutPanel* LLOutfitGallery::buildLayoutPanel(int left) return lpanel; } -LLLayoutStack* LLOutfitGallery::buildLayoutStak(int left, int top) +LLPanel* LLOutfitGallery::buildLayoutStak(int left, int bottom) +{ + LLPanel::Params sparams; + LLPanel* stack = LLUICtrlFactory::create(sparams); + moveLayoutStak(stack, left, bottom); + return stack; +} + +void LLOutfitGallery::moveLayoutStak(LLPanel* stack, int left, int bottom) { - LLLayoutStack::Params sparams; - LLLayoutStack* stack = LLUICtrlFactory::create(sparams); - LLRect rect = LLRect(left, top + LAYOUT_STACK_HEIGHT, left + LAYOUT_STACK_WIDTH, top); + LLRect rect = LLRect(left, bottom + LAYOUT_STACK_HEIGHT, left + LAYOUT_STACK_WIDTH, bottom); stack->setRect(rect); stack->reshape(LAYOUT_STACK_WIDTH, LAYOUT_STACK_HEIGHT); stack->setVisible(true); stack->setFollowsLeft(); stack->setFollowsTop(); - return stack; } - LLOutfitGallery::~LLOutfitGallery() { if (gInventory.containsObserver(mTexturesObserver)) @@ -240,7 +341,10 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) _1, _2, _3, cat_id)); LLWearableItemsList* list = NULL; item->setFocusReceivedCallback(boost::bind(&LLOutfitListBase::ñhangeOutfitSelection, this, list, cat_id)); - + if (galleryCreated) + { + addToGallery(item); + } } void LLOutfitGallery::updateRemovedCategory(LLUUID cat_id) @@ -259,7 +363,7 @@ void LLOutfitGallery::updateRemovedCategory(LLUUID cat_id) mOutfitMap.erase(outfits_iter); // 4. Remove outfit from gallery. - rebuildGallery(); + removeFromGalleryMiddle(item); // kill removed item if (item != NULL) diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 81a019f416..01d56d917f 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -78,11 +78,20 @@ protected: /*virtual*/ LLOutfitListGearMenuBase* createGearMenu(); private: - void rebuildGallery(); void loadPhotos(); void uploadPhoto(LLUUID outfit_id); bool checkRemovePhoto(LLUUID outfit_id); void setUploadedPhoto(LLUUID outfit_id, LLUUID asset_id); + void addToGallery(LLOutfitGalleryItem* item); + void removeFromGalleryLast(LLOutfitGalleryItem* item); + void removeFromGalleryMiddle(LLOutfitGalleryItem* item); + LLPanel* addLastRow(); + void removeLastRow(); + void moveRowUp(int row); + void moveRowDown(int row); + void moveRow(int row, int pos); + LLPanel* addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item, int pos, int hgap); + void removeFromLastRow(LLOutfitGalleryItem* item); static void onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, @@ -90,20 +99,32 @@ private: void* user_data, S32 status, LLExtStat ext_status); LLOutfitGalleryItem* buildGalleryItem(std::string name); - LLLayoutPanel* buildLayoutPanel(int left); - LLLayoutStack* buildLayoutStak(int left, int top); - + void buildGalleryPanel(int row_count); + void reshapeGalleryPanel(int row_count); + LLPanel* buildLayoutPanel(int left); + LLPanel* buildLayoutStak(int left, int bottom); + void moveLayoutStak(LLPanel* stack, int left, int bottom); LLView* mView; - std::vector mLayouts; - std::vector mPanels; + std::vector mStacks; + std::vector mPanels; std::vector mItems; + LLScrollContainer* mScrollPanel; + LLPanel* mGalleryPanel; + LLPanel* mLastRowStack; + bool galleryCreated; + int mRowCount; + int mItemsAddedCount; + + typedef std::map outfit_map_t; + typedef outfit_map_t::value_type outfit_map_value_t; + outfit_map_t mOutfitMap; + typedef std::map texture_map_t; + typedef texture_map_t::value_type texture_map_value_t; + texture_map_t mTextureMap; + typedef std::map item_num_map_t; + typedef item_num_map_t::value_type item_numb_map_value_t; + item_num_map_t mItemIndexMap; - typedef std::map outfit_map_t; - typedef outfit_map_t::value_type outfit_map_value_t; - outfit_map_t mOutfitMap; - typedef std::map texture_map_t; - typedef texture_map_t::value_type texture_map_value_t; - texture_map_t mTextureMap; LLInventoryCategoriesObserver* mTexturesObserver; diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml index 6146514f98..2a06b35942 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml @@ -26,19 +26,6 @@ name="gallery_scroll_panel" opaque="false" top_pad="0"> - - + Date: Thu, 4 Feb 2016 18:56:04 +0200 Subject: MAINT-5194 Visual Outfit Browser Fixed Mac specific build issues --- indra/newview/lloutfitgallery.cpp | 5 +---- indra/newview/lloutfitgallery.h | 1 - indra/newview/lloutfitslist.cpp | 14 ++++++++++---- indra/newview/lloutfitslist.h | 6 ++++-- 4 files changed, 15 insertions(+), 11 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 92827a7b6f..e50c35f29f 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -221,9 +221,6 @@ LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name) { LLOutfitGalleryItem::Params giparams; LLOutfitGalleryItem* gitem = LLUICtrlFactory::create(giparams); - LLRect girect = LLRect(0, GALLERY_ITEM_HEIGHT - GALLERY_ITEM_HEIGHT, - GALLERY_ITEM_WIDTH, 0); - //gitem->setRect(girect); gitem->reshape(GALLERY_ITEM_WIDTH, GALLERY_ITEM_HEIGHT); gitem->setVisible(true); gitem->setFollowsLeft(); @@ -340,7 +337,7 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) item->setRightMouseDownCallback(boost::bind(&LLOutfitListBase::outfitRightClickCallBack, this, _1, _2, _3, cat_id)); LLWearableItemsList* list = NULL; - item->setFocusReceivedCallback(boost::bind(&LLOutfitListBase::ñhangeOutfitSelection, this, list, cat_id)); + item->setFocusReceivedCallback(boost::bind(&LLOutfitListBase::ChangeOutfitSelection, this, list, cat_id)); if (galleryCreated) { addToGallery(item); diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 01d56d917f..323e2580f6 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -104,7 +104,6 @@ private: LLPanel* buildLayoutPanel(int left); LLPanel* buildLayoutStak(int left, int bottom); void moveLayoutStak(LLPanel* stack, int left, int bottom); - LLView* mView; std::vector mStacks; std::vector mPanels; std::vector mItems; diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 736da5d411..2b99391dc8 100755 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -227,7 +227,7 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_id) _1, _2, _3, cat_id)); // Setting tab focus callback to monitor currently selected outfit. - tab->setFocusReceivedCallback(boost::bind(&LLOutfitListBase::ñhangeOutfitSelection, this, list, cat_id)); + tab->setFocusReceivedCallback(boost::bind(&LLOutfitListBase::ChangeOutfitSelection, this, list, cat_id)); // Setting callback to reset items selection inside outfit on accordion collapsing and expanding (EXT-7875) tab->setDropDownStateChangedCallback(boost::bind(&LLOutfitsList::resetItemSelection, this, list, cat_id)); @@ -469,7 +469,7 @@ void LLOutfitsList::onListSelectionChange(LLUICtrl* ctrl) LLViewerInventoryItem *item = gInventory.getItem(list->getSelectedUUID()); if (!item) return; - ñhangeOutfitSelection(list, item->getParentUUID()); + ChangeOutfitSelection(list, item->getParentUUID()); } void LLOutfitListBase::performAction(std::string action) @@ -508,7 +508,7 @@ void LLOutfitsList::onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid) if (!list) continue; tab->setFocus(TRUE); - ñhangeOutfitSelection(list, outfit_uuid); + ChangeOutfitSelection(list, outfit_uuid); tab->setDisplayChildren(true); } @@ -1198,7 +1198,7 @@ void LLOutfitListBase::outfitRightClickCallBack(LLUICtrl* ctrl, S32 x, S32 y, co onOutfitRightClick(ctrl, x, y, cat_id); } -void LLOutfitListBase::ñhangeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id) +void LLOutfitListBase::ChangeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id) { onChangeOutfitSelection(list, category_id); mSelectedOutfitUUID = category_id; @@ -1335,6 +1335,9 @@ LLOutfitListGearMenuBase::LLOutfitListGearMenuBase(LLOutfitListBase* olist) llassert(mMenu); } +LLOutfitListGearMenuBase::~LLOutfitListGearMenuBase() +{} + void LLOutfitListGearMenuBase::updateItemsVisibility() { onUpdateItemsVisibility(); @@ -1472,6 +1475,9 @@ LLOutfitListGearMenu::LLOutfitListGearMenu(LLOutfitListBase* olist) : LLOutfitListGearMenuBase(olist) {} +LLOutfitListGearMenu::~LLOutfitListGearMenu() +{} + void LLOutfitListGearMenu::onUpdateItemsVisibility() { if (!mMenu) return; diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index f4b02991e5..9495866d73 100755 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -76,7 +76,7 @@ public: void computeDifference(const LLInventoryModel::cat_array_t& vcats, uuid_vec_t& vadded, uuid_vec_t& vremoved); // highlights currently worn outfit in list and unhighlights previously worn void highlightBaseOutfit(); - void ñhangeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id); + void ChangeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id); virtual void getCurrentCategories(uuid_vec_t& vcur) = 0; @@ -153,7 +153,8 @@ class LLOutfitListGearMenuBase { public: LLOutfitListGearMenuBase(LLOutfitListBase* olist); - + virtual ~LLOutfitListGearMenuBase(); + void updateItemsVisibility(); LLToggleableMenu* getMenu(); @@ -183,6 +184,7 @@ class LLOutfitListGearMenu : public LLOutfitListGearMenuBase { public: LLOutfitListGearMenu(LLOutfitListBase* olist); + virtual ~LLOutfitListGearMenu(); protected: /*virtual*/ void onUpdateItemsVisibility(); -- cgit v1.3 From 12608244387c3247adb759f221da99eb823f53c4 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Fri, 5 Feb 2016 18:11:36 +0200 Subject: MAINT-5194 Visual Outfit Browser Corrected typo "foto" to "photo" --- indra/newview/lloutfitgallery.cpp | 8 ++++---- indra/newview/lloutfitslist.cpp | 4 ++-- indra/newview/skins/default/xui/en/menu_outfit_gear.xml | 6 +++--- indra/newview/skins/default/xui/en/panel_outfit_gallery.xml | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 92827a7b6f..c1017d4cc0 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -544,7 +544,7 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() if (!mMenu) return; mMenu->setItemVisible("expand", FALSE); mMenu->setItemVisible("collapse", FALSE); - mMenu->setItemVisible("upload_foto", TRUE); + mMenu->setItemVisible("upload_photo", TRUE); mMenu->setItemVisible("load_assets", TRUE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } @@ -736,9 +736,9 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) checkRemovePhoto(outfit_id); - LLStringUtil::format_map_t foto_string_args; - foto_string_args["OUTFIT_NAME"] = outfit_cat->getName(); - std::string display_name = getString("outfit_foto_string", foto_string_args); + LLStringUtil::format_map_t photo_string_args; + photo_string_args["OUTFIT_NAME"] = outfit_cat->getName(); + std::string display_name = getString("outfit_photo_string", photo_string_args); upload_new_resource(filename, // file display_name, diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 736da5d411..00fa439e8f 100755 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -1324,7 +1324,7 @@ LLOutfitListGearMenuBase::LLOutfitListGearMenuBase(LLOutfitListBase* olist) registrar.add("Gear.WearAdd", boost::bind(&LLOutfitListGearMenuBase::onAdd, this)); - registrar.add("Gear.UploadFoto", boost::bind(&LLOutfitListGearMenuBase::onUploadFoto, this)); + registrar.add("Gear.UploadPhoto", boost::bind(&LLOutfitListGearMenuBase::onUploadFoto, this)); registrar.add("Gear.LoadAssets", boost::bind(&LLOutfitListGearMenuBase::onLoadAssets, this)); enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenuBase::onEnable, this, _2)); @@ -1477,7 +1477,7 @@ void LLOutfitListGearMenu::onUpdateItemsVisibility() if (!mMenu) return; mMenu->setItemVisible("expand", TRUE); mMenu->setItemVisible("collapse", TRUE); - mMenu->setItemVisible("upload_foto", FALSE); + mMenu->setItemVisible("upload_photo", FALSE); mMenu->setItemVisible("load_assets", TRUE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } 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 c970efbc03..3132c4db8b 100755 --- a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml @@ -40,11 +40,11 @@ parameter="take_off" /> + name="upload_photo"> + function="Gear.UploadPhoto" /> - - Foto of "[OUTFIT_NAME]" outfit + + Photo of "[OUTFIT_NAME]" outfit Date: Thu, 18 Feb 2016 18:39:53 +0200 Subject: MAINT-5194 Visual Outfit Browser Changed to store uploaded photos as links in outfit folders --- indra/newview/lloutfitgallery.cpp | 191 ++++++++++++--------- indra/newview/lloutfitgallery.h | 16 +- .../skins/default/xui/en/panel_outfit_gallery.xml | 3 + 3 files changed, 128 insertions(+), 82 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index e5ab736a96..4ee2175286 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -52,11 +52,14 @@ static LLOutfitGallery* gOutfitGallery = NULL; LLOutfitGallery::LLOutfitGallery() : LLOutfitListBase(), mTexturesObserver(NULL), + mOutfitsObserver(NULL), mScrollPanel(NULL), mGalleryPanel(NULL), galleryCreated(false), mRowCount(0), - mItemsAddedCount(0) + mItemsAddedCount(0), + mPhotoLinkPending(NULL), + mOutfitLinkPending(NULL) { } @@ -342,6 +345,23 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) { addToGallery(item); } + + LLViewerInventoryCategory* outfit_category = gInventory.getCategory(cat_id); + if (!outfit_category) + return; + + if (mOutfitsObserver == NULL) + { + mOutfitsObserver = new LLInventoryCategoriesObserver(); + gInventory.addObserver(mOutfitsObserver); + } + + // Start observing changes in "My Outits" category. + mOutfitsObserver->addCategory(cat_id, + boost::bind(&LLOutfitGallery::refreshOutfit, this, cat_id)); + + outfit_category->fetch(); + refreshOutfit(cat_id); } void LLOutfitGallery::updateRemovedCategory(LLUUID cat_id) @@ -349,6 +369,9 @@ void LLOutfitGallery::updateRemovedCategory(LLUUID cat_id) outfit_map_t::iterator outfits_iter = mOutfitMap.find(cat_id); if (outfits_iter != mOutfitMap.end()) { + // 0. Remove category from observer. + mOutfitsObserver->removeCategory(cat_id); + //const LLUUID& outfit_id = outfits_iter->first; LLOutfitGalleryItem* item = outfits_iter->second; @@ -362,6 +385,8 @@ void LLOutfitGallery::updateRemovedCategory(LLUUID cat_id) // 4. Remove outfit from gallery. removeFromGalleryMiddle(item); + + // kill removed item if (item != NULL) { @@ -573,22 +598,55 @@ void LLOutfitGallery::loadPhotos() { //Iterate over inventory LLUUID textures = gInventory.findCategoryUUIDForType(LLFolderType::EType::FT_TEXTURE); - LLViewerInventoryCategory* category = gInventory.getCategory(textures); - if (!category) + LLViewerInventoryCategory* textures_category = gInventory.getCategory(textures); + if (!textures_category) return; - if (mTexturesObserver == NULL) { mTexturesObserver = new LLInventoryCategoriesObserver(); gInventory.addObserver(mTexturesObserver); } - // Start observing changes in "My Outfits" category. + // Start observing changes in "Textures" category. mTexturesObserver->addCategory(textures, boost::bind(&LLOutfitGallery::refreshTextures, this, textures)); + + textures_category->fetch(); +} - category->fetch(); - refreshTextures(textures); +void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) +{ + LLViewerInventoryCategory* category = gInventory.getCategory(category_id); + { + std::string outfit_name = category->getName(); + bool photo_loaded = false; + LL_WARNS() << "Outfit name:" << outfit_name << LL_ENDL; + LLInventoryModel::cat_array_t sub_cat_array; + LLInventoryModel::item_array_t outfit_item_array; + // Collect all sub-categories of a given category. + gInventory.collectDescendents( + category->getUUID(), + sub_cat_array, + outfit_item_array, + LLInventoryModel::EXCLUDE_TRASH); + BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) + { + LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); + if (linked_item->getActualType() == LLAssetType::AT_TEXTURE) + { + std::string texture_name = linked_item->getName(); + LL_WARNS() << "Texture name:" << texture_name << LL_ENDL; + LLUUID asset_id = linked_item->getAssetUUID(); + mOutfitMap[category_id]->setImageAssetId(asset_id); + photo_loaded = true; + break; + } + if (!photo_loaded) + { + mOutfitMap[category_id]->setDefaultImage(); + } + } + } } void LLOutfitGallery::refreshTextures(const LLUUID& category_id) @@ -607,85 +665,44 @@ void LLOutfitGallery::refreshTextures(const LLUUID& category_id) //Find textures which contain outfit UUID string in description LLInventoryModel::item_array_t uploaded_item_array; + LLViewerInventoryItem* photo_upload_item = NULL; BOOST_FOREACH(LLViewerInventoryItem* item, item_array) { std::string desc = item->getDescription(); + std::string name = item->getName(); - LLUUID outfit_id(desc); - - //Check whether description contains correct UUID of outfit - if (outfit_id.isNull()) - continue; - - outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); - if (outfit_it != mOutfitMap.end() && !outfit_it->first.isNull()) + if (name == getString("photo_upload_pending_string")) { - uploaded_item_array.push_back(item); + photo_upload_item = item; + break; } } - uuid_vec_t vadded; - uuid_vec_t vremoved; - - // Create added and removed items vectors. - computeDifferenceOfTextures(uploaded_item_array, vadded, vremoved); - - BOOST_FOREACH(LLUUID item_id, vadded) - { - LLViewerInventoryItem* added_item = gInventory.getItem(item_id); - LLUUID asset_id = added_item->getAssetUUID(); - std::string desc = added_item->getDescription(); - LLUUID outfit_id(desc); - mOutfitMap[outfit_id]->setImageAssetId(asset_id); - mTextureMap[outfit_id] = added_item; - } - - BOOST_FOREACH(LLUUID item_id, vremoved) + if (!mPhotoLinkPending.isNull() && photo_upload_item != NULL) { - LLViewerInventoryItem* rm_item = gInventory.getItem(item_id); - std::string desc = rm_item->getDescription(); - LLUUID outfit_id(desc); - mOutfitMap[outfit_id]->setDefaultImage(); - mTextureMap.erase(outfit_id); - } - - /* - LLInventoryModel::item_array_t::const_iterator it = item_array.begin(); - for ( ; it != item_array.end(); it++) - { - LLViewerInventoryItem* item = (*it); - LLUUID asset_id = item->getAssetUUID(); - - std::string desc = item->getDescription(); + LLUUID upload_pending_id = photo_upload_item->getUUID(); + LLInventoryObject* upload_object = gInventory.getObject(upload_pending_id); + if (!upload_object) + { + LL_WARNS() << "LLOutfitGallery::refreshTextures added_object is null!" << LL_ENDL; + } + else + { + LLViewerInventoryCategory *outfit_cat = gInventory.getCategory(mOutfitLinkPending); + linkPhotoToOutfit(upload_pending_id, mOutfitLinkPending); - LLUUID outfit_id(desc); + LLStringUtil::format_map_t photo_string_args; + photo_string_args["OUTFIT_NAME"] = outfit_cat->getName(); + std::string new_name = getString("outfit_photo_string", photo_string_args); - //Check whether description contains correct UUID of outfit - if (outfit_id.isNull()) - continue; + LLSD updates; + updates["name"] = new_name; + update_inventory_item(upload_pending_id, updates, NULL); - outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); - if (outfit_it != mOutfitMap.end() && !outfit_it->first.isNull()) - { - outfit_it->second->setImageAssetId(asset_id); - mTextureMap[outfit_id] = item; } - - - //LLUUID* item_idp = new LLUUID(); - - //gOutfitGallery = this; - //const BOOL high_priority = TRUE; - //gAssetStorage->getAssetData(asset_id, - // LLAssetType::AT_TEXTURE, - // onLoadComplete, - // (void**)item_idp, - // high_priority); - // - ////mAssetStatus = PREVIEW_ASSET_LOADING; - + mPhotoLinkPending.setNull(); + mOutfitLinkPending.setNull(); } - */ } void LLOutfitGallery::onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status) @@ -703,6 +720,11 @@ void LLOutfitGallery::onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, LLAss } } +void LLGalleryPhotoStoreCallback(const LLUUID &asset_id, void *user_data, S32 status, LLExtStat ext_status) +{ + LL_WARNS() << "Photo stored as asset. UUID:" << asset_id.asString() << LL_ENDL; +} + void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) { outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); @@ -720,7 +742,7 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) if (unit->getValid()) { add_successful = true; - LLAssetStorage::LLStoreAssetCallback callback = NULL; + //LLAssetStorage::LLStoreAssetCallback callback = &LLGalleryPhotoStoreCallback; S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass). void *nruserdata = NULL; nruserdata = (void *)&outfit_id; @@ -732,23 +754,30 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) if (!outfit_cat) return; checkRemovePhoto(outfit_id); + + std::string upload_pending_name = getString("photo_upload_pending_string"); - LLStringUtil::format_map_t photo_string_args; - photo_string_args["OUTFIT_NAME"] = outfit_cat->getName(); - std::string display_name = getString("outfit_photo_string", photo_string_args); - - upload_new_resource(filename, // file - display_name, + LLUUID photo_id = upload_new_resource(filename, // file + upload_pending_name, outfit_id.asString(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - display_name, callback, expected_upload_cost, nruserdata); + upload_pending_name, &LLGalleryPhotoStoreCallback, expected_upload_cost, nruserdata); + + mPhotoLinkPending = photo_id; + mOutfitLinkPending = outfit_id; } } } +void LLOutfitGallery::linkPhotoToOutfit(LLUUID photo_id, LLUUID outfit_id) +{ + LLPointer cb = new LLUpdateGalleryOnPhotoUpload(); + link_inventory_object(outfit_id, photo_id, cb); +} + bool LLOutfitGallery::checkRemovePhoto(LLUUID outfit_id) { //remove existing photo of outfit from inventory @@ -771,7 +800,7 @@ void LLOutfitGallery::computeDifferenceOfTextures( uuid_vec_t& vremoved) { uuid_vec_t vnew; - // Creating a vector of newly collected sub-categories UUIDs. + // Creating a vector of newly collected texture UUIDs. for (LLInventoryModel::item_array_t::const_iterator iter = vtextures.begin(); iter != vtextures.end(); iter++) diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 323e2580f6..47ab85f4e1 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -42,6 +42,16 @@ class LLOutfitGalleryItem; class LLOutfitListGearMenuBase; class LLOutfitGalleryGearMenu; +class LLUpdateGalleryOnPhotoUpload : public LLInventoryCallback +{ +public: + LLUpdateGalleryOnPhotoUpload(){} + virtual ~LLUpdateGalleryOnPhotoUpload(){} + /* virtual */ void fire(const LLUUID& inv_item){} +private: +}; + + class LLOutfitGallery : public LLOutfitListBase { public: @@ -65,6 +75,7 @@ public: /*virtual*/ bool getHasExpandableFolders() { return FALSE; } void refreshTextures(const LLUUID& category_id); + void refreshOutfit(const LLUUID& category_id); void computeDifferenceOfTextures(const LLInventoryModel::item_array_t& vtextures, uuid_vec_t& vadded, uuid_vec_t& vremoved); protected: @@ -80,6 +91,7 @@ protected: private: void loadPhotos(); void uploadPhoto(LLUUID outfit_id); + void linkPhotoToOutfit(LLUUID outfit_id, LLUUID photo_id); bool checkRemovePhoto(LLUUID outfit_id); void setUploadedPhoto(LLUUID outfit_id, LLUUID asset_id); void addToGallery(LLOutfitGalleryItem* item); @@ -110,6 +122,8 @@ private: LLScrollContainer* mScrollPanel; LLPanel* mGalleryPanel; LLPanel* mLastRowStack; + LLUUID mPhotoLinkPending; + LLUUID mOutfitLinkPending; bool galleryCreated; int mRowCount; int mItemsAddedCount; @@ -126,7 +140,7 @@ private: LLInventoryCategoriesObserver* mTexturesObserver; - + LLInventoryCategoriesObserver* mOutfitsObserver; }; //static LLOutfitGallery* gOutfitGallery; diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml index c06c6a86c3..682d2d0730 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml @@ -10,6 +10,9 @@ left="0" top="0" width="312"> + + Photo upload pending... + Photo of "[OUTFIT_NAME]" outfit -- cgit v1.3 From c2bbd1fedd28df3283f087d391f52971e8139327 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Fri, 19 Feb 2016 20:47:57 +0200 Subject: MAINT-5194 Visual Outfit Browser Added creating links to photos via DragnDrop --- indra/newview/llinventorybridge.cpp | 5 ++-- indra/newview/lloutfitgallery.cpp | 27 ++++------------------ indra/newview/lloutfitgallery.h | 1 - .../skins/default/xui/en/panel_outfit_gallery.xml | 3 --- 4 files changed, 7 insertions(+), 29 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 9782c792c9..6e51c08d9c 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4483,8 +4483,9 @@ static BOOL can_move_to_outfit(LLInventoryItem* inv_item, BOOL move_is_into_curr if ((inv_item->getInventoryType() != LLInventoryType::IT_WEARABLE) && (inv_item->getInventoryType() != LLInventoryType::IT_GESTURE) && (inv_item->getInventoryType() != LLInventoryType::IT_ATTACHMENT) && - (inv_item->getInventoryType() != LLInventoryType::IT_OBJECT)) - { + (inv_item->getInventoryType() != LLInventoryType::IT_OBJECT) && + (inv_item->getInventoryType() != LLInventoryType::IT_TEXTURE)) + { return FALSE; } diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 4ee2175286..51d8bea3ad 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -58,7 +58,6 @@ LLOutfitGallery::LLOutfitGallery() galleryCreated(false), mRowCount(0), mItemsAddedCount(0), - mPhotoLinkPending(NULL), mOutfitLinkPending(NULL) { } @@ -618,9 +617,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) { LLViewerInventoryCategory* category = gInventory.getCategory(category_id); { - std::string outfit_name = category->getName(); bool photo_loaded = false; - LL_WARNS() << "Outfit name:" << outfit_name << LL_ENDL; LLInventoryModel::cat_array_t sub_cat_array; LLInventoryModel::item_array_t outfit_item_array; // Collect all sub-categories of a given category. @@ -634,8 +631,6 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); if (linked_item->getActualType() == LLAssetType::AT_TEXTURE) { - std::string texture_name = linked_item->getName(); - LL_WARNS() << "Texture name:" << texture_name << LL_ENDL; LLUUID asset_id = linked_item->getAssetUUID(); mOutfitMap[category_id]->setImageAssetId(asset_id); photo_loaded = true; @@ -663,22 +658,19 @@ void LLOutfitGallery::refreshTextures(const LLUUID& category_id) LLInventoryModel::EXCLUDE_TRASH, is_texture); - //Find textures which contain outfit UUID string in description - LLInventoryModel::item_array_t uploaded_item_array; + //Find texture which contain outfit ID string in name LLViewerInventoryItem* photo_upload_item = NULL; BOOST_FOREACH(LLViewerInventoryItem* item, item_array) { - std::string desc = item->getDescription(); std::string name = item->getName(); - - if (name == getString("photo_upload_pending_string")) + if (!mOutfitLinkPending.isNull() && name == mOutfitLinkPending.asString()) { photo_upload_item = item; break; } } - if (!mPhotoLinkPending.isNull() && photo_upload_item != NULL) + if (photo_upload_item != NULL) { LLUUID upload_pending_id = photo_upload_item->getUUID(); LLInventoryObject* upload_object = gInventory.getObject(upload_pending_id); @@ -700,7 +692,6 @@ void LLOutfitGallery::refreshTextures(const LLUUID& category_id) update_inventory_item(upload_pending_id, updates, NULL); } - mPhotoLinkPending.setNull(); mOutfitLinkPending.setNull(); } } @@ -733,7 +724,6 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) return; } - bool add_successful = false; LLFilePicker& picker = LLFilePicker::instance(); if (picker.getOpenFile(LLFilePicker::FFLOAD_IMAGE)) { @@ -741,22 +731,15 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) LLLocalBitmap* unit = new LLLocalBitmap(filename); if (unit->getValid()) { - add_successful = true; - //LLAssetStorage::LLStoreAssetCallback callback = &LLGalleryPhotoStoreCallback; S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass). void *nruserdata = NULL; nruserdata = (void *)&outfit_id; - LL_WARNS() << "selected_outfit_id: " << outfit_id.asString() << LL_ENDL; - - //LLViewerInventoryItem *outfit = gInventory.getItem(selected_outfit_id); LLViewerInventoryCategory *outfit_cat = gInventory.getCategory(outfit_id); if (!outfit_cat) return; checkRemovePhoto(outfit_id); - - std::string upload_pending_name = getString("photo_upload_pending_string"); - + std::string upload_pending_name = outfit_id.asString(); LLUUID photo_id = upload_new_resource(filename, // file upload_pending_name, outfit_id.asString(), @@ -765,8 +748,6 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), upload_pending_name, &LLGalleryPhotoStoreCallback, expected_upload_cost, nruserdata); - - mPhotoLinkPending = photo_id; mOutfitLinkPending = outfit_id; } } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 47ab85f4e1..a2bba62157 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -122,7 +122,6 @@ private: LLScrollContainer* mScrollPanel; LLPanel* mGalleryPanel; LLPanel* mLastRowStack; - LLUUID mPhotoLinkPending; LLUUID mOutfitLinkPending; bool galleryCreated; int mRowCount; diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml index 682d2d0730..c06c6a86c3 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml @@ -10,9 +10,6 @@ left="0" top="0" width="312"> - - Photo upload pending... - Photo of "[OUTFIT_NAME]" outfit -- cgit v1.3 From 5ca5d9f43b56981d0e237566732f16104aaa99db Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Tue, 23 Feb 2016 19:12:43 +0200 Subject: MAINT-5194 Visual Outfit Browser Fixed build issues under Linux --- indra/newview/lloutfitgallery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 51d8bea3ad..9a7aa5e277 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -596,7 +596,7 @@ void LLOutfitGalleryGearMenu::onLoadAssets() void LLOutfitGallery::loadPhotos() { //Iterate over inventory - LLUUID textures = gInventory.findCategoryUUIDForType(LLFolderType::EType::FT_TEXTURE); + LLUUID textures = gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE); LLViewerInventoryCategory* textures_category = gInventory.getCategory(textures); if (!textures_category) return; -- cgit v1.3 From 51945162d2f3cde29d698bfad47a2eeafcd86c76 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Thu, 25 Feb 2016 20:28:04 +0200 Subject: MAINT-5194 Visual Outfit Browser Сhanging default photo for outfit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- indra/newview/lloutfitgallery.cpp | 4 ---- .../default/textures/icons/Default_Outfit_Photo.jpg | Bin 0 -> 26604 bytes indra/newview/skins/default/textures/textures.xml | 2 +- .../skins/default/xui/en/panel_outfit_gallery_item.xml | 2 +- 4 files changed, 2 insertions(+), 6 deletions(-) create mode 100644 indra/newview/skins/default/textures/icons/Default_Outfit_Photo.jpg (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 9a7aa5e277..9f0c7cbbe3 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -578,10 +578,6 @@ void LLOutfitGalleryGearMenu::onUploadFoto() { gallery->uploadPhoto(selected_outfit_id); } - if (selected_outfit_id.notNull()) - { - - } } void LLOutfitGalleryGearMenu::onLoadAssets() diff --git a/indra/newview/skins/default/textures/icons/Default_Outfit_Photo.jpg b/indra/newview/skins/default/textures/icons/Default_Outfit_Photo.jpg new file mode 100644 index 0000000000..c019174fd7 Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Default_Outfit_Photo.jpg differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 1b7b76e3b8..b1b82669a9 100755 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -804,7 +804,7 @@ with the same filename but different name - + diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml index d8b0ecaf59..eede209e91 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml @@ -27,7 +27,7 @@ width="147" follows="left|top" visible="true" - image_name="Popup_Caution" + image_name="Default_Outfit_Photo" /> Date: Fri, 4 Mar 2016 19:41:01 +0200 Subject: MAINT-5194 Visual Outfit Browser 1) Made code clean-up 2) Removed constants in code via #define and introduced parametres which can ne set in XML instead 3) Made refactoring of some methods 4) Removed non-functional item "Load assets" from outfit gear-menu --- indra/newview/lloutfitgallery.cpp | 181 ++++++-------- indra/newview/lloutfitgallery.h | 66 ++++-- indra/newview/lloutfitslist.cpp | 264 +-------------------- indra/newview/lloutfitslist.h | 5 +- .../skins/default/xui/en/menu_outfit_gear.xml | 7 - 5 files changed, 141 insertions(+), 382 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 9f0c7cbbe3..48e78b62af 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -45,21 +45,48 @@ #include "llviewermenufile.h" #include "llwearableitemslist.h" - static LLPanelInjector t_outfit_gallery("outfit_gallery"); static LLOutfitGallery* gOutfitGallery = NULL; -LLOutfitGallery::LLOutfitGallery() +LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) : LLOutfitListBase(), mTexturesObserver(NULL), mOutfitsObserver(NULL), mScrollPanel(NULL), mGalleryPanel(NULL), - galleryCreated(false), + mGalleryCreated(false), mRowCount(0), mItemsAddedCount(0), - mOutfitLinkPending(NULL) + mOutfitLinkPending(NULL), + mRowPanelHeight(p.row_panel_height), + mVerticalGap(p.vertical_gap), + mHorizontalGap(p.horizontal_gap), + mItemWidth(p.item_width), + mItemHeight(p.item_height), + mItemHorizontalGap(p.item_horizontal_gap), + mItemsInRow(p.items_in_row) +{ + mRowPanelWidth = p.row_panel_width_factor * mItemsInRow; + mGalleryWidth = p.gallery_width_factor * mItemsInRow; +} + +LLOutfitGallery::Params::Params() + : row_panel_height("row_panel_height", 180), + vertical_gap("vertical_gap", 10), + horizontal_gap("horizontal_gap", 10), + item_width("item_width", 150), + item_height("item_height", 175), + item_horizontal_gap("item_horizontal_gap", 16), + items_in_row("items_in_row", 3), + row_panel_width_factor("row_panel_width_factor", 166), + gallery_width_factor("gallery_width_factor", 163) +{ + addSynonym(row_panel_height, "row_height"); +} + +const LLOutfitGallery::Params& LLOutfitGallery::getDefaultParams() { + return LLUICtrlFactory::getDefaultParams(); } BOOL LLOutfitGallery::postBuild() @@ -73,7 +100,7 @@ BOOL LLOutfitGallery::postBuild() void LLOutfitGallery::onOpen(const LLSD& info) { LLOutfitListBase::onOpen(info); - if (!galleryCreated) + if (!mGalleryCreated) { loadPhotos(); uuid_vec_t cats; @@ -85,26 +112,16 @@ void LLOutfitGallery::onOpen(const LLSD& info) { addToGallery(mOutfitMap[cats[i]]); } - galleryCreated = true; + mGalleryCreated = true; } } -#define LAYOUT_STACK_HEIGHT 180 -#define GALLERY_VERTICAL_GAP 10 -#define GALLERY_HORIZONTAL_GAP 10 -#define GALLERY_ITEM_WIDTH 150 -#define GALLERY_ITEM_HEIGHT 175 -#define GALLERY_ITEM_HGAP 16 -#define ITEMS_IN_ROW 3 -#define LAYOUT_STACK_WIDTH 166 * ITEMS_IN_ROW//498 -#define GALLERY_WIDTH 163 * ITEMS_IN_ROW//485//290 - LLPanel* LLOutfitGallery::addLastRow() { mRowCount++; int row = 0; - int vgap = GALLERY_VERTICAL_GAP * row; - LLPanel* result = buildLayoutStak(0, row * LAYOUT_STACK_HEIGHT + vgap); + int vgap = mVerticalGap * row; + LLPanel* result = buildRowPanel(0, row * mRowPanelHeight + vgap); mGalleryPanel->addChild(result); return result; } @@ -121,24 +138,24 @@ void LLOutfitGallery::moveRowDown(int row) void LLOutfitGallery::moveRow(int row, int pos) { - int vgap = GALLERY_VERTICAL_GAP * pos; - moveLayoutStak(mStacks[row], 0, pos * LAYOUT_STACK_HEIGHT + vgap); + int vgap = mVerticalGap * pos; + moveRowPanel(mRowPanels[row], 0, pos * mRowPanelHeight + vgap); } void LLOutfitGallery::removeLastRow() { mRowCount--; - mGalleryPanel->removeChild(mLastRowStack); - mStacks.pop_back(); - mLastRowStack = mStacks.back(); + mGalleryPanel->removeChild(mLastRowPanel); + mRowPanels.pop_back(); + mLastRowPanel = mRowPanels.back(); } LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item, int pos, int hgap) { - LLPanel* lpanel = buildLayoutPanel(pos * GALLERY_ITEM_WIDTH + hgap); + LLPanel* lpanel = buildItemPanel(pos * mItemWidth + hgap); lpanel->addChild(item); row_stack->addChild(lpanel); - mPanels.push_back(lpanel); + mItemPanels.push_back(lpanel); return lpanel; } @@ -147,9 +164,9 @@ void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item) mItemsAddedCount++; mItemIndexMap[item] = mItemsAddedCount - 1; int n = mItemsAddedCount; - int row_count = (n % ITEMS_IN_ROW) == 0 ? n / ITEMS_IN_ROW : n / ITEMS_IN_ROW + 1; + int row_count = (n % mItemsInRow) == 0 ? n / mItemsInRow : n / mItemsInRow + 1; int n_prev = n - 1; - int row_count_prev = (n_prev % ITEMS_IN_ROW) == 0 ? n_prev / ITEMS_IN_ROW : n_prev / ITEMS_IN_ROW + 1; + int row_count_prev = (n_prev % mItemsInRow) == 0 ? n_prev / mItemsInRow : n_prev / mItemsInRow + 1; bool add_row = row_count != row_count_prev; int pos = 0; @@ -159,12 +176,12 @@ void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item) { moveRowUp(i); } - mLastRowStack = addLastRow(); - mStacks.push_back(mLastRowStack); + mLastRowPanel = addLastRow(); + mRowPanels.push_back(mLastRowPanel); } - pos = (n - 1) % ITEMS_IN_ROW; + pos = (n - 1) % mItemsInRow; mItems.push_back(item); - addToRow(mLastRowStack, item, pos, GALLERY_HORIZONTAL_GAP * pos); + addToRow(mLastRowPanel, item, pos, mHorizontalGap * pos); reshapeGalleryPanel(row_count); } @@ -173,12 +190,11 @@ void LLOutfitGallery::removeFromGalleryLast(LLOutfitGalleryItem* item) { int n_prev = mItemsAddedCount; int n = mItemsAddedCount - 1; - int row_count = (n % ITEMS_IN_ROW) == 0 ? n / ITEMS_IN_ROW : n / ITEMS_IN_ROW + 1; - int row_count_prev = (n_prev % ITEMS_IN_ROW) == 0 ? n_prev / ITEMS_IN_ROW : n_prev / ITEMS_IN_ROW + 1; + int row_count = (n % mItemsInRow) == 0 ? n / mItemsInRow : n / mItemsInRow + 1; + int row_count_prev = (n_prev % mItemsInRow) == 0 ? n_prev / mItemsInRow : n_prev / mItemsInRow + 1; mItemsAddedCount--; bool remove_row = row_count != row_count_prev; - //int pos = (n_prev - 1) % ITEMS_IN_ROW; removeFromLastRow(mItems[mItemsAddedCount]); mItems.pop_back(); if (remove_row) @@ -214,16 +230,16 @@ void LLOutfitGallery::removeFromGalleryMiddle(LLOutfitGalleryItem* item) void LLOutfitGallery::removeFromLastRow(LLOutfitGalleryItem* item) { - mPanels.back()->removeChild(item); - mLastRowStack->removeChild(mPanels.back()); - mPanels.pop_back(); + mItemPanels.back()->removeChild(item); + mLastRowPanel->removeChild(mItemPanels.back()); + mItemPanels.pop_back(); } LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name) { LLOutfitGalleryItem::Params giparams; LLOutfitGalleryItem* gitem = LLUICtrlFactory::create(giparams); - gitem->reshape(GALLERY_ITEM_WIDTH, GALLERY_ITEM_HEIGHT); + gitem->reshape(mItemWidth, mItemHeight); gitem->setVisible(true); gitem->setFollowsLeft(); gitem->setFollowsTop(); @@ -242,42 +258,42 @@ void LLOutfitGallery::reshapeGalleryPanel(int row_count) { int bottom = 0; int left = 0; - int height = row_count * (LAYOUT_STACK_HEIGHT + GALLERY_VERTICAL_GAP); - LLRect rect = LLRect(left, bottom + height, left + GALLERY_WIDTH, bottom); + int height = row_count * (mRowPanelHeight + mVerticalGap); + LLRect rect = LLRect(left, bottom + height, left + mGalleryWidth, bottom); mGalleryPanel->setRect(rect); - mGalleryPanel->reshape(GALLERY_WIDTH, height); + mGalleryPanel->reshape(mGalleryWidth, height); mGalleryPanel->setVisible(true); mGalleryPanel->setFollowsLeft(); mGalleryPanel->setFollowsTop(); } -LLPanel* LLOutfitGallery::buildLayoutPanel(int left) +LLPanel* LLOutfitGallery::buildItemPanel(int left) { LLPanel::Params lpparams; int top = 0; LLPanel* lpanel = LLUICtrlFactory::create(lpparams); - LLRect rect = LLRect(left, top + GALLERY_ITEM_HEIGHT, left + GALLERY_ITEM_WIDTH + GALLERY_ITEM_HGAP, top); + LLRect rect = LLRect(left, top + mItemHeight, left + mItemWidth + mItemHorizontalGap, top); lpanel->setRect(rect); - lpanel->reshape(GALLERY_ITEM_WIDTH + GALLERY_ITEM_HGAP, GALLERY_ITEM_HEIGHT); + lpanel->reshape(mItemWidth + mItemHorizontalGap, mItemHeight); lpanel->setVisible(true); lpanel->setFollowsLeft(); lpanel->setFollowsTop(); return lpanel; } -LLPanel* LLOutfitGallery::buildLayoutStak(int left, int bottom) +LLPanel* LLOutfitGallery::buildRowPanel(int left, int bottom) { LLPanel::Params sparams; LLPanel* stack = LLUICtrlFactory::create(sparams); - moveLayoutStak(stack, left, bottom); + moveRowPanel(stack, left, bottom); return stack; } -void LLOutfitGallery::moveLayoutStak(LLPanel* stack, int left, int bottom) +void LLOutfitGallery::moveRowPanel(LLPanel* stack, int left, int bottom) { - LLRect rect = LLRect(left, bottom + LAYOUT_STACK_HEIGHT, left + LAYOUT_STACK_WIDTH, bottom); + LLRect rect = LLRect(left, bottom + mRowPanelHeight, left + mRowPanelWidth, bottom); stack->setRect(rect); - stack->reshape(LAYOUT_STACK_WIDTH, LAYOUT_STACK_HEIGHT); + stack->reshape(mRowPanelWidth, mRowPanelHeight); stack->setVisible(true); stack->setFollowsLeft(); stack->setFollowsTop(); @@ -290,6 +306,12 @@ LLOutfitGallery::~LLOutfitGallery() gInventory.removeObserver(mTexturesObserver); } delete mTexturesObserver; + + if (gInventory.containsObserver(mOutfitsObserver)) + { + gInventory.removeObserver(mOutfitsObserver); + } + delete mOutfitsObserver; } void LLOutfitGallery::setFilterSubString(const std::string& string) @@ -340,7 +362,7 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) _1, _2, _3, cat_id)); LLWearableItemsList* list = NULL; item->setFocusReceivedCallback(boost::bind(&LLOutfitListBase::ChangeOutfitSelection, this, list, cat_id)); - if (galleryCreated) + if (mGalleryCreated) { addToGallery(item); } @@ -355,7 +377,7 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) gInventory.addObserver(mOutfitsObserver); } - // Start observing changes in "My Outits" category. + // Start observing changes in "My Outfits" category. mOutfitsObserver->addCategory(cat_id, boost::bind(&LLOutfitGallery::refreshOutfit, this, cat_id)); @@ -376,7 +398,7 @@ void LLOutfitGallery::updateRemovedCategory(LLUUID cat_id) // An outfit is removed from the list. Do the following: // 2. Remove the outfit from selection. - //deselectOutfit(outfit_id); + deselectOutfit(cat_id); // 3. Remove category UUID to accordion tab mapping. mOutfitMap.erase(outfits_iter); @@ -384,8 +406,6 @@ void LLOutfitGallery::updateRemovedCategory(LLUUID cat_id) // 4. Remove outfit from gallery. removeFromGalleryMiddle(item); - - // kill removed item if (item != NULL) { @@ -479,7 +499,6 @@ BOOL LLOutfitGalleryItem::postBuild() void LLOutfitGalleryItem::draw() { LLPanel::draw(); - // Draw border LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "OutfitGalleryItemSelected" : "OutfitGalleryItemUnselected", LLColor4::white); @@ -491,12 +510,6 @@ void LLOutfitGalleryItem::draw() const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); if (mTexturep) { - //if (mTexturep->getComponents() == 4) - //{ - // gl_rect_2d_checkerboard(interior, alpha); - //} - - // Interior LLRect interior = border; interior.stretch(-1); @@ -516,8 +529,6 @@ void LLOutfitGalleryItem::setOutfitName(std::string name) void LLOutfitGalleryItem::setOutfitWorn(bool value) { mWorn = value; - //LLStringUtil::format_map_t string_args; - //std::string worn_text = getString("worn_text", string_args); LLStringUtil::format_map_t worn_string_args; std::string worn_string = getString("worn_string", worn_string_args); LLUIColor text_color = LLUIColorTable::instance().getColor(mSelected ? "White" : (mWorn ? "OutfitGalleryItemWorn" : "White"), LLColor4::white); @@ -547,11 +558,6 @@ void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) void LLOutfitGalleryItem::setDefaultImage() { - /* - LLUUID imageAssetID("e417f443-a199-bac1-86b0-0530e177fb54"); - mTexturep = LLViewerTextureManager::getFetchedTexture(imageAssetID); - mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); - */ mTexturep = NULL; } @@ -580,15 +586,6 @@ void LLOutfitGalleryGearMenu::onUploadFoto() } } -void LLOutfitGalleryGearMenu::onLoadAssets() -{ - LLOutfitGallery* gallery = dynamic_cast(mOutfitList); - if (gallery != NULL) - { - gallery->loadPhotos(); - } -} - void LLOutfitGallery::loadPhotos() { //Iterate over inventory @@ -692,26 +689,6 @@ void LLOutfitGallery::refreshTextures(const LLUUID& category_id) } } -void LLOutfitGallery::onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status) -{ - LL_WARNS() << "asset_uuid: " << asset_uuid.asString() << LL_ENDL; - - LLUUID* outfit_id = (LLUUID*)user_data; - if (!user_data) - return; - LL_WARNS() << "outfit_id: " << outfit_id->asString() << LL_ENDL; - - outfit_map_t::iterator it = gOutfitGallery->mOutfitMap.find(*outfit_id); - if (it != gOutfitGallery->mOutfitMap.end() && !it->first.isNull()) - { - } -} - -void LLGalleryPhotoStoreCallback(const LLUUID &asset_id, void *user_data, S32 status, LLExtStat ext_status) -{ - LL_WARNS() << "Photo stored as asset. UUID:" << asset_id.asString() << LL_ENDL; -} - void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) { outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); @@ -736,6 +713,7 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) checkRemovePhoto(outfit_id); std::string upload_pending_name = outfit_id.asString(); + LLAssetStorage::LLStoreAssetCallback callback = NULL; LLUUID photo_id = upload_new_resource(filename, // file upload_pending_name, outfit_id.asString(), @@ -743,7 +721,7 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - upload_pending_name, &LLGalleryPhotoStoreCallback, expected_upload_cost, nruserdata); + upload_pending_name, callback, expected_upload_cost, nruserdata); mOutfitLinkPending = outfit_id; } } @@ -766,11 +744,6 @@ bool LLOutfitGallery::checkRemovePhoto(LLUUID outfit_id) return false; } -void LLOutfitGallery::setUploadedPhoto(LLUUID outfit_id, LLUUID asset_id) -{ - -} - void LLOutfitGallery::computeDifferenceOfTextures( const LLInventoryModel::item_array_t& vtextures, uuid_vec_t& vadded, @@ -793,8 +766,6 @@ void LLOutfitGallery::computeDifferenceOfTextures( { vcur.push_back((*iter).second->getUUID()); } -// getCurrentCategories(vcur); LLCommonUtils::computeDifference(vnew, vcur, vadded, vremoved); - } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index a2bba62157..dfb100bd43 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -56,7 +56,28 @@ class LLOutfitGallery : public LLOutfitListBase { public: friend class LLOutfitGalleryGearMenu; - LLOutfitGallery(); + + struct Params + : public LLInitParam::Block + { + Optional row_panel_height; + Optional row_panel_width_factor; + Optional gallery_width_factor; + Optional vertical_gap; + Optional horizontal_gap; + Optional item_width; + Optional item_height; + Optional item_horizontal_gap; + Optional items_in_row; + + Params(); + }; + + static const LLOutfitGallery::Params& getDefaultParams(); + + LLOutfitGallery(const LLOutfitGallery::Params& params = getDefaultParams()); + +// LLOutfitGallery(); virtual ~LLOutfitGallery(); /*virtual*/ BOOL postBuild(); @@ -93,7 +114,6 @@ private: void uploadPhoto(LLUUID outfit_id); void linkPhotoToOutfit(LLUUID outfit_id, LLUUID photo_id); bool checkRemovePhoto(LLUUID outfit_id); - void setUploadedPhoto(LLUUID outfit_id, LLUUID asset_id); void addToGallery(LLOutfitGalleryItem* item); void removeFromGalleryLast(LLOutfitGalleryItem* item); void removeFromGalleryMiddle(LLOutfitGalleryItem* item); @@ -105,27 +125,44 @@ private: LLPanel* addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item, int pos, int hgap); void removeFromLastRow(LLOutfitGalleryItem* item); - static void onLoadComplete(LLVFS *vfs, - const LLUUID& asset_uuid, - LLAssetType::EType type, - void* user_data, S32 status, LLExtStat ext_status); - LLOutfitGalleryItem* buildGalleryItem(std::string name); void buildGalleryPanel(int row_count); void reshapeGalleryPanel(int row_count); - LLPanel* buildLayoutPanel(int left); - LLPanel* buildLayoutStak(int left, int bottom); - void moveLayoutStak(LLPanel* stack, int left, int bottom); - std::vector mStacks; - std::vector mPanels; + LLPanel* buildItemPanel(int left); + LLPanel* buildRowPanel(int left, int bottom); + void moveRowPanel(LLPanel* stack, int left, int bottom); + std::vector mRowPanels; + std::vector mItemPanels; std::vector mItems; LLScrollContainer* mScrollPanel; LLPanel* mGalleryPanel; - LLPanel* mLastRowStack; + LLPanel* mLastRowPanel; LLUUID mOutfitLinkPending; - bool galleryCreated; + bool mGalleryCreated; int mRowCount; int mItemsAddedCount; + /* Params */ + int mRowPanelHeight; + int mVerticalGap; + int mHorizontalGap; + int mItemWidth; + int mItemHeight; + int mItemHorizontalGap; + int mItemsInRow; + int mRowPanelWidth; + int mGalleryWidth; + + /* + #define LAYOUT_STACK_WIDTH_FACTOR 166 + #define LAYOUT_STACK_WIDTH LAYOUT_STACK_WIDTH_FACTOR * ITEMS_IN_ROW//498 + #define GALLERY_WIDTH_FACTOR 163 + #define GALLERY_WIDTH GALLERY_WIDTH_FACTOR * ITEMS_IN_ROW//485//290 + */ + + /* + #define GALLERY_ITEM_HGAP 16 + #define ITEMS_IN_ROW 3 + */ typedef std::map outfit_map_t; typedef outfit_map_t::value_type outfit_map_value_t; @@ -155,7 +192,6 @@ protected: private: /*virtual*/ void onUploadFoto(); - /*virtual*/ void onLoadAssets(); }; class LLOutfitGalleryItem : public LLPanel diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 945a8325f8..a7636fc368 100755 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -38,7 +38,6 @@ #include "llfloatersidepanelcontainer.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" -//#include "lllistcontextmenu.h" #include "llmenubutton.h" #include "llnotificationsutil.h" #include "lloutfitobserver.h" @@ -106,14 +105,10 @@ LLOutfitsList::LLOutfitsList() , mListCommands(NULL) , mItemSelected(false) { -// mCategoriesObserver = new LLInventoryCategoriesObserver(); - -// mGearMenu = new LLOutfitListGearMenu(this); } LLOutfitsList::~LLOutfitsList() { -// delete mGearMenu; } BOOL LLOutfitsList::postBuild() @@ -121,11 +116,6 @@ BOOL LLOutfitsList::postBuild() mAccordion = getChild("outfits_accordion"); mAccordion->setComparator(&OUTFIT_TAB_NAME_COMPARATOR); - //LLMenuButton* menu_gear_btn = getChild("options_gear_btn"); - - //menu_gear_btn->setMouseDownCallback(boost::bind(&LLOutfitListGearMenu::updateItemsVisibility, mGearMenu)); - //menu_gear_btn->setMenu(mGearMenu->getMenu()); - return LLOutfitListBase::postBuild(); } @@ -141,44 +131,6 @@ void LLOutfitsList::onOpen(const LLSD& info) LLOutfitListBase::onOpen(info); - // if (!mIsInitialized) - //{ - // // *TODO: I'm not sure is this check necessary but it never match while developing. - // if (!gInventory.isInventoryUsable()) - // return; - - // const LLUUID outfits = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - - // // *TODO: I'm not sure is this check necessary but it never match while developing. - // LLViewerInventoryCategory* category = gInventory.getCategory(outfits); - // if (!category) - // return; - - // gInventory.addObserver(mCategoriesObserver); - - // // Start observing changes in "My Outfits" category. - // mCategoriesObserver->addCategory(outfits, - // boost::bind(&LLOutfitsList::refreshList, this, outfits)); - - // const LLUUID cof = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); - - // // Start observing changes in Current Outfit category. - // mCategoriesObserver->addCategory(cof, boost::bind(&LLOutfitsList::onCOFChanged, this)); - - // LLOutfitObserver::instance().addBOFChangedCallback(boost::bind(&LLOutfitsList::highlightBaseOutfit, this)); - // LLOutfitObserver::instance().addBOFReplacedCallback(boost::bind(&LLOutfitsList::highlightBaseOutfit, this)); - - // // Fetch "My Outfits" contents and refresh the list to display - // // initially fetched items. If not all items are fetched now - // // the observer will refresh the list as soon as the new items - // // arrive. - // category->fetch(); - // refreshList(outfits); - // highlightBaseOutfit(); - - // mIsInitialized = true; - //} - LLAccordionCtrlTab* selected_tab = mAccordion->getSelectedTab(); if (!selected_tab) return; @@ -295,157 +247,6 @@ void LLOutfitsList::updateRemovedCategory(LLUUID cat_id) } } -/* -void LLOutfitsList::refreshList(const LLUUID& category_id) -{ - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - - // Collect all sub-categories of a given category. - LLIsType is_category(LLAssetType::AT_CATEGORY); - gInventory.collectDescendentsIf( - category_id, - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - is_category); - - uuid_vec_t vadded; - uuid_vec_t vremoved; - - // Create added and removed items vectors. - computeDifference(cat_array, vadded, vremoved); - - // Handle added tabs. - for (uuid_vec_t::const_iterator iter = vadded.begin(); - iter != vadded.end(); - ++iter) - { - const LLUUID cat_id = (*iter); - updateAddedCategory(cat_id); - //LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); - //if (!cat) continue; - - //std::string name = cat->getName(); - - //outfit_accordion_tab_params tab_params(get_accordion_tab_params()); - //LLAccordionCtrlTab* tab = LLUICtrlFactory::create(tab_params); - //if (!tab) continue; - //LLWearableItemsList* wearable_list = LLUICtrlFactory::create(tab_params.wearable_list); - //wearable_list->setShape(tab->getLocalRect()); - //tab->addChild(wearable_list); - - //tab->setName(name); - //tab->setTitle(name); - - //// *TODO: LLUICtrlFactory::defaultBuilder does not use "display_children" from xml. Should be investigated. - //tab->setDisplayChildren(false); - //mAccordion->addCollapsibleCtrl(tab); - - //// Start observing the new outfit category. - //LLWearableItemsList* list = tab->getChild("wearable_items_list"); - //if (!mCategoriesObserver->addCategory(cat_id, boost::bind(&LLWearableItemsList::updateList, list, cat_id))) - //{ - // // Remove accordion tab if category could not be added to observer. - // mAccordion->removeCollapsibleCtrl(tab); - - // // kill removed tab - // tab->die(); - // continue; - //} - - //// Map the new tab with outfit category UUID. - //mOutfitsMap.insert(LLOutfitsList::outfits_map_value_t(cat_id, tab)); - - //tab->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onAccordionTabRightClick, this, - // _1, _2, _3, cat_id)); - - //// Setting tab focus callback to monitor currently selected outfit. - //tab->setFocusReceivedCallback(boost::bind(&LLOutfitsList::changeOutfitSelection, this, list, cat_id)); - - //// Setting callback to reset items selection inside outfit on accordion collapsing and expanding (EXT-7875) - //tab->setDropDownStateChangedCallback(boost::bind(&LLOutfitsList::resetItemSelection, this, list, cat_id)); - - //// force showing list items that don't match current filter(EXT-7158) - //list->setForceShowingUnmatchedItems(true); - - //// Setting list commit callback to monitor currently selected wearable item. - //list->setCommitCallback(boost::bind(&LLOutfitsList::onSelectionChange, this, _1)); - - //// Setting list refresh callback to apply filter on list change. - //list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onFilteredWearableItemsListRefresh, this, _1)); - - //list->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onWearableItemsListRightClick, this, _1, _2, _3)); - - //// Fetch the new outfit contents. - //cat->fetch(); - - //// Refresh the list of outfit items after fetch(). - //// Further list updates will be triggered by the category observer. - //list->updateList(cat_id); - - //// If filter is currently applied we store the initial tab state and - //// open it to show matched items if any. - //if (!sFilterSubString.empty()) - //{ - // tab->notifyChildren(LLSD().with("action","store_state")); - // tab->setDisplayChildren(true); - - // // Setting mForceRefresh flag will make the list refresh its contents - // // even if it is not currently visible. This is required to apply the - // // filter to the newly added list. - // list->setForceRefresh(true); - - // list->setFilterSubString(sFilterSubString); - //} - } - - // Handle removed tabs. - for (uuid_vec_t::const_iterator iter=vremoved.begin(); iter != vremoved.end(); ++iter) - { - const LLUUID cat_id = (*iter); - updateRemovedCategory(cat_id); - //outfits_map_t::iterator outfits_iter = mOutfitsMap.find(cat_id); - //if (outfits_iter != mOutfitsMap.end()) - //{ - // const LLUUID& outfit_id = outfits_iter->first; - // LLAccordionCtrlTab* tab = outfits_iter->second; - - // // An outfit is removed from the list. Do the following: - // // 1. Remove outfit category from observer to stop monitoring its changes. - // mCategoriesObserver->removeCategory(outfit_id); - - // // 2. Remove the outfit from selection. - // deselectOutfit(outfit_id); - - // // 3. Remove category UUID to accordion tab mapping. - // mOutfitsMap.erase(outfits_iter); - - // // 4. Remove outfit tab from accordion. - // mAccordion->removeCollapsibleCtrl(tab); - - // // kill removed tab - // if (tab != NULL) - // { - // tab->die(); - // } - //} - } - - // Get changed items from inventory model and update outfit tabs - // which might have been renamed. - const LLInventoryModel::changed_items_t& changed_items = gInventory.getChangedIDs(); - for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); - items_iter != changed_items.end(); - ++items_iter) - { - updateChangedCategoryName(*items_iter); - } - - mAccordion->sort(); -} -*/ - //virtual void LLOutfitsList::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id) { @@ -628,33 +429,6 @@ bool LLOutfitsList::hasItemSelected() ////////////////////////////////////////////////////////////////////////// // Private methods ////////////////////////////////////////////////////////////////////////// -/* -void LLOutfitsList::computeDifference( - const LLInventoryModel::cat_array_t& vcats, - uuid_vec_t& vadded, - uuid_vec_t& vremoved) -{ - uuid_vec_t vnew; - // Creating a vector of newly collected sub-categories UUIDs. - for (LLInventoryModel::cat_array_t::const_iterator iter = vcats.begin(); - iter != vcats.end(); - iter++) - { - vnew.push_back((*iter)->getUUID()); - } - - uuid_vec_t vcur; - // Creating a vector of currently displayed sub-categories UUIDs. - for (outfits_map_t::const_iterator iter = mOutfitsMap.begin(); - iter != mOutfitsMap.end(); - iter++) - { - vcur.push_back((*iter).first); - } - - LLCommonUtils::computeDifference(vnew, vcur, vadded, vremoved); -} -*/ void LLOutfitsList::updateChangedCategoryName(LLViewerInventoryCategory *cat, std::string name) { @@ -710,12 +484,8 @@ void LLOutfitsList::deselectOutfit(const LLUUID& category_id) { // Remove selected lists map entry. mSelectedListsMap.erase(category_id); - - // Reset selection if the outfit is selected. - if (category_id == mSelectedOutfitUUID) - { - signalSelectionOutfitUUID(LLUUID::null); - } + + LLOutfitListBase::deselectOutfit(category_id); } void LLOutfitsList::restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID& category_id) @@ -1056,12 +826,6 @@ void LLOutfitListBase::onOpen(const LLSD& info) mIsInitialized = true; } - - //LLAccordionCtrlTab* selected_tab = mAccordion->getSelectedTab(); - //if (!selected_tab) return; - - //// Pass focus to the selected outfit tab. - //selected_tab->showAndFocusHeader(); } void LLOutfitListBase::refreshList(const LLUUID& category_id) @@ -1133,13 +897,6 @@ void LLOutfitListBase::computeDifference( } uuid_vec_t vcur; - //// Creating a vector of currently displayed sub-categories UUIDs. - //for (outfits_map_t::const_iterator iter = mOutfitsMap.begin(); - // iter != mOutfitsMap.end(); - // iter++) - //{ - // vcur.push_back((*iter).first); - //} getCurrentCategories(vcur); LLCommonUtils::computeDifference(vnew, vcur, vadded, vremoved); @@ -1226,6 +983,15 @@ void LLOutfitListBase::expandAllFolders() onExpandAllFolders(); } +void LLOutfitListBase::deselectOutfit(const LLUUID& category_id) +{ + // Reset selection if the outfit is selected. + if (category_id == mSelectedOutfitUUID) + { + signalSelectionOutfitUUID(LLUUID::null); + } +} + LLContextMenu* LLOutfitContextMenu::createMenu() { LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; @@ -1325,7 +1091,6 @@ LLOutfitListGearMenuBase::LLOutfitListGearMenuBase(LLOutfitListBase* olist) registrar.add("Gear.WearAdd", boost::bind(&LLOutfitListGearMenuBase::onAdd, this)); registrar.add("Gear.UploadPhoto", boost::bind(&LLOutfitListGearMenuBase::onUploadFoto, this)); - registrar.add("Gear.LoadAssets", boost::bind(&LLOutfitListGearMenuBase::onLoadAssets, this)); enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenuBase::onEnable, this, _2)); enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenuBase::onVisible, this, _2)); @@ -1350,8 +1115,6 @@ void LLOutfitListGearMenuBase::onUpdateItemsVisibility() bool have_selection = getSelectedOutfitID().notNull(); mMenu->setItemVisible("sepatator1", have_selection); mMenu->setItemVisible("sepatator2", have_selection); - //mMenu->setItemVisible("expand", mOutfitList->getHasExpandableFolders()); - //mMenu->setItemVisible("collapse", mOutfitList->getHasExpandableFolders()); mMenu->arrangeAndClear(); // update menu height } @@ -1466,11 +1229,6 @@ void LLOutfitListGearMenuBase::onUploadFoto() } -void LLOutfitListGearMenuBase::onLoadAssets() -{ - -} - LLOutfitListGearMenu::LLOutfitListGearMenu(LLOutfitListBase* olist) : LLOutfitListGearMenuBase(olist) {} diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index 9495866d73..6db3efa70d 100755 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -96,6 +96,8 @@ public: virtual bool hasItemSelected() = 0; virtual bool canWearSelected() = 0; + virtual void deselectOutfit(const LLUUID& category_id); + void signalSelectionOutfitUUID(const LLUUID& category_id); void collapseAllFolders(); @@ -162,7 +164,6 @@ public: protected: virtual void onUpdateItemsVisibility(); virtual void onUploadFoto(); - virtual void onLoadAssets(); const LLUUID& getSelectedOutfitID(); LLOutfitListBase* mOutfitList; @@ -279,7 +280,7 @@ private: /** * Removes the outfit from selection. */ - void deselectOutfit(const LLUUID& category_id); + /*virtual*/ void deselectOutfit(const LLUUID& category_id); /** * Try restoring selection for a temporary hidden tab. 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 3132c4db8b..e31ff2a6e2 100755 --- a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml @@ -46,13 +46,6 @@ - - - -- cgit v1.3 From ff0f2d2f9746b991c01bdbc8c685cb35c711cf2d Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Fri, 11 Mar 2016 18:25:25 +0200 Subject: MAINT-5194 Visual Outfit Browser Fixed Mac build issue --- indra/newview/lloutfitgallery.cpp | 1 - indra/newview/lloutfitgallery.h | 2 -- 2 files changed, 3 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 48e78b62af..c301f5d570 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -46,7 +46,6 @@ #include "llwearableitemslist.h" static LLPanelInjector t_outfit_gallery("outfit_gallery"); -static LLOutfitGallery* gOutfitGallery = NULL; LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) : LLOutfitListBase(), diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index dfb100bd43..97b80acd19 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -179,8 +179,6 @@ private: LLInventoryCategoriesObserver* mOutfitsObserver; }; -//static LLOutfitGallery* gOutfitGallery; - class LLOutfitGalleryGearMenu : public LLOutfitListGearMenuBase { public: -- cgit v1.3 From 30569854448e52e085366390a078054e1aa53ed9 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Wed, 30 Mar 2016 20:33:52 +0300 Subject: MAINT-6243 Photo upload for Visual Outfit Browser on the latest Mac build doesn't update Fixed photo update on upload over existing photo --- indra/newview/lloutfitgallery.cpp | 84 ++++++++++++++++++--------------------- indra/newview/lloutfitgallery.h | 28 ++++--------- 2 files changed, 46 insertions(+), 66 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index c301f5d570..8af05173e6 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -57,6 +57,7 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) mRowCount(0), mItemsAddedCount(0), mOutfitLinkPending(NULL), + mOutfitRenamePending(NULL), mRowPanelHeight(p.row_panel_height), mVerticalGap(p.vertical_gap), mHorizontalGap(p.horizontal_gap), @@ -621,11 +622,23 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) { LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); - if (linked_item->getActualType() == LLAssetType::AT_TEXTURE) + if (linked_item != NULL && linked_item->getActualType() == LLAssetType::AT_TEXTURE) { LLUUID asset_id = linked_item->getAssetUUID(); mOutfitMap[category_id]->setImageAssetId(asset_id); photo_loaded = true; + std::string linked_item_name = linked_item->getName(); + if (!mOutfitRenamePending.isNull() && mOutfitRenamePending.asString() == linked_item_name) + { + LLViewerInventoryCategory *outfit_cat = gInventory.getCategory(mOutfitRenamePending); + LLStringUtil::format_map_t photo_string_args; + photo_string_args["OUTFIT_NAME"] = outfit_cat->getName(); + std::string new_name = getString("outfit_photo_string", photo_string_args); + LLSD updates; + updates["name"] = new_name; + update_inventory_item(linked_item->getUUID(), updates, NULL); + mOutfitRenamePending.setNull(); + } break; } if (!photo_loaded) @@ -650,7 +663,7 @@ void LLOutfitGallery::refreshTextures(const LLUUID& category_id) LLInventoryModel::EXCLUDE_TRASH, is_texture); - //Find texture which contain outfit ID string in name + //Find texture which contain pending outfit ID string in name LLViewerInventoryItem* photo_upload_item = NULL; BOOST_FOREACH(LLViewerInventoryItem* item, item_array) { @@ -664,27 +677,18 @@ void LLOutfitGallery::refreshTextures(const LLUUID& category_id) if (photo_upload_item != NULL) { - LLUUID upload_pending_id = photo_upload_item->getUUID(); - LLInventoryObject* upload_object = gInventory.getObject(upload_pending_id); + LLUUID photo_item_id = photo_upload_item->getUUID(); + LLInventoryObject* upload_object = gInventory.getObject(photo_item_id); if (!upload_object) { LL_WARNS() << "LLOutfitGallery::refreshTextures added_object is null!" << LL_ENDL; } else { - LLViewerInventoryCategory *outfit_cat = gInventory.getCategory(mOutfitLinkPending); - linkPhotoToOutfit(upload_pending_id, mOutfitLinkPending); - - LLStringUtil::format_map_t photo_string_args; - photo_string_args["OUTFIT_NAME"] = outfit_cat->getName(); - std::string new_name = getString("outfit_photo_string", photo_string_args); - - LLSD updates; - updates["name"] = new_name; - update_inventory_item(upload_pending_id, updates, NULL); - + linkPhotoToOutfit(photo_item_id, mOutfitLinkPending); + mOutfitRenamePending = mOutfitLinkPending; + mOutfitLinkPending.setNull(); } - mOutfitLinkPending.setNull(); } } @@ -728,43 +732,31 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) void LLOutfitGallery::linkPhotoToOutfit(LLUUID photo_id, LLUUID outfit_id) { - LLPointer cb = new LLUpdateGalleryOnPhotoUpload(); + LLPointer cb = new LLUpdateGalleryOnPhotoLinked(this); link_inventory_object(outfit_id, photo_id, cb); } bool LLOutfitGallery::checkRemovePhoto(LLUUID outfit_id) { - //remove existing photo of outfit from inventory - texture_map_t::iterator texture_it = mTextureMap.find(outfit_id); - if (texture_it != mTextureMap.end()) { - gInventory.removeItem(texture_it->second->getUUID()); - return true; + //remove existing photo link from outfit folder + LLInventoryModel::cat_array_t sub_cat_array; + LLInventoryModel::item_array_t outfit_item_array; + gInventory.collectDescendents( + outfit_id, + sub_cat_array, + outfit_item_array, + LLInventoryModel::EXCLUDE_TRASH); + BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) + { + LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); + if (linked_item != NULL && linked_item->getActualType() == LLAssetType::AT_TEXTURE) + { + gInventory.removeItem(outfit_item->getUUID()); + } } - return false; + return true; } -void LLOutfitGallery::computeDifferenceOfTextures( - const LLInventoryModel::item_array_t& vtextures, - uuid_vec_t& vadded, - uuid_vec_t& vremoved) +void LLUpdateGalleryOnPhotoLinked::fire(const LLUUID& inv_item_id) { - uuid_vec_t vnew; - // Creating a vector of newly collected texture UUIDs. - for (LLInventoryModel::item_array_t::const_iterator iter = vtextures.begin(); - iter != vtextures.end(); - iter++) - { - vnew.push_back((*iter)->getUUID()); - } - - uuid_vec_t vcur; - // Creating a vector of currently uploaded texture UUIDs. - for (texture_map_t::const_iterator iter = mTextureMap.begin(); - iter != mTextureMap.end(); - iter++) - { - vcur.push_back((*iter).second->getUUID()); - } - - LLCommonUtils::computeDifference(vnew, vcur, vadded, vremoved); } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 97b80acd19..ce3964ca1d 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -38,24 +38,26 @@ #include class LLVFS; +class LLOutfitGallery; class LLOutfitGalleryItem; class LLOutfitListGearMenuBase; class LLOutfitGalleryGearMenu; -class LLUpdateGalleryOnPhotoUpload : public LLInventoryCallback +class LLUpdateGalleryOnPhotoLinked : public LLInventoryCallback { public: - LLUpdateGalleryOnPhotoUpload(){} - virtual ~LLUpdateGalleryOnPhotoUpload(){} - /* virtual */ void fire(const LLUUID& inv_item){} + LLUpdateGalleryOnPhotoLinked(LLOutfitGallery* gallery) : mGallery(gallery) {} + virtual ~LLUpdateGalleryOnPhotoLinked(){} + /* virtual */ void fire(const LLUUID& inv_item_id); private: + LLOutfitGallery* mGallery; }; - class LLOutfitGallery : public LLOutfitListBase { public: friend class LLOutfitGalleryGearMenu; + friend class LLUpdateGalleryOnPhotoLinked; struct Params : public LLInitParam::Block @@ -76,8 +78,6 @@ public: static const LLOutfitGallery::Params& getDefaultParams(); LLOutfitGallery(const LLOutfitGallery::Params& params = getDefaultParams()); - -// LLOutfitGallery(); virtual ~LLOutfitGallery(); /*virtual*/ BOOL postBuild(); @@ -97,7 +97,6 @@ public: void refreshTextures(const LLUUID& category_id); void refreshOutfit(const LLUUID& category_id); - void computeDifferenceOfTextures(const LLInventoryModel::item_array_t& vtextures, uuid_vec_t& vadded, uuid_vec_t& vremoved); protected: /*virtual*/ void onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id); @@ -138,6 +137,7 @@ private: LLPanel* mGalleryPanel; LLPanel* mLastRowPanel; LLUUID mOutfitLinkPending; + LLUUID mOutfitRenamePending; bool mGalleryCreated; int mRowCount; int mItemsAddedCount; @@ -152,18 +152,6 @@ private: int mRowPanelWidth; int mGalleryWidth; - /* - #define LAYOUT_STACK_WIDTH_FACTOR 166 - #define LAYOUT_STACK_WIDTH LAYOUT_STACK_WIDTH_FACTOR * ITEMS_IN_ROW//498 - #define GALLERY_WIDTH_FACTOR 163 - #define GALLERY_WIDTH GALLERY_WIDTH_FACTOR * ITEMS_IN_ROW//485//290 - */ - - /* - #define GALLERY_ITEM_HGAP 16 - #define ITEMS_IN_ROW 3 - */ - typedef std::map outfit_map_t; typedef outfit_map_t::value_type outfit_map_value_t; outfit_map_t mOutfitMap; -- cgit v1.3 From 4f27522175ce2be03cf7ef4673fcc57e29d88554 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Thu, 31 Mar 2016 19:13:31 +0300 Subject: Fixed build on Mac --- indra/newview/lloutfitgallery.cpp | 2 +- indra/newview/lloutfitgallery.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 8af05173e6..5bab133080 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -732,7 +732,7 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) void LLOutfitGallery::linkPhotoToOutfit(LLUUID photo_id, LLUUID outfit_id) { - LLPointer cb = new LLUpdateGalleryOnPhotoLinked(this); + LLPointer cb = new LLUpdateGalleryOnPhotoLinked(); link_inventory_object(outfit_id, photo_id, cb); } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index ce3964ca1d..e9b0fecae7 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -46,11 +46,10 @@ class LLOutfitGalleryGearMenu; class LLUpdateGalleryOnPhotoLinked : public LLInventoryCallback { public: - LLUpdateGalleryOnPhotoLinked(LLOutfitGallery* gallery) : mGallery(gallery) {} + LLUpdateGalleryOnPhotoLinked(){} virtual ~LLUpdateGalleryOnPhotoLinked(){} /* virtual */ void fire(const LLUUID& inv_item_id); private: - LLOutfitGallery* mGallery; }; class LLOutfitGallery : public LLOutfitListBase -- cgit v1.3 From 808b8ed01849fc6e2cd5caba68843eebcadc5333 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Tue, 5 Apr 2016 17:44:53 +0300 Subject: MAINT-6228 Update Photo/Image Upload feature for Outfit Browser 1) Added "Select Photo" to outfit gear menu 2) Incorporated Texture Picker --- indra/newview/lloutfitgallery.cpp | 108 ++++++++++- indra/newview/lloutfitgallery.h | 18 +- indra/newview/lloutfitslist.cpp | 10 +- indra/newview/lloutfitslist.h | 2 + indra/newview/lltexturectrl.cpp | 199 +++++++-------------- indra/newview/lltexturectrl.h | 141 ++++++++++++++- .../skins/default/xui/en/menu_outfit_gear.xml | 7 + 7 files changed, 339 insertions(+), 146 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 5bab133080..81ef8e96ec 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -42,6 +42,7 @@ #include "llinventoryfunctions.h" #include "llinventorymodel.h" #include "lllocalbitmaps.h" +#include "lltexturectrl.h" #include "llviewermenufile.h" #include "llwearableitemslist.h" @@ -552,13 +553,20 @@ BOOL LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) { + mImageAssetId = image_asset_id; mTexturep = LLViewerTextureManager::getFetchedTexture(image_asset_id); mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); } +LLUUID LLOutfitGalleryItem::getImageAssetId() +{ + return mImageAssetId; +} + void LLOutfitGalleryItem::setDefaultImage() { mTexturep = NULL; + mImageAssetId.setNull(); } LLOutfitGalleryGearMenu::LLOutfitGalleryGearMenu(LLOutfitListBase* olist) @@ -572,7 +580,7 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() mMenu->setItemVisible("expand", FALSE); mMenu->setItemVisible("collapse", FALSE); mMenu->setItemVisible("upload_photo", TRUE); - mMenu->setItemVisible("load_assets", TRUE); + mMenu->setItemVisible("select_photo", TRUE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } @@ -586,6 +594,20 @@ void LLOutfitGalleryGearMenu::onUploadFoto() } } +void LLOutfitGalleryGearMenu::onSelectPhoto() +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + LLUUID selected_outfit_id = getSelectedOutfitID(); + if (gallery && !selected_outfit_id.isNull()) + { + gallery->onSelectPhoto(selected_outfit_id); + } +} + +void LLOutfitGallery::onTextureSelectionChanged(LLInventoryItem* itemp) +{ +} + void LLOutfitGallery::loadPhotos() { //Iterate over inventory @@ -760,3 +782,87 @@ bool LLOutfitGallery::checkRemovePhoto(LLUUID outfit_id) void LLUpdateGalleryOnPhotoLinked::fire(const LLUUID& inv_item_id) { } + +LLUUID LLOutfitGallery::getPhotoAssetId(const LLUUID& outfit_id) +{ + outfit_map_t::iterator outfit_it = mOutfitMap.find(outfit_id); + if (outfit_it != mOutfitMap.end()) + { + return outfit_it->second->getImageAssetId(); + } + return LLUUID(); +} + +LLUUID LLOutfitGallery::getDefaultPhoto() +{ + return LLUUID(); +} + +void LLOutfitGallery::onTexturePickerCommit(LLTextureCtrl::ETexturePickOp op, LLUUID id) +{ + LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); + + if (floaterp && op == LLTextureCtrl::TEXTURE_SELECT) + { + LLUUID image_item_id; + if (id.notNull()) + { + image_item_id = id; + } + else + { + image_item_id = floaterp->findItemID(floaterp->getAssetID(), FALSE); + } + checkRemovePhoto(getSelectedOutfitUUID()); + linkPhotoToOutfit(image_item_id, getSelectedOutfitUUID()); + } +} + +void LLOutfitGallery::onSelectPhoto(LLUUID selected_outfit_id) +{ + if (selected_outfit_id.notNull()) + { + + // show hourglass cursor when loading inventory window + // because inventory construction is slooow + getWindow()->setCursor(UI_CURSOR_WAIT); + LLFloater* floaterp = mFloaterHandle.get(); + + // Show the dialog + if (floaterp) + { + floaterp->openFloater(); + } + else + { + floaterp = new LLFloaterTexturePicker( + this, + getPhotoAssetId(selected_outfit_id), + getPhotoAssetId(selected_outfit_id), + getPhotoAssetId(selected_outfit_id), + FALSE, + TRUE, + "SELECT PHOTO", + PERM_NONE, + PERM_NONE, + PERM_NONE, + FALSE, + NULL); + + mFloaterHandle = floaterp->getHandle(); + + LLFloaterTexturePicker* texture_floaterp = dynamic_cast(floaterp); + if (texture_floaterp) + { + texture_floaterp->setTextureSelectedCallback(boost::bind(&LLOutfitGallery::onTextureSelectionChanged, this, _1)); + } + if (texture_floaterp) + { + texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLOutfitGallery::onTexturePickerCommit, this, _1, _2)); + } + + floaterp->openFloater(); + } + floaterp->setFocus(TRUE); + } +} diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index e9b0fecae7..e874776e3e 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -33,6 +33,7 @@ #include "lllayoutstack.h" #include "lloutfitslist.h" #include "llpanelappearancetab.h" +#include "lltexturectrl.h" #include "llviewertexture.h" #include @@ -81,6 +82,8 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& info); + + void onSelectPhoto(LLUUID selected_outfit_id); /*virtual*/ void setFilterSubString(const std::string& string); @@ -97,6 +100,7 @@ public: void refreshTextures(const LLUUID& category_id); void refreshOutfit(const LLUUID& category_id); + void onTexturePickerCommit(LLTextureCtrl::ETexturePickOp op, LLUUID id); protected: /*virtual*/ void onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id); /*virtual*/ void onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid); @@ -110,6 +114,8 @@ protected: private: void loadPhotos(); void uploadPhoto(LLUUID outfit_id); + LLUUID getPhotoAssetId(const LLUUID& outfit_id); + LLUUID getDefaultPhoto(); void linkPhotoToOutfit(LLUUID outfit_id, LLUUID photo_id); bool checkRemovePhoto(LLUUID outfit_id); void addToGallery(LLOutfitGalleryItem* item); @@ -124,6 +130,9 @@ private: void removeFromLastRow(LLOutfitGalleryItem* item); LLOutfitGalleryItem* buildGalleryItem(std::string name); + + void onTextureSelectionChanged(LLInventoryItem* itemp); + void buildGalleryPanel(int row_count); void reshapeGalleryPanel(int row_count); LLPanel* buildItemPanel(int left); @@ -151,12 +160,11 @@ private: int mRowPanelWidth; int mGalleryWidth; + LLHandle mFloaterHandle; + typedef std::map outfit_map_t; typedef outfit_map_t::value_type outfit_map_value_t; outfit_map_t mOutfitMap; - typedef std::map texture_map_t; - typedef texture_map_t::value_type texture_map_value_t; - texture_map_t mTextureMap; typedef std::map item_num_map_t; typedef item_num_map_t::value_type item_numb_map_value_t; item_num_map_t mItemIndexMap; @@ -174,9 +182,9 @@ public: protected: /*virtual*/ void onUpdateItemsVisibility(); - private: /*virtual*/ void onUploadFoto(); + /*virtual*/ void onSelectPhoto(); }; class LLOutfitGalleryItem : public LLPanel @@ -194,11 +202,13 @@ public: void setDefaultImage(); void setImageAssetId(LLUUID asset_id); + LLUUID getImageAssetId(); void setOutfitName(std::string name); void setOutfitWorn(bool value); void setSelected(bool value); private: LLPointer mTexturep; + LLUUID mImageAssetId; LLTextBox* mOutfitNameText; LLTextBox* mOutfitWornText; LLPanel* mTextBgPanel; diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index a7636fc368..b657d2e285 100755 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -1091,7 +1091,8 @@ LLOutfitListGearMenuBase::LLOutfitListGearMenuBase(LLOutfitListBase* olist) registrar.add("Gear.WearAdd", boost::bind(&LLOutfitListGearMenuBase::onAdd, this)); registrar.add("Gear.UploadPhoto", boost::bind(&LLOutfitListGearMenuBase::onUploadFoto, this)); - + registrar.add("Gear.SelectPhoto", boost::bind(&LLOutfitListGearMenuBase::onSelectPhoto, this)); + enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenuBase::onEnable, this, _2)); enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenuBase::onVisible, this, _2)); @@ -1229,6 +1230,11 @@ void LLOutfitListGearMenuBase::onUploadFoto() } +void LLOutfitListGearMenuBase::onSelectPhoto() +{ + +} + LLOutfitListGearMenu::LLOutfitListGearMenu(LLOutfitListBase* olist) : LLOutfitListGearMenuBase(olist) {} @@ -1242,7 +1248,7 @@ void LLOutfitListGearMenu::onUpdateItemsVisibility() mMenu->setItemVisible("expand", TRUE); mMenu->setItemVisible("collapse", TRUE); mMenu->setItemVisible("upload_photo", FALSE); - mMenu->setItemVisible("load_assets", TRUE); + mMenu->setItemVisible("select_photo", FALSE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index 6db3efa70d..d7c549c417 100755 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -164,6 +164,8 @@ public: protected: virtual void onUpdateItemsVisibility(); virtual void onUploadFoto(); + virtual void onSelectPhoto(); + const LLUUID& getSelectedOutfitID(); LLOutfitListBase* mOutfitList; diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 1e9d0f912f..ee98ad0c4f 100755 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -37,8 +37,6 @@ #include "llbutton.h" #include "lldraghandle.h" #include "llfocusmgr.h" -#include "llviewertexture.h" -#include "llfolderview.h" #include "llfolderviewmodel.h" #include "llinventory.h" #include "llinventoryfunctions.h" @@ -83,118 +81,13 @@ static const S32 LOCAL_TRACKING_ID_COLUMN = 1; //static const char WHITE_IMAGE_NAME[] = "Blank Texture"; //static const char NO_IMAGE_NAME[] = "None"; -////////////////////////////////////////////////////////////////////////////////////////// -// LLFloaterTexturePicker - -class LLFloaterTexturePicker : public LLFloater -{ -public: - LLFloaterTexturePicker( - LLTextureCtrl* owner, - const std::string& label, - PermissionMask immediate_filter_perm_mask, - PermissionMask dnd_filter_perm_mask, - PermissionMask non_immediate_filter_perm_mask, - BOOL can_apply_immediately, - LLUIImagePtr fallback_image_name); - - virtual ~LLFloaterTexturePicker(); - - // LLView overrides - /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, - BOOL drop, EDragAndDropType cargo_type, void *cargo_data, - EAcceptance *accept, - std::string& tooltip_msg); - /*virtual*/ void draw(); - /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); - - // LLFloater overrides - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onClose(bool app_settings); - - // New functions - void setImageID( const LLUUID& image_asset_id, bool set_selection = true); - void updateImageStats(); - const LLUUID& getAssetID() { return mImageAssetID; } - const LLUUID& findItemID(const LLUUID& asset_id, BOOL copyable_only); - void setCanApplyImmediately(BOOL b); - - void setActive( BOOL active ); - - LLTextureCtrl* getOwner() const { return mOwner; } - void setOwner(LLTextureCtrl* owner) { mOwner = owner; } - - void stopUsingPipette(); - PermissionMask getFilterPermMask(); - void updateFilterPermMask(); - void commitIfImmediateSet(); - void commitCancel(); - - void onFilterEdit(const std::string& search_string ); - - void setCanApply(bool can_preview, bool can_apply); - void setTextureSelectedCallback(texture_selected_callback cb) {mTextureSelectedCallback = cb;} - - static void onBtnSetToDefault( void* userdata ); - static void onBtnSelect( void* userdata ); - static void onBtnCancel( void* userdata ); - void onBtnPipette( ); - //static void onBtnRevert( void* userdata ); - static void onBtnBlank( void* userdata ); - static void onBtnNone( void* userdata ); - static void onBtnClear( void* userdata ); - void onSelectionChange(const std::deque &items, BOOL user_action); - static void onShowFolders(LLUICtrl* ctrl, void* userdata); - static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); - void onTextureSelect( const LLTextureEntry& te ); - - static void onModeSelect(LLUICtrl* ctrl, void *userdata); - static void onBtnAdd(void* userdata); - static void onBtnRemove(void* userdata); - static void onBtnUpload(void* userdata); - static void onLocalScrollCommit(LLUICtrl* ctrl, void* userdata); - -protected: - LLPointer mTexturep; - LLTextureCtrl* mOwner; - - LLUUID mImageAssetID; // Currently selected texture - LLUIImagePtr mFallbackImage; // What to show if currently selected texture is null. - - LLUUID mSpecialCurrentImageAssetID; // Used when the asset id has no corresponding texture in the user's inventory. - LLUUID mOriginalImageAssetID; - - std::string mLabel; - - LLTextBox* mTentativeLabel; - LLTextBox* mResolutionLabel; - - std::string mPendingName; - BOOL mActive; - - LLFilterEditor* mFilterEdit; - LLInventoryPanel* mInventoryPanel; - PermissionMask mImmediateFilterPermMask; - PermissionMask mDnDFilterPermMask; - PermissionMask mNonImmediateFilterPermMask; - BOOL mCanApplyImmediately; - BOOL mNoCopyTextureSelected; - F32 mContextConeOpacity; - LLSaveFolderState mSavedFolderState; - BOOL mSelectedItemPinned; - - LLRadioGroup* mModeSelector; - LLScrollListCtrl* mLocalScrollCtrl; - -private: - bool mCanApply; - bool mCanPreview; - bool mPreviewSettingChanged; - texture_selected_callback mTextureSelectedCallback; -}; - LLFloaterTexturePicker::LLFloaterTexturePicker( - LLTextureCtrl* owner, + LLView* owner, + LLUUID image_asset_id, + LLUUID default_image_asset_id, + LLUUID blank_image_asset_id, + BOOL tentative, + BOOL allow_no_texture, const std::string& label, PermissionMask immediate_filter_perm_mask, PermissionMask dnd_filter_perm_mask, @@ -203,9 +96,13 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( LLUIImagePtr fallback_image) : LLFloater(LLSD()), mOwner( owner ), - mImageAssetID( owner->getImageAssetID() ), - mFallbackImage( fallback_image ), - mOriginalImageAssetID(owner->getImageAssetID()), + mImageAssetID( image_asset_id ), + mOriginalImageAssetID(image_asset_id), + mFallbackImage(fallback_image), + mDefaultImageAssetID(default_image_asset_id), + mBlankImageAssetID(blank_image_asset_id), + mTentative(tentative), + mAllowNoTexture(allow_no_texture), mLabel(label), mTentativeLabel(NULL), mResolutionLabel(NULL), @@ -218,7 +115,10 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mSelectedItemPinned( FALSE ), mCanApply(true), mCanPreview(true), - mPreviewSettingChanged(false) + mPreviewSettingChanged(false), + mOnFloaterCommitCallback(NULL), + mOnFloaterCloseCallback(NULL), + mSetImageAssetIDCallback(NULL) { buildFromFile("floater_texture_ctrl.xml"); mCanApplyImmediately = can_apply_immediately; @@ -401,9 +301,9 @@ BOOL LLFloaterTexturePicker::handleKeyHere(KEY key, MASK mask) void LLFloaterTexturePicker::onClose(bool app_quitting) { - if (mOwner) + if (mOnFloaterCloseCallback) { - mOwner->onFloaterClose(); + mOnFloaterCloseCallback(); } stopUsingPipette(); } @@ -584,9 +484,9 @@ void LLFloaterTexturePicker::draw() mTentativeLabel->setVisible( FALSE ); } - getChildView("Default")->setEnabled(mImageAssetID != mOwner->getDefaultImageAssetID() || mOwner->getTentative()); - getChildView("Blank")->setEnabled(mImageAssetID != mOwner->getBlankImageAssetID() || mOwner->getTentative()); - getChildView("None")->setEnabled(mOwner->getAllowNoTexture() && (!mImageAssetID.isNull() || mOwner->getTentative())); + getChildView("Default")->setEnabled(mImageAssetID != mDefaultImageAssetID || mTentative); + getChildView("Blank")->setEnabled(mImageAssetID != mBlankImageAssetID || mTentative); + getChildView("None")->setEnabled(mAllowNoTexture && (!mImageAssetID.isNull() || mTentative)); LLFloater::draw(); @@ -631,7 +531,7 @@ void LLFloaterTexturePicker::draw() } // Draw Tentative Label over the image - if( mOwner->getTentative() && !mViewModel->isDirty() ) + if( mTentative && !mViewModel->isDirty() ) { mTentativeLabel->setVisible( TRUE ); drawChild(mTentativeLabel); @@ -706,17 +606,17 @@ PermissionMask LLFloaterTexturePicker::getFilterPermMask() void LLFloaterTexturePicker::commitIfImmediateSet() { - if (!mNoCopyTextureSelected && mOwner && mCanApply) + if (!mNoCopyTextureSelected && mOnFloaterCommitCallback && mCanApply) { - mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CHANGE); + mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, LLUUID::null); } } void LLFloaterTexturePicker::commitCancel() { - if (!mNoCopyTextureSelected && mOwner && mCanApply) + if (!mNoCopyTextureSelected && mOnFloaterCommitCallback && mCanApply) { - mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CANCEL); + mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, LLUUID::null); } } @@ -727,7 +627,7 @@ void LLFloaterTexturePicker::onBtnSetToDefault(void* userdata) self->setCanApply(true, true); if (self->mOwner) { - self->setImageID( self->mOwner->getDefaultImageAssetID() ); + self->setImageID( self->getDefaultImageAssetID() ); } self->commitIfImmediateSet(); } @@ -737,7 +637,7 @@ void LLFloaterTexturePicker::onBtnBlank(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; self->setCanApply(true, true); - self->setImageID( self->mOwner->getBlankImageAssetID() ); + self->setImageID( self->getBlankImageAssetID() ); self->commitIfImmediateSet(); } @@ -767,9 +667,9 @@ void LLFloaterTexturePicker::onBtnCancel(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; self->setImageID( self->mOriginalImageAssetID ); - if (self->mOwner) + if (self->mOnFloaterCommitCallback) { - self->mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CANCEL); + self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, LLUUID::null); } self->mViewModel->resetDirty(); self->closeFloater(); @@ -779,17 +679,18 @@ void LLFloaterTexturePicker::onBtnCancel(void* userdata) void LLFloaterTexturePicker::onBtnSelect(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; + LLUUID local_id = LLUUID::null; if (self->mOwner) { - LLUUID local_id = LLUUID::null; - if (self->mLocalScrollCtrl->getVisible() && !self->mLocalScrollCtrl->getAllSelected().empty()) { LLUUID temp_id = self->mLocalScrollCtrl->getFirstSelected()->getColumn(LOCAL_TRACKING_ID_COLUMN)->getValue().asUUID(); local_id = LLLocalBitmapMgr::getWorldID(temp_id); } - - self->mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_SELECT, local_id); + } + if (self->mOnFloaterCommitCallback) + { + self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_SELECT, local_id); } self->closeFloater(); } @@ -943,11 +844,17 @@ void LLFloaterTexturePicker::onLocalScrollCommit(LLUICtrl* ctrl, void* userdata) { LLUUID tracking_id = (LLUUID)self->mLocalScrollCtrl->getSelectedItemLabel(LOCAL_TRACKING_ID_COLUMN); LLUUID inworld_id = LLLocalBitmapMgr::getWorldID(tracking_id); - self->mOwner->setImageAssetID(inworld_id); + if (self->mSetImageAssetIDCallback) + { + self->mSetImageAssetIDCallback(inworld_id); + } if (self->childGetValue("apply_immediate_check").asBoolean()) { - self->mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CHANGE, inworld_id); + if (self->mOnFloaterCommitCallback) + { + self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, inworld_id); + } } } } @@ -1240,13 +1147,17 @@ void LLTextureCtrl::showPicker(BOOL take_focus) { floaterp = new LLFloaterTexturePicker( this, + getImageAssetID(), + getDefaultImageAssetID(), + getBlankImageAssetID(), + getTentative(), + getAllowNoTexture(), mLabel, mImmediateFilterPermMask, mDnDFilterPermMask, mNonImmediateFilterPermMask, mCanApplyImmediately, mFallbackImage); - mFloaterHandle = floaterp->getHandle(); LLFloaterTexturePicker* texture_floaterp = dynamic_cast(floaterp); @@ -1254,6 +1165,18 @@ void LLTextureCtrl::showPicker(BOOL take_focus) { texture_floaterp->setTextureSelectedCallback(mOnTextureSelectedCallback); } + if (texture_floaterp && mOnCloseCallback) + { + texture_floaterp->setOnFloaterCloseCallback(boost::bind(&LLTextureCtrl::onFloaterClose, this)); + } + if (texture_floaterp) + { + texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2)); + } + if (texture_floaterp) + { + texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1)); + } LLFloater* root_floater = gFloaterView->getParentFloater(this); if (root_floater) diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 15ca7bed92..3ea052ad57 100755 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -29,12 +29,20 @@ #define LL_LLTEXTURECTRL_H #include "llcoord.h" +#include "llfiltereditor.h" #include "llfloater.h" +#include "llfolderview.h" +#include "lllocalbitmaps.h" #include "llstring.h" #include "lluictrl.h" #include "llpermissionsflags.h" +#include "llradiogroup.h" #include "lltextbox.h" // for params +#include "llviewerinventory.h" #include "llviewborder.h" // for params +#include "llviewerobject.h" +#include "llviewertexture.h" +#include "llwindow.h" class LLButton; class LLFloaterTexturePicker; @@ -166,7 +174,7 @@ public: void closeDependentFloater(); void onFloaterClose(); - void onFloaterCommit(ETexturePickOp op, LLUUID id = LLUUID::null); + void onFloaterCommit(ETexturePickOp op, LLUUID id); // This call is returned when a drag is detected. Your callback // should return TRUE if the drag is acceptable. @@ -227,4 +235,135 @@ private: S32 mLabelWidth; }; +////////////////////////////////////////////////////////////////////////////////////////// +// LLFloaterTexturePicker +typedef boost::function floater_commit_callback; +typedef boost::function floater_close_callback; +typedef boost::function set_image_asset_id_callback; + +class LLFloaterTexturePicker : public LLFloater +{ +public: + LLFloaterTexturePicker( + LLView* owner, + LLUUID image_asset_id, + LLUUID default_image_asset_id, + LLUUID blank_image_asset_id, + BOOL tentative, + BOOL allow_no_texture, + const std::string& label, + PermissionMask immediate_filter_perm_mask, + PermissionMask dnd_filter_perm_mask, + PermissionMask non_immediate_filter_perm_mask, + BOOL can_apply_immediately, + LLUIImagePtr fallback_image_name + ); + + virtual ~LLFloaterTexturePicker(); + + // LLView overrides + /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, + BOOL drop, EDragAndDropType cargo_type, void *cargo_data, + EAcceptance *accept, + std::string& tooltip_msg); + /*virtual*/ void draw(); + /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); + + // LLFloater overrides + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onClose(bool app_settings); + + // New functions + void setImageID(const LLUUID& image_asset_id, bool set_selection = true); + void updateImageStats(); + const LLUUID& getAssetID() { return mImageAssetID; } + const LLUUID& findItemID(const LLUUID& asset_id, BOOL copyable_only); + void setCanApplyImmediately(BOOL b); + + void setActive(BOOL active); + + LLView* getOwner() const { return mOwner; } + void setOwner(LLView* owner) { mOwner = owner; } + void stopUsingPipette(); + PermissionMask getFilterPermMask(); + + void updateFilterPermMask(); + void commitIfImmediateSet(); + void commitCancel(); + + void onFilterEdit(const std::string& search_string); + + void setCanApply(bool can_preview, bool can_apply); + void setTextureSelectedCallback(const texture_selected_callback& cb) { mTextureSelectedCallback = cb; } + void setOnFloaterCloseCallback(const floater_close_callback& cb) { mOnFloaterCloseCallback = cb; } + void setOnFloaterCommitCallback(const floater_commit_callback& cb) { mOnFloaterCommitCallback = cb; } + void setSetImageAssetIDCallback(const set_image_asset_id_callback& cb) { mSetImageAssetIDCallback = cb; } + const LLUUID& getDefaultImageAssetID() { return mDefaultImageAssetID; } + const LLUUID& getBlankImageAssetID() { return mBlankImageAssetID; } + + static void onBtnSetToDefault(void* userdata); + static void onBtnSelect(void* userdata); + static void onBtnCancel(void* userdata); + void onBtnPipette(); + //static void onBtnRevert( void* userdata ); + static void onBtnBlank(void* userdata); + static void onBtnNone(void* userdata); + static void onBtnClear(void* userdata); + void onSelectionChange(const std::deque &items, BOOL user_action); + static void onShowFolders(LLUICtrl* ctrl, void* userdata); + static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); + void onTextureSelect(const LLTextureEntry& te); + + static void onModeSelect(LLUICtrl* ctrl, void *userdata); + static void onBtnAdd(void* userdata); + static void onBtnRemove(void* userdata); + static void onBtnUpload(void* userdata); + static void onLocalScrollCommit(LLUICtrl* ctrl, void* userdata); + +protected: + LLPointer mTexturep; + LLView* mOwner; + + LLUUID mImageAssetID; // Currently selected texture + LLUIImagePtr mFallbackImage; // What to show if currently selected texture is null. + LLUUID mDefaultImageAssetID; + LLUUID mBlankImageAssetID; + BOOL mTentative; + BOOL mAllowNoTexture; + LLUUID mSpecialCurrentImageAssetID; // Used when the asset id has no corresponding texture in the user's inventory. + LLUUID mOriginalImageAssetID; + + std::string mLabel; + + LLTextBox* mTentativeLabel; + LLTextBox* mResolutionLabel; + + std::string mPendingName; + BOOL mActive; + + LLFilterEditor* mFilterEdit; + LLInventoryPanel* mInventoryPanel; + PermissionMask mImmediateFilterPermMask; + PermissionMask mDnDFilterPermMask; + PermissionMask mNonImmediateFilterPermMask; + BOOL mCanApplyImmediately; + BOOL mNoCopyTextureSelected; + F32 mContextConeOpacity; + LLSaveFolderState mSavedFolderState; + BOOL mSelectedItemPinned; + + LLRadioGroup* mModeSelector; + LLScrollListCtrl* mLocalScrollCtrl; + +private: + bool mCanApply; + bool mCanPreview; + bool mPreviewSettingChanged; + + texture_selected_callback mTextureSelectedCallback; + floater_close_callback mOnFloaterCloseCallback; + floater_commit_callback mOnFloaterCommitCallback; + set_image_asset_id_callback mSetImageAssetIDCallback; +}; + #endif // LL_LLTEXTURECTRL_H 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 e31ff2a6e2..23133d4f7c 100755 --- a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml @@ -46,6 +46,13 @@ + + + -- cgit v1.3 From bb06bcb1eae78ce3811761f057c8060e7575192d Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Thu, 14 Apr 2016 16:36:30 +0300 Subject: MAINT-6254 FIXED Default gallery thumbnail shows thru the outfit gallery image --- indra/newview/lloutfitgallery.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 81ef8e96ec..175fd652c5 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -556,6 +556,7 @@ void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) mImageAssetId = image_asset_id; mTexturep = LLViewerTextureManager::getFetchedTexture(image_asset_id); mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); + getChildView("preview_outfit")->setVisible(FALSE); } LLUUID LLOutfitGalleryItem::getImageAssetId() @@ -567,6 +568,7 @@ void LLOutfitGalleryItem::setDefaultImage() { mTexturep = NULL; mImageAssetId.setNull(); + getChildView("preview_outfit")->setVisible(TRUE); } LLOutfitGalleryGearMenu::LLOutfitGalleryGearMenu(LLOutfitListBase* olist) -- cgit v1.3 From 8c98c8e1cb3a040bef7b2c93111034358099bca2 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Tue, 19 Apr 2016 19:08:25 +0300 Subject: MAINT-6303 Outfit browser should add columns after window is resized --- indra/newview/lloutfitgallery.cpp | 46 ++++++++++++++++++++++++++++++++++++--- indra/newview/lloutfitgallery.h | 5 +++++ 2 files changed, 48 insertions(+), 3 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') 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 buf_items = mItems; + for (std::vector::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::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 mFloaterHandle; -- cgit v1.3 From 8d265cd59f0c141ae5fb5eadc0ef5e9007a38e29 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Fri, 22 Apr 2016 17:01:56 +0300 Subject: MAINT-6229 Organize Outfit Browser thumbnails --- indra/newview/lloutfitgallery.cpp | 32 +++++++++++++++++++++++++------- indra/newview/lloutfitgallery.h | 24 +++++++++++++++++++++++- 2 files changed, 48 insertions(+), 8 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index dfb5a3d5a8..9a9993f58c 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -69,8 +69,7 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) mRowPanWidthFactor(p.row_panel_width_factor), mGalleryWidthFactor(p.gallery_width_factor) { - mRowPanelWidth = mRowPanWidthFactor * mItemsInRow; - mGalleryWidth = mGalleryWidthFactor * mItemsInRow; + updateGalleryWidth(); } LLOutfitGallery::Params::Params() @@ -115,6 +114,7 @@ void LLOutfitGallery::onOpen(const LLSD& info) { addToGallery(mOutfitMap[cats[i]]); } + reArrangeRows(); mGalleryCreated = true; } } @@ -122,7 +122,10 @@ void LLOutfitGallery::onOpen(const LLSD& info) void LLOutfitGallery::draw() { LLPanel::draw(); - updateRowsIfNeeded(); + if (mGalleryCreated) + { + updateRowsIfNeeded(); + } } void LLOutfitGallery::updateRowsIfNeeded() @@ -147,16 +150,21 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff) } mItemsInRow+= row_diff; + updateGalleryWidth(); + std::sort(buf_items.begin(), buf_items.end(), LLOutfitGalleryItem::compareGalleryItem()); - mRowPanelWidth = mRowPanWidthFactor * mItemsInRow; - mGalleryWidth = mGalleryWidthFactor * mItemsInRow; - for (std::vector::const_iterator it = buf_items.begin(); it != buf_items.end(); ++it) { addToGallery(*it); } } +void LLOutfitGallery::updateGalleryWidth() +{ + mRowPanelWidth = mRowPanWidthFactor * mItemsInRow; + mGalleryWidth = mGalleryWidthFactor * mItemsInRow; +} + LLPanel* LLOutfitGallery::addLastRow() { mRowCount++; @@ -515,7 +523,9 @@ LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p) : LLPanel(p), mTexturep(NULL), mSelected(false), - mWorn(false) + mWorn(false), + mDefaultImage(true), + mOutfitName("") { buildFromFile("panel_outfit_gallery_item.xml"); } @@ -565,6 +575,7 @@ void LLOutfitGalleryItem::draw() void LLOutfitGalleryItem::setOutfitName(std::string name) { mOutfitNameText->setText(name); + mOutfitName = name; } void LLOutfitGalleryItem::setOutfitWorn(bool value) @@ -597,6 +608,7 @@ void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) mTexturep = LLViewerTextureManager::getFetchedTexture(image_asset_id); mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); getChildView("preview_outfit")->setVisible(FALSE); + mDefaultImage = false; } LLUUID LLOutfitGalleryItem::getImageAssetId() @@ -609,6 +621,7 @@ void LLOutfitGalleryItem::setDefaultImage() mTexturep = NULL; mImageAssetId.setNull(); getChildView("preview_outfit")->setVisible(TRUE); + mDefaultImage = true; } LLOutfitGalleryGearMenu::LLOutfitGalleryGearMenu(LLOutfitListBase* olist) @@ -711,6 +724,11 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } } } + + if (mGalleryCreated) + { + reArrangeRows(); + } } void LLOutfitGallery::refreshTextures(const LLUUID& category_id) diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 1b6878bce3..285c8baf59 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -129,8 +129,9 @@ 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 reArrangeRows(S32 row_diff = 0); void updateRowsIfNeeded(); + void updateGalleryWidth(); LLOutfitGalleryItem* buildGalleryItem(std::string name); @@ -211,6 +212,25 @@ public: void setOutfitName(std::string name); void setOutfitWorn(bool value); void setSelected(bool value); + + std::string getItemName() {return mOutfitName;} + bool mIsDefaultImage() {return mDefaultImage;} + + struct compareGalleryItem + { + bool operator()(LLOutfitGalleryItem* a, LLOutfitGalleryItem* b) + { + if((a->mIsDefaultImage() && b->mIsDefaultImage()) || (!a->mIsDefaultImage() && !b->mIsDefaultImage())) + { + return a->getItemName().compare(b->getItemName()) < 0; + } + else + { + return b->mIsDefaultImage(); + } + } + }; + private: LLPointer mTexturep; LLUUID mImageAssetId; @@ -220,6 +240,8 @@ private: LLPanel* mFotoBgPanel; bool mSelected; bool mWorn; + bool mDefaultImage; + std::string mOutfitName; }; #endif // LL_LLOUTFITGALLERYCTRL_H -- cgit v1.3 From f70be72ad614f2e7b2b2773c413249137662f570 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Fri, 22 Apr 2016 18:21:18 +0300 Subject: MAINT-6303 Width was changed to appropriate value --- indra/newview/lloutfitgallery.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 9a9993f58c..c553d3d338 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -161,8 +161,8 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff) void LLOutfitGallery::updateGalleryWidth() { - mRowPanelWidth = mRowPanWidthFactor * mItemsInRow; - mGalleryWidth = mGalleryWidthFactor * mItemsInRow; + mRowPanelWidth = mRowPanWidthFactor * mItemsInRow - mItemHorizontalGap; + mGalleryWidth = mGalleryWidthFactor * mItemsInRow - mItemHorizontalGap; } LLPanel* LLOutfitGallery::addLastRow() -- cgit v1.3 From 4125bebce7116e074aef664026b9ed33ffa9ca19 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Fri, 29 Apr 2016 20:28:11 +0300 Subject: MAINT-6226 Incorporate a customized Snapshot feature to Outfit Browser flow Initial version, further refactoring pending --- indra/newview/CMakeLists.txt | 2 + indra/newview/llappviewer.cpp | 3 + indra/newview/llassetuploadresponders.cpp | 11 +- indra/newview/llfloaterfacebook.cpp | 2 +- indra/newview/llfloaterflickr.cpp | 2 +- indra/newview/llfloateroutfitsnapshot.cpp | 1586 ++++++++++++++++++++ indra/newview/llfloateroutfitsnapshot.h | 110 ++ indra/newview/llfloatersnapshot.cpp | 110 +- indra/newview/llfloatersnapshot.h | 49 +- indra/newview/llfloatertwitter.cpp | 2 +- indra/newview/lloutfitgallery.cpp | 51 +- indra/newview/lloutfitgallery.h | 5 + indra/newview/lloutfitslist.cpp | 7 + indra/newview/lloutfitslist.h | 1 + indra/newview/llpanelsnapshot.cpp | 18 +- indra/newview/llpanelsnapshot.h | 11 +- indra/newview/llpanelsnapshotinventory.cpp | 112 +- indra/newview/llpanelsnapshotlocal.cpp | 19 +- indra/newview/llpanelsnapshotpostcard.cpp | 11 +- indra/newview/llpanelsnapshotprofile.cpp | 2 +- indra/newview/llsnapshotlivepreview.cpp | 36 +- indra/newview/llsnapshotlivepreview.h | 22 +- indra/newview/llviewerfloaterreg.cpp | 4 +- indra/newview/llviewermenufile.cpp | 2 +- .../default/xui/en/floater_outfit_snapshot.xml | 462 ++++++ .../skins/default/xui/en/menu_outfit_gear.xml | 9 +- .../xui/en/panel_outfit_snapshot_inventory.xml | 147 ++ 27 files changed, 2688 insertions(+), 108 deletions(-) create mode 100644 indra/newview/llfloateroutfitsnapshot.cpp create mode 100644 indra/newview/llfloateroutfitsnapshot.h create mode 100644 indra/newview/skins/default/xui/en/floater_outfit_snapshot.xml create mode 100644 indra/newview/skins/default/xui/en/panel_outfit_snapshot_inventory.xml (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 6567654a9d..595a9a5e21 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -271,6 +271,7 @@ set(viewer_SOURCE_FILES llfloaternamedesc.cpp llfloaternotificationsconsole.cpp llfloaternotificationstabbed.cpp + llfloateroutfitsnapshot.cpp llfloaterobjectweights.cpp llfloateropenobject.cpp llfloateroutbox.cpp @@ -894,6 +895,7 @@ set(viewer_HEADER_FILES llfloaternamedesc.h llfloaternotificationsconsole.h llfloaternotificationstabbed.h + llfloateroutfitsnapshot.h llfloaterobjectweights.h llfloateropenobject.h llfloateroutbox.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 2898d8ca31..1887adc97e 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -203,6 +203,7 @@ #include "llcommandlineparser.h" #include "llfloatermemleak.h" #include "llfloaterreg.h" +#include "llfloateroutfitsnapshot.h" #include "llfloatersnapshot.h" #include "llfloaterinventory.h" @@ -1471,6 +1472,8 @@ bool LLAppViewer::mainLoop() display(); pingMainloopTimeout("Main:Snapshot"); LLFloaterSnapshot::update(); // take snapshots + //TODO: Make one call by moving LLFloaterOutfitSnapshot::update() to LLFloaterSnapshotBase class + LLFloaterOutfitSnapshot::update(); gGLActive = FALSE; } } diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index 121ce647a6..86576538ec 100755 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -178,9 +178,14 @@ void on_new_single_inventory_upload_complete( // Let the Snapshot floater know we have finished uploading a snapshot to inventory. LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); - if (asset_type == LLAssetType::AT_TEXTURE && floater_snapshot) - { - floater_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); + if (asset_type == LLAssetType::AT_TEXTURE && floater_snapshot && floater_snapshot->isShown()) + { + floater_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); + } + LLFloater* floater_outfit_snapshot = LLFloaterReg::findInstance("outfit_snapshot"); + if (asset_type == LLAssetType::AT_TEXTURE && floater_outfit_snapshot && floater_outfit_snapshot->isShown()) + { + floater_outfit_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); } } diff --git a/indra/newview/llfloaterfacebook.cpp b/indra/newview/llfloaterfacebook.cpp index da85d378b2..ff6e342d62 100644 --- a/indra/newview/llfloaterfacebook.cpp +++ b/indra/newview/llfloaterfacebook.cpp @@ -488,7 +488,7 @@ void LLFacebookPhotoPanel::onVisibilityChange(BOOL visible) mQuality = MAX_QUALITY; previewp->setContainer(this); - previewp->setSnapshotType(previewp->SNAPSHOT_WEB); + previewp->setSnapshotType(LLPanelSnapshot::SNAPSHOT_WEB); previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); previewp->setSnapshotQuality(mQuality, false); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp index cd132b843d..131df22956 100644 --- a/indra/newview/llfloaterflickr.cpp +++ b/indra/newview/llfloaterflickr.cpp @@ -238,7 +238,7 @@ void LLFlickrPhotoPanel::onVisibilityChange(BOOL visible) mPreviewHandle = previewp->getHandle(); previewp->setContainer(this); - previewp->setSnapshotType(previewp->SNAPSHOT_WEB); + previewp->setSnapshotType(LLPanelSnapshot::SNAPSHOT_WEB); previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp new file mode 100644 index 0000000000..8fa54e7f94 --- /dev/null +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -0,0 +1,1586 @@ +/** + * @file llfloatersnapshot.cpp + * @brief Snapshot preview window for saving as an outfit thumbnail in visual outfit gallery + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2016, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatersnapshot.h" +#include "llfloateroutfitsnapshot.h" + +#include "llagent.h" +#include "llfacebookconnect.h" +#include "llfloaterreg.h" +#include "llfloaterfacebook.h" +#include "llfloaterflickr.h" +#include "llfloatertwitter.h" +#include "llimagefiltersmanager.h" +#include "llcheckboxctrl.h" +#include "llcombobox.h" +#include "llpostcard.h" +#include "llresmgr.h" // LLLocale +#include "llsdserialize.h" +#include "llsidetraypanelcontainer.h" +#include "llsnapshotlivepreview.h" +#include "llspinctrl.h" +#include "llviewercontrol.h" +#include "lltoolfocus.h" +#include "lltoolmgr.h" +#include "llwebprofile.h" + +///---------------------------------------------------------------------------- +/// Local function declarations, constants, enums, and typedefs +///---------------------------------------------------------------------------- +LLUICtrl* LLFloaterOutfitSnapshot::sThumbnailPlaceholder = NULL; +LLOutfitSnapshotFloaterView* gOutfitSnapshotFloaterView = NULL; + +const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; + +const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte +const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 + +static LLDefaultChildRegistry::Register r("snapshot_outfit_floater_view"); + + +///---------------------------------------------------------------------------- +/// Class LLFloaterSnapshot::Impl +///---------------------------------------------------------------------------- + + +class LLFloaterOutfitSnapshot::Impl +{ + LOG_CLASS(LLFloaterOutfitSnapshot::Impl); +public: + typedef enum e_status + { + STATUS_READY, + STATUS_WORKING, + STATUS_FINISHED + } EStatus; + + Impl() + : mAvatarPauseHandles(), + mLastToolset(NULL), + mAspectRatioCheckOff(false), + mNeedRefresh(false), + mStatus(STATUS_READY) + { + } + ~Impl() + { + //unpause avatars + mAvatarPauseHandles.clear(); + + } + static void onClickNewSnapshot(void* data); + static void onClickAutoSnap(LLUICtrl *ctrl, void* data); + static void onClickFilter(LLUICtrl *ctrl, void* data); + //static void onClickAdvanceSnap(LLUICtrl *ctrl, void* data); + static void onClickUICheck(LLUICtrl *ctrl, void* data); + static void onClickHUDCheck(LLUICtrl *ctrl, void* data); + static void applyKeepAspectCheck(LLFloaterOutfitSnapshot* view, BOOL checked); + static void updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update = TRUE); + static void onCommitFreezeFrame(LLUICtrl* ctrl, void* data); + static void onCommitLayerTypes(LLUICtrl* ctrl, void*data); + static void onImageQualityChange(LLFloaterOutfitSnapshot* view, S32 quality_val); + static void onImageFormatChange(LLFloaterOutfitSnapshot* view); + static void applyCustomResolution(LLFloaterOutfitSnapshot* view, S32 w, S32 h); + static void onSnapshotUploadFinished(bool status); + static void onSendingPostcardFinished(bool status); + static BOOL checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value); + static void setImageSizeSpinnersValues(LLFloaterOutfitSnapshot *view, S32 width, S32 height) ; + static void updateSpinners(LLFloaterOutfitSnapshot* view, LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL is_width_changed); + + static LLPanelSnapshot* getActivePanel(LLFloaterOutfitSnapshot* floater, bool ok_if_not_found = true); + static LLPanelSnapshot::ESnapshotType getActiveSnapshotType(LLFloaterOutfitSnapshot* floater); + static LLFloaterOutfitSnapshot::ESnapshotFormat getImageFormat(LLFloaterOutfitSnapshot* floater); + static LLSpinCtrl* getWidthSpinner(LLFloaterOutfitSnapshot* floater); + static LLSpinCtrl* getHeightSpinner(LLFloaterOutfitSnapshot* floater); + static void enableAspectRatioCheckbox(LLFloaterOutfitSnapshot* floater, BOOL enable); + static void setAspectRatioCheckboxValue(LLFloaterOutfitSnapshot* floater, BOOL checked); + + static LLSnapshotLivePreview* getPreviewView(LLFloaterOutfitSnapshot *floater); + static void setResolution(LLFloaterOutfitSnapshot* floater, const std::string& comboname); + static void updateControls(LLFloaterOutfitSnapshot* floater); + static void updateLayout(LLFloaterOutfitSnapshot* floater); + static void setStatus(EStatus status, bool ok = true, const std::string& msg = LLStringUtil::null); + EStatus getStatus() const { return mStatus; } + static void setNeedRefresh(LLFloaterOutfitSnapshot* floater, bool need); + +private: + static LLViewerWindow::ESnapshotType getLayerType(LLFloaterOutfitSnapshot* floater); + static void comboSetCustom(LLFloaterOutfitSnapshot *floater, const std::string& comboname); + static void checkAutoSnapshot(LLSnapshotLivePreview* floater, BOOL update_thumbnail = FALSE); + static void checkAspectRatio(LLFloaterOutfitSnapshot *view, S32 index) ; + static void setWorking(LLFloaterOutfitSnapshot* floater, bool working); + static void setFinished(LLFloaterOutfitSnapshot* floater, bool finished, bool ok = true, const std::string& msg = LLStringUtil::null); + + +public: + std::vector mAvatarPauseHandles; + + LLToolset* mLastToolset; + LLHandle mPreviewHandle; + bool mAspectRatioCheckOff ; + bool mNeedRefresh; + EStatus mStatus; +}; + + + +// static +LLPanelSnapshot* LLFloaterOutfitSnapshot::Impl::getActivePanel(LLFloaterOutfitSnapshot* floater, bool ok_if_not_found) +{ + LLPanel* panel = floater->getChild("panel_outfit_snapshot_inventory"); + //LLPanel* panel = panel_container->getCurrentPanel(); + LLPanelSnapshot* active_panel = dynamic_cast(panel); + if (!ok_if_not_found) + { + llassert_always(active_panel != NULL); + } + return active_panel; +} + +// static +LLPanelSnapshot::ESnapshotType LLFloaterOutfitSnapshot::Impl::getActiveSnapshotType(LLFloaterOutfitSnapshot* floater) +{ + //LLSnapshotLivePreview::ESnapshotType type = LLSnapshotLivePreview::SNAPSHOT_WEB; + //std::string name; + LLPanelSnapshot* spanel = getActivePanel(floater); + + //if (spanel) + //{ + // name = spanel->getName(); + //} + + //if (name == "panel_snapshot_postcard") + //{ + // type = LLSnapshotLivePreview::SNAPSHOT_POSTCARD; + //} + //else if (name == "panel_snapshot_inventory") + //{ + // type = LLSnapshotLivePreview::SNAPSHOT_TEXTURE; + //} + //else if (name == "panel_snapshot_local") + //{ + // type = LLSnapshotLivePreview::SNAPSHOT_LOCAL; + //} + + //return type; + if (spanel) + { + return spanel->getSnapshotType(); + } + return LLPanelSnapshot::SNAPSHOT_WEB; +} + +// static +LLFloaterOutfitSnapshot::ESnapshotFormat LLFloaterOutfitSnapshot::Impl::getImageFormat(LLFloaterOutfitSnapshot* floater) +{ + //LLPanelSnapshot* active_panel = getActivePanel(floater); + // FIXME: if the default is not PNG, profile uploads may fail. + //return active_panel ? active_panel->getImageFormat() : LLFloaterOutfitSnapshot::SNAPSHOT_FORMAT_PNG; + return LLFloaterOutfitSnapshot::SNAPSHOT_FORMAT_PNG; +} + +// static +LLSpinCtrl* LLFloaterOutfitSnapshot::Impl::getWidthSpinner(LLFloaterOutfitSnapshot* floater) +{ + LLPanelSnapshot* active_panel = getActivePanel(floater); + return active_panel ? active_panel->getWidthSpinner() : floater->getChild("snapshot_width"); +} + +// static +LLSpinCtrl* LLFloaterOutfitSnapshot::Impl::getHeightSpinner(LLFloaterOutfitSnapshot* floater) +{ + LLPanelSnapshot* active_panel = getActivePanel(floater); + return active_panel ? active_panel->getHeightSpinner() : floater->getChild("snapshot_height"); +} + +// static +void LLFloaterOutfitSnapshot::Impl::enableAspectRatioCheckbox(LLFloaterOutfitSnapshot* floater, BOOL enable) +{ + LLPanelSnapshot* active_panel = getActivePanel(floater); + if (active_panel) + { + active_panel->enableAspectRatioCheckbox(enable); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::setAspectRatioCheckboxValue(LLFloaterOutfitSnapshot* floater, BOOL checked) +{ + LLPanelSnapshot* active_panel = getActivePanel(floater); + if (active_panel) + { + active_panel->getChild(active_panel->getAspectRatioCBName())->setValue(checked); + } +} + +// static +LLSnapshotLivePreview* LLFloaterOutfitSnapshot::Impl::getPreviewView(LLFloaterOutfitSnapshot *floater) +{ + LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)floater->impl.mPreviewHandle.get(); + return previewp; +} + +// static +LLViewerWindow::ESnapshotType LLFloaterOutfitSnapshot::Impl::getLayerType(LLFloaterOutfitSnapshot* floater) +{ + LLViewerWindow::ESnapshotType type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + LLSD value = floater->getChild("layer_types")->getValue(); + const std::string id = value.asString(); + if (id == "colors") + type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + else if (id == "depth") + type = LLViewerWindow::SNAPSHOT_TYPE_DEPTH; + return type; +} + +// static +void LLFloaterOutfitSnapshot::Impl::setResolution(LLFloaterOutfitSnapshot* floater, const std::string& comboname) +{ + LLComboBox* combo = floater->getChild(comboname); + combo->setVisible(TRUE); + updateResolution(combo, floater, FALSE); // to sync spinners with combo +} + +//static +void LLFloaterOutfitSnapshot::Impl::updateLayout(LLFloaterOutfitSnapshot* floaterp) +{ + LLSnapshotLivePreview* previewp = getPreviewView(floaterp); + + BOOL advanced = gSavedSettings.getBOOL("AdvanceSnapshot"); + + //BD - Automatically calculate the size of our snapshot window to enlarge + // the snapshot preview to its maximum size, this is especially helpfull + // for pretty much every aspect ratio other than 1:1. + F32 panel_width = 400.f * gViewerWindow->getWorldViewAspectRatio(); + + //BD - Make sure we clamp at 700 here because 700 would be for 16:9 which we + // consider the maximum. Everything bigger will be clamped and will have + // a slightly smaller preview window which most likely won't fill up the + // whole snapshot floater as it should. + if(panel_width > 700.f) + { + panel_width = 700.f; + } + + S32 floater_width = 224.f; + if(advanced) + { + floater_width = floater_width + panel_width; + } + + LLUICtrl* thumbnail_placeholder = floaterp->getChild("thumbnail_placeholder"); + thumbnail_placeholder->setVisible(advanced); + thumbnail_placeholder->reshape(panel_width, thumbnail_placeholder->getRect().getHeight()); + floaterp->getChild("image_res_text")->setVisible(advanced); + floaterp->getChild("file_size_label")->setVisible(advanced); + if(!floaterp->isMinimized()) + { + floaterp->reshape(floater_width, floaterp->getRect().getHeight()); + } + + bool use_freeze_frame = floaterp->getChild("freeze_frame_check")->getValue().asBoolean(); + + if (use_freeze_frame) + { + // stop all mouse events at fullscreen preview layer + floaterp->getParent()->setMouseOpaque(TRUE); + + // shrink to smaller layout + // *TODO: unneeded? + floaterp->reshape(floaterp->getRect().getWidth(), floaterp->getRect().getHeight()); + + // can see and interact with fullscreen preview now + if (previewp) + { + previewp->setVisible(TRUE); + previewp->setEnabled(TRUE); + } + + //RN: freeze all avatars + LLCharacter* avatarp; + for (std::vector::iterator iter = LLCharacter::sInstances.begin(); + iter != LLCharacter::sInstances.end(); ++iter) + { + avatarp = *iter; + floaterp->impl.mAvatarPauseHandles.push_back(avatarp->requestPause()); + } + + // freeze everything else + gSavedSettings.setBOOL("FreezeTime", TRUE); + + if (LLToolMgr::getInstance()->getCurrentToolset() != gCameraToolset) + { + floaterp->impl.mLastToolset = LLToolMgr::getInstance()->getCurrentToolset(); + LLToolMgr::getInstance()->setCurrentToolset(gCameraToolset); + } + } + else // turning off freeze frame mode + { + floaterp->getParent()->setMouseOpaque(FALSE); + // *TODO: unneeded? + floaterp->reshape(floaterp->getRect().getWidth(), floaterp->getRect().getHeight()); + if (previewp) + { + previewp->setVisible(FALSE); + previewp->setEnabled(FALSE); + } + + //RN: thaw all avatars + floaterp->impl.mAvatarPauseHandles.clear(); + + // thaw everything else + gSavedSettings.setBOOL("FreezeTime", FALSE); + + // restore last tool (e.g. pie menu, etc) + if (floaterp->impl.mLastToolset) + { + LLToolMgr::getInstance()->setCurrentToolset(floaterp->impl.mLastToolset); + } + } +} + +// This is the main function that keeps all the GUI controls in sync with the saved settings. +// It should be called anytime a setting is changed that could affect the controls. +// No other methods should be changing any of the controls directly except for helpers called by this method. +// The basic pattern for programmatically changing the GUI settings is to first set the +// appropriate saved settings and then call this method to sync the GUI with them. +// FIXME: The above comment seems obsolete now. +// static +void LLFloaterOutfitSnapshot::Impl::updateControls(LLFloaterOutfitSnapshot* floater) +{ + LLPanelSnapshot::ESnapshotType shot_type = getActiveSnapshotType(floater); + LLFloaterSnapshotBase::ESnapshotFormat shot_format = (LLFloaterSnapshotBase::ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat"); + LLViewerWindow::ESnapshotType layer_type = getLayerType(floater); + + floater->getChild("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat")); + floater->getChildView("layer_types")->setEnabled(shot_type == LLPanelSnapshot::SNAPSHOT_LOCAL); + + LLPanelSnapshot* active_panel = getActivePanel(floater); + if (active_panel) + { + LLSpinCtrl* width_ctrl = getWidthSpinner(floater); + LLSpinCtrl* height_ctrl = getHeightSpinner(floater); + + // Initialize spinners. + if (width_ctrl->getValue().asInteger() == 0) + { + S32 w = gViewerWindow->getWindowWidthRaw(); + LL_DEBUGS() << "Initializing width spinner (" << width_ctrl->getName() << "): " << w << LL_ENDL; + width_ctrl->setValue(w); + if (getActiveSnapshotType(floater) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + { + width_ctrl->setIncrement(w >> 1); + } + } + if (height_ctrl->getValue().asInteger() == 0) + { + S32 h = gViewerWindow->getWindowHeightRaw(); + LL_DEBUGS() << "Initializing height spinner (" << height_ctrl->getName() << "): " << h << LL_ENDL; + height_ctrl->setValue(h); + if (getActiveSnapshotType(floater) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + { + height_ctrl->setIncrement(h >> 1); + } + } + + // Clamp snapshot resolution to window size when showing UI or HUD in snapshot. + if (gSavedSettings.getBOOL("RenderUIInSnapshot") || gSavedSettings.getBOOL("RenderHUDInSnapshot")) + { + S32 width = gViewerWindow->getWindowWidthRaw(); + S32 height = gViewerWindow->getWindowHeightRaw(); + + width_ctrl->setMaxValue(width); + + height_ctrl->setMaxValue(height); + + if (width_ctrl->getValue().asInteger() > width) + { + width_ctrl->forceSetValue(width); + } + if (height_ctrl->getValue().asInteger() > height) + { + height_ctrl->forceSetValue(height); + } + } + else + { + width_ctrl->setMaxValue(6016); + height_ctrl->setMaxValue(6016); + } + } + + LLSnapshotLivePreview* previewp = getPreviewView(floater); + BOOL got_bytes = previewp && previewp->getDataSize() > 0; + BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); + + // *TODO: Separate maximum size for Web images from postcards + LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; + + LLLocale locale(LLLocale::USER_LOCALE); + std::string bytes_string; + if (got_snap) + { + LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); + } + + // Update displayed image resolution. + LLTextBox* image_res_tb = floater->getChild("image_res_text"); + image_res_tb->setVisible(got_snap); + if (got_snap) + { + image_res_tb->setTextArg("[WIDTH]", llformat("%d", previewp->getEncodedImageWidth())); + image_res_tb->setTextArg("[HEIGHT]", llformat("%d", previewp->getEncodedImageHeight())); + } + + floater->getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown")); + floater->getChild("file_size_label")->setColor( + shot_type == LLPanelSnapshot::SNAPSHOT_POSTCARD + && got_bytes + && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" )); + + // Update the width and height spinners based on the corresponding resolution combos. (?) + switch(shot_type) + { + case LLPanelSnapshot::SNAPSHOT_WEB: + layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + floater->getChild("layer_types")->setValue("colors"); + setResolution(floater, "profile_size_combo"); + break; + case LLPanelSnapshot::SNAPSHOT_POSTCARD: + layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + floater->getChild("layer_types")->setValue("colors"); + setResolution(floater, "postcard_size_combo"); + break; + case LLPanelSnapshot::SNAPSHOT_TEXTURE: + layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + floater->getChild("layer_types")->setValue("colors"); + setResolution(floater, "texture_size_combo"); + break; + case LLPanelSnapshot::SNAPSHOT_LOCAL: + setResolution(floater, "local_size_combo"); + break; + default: + break; + } + setAspectRatioCheckboxValue(floater, !floater->impl.mAspectRatioCheckOff && gSavedSettings.getBOOL("KeepAspectForSnapshot")); + + if (previewp) + { + previewp->setSnapshotType(shot_type); + previewp->setSnapshotFormat(shot_format); + previewp->setSnapshotBufferType(layer_type); + } + + LLPanelSnapshot* current_panel = Impl::getActivePanel(floater); + if (current_panel) + { + LLSD info; + info["have-snapshot"] = got_snap; + current_panel->updateControls(info); + } + LL_DEBUGS() << "finished updating controls" << LL_ENDL; +} + +// static +void LLFloaterOutfitSnapshot::Impl::setStatus(EStatus status, bool ok, const std::string& msg) +{ + LLFloaterOutfitSnapshot* floater = LLFloaterOutfitSnapshot::getInstance(); + switch (status) + { + case STATUS_READY: + setWorking(floater, false); + setFinished(floater, false); + break; + case STATUS_WORKING: + setWorking(floater, true); + setFinished(floater, false); + break; + case STATUS_FINISHED: + setWorking(floater, false); + setFinished(floater, true, ok, msg); + break; + } + + floater->impl.mStatus = status; +} + +// static +void LLFloaterOutfitSnapshot::Impl::setNeedRefresh(LLFloaterOutfitSnapshot* floater, bool need) +{ + if (!floater) return; + + // Don't display the "Refresh to save" message if we're in auto-refresh mode. + if (gSavedSettings.getBOOL("AutoSnapshot")) + { + need = false; + } + + floater->mRefreshLabel->setVisible(need); + floater->impl.mNeedRefresh = need; +} + +// static +void LLFloaterOutfitSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp, BOOL update_thumbnail) +{ + if (previewp) + { + BOOL autosnap = gSavedSettings.getBOOL("AutoSnapshot"); + LL_DEBUGS() << "updating " << (autosnap ? "snapshot" : "thumbnail") << LL_ENDL; + previewp->updateSnapshot(autosnap, update_thumbnail, autosnap ? AUTO_SNAPSHOT_TIME_DELAY : 0.f); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onClickNewSnapshot(void* data) +{ + LLSnapshotLivePreview* previewp = getPreviewView((LLFloaterOutfitSnapshot *)data); + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; + if (previewp && view) + { + view->impl.setStatus(Impl::STATUS_READY); + LL_DEBUGS() << "updating snapshot" << LL_ENDL; + previewp->mForceUpdateSnapshot = TRUE; + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onClickAutoSnap(LLUICtrl *ctrl, void* data) +{ + LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; + gSavedSettings.setBOOL( "AutoSnapshot", check->get() ); + + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; + if (view) + { + checkAutoSnapshot(getPreviewView(view)); + updateControls(view); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onClickFilter(LLUICtrl *ctrl, void* data) +{ + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; + if (view) + { + updateControls(view); + LLSnapshotLivePreview* previewp = getPreviewView(view); + if (previewp) + { + checkAutoSnapshot(previewp); + // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale + LLComboBox* filterbox = static_cast(view->getChild("filters_combobox")); + std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : ""); + previewp->setFilter(filter_name); + previewp->updateSnapshot(TRUE); + } + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) +{ + LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; + gSavedSettings.setBOOL( "RenderUIInSnapshot", check->get() ); + + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; + if (view) + { + LLSnapshotLivePreview* previewp = getPreviewView(view); + if(previewp) + { + previewp->updateSnapshot(TRUE, TRUE); + } + updateControls(view); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onClickHUDCheck(LLUICtrl *ctrl, void* data) +{ + LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; + gSavedSettings.setBOOL( "RenderHUDInSnapshot", check->get() ); + + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; + if (view) + { + LLSnapshotLivePreview* previewp = getPreviewView(view); + if(previewp) + { + previewp->updateSnapshot(TRUE, TRUE); + } + updateControls(view); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::applyKeepAspectCheck(LLFloaterOutfitSnapshot* view, BOOL checked) +{ + gSavedSettings.setBOOL("KeepAspectForSnapshot", checked); + + if (view) + { + LLPanelSnapshot* active_panel = getActivePanel(view); + if (checked && active_panel) + { + LLComboBox* combo = view->getChild(active_panel->getImageSizeComboName()); + combo->setCurrentByIndex(combo->getItemCount() - 1); // "custom" is always the last index + } + + LLSnapshotLivePreview* previewp = getPreviewView(view) ; + if(previewp) + { + previewp->mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ; + + S32 w, h ; + previewp->getSize(w, h) ; + updateSpinners(view, previewp, w, h, TRUE); // may change w and h + + LL_DEBUGS() << "updating thumbnail" << LL_ENDL; + previewp->setSize(w, h) ; + previewp->updateSnapshot(TRUE); + checkAutoSnapshot(previewp, TRUE); + } + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onCommitFreezeFrame(LLUICtrl* ctrl, void* data) +{ + LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; + LLSnapshotLivePreview* previewp = getPreviewView(view); + + if (!view || !check_box || !previewp) + { + return; + } + + gSavedSettings.setBOOL("UseFreezeFrame", check_box->get()); + + if (check_box->get()) + { + previewp->prepareFreezeFrame(); + } + + updateLayout(view); +} + +// static +void LLFloaterOutfitSnapshot::Impl::checkAspectRatio(LLFloaterOutfitSnapshot *view, S32 index) +{ + LLSnapshotLivePreview *previewp = getPreviewView(view) ; + + // Don't round texture sizes; textures are commonly stretched in world, profiles, etc and need to be "squashed" during upload, not cropped here + if(LLPanelSnapshot::SNAPSHOT_TEXTURE == getActiveSnapshotType(view)) + { + previewp->mKeepAspectRatio = FALSE ; + return ; + } + + BOOL keep_aspect = FALSE, enable_cb = FALSE; + + if (0 == index) // current window size + { + enable_cb = FALSE; + keep_aspect = TRUE; + } + else if (-1 == index) // custom + { + enable_cb = TRUE; + keep_aspect = gSavedSettings.getBOOL("KeepAspectForSnapshot"); + } + else // predefined resolution + { + enable_cb = FALSE; + keep_aspect = FALSE; + } + + view->impl.mAspectRatioCheckOff = !enable_cb; + + if (previewp) + { + previewp->mKeepAspectRatio = keep_aspect; + } +} + +// Show/hide upload progress indicators. +// static +void LLFloaterOutfitSnapshot::Impl::setWorking(LLFloaterOutfitSnapshot* floater, bool working) +{ + LLUICtrl* working_lbl = floater->getChild("working_lbl"); + working_lbl->setVisible(working); + floater->getChild("working_indicator")->setVisible(working); + + if (working) + { + const std::string panel_name = getActivePanel(floater, false)->getName(); + const std::string prefix = panel_name.substr(std::string("panel_outfit_snapshot_").size()); + std::string progress_text = floater->getString(prefix + "_" + "progress_str"); + working_lbl->setValue(progress_text); + } + + // All controls should be disabled while posting. + floater->setCtrlsEnabled(!working); + LLPanelSnapshot* active_panel = getActivePanel(floater); + if (active_panel) + { + active_panel->enableControls(!working); + } +} + +// Show/hide upload status message. +// static +void LLFloaterOutfitSnapshot::Impl::setFinished(LLFloaterOutfitSnapshot* floater, bool finished, bool ok, const std::string& msg) +{ + floater->mSucceessLblPanel->setVisible(finished && ok); + floater->mFailureLblPanel->setVisible(finished && !ok); + + if (finished) + { + LLUICtrl* finished_lbl = floater->getChild(ok ? "succeeded_lbl" : "failed_lbl"); + std::string result_text = floater->getString(msg + "_" + (ok ? "succeeded_str" : "failed_str")); + finished_lbl->setValue(result_text); + + //LLSideTrayPanelContainer* panel_container = floater->getChild("panel_container"); + //panel_container->openPreviousPanel(); + //panel_container->getCurrentPanel()->onOpen(LLSD()); + LLPanel* snapshot_panel = floater->getChild("panel_outfit_snapshot_inventory"); + snapshot_panel->onOpen(LLSD()); + } +} + +// Apply a new resolution selected from the given combobox. +// static +void LLFloaterOutfitSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update) +{ + LLComboBox* combobox = (LLComboBox*)ctrl; + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; + + if (!view || !combobox) + { + llassert(view && combobox); + return; + } + + std::string sdstring = combobox->getSelectedValue(); + LLSD sdres; + std::stringstream sstream(sdstring); + LLSDSerialize::fromNotation(sdres, sstream, sdstring.size()); + + S32 width = sdres[0]; + S32 height = sdres[1]; + + LLSnapshotLivePreview* previewp = getPreviewView(view); + if (previewp && combobox->getCurrentIndex() >= 0) + { + S32 original_width = 0 , original_height = 0 ; + previewp->getSize(original_width, original_height) ; + + if (gSavedSettings.getBOOL("RenderUIInSnapshot") || gSavedSettings.getBOOL("RenderHUDInSnapshot")) + { //clamp snapshot resolution to window size when showing UI or HUD in snapshot + width = llmin(width, gViewerWindow->getWindowWidthRaw()); + height = llmin(height, gViewerWindow->getWindowHeightRaw()); + } + + if (width == 0 || height == 0) + { + // take resolution from current window size + LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL; + previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()); + } + else if (width == -1 || height == -1) + { + // load last custom value + S32 new_width = 0, new_height = 0; + LLPanelSnapshot* spanel = getActivePanel(view); + if (spanel) + { + LL_DEBUGS() << "Loading typed res from panel " << spanel->getName() << LL_ENDL; + new_width = spanel->getTypedPreviewWidth(); + new_height = spanel->getTypedPreviewHeight(); + + // Limit custom size for inventory snapshots to 512x512 px. + if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + { + new_width = llmin(new_width, MAX_TEXTURE_SIZE); + new_height = llmin(new_height, MAX_TEXTURE_SIZE); + } + } + else + { + LL_DEBUGS() << "No custom res chosen, setting preview res from window: " + << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL; + new_width = gViewerWindow->getWindowWidthRaw(); + new_height = gViewerWindow->getWindowHeightRaw(); + } + + llassert(new_width > 0 && new_height > 0); + previewp->setSize(new_width, new_height); + } + else + { + // use the resolution from the selected pre-canned drop-down choice + LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL; + previewp->setSize(width, height); + } + + checkAspectRatio(view, width) ; + + previewp->getSize(width, height); + + // We use the height spinner here because we come here via the aspect ratio + // checkbox as well and we want height always changing to width by default. + // If we use the width spinner we would change width according to height by + // default, that is not what we want. + updateSpinners(view, previewp, width, height, !getHeightSpinner(view)->isDirty()); // may change width and height + + if(getWidthSpinner(view)->getValue().asInteger() != width || getHeightSpinner(view)->getValue().asInteger() != height) + { + getWidthSpinner(view)->setValue(width); + getHeightSpinner(view)->setValue(height); + if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + { + getWidthSpinner(view)->setIncrement(width >> 1); + getHeightSpinner(view)->setIncrement(height >> 1); + } + } + + if(original_width != width || original_height != height) + { + previewp->setSize(width, height); + + // hide old preview as the aspect ratio could be wrong + checkAutoSnapshot(previewp, FALSE); + LL_DEBUGS() << "updating thumbnail" << LL_ENDL; + getPreviewView(view)->updateSnapshot(TRUE); + if(do_update) + { + LL_DEBUGS() << "Will update controls" << LL_ENDL; + updateControls(view); + } + } + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onCommitLayerTypes(LLUICtrl* ctrl, void*data) +{ + LLComboBox* combobox = (LLComboBox*)ctrl; + + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; + + if (view) + { + LLSnapshotLivePreview* previewp = getPreviewView(view); + if (previewp) + { + previewp->setSnapshotBufferType((LLViewerWindow::ESnapshotType)combobox->getCurrentIndex()); + } + checkAutoSnapshot(previewp, TRUE); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onImageQualityChange(LLFloaterOutfitSnapshot* view, S32 quality_val) +{ + LLSnapshotLivePreview* previewp = getPreviewView(view); + if (previewp) + { + previewp->setSnapshotQuality(quality_val); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onImageFormatChange(LLFloaterOutfitSnapshot* view) +{ + if (view) + { + gSavedSettings.setS32("SnapshotFormat", getImageFormat(view)); + LL_DEBUGS() << "image format changed, updating snapshot" << LL_ENDL; + getPreviewView(view)->updateSnapshot(TRUE); + updateControls(view); + } +} + +// Sets the named size combo to "custom" mode. +// static +void LLFloaterOutfitSnapshot::Impl::comboSetCustom(LLFloaterOutfitSnapshot* floater, const std::string& comboname) +{ + LLComboBox* combo = floater->getChild(comboname); + combo->setCurrentByIndex(combo->getItemCount() - 1); // "custom" is always the last index + checkAspectRatio(floater, -1); // -1 means custom +} + +// Update supplied width and height according to the constrain proportions flag; limit them by max_val. +//static +BOOL LLFloaterOutfitSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value) +{ + S32 w = width ; + S32 h = height ; + + if(previewp && previewp->mKeepAspectRatio) + { + if(gViewerWindow->getWindowWidthRaw() < 1 || gViewerWindow->getWindowHeightRaw() < 1) + { + return FALSE ; + } + + //aspect ratio of the current window + F32 aspect_ratio = (F32)gViewerWindow->getWindowWidthRaw() / gViewerWindow->getWindowHeightRaw() ; + + //change another value proportionally + if(isWidthChanged) + { + height = ll_round(width / aspect_ratio) ; + } + else + { + width = ll_round(height * aspect_ratio) ; + } + + //bound w/h by the max_value + if(width > max_value || height > max_value) + { + if(width > height) + { + width = max_value ; + height = (S32)(width / aspect_ratio) ; + } + else + { + height = max_value ; + width = (S32)(height * aspect_ratio) ; + } + } + } + + return (w != width || h != height) ; +} + +//static +void LLFloaterOutfitSnapshot::Impl::setImageSizeSpinnersValues(LLFloaterOutfitSnapshot *view, S32 width, S32 height) +{ + getWidthSpinner(view)->forceSetValue(width); + getHeightSpinner(view)->forceSetValue(height); + if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + { + getWidthSpinner(view)->setIncrement(width >> 1); + getHeightSpinner(view)->setIncrement(height >> 1); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::updateSpinners(LLFloaterOutfitSnapshot* view, LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL is_width_changed) +{ + getWidthSpinner(view)->resetDirty(); + getHeightSpinner(view)->resetDirty(); + if (checkImageSize(previewp, width, height, is_width_changed, previewp->getMaxImageSize())) + { + setImageSizeSpinnersValues(view, width, height); + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::applyCustomResolution(LLFloaterOutfitSnapshot* view, S32 w, S32 h) +{ + LL_DEBUGS() << "applyCustomResolution(" << w << ", " << h << ")" << LL_ENDL; + if (!view) return; + + LLSnapshotLivePreview* previewp = getPreviewView(view); + if (previewp) + { + S32 curw,curh; + previewp->getSize(curw, curh); + + if (w != curw || h != curh) + { + //if to upload a snapshot, process spinner input in a special way. + previewp->setMaxImageSize((S32) getWidthSpinner(view)->getMaxValue()) ; + + previewp->setSize(w,h); + checkAutoSnapshot(previewp, FALSE); + comboSetCustom(view, "profile_size_combo"); + comboSetCustom(view, "postcard_size_combo"); + comboSetCustom(view, "texture_size_combo"); + comboSetCustom(view, "local_size_combo"); + LL_DEBUGS() << "applied custom resolution, updating thumbnail" << LL_ENDL; + previewp->updateSnapshot(TRUE); + } + } +} + +// static +void LLFloaterOutfitSnapshot::Impl::onSnapshotUploadFinished(bool status) +{ + setStatus(STATUS_FINISHED, status, "profile"); +} + + +// static +void LLFloaterOutfitSnapshot::Impl::onSendingPostcardFinished(bool status) +{ + setStatus(STATUS_FINISHED, status, "postcard"); +} + + +///---------------------------------------------------------------------------- +/// Class LLFloaterSnapshot +///---------------------------------------------------------------------------- + +// Default constructor +LLFloaterOutfitSnapshot::LLFloaterOutfitSnapshot(const LLSD& key) + : LLFloaterSnapshotBase(key), + mRefreshBtn(NULL), + mRefreshLabel(NULL), + mSucceessLblPanel(NULL), + mFailureLblPanel(NULL), + mOutfitGallery(NULL), + impl (*(new Impl)) +{ +} + +// Destroys the object +LLFloaterOutfitSnapshot::~LLFloaterOutfitSnapshot() +{ + if (impl.mPreviewHandle.get()) impl.mPreviewHandle.get()->die(); + + //unfreeze everything else + gSavedSettings.setBOOL("FreezeTime", FALSE); + + if (impl.mLastToolset) + { + LLToolMgr::getInstance()->setCurrentToolset(impl.mLastToolset); + } + + delete &impl; +} + + +BOOL LLFloaterOutfitSnapshot::postBuild() +{ + mRefreshBtn = getChild("new_snapshot_btn"); + childSetAction("new_snapshot_btn", Impl::onClickNewSnapshot, this); + mRefreshLabel = getChild("refresh_lbl"); + mSucceessLblPanel = getChild("succeeded_panel"); + mFailureLblPanel = getChild("failed_panel"); + + childSetCommitCallback("ui_check", Impl::onClickUICheck, this); + getChild("ui_check")->setValue(gSavedSettings.getBOOL("RenderUIInSnapshot")); + + childSetCommitCallback("hud_check", Impl::onClickHUDCheck, this); + getChild("hud_check")->setValue(gSavedSettings.getBOOL("RenderHUDInSnapshot")); + + impl.setAspectRatioCheckboxValue(this, gSavedSettings.getBOOL("KeepAspectForSnapshot")); + + childSetCommitCallback("layer_types", Impl::onCommitLayerTypes, this); + getChild("layer_types")->setValue("colors"); + getChildView("layer_types")->setEnabled(FALSE); + + getChild("freeze_frame_check")->setValue(gSavedSettings.getBOOL("UseFreezeFrame")); + childSetCommitCallback("freeze_frame_check", Impl::onCommitFreezeFrame, this); + + getChild("auto_snapshot_check")->setValue(gSavedSettings.getBOOL("AutoSnapshot")); + childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this); + + + // Filters + LLComboBox* filterbox = getChild("filters_combobox"); + std::vector filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); + for (U32 i = 0; i < filter_list.size(); i++) + { + filterbox->add(filter_list[i]); + } + childSetCommitCallback("filters_combobox", Impl::onClickFilter, this); + + LLWebProfile::setImageUploadResultCallback(boost::bind(&LLFloaterOutfitSnapshot::Impl::onSnapshotUploadFinished, _1)); + LLPostCard::setPostResultCallback(boost::bind(&LLFloaterOutfitSnapshot::Impl::onSendingPostcardFinished, _1)); + + sThumbnailPlaceholder = getChild("thumbnail_placeholder"); + + // create preview window + LLRect full_screen_rect = getRootView()->getRect(); + LLSnapshotLivePreview::Params p; + p.rect(full_screen_rect); + LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); + LLView* parent_view = gSnapshotFloaterView->getParent(); + + parent_view->removeChild(gSnapshotFloaterView); + // make sure preview is below snapshot floater + parent_view->addChild(previewp); + parent_view->addChild(gSnapshotFloaterView); + + //move snapshot floater to special purpose snapshotfloaterview + gFloaterView->removeChild(this); + gSnapshotFloaterView->addChild(this); + + // Pre-select "Current Window" resolution. + getChild("profile_size_combo")->selectNthItem(0); + getChild("postcard_size_combo")->selectNthItem(0); + getChild("texture_size_combo")->selectNthItem(0); + getChild("local_size_combo")->selectNthItem(8); + getChild("local_format_combo")->selectNthItem(0); + + impl.mPreviewHandle = previewp->getHandle(); + previewp->setContainer(this); + impl.updateControls(this); + impl.updateLayout(this); + + + previewp->setThumbnailPlaceholderRect(getThumbnailPlaceholderRect()); + + return TRUE; +} + +void LLFloaterOutfitSnapshot::draw() +{ + LLSnapshotLivePreview* previewp = impl.getPreviewView(this); + + if (previewp && (previewp->isSnapshotActive() || previewp->getThumbnailLock())) + { + // don't render snapshot window in snapshot, even if "show ui" is turned on + return; + } + + LLFloater::draw(); + + if (previewp && !isMinimized() && sThumbnailPlaceholder->getVisible()) + { + if(previewp->getThumbnailImage()) + { + bool working = impl.getStatus() == Impl::STATUS_WORKING; + const LLRect& thumbnail_rect = getThumbnailPlaceholderRect(); + const S32 thumbnail_w = previewp->getThumbnailWidth(); + const S32 thumbnail_h = previewp->getThumbnailHeight(); + + // calc preview offset within the preview rect + const S32 local_offset_x = (thumbnail_rect.getWidth() - thumbnail_w) / 2 ; + const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2 ; // preview y pos within the preview rect + + // calc preview offset within the floater rect + S32 offset_x = thumbnail_rect.mLeft + local_offset_x; + S32 offset_y = thumbnail_rect.mBottom + local_offset_y; + + gGL.matrixMode(LLRender::MM_MODELVIEW); + // Apply floater transparency to the texture unless the floater is focused. + F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); + LLColor4 color = working ? LLColor4::grey4 : LLColor4::white; + gl_draw_scaled_image(offset_x, offset_y, + thumbnail_w, thumbnail_h, + previewp->getThumbnailImage(), color % alpha); + + previewp->drawPreviewRect(offset_x, offset_y) ; + + gGL.pushUIMatrix(); + LLUI::translate((F32) thumbnail_rect.mLeft, (F32) thumbnail_rect.mBottom); + sThumbnailPlaceholder->draw(); + gGL.popUIMatrix(); + } + } + impl.updateLayout(this); +} + +void LLFloaterOutfitSnapshot::onOpen(const LLSD& key) +{ + LLSnapshotLivePreview* preview = LLFloaterOutfitSnapshot::Impl::getPreviewView(this); + if(preview) + { + LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL; + preview->updateSnapshot(TRUE); + } + focusFirstItem(FALSE); + gSnapshotFloaterView->setEnabled(TRUE); + gSnapshotFloaterView->setVisible(TRUE); + gSnapshotFloaterView->adjustToFitScreen(this, FALSE); + + impl.updateControls(this); + impl.updateLayout(this); + + // Initialize default tab. + //getChild("panel_container")->getCurrentPanel()->onOpen(LLSD()); + //parent->openPanel(panel_name); + LLPanel* snapshot_panel = getChild("panel_outfit_snapshot_inventory"); + snapshot_panel->onOpen(LLSD()); + postPanelSwitch(); + +} + +void LLFloaterOutfitSnapshot::onClose(bool app_quitting) +{ + getParent()->setMouseOpaque(FALSE); + + //unfreeze everything, hide fullscreen preview + LLSnapshotLivePreview* previewp = LLFloaterOutfitSnapshot::Impl::getPreviewView(this); + if (previewp) + { + previewp->setVisible(FALSE); + previewp->setEnabled(FALSE); + } + + gSavedSettings.setBOOL("FreezeTime", FALSE); + impl.mAvatarPauseHandles.clear(); + + if (impl.mLastToolset) + { + LLToolMgr::getInstance()->setCurrentToolset(impl.mLastToolset); + } +} + +// virtual +S32 LLFloaterOutfitSnapshot::notify(const LLSD& info) +{ + // A child panel wants to change snapshot resolution. + if (info.has("combo-res-change")) + { + std::string combo_name = info["combo-res-change"]["control-name"].asString(); + impl.updateResolution(getChild(combo_name), this); + return 1; + } + + if (info.has("custom-res-change")) + { + LLSD res = info["custom-res-change"]; + impl.applyCustomResolution(this, res["w"].asInteger(), res["h"].asInteger()); + return 1; + } + + if (info.has("keep-aspect-change")) + { + impl.applyKeepAspectCheck(this, info["keep-aspect-change"].asBoolean()); + return 1; + } + + if (info.has("image-quality-change")) + { + impl.onImageQualityChange(this, info["image-quality-change"].asInteger()); + return 1; + } + + if (info.has("image-format-change")) + { + impl.onImageFormatChange(this); + return 1; + } + + if (info.has("set-ready")) + { + impl.setStatus(Impl::STATUS_READY); + return 1; + } + + if (info.has("set-working")) + { + impl.setStatus(Impl::STATUS_WORKING); + return 1; + } + + if (info.has("set-finished")) + { + LLSD data = info["set-finished"]; + impl.setStatus(Impl::STATUS_FINISHED, data["ok"].asBoolean(), data["msg"].asString()); + return 1; + } + + if (info.has("snapshot-updating")) + { + // Disable the send/post/save buttons until snapshot is ready. + impl.updateControls(this); + return 1; + } + + if (info.has("snapshot-updated")) + { + // Enable the send/post/save buttons. + impl.updateControls(this); + // We've just done refresh. + impl.setNeedRefresh(this, false); + + // The refresh button is initially hidden. We show it after the first update, + // i.e. when preview appears. + if (!mRefreshBtn->getVisible()) + { + mRefreshBtn->setVisible(true); + } + return 1; + } + + return 0; +} + +//static +void LLFloaterOutfitSnapshot::update() +{ + LLFloaterOutfitSnapshot* inst = findInstance(); + LLFloaterFacebook* floater_facebook = LLFloaterReg::findTypedInstance("facebook"); + LLFloaterFlickr* floater_flickr = LLFloaterReg::findTypedInstance("flickr"); + LLFloaterTwitter* floater_twitter = LLFloaterReg::findTypedInstance("twitter"); + + if (!inst && !floater_facebook && !floater_flickr && !floater_twitter) + return; + + BOOL changed = FALSE; + LL_DEBUGS() << "npreviews: " << LLSnapshotLivePreview::sList.size() << LL_ENDL; + for (std::set::iterator iter = LLSnapshotLivePreview::sList.begin(); + iter != LLSnapshotLivePreview::sList.end(); ++iter) + { + changed |= LLSnapshotLivePreview::onIdle(*iter); + } + + if (inst && changed) + { + LL_DEBUGS() << "changed" << LL_ENDL; + inst->impl.updateControls(inst); + } +} + +// static +LLFloaterOutfitSnapshot* LLFloaterOutfitSnapshot::getInstance() +{ + return LLFloaterReg::getTypedInstance("outfit_snapshot"); +} + +// static +LLFloaterOutfitSnapshot* LLFloaterOutfitSnapshot::findInstance() +{ + return LLFloaterReg::findTypedInstance("outfit_snapshot"); +} + +// static +void LLFloaterOutfitSnapshot::saveTexture() +{ + LL_DEBUGS() << "saveTexture" << LL_ENDL; + + // FIXME: duplicated code + LLFloaterOutfitSnapshot* instance = findInstance(); + if (!instance) + { + llassert(instance != NULL); + return; + } + LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); + if (!previewp) + { + llassert(previewp != NULL); + return; + } + + if (instance->mOutfitGallery) + { + instance->mOutfitGallery->onBeforeOutfitSnapshotSave(); + } + previewp->saveTexture(TRUE, instance->getOutfitID().asString()); + if (instance->mOutfitGallery) + { + instance->mOutfitGallery->onAfterOutfitSnapshotSave(); + } + instance->closeFloater(); +} + +// static +BOOL LLFloaterOutfitSnapshot::saveLocal() +{ + LL_DEBUGS() << "saveLocal" << LL_ENDL; + // FIXME: duplicated code + LLFloaterOutfitSnapshot* instance = findInstance(); + if (!instance) + { + llassert(instance != NULL); + return FALSE; + } + LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); + if (!previewp) + { + llassert(previewp != NULL); + return FALSE; + } + + return previewp->saveLocal(); +} + +// static +void LLFloaterOutfitSnapshot::postSave() +{ + LLFloaterOutfitSnapshot* instance = findInstance(); + if (!instance) + { + llassert(instance != NULL); + return; + } + + instance->impl.updateControls(instance); + instance->impl.setStatus(Impl::STATUS_WORKING); +} + +// static +void LLFloaterOutfitSnapshot::postPanelSwitch() +{ + LLFloaterOutfitSnapshot* instance = getInstance(); + instance->impl.updateControls(instance); + + // Remove the success/failure indicator whenever user presses a snapshot option button. + instance->impl.setStatus(Impl::STATUS_READY); +} + +// static +LLPointer LLFloaterOutfitSnapshot::getImageData() +{ + // FIXME: May not work for textures. + + LLFloaterOutfitSnapshot* instance = findInstance(); + if (!instance) + { + llassert(instance != NULL); + return NULL; + } + + LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); + if (!previewp) + { + llassert(previewp != NULL); + return NULL; + } + + LLPointer img = previewp->getFormattedImage(); + if (!img.get()) + { + LL_WARNS() << "Empty snapshot image data" << LL_ENDL; + llassert(img.get() != NULL); + } + + return img; +} + +// static +const LLVector3d& LLFloaterOutfitSnapshot::getPosTakenGlobal() +{ + LLFloaterOutfitSnapshot* instance = findInstance(); + if (!instance) + { + llassert(instance != NULL); + return LLVector3d::zero; + } + + LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); + if (!previewp) + { + llassert(previewp != NULL); + return LLVector3d::zero; + } + + return previewp->getPosTakenGlobal(); +} + +// static +void LLFloaterOutfitSnapshot::setAgentEmail(const std::string& email) +{ + LLFloaterOutfitSnapshot* instance = findInstance(); + if (instance) + { + LLSideTrayPanelContainer* panel_container = instance->getChild("panel_container"); + LLPanel* postcard_panel = panel_container->getPanelByName("panel_snapshot_postcard"); + postcard_panel->notify(LLSD().with("agent-email", email)); + } +} + +///---------------------------------------------------------------------------- +/// Class LLSnapshotFloaterView +///---------------------------------------------------------------------------- + +LLOutfitSnapshotFloaterView::LLOutfitSnapshotFloaterView (const Params& p) : LLFloaterView (p) +{ +} + +LLOutfitSnapshotFloaterView::~LLOutfitSnapshotFloaterView() +{ +} + +BOOL LLOutfitSnapshotFloaterView::handleKey(KEY key, MASK mask, BOOL called_from_parent) +{ + // use default handler when not in freeze-frame mode + if(!gSavedSettings.getBOOL("FreezeTime")) + { + return LLFloaterView::handleKey(key, mask, called_from_parent); + } + + if (called_from_parent) + { + // pass all keystrokes down + LLFloaterView::handleKey(key, mask, called_from_parent); + } + else + { + // bounce keystrokes back down + LLFloaterView::handleKey(key, mask, TRUE); + } + return TRUE; +} + +BOOL LLOutfitSnapshotFloaterView::handleMouseDown(S32 x, S32 y, MASK mask) +{ + // use default handler when not in freeze-frame mode + if(!gSavedSettings.getBOOL("FreezeTime")) + { + return LLFloaterView::handleMouseDown(x, y, mask); + } + // give floater a change to handle mouse, else camera tool + if (childrenHandleMouseDown(x, y, mask) == NULL) + { + LLToolMgr::getInstance()->getCurrentTool()->handleMouseDown( x, y, mask ); + } + return TRUE; +} + +BOOL LLOutfitSnapshotFloaterView::handleMouseUp(S32 x, S32 y, MASK mask) +{ + // use default handler when not in freeze-frame mode + if(!gSavedSettings.getBOOL("FreezeTime")) + { + return LLFloaterView::handleMouseUp(x, y, mask); + } + // give floater a change to handle mouse, else camera tool + if (childrenHandleMouseUp(x, y, mask) == NULL) + { + LLToolMgr::getInstance()->getCurrentTool()->handleMouseUp( x, y, mask ); + } + return TRUE; +} + +BOOL LLOutfitSnapshotFloaterView::handleHover(S32 x, S32 y, MASK mask) +{ + // use default handler when not in freeze-frame mode + if(!gSavedSettings.getBOOL("FreezeTime")) + { + return LLFloaterView::handleHover(x, y, mask); + } + // give floater a change to handle mouse, else camera tool + if (childrenHandleHover(x, y, mask) == NULL) + { + LLToolMgr::getInstance()->getCurrentTool()->handleHover( x, y, mask ); + } + return TRUE; +} diff --git a/indra/newview/llfloateroutfitsnapshot.h b/indra/newview/llfloateroutfitsnapshot.h new file mode 100644 index 0000000000..176a9520c2 --- /dev/null +++ b/indra/newview/llfloateroutfitsnapshot.h @@ -0,0 +1,110 @@ +/** + * @file llfloateroutfitsnapshot.h + * @brief Snapshot preview window for saving as an outfit thumbnail in visual outfit gallery + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2016, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATEROUTFITSNAPSHOT_H +#define LL_LLFLOATEROUTFITSNAPSHOT_H + +#include "llfloater.h" +#include "llfloatersnapshot.h" +#include "lloutfitgallery.h" + +class LLSpinCtrl; + +class LLFloaterOutfitSnapshot : public LLFloaterSnapshotBase +{ + LOG_CLASS(LLFloaterOutfitSnapshot); + +public: + //typedef enum e_snapshot_format + //{ + // SNAPSHOT_FORMAT_PNG, + // SNAPSHOT_FORMAT_JPEG, + // SNAPSHOT_FORMAT_BMP + //} ESnapshotFormat; + + LLFloaterOutfitSnapshot(const LLSD& key); + virtual ~LLFloaterOutfitSnapshot(); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void draw(); + /*virtual*/ void onOpen(const LLSD& key); + /*virtual*/ void onClose(bool app_quitting); + /*virtual*/ S32 notify(const LLSD& info); + + static void update(); + + // TODO: create a snapshot model instead + static LLFloaterOutfitSnapshot* getInstance(); + static LLFloaterOutfitSnapshot* findInstance(); + static void saveTexture(); + static BOOL saveLocal(); + static void postSave(); + static void postPanelSwitch(); + static LLPointer getImageData(); + static const LLVector3d& getPosTakenGlobal(); + static void setAgentEmail(const std::string& email); + + static const LLRect& getThumbnailPlaceholderRect() { return sThumbnailPlaceholder->getRect(); } + + void setOutfitID(LLUUID id) { mOutfitID = id; } + LLUUID getOutfitID() { return mOutfitID; } + void setGallery(LLOutfitGallery* gallery) { mOutfitGallery = gallery; } +private: + static LLUICtrl* sThumbnailPlaceholder; + LLUICtrl *mRefreshBtn, *mRefreshLabel; + LLUICtrl *mSucceessLblPanel, *mFailureLblPanel; + + class Impl; + Impl& impl; + + LLUUID mOutfitID; + LLOutfitGallery* mOutfitGallery; +}; + +class LLOutfitSnapshotFloaterView : public LLFloaterView +{ +public: + struct Params + : public LLInitParam::Block + { + }; + +protected: + LLOutfitSnapshotFloaterView (const Params& p); + friend class LLUICtrlFactory; + +public: + virtual ~LLOutfitSnapshotFloaterView(); + + /*virtual*/ BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); + /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); +}; + +extern LLOutfitSnapshotFloaterView* gOutfitSnapshotFloaterView; + +#endif // LL_LLFLOATEROUTFITSNAPSHOT_H diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index afec981d56..e5a2bd03cd 100755 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -62,11 +62,20 @@ const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 static LLDefaultChildRegistry::Register r("snapshot_floater_view"); +LLFloaterSnapshotBase::ImplBase::ImplBase() +{ +} + +LLFloaterSnapshotBase::ImplBase::~ImplBase() +{ +} + + ///---------------------------------------------------------------------------- /// Class LLFloaterSnapshot::Impl ///---------------------------------------------------------------------------- -class LLFloaterSnapshot::Impl +class LLFloaterSnapshot::Impl : public LLFloaterSnapshotBase::ImplBase { LOG_CLASS(LLFloaterSnapshot::Impl); public: @@ -111,8 +120,8 @@ public: static void updateSpinners(LLFloaterSnapshot* view, LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL is_width_changed); static LLPanelSnapshot* getActivePanel(LLFloaterSnapshot* floater, bool ok_if_not_found = true); - static LLSnapshotLivePreview::ESnapshotType getActiveSnapshotType(LLFloaterSnapshot* floater); - static LLFloaterSnapshot::ESnapshotFormat getImageFormat(LLFloaterSnapshot* floater); + static LLPanelSnapshot::ESnapshotType getActiveSnapshotType(LLFloaterSnapshot* floater); + static LLFloaterSnapshotBase::ESnapshotFormat getImageFormat(LLFloaterSnapshot* floater); static LLSpinCtrl* getWidthSpinner(LLFloaterSnapshot* floater); static LLSpinCtrl* getHeightSpinner(LLFloaterSnapshot* floater); static void enableAspectRatioCheckbox(LLFloaterSnapshot* floater, BOOL enable); @@ -158,35 +167,40 @@ LLPanelSnapshot* LLFloaterSnapshot::Impl::getActivePanel(LLFloaterSnapshot* floa } // static -LLSnapshotLivePreview::ESnapshotType LLFloaterSnapshot::Impl::getActiveSnapshotType(LLFloaterSnapshot* floater) +LLPanelSnapshot::ESnapshotType LLFloaterSnapshot::Impl::getActiveSnapshotType(LLFloaterSnapshot* floater) { - LLSnapshotLivePreview::ESnapshotType type = LLSnapshotLivePreview::SNAPSHOT_WEB; - std::string name; + // LLPanelSnapshot::ESnapshotType type = LLPanelSnapshot::SNAPSHOT_WEB; + //std::string name; LLPanelSnapshot* spanel = getActivePanel(floater); - if (spanel) - { - name = spanel->getName(); - } - - if (name == "panel_snapshot_postcard") - { - type = LLSnapshotLivePreview::SNAPSHOT_POSTCARD; - } - else if (name == "panel_snapshot_inventory") - { - type = LLSnapshotLivePreview::SNAPSHOT_TEXTURE; - } - else if (name == "panel_snapshot_local") - { - type = LLSnapshotLivePreview::SNAPSHOT_LOCAL; - } - - return type; + //if (spanel) + //{ + // name = spanel->getName(); + //} + + //if (name == "panel_snapshot_postcard") + //{ + // type = LLPanelSnapshot::SNAPSHOT_POSTCARD; + //} + //else if (name == "panel_snapshot_inventory") + //{ + // type = LLSnapshotLivePreview::SNAPSHOT_TEXTURE; + //} + //else if (name == "panel_snapshot_local") + //{ + // type = LLSnapshotLivePreview::SNAPSHOT_LOCAL; + //} + + //return type; + if (spanel) + { + return spanel->getSnapshotType(); + } + return LLPanelSnapshot::SNAPSHOT_WEB; } // static -LLFloaterSnapshot::ESnapshotFormat LLFloaterSnapshot::Impl::getImageFormat(LLFloaterSnapshot* floater) +LLFloaterSnapshotBase::ESnapshotFormat LLFloaterSnapshot::Impl::getImageFormat(LLFloaterSnapshot* floater) { LLPanelSnapshot* active_panel = getActivePanel(floater); // FIXME: if the default is not PNG, profile uploads may fail. @@ -362,12 +376,12 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) // static void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) { - LLSnapshotLivePreview::ESnapshotType shot_type = getActiveSnapshotType(floater); + LLPanelSnapshot::ESnapshotType shot_type = getActiveSnapshotType(floater); ESnapshotFormat shot_format = (ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat"); LLViewerWindow::ESnapshotType layer_type = getLayerType(floater); floater->getChild("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat")); - floater->getChildView("layer_types")->setEnabled(shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL); + floater->getChildView("layer_types")->setEnabled(shot_type == LLPanelSnapshot::SNAPSHOT_LOCAL); LLPanelSnapshot* active_panel = getActivePanel(floater); if (active_panel) @@ -381,7 +395,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) S32 w = gViewerWindow->getWindowWidthRaw(); LL_DEBUGS() << "Initializing width spinner (" << width_ctrl->getName() << "): " << w << LL_ENDL; width_ctrl->setValue(w); - if(getActiveSnapshotType(floater) == LLSnapshotLivePreview::SNAPSHOT_TEXTURE) + if(getActiveSnapshotType(floater) == LLPanelSnapshot::SNAPSHOT_TEXTURE) { width_ctrl->setIncrement(w >> 1); } @@ -391,7 +405,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) S32 h = gViewerWindow->getWindowHeightRaw(); LL_DEBUGS() << "Initializing height spinner (" << height_ctrl->getName() << "): " << h << LL_ENDL; height_ctrl->setValue(h); - if(getActiveSnapshotType(floater) == LLSnapshotLivePreview::SNAPSHOT_TEXTURE) + if(getActiveSnapshotType(floater) == LLPanelSnapshot::SNAPSHOT_TEXTURE) { height_ctrl->setIncrement(h >> 1); } @@ -448,29 +462,29 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) floater->getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown")); floater->getChild("file_size_label")->setColor( - shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD + shot_type == LLPanelSnapshot::SNAPSHOT_POSTCARD && got_bytes && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" )); // Update the width and height spinners based on the corresponding resolution combos. (?) switch(shot_type) { - case LLSnapshotLivePreview::SNAPSHOT_WEB: + case LLPanelSnapshot::SNAPSHOT_WEB: layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; floater->getChild("layer_types")->setValue("colors"); setResolution(floater, "profile_size_combo"); break; - case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: + case LLPanelSnapshot::SNAPSHOT_POSTCARD: layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; floater->getChild("layer_types")->setValue("colors"); setResolution(floater, "postcard_size_combo"); break; - case LLSnapshotLivePreview::SNAPSHOT_TEXTURE: + case LLPanelSnapshot::SNAPSHOT_TEXTURE: layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; floater->getChild("layer_types")->setValue("colors"); setResolution(floater, "texture_size_combo"); break; - case LLSnapshotLivePreview::SNAPSHOT_LOCAL: + case LLPanelSnapshot::SNAPSHOT_LOCAL: setResolution(floater, "local_size_combo"); break; default: @@ -686,7 +700,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde LLSnapshotLivePreview *previewp = getPreviewView(view) ; // Don't round texture sizes; textures are commonly stretched in world, profiles, etc and need to be "squashed" during upload, not cropped here - if(LLSnapshotLivePreview::SNAPSHOT_TEXTURE == getActiveSnapshotType(view)) + if(LLPanelSnapshot::SNAPSHOT_TEXTURE == getActiveSnapshotType(view)) { previewp->mKeepAspectRatio = FALSE ; return ; @@ -813,7 +827,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL new_height = spanel->getTypedPreviewHeight(); // Limit custom size for inventory snapshots to 512x512 px. - if (getActiveSnapshotType(view) == LLSnapshotLivePreview::SNAPSHOT_TEXTURE) + if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) { new_width = llmin(new_width, MAX_TEXTURE_SIZE); new_height = llmin(new_height, MAX_TEXTURE_SIZE); @@ -851,7 +865,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL { getWidthSpinner(view)->setValue(width); getHeightSpinner(view)->setValue(height); - if (getActiveSnapshotType(view) == LLSnapshotLivePreview::SNAPSHOT_TEXTURE) + if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) { getWidthSpinner(view)->setIncrement(width >> 1); getHeightSpinner(view)->setIncrement(height >> 1); @@ -975,7 +989,7 @@ void LLFloaterSnapshot::Impl::setImageSizeSpinnersValues(LLFloaterSnapshot *view { getWidthSpinner(view)->forceSetValue(width); getHeightSpinner(view)->forceSetValue(height); - if (getActiveSnapshotType(view) == LLSnapshotLivePreview::SNAPSHOT_TEXTURE) + if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) { getWidthSpinner(view)->setIncrement(width >> 1); getHeightSpinner(view)->setIncrement(height >> 1); @@ -1035,13 +1049,27 @@ void LLFloaterSnapshot::Impl::onSendingPostcardFinished(bool status) setStatus(STATUS_FINISHED, status, "postcard"); } +///---------------------------------------------------------------------------- +/// Class LLFloaterSnapshotBase +///---------------------------------------------------------------------------- + +// Default constructor +LLFloaterSnapshotBase::LLFloaterSnapshotBase(const LLSD& key) + : LLFloater(key) +{ +} + +LLFloaterSnapshotBase::~LLFloaterSnapshotBase() +{ +} + ///---------------------------------------------------------------------------- /// Class LLFloaterSnapshot ///---------------------------------------------------------------------------- // Default constructor LLFloaterSnapshot::LLFloaterSnapshot(const LLSD& key) - : LLFloater(key), + : LLFloaterSnapshotBase(key), mRefreshBtn(NULL), mRefreshLabel(NULL), mSucceessLblPanel(NULL), @@ -1377,7 +1405,7 @@ BOOL LLFloaterSnapshot::saveLocal() { LL_DEBUGS() << "saveLocal" << LL_ENDL; // FIXME: duplicated code - LLFloaterSnapshot* instance = findInstance(); + LLFloaterSnapshot* instance = findInstance(); if (!instance) { llassert(instance != NULL); diff --git a/indra/newview/llfloatersnapshot.h b/indra/newview/llfloatersnapshot.h index 0bb9474bb5..5f9857c8c5 100755 --- a/indra/newview/llfloatersnapshot.h +++ b/indra/newview/llfloatersnapshot.h @@ -31,17 +31,45 @@ class LLSpinCtrl; -class LLFloaterSnapshot : public LLFloater +class LLFloaterSnapshotBase : public LLFloater +{ + LOG_CLASS(LLFloaterSnapshotBase); + +public: + typedef enum e_snapshot_format + { + SNAPSHOT_FORMAT_PNG, + SNAPSHOT_FORMAT_JPEG, + SNAPSHOT_FORMAT_BMP + } ESnapshotFormat; + + LLFloaterSnapshotBase(const LLSD& key); + virtual ~LLFloaterSnapshotBase(); + + ///*virtual*/ S32 notify(const LLSD& info); + + //static LLFloaterSnapshotBase* getInstance(); + //static LLFloaterSnapshotBase* findInstance(); + //static void saveTexture(); + //static BOOL saveLocal(); + //static void postSave(); + +protected: + class ImplBase; + //ImplBase& impl; +}; + +class LLFloaterSnapshot : public LLFloaterSnapshotBase { LOG_CLASS(LLFloaterSnapshot); public: - typedef enum e_snapshot_format - { - SNAPSHOT_FORMAT_PNG, - SNAPSHOT_FORMAT_JPEG, - SNAPSHOT_FORMAT_BMP - } ESnapshotFormat; + //typedef enum e_snapshot_format + //{ + // SNAPSHOT_FORMAT_PNG, + // SNAPSHOT_FORMAT_JPEG, + // SNAPSHOT_FORMAT_BMP + //} ESnapshotFormat; LLFloaterSnapshot(const LLSD& key); virtual ~LLFloaterSnapshot(); @@ -76,6 +104,13 @@ private: Impl& impl; }; +class LLFloaterSnapshotBase::ImplBase +{ +public: + ImplBase(); + ~ImplBase(); +}; + class LLSnapshotFloaterView : public LLFloaterView { public: diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index c48b1a3325..984ba587ed 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -241,7 +241,7 @@ void LLTwitterPhotoPanel::onVisibilityChange(BOOL visible) mPreviewHandle = previewp->getHandle(); previewp->setContainer(this); - previewp->setSnapshotType(previewp->SNAPSHOT_WEB); + previewp->setSnapshotType(LLPanelSnapshot::SNAPSHOT_WEB); previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index c553d3d338..b351be8de9 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -39,6 +39,8 @@ #include "llerror.h" #include "llfilepicker.h" #include "llfloaterperms.h" +#include "llfloaterreg.h" +#include "llfloateroutfitsnapshot.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" #include "lllocalbitmaps.h" @@ -636,6 +638,7 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() mMenu->setItemVisible("collapse", FALSE); mMenu->setItemVisible("upload_photo", TRUE); mMenu->setItemVisible("select_photo", TRUE); + mMenu->setItemVisible("take_snapshot", TRUE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } @@ -659,6 +662,16 @@ void LLOutfitGalleryGearMenu::onSelectPhoto() } } +void LLOutfitGalleryGearMenu::onTakeSnapshot() +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + LLUUID selected_outfit_id = getSelectedOutfitID(); + if (gallery && !selected_outfit_id.isNull()) + { + gallery->onTakeSnapshot(selected_outfit_id); + } +} + void LLOutfitGallery::onTextureSelectionChanged(LLInventoryItem* itemp) { } @@ -715,6 +728,16 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) updates["name"] = new_name; update_inventory_item(linked_item->getUUID(), updates, NULL); mOutfitRenamePending.setNull(); + LLFloater* inv_floater = LLFloaterReg::getInstance("inventory"); + if (inv_floater) + { + inv_floater->closeFloater(); + } + LLFloater* appearance_floater = LLFloaterReg::getInstance("appearance"); + if (appearance_floater) + { + appearance_floater->setFocus(TRUE); + } } break; } @@ -798,10 +821,11 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) checkRemovePhoto(outfit_id); std::string upload_pending_name = outfit_id.asString(); + std::string upload_pending_desc = ""; LLAssetStorage::LLStoreAssetCallback callback = NULL; LLUUID photo_id = upload_new_resource(filename, // file upload_pending_name, - outfit_id.asString(), + upload_pending_desc, 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), @@ -926,3 +950,28 @@ void LLOutfitGallery::onSelectPhoto(LLUUID selected_outfit_id) floaterp->setFocus(TRUE); } } + +void LLOutfitGallery::onTakeSnapshot(LLUUID selected_outfit_id) +{ + LLFloaterReg::toggleInstanceOrBringToFront("outfit_snapshot"); + LLFloaterOutfitSnapshot::getInstance()->setOutfitID(selected_outfit_id); + LLFloaterOutfitSnapshot::getInstance()->setGallery(this); +} + +void LLOutfitGallery::onBeforeOutfitSnapshotSave() +{ + LLUUID selected_outfit_id = getSelectedOutfitUUID(); + if (!selected_outfit_id.isNull()) + { + checkRemovePhoto(selected_outfit_id); + } +} + +void LLOutfitGallery::onAfterOutfitSnapshotSave() +{ + LLUUID selected_outfit_id = getSelectedOutfitUUID(); + if (!selected_outfit_id.isNull()) + { + mOutfitLinkPending = selected_outfit_id; + } +} diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 285c8baf59..dbf891142d 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -85,6 +85,8 @@ public: /*virtual*/ void draw(); void onSelectPhoto(LLUUID selected_outfit_id); + void onTakeSnapshot(LLUUID selected_outfit_id); + /*virtual*/ void setFilterSubString(const std::string& string); @@ -102,6 +104,8 @@ public: void refreshOutfit(const LLUUID& category_id); void onTexturePickerCommit(LLTextureCtrl::ETexturePickOp op, LLUUID id); + void onBeforeOutfitSnapshotSave(); + void onAfterOutfitSnapshotSave(); protected: /*virtual*/ void onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id); /*virtual*/ void onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid); @@ -191,6 +195,7 @@ protected: private: /*virtual*/ void onUploadFoto(); /*virtual*/ void onSelectPhoto(); + /*virtual*/ void onTakeSnapshot(); }; class LLOutfitGalleryItem : public LLPanel diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index b657d2e285..31fe6839f3 100755 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -1092,6 +1092,7 @@ LLOutfitListGearMenuBase::LLOutfitListGearMenuBase(LLOutfitListBase* olist) registrar.add("Gear.UploadPhoto", boost::bind(&LLOutfitListGearMenuBase::onUploadFoto, this)); registrar.add("Gear.SelectPhoto", boost::bind(&LLOutfitListGearMenuBase::onSelectPhoto, this)); + registrar.add("Gear.TakeSnapshot", boost::bind(&LLOutfitListGearMenuBase::onTakeSnapshot, this)); enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenuBase::onEnable, this, _2)); enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenuBase::onVisible, this, _2)); @@ -1235,6 +1236,11 @@ void LLOutfitListGearMenuBase::onSelectPhoto() } +void LLOutfitListGearMenuBase::onTakeSnapshot() +{ + +} + LLOutfitListGearMenu::LLOutfitListGearMenu(LLOutfitListBase* olist) : LLOutfitListGearMenuBase(olist) {} @@ -1249,6 +1255,7 @@ void LLOutfitListGearMenu::onUpdateItemsVisibility() mMenu->setItemVisible("collapse", TRUE); mMenu->setItemVisible("upload_photo", FALSE); mMenu->setItemVisible("select_photo", FALSE); + mMenu->setItemVisible("take_snapshot", FALSE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index d7c549c417..696a18a36a 100755 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -165,6 +165,7 @@ protected: virtual void onUpdateItemsVisibility(); virtual void onUploadFoto(); virtual void onSelectPhoto(); + virtual void onTakeSnapshot(); const LLUUID& getSelectedOutfitID(); diff --git a/indra/newview/llpanelsnapshot.cpp b/indra/newview/llpanelsnapshot.cpp index 106fb4997e..ca62f2bdf5 100755 --- a/indra/newview/llpanelsnapshot.cpp +++ b/indra/newview/llpanelsnapshot.cpp @@ -76,11 +76,11 @@ void LLPanelSnapshot::onOpen(const LLSD& key) // e.g. attempt to send a large BMP image by email. if (old_format != new_format) { - LLFloaterSnapshot::getInstance()->notify(LLSD().with("image-format-change", true)); + getParentByType()->notify(LLSD().with("image-format-change", true)); } } -LLFloaterSnapshot::ESnapshotFormat LLPanelSnapshot::getImageFormat() const +LLFloaterSnapshotBase::ESnapshotFormat LLPanelSnapshot::getImageFormat() const { return LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG; } @@ -171,7 +171,7 @@ void LLPanelSnapshot::goBack() void LLPanelSnapshot::cancel() { goBack(); - LLFloaterSnapshot::getInstance()->notify(LLSD().with("set-ready", true)); + getParentByType()->notify(LLSD().with("set-ready", true)); } void LLPanelSnapshot::onCustomResolutionCommit() @@ -179,6 +179,7 @@ void LLPanelSnapshot::onCustomResolutionCommit() LLSD info; LLSpinCtrl *widthSpinner = getChild(getWidthSpinnerName()); LLSpinCtrl *heightSpinner = getChild(getHeightSpinnerName()); + //TODO: Refactoring - move this code into some virtual method of LLPanelSnapshotInventory if (getName() == "panel_snapshot_inventory") { S32 width = widthSpinner->getValue().asInteger(); @@ -197,17 +198,22 @@ void LLPanelSnapshot::onCustomResolutionCommit() info["w"] = widthSpinner->getValue().asInteger(); info["h"] = heightSpinner->getValue().asInteger(); } - LLFloaterSnapshot::getInstance()->notify(LLSD().with("custom-res-change", info)); + getParentByType()->notify(LLSD().with("custom-res-change", info)); } void LLPanelSnapshot::onResolutionComboCommit(LLUICtrl* ctrl) { LLSD info; info["combo-res-change"]["control-name"] = ctrl->getName(); - LLFloaterSnapshot::getInstance()->notify(info); + getParentByType()->notify(info); } void LLPanelSnapshot::onKeepAspectRatioCommit(LLUICtrl* ctrl) { - LLFloaterSnapshot::getInstance()->notify(LLSD().with("keep-aspect-change", ctrl->getValue().asBoolean())); + getParentByType()->notify(LLSD().with("keep-aspect-change", ctrl->getValue().asBoolean())); +} + +LLPanelSnapshot::ESnapshotType LLPanelSnapshot::getSnapshotType() +{ + return ESnapshotType::SNAPSHOT_WEB; } diff --git a/indra/newview/llpanelsnapshot.h b/indra/newview/llpanelsnapshot.h index 42ad798d60..d64ef3b75a 100755 --- a/indra/newview/llpanelsnapshot.h +++ b/indra/newview/llpanelsnapshot.h @@ -37,6 +37,14 @@ class LLSideTrayPanelContainer; class LLPanelSnapshot: public LLPanel { public: + enum ESnapshotType + { + SNAPSHOT_POSTCARD, + SNAPSHOT_TEXTURE, + SNAPSHOT_LOCAL, + SNAPSHOT_WEB + }; + /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); @@ -51,7 +59,8 @@ public: virtual LLSpinCtrl* getWidthSpinner(); virtual LLSpinCtrl* getHeightSpinner(); virtual void enableAspectRatioCheckbox(BOOL enable); - virtual LLFloaterSnapshot::ESnapshotFormat getImageFormat() const; + virtual LLFloaterSnapshotBase::ESnapshotFormat getImageFormat() const; + virtual ESnapshotType getSnapshotType(); virtual void updateControls(const LLSD& info) = 0; ///< Update controls from saved settings void enableControls(BOOL enable); diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp index c55e230b5e..013a564908 100755 --- a/indra/newview/llpanelsnapshotinventory.cpp +++ b/indra/newview/llpanelsnapshotinventory.cpp @@ -32,14 +32,43 @@ #include "llspinctrl.h" #include "llfloatersnapshot.h" // FIXME: replace with a snapshot storage model +#include "llfloateroutfitsnapshot.h" #include "llpanelsnapshot.h" +#include "llsnapshotlivepreview.h" #include "llviewercontrol.h" // gSavedSettings /** * The panel provides UI for saving snapshot as an inventory texture. */ +class LLPanelSnapshotInventoryBase + : public LLPanelSnapshot +{ + LOG_CLASS(LLPanelSnapshotInventoryBase); + +public: + LLPanelSnapshotInventoryBase(); +// +// /*virtual*/ BOOL postBuild(); +// /*virtual*/ void onOpen(const LLSD& key); +// +// void onResolutionCommit(LLUICtrl* ctrl); +// +//private: +// /*virtual*/ std::string getWidthSpinnerName() const { return "inventory_snapshot_width"; } +// /*virtual*/ std::string getHeightSpinnerName() const { return "inventory_snapshot_height"; } +// /*virtual*/ std::string getAspectRatioCBName() const { return "inventory_keep_aspect_check"; } +// /*virtual*/ std::string getImageSizeComboName() const { return "texture_size_combo"; } +// /*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; } +// /*virtual*/ void updateControls(const LLSD& info); + +protected: + virtual void onSend() = 0; + /*virtual*/ LLPanelSnapshot::ESnapshotType getSnapshotType(); + +}; + class LLPanelSnapshotInventory -: public LLPanelSnapshot + : public LLPanelSnapshotInventoryBase { LOG_CLASS(LLPanelSnapshotInventory); @@ -58,10 +87,44 @@ private: /*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; } /*virtual*/ void updateControls(const LLSD& info); - void onSend(); + /*virtual*/ void onSend(); +}; + +class LLPanelOutfitSnapshotInventory + : public LLPanelSnapshotInventoryBase +{ + LOG_CLASS(LLPanelOutfitSnapshotInventory); + +public: + LLPanelOutfitSnapshotInventory(); + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + + void onResolutionCommit(LLUICtrl* ctrl); + + private: + /*virtual*/ std::string getWidthSpinnerName() const { return "inventory_snapshot_width"; } + /*virtual*/ std::string getHeightSpinnerName() const { return "inventory_snapshot_height"; } + /*virtual*/ std::string getAspectRatioCBName() const { return "inventory_keep_aspect_check"; } + /*virtual*/ std::string getImageSizeComboName() const { return "texture_size_combo"; } + /*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; } + /*virtual*/ void updateControls(const LLSD& info); + + /*virtual*/ void onSend(); }; -static LLPanelInjector panel_class("llpanelsnapshotinventory"); +static LLPanelInjector panel_class1("llpanelsnapshotinventory"); + +static LLPanelInjector panel_class2("llpaneloutfitsnapshotinventory"); + +LLPanelSnapshotInventoryBase::LLPanelSnapshotInventoryBase() +{ +} + +LLPanelSnapshot::ESnapshotType LLPanelSnapshotInventoryBase::getSnapshotType() +{ + return LLPanelSnapshot::SNAPSHOT_TEXTURE; +} LLPanelSnapshotInventory::LLPanelSnapshotInventory() { @@ -105,3 +168,46 @@ void LLPanelSnapshotInventory::onSend() LLFloaterSnapshot::saveTexture(); LLFloaterSnapshot::postSave(); } + +LLPanelOutfitSnapshotInventory::LLPanelOutfitSnapshotInventory() +{ + mCommitCallbackRegistrar.add("Inventory.SaveOutfitPhoto", boost::bind(&LLPanelOutfitSnapshotInventory::onSend, this)); + mCommitCallbackRegistrar.add("Inventory.Cancel", boost::bind(&LLPanelOutfitSnapshotInventory::cancel, this)); +} + +// virtual +BOOL LLPanelOutfitSnapshotInventory::postBuild() +{ + getChild(getWidthSpinnerName())->setAllowEdit(FALSE); + getChild(getHeightSpinnerName())->setAllowEdit(FALSE); + + getChild(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelOutfitSnapshotInventory::onResolutionCommit, this, _1)); + return LLPanelSnapshot::postBuild(); +} + +// virtual +void LLPanelOutfitSnapshotInventory::onOpen(const LLSD& key) +{ + getChild("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", LLGlobalEconomy::Singleton::getInstance()->getPriceUpload())); + LLPanelSnapshot::onOpen(key); +} + +// virtual +void LLPanelOutfitSnapshotInventory::updateControls(const LLSD& info) +{ + const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true; + getChild("save_btn")->setEnabled(have_snapshot); +} + +void LLPanelOutfitSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl) +{ + BOOL current_window_selected = (getChild(getImageSizeComboName())->getCurrentIndex() == 3); + getChild(getWidthSpinnerName())->setVisible(!current_window_selected); + getChild(getHeightSpinnerName())->setVisible(!current_window_selected); +} + +void LLPanelOutfitSnapshotInventory::onSend() +{ + LLFloaterOutfitSnapshot::saveTexture(); + LLFloaterOutfitSnapshot::postSave(); +} diff --git a/indra/newview/llpanelsnapshotlocal.cpp b/indra/newview/llpanelsnapshotlocal.cpp index 01dfdc4ece..954eb63a28 100755 --- a/indra/newview/llpanelsnapshotlocal.cpp +++ b/indra/newview/llpanelsnapshotlocal.cpp @@ -33,6 +33,7 @@ #include "llfloatersnapshot.h" // FIXME: replace with a snapshot storage model #include "llpanelsnapshot.h" +#include "llsnapshotlivepreview.h" #include "llviewercontrol.h" // gSavedSettings #include "llviewerwindow.h" @@ -55,8 +56,9 @@ private: /*virtual*/ std::string getAspectRatioCBName() const { return "local_keep_aspect_check"; } /*virtual*/ std::string getImageSizeComboName() const { return "local_size_combo"; } /*virtual*/ std::string getImageSizePanelName() const { return "local_image_size_lp"; } - /*virtual*/ LLFloaterSnapshot::ESnapshotFormat getImageFormat() const; - /*virtual*/ void updateControls(const LLSD& info); + /*virtual*/ LLFloaterSnapshotBase::ESnapshotFormat getImageFormat() const; + /*virtual*/ LLPanelSnapshot::ESnapshotType getSnapshotType(); + /*virtual*/ void updateControls(const LLSD& info); S32 mLocalFormat; @@ -94,9 +96,9 @@ void LLPanelSnapshotLocal::onOpen(const LLSD& key) } // virtual -LLFloaterSnapshot::ESnapshotFormat LLPanelSnapshotLocal::getImageFormat() const +LLFloaterSnapshotBase::ESnapshotFormat LLPanelSnapshotLocal::getImageFormat() const { - LLFloaterSnapshot::ESnapshotFormat fmt = LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; + LLFloaterSnapshotBase::ESnapshotFormat fmt = LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; LLComboBox* local_format_combo = getChild("local_format_combo"); const std::string id = local_format_combo->getValue().asString(); @@ -119,8 +121,8 @@ LLFloaterSnapshot::ESnapshotFormat LLPanelSnapshotLocal::getImageFormat() const // virtual void LLPanelSnapshotLocal::updateControls(const LLSD& info) { - LLFloaterSnapshot::ESnapshotFormat fmt = - (LLFloaterSnapshot::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); + LLFloaterSnapshotBase::ESnapshotFormat fmt = + (LLFloaterSnapshotBase::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); getChild("local_format_combo")->selectNthItem((S32) fmt); const bool show_quality_ctrls = (fmt == LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); @@ -174,3 +176,8 @@ void LLPanelSnapshotLocal::onSaveFlyoutCommit(LLUICtrl* ctrl) cancel(); } } + +LLPanelSnapshot::ESnapshotType LLPanelSnapshotLocal::getSnapshotType() +{ + return LLPanelSnapshot::SNAPSHOT_LOCAL; +} diff --git a/indra/newview/llpanelsnapshotpostcard.cpp b/indra/newview/llpanelsnapshotpostcard.cpp index 8e37b1418c..2884313f60 100644 --- a/indra/newview/llpanelsnapshotpostcard.cpp +++ b/indra/newview/llpanelsnapshotpostcard.cpp @@ -38,6 +38,7 @@ #include "llfloatersnapshot.h" // FIXME: replace with a snapshot storage model #include "llpanelsnapshot.h" #include "llpostcard.h" +#include "llsnapshotlivepreview.h" #include "llviewercontrol.h" // gSavedSettings #include "llviewerwindow.h" @@ -63,8 +64,9 @@ private: /*virtual*/ std::string getAspectRatioCBName() const { return "postcard_keep_aspect_check"; } /*virtual*/ std::string getImageSizeComboName() const { return "postcard_size_combo"; } /*virtual*/ std::string getImageSizePanelName() const { return "postcard_image_size_lp"; } - /*virtual*/ LLFloaterSnapshot::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG; } - /*virtual*/ void updateControls(const LLSD& info); + /*virtual*/ LLFloaterSnapshotBase::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshotBase::SNAPSHOT_FORMAT_JPEG; } + /*virtual*/ LLPanelSnapshot::ESnapshotType getSnapshotType(); + /*virtual*/ void updateControls(const LLSD& info); bool missingSubjMsgAlertCallback(const LLSD& notification, const LLSD& response); void sendPostcard(); @@ -242,3 +244,8 @@ void LLPanelSnapshotPostcard::onSend() // Send postcard. sendPostcard(); } + +LLPanelSnapshot::ESnapshotType LLPanelSnapshotPostcard::getSnapshotType() +{ + return LLPanelSnapshot::SNAPSHOT_POSTCARD; +} diff --git a/indra/newview/llpanelsnapshotprofile.cpp b/indra/newview/llpanelsnapshotprofile.cpp index 8949eb73eb..b6fc45fb63 100755 --- a/indra/newview/llpanelsnapshotprofile.cpp +++ b/indra/newview/llpanelsnapshotprofile.cpp @@ -58,7 +58,7 @@ private: /*virtual*/ std::string getAspectRatioCBName() const { return "profile_keep_aspect_check"; } /*virtual*/ std::string getImageSizeComboName() const { return "profile_size_combo"; } /*virtual*/ std::string getImageSizePanelName() const { return "profile_image_size_lp"; } - /*virtual*/ LLFloaterSnapshot::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; } + /*virtual*/ LLFloaterSnapshotBase::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshotBase::SNAPSHOT_FORMAT_PNG; } /*virtual*/ void updateControls(const LLSD& info); void onSend(); diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 8561a89ae5..d40694f2f4 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -86,8 +86,8 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param mNeedsFlash(TRUE), mSnapshotQuality(gSavedSettings.getS32("SnapshotQuality")), mDataSize(0), - mSnapshotType(SNAPSHOT_POSTCARD), - mSnapshotFormat(LLFloaterSnapshot::ESnapshotFormat(gSavedSettings.getS32("SnapshotFormat"))), + mSnapshotType(LLPanelSnapshot::ESnapshotType::SNAPSHOT_POSTCARD), + mSnapshotFormat(LLFloaterSnapshotBase::ESnapshotFormat(gSavedSettings.getS32("SnapshotFormat"))), mSnapshotUpToDate(FALSE), mCameraPos(LLViewerCamera::getInstance()->getOrigin()), mCameraRot(LLViewerCamera::getInstance()->getQuaternion()), @@ -737,7 +737,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) previewp->getWidth(), previewp->getHeight(), previewp->mKeepAspectRatio,//gSavedSettings.getBOOL("KeepAspectForSnapshot"), - previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_TEXTURE, + previewp->getSnapshotType() == LLPanelSnapshot::SNAPSHOT_TEXTURE, previewp->mAllowRenderUI && gSavedSettings.getBOOL("RenderUIInSnapshot"), FALSE, previewp->mSnapshotBufferType, @@ -813,7 +813,7 @@ void LLSnapshotLivePreview::prepareFreezeFrame() mViewerImage[mCurImageIndex] = LLViewerTextureManager::getLocalTexture(scaled.get(), FALSE); LLPointer curr_preview_image = mViewerImage[mCurImageIndex]; gGL.getTexUnit(0)->bind(curr_preview_image); - curr_preview_image->setFilteringOption(getSnapshotType() == SNAPSHOT_TEXTURE ? LLTexUnit::TFO_ANISOTROPIC : LLTexUnit::TFO_POINT); + curr_preview_image->setFilteringOption(getSnapshotType() == LLPanelSnapshot::ESnapshotType::SNAPSHOT_TEXTURE ? LLTexUnit::TFO_ANISOTROPIC : LLTexUnit::TFO_POINT); curr_preview_image->setAddressMode(LLTexUnit::TAM_CLAMP); @@ -827,7 +827,7 @@ void LLSnapshotLivePreview::prepareFreezeFrame() S32 LLSnapshotLivePreview::getEncodedImageWidth() const { S32 width = getWidth(); - if (getSnapshotType() == SNAPSHOT_TEXTURE) + if (getSnapshotType() == LLPanelSnapshot::ESnapshotType::SNAPSHOT_TEXTURE) { width = LLImageRaw::biasedDimToPowerOfTwo(width,MAX_TEXTURE_SIZE); } @@ -836,7 +836,7 @@ S32 LLSnapshotLivePreview::getEncodedImageWidth() const S32 LLSnapshotLivePreview::getEncodedImageHeight() const { S32 height = getHeight(); - if (getSnapshotType() == SNAPSHOT_TEXTURE) + if (getSnapshotType() == LLPanelSnapshot::ESnapshotType::SNAPSHOT_TEXTURE) { height = LLImageRaw::biasedDimToPowerOfTwo(height,MAX_TEXTURE_SIZE); } @@ -854,7 +854,7 @@ LLPointer LLSnapshotLivePreview::getEncodedImage() mPreviewImage->getHeight(), mPreviewImage->getComponents()); - if (getSnapshotType() == SNAPSHOT_TEXTURE) + if (getSnapshotType() == LLPanelSnapshot::ESnapshotType::SNAPSHOT_TEXTURE) { // We don't store the intermediate formatted image in mFormattedImage in the J2C case LL_DEBUGS() << "Encoding new image of format J2C" << LL_ENDL; @@ -903,13 +903,13 @@ void LLSnapshotLivePreview::estimateDataSize() // Compression ratio F32 ratio = 1.0; - if (getSnapshotType() == SNAPSHOT_TEXTURE) + if (getSnapshotType() == LLPanelSnapshot::SNAPSHOT_TEXTURE) { ratio = 8.0; // This is what we shoot for when compressing to J2C } else { - LLFloaterSnapshot::ESnapshotFormat format = getSnapshotFormat(); + LLFloaterSnapshotBase::ESnapshotFormat format = getSnapshotFormat(); switch (format) { case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG: @@ -947,7 +947,7 @@ LLPointer LLSnapshotLivePreview::getFormattedImage() } // Create the new formatted image of the appropriate format. - LLFloaterSnapshot::ESnapshotFormat format = getSnapshotFormat(); + LLFloaterSnapshotBase::ESnapshotFormat format = getSnapshotFormat(); LL_DEBUGS() << "Encoding new image of format " << format << LL_ENDL; switch (format) @@ -978,7 +978,7 @@ void LLSnapshotLivePreview::setSize(S32 w, S32 h) setHeight(h); } -void LLSnapshotLivePreview::setSnapshotFormat(LLFloaterSnapshot::ESnapshotFormat format) +void LLSnapshotLivePreview::setSnapshotFormat(LLFloaterSnapshotBase::ESnapshotFormat format) { if (mSnapshotFormat != format) { @@ -993,7 +993,7 @@ void LLSnapshotLivePreview::getSize(S32& w, S32& h) const h = getHeight(); } -void LLSnapshotLivePreview::saveTexture() +void LLSnapshotLivePreview::saveTexture(BOOL outfit_snapshot, std::string name) { LL_DEBUGS() << "saving texture: " << mPreviewImage->getWidth() << "x" << mPreviewImage->getHeight() << LL_ENDL; // gen a new uuid for this asset @@ -1035,13 +1035,17 @@ void LLSnapshotLivePreview::saveTexture() LLAssetStorage::LLStoreAssetCallback callback = NULL; S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); void *userdata = NULL; + std::string res_name = outfit_snapshot ? name : "Snapshot : " + pos_string; + std::string res_desc = outfit_snapshot ? "" : "Taken by " + who_took_it + " at " + pos_string; + LLFolderType::EType folder_type = outfit_snapshot ? LLFolderType::FT_NONE : LLFolderType::FT_SNAPSHOT_CATEGORY; + LLInventoryType::EType inv_type = outfit_snapshot ? LLInventoryType::IT_NONE : LLInventoryType::IT_SNAPSHOT; upload_new_resource(tid, // tid LLAssetType::AT_TEXTURE, - "Snapshot : " + pos_string, - "Taken by " + who_took_it + " at " + pos_string, + res_name, + res_desc, 0, - LLFolderType::FT_SNAPSHOT_CATEGORY, - LLInventoryType::IT_SNAPSHOT, + folder_type, + inv_type, PERM_ALL, // Note: Snapshots to inventory is a special case of content upload LLFloaterPerms::getGroupPerms("Uploads"), // that is more permissive than other uploads LLFloaterPerms::getEveryonePerms("Uploads"), diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h index 57e5d83f8e..b822707d29 100644 --- a/indra/newview/llsnapshotlivepreview.h +++ b/indra/newview/llsnapshotlivepreview.h @@ -40,14 +40,6 @@ class LLSnapshotLivePreview : public LLView { LOG_CLASS(LLSnapshotLivePreview); public: - enum ESnapshotType - { - SNAPSHOT_POSTCARD, - SNAPSHOT_TEXTURE, - SNAPSHOT_LOCAL, - SNAPSHOT_WEB - }; - struct Params : public LLInitParam::Block { @@ -80,8 +72,8 @@ public: void setMaxImageSize(S32 size) ; S32 getMaxImageSize() {return mMaxImageSize ;} - ESnapshotType getSnapshotType() const { return mSnapshotType; } - LLFloaterSnapshot::ESnapshotFormat getSnapshotFormat() const { return mSnapshotFormat; } + LLPanelSnapshot::ESnapshotType getSnapshotType() const { return mSnapshotType; } + LLFloaterSnapshotBase::ESnapshotFormat getSnapshotFormat() const { return mSnapshotFormat; } BOOL getSnapshotUpToDate() const { return mSnapshotUpToDate; } BOOL isSnapshotActive() { return mSnapshotActive; } LLViewerTexture* getThumbnailImage() const { return mThumbnailImage ; } @@ -98,8 +90,8 @@ public: void setImageScaled(BOOL scaled) { mImageScaled[mCurImageIndex] = scaled; } const LLVector3d& getPosTakenGlobal() const { return mPosTakenGlobal; } - void setSnapshotType(ESnapshotType type) { mSnapshotType = type; } - void setSnapshotFormat(LLFloaterSnapshot::ESnapshotFormat format); + void setSnapshotType(LLPanelSnapshot::ESnapshotType type) { mSnapshotType = type; } + void setSnapshotFormat(LLFloaterSnapshotBase::ESnapshotFormat format); bool setSnapshotQuality(S32 quality, bool set_by_user = true); void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; } void setAllowRenderUI(BOOL allow) { mAllowRenderUI = allow; } @@ -107,7 +99,7 @@ public: void setFilter(std::string filter_name) { mFilterName = filter_name; } std::string getFilter() const { return mFilterName; } void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f); - void saveTexture(); + void saveTexture(BOOL outfit_snapshot = FALSE, std::string name = ""); BOOL saveLocal(); LLPointer getFormattedImage(); @@ -169,8 +161,8 @@ private: LLVector3d mPosTakenGlobal; S32 mSnapshotQuality; S32 mDataSize; - ESnapshotType mSnapshotType; - LLFloaterSnapshot::ESnapshotFormat mSnapshotFormat; + LLPanelSnapshot::ESnapshotType mSnapshotType; + LLFloaterSnapshotBase::ESnapshotFormat mSnapshotFormat; BOOL mSnapshotUpToDate; LLFrameTimer mFallAnimTimer; LLVector3 mCameraPos; diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 14a2627f27..fd48598925 100755 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -94,6 +94,7 @@ #include "llfloaterobjectweights.h" #include "llfloateropenobject.h" #include "llfloateroutbox.h" +#include "llfloateroutfitsnapshot.h" #include "llfloaterpathfindingcharacters.h" #include "llfloaterpathfindingconsole.h" #include "llfloaterpathfindinglinksets.h" @@ -332,7 +333,8 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("outfit_snapshot", "floater_outfit_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index f8e50ba463..7b87d210c0 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -556,7 +556,7 @@ class LLFileTakeSnapshotToDisk : public view_listener_t { gViewerWindow->playSnapshotAnimAndSound(); LLPointer formatted; - LLFloaterSnapshot::ESnapshotFormat fmt = (LLFloaterSnapshot::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); + LLFloaterSnapshotBase::ESnapshotFormat fmt = (LLFloaterSnapshotBase::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); switch (fmt) { case LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG: diff --git a/indra/newview/skins/default/xui/en/floater_outfit_snapshot.xml b/indra/newview/skins/default/xui/en/floater_outfit_snapshot.xml new file mode 100644 index 0000000000..7b88b07ca6 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_outfit_snapshot.xml @@ -0,0 +1,462 @@ + + + + unknown + + + Sending Email + + + Posting to Facebook + + + Posting + + + Saving to Inventory + + + Saving to Computer + + + Image uploaded + + + Image uploaded + + + Email Sent! + + + Saved to Inventory! + + + Saved to Computer! + + + Failed to upload image to your Facebook timeline. + + + Failed to upload image to your Profile Feed. + + + Failed to send email. + + + Failed to save to inventory. + + + Failed to save to computer. + + + + \ No newline at end of file -- cgit v1.3 From 0a73840dd8e350cd936b681c0cc5131905eb3b09 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Thu, 5 May 2016 16:30:41 +0300 Subject: MAINT-6381 Right click on Outfit Folder behavior --- indra/newview/lloutfitgallery.cpp | 103 ++++++++++++++++++++- indra/newview/lloutfitgallery.h | 27 ++++++ .../default/xui/en/panel_outfit_gallery_item.xml | 3 +- 3 files changed, 130 insertions(+), 3 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index b351be8de9..a36728e6ac 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -44,6 +44,7 @@ #include "llinventoryfunctions.h" #include "llinventorymodel.h" #include "lllocalbitmaps.h" +#include "llnotificationsutil.h" #include "lltexturectrl.h" #include "llviewermenufile.h" #include "llwearableitemslist.h" @@ -98,6 +99,7 @@ BOOL LLOutfitGallery::postBuild() BOOL rv = LLOutfitListBase::postBuild(); mScrollPanel = getChild("gallery_scroll_panel"); mGalleryPanel = getChild("gallery_panel"); + mOutfitGalleryMenu = new LLOutfitGalleryContextMenu(this); return rv; } @@ -352,6 +354,8 @@ void LLOutfitGallery::moveRowPanel(LLPanel* stack, int left, int bottom) LLOutfitGallery::~LLOutfitGallery() { + delete mOutfitGalleryMenu; + if (gInventory.containsObserver(mTexturesObserver)) { gInventory.removeObserver(mTexturesObserver); @@ -486,7 +490,7 @@ void LLOutfitGallery::onOutfitRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLU { uuid_vec_t selected_uuids; selected_uuids.push_back(cat_id); - mOutfitMenu->show(ctrl, selected_uuids, x, y); + mOutfitGalleryMenu->show(ctrl, selected_uuids, x, y); } } @@ -604,6 +608,12 @@ BOOL LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) return LLUICtrl::handleMouseDown(x, y, mask); } +BOOL LLOutfitGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + setFocus(TRUE); + return LLUICtrl::handleRightMouseDown(x, y, mask); +} + void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) { mImageAssetId = image_asset_id; @@ -626,6 +636,97 @@ void LLOutfitGalleryItem::setDefaultImage() mDefaultImage = true; } +LLContextMenu* LLOutfitGalleryContextMenu::createMenu() +{ + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + LLUUID selected_id = mUUIDs.front(); + + registrar.add("Outfit.WearReplace", + boost::bind(&LLAppearanceMgr::replaceCurrentOutfit, &LLAppearanceMgr::instance(), selected_id)); + registrar.add("Outfit.WearAdd", + boost::bind(&LLAppearanceMgr::addCategoryToCurrentOutfit, &LLAppearanceMgr::instance(), selected_id)); + registrar.add("Outfit.TakeOff", + 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(&LLOutfitGalleryContextMenu::onRemoveOutfit, this, selected_id)); + registrar.add("Outfit.Create", boost::bind(&LLOutfitGalleryContextMenu::onCreate, this, _2)); + registrar.add("Outfit.UploadPhoto", boost::bind(&LLOutfitGalleryContextMenu::onUploadPhoto, this, selected_id)); + registrar.add("Outfit.SelectPhoto", boost::bind(&LLOutfitGalleryContextMenu::onSelectPhoto, this, selected_id)); + registrar.add("Outfit.TakeSnapshot", boost::bind(&LLOutfitGalleryContextMenu::onTakeSnapshot, 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)); + + return createFromFile("menu_gallery_outfit_tab.xml"); +} + +void LLOutfitGalleryContextMenu::onUploadPhoto(const LLUUID& outfit_cat_id) +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + if (gallery && outfit_cat_id.notNull()) + { + gallery->uploadPhoto(outfit_cat_id); + } +} + +void LLOutfitGalleryContextMenu::onSelectPhoto(const LLUUID& outfit_cat_id) +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + if (gallery && outfit_cat_id.notNull()) + { + gallery->onSelectPhoto(outfit_cat_id); + } +} + +void LLOutfitGalleryContextMenu::onTakeSnapshot(const LLUUID& outfit_cat_id) +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + if (gallery && outfit_cat_id.notNull()) + { + gallery->onTakeSnapshot(outfit_cat_id); + } +} + +void LLOutfitGalleryContextMenu::onRemoveOutfit(const LLUUID& outfit_cat_id) +{ + LLNotificationsUtil::add("DeleteOutfits", LLSD(), LLSD(), boost::bind(&LLOutfitGalleryContextMenu::onOutfitsRemovalConfirmation, this, _1, _2, outfit_cat_id)); +} + +void LLOutfitGalleryContextMenu::onOutfitsRemovalConfirmation(const LLSD& notification, const LLSD& response, const LLUUID& outfit_cat_id) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) return; // canceled + + if (outfit_cat_id.notNull()) + { + gInventory.removeCategory(outfit_cat_id); + } +} + +void LLOutfitGalleryContextMenu::onCreate(const LLSD& data) +{ + LLWearableType::EType type = LLWearableType::typeNameToType(data.asString()); + if (type == LLWearableType::WT_NONE) + { + LL_WARNS() << "Invalid wearable type" << LL_ENDL; + return; + } + + LLAgentWearables::createWearable(type, true); +} + +bool LLOutfitGalleryContextMenu::onEnable(LLSD::String param) +{ + return LLOutfitContextMenu::onEnable(param); +} + +bool LLOutfitGalleryContextMenu::onVisible(LLSD::String param) +{ + return LLOutfitContextMenu::onVisible(param); +} + LLOutfitGalleryGearMenu::LLOutfitGalleryGearMenu(LLOutfitListBase* olist) : LLOutfitListGearMenuBase(olist) { diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index dbf891142d..b8c7d66406 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -43,6 +43,7 @@ class LLOutfitGallery; class LLOutfitGalleryItem; class LLOutfitListGearMenuBase; class LLOutfitGalleryGearMenu; +class LLOutfitGalleryContextMenu; class LLUpdateGalleryOnPhotoLinked : public LLInventoryCallback { @@ -57,6 +58,7 @@ class LLOutfitGallery : public LLOutfitListBase { public: friend class LLOutfitGalleryGearMenu; + friend class LLOutfitGalleryContextMenu; friend class LLUpdateGalleryOnPhotoLinked; struct Params @@ -169,6 +171,8 @@ private: int mGalleryWidth; int mRowPanWidthFactor; int mGalleryWidthFactor; + + LLListContextMenu* mOutfitGalleryMenu; LLHandle mFloaterHandle; @@ -183,6 +187,28 @@ private: LLInventoryCategoriesObserver* mTexturesObserver; LLInventoryCategoriesObserver* mOutfitsObserver; }; +class LLOutfitGalleryContextMenu : public LLOutfitContextMenu +{ +public: + + friend class LLOutfitGallery; + LLOutfitGalleryContextMenu(LLOutfitListBase* outfit_list) + : LLOutfitContextMenu(outfit_list), + mOutfitList(outfit_list){} +protected: + /* virtual */ LLContextMenu* createMenu(); + bool onEnable(LLSD::String param); + bool onVisible(LLSD::String param); + void onUploadPhoto(const LLUUID& outfit_cat_id); + void onSelectPhoto(const LLUUID& outfit_cat_id); + void onTakeSnapshot(const LLUUID& outfit_cat_id); + void onCreate(const LLSD& data); + void onRemoveOutfit(const LLUUID& outfit_cat_id); + void onOutfitsRemovalConfirmation(const LLSD& notification, const LLSD& response, const LLUUID& outfit_cat_id); +private: + LLOutfitListBase* mOutfitList; +}; + class LLOutfitGalleryGearMenu : public LLOutfitListGearMenuBase { @@ -210,6 +236,7 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ void draw(); /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); void setDefaultImage(); void setImageAssetId(LLUUID asset_id); diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml index eede209e91..77c546c6e7 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml @@ -3,8 +3,7 @@ background_visible="false" background_opaque="false" bg_alpha_color="FrogGreen" - bg_opaque_color="FrogGreen" - border_color="Red" + bg_opaque_color="FrogGreen" border="false" bevel_style="none" follows="left|top" -- cgit v1.3 From 5bee6f1e5e5ec9d25283ecf1815b57e5921f2c47 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 18 May 2016 15:02:15 +0300 Subject: MAINT-6421 Inappropriate menu items are presented in gear menu when no outfit is selected in Visual Outfit Browser --- indra/newview/lloutfitgallery.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index a36728e6ac..e6c41b612f 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -735,11 +735,12 @@ LLOutfitGalleryGearMenu::LLOutfitGalleryGearMenu(LLOutfitListBase* olist) void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() { if (!mMenu) return; + bool have_selection = getSelectedOutfitID().notNull(); mMenu->setItemVisible("expand", FALSE); mMenu->setItemVisible("collapse", FALSE); - mMenu->setItemVisible("upload_photo", TRUE); - mMenu->setItemVisible("select_photo", TRUE); - mMenu->setItemVisible("take_snapshot", TRUE); + mMenu->setItemVisible("upload_photo", have_selection); + mMenu->setItemVisible("select_photo", have_selection); + mMenu->setItemVisible("take_snapshot", have_selection); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } -- cgit v1.3 From 5b49f5c56e0178d1f2f655ee678a9bea58edd5d5 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 25 May 2016 18:52:57 +0300 Subject: MAINT-6440 FIXED Inappropriate outfit is worn after clicking Wear button in Visual Outfit Browser --- indra/newview/lloutfitgallery.cpp | 5 ++++ indra/newview/lloutfitgallery.h | 2 ++ indra/newview/llpaneloutfitsinventory.cpp | 50 +++++++++++++++++++++++-------- indra/newview/llpaneloutfitsinventory.h | 3 +- 4 files changed, 47 insertions(+), 13 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index e6c41b612f..f29fc53dea 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -508,6 +508,11 @@ void LLOutfitGallery::onChangeOutfitSelection(LLWearableItemsList* list, const L } } +void LLOutfitGallery::wearSelectedOutfit() +{ + LLAppearanceMgr::instance().replaceCurrentOutfit(getSelectedOutfitUUID()); +} + bool LLOutfitGallery::hasItemSelected() { return false; diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index b8c7d66406..a22e86df83 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -89,6 +89,8 @@ public: void onSelectPhoto(LLUUID selected_outfit_id); void onTakeSnapshot(LLUUID selected_outfit_id); + void wearSelectedOutfit(); + /*virtual*/ void setFilterSubString(const std::string& string); diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index c0c1adddf3..3f700496a9 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -167,14 +167,22 @@ void LLPanelOutfitsInventory::onSearchEdit(const std::string& string) void LLPanelOutfitsInventory::onWearButtonClick() { - if (mMyOutfitsPanel->hasItemSelected()) + if(isOutfitsListPanelActive()) { - mMyOutfitsPanel->wearSelectedItems(); + if (mMyOutfitsPanel->hasItemSelected()) + { + mMyOutfitsPanel->wearSelectedItems(); + } + else + { + mMyOutfitsPanel->performAction("replaceoutfit"); + } } - else + else if(isOutfitsGalleryPanelActive()) { - mMyOutfitsPanel->performAction("replaceoutfit"); + mOutfitGalleryPanel->wearSelectedOutfit(); } + } bool LLPanelOutfitsInventory::onSaveCommit(const LLSD& notification, const LLSD& response) @@ -236,7 +244,7 @@ void LLPanelOutfitsInventory::initListCommandsHandlers() mListCommands = getChild("bottom_panel"); mListCommands->childSetAction("wear_btn", boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this)); mMyOutfitsPanel->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this)); - mOutfitGalleryPanel->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onGalleryTrashButtonClick, this)); + mOutfitGalleryPanel->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this)); } void LLPanelOutfitsInventory::updateListCommands() @@ -252,17 +260,19 @@ void LLPanelOutfitsInventory::updateListCommands() wear_btn->setEnabled(wear_enabled); wear_btn->setVisible(wear_visible); mSaveComboBtn->setMenuItemEnabled("save_outfit", make_outfit_enabled); - wear_btn->setToolTip(getString(mMyOutfitsPanel->hasItemSelected() ? "wear_items_tooltip" : "wear_outfit_tooltip")); + wear_btn->setToolTip(getString((!isOutfitsGalleryPanelActive() && mMyOutfitsPanel->hasItemSelected()) ? "wear_items_tooltip" : "wear_outfit_tooltip")); } void LLPanelOutfitsInventory::onTrashButtonClick() { - mMyOutfitsPanel->removeSelected(); -} - -void LLPanelOutfitsInventory::onGalleryTrashButtonClick() -{ - mOutfitGalleryPanel->removeSelected(); + if(isOutfitsListPanelActive()) + { + mMyOutfitsPanel->removeSelected(); + } + else if(isOutfitsGalleryPanelActive()) + { + mOutfitGalleryPanel->removeSelected(); + } } bool LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) @@ -309,6 +319,22 @@ bool LLPanelOutfitsInventory::isCOFPanelActive() const return mActivePanel->getName() == COF_TAB_NAME; } +bool LLPanelOutfitsInventory::isOutfitsListPanelActive() const +{ + if (!mActivePanel) return false; + + return mActivePanel->getName() == OUTFITS_TAB_NAME; +} + +bool LLPanelOutfitsInventory::isOutfitsGalleryPanelActive() const +{ + if (!mActivePanel) return false; + + return mActivePanel->getName() == OUTFIT_GALLERY_TAB_NAME; +} + + + void LLPanelOutfitsInventory::setWearablesLoading(bool val) { updateVerbs(); diff --git a/indra/newview/llpaneloutfitsinventory.h b/indra/newview/llpaneloutfitsinventory.h index efb9524a21..6a0ea04fa6 100644 --- a/indra/newview/llpaneloutfitsinventory.h +++ b/indra/newview/llpaneloutfitsinventory.h @@ -73,6 +73,8 @@ protected: void initTabPanels(); void onTabChange(); bool isCOFPanelActive() const; + bool isOutfitsListPanelActive() const; + bool isOutfitsGalleryPanelActive() const; private: LLPanelAppearanceTab* mActivePanel; @@ -91,7 +93,6 @@ protected: void onWearButtonClick(); void showGearMenu(); void onTrashButtonClick(); - void onGalleryTrashButtonClick(); bool isActionEnabled(const LLSD& userdata); void setWearablesLoading(bool val); void onWearablesLoaded(); -- cgit v1.3 From 2b9927863ff6826bc448379e2f829b1de5e6c3fb Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 30 May 2016 15:03:40 +0300 Subject: MAINT-6444 Outfits filter doesn't work in Outfit gallery --- indra/newview/lloutfitgallery.cpp | 42 ++++++++++++++++++++++++++++++++++++--- indra/newview/lloutfitgallery.h | 7 +++++++ 2 files changed, 46 insertions(+), 3 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index f29fc53dea..6a8256d41c 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -152,6 +152,11 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff) { removeFromGalleryLast(*it); } + for (std::vector::const_reverse_iterator it = mHiddenItems.rbegin(); it != mHiddenItems.rend(); ++it) + { + buf_items.push_back(*it); + } + mHiddenItems.clear(); mItemsInRow+= row_diff; updateGalleryWidth(); @@ -159,7 +164,9 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff) for (std::vector::const_iterator it = buf_items.begin(); it != buf_items.end(); ++it) { - addToGallery(*it); + (*it)->setHidden(false); + applyFilter(*it,sFilterSubString); + addToGallery(*it); } } @@ -214,6 +221,11 @@ LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item) { + if(item->isHidden()) + { + mHiddenItems.push_back(item); + return; + } mItemsAddedCount++; mItemIndexMap[item] = mItemsAddedCount - 1; int n = mItemsAddedCount; @@ -241,6 +253,11 @@ void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item) void LLOutfitGallery::removeFromGalleryLast(LLOutfitGalleryItem* item) { + if(item->isHidden()) + { + mHiddenItems.pop_back(); + return; + } int n_prev = mItemsAddedCount; int n = mItemsAddedCount - 1; int row_count = (n % mItemsInRow) == 0 ? n / mItemsInRow : n / mItemsInRow + 1; @@ -264,6 +281,11 @@ void LLOutfitGallery::removeFromGalleryLast(LLOutfitGalleryItem* item) void LLOutfitGallery::removeFromGalleryMiddle(LLOutfitGalleryItem* item) { + if(item->isHidden()) + { + mHiddenItems.erase(std::remove(mHiddenItems.begin(), mHiddenItems.end(), item), mHiddenItems.end()); + return; + } int n = mItemIndexMap[item]; mItemIndexMap.erase(item); std::vector saved; @@ -371,9 +393,8 @@ LLOutfitGallery::~LLOutfitGallery() void LLOutfitGallery::setFilterSubString(const std::string& string) { - //TODO: Implement filtering - sFilterSubString = string; + reArrangeRows(); } void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id) @@ -388,6 +409,20 @@ void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id) } } +void LLOutfitGallery::applyFilter(LLOutfitGalleryItem* item, const std::string& filter_substring) +{ + if (!item) return; + + std::string outfit_name = item->getItemName(); + LLStringUtil::toUpper(outfit_name); + + std::string cur_filter = filter_substring; + LLStringUtil::toUpper(cur_filter); + + bool hidden = (std::string::npos == outfit_name.find(cur_filter)); + item->setHidden(hidden); +} + void LLOutfitGallery::onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid) { } @@ -555,6 +590,7 @@ BOOL LLOutfitGalleryItem::postBuild() mFotoBgPanel = getChild("foto_bg_panel"); mTextBgPanel = getChild("text_bg_panel"); setOutfitWorn(false); + mHidden = false; return TRUE; } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index a22e86df83..b3e699e0e7 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -120,6 +120,8 @@ protected: /*virtual*/ void onExpandAllFolders() {} /*virtual*/ LLOutfitListGearMenuBase* createGearMenu(); + void applyFilter(LLOutfitGalleryItem* item, const std::string& filter_substring); + private: void loadPhotos(); void uploadPhoto(LLUUID outfit_id); @@ -153,6 +155,7 @@ private: std::vector mRowPanels; std::vector mItemPanels; std::vector mItems; + std::vector mHiddenItems; LLScrollContainer* mScrollPanel; LLPanel* mGalleryPanel; LLPanel* mLastRowPanel; @@ -250,6 +253,9 @@ public: std::string getItemName() {return mOutfitName;} bool mIsDefaultImage() {return mDefaultImage;} + bool isHidden() {return mHidden;} + void setHidden(bool hidden) {mHidden = hidden;} + struct compareGalleryItem { bool operator()(LLOutfitGalleryItem* a, LLOutfitGalleryItem* b) @@ -275,6 +281,7 @@ private: bool mSelected; bool mWorn; bool mDefaultImage; + bool mHidden; std::string mOutfitName; }; -- cgit v1.3 From d1b7deda45f778e0fcfb92f38f9f5694ab285d1c Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Tue, 31 May 2016 18:04:05 +0300 Subject: MAINT-6452 No message is displayed when there is no outfits in Gallery --- indra/newview/lloutfitgallery.cpp | 18 ++++++++++++++++ indra/newview/lloutfitgallery.h | 3 +++ .../skins/default/xui/en/panel_outfit_gallery.xml | 24 ++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 6a8256d41c..7bd9c0bd94 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -99,6 +99,7 @@ BOOL LLOutfitGallery::postBuild() BOOL rv = LLOutfitListBase::postBuild(); mScrollPanel = getChild("gallery_scroll_panel"); mGalleryPanel = getChild("gallery_panel"); + mMessageTextBox = getChild("no_outfits_txt"); mOutfitGalleryMenu = new LLOutfitGalleryContextMenu(this); return rv; } @@ -168,6 +169,7 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff) applyFilter(*it,sFilterSubString); addToGallery(*it); } + updateMessageVisibility(); } void LLOutfitGallery::updateGalleryWidth() @@ -558,6 +560,22 @@ bool LLOutfitGallery::canWearSelected() return false; } +void LLOutfitGallery::updateMessageVisibility() +{ + if(mItems.empty()) + { + mMessageTextBox->setVisible(TRUE); + mScrollPanel->setVisible(FALSE); + std::string message = sFilterSubString.empty()? getString("no_outfits_msg") : getString("no_matched_outfits_msg"); + mMessageTextBox->setValue(message); + } + else + { + mScrollPanel->setVisible(TRUE); + mMessageTextBox->setVisible(FALSE); + } +} + LLOutfitListGearMenuBase* LLOutfitGallery::createGearMenu() { return new LLOutfitGalleryGearMenu(this); diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index b3e699e0e7..ad3f2a7129 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -104,6 +104,8 @@ public: /*virtual*/ bool getHasExpandableFolders() { return FALSE; } + void updateMessageVisibility(); + void refreshTextures(const LLUUID& category_id); void refreshOutfit(const LLUUID& category_id); @@ -161,6 +163,7 @@ private: LLPanel* mLastRowPanel; LLUUID mOutfitLinkPending; LLUUID mOutfitRenamePending; + LLTextBox* mMessageTextBox; bool mGalleryCreated; int mRowCount; int mItemsAddedCount; diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml index c06c6a86c3..9a547f615d 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml @@ -13,6 +13,26 @@ Photo of "[OUTFIT_NAME]" outfit + + You don't have any outfits yet. Try [secondlife:///app/search/all/ Search] + + + Didn't find what you're looking for? Try [secondlife:///app/search/all/[SEARCH_TERM] Search]. + + + Searching... + - - + + Date: Thu, 2 Jun 2016 20:23:46 +0300 Subject: MAINT-5194 Visual Outfit browser Made refactoring of LLFloaterOutfitSnapshot and LLFloaterSnapshot --- indra/newview/CMakeLists.txt | 1 + indra/newview/llappviewer.cpp | 3 +- indra/newview/llfloaterfacebook.cpp | 1072 ++++++++++++++-------------- indra/newview/llfloaterflickr.cpp | 4 +- indra/newview/llfloateroutfitsnapshot.cpp | 1051 +++++---------------------- indra/newview/llfloateroutfitsnapshot.h | 108 +-- indra/newview/llfloatersnapshot.cpp | 689 +++++++----------- indra/newview/llfloatersnapshot.h | 175 +++-- indra/newview/llfloatertwitter.cpp | 4 +- indra/newview/lloutfitgallery.cpp | 8 +- indra/newview/llpanelsnapshot.cpp | 16 +- indra/newview/llpanelsnapshot.h | 20 +- indra/newview/llpanelsnapshotinventory.cpp | 42 +- indra/newview/llpanelsnapshotlocal.cpp | 30 +- indra/newview/llpanelsnapshotoptions.cpp | 5 +- indra/newview/llpanelsnapshotpostcard.cpp | 20 +- indra/newview/llpanelsnapshotprofile.cpp | 6 +- indra/newview/llsnapshotlivepreview.cpp | 38 +- indra/newview/llsnapshotlivepreview.h | 18 +- indra/newview/llsnapshotmodel.h | 55 ++ indra/newview/llviewerassetupload.cpp | 9 +- indra/newview/llviewermenufile.cpp | 24 +- indra/newview/llviewerwindow.cpp | 10 +- indra/newview/llviewerwindow.h | 13 +- indra/newview/llviewerwindowlistener.cpp | 6 +- 25 files changed, 1384 insertions(+), 2043 deletions(-) create mode 100644 indra/newview/llsnapshotmodel.h (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index de0dff61bb..5d7ab0c985 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1144,6 +1144,7 @@ set(viewer_HEADER_FILES llsky.h llslurl.h llsnapshotlivepreview.h + llsnapshotmodel.h llspatialpartition.h llspeakers.h llspeakingindicatormanager.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 86cf1cecf3..a92ad4e41d 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1448,8 +1448,7 @@ bool LLAppViewer::mainLoop() display(); pingMainloopTimeout("Main:Snapshot"); LLFloaterSnapshot::update(); // take snapshots - //TODO: Make one call by moving LLFloaterOutfitSnapshot::update() to LLFloaterSnapshotBase class - LLFloaterOutfitSnapshot::update(); + LLFloaterOutfitSnapshot::update(); gGLActive = FALSE; } } diff --git a/indra/newview/llfloaterfacebook.cpp b/indra/newview/llfloaterfacebook.cpp index ff6e342d62..b1d6d8be82 100644 --- a/indra/newview/llfloaterfacebook.cpp +++ b/indra/newview/llfloaterfacebook.cpp @@ -87,7 +87,7 @@ S32 compute_jpeg_quality(S32 width, S32 height) { F32 target_compression_ratio = (F32)(width * height * 3) / (F32)(TARGET_DATA_SIZE); S32 quality = (S32)(110.0f - (2.0f * target_compression_ratio)); - return llclamp(quality,MIN_QUALITY,MAX_QUALITY); + return llclamp(quality, MIN_QUALITY, MAX_QUALITY); } /////////////////////////// @@ -95,52 +95,52 @@ S32 compute_jpeg_quality(S32 width, S32 height) /////////////////////////// LLFacebookStatusPanel::LLFacebookStatusPanel() : - mMessageTextEditor(NULL), - mPostButton(NULL), + mMessageTextEditor(NULL), + mPostButton(NULL), mCancelButton(NULL), - mAccountCaptionLabel(NULL), - mAccountNameLabel(NULL), - mPanelButtons(NULL), - mConnectButton(NULL), - mDisconnectButton(NULL) + mAccountCaptionLabel(NULL), + mAccountNameLabel(NULL), + mPanelButtons(NULL), + mConnectButton(NULL), + mDisconnectButton(NULL) { - mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLFacebookStatusPanel::onConnect, this)); - mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLFacebookStatusPanel::onDisconnect, this)); + mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLFacebookStatusPanel::onConnect, this)); + mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLFacebookStatusPanel::onDisconnect, this)); - setVisibleCallback(boost::bind(&LLFacebookStatusPanel::onVisibilityChange, this, _2)); + setVisibleCallback(boost::bind(&LLFacebookStatusPanel::onVisibilityChange, this, _2)); - mCommitCallbackRegistrar.add("SocialSharing.SendStatus", boost::bind(&LLFacebookStatusPanel::onSend, this)); + mCommitCallbackRegistrar.add("SocialSharing.SendStatus", boost::bind(&LLFacebookStatusPanel::onSend, this)); } BOOL LLFacebookStatusPanel::postBuild() { - mAccountCaptionLabel = getChild("account_caption_label"); - mAccountNameLabel = getChild("account_name_label"); - mPanelButtons = getChild("panel_buttons"); - mConnectButton = getChild("connect_btn"); - mDisconnectButton = getChild("disconnect_btn"); + mAccountCaptionLabel = getChild("account_caption_label"); + mAccountNameLabel = getChild("account_name_label"); + mPanelButtons = getChild("panel_buttons"); + mConnectButton = getChild("connect_btn"); + mDisconnectButton = getChild("disconnect_btn"); - mMessageTextEditor = getChild("status_message"); - mPostButton = getChild("post_status_btn"); - mCancelButton = getChild("cancel_status_btn"); + mMessageTextEditor = getChild("status_message"); + mPostButton = getChild("post_status_btn"); + mCancelButton = getChild("cancel_status_btn"); - return LLPanel::postBuild(); + return LLPanel::postBuild(); } void LLFacebookStatusPanel::draw() { - LLFacebookConnect::EConnectionState connection_state = LLFacebookConnect::instance().getConnectionState(); + LLFacebookConnect::EConnectionState connection_state = LLFacebookConnect::instance().getConnectionState(); - //Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress - bool disconnecting = connection_state == LLFacebookConnect::FB_DISCONNECTING; - mDisconnectButton->setEnabled(!disconnecting); + //Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress + bool disconnecting = connection_state == LLFacebookConnect::FB_DISCONNECTING; + mDisconnectButton->setEnabled(!disconnecting); - //Disable the 'connect' button when a connection is in progress - bool connecting = connection_state == LLFacebookConnect::FB_CONNECTION_IN_PROGRESS; - mConnectButton->setEnabled(!connecting); + //Disable the 'connect' button when a connection is in progress + bool connecting = connection_state == LLFacebookConnect::FB_CONNECTION_IN_PROGRESS; + mConnectButton->setEnabled(!connecting); if (mMessageTextEditor && mPostButton && mCancelButton) - { + { bool no_ongoing_connection = !(LLFacebookConnect::instance().isTransactionOngoing()); std::string message = mMessageTextEditor->getValue().asString(); mMessageTextEditor->setEnabled(no_ongoing_connection); @@ -148,175 +148,175 @@ void LLFacebookStatusPanel::draw() mPostButton->setEnabled(no_ongoing_connection && !message.empty()); } - LLPanel::draw(); + LLPanel::draw(); } void LLFacebookStatusPanel::onSend() { - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookStatusPanel"); // just in case it is already listening - LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookStatusPanel", boost::bind(&LLFacebookStatusPanel::onFacebookConnectStateChange, this, _1)); - - // Connect to Facebook if necessary and then post - if (LLFacebookConnect::instance().isConnected()) - { - sendStatus(); - } - else - { - LLFacebookConnect::instance().checkConnectionToFacebook(true); - } + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookStatusPanel"); // just in case it is already listening + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookStatusPanel", boost::bind(&LLFacebookStatusPanel::onFacebookConnectStateChange, this, _1)); + + // Connect to Facebook if necessary and then post + if (LLFacebookConnect::instance().isConnected()) + { + sendStatus(); + } + else + { + LLFacebookConnect::instance().checkConnectionToFacebook(true); + } } bool LLFacebookStatusPanel::onFacebookConnectStateChange(const LLSD& data) { - switch (data.get("enum").asInteger()) - { - case LLFacebookConnect::FB_CONNECTED: - sendStatus(); - break; - - case LLFacebookConnect::FB_POSTED: - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookStatusPanel"); - clearAndClose(); - break; - } - - return false; + switch (data.get("enum").asInteger()) + { + case LLFacebookConnect::FB_CONNECTED: + sendStatus(); + break; + + case LLFacebookConnect::FB_POSTED: + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookStatusPanel"); + clearAndClose(); + break; + } + + return false; } bool LLFacebookStatusPanel::onFacebookConnectAccountStateChange(const LLSD& data) { - if(LLFacebookConnect::instance().isConnected()) - { - //In process of disconnecting so leave the layout as is - if(data.get("enum").asInteger() != LLFacebookConnect::FB_DISCONNECTING) - { - showConnectedLayout(); - } - } - else - { - showDisconnectedLayout(); - } - - return false; + if (LLFacebookConnect::instance().isConnected()) + { + //In process of disconnecting so leave the layout as is + if (data.get("enum").asInteger() != LLFacebookConnect::FB_DISCONNECTING) + { + showConnectedLayout(); + } + } + else + { + showDisconnectedLayout(); + } + + return false; } void LLFacebookStatusPanel::sendStatus() { - std::string message = mMessageTextEditor->getValue().asString(); - if (!message.empty()) - { - LLFacebookConnect::instance().updateStatus(message); - } + std::string message = mMessageTextEditor->getValue().asString(); + if (!message.empty()) + { + LLFacebookConnect::instance().updateStatus(message); + } } void LLFacebookStatusPanel::onVisibilityChange(BOOL visible) { - if(visible) - { - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookAccountPanel"); - LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookAccountPanel", boost::bind(&LLFacebookStatusPanel::onFacebookConnectAccountStateChange, this, _1)); - - LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLFacebookAccountPanel"); - LLEventPumps::instance().obtain("FacebookConnectInfo").listen("LLFacebookAccountPanel", boost::bind(&LLFacebookStatusPanel::onFacebookConnectInfoChange, this)); - - //Connected - if(LLFacebookConnect::instance().isConnected()) - { - showConnectedLayout(); - } - //Check if connected (show disconnected layout in meantime) - else - { - showDisconnectedLayout(); - } + if (visible) + { + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookAccountPanel"); + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookAccountPanel", boost::bind(&LLFacebookStatusPanel::onFacebookConnectAccountStateChange, this, _1)); + + LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLFacebookAccountPanel"); + LLEventPumps::instance().obtain("FacebookConnectInfo").listen("LLFacebookAccountPanel", boost::bind(&LLFacebookStatusPanel::onFacebookConnectInfoChange, this)); + + //Connected + if (LLFacebookConnect::instance().isConnected()) + { + showConnectedLayout(); + } + //Check if connected (show disconnected layout in meantime) + else + { + showDisconnectedLayout(); + } if ((LLFacebookConnect::instance().getConnectionState() == LLFacebookConnect::FB_NOT_CONNECTED) || (LLFacebookConnect::instance().getConnectionState() == LLFacebookConnect::FB_CONNECTION_FAILED)) { LLFacebookConnect::instance().checkConnectionToFacebook(); } - } - else - { - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookAccountPanel"); - LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLFacebookAccountPanel"); - } + } + else + { + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookAccountPanel"); + LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLFacebookAccountPanel"); + } } bool LLFacebookStatusPanel::onFacebookConnectInfoChange() { - LLSD info = LLFacebookConnect::instance().getInfo(); - std::string clickable_name; + LLSD info = LLFacebookConnect::instance().getInfo(); + std::string clickable_name; - //Strings of format [http://www.somewebsite.com Click Me] become clickable text - if(info.has("link") && info.has("name")) - { - clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]"; - } + //Strings of format [http://www.somewebsite.com Click Me] become clickable text + if (info.has("link") && info.has("name")) + { + clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]"; + } - mAccountNameLabel->setText(clickable_name); + mAccountNameLabel->setText(clickable_name); - return false; + return false; } void LLFacebookStatusPanel::showConnectButton() { - if(!mConnectButton->getVisible()) - { - mConnectButton->setVisible(TRUE); - mDisconnectButton->setVisible(FALSE); - } + if (!mConnectButton->getVisible()) + { + mConnectButton->setVisible(TRUE); + mDisconnectButton->setVisible(FALSE); + } } void LLFacebookStatusPanel::hideConnectButton() { - if(mConnectButton->getVisible()) - { - mConnectButton->setVisible(FALSE); - mDisconnectButton->setVisible(TRUE); - } + if (mConnectButton->getVisible()) + { + mConnectButton->setVisible(FALSE); + mDisconnectButton->setVisible(TRUE); + } } void LLFacebookStatusPanel::showDisconnectedLayout() { - mAccountCaptionLabel->setText(getString("facebook_disconnected")); - mAccountNameLabel->setText(std::string("")); - showConnectButton(); + mAccountCaptionLabel->setText(getString("facebook_disconnected")); + mAccountNameLabel->setText(std::string("")); + showConnectButton(); } void LLFacebookStatusPanel::showConnectedLayout() { - LLFacebookConnect::instance().loadFacebookInfo(); + LLFacebookConnect::instance().loadFacebookInfo(); - mAccountCaptionLabel->setText(getString("facebook_connected")); - hideConnectButton(); + mAccountCaptionLabel->setText(getString("facebook_connected")); + hideConnectButton(); } void LLFacebookStatusPanel::onConnect() { - LLFacebookConnect::instance().checkConnectionToFacebook(true); + LLFacebookConnect::instance().checkConnectionToFacebook(true); - //Clear only the facebook browser cookies so that the facebook login screen appears - LLViewerMedia::getCookieStore()->removeCookiesByDomain(".facebook.com"); + //Clear only the facebook browser cookies so that the facebook login screen appears + LLViewerMedia::getCookieStore()->removeCookiesByDomain(".facebook.com"); } void LLFacebookStatusPanel::onDisconnect() { - LLFacebookConnect::instance().disconnectFromFacebook(); + LLFacebookConnect::instance().disconnectFromFacebook(); - LLViewerMedia::getCookieStore()->removeCookiesByDomain(".facebook.com"); + LLViewerMedia::getCookieStore()->removeCookiesByDomain(".facebook.com"); } void LLFacebookStatusPanel::clearAndClose() { - mMessageTextEditor->setValue(""); + mMessageTextEditor->setValue(""); - LLFloater* floater = getParentByType(); - if (floater) - { - floater->closeFloater(); - } + LLFloater* floater = getParentByType(); + if (floater) + { + floater->closeFloater(); + } } /////////////////////////// @@ -324,89 +324,89 @@ void LLFacebookStatusPanel::clearAndClose() /////////////////////////// LLFacebookPhotoPanel::LLFacebookPhotoPanel() : -mResolutionComboBox(NULL), -mRefreshBtn(NULL), -mBtnPreview(NULL), -mWorkingLabel(NULL), -mThumbnailPlaceholder(NULL), -mCaptionTextBox(NULL), -mPostButton(NULL), -mBigPreviewFloater(NULL), -mQuality(MAX_QUALITY) + mResolutionComboBox(NULL), + mRefreshBtn(NULL), + mBtnPreview(NULL), + mWorkingLabel(NULL), + mThumbnailPlaceholder(NULL), + mCaptionTextBox(NULL), + mPostButton(NULL), + mBigPreviewFloater(NULL), + mQuality(MAX_QUALITY) { - mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLFacebookPhotoPanel::onSend, this)); - mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLFacebookPhotoPanel::onClickNewSnapshot, this)); - mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLFacebookPhotoPanel::onClickBigPreview, this)); + mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLFacebookPhotoPanel::onSend, this)); + mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLFacebookPhotoPanel::onClickNewSnapshot, this)); + mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLFacebookPhotoPanel::onClickBigPreview, this)); } LLFacebookPhotoPanel::~LLFacebookPhotoPanel() { - if(mPreviewHandle.get()) - { - mPreviewHandle.get()->die(); - } + if (mPreviewHandle.get()) + { + mPreviewHandle.get()->die(); + } } BOOL LLFacebookPhotoPanel::postBuild() { - setVisibleCallback(boost::bind(&LLFacebookPhotoPanel::onVisibilityChange, this, _2)); - - mResolutionComboBox = getChild("resolution_combobox"); - mResolutionComboBox->setValue("[i1200,i630]"); // hardcoded defaults ftw! - mResolutionComboBox->setCommitCallback(boost::bind(&LLFacebookPhotoPanel::updateResolution, this, TRUE)); - mFilterComboBox = getChild("filters_combobox"); - mFilterComboBox->setCommitCallback(boost::bind(&LLFacebookPhotoPanel::updateResolution, this, TRUE)); - mRefreshBtn = getChild("new_snapshot_btn"); - mBtnPreview = getChild("big_preview_btn"); + setVisibleCallback(boost::bind(&LLFacebookPhotoPanel::onVisibilityChange, this, _2)); + + mResolutionComboBox = getChild("resolution_combobox"); + mResolutionComboBox->setValue("[i1200,i630]"); // hardcoded defaults ftw! + mResolutionComboBox->setCommitCallback(boost::bind(&LLFacebookPhotoPanel::updateResolution, this, TRUE)); + mFilterComboBox = getChild("filters_combobox"); + mFilterComboBox->setCommitCallback(boost::bind(&LLFacebookPhotoPanel::updateResolution, this, TRUE)); + mRefreshBtn = getChild("new_snapshot_btn"); + mBtnPreview = getChild("big_preview_btn"); mWorkingLabel = getChild("working_lbl"); - mThumbnailPlaceholder = getChild("thumbnail_placeholder"); - mCaptionTextBox = getChild("photo_caption"); - mPostButton = getChild("post_photo_btn"); - mCancelButton = getChild("cancel_photo_btn"); - mBigPreviewFloater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); + mThumbnailPlaceholder = getChild("thumbnail_placeholder"); + mCaptionTextBox = getChild("photo_caption"); + mPostButton = getChild("post_photo_btn"); + mCancelButton = getChild("cancel_photo_btn"); + mBigPreviewFloater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); - // Update filter list + // Update filter list std::vector filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); - LLComboBox* filterbox = static_cast(mFilterComboBox); + LLComboBox* filterbox = static_cast(mFilterComboBox); for (U32 i = 0; i < filter_list.size(); i++) - { + { filterbox->add(filter_list[i]); } - return LLPanel::postBuild(); + return LLPanel::postBuild(); } // virtual S32 LLFacebookPhotoPanel::notify(const LLSD& info) { - if (info.has("snapshot-updating")) - { + if (info.has("snapshot-updating")) + { // Disable the Post button and whatever else while the snapshot is not updated // updateControls(); - return 1; - } - - if (info.has("snapshot-updated")) - { + return 1; + } + + if (info.has("snapshot-updated")) + { // Enable the send/post/save buttons. updateControls(); - - // The refresh button is initially hidden. We show it after the first update, - // i.e. after snapshot is taken - LLUICtrl * refresh_button = getRefreshBtn(); - if (!refresh_button->getVisible()) - { - refresh_button->setVisible(true); - } - return 1; - } - - return 0; + + // The refresh button is initially hidden. We show it after the first update, + // i.e. after snapshot is taken + LLUICtrl * refresh_button = getRefreshBtn(); + if (!refresh_button->getVisible()) + { + refresh_button->setVisible(true); + } + return 1; + } + + return 0; } void LLFacebookPhotoPanel::draw() -{ - LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); +{ + LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); // Enable interaction only if no transaction with the service is on-going (prevent duplicated posts) bool no_ongoing_connection = !(LLFacebookConnect::instance().isTransactionOngoing()); @@ -416,98 +416,98 @@ void LLFacebookPhotoPanel::draw() mFilterComboBox->setEnabled(no_ongoing_connection); mRefreshBtn->setEnabled(no_ongoing_connection); mBtnPreview->setEnabled(no_ongoing_connection); - + // Reassign the preview floater if we have the focus and the preview exists if (hasFocus() && isPreviewVisible()) { attachPreview(); } - + // Toggle the button state as appropriate bool preview_active = (isPreviewVisible() && mBigPreviewFloater->isFloaterOwner(getParentByType())); - mBtnPreview->setToggleState(preview_active); - + mBtnPreview->setToggleState(preview_active); + // Display the thumbnail if one is available - if (previewp && previewp->getThumbnailImage()) - { - const LLRect& thumbnail_rect = mThumbnailPlaceholder->getRect(); - const S32 thumbnail_w = previewp->getThumbnailWidth(); - const S32 thumbnail_h = previewp->getThumbnailHeight(); - - // calc preview offset within the preview rect - const S32 local_offset_x = (thumbnail_rect.getWidth() - thumbnail_w) / 2 ; - const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2 ; - S32 offset_x = thumbnail_rect.mLeft + local_offset_x; - S32 offset_y = thumbnail_rect.mBottom + local_offset_y; - - gGL.matrixMode(LLRender::MM_MODELVIEW); - // Apply floater transparency to the texture unless the floater is focused. - F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); - LLColor4 color = LLColor4::white; - gl_draw_scaled_image(offset_x, offset_y, - thumbnail_w, thumbnail_h, - previewp->getThumbnailImage(), color % alpha); - } + if (previewp && previewp->getThumbnailImage()) + { + const LLRect& thumbnail_rect = mThumbnailPlaceholder->getRect(); + const S32 thumbnail_w = previewp->getThumbnailWidth(); + const S32 thumbnail_h = previewp->getThumbnailHeight(); + + // calc preview offset within the preview rect + const S32 local_offset_x = (thumbnail_rect.getWidth() - thumbnail_w) / 2; + const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2; + S32 offset_x = thumbnail_rect.mLeft + local_offset_x; + S32 offset_y = thumbnail_rect.mBottom + local_offset_y; + + gGL.matrixMode(LLRender::MM_MODELVIEW); + // Apply floater transparency to the texture unless the floater is focused. + F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); + LLColor4 color = LLColor4::white; + gl_draw_scaled_image(offset_x, offset_y, + thumbnail_w, thumbnail_h, + previewp->getThumbnailImage(), color % alpha); + } // Update the visibility of the working (computing preview) label mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate())); - + // Enable Post if we have a preview to send and no on going connection being processed mPostButton->setEnabled(no_ongoing_connection && (previewp && previewp->getSnapshotUpToDate())); - + // Draw the rest of the panel on top of it - LLPanel::draw(); + LLPanel::draw(); } LLSnapshotLivePreview* LLFacebookPhotoPanel::getPreviewView() { - LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get(); - return previewp; + LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get(); + return previewp; } void LLFacebookPhotoPanel::onVisibilityChange(BOOL visible) { - if (visible) - { - if (mPreviewHandle.get()) - { - LLSnapshotLivePreview* preview = getPreviewView(); - if(preview) - { - LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL; - preview->updateSnapshot(TRUE); - } - } - else - { - LLRect full_screen_rect = getRootView()->getRect(); - LLSnapshotLivePreview::Params p; - p.rect(full_screen_rect); - LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); - mPreviewHandle = previewp->getHandle(); + if (visible) + { + if (mPreviewHandle.get()) + { + LLSnapshotLivePreview* preview = getPreviewView(); + if (preview) + { + LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL; + preview->updateSnapshot(TRUE); + } + } + else + { + LLRect full_screen_rect = getRootView()->getRect(); + LLSnapshotLivePreview::Params p; + p.rect(full_screen_rect); + LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); + mPreviewHandle = previewp->getHandle(); mQuality = MAX_QUALITY; previewp->setContainer(this); - previewp->setSnapshotType(LLPanelSnapshot::SNAPSHOT_WEB); - previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); - previewp->setSnapshotQuality(mQuality, false); + previewp->setSnapshotType(LLSnapshotModel::SNAPSHOT_WEB); + previewp->setSnapshotFormat(LLSnapshotModel::SNAPSHOT_FORMAT_JPEG); + previewp->setSnapshotQuality(mQuality, false); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots previewp->setAllowFullScreenPreview(FALSE); // No full screen preview in SL Share mode - previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect()); + previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect()); - updateControls(); - } - } + updateControls(); + } + } } void LLFacebookPhotoPanel::onClickNewSnapshot() { - LLSnapshotLivePreview* previewp = getPreviewView(); - if (previewp) - { - previewp->updateSnapshot(TRUE); - } + LLSnapshotLivePreview* previewp = getPreviewView(); + if (previewp) + { + previewp->updateSnapshot(TRUE); + } } void LLFacebookPhotoPanel::onClickBigPreview() @@ -541,167 +541,167 @@ void LLFacebookPhotoPanel::attachPreview() void LLFacebookPhotoPanel::onSend() { - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookPhotoPanel"); // just in case it is already listening - LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookPhotoPanel", boost::bind(&LLFacebookPhotoPanel::onFacebookConnectStateChange, this, _1)); - - // Connect to Facebook if necessary and then post - if (LLFacebookConnect::instance().isConnected()) - { - sendPhoto(); - } - else - { - LLFacebookConnect::instance().checkConnectionToFacebook(true); - } + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookPhotoPanel"); // just in case it is already listening + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookPhotoPanel", boost::bind(&LLFacebookPhotoPanel::onFacebookConnectStateChange, this, _1)); + + // Connect to Facebook if necessary and then post + if (LLFacebookConnect::instance().isConnected()) + { + sendPhoto(); + } + else + { + LLFacebookConnect::instance().checkConnectionToFacebook(true); + } } bool LLFacebookPhotoPanel::onFacebookConnectStateChange(const LLSD& data) { - switch (data.get("enum").asInteger()) - { - case LLFacebookConnect::FB_CONNECTED: - sendPhoto(); - break; - - case LLFacebookConnect::FB_POSTED: - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookPhotoPanel"); - clearAndClose(); - break; - } - - return false; + switch (data.get("enum").asInteger()) + { + case LLFacebookConnect::FB_CONNECTED: + sendPhoto(); + break; + + case LLFacebookConnect::FB_POSTED: + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookPhotoPanel"); + clearAndClose(); + break; + } + + return false; } void LLFacebookPhotoPanel::sendPhoto() { - // Get the caption - std::string caption = mCaptionTextBox->getValue().asString(); + // Get the caption + std::string caption = mCaptionTextBox->getValue().asString(); - // Get the image - LLSnapshotLivePreview* previewp = getPreviewView(); - - // Post to Facebook - LLFacebookConnect::instance().sharePhoto(previewp->getFormattedImage(), caption); + // Get the image + LLSnapshotLivePreview* previewp = getPreviewView(); - updateControls(); + // Post to Facebook + LLFacebookConnect::instance().sharePhoto(previewp->getFormattedImage(), caption); + + updateControls(); } void LLFacebookPhotoPanel::clearAndClose() { - mCaptionTextBox->setValue(""); + mCaptionTextBox->setValue(""); - LLFloater* floater = getParentByType(); - if (floater) - { - floater->closeFloater(); + LLFloater* floater = getParentByType(); + if (floater) + { + floater->closeFloater(); if (mBigPreviewFloater) { mBigPreviewFloater->closeOnFloaterOwnerClosing(floater); } - } + } } void LLFacebookPhotoPanel::updateControls() { - LLSnapshotLivePreview* previewp = getPreviewView(); - BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); - - // *TODO: Separate maximum size for Web images from postcards - LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; - - updateResolution(FALSE); + LLSnapshotLivePreview* previewp = getPreviewView(); + BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); + + // *TODO: Separate maximum size for Web images from postcards + LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; + + updateResolution(FALSE); } void LLFacebookPhotoPanel::updateResolution(BOOL do_update) { - LLComboBox* combobox = static_cast(mResolutionComboBox); - LLComboBox* filterbox = static_cast(mFilterComboBox); + LLComboBox* combobox = static_cast(mResolutionComboBox); + LLComboBox* filterbox = static_cast(mFilterComboBox); - std::string sdstring = combobox->getSelectedValue(); - LLSD sdres; - std::stringstream sstream(sdstring); - LLSDSerialize::fromNotation(sdres, sstream, sdstring.size()); + std::string sdstring = combobox->getSelectedValue(); + LLSD sdres; + std::stringstream sstream(sdstring); + LLSDSerialize::fromNotation(sdres, sstream, sdstring.size()); - S32 width = sdres[0]; - S32 height = sdres[1]; + S32 width = sdres[0]; + S32 height = sdres[1]; // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : ""); - LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); - if (previewp && combobox->getCurrentIndex() >= 0) - { - S32 original_width = 0 , original_height = 0 ; - previewp->getSize(original_width, original_height) ; - - if (width == 0 || height == 0) - { - // take resolution from current window size - LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL; - previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()); - } - else - { - // use the resolution from the selected pre-canned drop-down choice - LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL; - previewp->setSize(width, height); - } - - checkAspectRatio(width); - - previewp->getSize(width, height); - + LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); + if (previewp && combobox->getCurrentIndex() >= 0) + { + S32 original_width = 0, original_height = 0; + previewp->getSize(original_width, original_height); + + if (width == 0 || height == 0) + { + // take resolution from current window size + LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL; + previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()); + } + else + { + // use the resolution from the selected pre-canned drop-down choice + LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL; + previewp->setSize(width, height); + } + + checkAspectRatio(width); + + previewp->getSize(width, height); + // Recompute quality setting mQuality = compute_jpeg_quality(width, height); previewp->setSnapshotQuality(mQuality, false); - - if (original_width != width || original_height != height) - { - previewp->setSize(width, height); - if (do_update) - { + + if (original_width != width || original_height != height) + { + previewp->setSize(width, height); + if (do_update) + { previewp->updateSnapshot(TRUE); - updateControls(); - } - } + updateControls(); + } + } // Get the old filter, compare to the current one "filter_name" and set if changed std::string original_filter = previewp->getFilter(); - if (original_filter != filter_name) - { + if (original_filter != filter_name) + { previewp->setFilter(filter_name); - if (do_update) - { + if (do_update) + { previewp->updateSnapshot(FALSE, TRUE); - updateControls(); - } - } - } + updateControls(); + } + } + } } void LLFacebookPhotoPanel::checkAspectRatio(S32 index) { - LLSnapshotLivePreview *previewp = getPreviewView() ; - - BOOL keep_aspect = FALSE; - - if (0 == index) // current window size - { - keep_aspect = TRUE; - } - else // predefined resolution - { - keep_aspect = FALSE; - } - - if (previewp) - { - previewp->mKeepAspectRatio = keep_aspect; - } + LLSnapshotLivePreview *previewp = getPreviewView(); + + BOOL keep_aspect = FALSE; + + if (0 == index) // current window size + { + keep_aspect = TRUE; + } + else // predefined resolution + { + keep_aspect = FALSE; + } + + if (previewp) + { + previewp->mKeepAspectRatio = keep_aspect; + } } LLUICtrl* LLFacebookPhotoPanel::getRefreshBtn() { - return mRefreshBtn; + return mRefreshBtn; } //////////////////////// @@ -712,21 +712,21 @@ LLFacebookCheckinPanel::LLFacebookCheckinPanel() : mMapUrl(""), mReloadingMapTexture(false) { - mCommitCallbackRegistrar.add("SocialSharing.SendCheckin", boost::bind(&LLFacebookCheckinPanel::onSend, this)); + mCommitCallbackRegistrar.add("SocialSharing.SendCheckin", boost::bind(&LLFacebookCheckinPanel::onSend, this)); } BOOL LLFacebookCheckinPanel::postBuild() { // Keep pointers to widgets so we don't traverse the UI hierarchy too often - mPostButton = getChild("post_place_btn"); - mCancelButton = getChild("cancel_place_btn"); - mMessageTextEditor = getChild("place_caption"); + mPostButton = getChild("post_place_btn"); + mCancelButton = getChild("cancel_place_btn"); + mMessageTextEditor = getChild("place_caption"); mMapLoadingIndicator = getChild("map_loading_indicator"); mMapPlaceholder = getChild("map_placeholder"); mMapDefault = getChild("map_default"); mMapCheckBox = getChild("add_place_view_cb"); - - return LLPanel::postBuild(); + + return LLPanel::postBuild(); } void LLFacebookCheckinPanel::draw() @@ -767,101 +767,101 @@ void LLFacebookCheckinPanel::draw() // This will hide/show the loading indicator and/or tile underneath mMapDefault->setVisible(!(mMapCheckBox->get())); - LLPanel::draw(); + LLPanel::draw(); } void LLFacebookCheckinPanel::onSend() { - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookCheckinPanel"); // just in case it is already listening - LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookCheckinPanel", boost::bind(&LLFacebookCheckinPanel::onFacebookConnectStateChange, this, _1)); - - // Connect to Facebook if necessary and then post - if (LLFacebookConnect::instance().isConnected()) - { - sendCheckin(); - } - else - { - LLFacebookConnect::instance().checkConnectionToFacebook(true); - } + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookCheckinPanel"); // just in case it is already listening + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookCheckinPanel", boost::bind(&LLFacebookCheckinPanel::onFacebookConnectStateChange, this, _1)); + + // Connect to Facebook if necessary and then post + if (LLFacebookConnect::instance().isConnected()) + { + sendCheckin(); + } + else + { + LLFacebookConnect::instance().checkConnectionToFacebook(true); + } } bool LLFacebookCheckinPanel::onFacebookConnectStateChange(const LLSD& data) { - switch (data.get("enum").asInteger()) - { - case LLFacebookConnect::FB_CONNECTED: - sendCheckin(); - break; - - case LLFacebookConnect::FB_POSTED: - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookCheckinPanel"); - clearAndClose(); - break; - } - - return false; + switch (data.get("enum").asInteger()) + { + case LLFacebookConnect::FB_CONNECTED: + sendCheckin(); + break; + + case LLFacebookConnect::FB_POSTED: + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookCheckinPanel"); + clearAndClose(); + break; + } + + return false; } void LLFacebookCheckinPanel::sendCheckin() { - // Get the location SLURL - LLSLURL slurl; - LLAgentUI::buildSLURL(slurl); - std::string slurl_string = slurl.getSLURLString(); - - // Use a valid http:// URL if the scheme is secondlife:// - LLURI slurl_uri(slurl_string); - if (slurl_uri.scheme() == LLSLURL::SLURL_SECONDLIFE_SCHEME) - { - slurl_string = DEFAULT_CHECKIN_LOCATION_URL; - } - - // Add query parameters so Google Analytics can track incoming clicks! - slurl_string += DEFAULT_CHECKIN_QUERY_PARAMETERS; - - // Get the region name - std::string region_name(""); + // Get the location SLURL + LLSLURL slurl; + LLAgentUI::buildSLURL(slurl); + std::string slurl_string = slurl.getSLURLString(); + + // Use a valid http:// URL if the scheme is secondlife:// + LLURI slurl_uri(slurl_string); + if (slurl_uri.scheme() == LLSLURL::SLURL_SECONDLIFE_SCHEME) + { + slurl_string = DEFAULT_CHECKIN_LOCATION_URL; + } + + // Add query parameters so Google Analytics can track incoming clicks! + slurl_string += DEFAULT_CHECKIN_QUERY_PARAMETERS; + + // Get the region name + std::string region_name(""); LLViewerRegion *regionp = gAgent.getRegion(); if (regionp) { region_name = regionp->getName(); } - - // Get the region description - std::string description; - LLAgentUI::buildLocationString(description, LLAgentUI::LOCATION_FORMAT_NORMAL_COORDS, gAgent.getPositionAgent()); - - // Optionally add the region map view - bool add_map_view = mMapCheckBox->getValue().asBoolean(); + + // Get the region description + std::string description; + LLAgentUI::buildLocationString(description, LLAgentUI::LOCATION_FORMAT_NORMAL_COORDS, gAgent.getPositionAgent()); + + // Optionally add the region map view + bool add_map_view = mMapCheckBox->getValue().asBoolean(); std::string map_url = (add_map_view ? get_map_url() : DEFAULT_CHECKIN_ICON_URL); - - // Get the caption - std::string caption = mMessageTextEditor->getValue().asString(); - // Post to Facebook - LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, map_url, caption); + // Get the caption + std::string caption = mMessageTextEditor->getValue().asString(); + + // Post to Facebook + LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, map_url, caption); } void LLFacebookCheckinPanel::clearAndClose() { - mMessageTextEditor->setValue(""); + mMessageTextEditor->setValue(""); - LLFloater* floater = getParentByType(); - if (floater) - { - floater->closeFloater(); - } + LLFloater* floater = getParentByType(); + if (floater) + { + floater->closeFloater(); + } } /////////////////////////// //LLFacebookFriendsPanel////// /////////////////////////// -LLFacebookFriendsPanel::LLFacebookFriendsPanel() : -mFriendsStatusCaption(NULL), -mSecondLifeFriends(NULL), -mSuggestedFriends(NULL) +LLFacebookFriendsPanel::LLFacebookFriendsPanel() : + mFriendsStatusCaption(NULL), + mSecondLifeFriends(NULL), + mSuggestedFriends(NULL) { } @@ -872,55 +872,55 @@ LLFacebookFriendsPanel::~LLFacebookFriendsPanel() BOOL LLFacebookFriendsPanel::postBuild() { - mFriendsStatusCaption = getChild("facebook_friends_status"); + mFriendsStatusCaption = getChild("facebook_friends_status"); + + mSecondLifeFriends = getChild("second_life_friends"); + mSecondLifeFriends->setContextMenu(&LLPanelPeopleMenus::gPeopleContextMenu); - mSecondLifeFriends = getChild("second_life_friends"); - mSecondLifeFriends->setContextMenu(&LLPanelPeopleMenus::gPeopleContextMenu); - - mSuggestedFriends = getChild("suggested_friends"); - mSuggestedFriends->setContextMenu(&LLPanelPeopleMenus::gSuggestedFriendsContextMenu); - - setVisibleCallback(boost::bind(&LLFacebookFriendsPanel::updateFacebookList, this, _2)); + mSuggestedFriends = getChild("suggested_friends"); + mSuggestedFriends->setContextMenu(&LLPanelPeopleMenus::gSuggestedFriendsContextMenu); + + setVisibleCallback(boost::bind(&LLFacebookFriendsPanel::updateFacebookList, this, _2)); LLAvatarTracker::instance().addObserver(this); - - return LLPanel::postBuild(); + + return LLPanel::postBuild(); } bool LLFacebookFriendsPanel::updateSuggestedFriendList() { - const LLAvatarTracker& av_tracker = LLAvatarTracker::instance(); - uuid_vec_t& second_life_friends = mSecondLifeFriends->getIDs(); - second_life_friends.clear(); - uuid_vec_t& suggested_friends = mSuggestedFriends->getIDs(); - suggested_friends.clear(); - - //Add suggested friends - LLSD friends = LLFacebookConnect::instance().getContent(); - for (LLSD::array_const_iterator i = friends.beginArray(); i != friends.endArray(); ++i) - { - LLUUID agent_id = (*i).asUUID(); - if (agent_id.notNull()) - { - bool second_life_buddy = av_tracker.isBuddy(agent_id); - if (second_life_buddy) - { - second_life_friends.push_back(agent_id); - } - else - { - //FB+SL but not SL friend - suggested_friends.push_back(agent_id); - } - } - } - - //Force a refresh when there aren't any filter matches (prevent displaying content that shouldn't display) - mSecondLifeFriends->setDirty(true, !mSecondLifeFriends->filterHasMatches()); - mSuggestedFriends->setDirty(true, !mSuggestedFriends->filterHasMatches()); - showFriendsAccordionsIfNeeded(); - - return false; + const LLAvatarTracker& av_tracker = LLAvatarTracker::instance(); + uuid_vec_t& second_life_friends = mSecondLifeFriends->getIDs(); + second_life_friends.clear(); + uuid_vec_t& suggested_friends = mSuggestedFriends->getIDs(); + suggested_friends.clear(); + + //Add suggested friends + LLSD friends = LLFacebookConnect::instance().getContent(); + for (LLSD::array_const_iterator i = friends.beginArray(); i != friends.endArray(); ++i) + { + LLUUID agent_id = (*i).asUUID(); + if (agent_id.notNull()) + { + bool second_life_buddy = av_tracker.isBuddy(agent_id); + if (second_life_buddy) + { + second_life_friends.push_back(agent_id); + } + else + { + //FB+SL but not SL friend + suggested_friends.push_back(agent_id); + } + } + } + + //Force a refresh when there aren't any filter matches (prevent displaying content that shouldn't display) + mSecondLifeFriends->setDirty(true, !mSecondLifeFriends->filterHasMatches()); + mSuggestedFriends->setDirty(true, !mSuggestedFriends->filterHasMatches()); + showFriendsAccordionsIfNeeded(); + + return false; } void LLFacebookFriendsPanel::showFriendsAccordionsIfNeeded() @@ -949,15 +949,15 @@ void LLFacebookFriendsPanel::showFriendsAccordionsIfNeeded() { // We have something in the lists, hide the explanatory text mFriendsStatusCaption->setVisible(false); - + // Show the lists LLAccordionCtrl* accordion = getChild("friends_accordion"); accordion->setVisible(true); - + // Expand and show accordions if needed, else - hide them getChild("tab_second_life_friends")->setVisible(mSecondLifeFriends->filterHasMatches()); getChild("tab_suggested_friends")->setVisible(mSuggestedFriends->filterHasMatches()); - + // Rearrange accordions accordion->arrange(); } @@ -965,56 +965,56 @@ void LLFacebookFriendsPanel::showFriendsAccordionsIfNeeded() void LLFacebookFriendsPanel::changed(U32 mask) { - if (mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE)) - { + if (mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE)) + { LLFacebookConnect::instance().loadFacebookFriends(); - updateFacebookList(true); - } + updateFacebookList(true); + } } void LLFacebookFriendsPanel::updateFacebookList(bool visible) { - if (visible) - { + if (visible) + { // We want this to be called to fetch the friends list once a connection is established - LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookFriendsPanel"); - LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookFriendsPanel", boost::bind(&LLFacebookFriendsPanel::onConnectedToFacebook, this, _1)); - + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookFriendsPanel"); + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLFacebookFriendsPanel", boost::bind(&LLFacebookFriendsPanel::onConnectedToFacebook, this, _1)); + // We then want this to be called to update the displayed lists once the list of friends is received - LLEventPumps::instance().obtain("FacebookConnectContent").stopListening("LLFacebookFriendsPanel"); // just in case it is already listening - LLEventPumps::instance().obtain("FacebookConnectContent").listen("LLFacebookFriendsPanel", boost::bind(&LLFacebookFriendsPanel::updateSuggestedFriendList, this)); - - // Try to connect to Facebook + LLEventPumps::instance().obtain("FacebookConnectContent").stopListening("LLFacebookFriendsPanel"); // just in case it is already listening + LLEventPumps::instance().obtain("FacebookConnectContent").listen("LLFacebookFriendsPanel", boost::bind(&LLFacebookFriendsPanel::updateSuggestedFriendList, this)); + + // Try to connect to Facebook if ((LLFacebookConnect::instance().getConnectionState() == LLFacebookConnect::FB_NOT_CONNECTED) || (LLFacebookConnect::instance().getConnectionState() == LLFacebookConnect::FB_CONNECTION_FAILED)) { LLFacebookConnect::instance().checkConnectionToFacebook(); } - // Loads FB friends - if (LLFacebookConnect::instance().isConnected()) - { - LLFacebookConnect::instance().loadFacebookFriends(); - } + // Loads FB friends + if (LLFacebookConnect::instance().isConnected()) + { + LLFacebookConnect::instance().loadFacebookFriends(); + } // Sort the FB friends and update the lists - updateSuggestedFriendList(); - } + updateSuggestedFriendList(); + } } bool LLFacebookFriendsPanel::onConnectedToFacebook(const LLSD& data) { - LLSD::Integer connection_state = data.get("enum").asInteger(); - - if (connection_state == LLFacebookConnect::FB_CONNECTED) - { - LLFacebookConnect::instance().loadFacebookFriends(); - } - else if (connection_state == LLFacebookConnect::FB_NOT_CONNECTED) - { - updateSuggestedFriendList(); - } - - return false; + LLSD::Integer connection_state = data.get("enum").asInteger(); + + if (connection_state == LLFacebookConnect::FB_CONNECTED) + { + LLFacebookConnect::instance().loadFacebookFriends(); + } + else if (connection_state == LLFacebookConnect::FB_NOT_CONNECTED) + { + updateSuggestedFriendList(); + } + + return false; } //////////////////////// @@ -1027,7 +1027,7 @@ LLFloaterFacebook::LLFloaterFacebook(const LLSD& key) : LLFloater(key), mStatusLoadingText(NULL), mStatusLoadingIndicator(NULL) { - mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterFacebook::onCancel, this)); + mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterFacebook::onCancel, this)); } void LLFloaterFacebook::onClose(bool app_quitting) @@ -1037,7 +1037,7 @@ void LLFloaterFacebook::onClose(bool app_quitting) { big_preview_floater->closeOnFloaterOwnerClosing(this); } - LLFloater::onClose(app_quitting); + LLFloater::onClose(app_quitting); } void LLFloaterFacebook::onCancel() @@ -1053,24 +1053,24 @@ void LLFloaterFacebook::onCancel() BOOL LLFloaterFacebook::postBuild() { // Keep tab of the Photo Panel - mFacebookPhotoPanel = static_cast(getChild("panel_facebook_photo")); + mFacebookPhotoPanel = static_cast(getChild("panel_facebook_photo")); // Connection status widgets mStatusErrorText = getChild("connection_error_text"); mStatusLoadingText = getChild("connection_loading_text"); mStatusLoadingIndicator = getChild("connection_loading_indicator"); - return LLFloater::postBuild(); + return LLFloater::postBuild(); } void LLFloaterFacebook::showPhotoPanel() { - LLTabContainer* parent = dynamic_cast(mFacebookPhotoPanel->getParent()); - if (!parent) - { - LL_WARNS() << "Cannot find panel container" << LL_ENDL; - return; - } - - parent->selectTabPanel(mFacebookPhotoPanel); + LLTabContainer* parent = dynamic_cast(mFacebookPhotoPanel->getParent()); + if (!parent) + { + LL_WARNS() << "Cannot find panel container" << LL_ENDL; + return; + } + + parent->selectTabPanel(mFacebookPhotoPanel); } void LLFloaterFacebook::draw() @@ -1082,7 +1082,7 @@ void LLFloaterFacebook::draw() mStatusLoadingIndicator->setVisible(false); LLFacebookConnect::EConnectionState connection_state = LLFacebookConnect::instance().getConnectionState(); std::string status_text; - + switch (connection_state) { case LLFacebookConnect::FB_NOT_CONNECTED: @@ -1105,7 +1105,7 @@ void LLFloaterFacebook::draw() status_text = LLTrans::getString("SocialFacebookPosting"); mStatusLoadingText->setValue(status_text); mStatusLoadingIndicator->setVisible(true); - break; + break; case LLFacebookConnect::FB_CONNECTION_FAILED: // Error connecting to the service mStatusErrorText->setVisible(true); @@ -1118,21 +1118,21 @@ void LLFloaterFacebook::draw() status_text = LLTrans::getString("SocialFacebookErrorPosting"); mStatusErrorText->setValue(status_text); break; - case LLFacebookConnect::FB_DISCONNECTING: - // Disconnecting loading indicator - mStatusLoadingText->setVisible(true); - status_text = LLTrans::getString("SocialFacebookDisconnecting"); - mStatusLoadingText->setValue(status_text); - mStatusLoadingIndicator->setVisible(true); - break; - case LLFacebookConnect::FB_DISCONNECT_FAILED: - // Error disconnecting from the service - mStatusErrorText->setVisible(true); - status_text = LLTrans::getString("SocialFacebookErrorDisconnecting"); - mStatusErrorText->setValue(status_text); - break; + case LLFacebookConnect::FB_DISCONNECTING: + // Disconnecting loading indicator + mStatusLoadingText->setVisible(true); + status_text = LLTrans::getString("SocialFacebookDisconnecting"); + mStatusLoadingText->setValue(status_text); + mStatusLoadingIndicator->setVisible(true); + break; + case LLFacebookConnect::FB_DISCONNECT_FAILED: + // Error disconnecting from the service + mStatusErrorText->setVisible(true); + status_text = LLTrans::getString("SocialFacebookErrorDisconnecting"); + mStatusErrorText->setValue(status_text); + break; } } - LLFloater::draw(); + LLFloater::draw(); } diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp index 131df22956..15b7c7fafa 100644 --- a/indra/newview/llfloaterflickr.cpp +++ b/indra/newview/llfloaterflickr.cpp @@ -238,8 +238,8 @@ void LLFlickrPhotoPanel::onVisibilityChange(BOOL visible) mPreviewHandle = previewp->getHandle(); previewp->setContainer(this); - previewp->setSnapshotType(LLPanelSnapshot::SNAPSHOT_WEB); - previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG); + previewp->setSnapshotType(LLSnapshotModel::SNAPSHOT_WEB); + previewp->setSnapshotFormat(LLSnapshotModel::SNAPSHOT_FORMAT_PNG); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots previewp->setAllowFullScreenPreview(FALSE); // No full screen preview in SL Share mode diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index 6d641613ff..4c4e9bcc48 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -42,7 +42,6 @@ #include "llresmgr.h" // LLLocale #include "llsdserialize.h" #include "llsidetraypanelcontainer.h" -#include "llsnapshotlivepreview.h" #include "llspinctrl.h" #include "llviewercontrol.h" #include "lltoolfocus.h" @@ -52,7 +51,6 @@ ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- -LLUICtrl* LLFloaterOutfitSnapshot::sThumbnailPlaceholder = NULL; LLOutfitSnapshotFloaterView* gOutfitSnapshotFloaterView = NULL; const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; @@ -62,213 +60,32 @@ const S32 OUTFIT_SNAPSHOT_HEIGHT = 256; static LLDefaultChildRegistry::Register r("snapshot_outfit_floater_view"); - ///---------------------------------------------------------------------------- -/// Class LLFloaterSnapshot::Impl +/// Class LLFloaterOutfitSnapshot::Impl ///---------------------------------------------------------------------------- - -class LLFloaterOutfitSnapshot::Impl -{ - LOG_CLASS(LLFloaterOutfitSnapshot::Impl); -public: - typedef enum e_status - { - STATUS_READY, - STATUS_WORKING, - STATUS_FINISHED - } EStatus; - - Impl() - : mAvatarPauseHandles(), - mLastToolset(NULL), - mAspectRatioCheckOff(false), - mNeedRefresh(false), - mStatus(STATUS_READY) - { - } - ~Impl() - { - //unpause avatars - mAvatarPauseHandles.clear(); - - } - static void onClickNewSnapshot(void* data); - static void onClickAutoSnap(LLUICtrl *ctrl, void* data); - static void onClickFilter(LLUICtrl *ctrl, void* data); - //static void onClickAdvanceSnap(LLUICtrl *ctrl, void* data); - static void onClickUICheck(LLUICtrl *ctrl, void* data); - static void onClickHUDCheck(LLUICtrl *ctrl, void* data); - static void updateResolution(void* data); - static void onCommitFreezeFrame(LLUICtrl* ctrl, void* data); - static void onCommitLayerTypes(LLUICtrl* ctrl, void*data); - static void onSnapshotUploadFinished(bool status); - static void onSendingPostcardFinished(bool status); - - static LLPanelSnapshot* getActivePanel(LLFloaterOutfitSnapshot* floater, bool ok_if_not_found = true); - static LLPanelSnapshot::ESnapshotType getActiveSnapshotType(LLFloaterOutfitSnapshot* floater); - static LLFloaterOutfitSnapshot::ESnapshotFormat getImageFormat(LLFloaterOutfitSnapshot* floater); - - static LLSnapshotLivePreview* getPreviewView(LLFloaterOutfitSnapshot *floater); - static void updateControls(LLFloaterOutfitSnapshot* floater); - static void updateLayout(LLFloaterOutfitSnapshot* floater); - static void setStatus(EStatus status, bool ok = true, const std::string& msg = LLStringUtil::null); - EStatus getStatus() const { return mStatus; } - static void setNeedRefresh(LLFloaterOutfitSnapshot* floater, bool need); - -private: - static LLViewerWindow::ESnapshotType getLayerType(LLFloaterOutfitSnapshot* floater); - static void checkAutoSnapshot(LLSnapshotLivePreview* floater, BOOL update_thumbnail = FALSE); - static void setWorking(LLFloaterOutfitSnapshot* floater, bool working); - static void setFinished(LLFloaterOutfitSnapshot* floater, bool finished, bool ok = true, const std::string& msg = LLStringUtil::null); - - -public: - std::vector mAvatarPauseHandles; - - LLToolset* mLastToolset; - LLHandle mPreviewHandle; - bool mAspectRatioCheckOff ; - bool mNeedRefresh; - EStatus mStatus; -}; - - - -// static -LLPanelSnapshot* LLFloaterOutfitSnapshot::Impl::getActivePanel(LLFloaterOutfitSnapshot* floater, bool ok_if_not_found) +// virtual +LLPanelSnapshot* LLFloaterOutfitSnapshot::Impl::getActivePanel(LLFloaterSnapshotBase* floater, bool ok_if_not_found) { LLPanel* panel = floater->getChild("panel_outfit_snapshot_inventory"); - //LLPanel* panel = panel_container->getCurrentPanel(); LLPanelSnapshot* active_panel = dynamic_cast(panel); - if (!ok_if_not_found) - { - llassert_always(active_panel != NULL); - } - return active_panel; -} - -// static -LLPanelSnapshot::ESnapshotType LLFloaterOutfitSnapshot::Impl::getActiveSnapshotType(LLFloaterOutfitSnapshot* floater) -{ - return LLPanelSnapshot::SNAPSHOT_TEXTURE; -} - -// static -LLFloaterOutfitSnapshot::ESnapshotFormat LLFloaterOutfitSnapshot::Impl::getImageFormat(LLFloaterOutfitSnapshot* floater) -{ - return LLFloaterOutfitSnapshot::SNAPSHOT_FORMAT_PNG; -} - -// static -LLSnapshotLivePreview* LLFloaterOutfitSnapshot::Impl::getPreviewView(LLFloaterOutfitSnapshot *floater) -{ - LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)floater->impl.mPreviewHandle.get(); - return previewp; + if (!ok_if_not_found) + { + llassert_always(active_panel != NULL); + } + return active_panel; } -// static -LLViewerWindow::ESnapshotType LLFloaterOutfitSnapshot::Impl::getLayerType(LLFloaterOutfitSnapshot* floater) +// virtual +LLSnapshotModel::ESnapshotFormat LLFloaterOutfitSnapshot::Impl::getImageFormat(LLFloaterSnapshotBase* floater) { - return LLViewerWindow::SNAPSHOT_TYPE_COLOR; + return LLSnapshotModel::SNAPSHOT_FORMAT_PNG; } -//static -void LLFloaterOutfitSnapshot::Impl::updateLayout(LLFloaterOutfitSnapshot* floaterp) +// virtual +LLSnapshotModel::ESnapshotLayerType LLFloaterOutfitSnapshot::Impl::getLayerType(LLFloaterSnapshotBase* floater) { - LLSnapshotLivePreview* previewp = getPreviewView(floaterp); - - BOOL advanced = gSavedSettings.getBOOL("AdvanceSnapshot"); - - //BD - Automatically calculate the size of our snapshot window to enlarge - // the snapshot preview to its maximum size, this is especially helpfull - // for pretty much every aspect ratio other than 1:1. - F32 panel_width = 400.f * gViewerWindow->getWorldViewAspectRatio(); - - //BD - Make sure we clamp at 700 here because 700 would be for 16:9 which we - // consider the maximum. Everything bigger will be clamped and will have - // a slightly smaller preview window which most likely won't fill up the - // whole snapshot floater as it should. - if(panel_width > 700.f) - { - panel_width = 700.f; - } - - S32 floater_width = 224.f; - if(advanced) - { - floater_width = floater_width + panel_width; - } - - LLUICtrl* thumbnail_placeholder = floaterp->getChild("thumbnail_placeholder"); - thumbnail_placeholder->setVisible(advanced); - thumbnail_placeholder->reshape(panel_width, thumbnail_placeholder->getRect().getHeight()); - floaterp->getChild("image_res_text")->setVisible(advanced); - floaterp->getChild("file_size_label")->setVisible(advanced); - if(!floaterp->isMinimized()) - { - floaterp->reshape(floater_width, floaterp->getRect().getHeight()); - } - - bool use_freeze_frame = floaterp->getChild("freeze_frame_check")->getValue().asBoolean(); - - if (use_freeze_frame) - { - // stop all mouse events at fullscreen preview layer - floaterp->getParent()->setMouseOpaque(TRUE); - - // shrink to smaller layout - // *TODO: unneeded? - floaterp->reshape(floaterp->getRect().getWidth(), floaterp->getRect().getHeight()); - - // can see and interact with fullscreen preview now - if (previewp) - { - previewp->setVisible(TRUE); - previewp->setEnabled(TRUE); - } - - //RN: freeze all avatars - LLCharacter* avatarp; - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) - { - avatarp = *iter; - floaterp->impl.mAvatarPauseHandles.push_back(avatarp->requestPause()); - } - - // freeze everything else - gSavedSettings.setBOOL("FreezeTime", TRUE); - - if (LLToolMgr::getInstance()->getCurrentToolset() != gCameraToolset) - { - floaterp->impl.mLastToolset = LLToolMgr::getInstance()->getCurrentToolset(); - LLToolMgr::getInstance()->setCurrentToolset(gCameraToolset); - } - } - else // turning off freeze frame mode - { - floaterp->getParent()->setMouseOpaque(FALSE); - // *TODO: unneeded? - floaterp->reshape(floaterp->getRect().getWidth(), floaterp->getRect().getHeight()); - if (previewp) - { - previewp->setVisible(FALSE); - previewp->setEnabled(FALSE); - } - - //RN: thaw all avatars - floaterp->impl.mAvatarPauseHandles.clear(); - - // thaw everything else - gSavedSettings.setBOOL("FreezeTime", FALSE); - - // restore last tool (e.g. pie menu, etc) - if (floaterp->impl.mLastToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(floaterp->impl.mLastToolset); - } - } + return LLSnapshotModel::SNAPSHOT_TYPE_COLOR; } // This is the main function that keeps all the GUI controls in sync with the saved settings. @@ -277,788 +94,272 @@ void LLFloaterOutfitSnapshot::Impl::updateLayout(LLFloaterOutfitSnapshot* floate // The basic pattern for programmatically changing the GUI settings is to first set the // appropriate saved settings and then call this method to sync the GUI with them. // FIXME: The above comment seems obsolete now. -// static -void LLFloaterOutfitSnapshot::Impl::updateControls(LLFloaterOutfitSnapshot* floater) -{ - LLPanelSnapshot::ESnapshotType shot_type = getActiveSnapshotType(floater); - LLFloaterSnapshotBase::ESnapshotFormat shot_format = (LLFloaterSnapshotBase::ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat"); - LLViewerWindow::ESnapshotType layer_type = getLayerType(floater); - - LLSnapshotLivePreview* previewp = getPreviewView(floater); - BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); - - // *TODO: Separate maximum size for Web images from postcards - LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; - - LLLocale locale(LLLocale::USER_LOCALE); - std::string bytes_string; - if (got_snap) - { - LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); - } - - // Update displayed image resolution. - LLTextBox* image_res_tb = floater->getChild("image_res_text"); - image_res_tb->setVisible(got_snap); - if (got_snap) - { - image_res_tb->setTextArg("[WIDTH]", llformat("%d", previewp->getEncodedImageWidth())); - image_res_tb->setTextArg("[HEIGHT]", llformat("%d", previewp->getEncodedImageHeight())); - } - - floater->getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown")); - floater->getChild("file_size_label")->setColor(LLUIColorTable::instance().getColor( "LabelTextColor" )); - - updateResolution(floater); - - if (previewp) - { - previewp->setSnapshotType(shot_type); - previewp->setSnapshotFormat(shot_format); - previewp->setSnapshotBufferType(layer_type); - } - - LLPanelSnapshot* current_panel = Impl::getActivePanel(floater); - if (current_panel) - { - LLSD info; - info["have-snapshot"] = got_snap; - current_panel->updateControls(info); - } - LL_DEBUGS() << "finished updating controls" << LL_ENDL; -} - -// static -void LLFloaterOutfitSnapshot::Impl::setStatus(EStatus status, bool ok, const std::string& msg) +// virtual +void LLFloaterOutfitSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) { - LLFloaterOutfitSnapshot* floater = LLFloaterOutfitSnapshot::getInstance(); - switch (status) - { - case STATUS_READY: - setWorking(floater, false); - setFinished(floater, false); - break; - case STATUS_WORKING: - setWorking(floater, true); - setFinished(floater, false); - break; - case STATUS_FINISHED: - setWorking(floater, false); - setFinished(floater, true, ok, msg); - break; - } - - floater->impl.mStatus = status; -} + LLSnapshotModel::ESnapshotType shot_type = getActiveSnapshotType(floater); + LLSnapshotModel::ESnapshotFormat shot_format = (LLSnapshotModel::ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat"); + LLSnapshotModel::ESnapshotLayerType layer_type = getLayerType(floater); -// static -void LLFloaterOutfitSnapshot::Impl::setNeedRefresh(LLFloaterOutfitSnapshot* floater, bool need) -{ - if (!floater) return; + LLSnapshotLivePreview* previewp = getPreviewView(); + BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); - // Don't display the "Refresh to save" message if we're in auto-refresh mode. - if (gSavedSettings.getBOOL("AutoSnapshot")) - { - need = false; - } + // *TODO: Separate maximum size for Web images from postcards + LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; - floater->mRefreshLabel->setVisible(need); - floater->impl.mNeedRefresh = need; -} + LLLocale locale(LLLocale::USER_LOCALE); + std::string bytes_string; + if (got_snap) + { + LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10); + } -// static -void LLFloaterOutfitSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp, BOOL update_thumbnail) -{ - if (previewp) - { - BOOL autosnap = gSavedSettings.getBOOL("AutoSnapshot"); - LL_DEBUGS() << "updating " << (autosnap ? "snapshot" : "thumbnail") << LL_ENDL; - previewp->updateSnapshot(autosnap, update_thumbnail, autosnap ? AUTO_SNAPSHOT_TIME_DELAY : 0.f); - } -} + // Update displayed image resolution. + LLTextBox* image_res_tb = floater->getChild("image_res_text"); + image_res_tb->setVisible(got_snap); + if (got_snap) + { + image_res_tb->setTextArg("[WIDTH]", llformat("%d", previewp->getEncodedImageWidth())); + image_res_tb->setTextArg("[HEIGHT]", llformat("%d", previewp->getEncodedImageHeight())); + } -// static -void LLFloaterOutfitSnapshot::Impl::onClickNewSnapshot(void* data) -{ - LLSnapshotLivePreview* previewp = getPreviewView((LLFloaterOutfitSnapshot *)data); - LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - if (previewp && view) - { - view->impl.setStatus(Impl::STATUS_READY); - LL_DEBUGS() << "updating snapshot" << LL_ENDL; - previewp->mForceUpdateSnapshot = TRUE; - } -} + floater->getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown")); + floater->getChild("file_size_label")->setColor(LLUIColorTable::instance().getColor("LabelTextColor")); -// static -void LLFloaterOutfitSnapshot::Impl::onClickAutoSnap(LLUICtrl *ctrl, void* data) -{ - LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; - gSavedSettings.setBOOL( "AutoSnapshot", check->get() ); - - LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - if (view) - { - checkAutoSnapshot(getPreviewView(view)); - updateControls(view); - } -} + updateResolution(floater); -// static -void LLFloaterOutfitSnapshot::Impl::onClickFilter(LLUICtrl *ctrl, void* data) -{ - LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - if (view) - { - updateControls(view); - LLSnapshotLivePreview* previewp = getPreviewView(view); - if (previewp) - { - checkAutoSnapshot(previewp); - // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale - LLComboBox* filterbox = static_cast(view->getChild("filters_combobox")); - std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : ""); - previewp->setFilter(filter_name); - previewp->updateSnapshot(TRUE); - } - } -} + if (previewp) + { + previewp->setSnapshotType(shot_type); + previewp->setSnapshotFormat(shot_format); + previewp->setSnapshotBufferType(layer_type); + } -// static -void LLFloaterOutfitSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) -{ - LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; - gSavedSettings.setBOOL( "RenderUIInSnapshot", check->get() ); - - LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - if (view) - { - LLSnapshotLivePreview* previewp = getPreviewView(view); - if(previewp) - { - previewp->updateSnapshot(TRUE, TRUE); - } - updateControls(view); - } + LLPanelSnapshot* current_panel = Impl::getActivePanel(floater); + if (current_panel) + { + LLSD info; + info["have-snapshot"] = got_snap; + current_panel->updateControls(info); + } + LL_DEBUGS() << "finished updating controls" << LL_ENDL; } -// static -void LLFloaterOutfitSnapshot::Impl::onClickHUDCheck(LLUICtrl *ctrl, void* data) +// virtual +std::string LLFloaterOutfitSnapshot::Impl::getSnapshotPanelPrefix() { - LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; - gSavedSettings.setBOOL( "RenderHUDInSnapshot", check->get() ); - - LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - if (view) - { - LLSnapshotLivePreview* previewp = getPreviewView(view); - if(previewp) - { - previewp->updateSnapshot(TRUE, TRUE); - } - updateControls(view); - } + return "panel_outfit_snapshot_"; } -// static -void LLFloaterOutfitSnapshot::Impl::onCommitFreezeFrame(LLUICtrl* ctrl, void* data) +// Show/hide upload status message. +// virtual +void LLFloaterOutfitSnapshot::Impl::setFinished(bool finished, bool ok, const std::string& msg) { - LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; - LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - LLSnapshotLivePreview* previewp = getPreviewView(view); - - if (!view || !check_box || !previewp) - { - return; - } - - gSavedSettings.setBOOL("UseFreezeFrame", check_box->get()); + mFloater->setSuccessLabelPanelVisible(finished && ok); + mFloater->setFailureLabelPanelVisible(finished && !ok); - if (check_box->get()) - { - previewp->prepareFreezeFrame(); - } + if (finished) + { + LLUICtrl* finished_lbl = mFloater->getChild(ok ? "succeeded_lbl" : "failed_lbl"); + std::string result_text = mFloater->getString(msg + "_" + (ok ? "succeeded_str" : "failed_str")); + finished_lbl->setValue(result_text); - updateLayout(view); + LLPanel* snapshot_panel = mFloater->getChild("panel_outfit_snapshot_inventory"); + snapshot_panel->onOpen(LLSD()); + } } -// Show/hide upload progress indicators. -// static -void LLFloaterOutfitSnapshot::Impl::setWorking(LLFloaterOutfitSnapshot* floater, bool working) +void LLFloaterOutfitSnapshot::Impl::updateResolution(void* data) { - LLUICtrl* working_lbl = floater->getChild("working_lbl"); - working_lbl->setVisible(working); - floater->getChild("working_indicator")->setVisible(working); + LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - if (working) - { - const std::string panel_name = getActivePanel(floater, false)->getName(); - const std::string prefix = panel_name.substr(std::string("panel_outfit_snapshot_").size()); - std::string progress_text = floater->getString(prefix + "_" + "progress_str"); - working_lbl->setValue(progress_text); - } - - // All controls should be disabled while posting. - floater->setCtrlsEnabled(!working); - LLPanelSnapshot* active_panel = getActivePanel(floater); - if (active_panel) - { - active_panel->enableControls(!working); - } -} + if (!view) + { + llassert(view); + return; + } -// Show/hide upload status message. -// static -void LLFloaterOutfitSnapshot::Impl::setFinished(LLFloaterOutfitSnapshot* floater, bool finished, bool ok, const std::string& msg) -{ - floater->mSucceessLblPanel->setVisible(finished && ok); - floater->mFailureLblPanel->setVisible(finished && !ok); + S32 width = OUTFIT_SNAPSHOT_WIDTH; + S32 height = OUTFIT_SNAPSHOT_HEIGHT; - if (finished) - { - LLUICtrl* finished_lbl = floater->getChild(ok ? "succeeded_lbl" : "failed_lbl"); - std::string result_text = floater->getString(msg + "_" + (ok ? "succeeded_str" : "failed_str")); - finished_lbl->setValue(result_text); + LLSnapshotLivePreview* previewp = getPreviewView(); + if (previewp) + { + S32 original_width = 0, original_height = 0; + previewp->getSize(original_width, original_height); - //LLSideTrayPanelContainer* panel_container = floater->getChild("panel_container"); - //panel_container->openPreviousPanel(); - //panel_container->getCurrentPanel()->onOpen(LLSD()); - LLPanel* snapshot_panel = floater->getChild("panel_outfit_snapshot_inventory"); - snapshot_panel->onOpen(LLSD()); - } -} + if (gSavedSettings.getBOOL("RenderUIInSnapshot") || gSavedSettings.getBOOL("RenderHUDInSnapshot")) + { //clamp snapshot resolution to window size when showing UI or HUD in snapshot + width = llmin(width, gViewerWindow->getWindowWidthRaw()); + height = llmin(height, gViewerWindow->getWindowHeightRaw()); + } -// Apply a new resolution selected from the given combobox. -// static -void LLFloaterOutfitSnapshot::Impl::updateResolution(void* data) -{ - LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - - if (!view) - { - llassert(view); - return; - } - - S32 width = OUTFIT_SNAPSHOT_WIDTH; - S32 height = OUTFIT_SNAPSHOT_HEIGHT; - - LLSnapshotLivePreview* previewp = getPreviewView(view); - if (previewp) - { - S32 original_width = 0 , original_height = 0 ; - previewp->getSize(original_width, original_height) ; - - if (gSavedSettings.getBOOL("RenderUIInSnapshot") || gSavedSettings.getBOOL("RenderHUDInSnapshot")) - { //clamp snapshot resolution to window size when showing UI or HUD in snapshot - width = llmin(width, gViewerWindow->getWindowWidthRaw()); - height = llmin(height, gViewerWindow->getWindowHeightRaw()); - } - llassert(width > 0 && height > 0); // use the resolution from the selected pre-canned drop-down choice LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL; previewp->setSize(width, height); - - if(original_width != width || original_height != height) - { - //previewp->setSize(width, height); - // hide old preview as the aspect ratio could be wrong - checkAutoSnapshot(previewp, FALSE); - LL_DEBUGS() << "updating thumbnail" << LL_ENDL; + if (original_width != width || original_height != height) + { + // hide old preview as the aspect ratio could be wrong + checkAutoSnapshot(previewp, FALSE); + LL_DEBUGS() << "updating thumbnail" << LL_ENDL; previewp->updateSnapshot(TRUE); - } - } -} - -// static -void LLFloaterOutfitSnapshot::Impl::onCommitLayerTypes(LLUICtrl* ctrl, void*data) -{ - LLComboBox* combobox = (LLComboBox*)ctrl; - - LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - - if (view) - { - LLSnapshotLivePreview* previewp = getPreviewView(view); - if (previewp) - { - previewp->setSnapshotBufferType((LLViewerWindow::ESnapshotType)combobox->getCurrentIndex()); - } - checkAutoSnapshot(previewp, TRUE); - } -} - -// static -void LLFloaterOutfitSnapshot::Impl::onSnapshotUploadFinished(bool status) -{ - setStatus(STATUS_FINISHED, status, "profile"); -} - - -// static -void LLFloaterOutfitSnapshot::Impl::onSendingPostcardFinished(bool status) -{ - setStatus(STATUS_FINISHED, status, "postcard"); + } + } } - ///---------------------------------------------------------------------------- -/// Class LLFloaterSnapshot +/// Class LLFloaterOutfitSnapshot ///---------------------------------------------------------------------------- // Default constructor LLFloaterOutfitSnapshot::LLFloaterOutfitSnapshot(const LLSD& key) - : LLFloaterSnapshotBase(key), - mRefreshBtn(NULL), - mRefreshLabel(NULL), - mSucceessLblPanel(NULL), - mFailureLblPanel(NULL), - mOutfitGallery(NULL), - impl (*(new Impl)) +: LLFloaterSnapshotBase(key), +mOutfitGallery(NULL) { + impl = new Impl(this); } -// Destroys the object LLFloaterOutfitSnapshot::~LLFloaterOutfitSnapshot() { - if (impl.mPreviewHandle.get()) impl.mPreviewHandle.get()->die(); - - //unfreeze everything else - gSavedSettings.setBOOL("FreezeTime", FALSE); - - if (impl.mLastToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(impl.mLastToolset); - } - - delete &impl; } - +// virtual BOOL LLFloaterOutfitSnapshot::postBuild() { - mRefreshBtn = getChild("new_snapshot_btn"); - childSetAction("new_snapshot_btn", Impl::onClickNewSnapshot, this); - mRefreshLabel = getChild("refresh_lbl"); - mSucceessLblPanel = getChild("succeeded_panel"); - mFailureLblPanel = getChild("failed_panel"); + mRefreshBtn = getChild("new_snapshot_btn"); + childSetAction("new_snapshot_btn", ImplBase::onClickNewSnapshot, this); + mRefreshLabel = getChild("refresh_lbl"); + mSucceessLblPanel = getChild("succeeded_panel"); + mFailureLblPanel = getChild("failed_panel"); - childSetCommitCallback("ui_check", Impl::onClickUICheck, this); - getChild("ui_check")->setValue(gSavedSettings.getBOOL("RenderUIInSnapshot")); + childSetCommitCallback("ui_check", ImplBase::onClickUICheck, this); + getChild("ui_check")->setValue(gSavedSettings.getBOOL("RenderUIInSnapshot")); - childSetCommitCallback("hud_check", Impl::onClickHUDCheck, this); - getChild("hud_check")->setValue(gSavedSettings.getBOOL("RenderHUDInSnapshot")); + childSetCommitCallback("hud_check", ImplBase::onClickHUDCheck, this); + getChild("hud_check")->setValue(gSavedSettings.getBOOL("RenderHUDInSnapshot")); - getChild("freeze_frame_check")->setValue(gSavedSettings.getBOOL("UseFreezeFrame")); - childSetCommitCallback("freeze_frame_check", Impl::onCommitFreezeFrame, this); + getChild("freeze_frame_check")->setValue(gSavedSettings.getBOOL("UseFreezeFrame")); + childSetCommitCallback("freeze_frame_check", ImplBase::onCommitFreezeFrame, this); - getChild("auto_snapshot_check")->setValue(gSavedSettings.getBOOL("AutoSnapshot")); - childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this); - + getChild("auto_snapshot_check")->setValue(gSavedSettings.getBOOL("AutoSnapshot")); + childSetCommitCallback("auto_snapshot_check", ImplBase::onClickAutoSnap, this); - // Filters - LLComboBox* filterbox = getChild("filters_combobox"); + + // Filters + LLComboBox* filterbox = getChild("filters_combobox"); std::vector filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); for (U32 i = 0; i < filter_list.size(); i++) { filterbox->add(filter_list[i]); } - childSetCommitCallback("filters_combobox", Impl::onClickFilter, this); - - LLWebProfile::setImageUploadResultCallback(boost::bind(&LLFloaterOutfitSnapshot::Impl::onSnapshotUploadFinished, _1)); - LLPostCard::setPostResultCallback(boost::bind(&LLFloaterOutfitSnapshot::Impl::onSendingPostcardFinished, _1)); - - sThumbnailPlaceholder = getChild("thumbnail_placeholder"); - - // create preview window - LLRect full_screen_rect = getRootView()->getRect(); - LLSnapshotLivePreview::Params p; - p.rect(full_screen_rect); - LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); - LLView* parent_view = gSnapshotFloaterView->getParent(); - - parent_view->removeChild(gSnapshotFloaterView); - // make sure preview is below snapshot floater - parent_view->addChild(previewp); - parent_view->addChild(gSnapshotFloaterView); - - //move snapshot floater to special purpose snapshotfloaterview - gFloaterView->removeChild(this); - gSnapshotFloaterView->addChild(this); + childSetCommitCallback("filters_combobox", ImplBase::onClickFilter, this); - impl.mPreviewHandle = previewp->getHandle(); - previewp->setContainer(this); - impl.updateControls(this); - impl.updateLayout(this); - - previewp->mKeepAspectRatio = FALSE; - previewp->setThumbnailPlaceholderRect(getThumbnailPlaceholderRect()); - - return TRUE; -} + LLWebProfile::setImageUploadResultCallback(boost::bind(&ImplBase::onSnapshotUploadFinished, this, _1)); -void LLFloaterOutfitSnapshot::draw() -{ - LLSnapshotLivePreview* previewp = impl.getPreviewView(this); + sThumbnailPlaceholder = getChild("thumbnail_placeholder"); - if (previewp && (previewp->isSnapshotActive() || previewp->getThumbnailLock())) - { - // don't render snapshot window in snapshot, even if "show ui" is turned on - return; - } + // create preview window + LLRect full_screen_rect = getRootView()->getRect(); + LLSnapshotLivePreview::Params p; + p.rect(full_screen_rect); + LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); + LLView* parent_view = gSnapshotFloaterView->getParent(); - LLFloater::draw(); + parent_view->removeChild(gSnapshotFloaterView); + // make sure preview is below snapshot floater + parent_view->addChild(previewp); + parent_view->addChild(gSnapshotFloaterView); - if (previewp && !isMinimized() && sThumbnailPlaceholder->getVisible()) - { - if(previewp->getThumbnailImage()) - { - bool working = impl.getStatus() == Impl::STATUS_WORKING; - const LLRect& thumbnail_rect = getThumbnailPlaceholderRect(); - const S32 thumbnail_w = previewp->getThumbnailWidth(); - const S32 thumbnail_h = previewp->getThumbnailHeight(); + //move snapshot floater to special purpose snapshotfloaterview + gFloaterView->removeChild(this); + gSnapshotFloaterView->addChild(this); - // calc preview offset within the preview rect - const S32 local_offset_x = (thumbnail_rect.getWidth() - thumbnail_w) / 2 ; - const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2 ; // preview y pos within the preview rect - - // calc preview offset within the floater rect - S32 offset_x = thumbnail_rect.mLeft + local_offset_x; - S32 offset_y = thumbnail_rect.mBottom + local_offset_y; - - gGL.matrixMode(LLRender::MM_MODELVIEW); - // Apply floater transparency to the texture unless the floater is focused. - F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); - LLColor4 color = working ? LLColor4::grey4 : LLColor4::white; - gl_draw_scaled_image(offset_x, offset_y, - thumbnail_w, thumbnail_h, - previewp->getThumbnailImage(), color % alpha); + impl->mPreviewHandle = previewp->getHandle(); + previewp->setContainer(this); + impl->updateControls(this); + impl->updateLayout(this); - previewp->drawPreviewRect(offset_x, offset_y) ; + previewp->mKeepAspectRatio = FALSE; + previewp->setThumbnailPlaceholderRect(getThumbnailPlaceholderRect()); - gGL.pushUIMatrix(); - LLUI::translate((F32) thumbnail_rect.mLeft, (F32) thumbnail_rect.mBottom); - sThumbnailPlaceholder->draw(); - gGL.popUIMatrix(); - } - } - impl.updateLayout(this); + return TRUE; } +// virtual void LLFloaterOutfitSnapshot::onOpen(const LLSD& key) { - LLSnapshotLivePreview* preview = LLFloaterOutfitSnapshot::Impl::getPreviewView(this); - if(preview) - { - LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL; - preview->updateSnapshot(TRUE); - } - focusFirstItem(FALSE); - gSnapshotFloaterView->setEnabled(TRUE); - gSnapshotFloaterView->setVisible(TRUE); - gSnapshotFloaterView->adjustToFitScreen(this, FALSE); + LLSnapshotLivePreview* preview = getPreviewView(); + if (preview) + { + LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL; + preview->updateSnapshot(TRUE); + } + focusFirstItem(FALSE); + gSnapshotFloaterView->setEnabled(TRUE); + gSnapshotFloaterView->setVisible(TRUE); + gSnapshotFloaterView->adjustToFitScreen(this, FALSE); - impl.updateControls(this); - impl.updateLayout(this); + impl->updateControls(this); + impl->updateLayout(this); - // Initialize default tab. - //getChild("panel_container")->getCurrentPanel()->onOpen(LLSD()); - //parent->openPanel(panel_name); LLPanel* snapshot_panel = getChild("panel_outfit_snapshot_inventory"); snapshot_panel->onOpen(LLSD()); postPanelSwitch(); } -void LLFloaterOutfitSnapshot::onClose(bool app_quitting) -{ - getParent()->setMouseOpaque(FALSE); - - //unfreeze everything, hide fullscreen preview - LLSnapshotLivePreview* previewp = LLFloaterOutfitSnapshot::Impl::getPreviewView(this); - if (previewp) - { - previewp->setVisible(FALSE); - previewp->setEnabled(FALSE); - } - - gSavedSettings.setBOOL("FreezeTime", FALSE); - impl.mAvatarPauseHandles.clear(); - - if (impl.mLastToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(impl.mLastToolset); - } -} - -// virtual -S32 LLFloaterOutfitSnapshot::notify(const LLSD& info) -{ - if (info.has("set-ready")) - { - impl.setStatus(Impl::STATUS_READY); - return 1; - } - - if (info.has("set-working")) - { - impl.setStatus(Impl::STATUS_WORKING); - return 1; - } - - if (info.has("set-finished")) - { - LLSD data = info["set-finished"]; - impl.setStatus(Impl::STATUS_FINISHED, data["ok"].asBoolean(), data["msg"].asString()); - return 1; - } - - if (info.has("snapshot-updating")) - { - // Disable the send/post/save buttons until snapshot is ready. - impl.updateControls(this); - return 1; - } - - if (info.has("snapshot-updated")) - { - // Enable the send/post/save buttons. - impl.updateControls(this); - // We've just done refresh. - impl.setNeedRefresh(this, false); - - // The refresh button is initially hidden. We show it after the first update, - // i.e. when preview appears. - if (!mRefreshBtn->getVisible()) - { - mRefreshBtn->setVisible(true); - } - return 1; - } - - return 0; -} - -//static +// static void LLFloaterOutfitSnapshot::update() { - LLFloaterOutfitSnapshot* inst = findInstance(); - LLFloaterFacebook* floater_facebook = LLFloaterReg::findTypedInstance("facebook"); - LLFloaterFlickr* floater_flickr = LLFloaterReg::findTypedInstance("flickr"); - LLFloaterTwitter* floater_twitter = LLFloaterReg::findTypedInstance("twitter"); - - if (!inst && !floater_facebook && !floater_flickr && !floater_twitter) - return; - - BOOL changed = FALSE; - LL_DEBUGS() << "npreviews: " << LLSnapshotLivePreview::sList.size() << LL_ENDL; - for (std::set::iterator iter = LLSnapshotLivePreview::sList.begin(); - iter != LLSnapshotLivePreview::sList.end(); ++iter) - { - changed |= LLSnapshotLivePreview::onIdle(*iter); - } - - if (inst && changed) - { - LL_DEBUGS() << "changed" << LL_ENDL; - inst->impl.updateControls(inst); - } + LLFloaterOutfitSnapshot* inst = getInstance(); + if (inst != NULL) + { + inst->impl->updateLivePreview(); + } } // static LLFloaterOutfitSnapshot* LLFloaterOutfitSnapshot::getInstance() { - return LLFloaterReg::getTypedInstance("outfit_snapshot"); + return LLFloaterReg::getTypedInstance("outfit_snapshot"); } -// static -LLFloaterOutfitSnapshot* LLFloaterOutfitSnapshot::findInstance() -{ - return LLFloaterReg::findTypedInstance("outfit_snapshot"); -} - -// static +// virtual void LLFloaterOutfitSnapshot::saveTexture() { - LL_DEBUGS() << "saveTexture" << LL_ENDL; + LL_DEBUGS() << "saveTexture" << LL_ENDL; - // FIXME: duplicated code - LLFloaterOutfitSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return; - } - LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); - if (!previewp) - { - llassert(previewp != NULL); - return; - } + LLSnapshotLivePreview* previewp = getPreviewView(); + if (!previewp) + { + llassert(previewp != NULL); + return; + } - if (instance->mOutfitGallery) + if (mOutfitGallery) { - instance->mOutfitGallery->onBeforeOutfitSnapshotSave(); + mOutfitGallery->onBeforeOutfitSnapshotSave(); } - previewp->saveTexture(TRUE, instance->getOutfitID().asString()); - if (instance->mOutfitGallery) + previewp->saveTexture(TRUE, getOutfitID().asString()); + if (mOutfitGallery) { - instance->mOutfitGallery->onAfterOutfitSnapshotSave(); + mOutfitGallery->onAfterOutfitSnapshotSave(); } - instance->closeFloater(); -} - -// static -void LLFloaterOutfitSnapshot::postSave() -{ - LLFloaterOutfitSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return; - } - - instance->impl.updateControls(instance); - instance->impl.setStatus(Impl::STATUS_WORKING); -} - -// static -void LLFloaterOutfitSnapshot::postPanelSwitch() -{ - LLFloaterOutfitSnapshot* instance = getInstance(); - instance->impl.updateControls(instance); - - // Remove the success/failure indicator whenever user presses a snapshot option button. - instance->impl.setStatus(Impl::STATUS_READY); -} - -// static -LLPointer LLFloaterOutfitSnapshot::getImageData() -{ - // FIXME: May not work for textures. - - LLFloaterOutfitSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return NULL; - } - - LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); - if (!previewp) - { - llassert(previewp != NULL); - return NULL; - } - - LLPointer img = previewp->getFormattedImage(); - if (!img.get()) - { - LL_WARNS() << "Empty snapshot image data" << LL_ENDL; - llassert(img.get() != NULL); - } - - return img; -} - -// static -const LLVector3d& LLFloaterOutfitSnapshot::getPosTakenGlobal() -{ - LLFloaterOutfitSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return LLVector3d::zero; - } - - LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); - if (!previewp) - { - llassert(previewp != NULL); - return LLVector3d::zero; - } - - return previewp->getPosTakenGlobal(); + closeFloater(); } ///---------------------------------------------------------------------------- -/// Class LLSnapshotFloaterView +/// Class LLOutfitSnapshotFloaterView ///---------------------------------------------------------------------------- -LLOutfitSnapshotFloaterView::LLOutfitSnapshotFloaterView (const Params& p) : LLFloaterView (p) +LLOutfitSnapshotFloaterView::LLOutfitSnapshotFloaterView(const Params& p) : LLFloaterView(p) { } LLOutfitSnapshotFloaterView::~LLOutfitSnapshotFloaterView() { } - -BOOL LLOutfitSnapshotFloaterView::handleKey(KEY key, MASK mask, BOOL called_from_parent) -{ - // use default handler when not in freeze-frame mode - if(!gSavedSettings.getBOOL("FreezeTime")) - { - return LLFloaterView::handleKey(key, mask, called_from_parent); - } - - if (called_from_parent) - { - // pass all keystrokes down - LLFloaterView::handleKey(key, mask, called_from_parent); - } - else - { - // bounce keystrokes back down - LLFloaterView::handleKey(key, mask, TRUE); - } - return TRUE; -} - -BOOL LLOutfitSnapshotFloaterView::handleMouseDown(S32 x, S32 y, MASK mask) -{ - // use default handler when not in freeze-frame mode - if(!gSavedSettings.getBOOL("FreezeTime")) - { - return LLFloaterView::handleMouseDown(x, y, mask); - } - // give floater a change to handle mouse, else camera tool - if (childrenHandleMouseDown(x, y, mask) == NULL) - { - LLToolMgr::getInstance()->getCurrentTool()->handleMouseDown( x, y, mask ); - } - return TRUE; -} - -BOOL LLOutfitSnapshotFloaterView::handleMouseUp(S32 x, S32 y, MASK mask) -{ - // use default handler when not in freeze-frame mode - if(!gSavedSettings.getBOOL("FreezeTime")) - { - return LLFloaterView::handleMouseUp(x, y, mask); - } - // give floater a change to handle mouse, else camera tool - if (childrenHandleMouseUp(x, y, mask) == NULL) - { - LLToolMgr::getInstance()->getCurrentTool()->handleMouseUp( x, y, mask ); - } - return TRUE; -} - -BOOL LLOutfitSnapshotFloaterView::handleHover(S32 x, S32 y, MASK mask) -{ - // use default handler when not in freeze-frame mode - if(!gSavedSettings.getBOOL("FreezeTime")) - { - return LLFloaterView::handleHover(x, y, mask); - } - // give floater a change to handle mouse, else camera tool - if (childrenHandleHover(x, y, mask) == NULL) - { - LLToolMgr::getInstance()->getCurrentTool()->handleHover( x, y, mask ); - } - return TRUE; -} diff --git a/indra/newview/llfloateroutfitsnapshot.h b/indra/newview/llfloateroutfitsnapshot.h index 9a7b30ebd8..37e264b0e7 100644 --- a/indra/newview/llfloateroutfitsnapshot.h +++ b/indra/newview/llfloateroutfitsnapshot.h @@ -1,25 +1,25 @@ -/** +/** * @file llfloateroutfitsnapshot.h * @brief Snapshot preview window for saving as an outfit thumbnail in visual outfit gallery * * $LicenseInfo:firstyear=2004&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2016, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -30,71 +30,87 @@ #include "llfloater.h" #include "llfloatersnapshot.h" #include "lloutfitgallery.h" +#include "llsnapshotlivepreview.h" -class LLSpinCtrl; +///---------------------------------------------------------------------------- +/// Class LLFloaterOutfitSnapshot +///---------------------------------------------------------------------------- class LLFloaterOutfitSnapshot : public LLFloaterSnapshotBase { - LOG_CLASS(LLFloaterOutfitSnapshot); + LOG_CLASS(LLFloaterOutfitSnapshot); public: - LLFloaterOutfitSnapshot(const LLSD& key); - virtual ~LLFloaterOutfitSnapshot(); - - /*virtual*/ BOOL postBuild(); - /*virtual*/ void draw(); - /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClose(bool app_quitting); - /*virtual*/ S32 notify(const LLSD& info); - - static void update(); - - // TODO: create a snapshot model instead - static LLFloaterOutfitSnapshot* getInstance(); - static LLFloaterOutfitSnapshot* findInstance(); - static void saveTexture(); - static void postSave(); - static void postPanelSwitch(); - static LLPointer getImageData(); - static const LLVector3d& getPosTakenGlobal(); - - static const LLRect& getThumbnailPlaceholderRect() { return sThumbnailPlaceholder->getRect(); } + LLFloaterOutfitSnapshot(const LLSD& key); + /*virtual*/ ~LLFloaterOutfitSnapshot(); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + + static void update(); + + static LLFloaterOutfitSnapshot* getInstance(); + /*virtual*/ void saveTexture(); + + static const LLRect& getThumbnailPlaceholderRect() { return sThumbnailPlaceholder->getRect(); } void setOutfitID(LLUUID id) { mOutfitID = id; } LLUUID getOutfitID() { return mOutfitID; } void setGallery(LLOutfitGallery* gallery) { mOutfitGallery = gallery; } -private: - static LLUICtrl* sThumbnailPlaceholder; - LLUICtrl *mRefreshBtn, *mRefreshLabel; - LLUICtrl *mSucceessLblPanel, *mFailureLblPanel; - class Impl; - Impl& impl; + class Impl; + friend Impl; +private: LLUUID mOutfitID; LLOutfitGallery* mOutfitGallery; }; +///---------------------------------------------------------------------------- +/// Class LLFloaterOutfitSnapshot::Impl +///---------------------------------------------------------------------------- + +class LLFloaterOutfitSnapshot::Impl : public LLFloaterSnapshotBase::ImplBase +{ + LOG_CLASS(LLFloaterOutfitSnapshot::Impl); +public: + Impl(LLFloaterSnapshotBase* floater) + : LLFloaterSnapshotBase::ImplBase(floater) + {} + ~Impl() + {} + void updateResolution(void* data); + + /*virtual*/ LLPanelSnapshot* getActivePanel(LLFloaterSnapshotBase* floater, bool ok_if_not_found = true); + /*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat(LLFloaterSnapshotBase* floater); + /*virtual*/ std::string getSnapshotPanelPrefix(); + + /*virtual*/ void updateControls(LLFloaterSnapshotBase* floater); + +private: + /*virtual*/ LLSnapshotModel::ESnapshotLayerType getLayerType(LLFloaterSnapshotBase* floater); + /*virtual*/ void setFinished(bool finished, bool ok = true, const std::string& msg = LLStringUtil::null); +}; + +///---------------------------------------------------------------------------- +/// Class LLOutfitSnapshotFloaterView +///---------------------------------------------------------------------------- + class LLOutfitSnapshotFloaterView : public LLFloaterView { public: - struct Params - : public LLInitParam::Block - { - }; + struct Params + : public LLInitParam::Block + { + }; protected: - LLOutfitSnapshotFloaterView (const Params& p); - friend class LLUICtrlFactory; + LLOutfitSnapshotFloaterView(const Params& p); + friend class LLUICtrlFactory; public: - virtual ~LLOutfitSnapshotFloaterView(); - - /*virtual*/ BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); - /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); + virtual ~LLOutfitSnapshotFloaterView(); }; extern LLOutfitSnapshotFloaterView* gOutfitSnapshotFloaterView; diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index e5a2bd03cd..2585c7c6a5 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2004&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2016, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,7 +28,6 @@ #include "llfloatersnapshot.h" -#include "llagent.h" #include "llfacebookconnect.h" #include "llfloaterreg.h" #include "llfloaterfacebook.h" @@ -51,7 +50,7 @@ ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- -LLUICtrl* LLFloaterSnapshot::sThumbnailPlaceholder = NULL; +LLUICtrl* LLFloaterSnapshotBase::sThumbnailPlaceholder = NULL; LLSnapshotFloaterView* gSnapshotFloaterView = NULL; const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; @@ -61,101 +60,8 @@ const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 static LLDefaultChildRegistry::Register r("snapshot_floater_view"); - -LLFloaterSnapshotBase::ImplBase::ImplBase() -{ -} - -LLFloaterSnapshotBase::ImplBase::~ImplBase() -{ -} - - -///---------------------------------------------------------------------------- -/// Class LLFloaterSnapshot::Impl -///---------------------------------------------------------------------------- - -class LLFloaterSnapshot::Impl : public LLFloaterSnapshotBase::ImplBase -{ - LOG_CLASS(LLFloaterSnapshot::Impl); -public: - typedef enum e_status - { - STATUS_READY, - STATUS_WORKING, - STATUS_FINISHED - } EStatus; - - Impl() - : mAvatarPauseHandles(), - mLastToolset(NULL), - mAspectRatioCheckOff(false), - mNeedRefresh(false), - mStatus(STATUS_READY) - { - } - ~Impl() - { - //unpause avatars - mAvatarPauseHandles.clear(); - - } - static void onClickNewSnapshot(void* data); - static void onClickAutoSnap(LLUICtrl *ctrl, void* data); - static void onClickFilter(LLUICtrl *ctrl, void* data); - //static void onClickAdvanceSnap(LLUICtrl *ctrl, void* data); - static void onClickUICheck(LLUICtrl *ctrl, void* data); - static void onClickHUDCheck(LLUICtrl *ctrl, void* data); - static void applyKeepAspectCheck(LLFloaterSnapshot* view, BOOL checked); - static void updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update = TRUE); - static void onCommitFreezeFrame(LLUICtrl* ctrl, void* data); - static void onCommitLayerTypes(LLUICtrl* ctrl, void*data); - static void onImageQualityChange(LLFloaterSnapshot* view, S32 quality_val); - static void onImageFormatChange(LLFloaterSnapshot* view); - static void applyCustomResolution(LLFloaterSnapshot* view, S32 w, S32 h); - static void onSnapshotUploadFinished(bool status); - static void onSendingPostcardFinished(bool status); - static BOOL checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value); - static void setImageSizeSpinnersValues(LLFloaterSnapshot *view, S32 width, S32 height) ; - static void updateSpinners(LLFloaterSnapshot* view, LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL is_width_changed); - - static LLPanelSnapshot* getActivePanel(LLFloaterSnapshot* floater, bool ok_if_not_found = true); - static LLPanelSnapshot::ESnapshotType getActiveSnapshotType(LLFloaterSnapshot* floater); - static LLFloaterSnapshotBase::ESnapshotFormat getImageFormat(LLFloaterSnapshot* floater); - static LLSpinCtrl* getWidthSpinner(LLFloaterSnapshot* floater); - static LLSpinCtrl* getHeightSpinner(LLFloaterSnapshot* floater); - static void enableAspectRatioCheckbox(LLFloaterSnapshot* floater, BOOL enable); - static void setAspectRatioCheckboxValue(LLFloaterSnapshot* floater, BOOL checked); - - static LLSnapshotLivePreview* getPreviewView(LLFloaterSnapshot *floater); - static void setResolution(LLFloaterSnapshot* floater, const std::string& comboname); - static void updateControls(LLFloaterSnapshot* floater); - static void updateLayout(LLFloaterSnapshot* floater); - static void setStatus(EStatus status, bool ok = true, const std::string& msg = LLStringUtil::null); - EStatus getStatus() const { return mStatus; } - static void setNeedRefresh(LLFloaterSnapshot* floater, bool need); - -private: - static LLViewerWindow::ESnapshotType getLayerType(LLFloaterSnapshot* floater); - static void comboSetCustom(LLFloaterSnapshot *floater, const std::string& comboname); - static void checkAutoSnapshot(LLSnapshotLivePreview* floater, BOOL update_thumbnail = FALSE); - static void checkAspectRatio(LLFloaterSnapshot *view, S32 index) ; - static void setWorking(LLFloaterSnapshot* floater, bool working); - static void setFinished(LLFloaterSnapshot* floater, bool finished, bool ok = true, const std::string& msg = LLStringUtil::null); - - -public: - std::vector mAvatarPauseHandles; - - LLToolset* mLastToolset; - LLHandle mPreviewHandle; - bool mAspectRatioCheckOff ; - bool mNeedRefresh; - EStatus mStatus; -}; - -// static -LLPanelSnapshot* LLFloaterSnapshot::Impl::getActivePanel(LLFloaterSnapshot* floater, bool ok_if_not_found) +// virtual +LLPanelSnapshot* LLFloaterSnapshot::Impl::getActivePanel(LLFloaterSnapshotBase* floater, bool ok_if_not_found) { LLSideTrayPanelContainer* panel_container = floater->getChild("panel_container"); LLPanelSnapshot* active_panel = dynamic_cast(panel_container->getCurrentPanel()); @@ -166,63 +72,40 @@ LLPanelSnapshot* LLFloaterSnapshot::Impl::getActivePanel(LLFloaterSnapshot* floa return active_panel; } -// static -LLPanelSnapshot::ESnapshotType LLFloaterSnapshot::Impl::getActiveSnapshotType(LLFloaterSnapshot* floater) +// virtual +LLSnapshotModel::ESnapshotType LLFloaterSnapshotBase::ImplBase::getActiveSnapshotType(LLFloaterSnapshotBase* floater) { - // LLPanelSnapshot::ESnapshotType type = LLPanelSnapshot::SNAPSHOT_WEB; - //std::string name; LLPanelSnapshot* spanel = getActivePanel(floater); - //if (spanel) - //{ - // name = spanel->getName(); - //} - - //if (name == "panel_snapshot_postcard") - //{ - // type = LLPanelSnapshot::SNAPSHOT_POSTCARD; - //} - //else if (name == "panel_snapshot_inventory") - //{ - // type = LLSnapshotLivePreview::SNAPSHOT_TEXTURE; - //} - //else if (name == "panel_snapshot_local") - //{ - // type = LLSnapshotLivePreview::SNAPSHOT_LOCAL; - //} - //return type; if (spanel) { return spanel->getSnapshotType(); } - return LLPanelSnapshot::SNAPSHOT_WEB; + return LLSnapshotModel::SNAPSHOT_WEB; } -// static -LLFloaterSnapshotBase::ESnapshotFormat LLFloaterSnapshot::Impl::getImageFormat(LLFloaterSnapshot* floater) +// virtual +LLSnapshotModel::ESnapshotFormat LLFloaterSnapshot::Impl::getImageFormat(LLFloaterSnapshotBase* floater) { LLPanelSnapshot* active_panel = getActivePanel(floater); // FIXME: if the default is not PNG, profile uploads may fail. - return active_panel ? active_panel->getImageFormat() : LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; + return active_panel ? active_panel->getImageFormat() : LLSnapshotModel::SNAPSHOT_FORMAT_PNG; } -// static -LLSpinCtrl* LLFloaterSnapshot::Impl::getWidthSpinner(LLFloaterSnapshot* floater) +LLSpinCtrl* LLFloaterSnapshot::Impl::getWidthSpinner(LLFloaterSnapshotBase* floater) { LLPanelSnapshot* active_panel = getActivePanel(floater); return active_panel ? active_panel->getWidthSpinner() : floater->getChild("snapshot_width"); } -// static -LLSpinCtrl* LLFloaterSnapshot::Impl::getHeightSpinner(LLFloaterSnapshot* floater) +LLSpinCtrl* LLFloaterSnapshot::Impl::getHeightSpinner(LLFloaterSnapshotBase* floater) { LLPanelSnapshot* active_panel = getActivePanel(floater); return active_panel ? active_panel->getHeightSpinner() : floater->getChild("snapshot_height"); } -// static -void LLFloaterSnapshot::Impl::enableAspectRatioCheckbox(LLFloaterSnapshot* floater, BOOL enable) +void LLFloaterSnapshot::Impl::enableAspectRatioCheckbox(LLFloaterSnapshotBase* floater, BOOL enable) { LLPanelSnapshot* active_panel = getActivePanel(floater); if (active_panel) @@ -231,8 +114,7 @@ void LLFloaterSnapshot::Impl::enableAspectRatioCheckbox(LLFloaterSnapshot* float } } -// static -void LLFloaterSnapshot::Impl::setAspectRatioCheckboxValue(LLFloaterSnapshot* floater, BOOL checked) +void LLFloaterSnapshot::Impl::setAspectRatioCheckboxValue(LLFloaterSnapshotBase* floater, BOOL checked) { LLPanelSnapshot* active_panel = getActivePanel(floater); if (active_panel) @@ -241,38 +123,41 @@ void LLFloaterSnapshot::Impl::setAspectRatioCheckboxValue(LLFloaterSnapshot* flo } } -// static -LLSnapshotLivePreview* LLFloaterSnapshot::Impl::getPreviewView(LLFloaterSnapshot *floater) +LLSnapshotLivePreview* LLFloaterSnapshotBase::getPreviewView() +{ + return impl->getPreviewView(); +} + +LLSnapshotLivePreview* LLFloaterSnapshotBase::ImplBase::getPreviewView() { - LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)floater->impl.mPreviewHandle.get(); + LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get(); return previewp; } -// static -LLViewerWindow::ESnapshotType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSnapshot* floater) +// virtual +LLSnapshotModel::ESnapshotLayerType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSnapshotBase* floater) { - LLViewerWindow::ESnapshotType type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; LLSD value = floater->getChild("layer_types")->getValue(); const std::string id = value.asString(); if (id == "colors") - type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; else if (id == "depth") - type = LLViewerWindow::SNAPSHOT_TYPE_DEPTH; + type = LLSnapshotModel::SNAPSHOT_TYPE_DEPTH; return type; } -// static -void LLFloaterSnapshot::Impl::setResolution(LLFloaterSnapshot* floater, const std::string& comboname) +void LLFloaterSnapshot::Impl::setResolution(LLFloaterSnapshotBase* floater, const std::string& comboname) { LLComboBox* combo = floater->getChild(comboname); combo->setVisible(TRUE); updateResolution(combo, floater, FALSE); // to sync spinners with combo } -//static -void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) +//virtual +void LLFloaterSnapshotBase::ImplBase::updateLayout(LLFloaterSnapshotBase* floaterp) { - LLSnapshotLivePreview* previewp = getPreviewView(floaterp); + LLSnapshotLivePreview* previewp = getPreviewView(); BOOL advanced = gSavedSettings.getBOOL("AdvanceSnapshot"); @@ -330,7 +215,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) iter != LLCharacter::sInstances.end(); ++iter) { avatarp = *iter; - floaterp->impl.mAvatarPauseHandles.push_back(avatarp->requestPause()); + floaterp->impl->mAvatarPauseHandles.push_back(avatarp->requestPause()); } // freeze everything else @@ -338,7 +223,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) if (LLToolMgr::getInstance()->getCurrentToolset() != gCameraToolset) { - floaterp->impl.mLastToolset = LLToolMgr::getInstance()->getCurrentToolset(); + floaterp->impl->mLastToolset = LLToolMgr::getInstance()->getCurrentToolset(); LLToolMgr::getInstance()->setCurrentToolset(gCameraToolset); } } @@ -354,15 +239,15 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) } //RN: thaw all avatars - floaterp->impl.mAvatarPauseHandles.clear(); + floaterp->impl->mAvatarPauseHandles.clear(); // thaw everything else gSavedSettings.setBOOL("FreezeTime", FALSE); // restore last tool (e.g. pie menu, etc) - if (floaterp->impl.mLastToolset) + if (floaterp->impl->mLastToolset) { - LLToolMgr::getInstance()->setCurrentToolset(floaterp->impl.mLastToolset); + LLToolMgr::getInstance()->setCurrentToolset(floaterp->impl->mLastToolset); } } } @@ -373,15 +258,15 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) // The basic pattern for programmatically changing the GUI settings is to first set the // appropriate saved settings and then call this method to sync the GUI with them. // FIXME: The above comment seems obsolete now. -// static -void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) +// virtual +void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) { - LLPanelSnapshot::ESnapshotType shot_type = getActiveSnapshotType(floater); - ESnapshotFormat shot_format = (ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat"); - LLViewerWindow::ESnapshotType layer_type = getLayerType(floater); + LLSnapshotModel::ESnapshotType shot_type = getActiveSnapshotType(floater); + LLSnapshotModel::ESnapshotFormat shot_format = (LLSnapshotModel::ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat"); + LLSnapshotModel::ESnapshotLayerType layer_type = getLayerType(floater); floater->getChild("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat")); - floater->getChildView("layer_types")->setEnabled(shot_type == LLPanelSnapshot::SNAPSHOT_LOCAL); + floater->getChildView("layer_types")->setEnabled(shot_type == LLSnapshotModel::SNAPSHOT_LOCAL); LLPanelSnapshot* active_panel = getActivePanel(floater); if (active_panel) @@ -395,7 +280,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) S32 w = gViewerWindow->getWindowWidthRaw(); LL_DEBUGS() << "Initializing width spinner (" << width_ctrl->getName() << "): " << w << LL_ENDL; width_ctrl->setValue(w); - if(getActiveSnapshotType(floater) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getActiveSnapshotType(floater) == LLSnapshotModel::SNAPSHOT_TEXTURE) { width_ctrl->setIncrement(w >> 1); } @@ -405,7 +290,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) S32 h = gViewerWindow->getWindowHeightRaw(); LL_DEBUGS() << "Initializing height spinner (" << height_ctrl->getName() << "): " << h << LL_ENDL; height_ctrl->setValue(h); - if(getActiveSnapshotType(floater) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getActiveSnapshotType(floater) == LLSnapshotModel::SNAPSHOT_TEXTURE) { height_ctrl->setIncrement(h >> 1); } @@ -437,7 +322,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) } } - LLSnapshotLivePreview* previewp = getPreviewView(floater); + LLSnapshotLivePreview* previewp = getPreviewView(); BOOL got_bytes = previewp && previewp->getDataSize() > 0; BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); @@ -462,35 +347,35 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) floater->getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown")); floater->getChild("file_size_label")->setColor( - shot_type == LLPanelSnapshot::SNAPSHOT_POSTCARD + shot_type == LLSnapshotModel::SNAPSHOT_POSTCARD && got_bytes && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" )); // Update the width and height spinners based on the corresponding resolution combos. (?) switch(shot_type) { - case LLPanelSnapshot::SNAPSHOT_WEB: - layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + case LLSnapshotModel::SNAPSHOT_WEB: + layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; floater->getChild("layer_types")->setValue("colors"); setResolution(floater, "profile_size_combo"); break; - case LLPanelSnapshot::SNAPSHOT_POSTCARD: - layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + case LLSnapshotModel::SNAPSHOT_POSTCARD: + layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; floater->getChild("layer_types")->setValue("colors"); setResolution(floater, "postcard_size_combo"); break; - case LLPanelSnapshot::SNAPSHOT_TEXTURE: - layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; + case LLSnapshotModel::SNAPSHOT_TEXTURE: + layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; floater->getChild("layer_types")->setValue("colors"); setResolution(floater, "texture_size_combo"); break; - case LLPanelSnapshot::SNAPSHOT_LOCAL: + case LLSnapshotModel::SNAPSHOT_LOCAL: setResolution(floater, "local_size_combo"); break; default: break; } - setAspectRatioCheckboxValue(floater, !floater->impl.mAspectRatioCheckOff && gSavedSettings.getBOOL("KeepAspectForSnapshot")); + setAspectRatioCheckboxValue(floater, !floater->impl->mAspectRatioCheckOff && gSavedSettings.getBOOL("KeepAspectForSnapshot")); if (previewp) { @@ -509,33 +394,32 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) LL_DEBUGS() << "finished updating controls" << LL_ENDL; } -// static -void LLFloaterSnapshot::Impl::setStatus(EStatus status, bool ok, const std::string& msg) +//virtual +void LLFloaterSnapshotBase::ImplBase::setStatus(EStatus status, bool ok, const std::string& msg) { - LLFloaterSnapshot* floater = LLFloaterSnapshot::getInstance(); switch (status) { case STATUS_READY: - setWorking(floater, false); - setFinished(floater, false); + setWorking(false); + setFinished(false); break; case STATUS_WORKING: - setWorking(floater, true); - setFinished(floater, false); + setWorking(true); + setFinished(false); break; case STATUS_FINISHED: - setWorking(floater, false); - setFinished(floater, true, ok, msg); + setWorking(false); + setFinished(true, ok, msg); break; } - floater->impl.mStatus = status; + mStatus = status; } -// static -void LLFloaterSnapshot::Impl::setNeedRefresh(LLFloaterSnapshot* floater, bool need) +// virtual +void LLFloaterSnapshotBase::ImplBase::setNeedRefresh(bool need) { - if (!floater) return; + if (!mFloater) return; // Don't display the "Refresh to save" message if we're in auto-refresh mode. if (gSavedSettings.getBOOL("AutoSnapshot")) @@ -543,12 +427,12 @@ void LLFloaterSnapshot::Impl::setNeedRefresh(LLFloaterSnapshot* floater, bool ne need = false; } - floater->mRefreshLabel->setVisible(need); - floater->impl.mNeedRefresh = need; + mFloater->setRefreshLabelVisible(need); + mNeedRefresh = need; } -// static -void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp, BOOL update_thumbnail) +// virtual +void LLFloaterSnapshotBase::ImplBase::checkAutoSnapshot(LLSnapshotLivePreview* previewp, BOOL update_thumbnail) { if (previewp) { @@ -559,43 +443,43 @@ void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp, } // static -void LLFloaterSnapshot::Impl::onClickNewSnapshot(void* data) +void LLFloaterSnapshotBase::ImplBase::onClickNewSnapshot(void* data) { - LLSnapshotLivePreview* previewp = getPreviewView((LLFloaterSnapshot *)data); - LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; - if (previewp && view) + LLFloaterSnapshotBase* floater = (LLFloaterSnapshotBase *)data; + LLSnapshotLivePreview* previewp = floater->getPreviewView(); + if (previewp) { - view->impl.setStatus(Impl::STATUS_READY); + floater->impl->setStatus(ImplBase::STATUS_READY); LL_DEBUGS() << "updating snapshot" << LL_ENDL; previewp->mForceUpdateSnapshot = TRUE; } } // static -void LLFloaterSnapshot::Impl::onClickAutoSnap(LLUICtrl *ctrl, void* data) +void LLFloaterSnapshotBase::ImplBase::onClickAutoSnap(LLUICtrl *ctrl, void* data) { LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; gSavedSettings.setBOOL( "AutoSnapshot", check->get() ); - LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; + LLFloaterSnapshotBase *view = (LLFloaterSnapshotBase *)data; if (view) { - checkAutoSnapshot(getPreviewView(view)); - updateControls(view); + view->impl->checkAutoSnapshot(view->getPreviewView()); + view->impl->updateControls(view); } } // static -void LLFloaterSnapshot::Impl::onClickFilter(LLUICtrl *ctrl, void* data) +void LLFloaterSnapshotBase::ImplBase::onClickFilter(LLUICtrl *ctrl, void* data) { - LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; + LLFloaterSnapshotBase *view = (LLFloaterSnapshotBase *)data; if (view) { - updateControls(view); - LLSnapshotLivePreview* previewp = getPreviewView(view); + view->impl->updateControls(view); + LLSnapshotLivePreview* previewp = view->getPreviewView(); if (previewp) { - checkAutoSnapshot(previewp); + view->impl->checkAutoSnapshot(previewp); // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale LLComboBox* filterbox = static_cast(view->getChild("filters_combobox")); std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : ""); @@ -606,7 +490,7 @@ void LLFloaterSnapshot::Impl::onClickFilter(LLUICtrl *ctrl, void* data) } // static -void LLFloaterSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) +void LLFloaterSnapshotBase::ImplBase::onClickUICheck(LLUICtrl *ctrl, void* data) { LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; gSavedSettings.setBOOL( "RenderUIInSnapshot", check->get() ); @@ -614,17 +498,17 @@ void LLFloaterSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; if (view) { - LLSnapshotLivePreview* previewp = getPreviewView(view); + LLSnapshotLivePreview* previewp = view->getPreviewView(); if(previewp) { previewp->updateSnapshot(TRUE, TRUE); } - updateControls(view); + view->impl->updateControls(view); } } // static -void LLFloaterSnapshot::Impl::onClickHUDCheck(LLUICtrl *ctrl, void* data) +void LLFloaterSnapshotBase::ImplBase::onClickHUDCheck(LLUICtrl *ctrl, void* data) { LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; gSavedSettings.setBOOL( "RenderHUDInSnapshot", check->get() ); @@ -632,17 +516,16 @@ void LLFloaterSnapshot::Impl::onClickHUDCheck(LLUICtrl *ctrl, void* data) LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; if (view) { - LLSnapshotLivePreview* previewp = getPreviewView(view); + LLSnapshotLivePreview* previewp = view->getPreviewView(); if(previewp) { previewp->updateSnapshot(TRUE, TRUE); } - updateControls(view); + view->impl->updateControls(view); } } -// static -void LLFloaterSnapshot::Impl::applyKeepAspectCheck(LLFloaterSnapshot* view, BOOL checked) +void LLFloaterSnapshot::Impl::applyKeepAspectCheck(LLFloaterSnapshotBase* view, BOOL checked) { gSavedSettings.setBOOL("KeepAspectForSnapshot", checked); @@ -655,7 +538,7 @@ void LLFloaterSnapshot::Impl::applyKeepAspectCheck(LLFloaterSnapshot* view, BOOL combo->setCurrentByIndex(combo->getItemCount() - 1); // "custom" is always the last index } - LLSnapshotLivePreview* previewp = getPreviewView(view) ; + LLSnapshotLivePreview* previewp = getPreviewView() ; if(previewp) { previewp->mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ; @@ -673,11 +556,11 @@ void LLFloaterSnapshot::Impl::applyKeepAspectCheck(LLFloaterSnapshot* view, BOOL } // static -void LLFloaterSnapshot::Impl::onCommitFreezeFrame(LLUICtrl* ctrl, void* data) +void LLFloaterSnapshotBase::ImplBase::onCommitFreezeFrame(LLUICtrl* ctrl, void* data) { LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; - LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; - LLSnapshotLivePreview* previewp = getPreviewView(view); + LLFloaterSnapshotBase *view = (LLFloaterSnapshotBase *)data; + LLSnapshotLivePreview* previewp = view->getPreviewView(); if (!view || !check_box || !previewp) { @@ -691,16 +574,15 @@ void LLFloaterSnapshot::Impl::onCommitFreezeFrame(LLUICtrl* ctrl, void* data) previewp->prepareFreezeFrame(); } - updateLayout(view); + view->impl->updateLayout(view); } -// static -void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 index) +void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshotBase *view, S32 index) { - LLSnapshotLivePreview *previewp = getPreviewView(view) ; + LLSnapshotLivePreview *previewp = getPreviewView() ; // Don't round texture sizes; textures are commonly stretched in world, profiles, etc and need to be "squashed" during upload, not cropped here - if(LLPanelSnapshot::SNAPSHOT_TEXTURE == getActiveSnapshotType(view)) + if (LLSnapshotModel::SNAPSHOT_TEXTURE == getActiveSnapshotType(view)) { previewp->mKeepAspectRatio = FALSE ; return ; @@ -724,7 +606,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde keep_aspect = FALSE; } - view->impl.mAspectRatioCheckOff = !enable_cb; + view->impl->mAspectRatioCheckOff = !enable_cb; if (previewp) { @@ -733,51 +615,55 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde } // Show/hide upload progress indicators. -// static -void LLFloaterSnapshot::Impl::setWorking(LLFloaterSnapshot* floater, bool working) +void LLFloaterSnapshotBase::ImplBase::setWorking(bool working) { - LLUICtrl* working_lbl = floater->getChild("working_lbl"); + LLUICtrl* working_lbl = mFloater->getChild("working_lbl"); working_lbl->setVisible(working); - floater->getChild("working_indicator")->setVisible(working); + mFloater->getChild("working_indicator")->setVisible(working); if (working) { - const std::string panel_name = getActivePanel(floater, false)->getName(); - const std::string prefix = panel_name.substr(std::string("panel_snapshot_").size()); - std::string progress_text = floater->getString(prefix + "_" + "progress_str"); + const std::string panel_name = getActivePanel(mFloater, false)->getName(); + const std::string prefix = panel_name.substr(getSnapshotPanelPrefix().size()); + std::string progress_text = mFloater->getString(prefix + "_" + "progress_str"); working_lbl->setValue(progress_text); } // All controls should be disabled while posting. - floater->setCtrlsEnabled(!working); - LLPanelSnapshot* active_panel = getActivePanel(floater); + mFloater->setCtrlsEnabled(!working); + LLPanelSnapshot* active_panel = getActivePanel(mFloater); if (active_panel) { active_panel->enableControls(!working); } } +//virtual +std::string LLFloaterSnapshot::Impl::getSnapshotPanelPrefix() +{ + return "panel_snapshot_"; +} + // Show/hide upload status message. -// static -void LLFloaterSnapshot::Impl::setFinished(LLFloaterSnapshot* floater, bool finished, bool ok, const std::string& msg) +// virtual +void LLFloaterSnapshot::Impl::setFinished(bool finished, bool ok, const std::string& msg) { - floater->mSucceessLblPanel->setVisible(finished && ok); - floater->mFailureLblPanel->setVisible(finished && !ok); + mFloater->setSuccessLabelPanelVisible(finished && ok); + mFloater->setFailureLabelPanelVisible(finished && !ok); if (finished) { - LLUICtrl* finished_lbl = floater->getChild(ok ? "succeeded_lbl" : "failed_lbl"); - std::string result_text = floater->getString(msg + "_" + (ok ? "succeeded_str" : "failed_str")); + LLUICtrl* finished_lbl = mFloater->getChild(ok ? "succeeded_lbl" : "failed_lbl"); + std::string result_text = mFloater->getString(msg + "_" + (ok ? "succeeded_str" : "failed_str")); finished_lbl->setValue(result_text); - LLSideTrayPanelContainer* panel_container = floater->getChild("panel_container"); + LLSideTrayPanelContainer* panel_container = mFloater->getChild("panel_container"); panel_container->openPreviousPanel(); panel_container->getCurrentPanel()->onOpen(LLSD()); } } // Apply a new resolution selected from the given combobox. -// static void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update) { LLComboBox* combobox = (LLComboBox*)ctrl; @@ -797,7 +683,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL S32 width = sdres[0]; S32 height = sdres[1]; - LLSnapshotLivePreview* previewp = getPreviewView(view); + LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp && combobox->getCurrentIndex() >= 0) { S32 original_width = 0 , original_height = 0 ; @@ -827,7 +713,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL new_height = spanel->getTypedPreviewHeight(); // Limit custom size for inventory snapshots to 512x512 px. - if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE) { new_width = llmin(new_width, MAX_TEXTURE_SIZE); new_height = llmin(new_height, MAX_TEXTURE_SIZE); @@ -865,7 +751,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL { getWidthSpinner(view)->setValue(width); getHeightSpinner(view)->setValue(height); - if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE) { getWidthSpinner(view)->setIncrement(width >> 1); getHeightSpinner(view)->setIncrement(height >> 1); @@ -879,7 +765,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL // hide old preview as the aspect ratio could be wrong checkAutoSnapshot(previewp, FALSE); LL_DEBUGS() << "updating thumbnail" << LL_ENDL; - getPreviewView(view)->updateSnapshot(TRUE); + getPreviewView()->updateSnapshot(TRUE); if(do_update) { LL_DEBUGS() << "Will update controls" << LL_ENDL; @@ -898,40 +784,37 @@ void LLFloaterSnapshot::Impl::onCommitLayerTypes(LLUICtrl* ctrl, void*data) if (view) { - LLSnapshotLivePreview* previewp = getPreviewView(view); + LLSnapshotLivePreview* previewp = view->getPreviewView(); if (previewp) { - previewp->setSnapshotBufferType((LLViewerWindow::ESnapshotType)combobox->getCurrentIndex()); + previewp->setSnapshotBufferType((LLSnapshotModel::ESnapshotLayerType)combobox->getCurrentIndex()); } - checkAutoSnapshot(previewp, TRUE); + view->impl->checkAutoSnapshot(previewp, TRUE); } } -// static -void LLFloaterSnapshot::Impl::onImageQualityChange(LLFloaterSnapshot* view, S32 quality_val) +void LLFloaterSnapshot::Impl::onImageQualityChange(LLFloaterSnapshotBase* view, S32 quality_val) { - LLSnapshotLivePreview* previewp = getPreviewView(view); + LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp) { previewp->setSnapshotQuality(quality_val); } } -// static -void LLFloaterSnapshot::Impl::onImageFormatChange(LLFloaterSnapshot* view) +void LLFloaterSnapshot::Impl::onImageFormatChange(LLFloaterSnapshotBase* view) { if (view) { gSavedSettings.setS32("SnapshotFormat", getImageFormat(view)); LL_DEBUGS() << "image format changed, updating snapshot" << LL_ENDL; - getPreviewView(view)->updateSnapshot(TRUE); + getPreviewView()->updateSnapshot(TRUE); updateControls(view); } } // Sets the named size combo to "custom" mode. -// static -void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const std::string& comboname) +void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshotBase* floater, const std::string& comboname) { LLComboBox* combo = floater->getChild(comboname); combo->setCurrentByIndex(combo->getItemCount() - 1); // "custom" is always the last index @@ -939,7 +822,6 @@ void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const s } // Update supplied width and height according to the constrain proportions flag; limit them by max_val. -//static BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value) { S32 w = width ; @@ -984,20 +866,18 @@ BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S3 return (w != width || h != height) ; } -//static -void LLFloaterSnapshot::Impl::setImageSizeSpinnersValues(LLFloaterSnapshot *view, S32 width, S32 height) +void LLFloaterSnapshot::Impl::setImageSizeSpinnersValues(LLFloaterSnapshotBase* view, S32 width, S32 height) { getWidthSpinner(view)->forceSetValue(width); getHeightSpinner(view)->forceSetValue(height); - if (getActiveSnapshotType(view) == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE) { getWidthSpinner(view)->setIncrement(width >> 1); getHeightSpinner(view)->setIncrement(height >> 1); } } -// static -void LLFloaterSnapshot::Impl::updateSpinners(LLFloaterSnapshot* view, LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL is_width_changed) +void LLFloaterSnapshot::Impl::updateSpinners(LLFloaterSnapshotBase* view, LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL is_width_changed) { getWidthSpinner(view)->resetDirty(); getHeightSpinner(view)->resetDirty(); @@ -1007,13 +887,12 @@ void LLFloaterSnapshot::Impl::updateSpinners(LLFloaterSnapshot* view, LLSnapshot } } -// static -void LLFloaterSnapshot::Impl::applyCustomResolution(LLFloaterSnapshot* view, S32 w, S32 h) +void LLFloaterSnapshot::Impl::applyCustomResolution(LLFloaterSnapshotBase* view, S32 w, S32 h) { LL_DEBUGS() << "applyCustomResolution(" << w << ", " << h << ")" << LL_ENDL; if (!view) return; - LLSnapshotLivePreview* previewp = getPreviewView(view); + LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp) { S32 curw,curh; @@ -1037,16 +916,15 @@ void LLFloaterSnapshot::Impl::applyCustomResolution(LLFloaterSnapshot* view, S32 } // static -void LLFloaterSnapshot::Impl::onSnapshotUploadFinished(bool status) +void LLFloaterSnapshotBase::ImplBase::onSnapshotUploadFinished(LLFloaterSnapshotBase* floater, bool status) { - setStatus(STATUS_FINISHED, status, "profile"); + floater->impl->setStatus(STATUS_FINISHED, status, "profile"); } - // static -void LLFloaterSnapshot::Impl::onSendingPostcardFinished(bool status) +void LLFloaterSnapshot::Impl::onSendingPostcardFinished(LLFloaterSnapshotBase* floater, bool status) { - setStatus(STATUS_FINISHED, status, "postcard"); + floater->impl->setStatus(STATUS_FINISHED, status, "postcard"); } ///---------------------------------------------------------------------------- @@ -1055,12 +933,27 @@ void LLFloaterSnapshot::Impl::onSendingPostcardFinished(bool status) // Default constructor LLFloaterSnapshotBase::LLFloaterSnapshotBase(const LLSD& key) - : LLFloater(key) + : LLFloater(key), + mRefreshBtn(NULL), + mRefreshLabel(NULL), + mSucceessLblPanel(NULL), + mFailureLblPanel(NULL) { } LLFloaterSnapshotBase::~LLFloaterSnapshotBase() { + if (impl->mPreviewHandle.get()) impl->mPreviewHandle.get()->die(); + + //unfreeze everything else + gSavedSettings.setBOOL("FreezeTime", FALSE); + + if (impl->mLastToolset) + { + LLToolMgr::getInstance()->setCurrentToolset(impl->mLastToolset); + } + + delete impl; } ///---------------------------------------------------------------------------- @@ -1069,57 +962,41 @@ LLFloaterSnapshotBase::~LLFloaterSnapshotBase() // Default constructor LLFloaterSnapshot::LLFloaterSnapshot(const LLSD& key) - : LLFloaterSnapshotBase(key), - mRefreshBtn(NULL), - mRefreshLabel(NULL), - mSucceessLblPanel(NULL), - mFailureLblPanel(NULL), - impl (*(new Impl)) + : LLFloaterSnapshotBase(key) { + impl = new Impl(this); } -// Destroys the object LLFloaterSnapshot::~LLFloaterSnapshot() { - if (impl.mPreviewHandle.get()) impl.mPreviewHandle.get()->die(); - - //unfreeze everything else - gSavedSettings.setBOOL("FreezeTime", FALSE); - - if (impl.mLastToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(impl.mLastToolset); - } - - delete &impl; } - +// virtual BOOL LLFloaterSnapshot::postBuild() { mRefreshBtn = getChild("new_snapshot_btn"); - childSetAction("new_snapshot_btn", Impl::onClickNewSnapshot, this); + childSetAction("new_snapshot_btn", ImplBase::onClickNewSnapshot, this); mRefreshLabel = getChild("refresh_lbl"); mSucceessLblPanel = getChild("succeeded_panel"); mFailureLblPanel = getChild("failed_panel"); - childSetCommitCallback("ui_check", Impl::onClickUICheck, this); + childSetCommitCallback("ui_check", ImplBase::onClickUICheck, this); getChild("ui_check")->setValue(gSavedSettings.getBOOL("RenderUIInSnapshot")); - childSetCommitCallback("hud_check", Impl::onClickHUDCheck, this); + childSetCommitCallback("hud_check", ImplBase::onClickHUDCheck, this); getChild("hud_check")->setValue(gSavedSettings.getBOOL("RenderHUDInSnapshot")); - impl.setAspectRatioCheckboxValue(this, gSavedSettings.getBOOL("KeepAspectForSnapshot")); + ((Impl*)impl)->setAspectRatioCheckboxValue(this, gSavedSettings.getBOOL("KeepAspectForSnapshot")); childSetCommitCallback("layer_types", Impl::onCommitLayerTypes, this); getChild("layer_types")->setValue("colors"); getChildView("layer_types")->setEnabled(FALSE); getChild("freeze_frame_check")->setValue(gSavedSettings.getBOOL("UseFreezeFrame")); - childSetCommitCallback("freeze_frame_check", Impl::onCommitFreezeFrame, this); + childSetCommitCallback("freeze_frame_check", ImplBase::onCommitFreezeFrame, this); getChild("auto_snapshot_check")->setValue(gSavedSettings.getBOOL("AutoSnapshot")); - childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this); + childSetCommitCallback("auto_snapshot_check", ImplBase::onClickAutoSnap, this); // Filters @@ -1129,10 +1006,10 @@ BOOL LLFloaterSnapshot::postBuild() { filterbox->add(filter_list[i]); } - childSetCommitCallback("filters_combobox", Impl::onClickFilter, this); + childSetCommitCallback("filters_combobox", ImplBase::onClickFilter, this); - LLWebProfile::setImageUploadResultCallback(boost::bind(&LLFloaterSnapshot::Impl::onSnapshotUploadFinished, _1)); - LLPostCard::setPostResultCallback(boost::bind(&LLFloaterSnapshot::Impl::onSendingPostcardFinished, _1)); + LLWebProfile::setImageUploadResultCallback(boost::bind(&ImplBase::onSnapshotUploadFinished, this, _1)); + LLPostCard::setPostResultCallback(boost::bind(&Impl::onSendingPostcardFinished, this, _1)); sThumbnailPlaceholder = getChild("thumbnail_placeholder"); @@ -1159,10 +1036,10 @@ BOOL LLFloaterSnapshot::postBuild() getChild("local_size_combo")->selectNthItem(8); getChild("local_format_combo")->selectNthItem(0); - impl.mPreviewHandle = previewp->getHandle(); + impl->mPreviewHandle = previewp->getHandle(); previewp->setContainer(this); - impl.updateControls(this); - impl.updateLayout(this); + impl->updateControls(this); + impl->updateLayout(this); previewp->setThumbnailPlaceholderRect(getThumbnailPlaceholderRect()); @@ -1170,9 +1047,10 @@ BOOL LLFloaterSnapshot::postBuild() return TRUE; } -void LLFloaterSnapshot::draw() +// virtual +void LLFloaterSnapshotBase::draw() { - LLSnapshotLivePreview* previewp = impl.getPreviewView(this); + LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp && (previewp->isSnapshotActive() || previewp->getThumbnailLock())) { @@ -1186,7 +1064,7 @@ void LLFloaterSnapshot::draw() { if(previewp->getThumbnailImage()) { - bool working = impl.getStatus() == Impl::STATUS_WORKING; + bool working = impl->getStatus() == ImplBase::STATUS_WORKING; const LLRect& thumbnail_rect = getThumbnailPlaceholderRect(); const S32 thumbnail_w = previewp->getThumbnailWidth(); const S32 thumbnail_h = previewp->getThumbnailHeight(); @@ -1215,12 +1093,13 @@ void LLFloaterSnapshot::draw() gGL.popUIMatrix(); } } - impl.updateLayout(this); + impl->updateLayout(this); } +//virtual void LLFloaterSnapshot::onOpen(const LLSD& key) { - LLSnapshotLivePreview* preview = LLFloaterSnapshot::Impl::getPreviewView(this); + LLSnapshotLivePreview* preview = getPreviewView(); if(preview) { LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL; @@ -1231,19 +1110,20 @@ void LLFloaterSnapshot::onOpen(const LLSD& key) gSnapshotFloaterView->setVisible(TRUE); gSnapshotFloaterView->adjustToFitScreen(this, FALSE); - impl.updateControls(this); - impl.updateLayout(this); + impl->updateControls(this); + impl->updateLayout(this); // Initialize default tab. getChild("panel_container")->getCurrentPanel()->onOpen(LLSD()); } -void LLFloaterSnapshot::onClose(bool app_quitting) +//virtual +void LLFloaterSnapshotBase::onClose(bool app_quitting) { getParent()->setMouseOpaque(FALSE); //unfreeze everything, hide fullscreen preview - LLSnapshotLivePreview* previewp = LLFloaterSnapshot::Impl::getPreviewView(this); + LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp) { previewp->setVisible(FALSE); @@ -1251,146 +1131,150 @@ void LLFloaterSnapshot::onClose(bool app_quitting) } gSavedSettings.setBOOL("FreezeTime", FALSE); - impl.mAvatarPauseHandles.clear(); + impl->mAvatarPauseHandles.clear(); - if (impl.mLastToolset) + if (impl->mLastToolset) { - LLToolMgr::getInstance()->setCurrentToolset(impl.mLastToolset); + LLToolMgr::getInstance()->setCurrentToolset(impl->mLastToolset); } } // virtual -S32 LLFloaterSnapshot::notify(const LLSD& info) +S32 LLFloaterSnapshotBase::notify(const LLSD& info) { - // A child panel wants to change snapshot resolution. - if (info.has("combo-res-change")) + if (info.has("set-ready")) { - std::string combo_name = info["combo-res-change"]["control-name"].asString(); - impl.updateResolution(getChild(combo_name), this); + impl->setStatus(ImplBase::STATUS_READY); return 1; } - if (info.has("custom-res-change")) + if (info.has("set-working")) { - LLSD res = info["custom-res-change"]; - impl.applyCustomResolution(this, res["w"].asInteger(), res["h"].asInteger()); + impl->setStatus(ImplBase::STATUS_WORKING); return 1; } - if (info.has("keep-aspect-change")) + if (info.has("set-finished")) { - impl.applyKeepAspectCheck(this, info["keep-aspect-change"].asBoolean()); + LLSD data = info["set-finished"]; + impl->setStatus(ImplBase::STATUS_FINISHED, data["ok"].asBoolean(), data["msg"].asString()); return 1; } - if (info.has("image-quality-change")) + if (info.has("snapshot-updating")) { - impl.onImageQualityChange(this, info["image-quality-change"].asInteger()); + // Disable the send/post/save buttons until snapshot is ready. + impl->updateControls(this); return 1; } - if (info.has("image-format-change")) + if (info.has("snapshot-updated")) { - impl.onImageFormatChange(this); + // Enable the send/post/save buttons. + impl->updateControls(this); + // We've just done refresh. + impl->setNeedRefresh(false); + + // The refresh button is initially hidden. We show it after the first update, + // i.e. when preview appears. + if (!mRefreshBtn->getVisible()) + { + mRefreshBtn->setVisible(true); + } return 1; } - if (info.has("set-ready")) + return 0; +} + +// virtual +S32 LLFloaterSnapshot::notify(const LLSD& info) +{ + bool res = LLFloaterSnapshotBase::notify(info); + if (res) + return res; + // A child panel wants to change snapshot resolution. + if (info.has("combo-res-change")) { - impl.setStatus(Impl::STATUS_READY); + std::string combo_name = info["combo-res-change"]["control-name"].asString(); + ((Impl*)impl)->updateResolution(getChild(combo_name), this); return 1; } - if (info.has("set-working")) + if (info.has("custom-res-change")) { - impl.setStatus(Impl::STATUS_WORKING); + LLSD res = info["custom-res-change"]; + ((Impl*)impl)->applyCustomResolution(this, res["w"].asInteger(), res["h"].asInteger()); return 1; } - if (info.has("set-finished")) + if (info.has("keep-aspect-change")) { - LLSD data = info["set-finished"]; - impl.setStatus(Impl::STATUS_FINISHED, data["ok"].asBoolean(), data["msg"].asString()); + ((Impl*)impl)->applyKeepAspectCheck(this, info["keep-aspect-change"].asBoolean()); return 1; } - - if (info.has("snapshot-updating")) + + if (info.has("image-quality-change")) { - // Disable the send/post/save buttons until snapshot is ready. - impl.updateControls(this); + ((Impl*)impl)->onImageQualityChange(this, info["image-quality-change"].asInteger()); return 1; } - if (info.has("snapshot-updated")) + if (info.has("image-format-change")) { - // Enable the send/post/save buttons. - impl.updateControls(this); - // We've just done refresh. - impl.setNeedRefresh(this, false); - - // The refresh button is initially hidden. We show it after the first update, - // i.e. when preview appears. - if (!mRefreshBtn->getVisible()) - { - mRefreshBtn->setVisible(true); - } + ((Impl*)impl)->onImageFormatChange(this); return 1; - } + } return 0; } -//static -void LLFloaterSnapshot::update() +void LLFloaterSnapshotBase::ImplBase::updateLivePreview() { - LLFloaterSnapshot* inst = findInstance(); - LLFloaterFacebook* floater_facebook = LLFloaterReg::findTypedInstance("facebook"); - LLFloaterFlickr* floater_flickr = LLFloaterReg::findTypedInstance("flickr"); - LLFloaterTwitter* floater_twitter = LLFloaterReg::findTypedInstance("twitter"); + LLFloaterFacebook* floater_facebook = LLFloaterReg::findTypedInstance("facebook"); + LLFloaterFlickr* floater_flickr = LLFloaterReg::findTypedInstance("flickr"); + LLFloaterTwitter* floater_twitter = LLFloaterReg::findTypedInstance("twitter"); - if (!inst && !floater_facebook && !floater_flickr && !floater_twitter) + if (!mFloater && !floater_facebook && !floater_flickr && !floater_twitter) return; - + BOOL changed = FALSE; LL_DEBUGS() << "npreviews: " << LLSnapshotLivePreview::sList.size() << LL_ENDL; for (std::set::iterator iter = LLSnapshotLivePreview::sList.begin(); - iter != LLSnapshotLivePreview::sList.end(); ++iter) + iter != LLSnapshotLivePreview::sList.end(); ++iter) { changed |= LLSnapshotLivePreview::onIdle(*iter); } - - if (inst && changed) + + if (mFloater && changed) { LL_DEBUGS() << "changed" << LL_ENDL; - inst->impl.updateControls(inst); + updateControls(mFloater); } } -// static -LLFloaterSnapshot* LLFloaterSnapshot::getInstance() +//static +void LLFloaterSnapshot::update() { - return LLFloaterReg::getTypedInstance("snapshot"); + LLFloaterSnapshot* inst = getInstance(); + if (inst != NULL) + { + inst->impl->updateLivePreview(); + } } // static -LLFloaterSnapshot* LLFloaterSnapshot::findInstance() +LLFloaterSnapshot* LLFloaterSnapshot::getInstance() { - return LLFloaterReg::findTypedInstance("snapshot"); + return LLFloaterReg::getTypedInstance("snapshot"); } -// static +// virtual void LLFloaterSnapshot::saveTexture() { LL_DEBUGS() << "saveTexture" << LL_ENDL; - // FIXME: duplicated code - LLFloaterSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return; - } - LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); + LLSnapshotLivePreview* previewp = getPreviewView(); if (!previewp) { llassert(previewp != NULL); @@ -1400,18 +1284,10 @@ void LLFloaterSnapshot::saveTexture() previewp->saveTexture(); } -// static BOOL LLFloaterSnapshot::saveLocal() { LL_DEBUGS() << "saveLocal" << LL_ENDL; - // FIXME: duplicated code - LLFloaterSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return FALSE; - } - LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); + LLSnapshotLivePreview* previewp = getPreviewView(); if (!previewp) { llassert(previewp != NULL); @@ -1421,43 +1297,26 @@ BOOL LLFloaterSnapshot::saveLocal() return previewp->saveLocal(); } -// static -void LLFloaterSnapshot::postSave() +void LLFloaterSnapshotBase::postSave() { - LLFloaterSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return; - } - - instance->impl.updateControls(instance); - instance->impl.setStatus(Impl::STATUS_WORKING); + impl->updateControls(this); + impl->setStatus(ImplBase::STATUS_WORKING); } -// static -void LLFloaterSnapshot::postPanelSwitch() +// virtual +void LLFloaterSnapshotBase::postPanelSwitch() { - LLFloaterSnapshot* instance = getInstance(); - instance->impl.updateControls(instance); + impl->updateControls(this); // Remove the success/failure indicator whenever user presses a snapshot option button. - instance->impl.setStatus(Impl::STATUS_READY); + impl->setStatus(ImplBase::STATUS_READY); } -// static -LLPointer LLFloaterSnapshot::getImageData() +LLPointer LLFloaterSnapshotBase::getImageData() { // FIXME: May not work for textures. - LLFloaterSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return NULL; - } - - LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); + LLSnapshotLivePreview* previewp = getPreviewView(); if (!previewp) { llassert(previewp != NULL); @@ -1474,17 +1333,9 @@ LLPointer LLFloaterSnapshot::getImageData() return img; } -// static -const LLVector3d& LLFloaterSnapshot::getPosTakenGlobal() +const LLVector3d& LLFloaterSnapshotBase::getPosTakenGlobal() { - LLFloaterSnapshot* instance = findInstance(); - if (!instance) - { - llassert(instance != NULL); - return LLVector3d::zero; - } - - LLSnapshotLivePreview* previewp = Impl::getPreviewView(instance); + LLSnapshotLivePreview* previewp = getPreviewView(); if (!previewp) { llassert(previewp != NULL); @@ -1497,7 +1348,7 @@ const LLVector3d& LLFloaterSnapshot::getPosTakenGlobal() // static void LLFloaterSnapshot::setAgentEmail(const std::string& email) { - LLFloaterSnapshot* instance = findInstance(); + LLFloaterSnapshot* instance = getInstance(); if (instance) { LLSideTrayPanelContainer* panel_container = instance->getChild("panel_container"); @@ -1518,6 +1369,7 @@ LLSnapshotFloaterView::~LLSnapshotFloaterView() { } +// virtual BOOL LLSnapshotFloaterView::handleKey(KEY key, MASK mask, BOOL called_from_parent) { // use default handler when not in freeze-frame mode @@ -1539,6 +1391,7 @@ BOOL LLSnapshotFloaterView::handleKey(KEY key, MASK mask, BOOL called_from_paren return TRUE; } +// virtual BOOL LLSnapshotFloaterView::handleMouseDown(S32 x, S32 y, MASK mask) { // use default handler when not in freeze-frame mode @@ -1554,6 +1407,7 @@ BOOL LLSnapshotFloaterView::handleMouseDown(S32 x, S32 y, MASK mask) return TRUE; } +// virtual BOOL LLSnapshotFloaterView::handleMouseUp(S32 x, S32 y, MASK mask) { // use default handler when not in freeze-frame mode @@ -1569,6 +1423,7 @@ BOOL LLSnapshotFloaterView::handleMouseUp(S32 x, S32 y, MASK mask) return TRUE; } +// virtual BOOL LLSnapshotFloaterView::handleHover(S32 x, S32 y, MASK mask) { // use default handler when not in freeze-frame mode diff --git a/indra/newview/llfloatersnapshot.h b/indra/newview/llfloatersnapshot.h index 5f9857c8c5..431888d2d0 100644 --- a/indra/newview/llfloatersnapshot.h +++ b/indra/newview/llfloatersnapshot.h @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2004&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2016, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,36 +27,109 @@ #ifndef LL_LLFLOATERSNAPSHOT_H #define LL_LLFLOATERSNAPSHOT_H +#include "llagent.h" #include "llfloater.h" +#include "llpanelsnapshot.h" +#include "llsnapshotmodel.h" class LLSpinCtrl; +class LLSnapshotLivePreview; class LLFloaterSnapshotBase : public LLFloater { LOG_CLASS(LLFloaterSnapshotBase); public: - typedef enum e_snapshot_format - { - SNAPSHOT_FORMAT_PNG, - SNAPSHOT_FORMAT_JPEG, - SNAPSHOT_FORMAT_BMP - } ESnapshotFormat; LLFloaterSnapshotBase(const LLSD& key); virtual ~LLFloaterSnapshotBase(); - ///*virtual*/ S32 notify(const LLSD& info); + /*virtual*/ void draw(); + /*virtual*/ void onClose(bool app_quitting); + virtual S32 notify(const LLSD& info); - //static LLFloaterSnapshotBase* getInstance(); - //static LLFloaterSnapshotBase* findInstance(); - //static void saveTexture(); - //static BOOL saveLocal(); - //static void postSave(); + // TODO: create a snapshot model instead + virtual void saveTexture() = 0; + void postSave(); + virtual void postPanelSwitch(); + LLPointer getImageData(); + LLSnapshotLivePreview* getPreviewView(); + const LLVector3d& getPosTakenGlobal(); + + static const LLRect& getThumbnailPlaceholderRect() { return sThumbnailPlaceholder->getRect(); } + + void setRefreshLabelVisible(bool value) { mRefreshLabel->setVisible(value); } + void setSuccessLabelPanelVisible(bool value) { mSucceessLblPanel->setVisible(value); } + void setFailureLabelPanelVisible(bool value) { mFailureLblPanel->setVisible(value); } + + class ImplBase; + friend ImplBase; + ImplBase* impl; protected: - class ImplBase; - //ImplBase& impl; + static LLUICtrl* sThumbnailPlaceholder; + LLUICtrl *mRefreshBtn, *mRefreshLabel; + LLUICtrl *mSucceessLblPanel, *mFailureLblPanel; +}; + +class LLFloaterSnapshotBase::ImplBase +{ +public: + typedef enum e_status + { + STATUS_READY, + STATUS_WORKING, + STATUS_FINISHED + } EStatus; + + ImplBase(LLFloaterSnapshotBase* floater) : mAvatarPauseHandles(), + mLastToolset(NULL), + mAspectRatioCheckOff(false), + mNeedRefresh(false), + mStatus(STATUS_READY), + mFloater(floater) + {} + virtual ~ImplBase() + { + //unpause avatars + mAvatarPauseHandles.clear(); + } + + static void onClickNewSnapshot(void* data); + static void onClickAutoSnap(LLUICtrl *ctrl, void* data); + static void onClickFilter(LLUICtrl *ctrl, void* data); + static void onClickUICheck(LLUICtrl *ctrl, void* data); + static void onClickHUDCheck(LLUICtrl *ctrl, void* data); + static void onCommitFreezeFrame(LLUICtrl* ctrl, void* data); + static void onSnapshotUploadFinished(LLFloaterSnapshotBase* floater, bool status); + + virtual LLPanelSnapshot* getActivePanel(LLFloaterSnapshotBase* floater, bool ok_if_not_found = true) = 0; + virtual LLSnapshotModel::ESnapshotType getActiveSnapshotType(LLFloaterSnapshotBase* floater); + virtual LLSnapshotModel::ESnapshotFormat getImageFormat(LLFloaterSnapshotBase* floater) = 0; + virtual std::string getSnapshotPanelPrefix() = 0; + + LLSnapshotLivePreview* getPreviewView(); + virtual void updateControls(LLFloaterSnapshotBase* floater) = 0; + virtual void updateLayout(LLFloaterSnapshotBase* floater); + virtual void updateLivePreview(); + virtual void setStatus(EStatus status, bool ok = true, const std::string& msg = LLStringUtil::null); + virtual EStatus getStatus() const { return mStatus; } + virtual void setNeedRefresh(bool need); + + virtual LLSnapshotModel::ESnapshotLayerType getLayerType(LLFloaterSnapshotBase* floater) = 0; + virtual void checkAutoSnapshot(LLSnapshotLivePreview* floater, BOOL update_thumbnail = FALSE); + void setWorking(bool working); + virtual void setFinished(bool finished, bool ok = true, const std::string& msg = LLStringUtil::null) = 0; + +public: + LLFloaterSnapshotBase* mFloater; + std::vector mAvatarPauseHandles; + + LLToolset* mLastToolset; + LLHandle mPreviewHandle; + bool mAspectRatioCheckOff; + bool mNeedRefresh; + EStatus mStatus; }; class LLFloaterSnapshot : public LLFloaterSnapshotBase @@ -64,51 +137,65 @@ class LLFloaterSnapshot : public LLFloaterSnapshotBase LOG_CLASS(LLFloaterSnapshot); public: - //typedef enum e_snapshot_format - //{ - // SNAPSHOT_FORMAT_PNG, - // SNAPSHOT_FORMAT_JPEG, - // SNAPSHOT_FORMAT_BMP - //} ESnapshotFormat; - LLFloaterSnapshot(const LLSD& key); - virtual ~LLFloaterSnapshot(); + /*virtual*/ ~LLFloaterSnapshot(); /*virtual*/ BOOL postBuild(); - /*virtual*/ void draw(); /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClose(bool app_quitting); /*virtual*/ S32 notify(const LLSD& info); static void update(); - // TODO: create a snapshot model instead static LLFloaterSnapshot* getInstance(); - static LLFloaterSnapshot* findInstance(); - static void saveTexture(); - static BOOL saveLocal(); - static void postSave(); - static void postPanelSwitch(); - static LLPointer getImageData(); - static const LLVector3d& getPosTakenGlobal(); + /*virtual*/ void saveTexture(); + BOOL saveLocal(); static void setAgentEmail(const std::string& email); - static const LLRect& getThumbnailPlaceholderRect() { return sThumbnailPlaceholder->getRect(); } - -private: - static LLUICtrl* sThumbnailPlaceholder; - LLUICtrl *mRefreshBtn, *mRefreshLabel; - LLUICtrl *mSucceessLblPanel, *mFailureLblPanel; - class Impl; - Impl& impl; + friend Impl; }; -class LLFloaterSnapshotBase::ImplBase +///---------------------------------------------------------------------------- +/// Class LLFloaterSnapshot::Impl +///---------------------------------------------------------------------------- + +class LLFloaterSnapshot::Impl : public LLFloaterSnapshotBase::ImplBase { + LOG_CLASS(LLFloaterSnapshot::Impl); public: - ImplBase(); - ~ImplBase(); + Impl(LLFloaterSnapshotBase* floater) + : LLFloaterSnapshotBase::ImplBase(floater) + {} + ~Impl() + {} + + void applyKeepAspectCheck(LLFloaterSnapshotBase* view, BOOL checked); + void updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update = TRUE); + static void onCommitLayerTypes(LLUICtrl* ctrl, void*data); + void onImageQualityChange(LLFloaterSnapshotBase* view, S32 quality_val); + void onImageFormatChange(LLFloaterSnapshotBase* view); + void applyCustomResolution(LLFloaterSnapshotBase* view, S32 w, S32 h); + static void onSendingPostcardFinished(LLFloaterSnapshotBase* floater, bool status); + BOOL checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value); + void setImageSizeSpinnersValues(LLFloaterSnapshotBase *view, S32 width, S32 height); + void updateSpinners(LLFloaterSnapshotBase* view, LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL is_width_changed); + + /*virtual*/ LLPanelSnapshot* getActivePanel(LLFloaterSnapshotBase* floater, bool ok_if_not_found = true); + /*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat(LLFloaterSnapshotBase* floater); + LLSpinCtrl* getWidthSpinner(LLFloaterSnapshotBase* floater); + LLSpinCtrl* getHeightSpinner(LLFloaterSnapshotBase* floater); + void enableAspectRatioCheckbox(LLFloaterSnapshotBase* floater, BOOL enable); + void setAspectRatioCheckboxValue(LLFloaterSnapshotBase* floater, BOOL checked); + /*virtual*/ std::string getSnapshotPanelPrefix(); + + void setResolution(LLFloaterSnapshotBase* floater, const std::string& comboname); + /*virtual*/ void updateControls(LLFloaterSnapshotBase* floater); + +private: + /*virtual*/ LLSnapshotModel::ESnapshotLayerType getLayerType(LLFloaterSnapshotBase* floater); + void comboSetCustom(LLFloaterSnapshotBase *floater, const std::string& comboname); + void checkAspectRatio(LLFloaterSnapshotBase *view, S32 index); + void setFinished(bool finished, bool ok = true, const std::string& msg = LLStringUtil::null); }; class LLSnapshotFloaterView : public LLFloaterView diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 984ba587ed..4bab89ace2 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -241,8 +241,8 @@ void LLTwitterPhotoPanel::onVisibilityChange(BOOL visible) mPreviewHandle = previewp->getHandle(); previewp->setContainer(this); - previewp->setSnapshotType(LLPanelSnapshot::SNAPSHOT_WEB); - previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); + previewp->setSnapshotType(LLSnapshotModel::SNAPSHOT_WEB); + previewp->setSnapshotFormat(LLSnapshotModel::SNAPSHOT_FORMAT_JPEG); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots previewp->setAllowFullScreenPreview(FALSE); // No full screen preview in SL Share mode diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 7bd9c0bd94..f6af3d63f6 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -1115,8 +1115,12 @@ void LLOutfitGallery::onSelectPhoto(LLUUID selected_outfit_id) void LLOutfitGallery::onTakeSnapshot(LLUUID selected_outfit_id) { LLFloaterReg::toggleInstanceOrBringToFront("outfit_snapshot"); - LLFloaterOutfitSnapshot::getInstance()->setOutfitID(selected_outfit_id); - LLFloaterOutfitSnapshot::getInstance()->setGallery(this); + LLFloaterOutfitSnapshot* snapshot_floater = LLFloaterOutfitSnapshot::getInstance(); + if (snapshot_floater) + { + snapshot_floater->setOutfitID(selected_outfit_id); + snapshot_floater->getInstance()->setGallery(this); + } } void LLOutfitGallery::onBeforeOutfitSnapshotSave() diff --git a/indra/newview/llpanelsnapshot.cpp b/indra/newview/llpanelsnapshot.cpp index e320c4ce8b..a17e3f9e78 100644 --- a/indra/newview/llpanelsnapshot.cpp +++ b/indra/newview/llpanelsnapshot.cpp @@ -29,6 +29,8 @@ // libs #include "llcombobox.h" +#include "llfloater.h" +#include "llfloatersnapshot.h" #include "llsliderctrl.h" #include "llspinctrl.h" #include "lltrans.h" @@ -50,6 +52,10 @@ S32 power_of_two(S32 sz, S32 upper) return res; } +LLPanelSnapshot::LLPanelSnapshot() + : mSnapshotFloater(NULL) +{} + // virtual BOOL LLPanelSnapshot::postBuild() { @@ -67,6 +73,8 @@ BOOL LLPanelSnapshot::postBuild() getChild(getAspectRatioCBName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onKeepAspectRatioCommit, this, _1)); } updateControls(LLSD()); + + mSnapshotFloater = getParentByType(); return TRUE; } @@ -88,9 +96,9 @@ void LLPanelSnapshot::onOpen(const LLSD& key) } } -LLFloaterSnapshotBase::ESnapshotFormat LLPanelSnapshot::getImageFormat() const +LLSnapshotModel::ESnapshotFormat LLPanelSnapshot::getImageFormat() const { - return LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG; + return LLSnapshotModel::SNAPSHOT_FORMAT_JPEG; } void LLPanelSnapshot::enableControls(BOOL enable) @@ -228,7 +236,7 @@ void LLPanelSnapshot::onKeepAspectRatioCommit(LLUICtrl* ctrl) getParentByType()->notify(LLSD().with("keep-aspect-change", ctrl->getValue().asBoolean())); } -LLPanelSnapshot::ESnapshotType LLPanelSnapshot::getSnapshotType() +LLSnapshotModel::ESnapshotType LLPanelSnapshot::getSnapshotType() { - return LLPanelSnapshot::SNAPSHOT_WEB; + return LLSnapshotModel::SNAPSHOT_WEB; } diff --git a/indra/newview/llpanelsnapshot.h b/indra/newview/llpanelsnapshot.h index 3868020cdf..55273797cc 100644 --- a/indra/newview/llpanelsnapshot.h +++ b/indra/newview/llpanelsnapshot.h @@ -27,9 +27,13 @@ #ifndef LL_LLPANELSNAPSHOT_H #define LL_LLPANELSNAPSHOT_H -#include "llfloatersnapshot.h" +//#include "llfloatersnapshot.h" +#include "llpanel.h" +#include "llsnapshotmodel.h" +class LLSpinCtrl; class LLSideTrayPanelContainer; +class LLFloaterSnapshotBase; /** * Snapshot panel base class. @@ -37,13 +41,7 @@ class LLSideTrayPanelContainer; class LLPanelSnapshot: public LLPanel { public: - enum ESnapshotType - { - SNAPSHOT_POSTCARD, - SNAPSHOT_TEXTURE, - SNAPSHOT_LOCAL, - SNAPSHOT_WEB - }; + LLPanelSnapshot(); /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); @@ -59,8 +57,8 @@ public: virtual LLSpinCtrl* getWidthSpinner(); virtual LLSpinCtrl* getHeightSpinner(); virtual void enableAspectRatioCheckbox(BOOL enable); - virtual LLFloaterSnapshotBase::ESnapshotFormat getImageFormat() const; - virtual ESnapshotType getSnapshotType(); + virtual LLSnapshotModel::ESnapshotFormat getImageFormat() const; + virtual LLSnapshotModel::ESnapshotType getSnapshotType(); virtual void updateControls(const LLSD& info) = 0; ///< Update controls from saved settings void enableControls(BOOL enable); @@ -74,6 +72,8 @@ protected: void onCustomResolutionCommit(); void onResolutionComboCommit(LLUICtrl* ctrl); void onKeepAspectRatioCommit(LLUICtrl* ctrl); + + LLFloaterSnapshotBase* mSnapshotFloater; }; #endif // LL_LLPANELSNAPSHOT_H diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp index 057e046e30..408eb8fbf3 100644 --- a/indra/newview/llpanelsnapshotinventory.cpp +++ b/indra/newview/llpanelsnapshotinventory.cpp @@ -32,7 +32,6 @@ #include "llspinctrl.h" #include "llfloatersnapshot.h" // FIXME: replace with a snapshot storage model -#include "llfloateroutfitsnapshot.h" #include "llpanelsnapshot.h" #include "llsnapshotlivepreview.h" #include "llviewercontrol.h" // gSavedSettings @@ -48,10 +47,10 @@ class LLPanelSnapshotInventoryBase public: LLPanelSnapshotInventoryBase(); + /*virtual*/ BOOL postBuild(); protected: - virtual void onSend() = 0; - /*virtual*/ LLPanelSnapshot::ESnapshotType getSnapshotType(); - + void onSend(); + /*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType(); }; class LLPanelSnapshotInventory @@ -74,7 +73,6 @@ private: /*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; } /*virtual*/ void updateControls(const LLSD& info); - /*virtual*/ void onSend(); }; class LLPanelOutfitSnapshotInventory @@ -95,7 +93,6 @@ private: /*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; } /*virtual*/ void updateControls(const LLSD& info); - /*virtual*/ void onSend(); /*virtual*/ void cancel(); }; @@ -107,9 +104,14 @@ LLPanelSnapshotInventoryBase::LLPanelSnapshotInventoryBase() { } -LLPanelSnapshot::ESnapshotType LLPanelSnapshotInventoryBase::getSnapshotType() +BOOL LLPanelSnapshotInventoryBase::postBuild() +{ + return LLPanelSnapshot::postBuild(); +} + +LLSnapshotModel::ESnapshotType LLPanelSnapshotInventoryBase::getSnapshotType() { - return LLPanelSnapshot::SNAPSHOT_TEXTURE; + return LLSnapshotModel::SNAPSHOT_TEXTURE; } LLPanelSnapshotInventory::LLPanelSnapshotInventory() @@ -125,7 +127,7 @@ BOOL LLPanelSnapshotInventory::postBuild() getChild(getHeightSpinnerName())->setAllowEdit(FALSE); getChild(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshotInventory::onResolutionCommit, this, _1)); - return LLPanelSnapshot::postBuild(); + return LLPanelSnapshotInventoryBase::postBuild(); } // virtual @@ -149,10 +151,13 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl) getChild(getHeightSpinnerName())->setVisible(!current_window_selected); } -void LLPanelSnapshotInventory::onSend() +void LLPanelSnapshotInventoryBase::onSend() { - LLFloaterSnapshot::saveTexture(); - LLFloaterSnapshot::postSave(); + if (mSnapshotFloater) + { + mSnapshotFloater->saveTexture(); + mSnapshotFloater->postSave(); + } } LLPanelOutfitSnapshotInventory::LLPanelOutfitSnapshotInventory() @@ -164,7 +169,7 @@ LLPanelOutfitSnapshotInventory::LLPanelOutfitSnapshotInventory() // virtual BOOL LLPanelOutfitSnapshotInventory::postBuild() { - return LLPanelSnapshot::postBuild(); + return LLPanelSnapshotInventoryBase::postBuild(); } // virtual @@ -181,13 +186,10 @@ void LLPanelOutfitSnapshotInventory::updateControls(const LLSD& info) getChild("save_btn")->setEnabled(have_snapshot); } -void LLPanelOutfitSnapshotInventory::onSend() -{ - LLFloaterOutfitSnapshot::saveTexture(); - LLFloaterOutfitSnapshot::postSave(); -} - void LLPanelOutfitSnapshotInventory::cancel() { - getParentByType()->closeFloater(); + if (mSnapshotFloater) + { + mSnapshotFloater->closeFloater(); + } } diff --git a/indra/newview/llpanelsnapshotlocal.cpp b/indra/newview/llpanelsnapshotlocal.cpp index 954eb63a28..3652c10586 100644 --- a/indra/newview/llpanelsnapshotlocal.cpp +++ b/indra/newview/llpanelsnapshotlocal.cpp @@ -56,9 +56,9 @@ private: /*virtual*/ std::string getAspectRatioCBName() const { return "local_keep_aspect_check"; } /*virtual*/ std::string getImageSizeComboName() const { return "local_size_combo"; } /*virtual*/ std::string getImageSizePanelName() const { return "local_image_size_lp"; } - /*virtual*/ LLFloaterSnapshotBase::ESnapshotFormat getImageFormat() const; - /*virtual*/ LLPanelSnapshot::ESnapshotType getSnapshotType(); - /*virtual*/ void updateControls(const LLSD& info); + /*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const; + /*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType(); + /*virtual*/ void updateControls(const LLSD& info); S32 mLocalFormat; @@ -96,23 +96,23 @@ void LLPanelSnapshotLocal::onOpen(const LLSD& key) } // virtual -LLFloaterSnapshotBase::ESnapshotFormat LLPanelSnapshotLocal::getImageFormat() const +LLSnapshotModel::ESnapshotFormat LLPanelSnapshotLocal::getImageFormat() const { - LLFloaterSnapshotBase::ESnapshotFormat fmt = LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; + LLSnapshotModel::ESnapshotFormat fmt = LLSnapshotModel::SNAPSHOT_FORMAT_PNG; LLComboBox* local_format_combo = getChild("local_format_combo"); const std::string id = local_format_combo->getValue().asString(); if (id == "PNG") { - fmt = LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; + fmt = LLSnapshotModel::SNAPSHOT_FORMAT_PNG; } else if (id == "JPEG") { - fmt = LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG; + fmt = LLSnapshotModel::SNAPSHOT_FORMAT_JPEG; } else if (id == "BMP") { - fmt = LLFloaterSnapshot::SNAPSHOT_FORMAT_BMP; + fmt = LLSnapshotModel::SNAPSHOT_FORMAT_BMP; } return fmt; @@ -121,11 +121,11 @@ LLFloaterSnapshotBase::ESnapshotFormat LLPanelSnapshotLocal::getImageFormat() co // virtual void LLPanelSnapshotLocal::updateControls(const LLSD& info) { - LLFloaterSnapshotBase::ESnapshotFormat fmt = - (LLFloaterSnapshotBase::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); + LLSnapshotModel::ESnapshotFormat fmt = + (LLSnapshotModel::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); getChild("local_format_combo")->selectNthItem((S32) fmt); - const bool show_quality_ctrls = (fmt == LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); + const bool show_quality_ctrls = (fmt == LLSnapshotModel::SNAPSHOT_FORMAT_JPEG); getChild("image_quality_slider")->setVisible(show_quality_ctrls); getChild("image_quality_level")->setVisible(show_quality_ctrls); @@ -164,10 +164,10 @@ void LLPanelSnapshotLocal::onSaveFlyoutCommit(LLUICtrl* ctrl) LLFloaterSnapshot* floater = LLFloaterSnapshot::getInstance(); floater->notify(LLSD().with("set-working", true)); - BOOL saved = LLFloaterSnapshot::saveLocal(); + BOOL saved = floater->saveLocal(); if (saved) { - LLFloaterSnapshot::postSave(); + mSnapshotFloater->postSave(); goBack(); floater->notify(LLSD().with("set-finished", LLSD().with("ok", true).with("msg", "local"))); } @@ -177,7 +177,7 @@ void LLPanelSnapshotLocal::onSaveFlyoutCommit(LLUICtrl* ctrl) } } -LLPanelSnapshot::ESnapshotType LLPanelSnapshotLocal::getSnapshotType() +LLSnapshotModel::ESnapshotType LLPanelSnapshotLocal::getSnapshotType() { - return LLPanelSnapshot::SNAPSHOT_LOCAL; + return LLSnapshotModel::SNAPSHOT_LOCAL; } diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp index 0fc9ceec83..269f16c5e4 100644 --- a/indra/newview/llpanelsnapshotoptions.cpp +++ b/indra/newview/llpanelsnapshotoptions.cpp @@ -62,6 +62,8 @@ private: void onSendToFacebook(); void onSendToTwitter(); void onSendToFlickr(); + + LLFloaterSnapshotBase* mSnapshotFloater; }; static LLPanelInjector panel_class("llpanelsnapshotoptions"); @@ -86,6 +88,7 @@ LLPanelSnapshotOptions::~LLPanelSnapshotOptions() // virtual BOOL LLPanelSnapshotOptions::postBuild() { + mSnapshotFloater = getParentByType(); return LLPanel::postBuild(); } @@ -112,7 +115,7 @@ void LLPanelSnapshotOptions::openPanel(const std::string& panel_name) parent->openPanel(panel_name); parent->getCurrentPanel()->onOpen(LLSD()); - LLFloaterSnapshot::postPanelSwitch(); + mSnapshotFloater->postPanelSwitch(); } void LLPanelSnapshotOptions::onSaveToProfile() diff --git a/indra/newview/llpanelsnapshotpostcard.cpp b/indra/newview/llpanelsnapshotpostcard.cpp index dcd12a7a47..12adcdec8d 100644 --- a/indra/newview/llpanelsnapshotpostcard.cpp +++ b/indra/newview/llpanelsnapshotpostcard.cpp @@ -65,13 +65,13 @@ private: /*virtual*/ std::string getAspectRatioCBName() const { return "postcard_keep_aspect_check"; } /*virtual*/ std::string getImageSizeComboName() const { return "postcard_size_combo"; } /*virtual*/ std::string getImageSizePanelName() const { return "postcard_image_size_lp"; } - /*virtual*/ LLFloaterSnapshotBase::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshotBase::SNAPSHOT_FORMAT_JPEG; } - /*virtual*/ LLPanelSnapshot::ESnapshotType getSnapshotType(); - /*virtual*/ void updateControls(const LLSD& info); + /*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const { return LLSnapshotModel::SNAPSHOT_FORMAT_JPEG; } + /*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType(); + /*virtual*/ void updateControls(const LLSD& info); bool missingSubjMsgAlertCallback(const LLSD& notification, const LLSD& response); - static void sendPostcardFinished(LLSD result); - void sendPostcard(); + static void sendPostcardFinished(LLSD result); + void sendPostcard(); void onMsgFormFocusRecieved(); void onFormatComboCommit(LLUICtrl* ctrl); @@ -192,8 +192,8 @@ void LLPanelSnapshotPostcard::sendPostcard() getChild("to_form")->getValue().asString(), getChild("subject_form")->getValue().asString(), getChild("msg_form")->getValue().asString(), - LLFloaterSnapshot::getPosTakenGlobal(), - LLFloaterSnapshot::getImageData(), + mSnapshotFloater->getPosTakenGlobal(), + mSnapshotFloater->getImageData(), boost::bind(&LLPanelSnapshotPostcard::sendPostcardFinished, _4))); LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); @@ -207,7 +207,7 @@ void LLPanelSnapshotPostcard::sendPostcard() // Give user feedback of the event. gViewerWindow->playSnapshotAnimAndSound(); - LLFloaterSnapshot::postSave(); + mSnapshotFloater->postSave(); } void LLPanelSnapshotPostcard::onMsgFormFocusRecieved() @@ -267,7 +267,7 @@ void LLPanelSnapshotPostcard::onSend() sendPostcard(); } -LLPanelSnapshot::ESnapshotType LLPanelSnapshotPostcard::getSnapshotType() +LLSnapshotModel::ESnapshotType LLPanelSnapshotPostcard::getSnapshotType() { - return LLPanelSnapshot::SNAPSHOT_POSTCARD; + return LLSnapshotModel::SNAPSHOT_POSTCARD; } diff --git a/indra/newview/llpanelsnapshotprofile.cpp b/indra/newview/llpanelsnapshotprofile.cpp index b6fc45fb63..38dec78030 100644 --- a/indra/newview/llpanelsnapshotprofile.cpp +++ b/indra/newview/llpanelsnapshotprofile.cpp @@ -58,7 +58,7 @@ private: /*virtual*/ std::string getAspectRatioCBName() const { return "profile_keep_aspect_check"; } /*virtual*/ std::string getImageSizeComboName() const { return "profile_size_combo"; } /*virtual*/ std::string getImageSizePanelName() const { return "profile_image_size_lp"; } - /*virtual*/ LLFloaterSnapshotBase::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshotBase::SNAPSHOT_FORMAT_PNG; } + /*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const { return LLSnapshotModel::SNAPSHOT_FORMAT_PNG; } /*virtual*/ void updateControls(const LLSD& info); void onSend(); @@ -96,6 +96,6 @@ void LLPanelSnapshotProfile::onSend() std::string caption = getChild("caption")->getValue().asString(); bool add_location = getChild("add_location_cb")->getValue().asBoolean(); - LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location); - LLFloaterSnapshot::postSave(); + LLWebProfile::uploadImage(mSnapshotFloater->getImageData(), caption, add_location); + mSnapshotFloater->postSave(); } diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 15aa62f5d3..049aae1336 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -86,13 +86,13 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param mNeedsFlash(TRUE), mSnapshotQuality(gSavedSettings.getS32("SnapshotQuality")), mDataSize(0), - mSnapshotType(LLPanelSnapshot::SNAPSHOT_POSTCARD), - mSnapshotFormat(LLFloaterSnapshotBase::ESnapshotFormat(gSavedSettings.getS32("SnapshotFormat"))), + mSnapshotType(LLSnapshotModel::SNAPSHOT_POSTCARD), + mSnapshotFormat(LLSnapshotModel::ESnapshotFormat(gSavedSettings.getS32("SnapshotFormat"))), mSnapshotUpToDate(FALSE), mCameraPos(LLViewerCamera::getInstance()->getOrigin()), mCameraRot(LLViewerCamera::getInstance()->getQuaternion()), mSnapshotActive(FALSE), - mSnapshotBufferType(LLViewerWindow::SNAPSHOT_TYPE_COLOR), + mSnapshotBufferType(LLSnapshotModel::SNAPSHOT_TYPE_COLOR), mFilterName(""), mAllowRenderUI(TRUE), mAllowFullScreenPreview(TRUE), @@ -737,7 +737,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) previewp->getWidth(), previewp->getHeight(), previewp->mKeepAspectRatio,//gSavedSettings.getBOOL("KeepAspectForSnapshot"), - previewp->getSnapshotType() == LLPanelSnapshot::SNAPSHOT_TEXTURE, + previewp->getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE, previewp->mAllowRenderUI && gSavedSettings.getBOOL("RenderUIInSnapshot"), FALSE, previewp->mSnapshotBufferType, @@ -813,7 +813,7 @@ void LLSnapshotLivePreview::prepareFreezeFrame() mViewerImage[mCurImageIndex] = LLViewerTextureManager::getLocalTexture(scaled.get(), FALSE); LLPointer curr_preview_image = mViewerImage[mCurImageIndex]; gGL.getTexUnit(0)->bind(curr_preview_image); - curr_preview_image->setFilteringOption(getSnapshotType() == LLPanelSnapshot::SNAPSHOT_TEXTURE ? LLTexUnit::TFO_ANISOTROPIC : LLTexUnit::TFO_POINT); + curr_preview_image->setFilteringOption(getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE ? LLTexUnit::TFO_ANISOTROPIC : LLTexUnit::TFO_POINT); curr_preview_image->setAddressMode(LLTexUnit::TAM_CLAMP); @@ -827,7 +827,7 @@ void LLSnapshotLivePreview::prepareFreezeFrame() S32 LLSnapshotLivePreview::getEncodedImageWidth() const { S32 width = getWidth(); - if (getSnapshotType() == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE) { width = LLImageRaw::biasedDimToPowerOfTwo(width,MAX_TEXTURE_SIZE); } @@ -836,7 +836,7 @@ S32 LLSnapshotLivePreview::getEncodedImageWidth() const S32 LLSnapshotLivePreview::getEncodedImageHeight() const { S32 height = getHeight(); - if (getSnapshotType() == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE) { height = LLImageRaw::biasedDimToPowerOfTwo(height,MAX_TEXTURE_SIZE); } @@ -854,7 +854,7 @@ LLPointer LLSnapshotLivePreview::getEncodedImage() mPreviewImage->getHeight(), mPreviewImage->getComponents()); - if (getSnapshotType() == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE) { // We don't store the intermediate formatted image in mFormattedImage in the J2C case LL_DEBUGS() << "Encoding new image of format J2C" << LL_ENDL; @@ -881,7 +881,7 @@ LLPointer LLSnapshotLivePreview::getEncodedImage() { // Update mFormattedImage if necessary getFormattedImage(); - if (getSnapshotFormat() == LLFloaterSnapshot::SNAPSHOT_FORMAT_BMP) + if (getSnapshotFormat() == LLSnapshotModel::SNAPSHOT_FORMAT_BMP) { // BMP hack : copy instead of decode otherwise decode will crash. mPreviewImageEncoded->copy(mPreviewImage); @@ -903,23 +903,23 @@ void LLSnapshotLivePreview::estimateDataSize() // Compression ratio F32 ratio = 1.0; - if (getSnapshotType() == LLPanelSnapshot::SNAPSHOT_TEXTURE) + if (getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE) { ratio = 8.0; // This is what we shoot for when compressing to J2C } else { - LLFloaterSnapshotBase::ESnapshotFormat format = getSnapshotFormat(); + LLSnapshotModel::ESnapshotFormat format = getSnapshotFormat(); switch (format) { - case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG: + case LLSnapshotModel::SNAPSHOT_FORMAT_PNG: ratio = 3.0; // Average observed PNG compression ratio break; - case LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG: + case LLSnapshotModel::SNAPSHOT_FORMAT_JPEG: // Observed from JPG compression tests ratio = (110 - mSnapshotQuality) / 2; break; - case LLFloaterSnapshot::SNAPSHOT_FORMAT_BMP: + case LLSnapshotModel::SNAPSHOT_FORMAT_BMP: ratio = 1.0; // No compression with BMP break; } @@ -947,18 +947,18 @@ LLPointer LLSnapshotLivePreview::getFormattedImage() } // Create the new formatted image of the appropriate format. - LLFloaterSnapshotBase::ESnapshotFormat format = getSnapshotFormat(); + LLSnapshotModel::ESnapshotFormat format = getSnapshotFormat(); LL_DEBUGS() << "Encoding new image of format " << format << LL_ENDL; switch (format) { - case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG: + case LLSnapshotModel::SNAPSHOT_FORMAT_PNG: mFormattedImage = new LLImagePNG(); break; - case LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG: + case LLSnapshotModel::SNAPSHOT_FORMAT_JPEG: mFormattedImage = new LLImageJPEG(mSnapshotQuality); break; - case LLFloaterSnapshot::SNAPSHOT_FORMAT_BMP: + case LLSnapshotModel::SNAPSHOT_FORMAT_BMP: mFormattedImage = new LLImageBMP(); break; } @@ -978,7 +978,7 @@ void LLSnapshotLivePreview::setSize(S32 w, S32 h) setHeight(h); } -void LLSnapshotLivePreview::setSnapshotFormat(LLFloaterSnapshotBase::ESnapshotFormat format) +void LLSnapshotLivePreview::setSnapshotFormat(LLSnapshotModel::ESnapshotFormat format) { if (mSnapshotFormat != format) { diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h index b822707d29..b689c50320 100644 --- a/indra/newview/llsnapshotlivepreview.h +++ b/indra/newview/llsnapshotlivepreview.h @@ -27,7 +27,7 @@ #ifndef LL_LLSNAPSHOTLIVEPREVIEW_H #define LL_LLSNAPSHOTLIVEPREVIEW_H -#include "llpanelsnapshot.h" +#include "llsnapshotmodel.h" #include "llviewertexture.h" #include "llviewerwindow.h" @@ -72,8 +72,8 @@ public: void setMaxImageSize(S32 size) ; S32 getMaxImageSize() {return mMaxImageSize ;} - LLPanelSnapshot::ESnapshotType getSnapshotType() const { return mSnapshotType; } - LLFloaterSnapshotBase::ESnapshotFormat getSnapshotFormat() const { return mSnapshotFormat; } + LLSnapshotModel::ESnapshotType getSnapshotType() const { return mSnapshotType; } + LLSnapshotModel::ESnapshotFormat getSnapshotFormat() const { return mSnapshotFormat; } BOOL getSnapshotUpToDate() const { return mSnapshotUpToDate; } BOOL isSnapshotActive() { return mSnapshotActive; } LLViewerTexture* getThumbnailImage() const { return mThumbnailImage ; } @@ -90,10 +90,10 @@ public: void setImageScaled(BOOL scaled) { mImageScaled[mCurImageIndex] = scaled; } const LLVector3d& getPosTakenGlobal() const { return mPosTakenGlobal; } - void setSnapshotType(LLPanelSnapshot::ESnapshotType type) { mSnapshotType = type; } - void setSnapshotFormat(LLFloaterSnapshotBase::ESnapshotFormat format); + void setSnapshotType(LLSnapshotModel::ESnapshotType type) { mSnapshotType = type; } + void setSnapshotFormat(LLSnapshotModel::ESnapshotFormat format); bool setSnapshotQuality(S32 quality, bool set_by_user = true); - void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; } + void setSnapshotBufferType(LLSnapshotModel::ESnapshotLayerType type) { mSnapshotBufferType = type; } void setAllowRenderUI(BOOL allow) { mAllowRenderUI = allow; } void setAllowFullScreenPreview(BOOL allow) { mAllowFullScreenPreview = allow; } void setFilter(std::string filter_name) { mFilterName = filter_name; } @@ -161,14 +161,14 @@ private: LLVector3d mPosTakenGlobal; S32 mSnapshotQuality; S32 mDataSize; - LLPanelSnapshot::ESnapshotType mSnapshotType; - LLFloaterSnapshotBase::ESnapshotFormat mSnapshotFormat; + LLSnapshotModel::ESnapshotType mSnapshotType; + LLSnapshotModel::ESnapshotFormat mSnapshotFormat; BOOL mSnapshotUpToDate; LLFrameTimer mFallAnimTimer; LLVector3 mCameraPos; LLQuaternion mCameraRot; BOOL mSnapshotActive; - LLViewerWindow::ESnapshotType mSnapshotBufferType; + LLSnapshotModel::ESnapshotLayerType mSnapshotBufferType; std::string mFilterName; public: diff --git a/indra/newview/llsnapshotmodel.h b/indra/newview/llsnapshotmodel.h new file mode 100644 index 0000000000..71402fb5bc --- /dev/null +++ b/indra/newview/llsnapshotmodel.h @@ -0,0 +1,55 @@ +/** +* @file llsnapshotmodel.h +* @brief Snapshot model for storing snapshot data etc. +* +* $LicenseInfo:firstyear=2004&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2016, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_LLSNAPSHOTMODEL_H +#define LL_LLSNAPSHOTMODEL_H + +class LLSnapshotModel +{ +public: + enum ESnapshotType + { + SNAPSHOT_POSTCARD, + SNAPSHOT_TEXTURE, + SNAPSHOT_LOCAL, + SNAPSHOT_WEB + }; + + typedef enum e_snapshot_format + { + SNAPSHOT_FORMAT_PNG, + SNAPSHOT_FORMAT_JPEG, + SNAPSHOT_FORMAT_BMP + } ESnapshotFormat; + + typedef enum + { + SNAPSHOT_TYPE_COLOR, + SNAPSHOT_TYPE_DEPTH + } ESnapshotLayerType; +}; + +#endif // LL_LLSNAPSHOTMODEL_H diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index f0dafec240..f2b8a5ce06 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -779,12 +779,17 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti if (uploadInfo->showUploadDialog()) LLUploadDialog::modalUploadFinished(); - // Let the Snapshot floater know we have finished uploading a snapshot to inventory. + // Let the Snapshot floater know we have finished uploading a snapshot to inventory LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); - if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE && floater_snapshot) + if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE && floater_snapshot && floater_snapshot->isShown()) { floater_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); } + LLFloater* floater_outfit_snapshot = LLFloaterReg::findInstance("outfit_snapshot"); + if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE && floater_outfit_snapshot && floater_outfit_snapshot->isShown()) + { + floater_outfit_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); + } } //========================================================================= diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 0644e1b196..459397a0f7 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -37,6 +37,7 @@ #include "llfloatermap.h" #include "llfloatermodelpreview.h" #include "llfloatersnapshot.h" +#include "llfloateroutfitsnapshot.h" #include "llimage.h" #include "llimagebmp.h" #include "llimagepng.h" @@ -507,9 +508,11 @@ class LLFileEnableCloseAllWindows : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance(); - bool is_floater_snapshot_opened = floater_snapshot && floater_snapshot->isInVisibleChain(); - bool open_children = gFloaterView->allChildrenClosed() && !is_floater_snapshot_opened; + LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::getInstance(); + LLFloaterOutfitSnapshot* floater_outfit_snapshot = LLFloaterOutfitSnapshot::getInstance(); + bool is_floaters_snapshot_opened = floater_snapshot && floater_snapshot->isInVisibleChain() + || floater_outfit_snapshot && floater_outfit_snapshot->isInVisibleChain(); + bool open_children = gFloaterView->allChildrenClosed() && !is_floaters_snapshot_opened; return !open_children; } }; @@ -520,7 +523,12 @@ class LLFileCloseAllWindows : public view_listener_t { bool app_quitting = false; gFloaterView->closeAllChildren(app_quitting); - LLFloaterSnapshot::getInstance()->closeFloater(app_quitting); + LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::getInstance(); + if (floater_snapshot) + floater_snapshot->closeFloater(app_quitting); + LLFloaterOutfitSnapshot* floater_outfit_snapshot = LLFloaterOutfitSnapshot::getInstance(); + if (floater_outfit_snapshot) + floater_outfit_snapshot->closeFloater(app_quitting); if (gMenuHolder) gMenuHolder->hideMenus(); return true; } @@ -551,18 +559,18 @@ class LLFileTakeSnapshotToDisk : public view_listener_t { gViewerWindow->playSnapshotAnimAndSound(); LLPointer formatted; - LLFloaterSnapshotBase::ESnapshotFormat fmt = (LLFloaterSnapshotBase::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); + LLSnapshotModel::ESnapshotFormat fmt = (LLSnapshotModel::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); switch (fmt) { - case LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG: + case LLSnapshotModel::SNAPSHOT_FORMAT_JPEG: formatted = new LLImageJPEG(gSavedSettings.getS32("SnapshotQuality")); break; default: LL_WARNS() << "Unknown local snapshot format: " << fmt << LL_ENDL; - case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG: + case LLSnapshotModel::SNAPSHOT_FORMAT_PNG: formatted = new LLImagePNG; break; - case LLFloaterSnapshot::SNAPSHOT_FORMAT_BMP: + case LLSnapshotModel::SNAPSHOT_FORMAT_BMP: formatted = new LLImageBMP; break; } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index c17c50fd88..cd9ab3e672 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4364,7 +4364,7 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height) } } -BOOL LLViewerWindow::saveSnapshot( const std::string& filepath, S32 image_width, S32 image_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) +BOOL LLViewerWindow::saveSnapshot(const std::string& filepath, S32 image_width, S32 image_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type) { LL_INFOS() << "Saving snapshot to: " << filepath << LL_ENDL; @@ -4403,7 +4403,7 @@ void LLViewerWindow::playSnapshotAnimAndSound() send_sound_trigger(LLUUID(gSavedSettings.getString("UISndSnapshot")), 1.0f); } -BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) +BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type) { return rawSnapshot(raw, preview_width, preview_height, FALSE, FALSE, show_ui, do_rebuild, type); } @@ -4412,7 +4412,7 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p // Since the required size might be bigger than the available screen, this method rerenders the scene in parts (called subimages) and copy // the results over to the final raw image. BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, - BOOL keep_window_aspect, BOOL is_texture, BOOL show_ui, BOOL do_rebuild, ESnapshotType type, S32 max_size) + BOOL keep_window_aspect, BOOL is_texture, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type, S32 max_size) { if (!raw) { @@ -4620,7 +4620,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei LLAppViewer::instance()->pingMainloopTimeout("LLViewerWindow::rawSnapshot"); } - if (type == SNAPSHOT_TYPE_COLOR) + if (type == LLSnapshotModel::SNAPSHOT_TYPE_COLOR) { glReadPixels( subimage_x_offset, out_y + subimage_y_offset, @@ -4629,7 +4629,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei raw->getData() + output_buffer_offset ); } - else // SNAPSHOT_TYPE_DEPTH + else // LLSnapshotModel::SNAPSHOT_TYPE_DEPTH { LLPointer depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values glReadPixels( diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index ad06f00234..cdf5b686a7 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -46,6 +46,7 @@ #include "llhandle.h" #include "llinitparam.h" #include "lltrace.h" +#include "llsnapshotmodel.h" #include #include @@ -342,15 +343,11 @@ public: // snapshot functionality. // perhaps some of this should move to llfloatershapshot? -MG - typedef enum - { - SNAPSHOT_TYPE_COLOR, - SNAPSHOT_TYPE_DEPTH - } ESnapshotType; - BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR); + + BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR); BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE, - BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR, S32 max_size = MAX_SNAPSHOT_IMAGE_SIZE ); - BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) ; + BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR, S32 max_size = MAX_SNAPSHOT_IMAGE_SIZE); + BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type); BOOL isSnapshotLocSet() const { return ! sSnapshotDir.empty(); } void resetSnapshotLoc() const { sSnapshotDir.clear(); } BOOL saveImageNumbered(LLImageFormatted *image, bool force_picker = false); diff --git a/indra/newview/llviewerwindowlistener.cpp b/indra/newview/llviewerwindowlistener.cpp index 1fe5fc9800..97b405c1d0 100644 --- a/indra/newview/llviewerwindowlistener.cpp +++ b/indra/newview/llviewerwindowlistener.cpp @@ -65,9 +65,9 @@ LLViewerWindowListener::LLViewerWindowListener(LLViewerWindow* llviewerwindow): void LLViewerWindowListener::saveSnapshot(const LLSD& event) const { - typedef std::map TypeMap; + typedef std::map TypeMap; TypeMap types; -#define tp(name) types[#name] = LLViewerWindow::SNAPSHOT_TYPE_##name +#define tp(name) types[#name] = LLSnapshotModel::SNAPSHOT_TYPE_##name tp(COLOR); tp(DEPTH); #undef tp @@ -84,7 +84,7 @@ void LLViewerWindowListener::saveSnapshot(const LLSD& event) const if (event.has("showui")) showui = event["showui"].asBoolean(); bool rebuild(event["rebuild"]); // defaults to false - LLViewerWindow::ESnapshotType type(LLViewerWindow::SNAPSHOT_TYPE_COLOR); + LLSnapshotModel::ESnapshotLayerType type(LLSnapshotModel::SNAPSHOT_TYPE_COLOR); if (event.has("type")) { TypeMap::const_iterator found = types.find(event["type"]); -- cgit v1.3 From 2da3148759760abc97fdcb51b1feb6db28c38277 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 3 Jun 2016 17:53:24 +0300 Subject: MAINT-6475 FIXED Inconsistent sort order in "Outfit Gallery" tab --- indra/newview/lloutfitgallery.cpp | 19 ++++++++++++++++++- indra/newview/lloutfitgallery.h | 15 --------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index f6af3d63f6..a4315b9189 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -145,6 +145,23 @@ void LLOutfitGallery::updateRowsIfNeeded() } } +bool compareGalleryItem(LLOutfitGalleryItem* item1, LLOutfitGalleryItem* item2) +{ + if((item1->mIsDefaultImage() && item2->mIsDefaultImage()) || (!item1->mIsDefaultImage() && !item2->mIsDefaultImage())) + { + std::string name1 = item1->getItemName(); + std::string name2 = item2->getItemName(); + + LLStringUtil::toUpper(name1); + LLStringUtil::toUpper(name2); + return name1 < name2; + } + else + { + return item2->mIsDefaultImage(); + } +} + void LLOutfitGallery::reArrangeRows(S32 row_diff) { @@ -161,7 +178,7 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff) mItemsInRow+= row_diff; updateGalleryWidth(); - std::sort(buf_items.begin(), buf_items.end(), LLOutfitGalleryItem::compareGalleryItem()); + std::sort(buf_items.begin(), buf_items.end(), compareGalleryItem); for (std::vector::const_iterator it = buf_items.begin(); it != buf_items.end(); ++it) { diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index ad3f2a7129..385a1e1c7a 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -258,21 +258,6 @@ public: bool isHidden() {return mHidden;} void setHidden(bool hidden) {mHidden = hidden;} - - struct compareGalleryItem - { - bool operator()(LLOutfitGalleryItem* a, LLOutfitGalleryItem* b) - { - if((a->mIsDefaultImage() && b->mIsDefaultImage()) || (!a->mIsDefaultImage() && !b->mIsDefaultImage())) - { - return a->getItemName().compare(b->getItemName()) < 0; - } - else - { - return b->mIsDefaultImage(); - } - } - }; private: LLPointer mTexturep; -- cgit v1.3 From 3cbab4d820963565c23f72e0bb6efd519c97462d Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 6 Jun 2016 16:47:09 +0300 Subject: MAINT-6474 FIXED No easy way to remove an image from a VOB Folder --- indra/newview/lloutfitgallery.cpp | 57 ++++++++++++++++++++-- indra/newview/lloutfitgallery.h | 7 ++- indra/newview/lloutfitslist.cpp | 8 ++- indra/newview/lloutfitslist.h | 1 + .../default/xui/en/menu_gallery_outfit_tab.xml | 11 ++++- .../skins/default/xui/en/menu_outfit_gear.xml | 8 ++- 6 files changed, 85 insertions(+), 7 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index a4315b9189..f414179f9c 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -147,7 +147,7 @@ void LLOutfitGallery::updateRowsIfNeeded() bool compareGalleryItem(LLOutfitGalleryItem* item1, LLOutfitGalleryItem* item2) { - if((item1->mIsDefaultImage() && item2->mIsDefaultImage()) || (!item1->mIsDefaultImage() && !item2->mIsDefaultImage())) + if((item1->isDefaultImage() && item2->isDefaultImage()) || (!item1->isDefaultImage() && !item2->isDefaultImage())) { std::string name1 = item1->getItemName(); std::string name2 = item2->getItemName(); @@ -158,7 +158,7 @@ bool compareGalleryItem(LLOutfitGalleryItem* item1, LLOutfitGalleryItem* item2) } else { - return item2->mIsDefaultImage(); + return item2->isDefaultImage(); } } @@ -577,6 +577,15 @@ bool LLOutfitGallery::canWearSelected() return false; } +bool LLOutfitGallery::hasDefaultImage(const LLUUID& outfit_cat_id) +{ + if (mOutfitMap[outfit_cat_id]) + { + return mOutfitMap[outfit_cat_id]->isDefaultImage(); + } + return false; +} + void LLOutfitGallery::updateMessageVisibility() { if(mItems.empty()) @@ -731,7 +740,7 @@ LLContextMenu* LLOutfitGalleryContextMenu::createMenu() registrar.add("Outfit.UploadPhoto", boost::bind(&LLOutfitGalleryContextMenu::onUploadPhoto, this, selected_id)); registrar.add("Outfit.SelectPhoto", boost::bind(&LLOutfitGalleryContextMenu::onSelectPhoto, this, selected_id)); registrar.add("Outfit.TakeSnapshot", boost::bind(&LLOutfitGalleryContextMenu::onTakeSnapshot, this, selected_id)); - + registrar.add("Outfit.RemovePhoto", boost::bind(&LLOutfitGalleryContextMenu::onRemovePhoto, 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)); @@ -756,6 +765,16 @@ void LLOutfitGalleryContextMenu::onSelectPhoto(const LLUUID& outfit_cat_id) } } +void LLOutfitGalleryContextMenu::onRemovePhoto(const LLUUID& outfit_cat_id) +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + if (gallery && outfit_cat_id.notNull()) + { + gallery->checkRemovePhoto(outfit_cat_id); + gallery->refreshOutfit(outfit_cat_id); + } +} + void LLOutfitGalleryContextMenu::onTakeSnapshot(const LLUUID& outfit_cat_id) { LLOutfitGallery* gallery = dynamic_cast(mOutfitList); @@ -800,6 +819,15 @@ bool LLOutfitGalleryContextMenu::onEnable(LLSD::String param) bool LLOutfitGalleryContextMenu::onVisible(LLSD::String param) { + if ("remove_photo" == param) + { + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + LLUUID selected_id = mUUIDs.front(); + if (gallery && selected_id.notNull()) + { + return !gallery->hasDefaultImage(selected_id); + } + } return LLOutfitContextMenu::onVisible(param); } @@ -817,6 +845,7 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() mMenu->setItemVisible("upload_photo", have_selection); mMenu->setItemVisible("select_photo", have_selection); mMenu->setItemVisible("take_snapshot", have_selection); + mMenu->setItemVisible("remove_photo", !hasDefaultImage()); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } @@ -840,6 +869,17 @@ void LLOutfitGalleryGearMenu::onSelectPhoto() } } +void LLOutfitGalleryGearMenu::onRemovePhoto() +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + LLUUID selected_outfit_id = getSelectedOutfitID(); + if (gallery && !selected_outfit_id.isNull()) + { + gallery->checkRemovePhoto(selected_outfit_id); + gallery->refreshOutfit(selected_outfit_id); + } +} + void LLOutfitGalleryGearMenu::onTakeSnapshot() { LLOutfitGallery* gallery = dynamic_cast(mOutfitList); @@ -850,6 +890,17 @@ void LLOutfitGalleryGearMenu::onTakeSnapshot() } } +bool LLOutfitGalleryGearMenu::hasDefaultImage() +{ + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + LLUUID selected_outfit_id = getSelectedOutfitID(); + if (gallery && selected_outfit_id.notNull()) + { + return gallery->hasDefaultImage(selected_outfit_id); + } + return true; +} + void LLOutfitGallery::onTextureSelectionChanged(LLInventoryItem* itemp) { } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 385a1e1c7a..19bfc10586 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -105,6 +105,7 @@ public: /*virtual*/ bool getHasExpandableFolders() { return FALSE; } void updateMessageVisibility(); + bool hasDefaultImage(const LLUUID& outfit_cat_id); void refreshTextures(const LLUUID& category_id); void refreshOutfit(const LLUUID& category_id); @@ -209,6 +210,7 @@ protected: bool onVisible(LLSD::String param); void onUploadPhoto(const LLUUID& outfit_cat_id); void onSelectPhoto(const LLUUID& outfit_cat_id); + void onRemovePhoto(const LLUUID& outfit_cat_id); void onTakeSnapshot(const LLUUID& outfit_cat_id); void onCreate(const LLSD& data); void onRemoveOutfit(const LLUUID& outfit_cat_id); @@ -230,6 +232,9 @@ private: /*virtual*/ void onUploadFoto(); /*virtual*/ void onSelectPhoto(); /*virtual*/ void onTakeSnapshot(); + /*virtual*/ void onRemovePhoto(); + + bool hasDefaultImage(); }; class LLOutfitGalleryItem : public LLPanel @@ -254,7 +259,7 @@ public: void setSelected(bool value); std::string getItemName() {return mOutfitName;} - bool mIsDefaultImage() {return mDefaultImage;} + bool isDefaultImage() {return mDefaultImage;} bool isHidden() {return mHidden;} void setHidden(bool hidden) {mHidden = hidden;} diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 31fe6839f3..2e6599090a 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -1093,6 +1093,7 @@ LLOutfitListGearMenuBase::LLOutfitListGearMenuBase(LLOutfitListBase* olist) registrar.add("Gear.UploadPhoto", boost::bind(&LLOutfitListGearMenuBase::onUploadFoto, this)); registrar.add("Gear.SelectPhoto", boost::bind(&LLOutfitListGearMenuBase::onSelectPhoto, this)); registrar.add("Gear.TakeSnapshot", boost::bind(&LLOutfitListGearMenuBase::onTakeSnapshot, this)); + registrar.add("Gear.RemovePhoto", boost::bind(&LLOutfitListGearMenuBase::onRemovePhoto, this)); enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenuBase::onEnable, this, _2)); enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenuBase::onVisible, this, _2)); @@ -1241,6 +1242,10 @@ void LLOutfitListGearMenuBase::onTakeSnapshot() } +void LLOutfitListGearMenuBase::onRemovePhoto() +{ + +} LLOutfitListGearMenu::LLOutfitListGearMenu(LLOutfitListBase* olist) : LLOutfitListGearMenuBase(olist) {} @@ -1255,7 +1260,8 @@ void LLOutfitListGearMenu::onUpdateItemsVisibility() mMenu->setItemVisible("collapse", TRUE); mMenu->setItemVisible("upload_photo", FALSE); mMenu->setItemVisible("select_photo", FALSE); - mMenu->setItemVisible("take_snapshot", FALSE); + mMenu->setItemVisible("take_snapshot", FALSE); + mMenu->setItemVisible("remove_photo", FALSE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index 696a18a36a..c4dd2cd075 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -166,6 +166,7 @@ protected: virtual void onUploadFoto(); virtual void onSelectPhoto(); virtual void onTakeSnapshot(); + virtual void onRemovePhoto(); const LLUUID& getSelectedOutfitID(); 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 b9e29788dc..1b08767edc 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 @@ -62,7 +62,16 @@ - + + + + - + + + -- cgit v1.3 From 29078e7696c0cdee21e336ddb701f6c7966a33e0 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 8 Jun 2016 16:08:36 +0300 Subject: MAINT-6473 Request for Drag & Drop functionality for adding images to Outfit Folders --- indra/newview/llappearancemgr.cpp | 21 +++++++++++++++++++++ indra/newview/llappearancemgr.h | 1 + indra/newview/llinventorybridge.cpp | 27 +++++++++++++++++++++------ indra/newview/lloutfitgallery.cpp | 17 +---------------- 4 files changed, 44 insertions(+), 22 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index cc676550ab..e7e85467cd 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include +#include #include "llaccordionctrltab.h" #include "llagent.h" #include "llagentcamera.h" @@ -1515,6 +1516,26 @@ void LLAppearanceMgr::replaceCurrentOutfit(const LLUUID& new_outfit) wearInventoryCategory(cat, false, false); } +// Remove existing photo link from outfit folder. +void LLAppearanceMgr::removeOutfitPhoto(const LLUUID& outfit_id) +{ + LLInventoryModel::cat_array_t sub_cat_array; + LLInventoryModel::item_array_t outfit_item_array; + gInventory.collectDescendents( + outfit_id, + sub_cat_array, + outfit_item_array, + LLInventoryModel::EXCLUDE_TRASH); + BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) + { + LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); + if (linked_item != NULL && linked_item->getActualType() == LLAssetType::AT_TEXTURE) + { + gInventory.removeItem(outfit_item->getUUID()); + } + } +} + // Open outfit renaming dialog. void LLAppearanceMgr::renameOutfit(const LLUUID& outfit_id) { diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index bf181cb4ad..3646f245c1 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -61,6 +61,7 @@ public: void changeOutfit(bool proceed, const LLUUID& category, bool append); void replaceCurrentOutfit(const LLUUID& new_outfit); void renameOutfit(const LLUUID& outfit_id); + void removeOutfitPhoto(const LLUUID& outfit_id); void takeOffOutfit(const LLUUID& cat_id); void addCategoryToCurrentOutfit(const LLUUID& cat_id); S32 findExcessOrDuplicateItems(const LLUUID& cat_id, diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 86cc6dfae1..9f0b35fc8c 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4358,12 +4358,14 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response // Returns true if the item can be moved to Current Outfit or any outfit folder. static BOOL can_move_to_outfit(LLInventoryItem* inv_item, BOOL move_is_into_current_outfit) { - if ((inv_item->getInventoryType() != LLInventoryType::IT_WEARABLE) && - (inv_item->getInventoryType() != LLInventoryType::IT_GESTURE) && - (inv_item->getInventoryType() != LLInventoryType::IT_ATTACHMENT) && - (inv_item->getInventoryType() != LLInventoryType::IT_OBJECT) && - (inv_item->getInventoryType() != LLInventoryType::IT_TEXTURE)) - { + LLInventoryType::EType inv_type = inv_item->getInventoryType(); + if ((inv_type != LLInventoryType::IT_WEARABLE) && + (inv_type != LLInventoryType::IT_GESTURE) && + (inv_type != LLInventoryType::IT_ATTACHMENT) && + (inv_type != LLInventoryType::IT_OBJECT) && + (inv_type != LLInventoryType::IT_SNAPSHOT) && + (inv_type != LLInventoryType::IT_TEXTURE)) + { return FALSE; } @@ -4373,6 +4375,11 @@ static BOOL can_move_to_outfit(LLInventoryItem* inv_item, BOOL move_is_into_curr return FALSE; } + if((inv_type == LLInventoryType::IT_TEXTURE) || (inv_type == LLInventoryType::IT_SNAPSHOT)) + { + return TRUE; + } + if (move_is_into_current_outfit && get_is_item_worn(inv_item->getUUID())) { return FALSE; @@ -4423,6 +4430,14 @@ void LLFolderBridge::dropToFavorites(LLInventoryItem* inv_item) void LLFolderBridge::dropToOutfit(LLInventoryItem* inv_item, BOOL move_is_into_current_outfit) { + if((inv_item->getInventoryType() == LLInventoryType::IT_TEXTURE) || (inv_item->getInventoryType() == LLInventoryType::IT_SNAPSHOT)) + { + LLAppearanceMgr::instance().removeOutfitPhoto(mUUID); + LLPointer cb = NULL; + link_inventory_object(mUUID, LLConstPointer(inv_item), cb); + return; + } + // BAP - should skip if dup. if (move_is_into_current_outfit) { diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index f414179f9c..dcc4d70a2c 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -1073,22 +1073,7 @@ void LLOutfitGallery::linkPhotoToOutfit(LLUUID photo_id, LLUUID outfit_id) bool LLOutfitGallery::checkRemovePhoto(LLUUID outfit_id) { - //remove existing photo link from outfit folder - LLInventoryModel::cat_array_t sub_cat_array; - LLInventoryModel::item_array_t outfit_item_array; - gInventory.collectDescendents( - outfit_id, - sub_cat_array, - outfit_item_array, - LLInventoryModel::EXCLUDE_TRASH); - BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) - { - LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); - if (linked_item != NULL && linked_item->getActualType() == LLAssetType::AT_TEXTURE) - { - gInventory.removeItem(outfit_item->getUUID()); - } - } + LLAppearanceMgr::instance().removeOutfitPhoto(outfit_id); return true; } -- cgit v1.3 From 9adf2dbeb7e7dcc1d3b4188899b58c089f4d99c8 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 9 Jun 2016 17:40:38 +0300 Subject: MAINT-6472 Show outfit tooltips in Outfit Gallery. Increase space between image and outfit name. --- indra/newview/lloutfitgallery.cpp | 1 + indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index dcc4d70a2c..224f2b7f49 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -666,6 +666,7 @@ void LLOutfitGalleryItem::draw() void LLOutfitGalleryItem::setOutfitName(std::string name) { mOutfitNameText->setText(name); + mOutfitNameText->setToolTip(name); mOutfitName = name; } diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml index 77c546c6e7..e3f0f1128b 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery_item.xml @@ -49,7 +49,7 @@ height="10" layout="topleft" name="outfit_name" - top="0" + top="2" width="150" use_ellipses="true"> Summer hipster, Pierce Pierce Pierce Pierce @@ -62,7 +62,7 @@ height="10" layout="topleft" name="outfit_worn_text" - top="10" + top="12" width="150"> (worn) -- cgit v1.3 From 554db00bdf20692f58c3eb42b83731011e9ad119 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 10 Jun 2016 18:04:16 +0300 Subject: MAINT-6475 Add menu item for changing sort priority --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/lloutfitgallery.cpp | 17 ++++++++++++++++- indra/newview/lloutfitgallery.h | 1 + indra/newview/lloutfitslist.cpp | 9 +++++++++ indra/newview/lloutfitslist.h | 1 + indra/newview/skins/default/xui/en/menu_outfit_gear.xml | 11 +++++++++++ 6 files changed, 49 insertions(+), 1 deletion(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index a8d42be2a1..57a71ce93d 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14592,6 +14592,17 @@ Value 1 + OutfitGallerySortByName + + Comment + Always sort outfits by name in Outfit Gallery + Persist + 1 + Type + Boolean + Value + 0 + OutfitOperationsTimeout Comment diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 224f2b7f49..055d4dbe9f 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -46,6 +46,7 @@ #include "lllocalbitmaps.h" #include "llnotificationsutil.h" #include "lltexturectrl.h" +#include "llviewercontrol.h" #include "llviewermenufile.h" #include "llwearableitemslist.h" @@ -147,7 +148,8 @@ void LLOutfitGallery::updateRowsIfNeeded() bool compareGalleryItem(LLOutfitGalleryItem* item1, LLOutfitGalleryItem* item2) { - if((item1->isDefaultImage() && item2->isDefaultImage()) || (!item1->isDefaultImage() && !item2->isDefaultImage())) + if(gSavedSettings.getBOOL("OutfitGallerySortByName") || + ((item1->isDefaultImage() && item2->isDefaultImage()) || (!item1->isDefaultImage() && !item2->isDefaultImage()))) { std::string name1 = item1->getItemName(); std::string name2 = item2->getItemName(); @@ -847,6 +849,8 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() mMenu->setItemVisible("select_photo", have_selection); mMenu->setItemVisible("take_snapshot", have_selection); mMenu->setItemVisible("remove_photo", !hasDefaultImage()); + mMenu->setItemVisible("sepatator3", TRUE); + mMenu->setItemVisible("sort_folders_by_name", TRUE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } @@ -891,6 +895,17 @@ void LLOutfitGalleryGearMenu::onTakeSnapshot() } } +void LLOutfitGalleryGearMenu::onChangeSortOrder() +{ + bool sort_by_name = !gSavedSettings.getBOOL("OutfitGallerySortByName"); + gSavedSettings.setBOOL("OutfitGallerySortByName", sort_by_name); + LLOutfitGallery* gallery = dynamic_cast(mOutfitList); + if (gallery) + { + gallery->reArrangeRows(); + } +} + bool LLOutfitGalleryGearMenu::hasDefaultImage() { LLOutfitGallery* gallery = dynamic_cast(mOutfitList); diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 19bfc10586..f5954d9cc2 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -233,6 +233,7 @@ private: /*virtual*/ void onSelectPhoto(); /*virtual*/ void onTakeSnapshot(); /*virtual*/ void onRemovePhoto(); + /*virtual*/ void onChangeSortOrder(); bool hasDefaultImage(); }; diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 2e6599090a..87c3c5042b 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -1094,6 +1094,7 @@ LLOutfitListGearMenuBase::LLOutfitListGearMenuBase(LLOutfitListBase* olist) registrar.add("Gear.SelectPhoto", boost::bind(&LLOutfitListGearMenuBase::onSelectPhoto, this)); registrar.add("Gear.TakeSnapshot", boost::bind(&LLOutfitListGearMenuBase::onTakeSnapshot, this)); registrar.add("Gear.RemovePhoto", boost::bind(&LLOutfitListGearMenuBase::onRemovePhoto, this)); + registrar.add("Gear.SortByName", boost::bind(&LLOutfitListGearMenuBase::onChangeSortOrder, this)); enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenuBase::onEnable, this, _2)); enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenuBase::onVisible, this, _2)); @@ -1246,6 +1247,12 @@ void LLOutfitListGearMenuBase::onRemovePhoto() { } + +void LLOutfitListGearMenuBase::onChangeSortOrder() +{ + +} + LLOutfitListGearMenu::LLOutfitListGearMenu(LLOutfitListBase* olist) : LLOutfitListGearMenuBase(olist) {} @@ -1262,6 +1269,8 @@ void LLOutfitListGearMenu::onUpdateItemsVisibility() mMenu->setItemVisible("select_photo", FALSE); mMenu->setItemVisible("take_snapshot", FALSE); mMenu->setItemVisible("remove_photo", FALSE); + mMenu->setItemVisible("sepatator3", FALSE); + mMenu->setItemVisible("sort_folders_by_name", FALSE); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index c4dd2cd075..81be8de94f 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -167,6 +167,7 @@ protected: virtual void onSelectPhoto(); virtual void onTakeSnapshot(); virtual void onRemovePhoto(); + virtual void onChangeSortOrder(); const LLUUID& getSelectedOutfitID(); 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 6b8a784560..7faa4f3d71 100644 --- a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml @@ -261,4 +261,15 @@ function="Gear.OnVisible" parameter="delete" /> + + + + + -- cgit v1.3 From 510957673399be1a4d603bc7e5491fe27c765d8a Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Thu, 7 Jul 2016 20:19:29 +0300 Subject: MAINT-6476 FIXED VOB - User can add any size image to an Outfit Gallery outfit folders Eliminated overuse of texture memory --- indra/newview/lloutfitgallery.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 055d4dbe9f..fc736056b9 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -48,6 +48,7 @@ #include "lltexturectrl.h" #include "llviewercontrol.h" #include "llviewermenufile.h" +#include "llviewertexturelist.h" #include "llwearableitemslist.h" static LLPanelInjector t_outfit_gallery("outfit_gallery"); @@ -705,8 +706,7 @@ BOOL LLOutfitGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) { mImageAssetId = image_asset_id; - mTexturep = LLViewerTextureManager::getFetchedTexture(image_asset_id); - mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); + mTexturep = LLViewerTextureManager::getFetchedTexture(image_asset_id, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); getChildView("preview_outfit")->setVisible(FALSE); mDefaultImage = false; } -- cgit v1.3 From 9c7b7d13c7e9c0c2376c90d94a60962608fe979d Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Mon, 18 Jul 2016 19:54:00 +0300 Subject: MAINT-6476 VOB - User can add any size image to an Outfit Gallery outfit folders Added restriction of image size that can be added to outfit --- indra/newview/lloutfitgallery.cpp | 32 ++++++++++++++++++++++ .../newview/skins/default/xui/en/notifications.xml | 12 ++++++++ 2 files changed, 44 insertions(+) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index fc736056b9..a65ab26c52 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -41,11 +41,13 @@ #include "llfloaterperms.h" #include "llfloaterreg.h" #include "llfloateroutfitsnapshot.h" +#include "llimagedimensionsinfo.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" #include "lllocalbitmaps.h" #include "llnotificationsutil.h" #include "lltexturectrl.h" +#include "lltrans.h" #include "llviewercontrol.h" #include "llviewermenufile.h" #include "llviewertexturelist.h" @@ -1057,6 +1059,36 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) LLLocalBitmap* unit = new LLLocalBitmap(filename); if (unit->getValid()) { + std::string exten = gDirUtilp->getExtension(filename); + U32 codec = LLImageBase::getCodecFromExtension(exten); + + LLImageDimensionsInfo image_info; + std::string image_load_error; + if (!image_info.load(filename, codec)) + { + image_load_error = image_info.getLastError(); + } + + S32 max_width = gSavedSettings.getS32("max_texture_dimension_X"); + S32 max_height = gSavedSettings.getS32("max_texture_dimension_Y"); + + if ((image_info.getWidth() > max_width) || (image_info.getHeight() > max_height)) + { + LLStringUtil::format_map_t args; + args["WIDTH"] = llformat("%d", max_width); + args["HEIGHT"] = llformat("%d", max_height); + + image_load_error = LLTrans::getString("texture_load_dimensions_error", args); + } + + if (!image_load_error.empty()) + { + LLSD subst; + subst["REASON"] = image_load_error; + LLNotificationsUtil::add("ImageLoadError", subst); + return; + } + S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass). void *nruserdata = NULL; nruserdata = (void *)&outfit_id; diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 492d963653..f96b8636f5 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -11016,4 +11016,16 @@ Cannot create large prims that intersect other players. Please re-try when othe yestext="OK"/> + + + [REASON] + fail + + + -- cgit v1.3 From 7187ec75a7095ab7bf1d49896d2f4f72b7899243 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Tue, 26 Jul 2016 19:18:03 +0300 Subject: MAINT-6476 VOB - User can add any size image to an Outfit Gallery outfit folders Added restriction of image size that can be added to outfit via "Select Photo" --- indra/newview/lloutfitgallery.cpp | 60 +++++++++++++++++++--- indra/newview/lloutfitgallery.h | 4 +- indra/newview/lltexturectrl.cpp | 7 ++- indra/newview/lltexturectrl.h | 3 ++ .../newview/skins/default/xui/en/notifications.xml | 4 +- indra/newview/skins/default/xui/en/strings.xml | 3 ++ 6 files changed, 69 insertions(+), 12 deletions(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index a65ab26c52..a93cbb30f5 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -55,6 +55,9 @@ static LLPanelInjector t_outfit_gallery("outfit_gallery"); +#define MAX_OUTFIT_PHOTO_WIDTH 256 +#define MAX_OUTFIT_PHOTO_HEIGHT 256 + LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) : LLOutfitListBase(), mTexturesObserver(NULL), @@ -74,7 +77,8 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) mItemHorizontalGap(p.item_horizontal_gap), mItemsInRow(p.items_in_row), mRowPanWidthFactor(p.row_panel_width_factor), - mGalleryWidthFactor(p.gallery_width_factor) + mGalleryWidthFactor(p.gallery_width_factor), + mTextureSelected(NULL) { updateGalleryWidth(); } @@ -1069,8 +1073,8 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) image_load_error = image_info.getLastError(); } - S32 max_width = gSavedSettings.getS32("max_texture_dimension_X"); - S32 max_height = gSavedSettings.getS32("max_texture_dimension_Y"); + S32 max_width = MAX_OUTFIT_PHOTO_WIDTH; + S32 max_height = MAX_OUTFIT_PHOTO_HEIGHT; if ((image_info.getWidth() > max_width) || (image_info.getHeight() > max_height)) { @@ -1078,14 +1082,14 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) args["WIDTH"] = llformat("%d", max_width); args["HEIGHT"] = llformat("%d", max_height); - image_load_error = LLTrans::getString("texture_load_dimensions_error", args); + image_load_error = LLTrans::getString("outfit_photo_load_dimensions_error", args); } if (!image_load_error.empty()) { LLSD subst; subst["REASON"] = image_load_error; - LLNotificationsUtil::add("ImageLoadError", subst); + LLNotificationsUtil::add("OutfitPhotoLoadError", subst); return; } @@ -1158,7 +1162,43 @@ void LLOutfitGallery::onTexturePickerCommit(LLTextureCtrl::ETexturePickOp op, LL else { image_item_id = floaterp->findItemID(floaterp->getAssetID(), FALSE); + if (image_item_id.isNull()) + { + LL_WARNS() << "id or image_item_id is NULL!" << LL_ENDL; + return; + } + } + + std::string image_load_error; + S32 max_width = MAX_OUTFIT_PHOTO_WIDTH; + S32 max_height = MAX_OUTFIT_PHOTO_HEIGHT; + if (mTextureSelected.isNull() || + mTextureSelected->getFullWidth() == 0 || + mTextureSelected->getFullHeight() == 0) + { + image_load_error = LLTrans::getString("outfit_photo_verify_dimensions_error"); + LL_WARNS() << "Cannot verify selected texture dimensions" << LL_ENDL; + return; + } + S32 width = mTextureSelected->getFullWidth(); + S32 height = mTextureSelected->getFullHeight(); + if ((width > max_width) || (height > max_height)) + { + LLStringUtil::format_map_t args; + args["WIDTH"] = llformat("%d", max_width); + args["HEIGHT"] = llformat("%d", max_height); + + image_load_error = LLTrans::getString("outfit_photo_select_dimensions_error", args); } + + if (!image_load_error.empty()) + { + LLSD subst; + subst["REASON"] = image_load_error; + LLNotificationsUtil::add("OutfitPhotoLoadError", subst); + return; + } + checkRemovePhoto(getSelectedOutfitUUID()); linkPhotoToOutfit(image_item_id, getSelectedOutfitUUID()); } @@ -1196,15 +1236,14 @@ void LLOutfitGallery::onSelectPhoto(LLUUID selected_outfit_id) NULL); mFloaterHandle = floaterp->getHandle(); + mTextureSelected = NULL; LLFloaterTexturePicker* texture_floaterp = dynamic_cast(floaterp); if (texture_floaterp) { texture_floaterp->setTextureSelectedCallback(boost::bind(&LLOutfitGallery::onTextureSelectionChanged, this, _1)); - } - if (texture_floaterp) - { texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLOutfitGallery::onTexturePickerCommit, this, _1, _2)); + texture_floaterp->setOnUpdateImageStatsCallback(boost::bind(&LLOutfitGallery::onTexturePickerUpdateImageStats, this, _1)); } floaterp->openFloater(); @@ -1241,3 +1280,8 @@ void LLOutfitGallery::onAfterOutfitSnapshotSave() mOutfitLinkPending = selected_outfit_id; } } + +void LLOutfitGallery::onTexturePickerUpdateImageStats(LLPointer texture) +{ + mTextureSelected = texture; +} diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index f5954d9cc2..6b13f264a4 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -111,6 +111,7 @@ public: void refreshOutfit(const LLUUID& category_id); void onTexturePickerCommit(LLTextureCtrl::ETexturePickOp op, LLUUID id); + void onTexturePickerUpdateImageStats(LLPointer texture); void onBeforeOutfitSnapshotSave(); void onAfterOutfitSnapshotSave(); protected: @@ -168,6 +169,7 @@ private: bool mGalleryCreated; int mRowCount; int mItemsAddedCount; + LLPointer mTextureSelected; /* Params */ int mRowPanelHeight; int mVerticalGap; @@ -266,7 +268,7 @@ public: void setHidden(bool hidden) {mHidden = hidden;} private: - LLPointer mTexturep; + LLPointer mTexturep; LLUUID mImageAssetId; LLTextBox* mOutfitNameText; LLTextBox* mOutfitWornText; diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 858486514f..f77e0349b5 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -118,7 +118,8 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mPreviewSettingChanged(false), mOnFloaterCommitCallback(NULL), mOnFloaterCloseCallback(NULL), - mSetImageAssetIDCallback(NULL) + mSetImageAssetIDCallback(NULL), + mOnUpdateImageStatsCallback(NULL) { buildFromFile("floater_texture_ctrl.xml"); mCanApplyImmediately = can_apply_immediately; @@ -195,6 +196,10 @@ void LLFloaterTexturePicker::updateImageStats() { std::string formatted_dims = llformat("%d x %d", mTexturep->getFullWidth(),mTexturep->getFullHeight()); mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims); + if (mOnUpdateImageStatsCallback) + { + mOnUpdateImageStatsCallback(mTexturep); + } } else { diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 3ea052ad57..471a36094c 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -240,6 +240,7 @@ private: typedef boost::function floater_commit_callback; typedef boost::function floater_close_callback; typedef boost::function set_image_asset_id_callback; +typedef boost::function texture)> set_on_update_image_stats_callback; class LLFloaterTexturePicker : public LLFloater { @@ -298,6 +299,7 @@ public: void setOnFloaterCloseCallback(const floater_close_callback& cb) { mOnFloaterCloseCallback = cb; } void setOnFloaterCommitCallback(const floater_commit_callback& cb) { mOnFloaterCommitCallback = cb; } void setSetImageAssetIDCallback(const set_image_asset_id_callback& cb) { mSetImageAssetIDCallback = cb; } + void setOnUpdateImageStatsCallback(const set_on_update_image_stats_callback& cb) { mOnUpdateImageStatsCallback = cb; } const LLUUID& getDefaultImageAssetID() { return mDefaultImageAssetID; } const LLUUID& getBlankImageAssetID() { return mBlankImageAssetID; } @@ -364,6 +366,7 @@ private: floater_close_callback mOnFloaterCloseCallback; floater_commit_callback mOnFloaterCommitCallback; set_image_asset_id_callback mSetImageAssetIDCallback; + set_on_update_image_stats_callback mOnUpdateImageStatsCallback; }; #endif // LL_LLTEXTURECTRL_H diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index f96b8636f5..bb9c767f2b 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -11019,9 +11019,9 @@ Cannot create large prims that intersect other players. Please re-try when othe - [REASON] + [REASON] fail none/none Can't load images larger than [WIDTH]*[HEIGHT] + Max outfit photo size is [WIDTH]*[HEIGHT]. Please resize or use another image + Max outfit photo size is [WIDTH]*[HEIGHT]. Please select another texture + Cannot verify photo dimensions. Please wait until photo size is displayed in picker -- cgit v1.3 From 84677aad4cfb5b892f9037118b0bb6cdbe9d6309 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 1 Aug 2016 15:18:32 +0300 Subject: MAINT-6602 disable ability to select local textures --- indra/newview/lloutfitgallery.cpp | 1 + indra/newview/lltexturectrl.cpp | 5 +++++ indra/newview/lltexturectrl.h | 2 ++ 3 files changed, 8 insertions(+) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index a93cbb30f5..65fd3f95ab 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -1244,6 +1244,7 @@ void LLOutfitGallery::onSelectPhoto(LLUUID selected_outfit_id) texture_floaterp->setTextureSelectedCallback(boost::bind(&LLOutfitGallery::onTextureSelectionChanged, this, _1)); texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLOutfitGallery::onTexturePickerCommit, this, _1, _2)); texture_floaterp->setOnUpdateImageStatsCallback(boost::bind(&LLOutfitGallery::onTexturePickerUpdateImageStats, this, _1)); + texture_floaterp->setLocalTextureEnabled(FALSE); } floaterp->openFloater(); diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index a93f8da3f0..fd13f60606 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -941,6 +941,11 @@ void LLFloaterTexturePicker::onFilterEdit(const std::string& search_string ) mInventoryPanel->setFilterSubString(search_string); } +void LLFloaterTexturePicker::setLocalTextureEnabled(BOOL enabled) +{ + mModeSelector->setIndexEnabled(1,enabled); +} + void LLFloaterTexturePicker::onTextureSelect( const LLTextureEntry& te ) { LLUUID inventory_item_id = findItemID(te.getID(), TRUE); diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 471a36094c..61f99de5c0 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -322,6 +322,8 @@ public: static void onBtnUpload(void* userdata); static void onLocalScrollCommit(LLUICtrl* ctrl, void* userdata); + void setLocalTextureEnabled(BOOL enabled); + protected: LLPointer mTexturep; LLView* mOwner; -- cgit v1.3 From 3c8cc4d2ac4dbcbae6bc56ccb222a043d6616341 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 14 Sep 2016 18:27:54 +0300 Subject: MAINT-6723 FIXED [VOB] Crash in LLOutfitGallery::buildItemPanel(int) --- indra/newview/lloutfitgallery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lloutfitgallery.cpp') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 65fd3f95ab..de6a36ce2f 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -999,7 +999,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } } - if (mGalleryCreated) + if (mGalleryCreated && !LLApp::isQuitting()) { reArrangeRows(); } -- cgit v1.3