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/llfloateroutfitsnapshot.cpp | 1586 +++++++++++++++++++++++++++++ 1 file changed, 1586 insertions(+) create mode 100644 indra/newview/llfloateroutfitsnapshot.cpp (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') 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; +} -- cgit v1.2.3 From 8b3f4ec5f58c1488ac7b3403a1a510a4977cebf6 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Thu, 5 May 2016 19:43:02 +0300 Subject: MAINT-6226 Incorporate a customized Snapshot feature to Outfit Browser flow Removed odd controls like custom resolution spinners etc --- indra/newview/llfloateroutfitsnapshot.cpp | 382 ++---------------------------- 1 file changed, 15 insertions(+), 367 deletions(-) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index 8fa54e7f94..cea0e48aa6 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -105,20 +105,13 @@ public: 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); @@ -130,9 +123,7 @@ public: 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); @@ -165,79 +156,15 @@ LLPanelSnapshot* LLFloaterOutfitSnapshot::Impl::getActivePanel(LLFloaterOutfitSn // 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; + return LLPanelSnapshot::SNAPSHOT_TEXTURE; } // 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) { @@ -248,14 +175,7 @@ LLSnapshotLivePreview* LLFloaterOutfitSnapshot::Impl::getPreviewView(LLFloaterOu // 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; + return LLViewerWindow::SNAPSHOT_TYPE_COLOR; } // static @@ -375,67 +295,9 @@ void LLFloaterOutfitSnapshot::Impl::updateControls(LLFloaterOutfitSnapshot* floa { 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); - } - } + LLViewerWindow::ESnapshotType layer_type = getLayerType(floater); 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 @@ -458,36 +320,9 @@ void LLFloaterOutfitSnapshot::Impl::updateControls(LLFloaterOutfitSnapshot* floa } 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")); + floater->getChild("file_size_label")->setColor(LLUIColorTable::instance().getColor( "LabelTextColor" )); + + setResolution(floater, "texture_size_combo"); if (previewp) { @@ -641,32 +476,6 @@ void LLFloaterOutfitSnapshot::Impl::onClickHUDCheck(LLUICtrl *ctrl, void* data) // 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 @@ -691,44 +500,6 @@ void LLFloaterOutfitSnapshot::Impl::onCommitFreezeFrame(LLUICtrl* ctrl, void* da 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) @@ -807,78 +578,22 @@ void LLFloaterOutfitSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, 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(width > 0 && height > 0); - 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 + // 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(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); + //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); + previewp->updateSnapshot(TRUE); if(do_update) { LL_DEBUGS() << "Will update controls" << LL_ENDL; @@ -928,15 +643,6 @@ void LLFloaterOutfitSnapshot::Impl::onImageFormatChange(LLFloaterOutfitSnapshot* } } -// 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) @@ -983,58 +689,6 @@ BOOL LLFloaterOutfitSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previe 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) { @@ -1096,12 +750,6 @@ BOOL LLFloaterOutfitSnapshot::postBuild() 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); @@ -1261,7 +909,7 @@ S32 LLFloaterOutfitSnapshot::notify(const LLSD& info) impl.updateResolution(getChild(combo_name), this); return 1; } - + /* if (info.has("custom-res-change")) { LLSD res = info["custom-res-change"]; @@ -1274,7 +922,7 @@ S32 LLFloaterOutfitSnapshot::notify(const LLSD& info) impl.applyKeepAspectCheck(this, info["keep-aspect-change"].asBoolean()); return 1; } - + */ if (info.has("image-quality-change")) { impl.onImageQualityChange(this, info["image-quality-change"].asInteger()); -- cgit v1.2.3 From cec81209b7c3163135cca138cca920b364ae82df Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Fri, 6 May 2016 11:09:46 +0300 Subject: mac build fix --- indra/newview/llfloateroutfitsnapshot.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index cea0e48aa6..66bb4df4ba 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -57,9 +57,6 @@ 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"); -- cgit v1.2.3 From 6d4d58738c8f1703d4e821308f749a3ae577268c Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 13 May 2016 18:17:29 +0300 Subject: MAINT-6395 Visual outfit browser snapshot window needs image size fixes --- indra/newview/llfloateroutfitsnapshot.cpp | 191 ++---------------------------- 1 file changed, 12 insertions(+), 179 deletions(-) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index 66bb4df4ba..6d641613ff 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -57,6 +57,9 @@ LLOutfitSnapshotFloaterView* gOutfitSnapshotFloaterView = NULL; const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; +const S32 OUTFIT_SNAPSHOT_WIDTH = 256; +const S32 OUTFIT_SNAPSHOT_HEIGHT = 256; + static LLDefaultChildRegistry::Register r("snapshot_outfit_floater_view"); @@ -96,22 +99,17 @@ public: //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 updateResolution(void* data); 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 onSnapshotUploadFinished(bool status); static void onSendingPostcardFinished(bool status); - static BOOL checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value); 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 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); @@ -175,14 +173,6 @@ LLViewerWindow::ESnapshotType LLFloaterOutfitSnapshot::Impl::getLayerType(LLFloa return LLViewerWindow::SNAPSHOT_TYPE_COLOR; } -// 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) { @@ -319,7 +309,7 @@ void LLFloaterOutfitSnapshot::Impl::updateControls(LLFloaterOutfitSnapshot* floa floater->getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown")); floater->getChild("file_size_label")->setColor(LLUIColorTable::instance().getColor( "LabelTextColor" )); - setResolution(floater, "texture_size_combo"); + updateResolution(floater); if (previewp) { @@ -470,11 +460,6 @@ void LLFloaterOutfitSnapshot::Impl::onClickHUDCheck(LLUICtrl *ctrl, void* data) } } -// static -void LLFloaterOutfitSnapshot::Impl::applyKeepAspectCheck(LLFloaterOutfitSnapshot* view, BOOL checked) -{ -} - // static void LLFloaterOutfitSnapshot::Impl::onCommitFreezeFrame(LLUICtrl* ctrl, void* data) { @@ -545,27 +530,21 @@ void LLFloaterOutfitSnapshot::Impl::setFinished(LLFloaterOutfitSnapshot* floater // Apply a new resolution selected from the given combobox. // static -void LLFloaterOutfitSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update) +void LLFloaterOutfitSnapshot::Impl::updateResolution(void* data) { - LLComboBox* combobox = (LLComboBox*)ctrl; LLFloaterOutfitSnapshot *view = (LLFloaterOutfitSnapshot *)data; - if (!view || !combobox) + if (!view) { - llassert(view && combobox); + llassert(view); 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]; + S32 width = OUTFIT_SNAPSHOT_WIDTH; + S32 height = OUTFIT_SNAPSHOT_HEIGHT; LLSnapshotLivePreview* previewp = getPreviewView(view); - if (previewp && combobox->getCurrentIndex() >= 0) + if (previewp) { S32 original_width = 0 , original_height = 0 ; previewp->getSize(original_width, original_height) ; @@ -591,11 +570,6 @@ void LLFloaterOutfitSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, checkAutoSnapshot(previewp, FALSE); LL_DEBUGS() << "updating thumbnail" << LL_ENDL; previewp->updateSnapshot(TRUE); - if(do_update) - { - LL_DEBUGS() << "Will update controls" << LL_ENDL; - updateControls(view); - } } } } @@ -618,74 +592,6 @@ void LLFloaterOutfitSnapshot::Impl::onCommitLayerTypes(LLUICtrl* ctrl, void*data } } -// 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); - } -} - -// 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::onSnapshotUploadFinished(bool status) { @@ -784,19 +690,12 @@ BOOL LLFloaterOutfitSnapshot::postBuild() 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->mKeepAspectRatio = FALSE; previewp->setThumbnailPlaceholderRect(getThumbnailPlaceholderRect()); return TRUE; @@ -899,39 +798,6 @@ void LLFloaterOutfitSnapshot::onClose(bool app_quitting) // 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); @@ -1046,27 +912,6 @@ void LLFloaterOutfitSnapshot::saveTexture() 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() { @@ -1140,18 +985,6 @@ const LLVector3d& LLFloaterOutfitSnapshot::getPosTakenGlobal() 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 ///---------------------------------------------------------------------------- -- cgit v1.2.3 From 9f789ddfbad656b0a6e1f59b592795ad22bdd061 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Thu, 2 Jun 2016 20:23:46 +0300 Subject: MAINT-5194 Visual Outfit browser Made refactoring of LLFloaterOutfitSnapshot and LLFloaterSnapshot --- indra/newview/llfloateroutfitsnapshot.cpp | 1051 +++++------------------------ 1 file changed, 176 insertions(+), 875 deletions(-) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') 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; -} -- cgit v1.2.3 From e2e208898be7bcc3d3801bfd537a5d84201a1563 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Fri, 3 Jun 2016 16:06:10 +0300 Subject: mac build fix --- indra/newview/llfloateroutfitsnapshot.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index 4c4e9bcc48..c29c607449 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -53,8 +53,6 @@ ///---------------------------------------------------------------------------- LLOutfitSnapshotFloaterView* gOutfitSnapshotFloaterView = NULL; -const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; - const S32 OUTFIT_SNAPSHOT_WIDTH = 256; const S32 OUTFIT_SNAPSHOT_HEIGHT = 256; -- cgit v1.2.3 From 97d73a7c31da32f1555215efe6a21a3428153341 Mon Sep 17 00:00:00 2001 From: pavelkproductengine Date: Tue, 19 Jul 2016 20:09:46 +0300 Subject: MAINT-6583 FIXED [VOB] Snapshot floater is stuck in "Posting" state. Removed wrong callback set from VOB snapshot floater --- indra/newview/llfloateroutfitsnapshot.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index c29c607449..d671c36a1c 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -256,8 +256,6 @@ BOOL LLFloaterOutfitSnapshot::postBuild() } childSetCommitCallback("filters_combobox", ImplBase::onClickFilter, this); - LLWebProfile::setImageUploadResultCallback(boost::bind(&ImplBase::onSnapshotUploadFinished, this, _1)); - sThumbnailPlaceholder = getChild("thumbnail_placeholder"); // create preview window -- cgit v1.2.3 From cc7dda96e7ab09ee221e741aac9813af815e0aed Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 4 Aug 2016 17:27:48 +0300 Subject: MAINT-6604 FIXED [VOB] Snapshot preview is corrupted --- indra/newview/llfloateroutfitsnapshot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index d671c36a1c..093a2dad64 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -1,5 +1,5 @@ /** - * @file llfloatersnapshot.cpp + * @file llfloateroutfitsnapshot.cpp * @brief Snapshot preview window for saving as an outfit thumbnail in visual outfit gallery * * $LicenseInfo:firstyear=2004&license=viewerlgpl$ @@ -256,7 +256,7 @@ BOOL LLFloaterOutfitSnapshot::postBuild() } childSetCommitCallback("filters_combobox", ImplBase::onClickFilter, this); - sThumbnailPlaceholder = getChild("thumbnail_placeholder"); + mThumbnailPlaceholder = getChild("thumbnail_placeholder"); // create preview window LLRect full_screen_rect = getRootView()->getRect(); -- cgit v1.2.3 From b496e4ff156ab2fb055e741b97ceda5751476e7f Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 10 Aug 2016 16:32:35 +0300 Subject: MAINT-6616 new crash in VOB viewer in snapshot preview --- indra/newview/llfloateroutfitsnapshot.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index 093a2dad64..ca5a2fdad5 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -311,13 +311,20 @@ void LLFloaterOutfitSnapshot::onOpen(const LLSD& key) // static void LLFloaterOutfitSnapshot::update() { - LLFloaterOutfitSnapshot* inst = getInstance(); + LLFloaterOutfitSnapshot* inst = findInstance(); if (inst != NULL) { inst->impl->updateLivePreview(); } } + +// static +LLFloaterOutfitSnapshot* LLFloaterOutfitSnapshot::findInstance() +{ + return LLFloaterReg::findTypedInstance("outfit_snapshot"); +} + // static LLFloaterOutfitSnapshot* LLFloaterOutfitSnapshot::getInstance() { -- cgit v1.2.3 From 81b683f83b759e78d1e0b598e412d86991791d39 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 1 Sep 2016 16:40:41 +0300 Subject: MAINT-6686 FIXED [VOB] Outfit Snapshot floater should be resized independently of general Snapshot floater --- indra/newview/llfloateroutfitsnapshot.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/llfloateroutfitsnapshot.cpp') diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index ca5a2fdad5..d80793f9e4 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -246,6 +246,8 @@ BOOL LLFloaterOutfitSnapshot::postBuild() getChild("auto_snapshot_check")->setValue(gSavedSettings.getBOOL("AutoSnapshot")); childSetCommitCallback("auto_snapshot_check", ImplBase::onClickAutoSnap, this); + getChild("retract_btn")->setCommitCallback(boost::bind(&LLFloaterOutfitSnapshot::onExtendFloater, this)); + getChild("extend_btn")->setCommitCallback(boost::bind(&LLFloaterOutfitSnapshot::onExtendFloater, this)); // Filters LLComboBox* filterbox = getChild("filters_combobox"); @@ -277,6 +279,7 @@ BOOL LLFloaterOutfitSnapshot::postBuild() impl->mPreviewHandle = previewp->getHandle(); previewp->setContainer(this); impl->updateControls(this); + impl->setAdvanced(gSavedSettings.getBOOL("AdvanceOutfitSnapshot")); impl->updateLayout(this); previewp->mKeepAspectRatio = FALSE; @@ -300,6 +303,7 @@ void LLFloaterOutfitSnapshot::onOpen(const LLSD& key) gSnapshotFloaterView->adjustToFitScreen(this, FALSE); impl->updateControls(this); + impl->setAdvanced(gSavedSettings.getBOOL("AdvanceOutfitSnapshot")); impl->updateLayout(this); LLPanel* snapshot_panel = getChild("panel_outfit_snapshot_inventory"); @@ -308,6 +312,11 @@ void LLFloaterOutfitSnapshot::onOpen(const LLSD& key) } +void LLFloaterOutfitSnapshot::onExtendFloater() +{ + impl->setAdvanced(gSavedSettings.getBOOL("AdvanceOutfitSnapshot")); +} + // static void LLFloaterOutfitSnapshot::update() { -- cgit v1.2.3