From dc8365ff00c5ae33f31d779efa23f7872ec368a7 Mon Sep 17 00:00:00 2001 From: "Eric M. Tulla (BigPapi)" Date: Wed, 9 Dec 2009 16:27:39 -0500 Subject: Fix for EXT-2703 & EXT-2708 - save texture as issues Added save as to texture preview floater. Fixed behavior of save as (was only working for textures, not snapshots). Removed advanced menu entry for save texture as (refused to work after multiple implementations). --- indra/newview/llpanelmaininventory.cpp | 46 +++++++++++++--------- indra/newview/llpanelmaininventory.h | 2 + indra/newview/llpreviewtexture.cpp | 9 +++++ indra/newview/llpreviewtexture.h | 3 +- indra/newview/llviewermenufile.cpp | 26 +----------- .../default/xui/en/floater_preview_texture.xml | 9 +++++ indra/newview/skins/default/xui/en/menu_viewer.xml | 9 ----- 7 files changed, 52 insertions(+), 52 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 74c1420cf3..4cebe68152 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -863,7 +863,6 @@ void LLPanelMainInventory::initListCommandsHandlers() mEnableCallbackRegistrar.add("Inventory.GearDefault.Enable", boost::bind(&LLPanelMainInventory::isActionEnabled, this, _2)); mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile("menu_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); mMenuAdd = LLUICtrlFactory::getInstance()->createFromFile("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - } void LLPanelMainInventory::updateListCommands() @@ -909,6 +908,22 @@ void LLPanelMainInventory::onClipboardAction(const LLSD& userdata) getActivePanel()->getRootFolder()->doToSelected(getActivePanel()->getModel(),command_name); } +void LLPanelMainInventory::saveTexture(const LLSD& userdata) +{ + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) + { + return; + } + + const LLUUID& item_id = current_item->getListener()->getUUID(); + LLPreviewTexture* preview_texture = LLFloaterReg::showTypedInstance("preview_texture", LLSD(item_id), TAKE_FOCUS_YES); + if (preview_texture) + { + preview_texture->openToSave(); + } +} + void LLPanelMainInventory::onCustomAction(const LLSD& userdata) { if (!isActionEnabled(userdata)) @@ -953,19 +968,19 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) } if (command_name == "save_texture") { - LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); - if (!current_item) - { - return; - } + saveTexture(userdata); + } +} - const LLUUID& item_id = current_item->getListener()->getUUID(); - LLPreviewTexture* preview_texture = LLFloaterReg::showTypedInstance("preview_texture", LLSD(item_id), TAKE_FOCUS_YES); - if (preview_texture) - { - preview_texture->openToSave(); - } +bool LLPanelMainInventory::isSaveTextureEnabled(const LLSD& userdata) +{ + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (current_item) + { + LLInventoryType::EType curr_type = current_item->getListener()->getInventoryType(); + return (curr_type == LLInventoryType::IT_TEXTURE || curr_type == LLInventoryType::IT_SNAPSHOT); } + return false; } BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) @@ -994,12 +1009,7 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) } if (command_name == "save_texture") { - LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); - if (current_item) - { - return (current_item->getListener()->getInventoryType() == LLInventoryType::IT_TEXTURE); - } - return FALSE; + return isSaveTextureEnabled(userdata); } return TRUE; } diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index ae78d3bec8..92443df369 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -110,6 +110,8 @@ protected: void doCreate(const LLSD& userdata); void resetFilters(); void setSortBy(const LLSD& userdata); + void saveTexture(const LLSD& userdata); + bool isSaveTextureEnabled(const LLSD& userdata); private: LLFloaterInventoryFinder* getFinder(); diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 698f6152b4..8fa147f201 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -145,6 +145,8 @@ BOOL LLPreviewTexture::postBuild() childSetVisible("Discard", false); } + childSetAction("save_tex_btn", LLPreviewTexture::onSaveAsBtn, this); + if (!mCopyToInv) { const LLInventoryItem* item = getItem(); @@ -164,6 +166,13 @@ BOOL LLPreviewTexture::postBuild() return LLPreview::postBuild(); } +// static +void LLPreviewTexture::onSaveAsBtn(void* data) +{ + LLPreviewTexture* self = (LLPreviewTexture*)data; + self->saveAs(); +} + void LLPreviewTexture::draw() { if (mUpdateDimensions) diff --git a/indra/newview/llpreviewtexture.h b/indra/newview/llpreviewtexture.h index 9b3c91d831..980aecee6d 100644 --- a/indra/newview/llpreviewtexture.h +++ b/indra/newview/llpreviewtexture.h @@ -58,7 +58,6 @@ public: virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); virtual void onFocusReceived(); - static void saveToFile(void* userdata); static void onFileLoadedForSave( BOOL success, LLViewerFetchedTexture *src_vi, @@ -68,6 +67,8 @@ public: BOOL final, void* userdata ); void openToSave(); + + static void onSaveAsBtn(void* data); protected: void init(); /* virtual */ BOOL postBuild(); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 4b0dc8f668..a1c3806b27 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -71,15 +71,6 @@ // system libraries #include -class LLFileEnableSaveAs : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - bool new_value = gFloaterView->getFrontmost() && gFloaterView->getFrontmost()->canSaveAs(); - return new_value; - } -}; - class LLFileEnableUpload : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -386,19 +377,6 @@ class LLFileCloseAllWindows : public view_listener_t } }; -class LLFileSaveTexture : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - LLFloater* top = gFloaterView->getFrontmost(); - if (top) - { - top->saveAs(); - } - return true; - } -}; - class LLFileTakeSnapshotToDisk : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -1050,10 +1028,10 @@ void init_menu_file() view_listener_t::addCommit(new LLFileCloseAllWindows(), "File.CloseAllWindows"); view_listener_t::addEnable(new LLFileEnableCloseWindow(), "File.EnableCloseWindow"); view_listener_t::addEnable(new LLFileEnableCloseAllWindows(), "File.EnableCloseAllWindows"); - view_listener_t::addCommit(new LLFileSaveTexture(), "File.SaveTexture"); view_listener_t::addCommit(new LLFileTakeSnapshotToDisk(), "File.TakeSnapshotToDisk"); view_listener_t::addCommit(new LLFileQuit(), "File.Quit"); view_listener_t::addEnable(new LLFileEnableUpload(), "File.EnableUpload"); - view_listener_t::addEnable(new LLFileEnableSaveAs(), "File.EnableSaveAs"); + + // "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled. } diff --git a/indra/newview/skins/default/xui/en/floater_preview_texture.xml b/indra/newview/skins/default/xui/en/floater_preview_texture.xml index 52a19ac6b3..054f3be70a 100644 --- a/indra/newview/skins/default/xui/en/floater_preview_texture.xml +++ b/indra/newview/skins/default/xui/en/floater_preview_texture.xml @@ -60,6 +60,15 @@ left_pad="5" name="Discard" top_delta="0" + width="100" /> +