diff options
Diffstat (limited to 'indra/newview/llfloatersnapshot.cpp')
-rw-r--r-- | indra/newview/llfloatersnapshot.cpp | 260 |
1 files changed, 126 insertions, 134 deletions
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index e68d699d03..afb58c9407 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -34,20 +34,13 @@ #include "llfloatersnapshot.h" -#include "llfontgl.h" -#include "llsys.h" -#include "llgl.h" -#include "llrender.h" -#include "v3dmath.h" -#include "llmath.h" -#include "lldir.h" -#include "llsdserialize.h" +#include "llfloaterreg.h" +// Viewer includes #include "llagent.h" #include "llcallbacklist.h" #include "llcriticaldamp.h" #include "llui.h" -#include "llviewertexteditor.h" #include "llfocusmgr.h" #include "llbutton.h" #include "llcombobox.h" @@ -66,15 +59,28 @@ #include "lltoolfocus.h" #include "lltoolmgr.h" #include "llworld.h" +#include "llagentui.h" +// Linden library includes +#include "llfontgl.h" +#include "llsys.h" +#include "llrender.h" +#include "v3dmath.h" +#include "llmath.h" +#include "lldir.h" +#include "llsdserialize.h" #include "llgl.h" #include "llglheaders.h" #include "llimagejpeg.h" #include "llimagepng.h" #include "llimagebmp.h" #include "llimagej2c.h" +#include "lllocalcliprect.h" +#include "llnotificationsutil.h" +#include "llresmgr.h" // LLLocale #include "llvfile.h" #include "llvfs.h" +#include "llwindow.h" ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs @@ -85,8 +91,6 @@ S32 LLFloaterSnapshot::sUIWinWidth = 215 ; LLSnapshotFloaterView* gSnapshotFloaterView = NULL; -LLFloaterSnapshot* LLFloaterSnapshot::sInstance = NULL; - const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; F32 SHINE_TIME = 0.5f; @@ -98,6 +102,8 @@ S32 BORDER_WIDTH = 6; const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 +static LLDefaultChildRegistry::Register<LLSnapshotFloaterView> r("snapshot_floater_view"); + ///---------------------------------------------------------------------------- /// Class LLSnapshotLivePreview ///---------------------------------------------------------------------------- @@ -112,7 +118,17 @@ public: }; - LLSnapshotLivePreview(const LLRect& rect); + struct Params : public LLInitParam::Block<Params, LLView::Params> + { + Params() + { + name = "snapshot_live_preview"; + mouse_opaque = false; + } + }; + + + LLSnapshotLivePreview(const LLSnapshotLivePreview::Params& p); ~LLSnapshotLivePreview(); /*virtual*/ void draw(); @@ -128,12 +144,12 @@ public: LLFloaterSnapshot::ESnapshotFormat getSnapshotFormat() const { return mSnapshotFormat; } BOOL getSnapshotUpToDate() const { return mSnapshotUpToDate; } BOOL isSnapshotActive() { return mSnapshotActive; } - LLImageGL* getThumbnailImage() const { return mThumbnailImage ; } + LLViewerTexture* getThumbnailImage() const { return mThumbnailImage ; } S32 getThumbnailWidth() const { return mThumbnailWidth ; } S32 getThumbnailHeight() const { return mThumbnailHeight ; } BOOL getThumbnailLock() const { return mThumbnailUpdateLock ; } BOOL getThumbnailUpToDate() const { return mThumbnailUpToDate ;} - LLImageGL* getCurrentImage(); + LLViewerTexture* getCurrentImage(); F32 getImageAspect(); F32 getAspect() ; LLRect getImageRect(); @@ -158,7 +174,7 @@ public: private: LLColor4 mColor; - LLPointer<LLImageGL> mViewerImage[2]; //used to represent the scene when the frame is frozen. + LLPointer<LLViewerTexture> mViewerImage[2]; //used to represent the scene when the frame is frozen. LLRect mImageRect[2]; S32 mWidth[2]; S32 mHeight[2]; @@ -166,7 +182,7 @@ private: S32 mMaxImageSize ; //thumbnail image - LLPointer<LLImageGL> mThumbnailImage ; + LLPointer<LLViewerTexture> mThumbnailImage ; S32 mThumbnailWidth ; S32 mThumbnailHeight ; LLRect mPreviewRect ; @@ -200,8 +216,9 @@ public: }; std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList; -LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : - LLView(std::string("snapshot_live_preview"), rect, FALSE), + +LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Params& p) +: LLView(p), mColor(1.f, 0.f, 0.f, 0.5f), mCurImageIndex(0), mPreviewImage(NULL), @@ -229,10 +246,10 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : // gIdleCallbacks.addFunction( &LLSnapshotLivePreview::onIdle, (void*)this ); sList.insert(this); setFollowsAll(); - mWidth[0] = gViewerWindow->getWindowDisplayWidth(); - mWidth[1] = gViewerWindow->getWindowDisplayWidth(); - mHeight[0] = gViewerWindow->getWindowDisplayHeight(); - mHeight[1] = gViewerWindow->getWindowDisplayHeight(); + mWidth[0] = gViewerWindow->getWindowWidthRaw(); + mWidth[1] = gViewerWindow->getWindowWidthRaw(); + mHeight[0] = gViewerWindow->getWindowHeightRaw(); + mHeight[1] = gViewerWindow->getWindowHeightRaw(); mImageScaled[0] = FALSE; mImageScaled[1] = FALSE; @@ -265,7 +282,7 @@ void LLSnapshotLivePreview::setMaxImageSize(S32 size) } } -LLImageGL* LLSnapshotLivePreview::getCurrentImage() +LLViewerTexture* LLSnapshotLivePreview::getCurrentImage() { return mViewerImage[mCurImageIndex]; } @@ -472,37 +489,33 @@ void LLSnapshotLivePreview::draw() } else if (mShineAnimTimer.getStarted()) { - //LLDebugVarMessageBox::show("Shine time", &SHINE_TIME, 10.f, 0.1f); - //LLDebugVarMessageBox::show("Shine width", &SHINE_WIDTH, 2.f, 0.05f); - //LLDebugVarMessageBox::show("Shine opacity", &SHINE_OPACITY, 1.f, 0.05f); - F32 shine_interp = llmin(1.f, mShineAnimTimer.getElapsedTimeF32() / SHINE_TIME); // draw "shine" effect LLLocalClipRect clip(getLocalRect()); { // draw diagonal stripe with gradient that passes over screen - S32 x1 = gViewerWindow->getWindowWidth() * llround((clamp_rescale(shine_interp, 0.f, 1.f, -1.f - SHINE_WIDTH, 1.f))); - S32 x2 = x1 + llround(gViewerWindow->getWindowWidth() * SHINE_WIDTH); - S32 x3 = x2 + llround(gViewerWindow->getWindowWidth() * SHINE_WIDTH); + S32 x1 = gViewerWindow->getWindowWidthScaled() * llround((clamp_rescale(shine_interp, 0.f, 1.f, -1.f - SHINE_WIDTH, 1.f))); + S32 x2 = x1 + llround(gViewerWindow->getWindowWidthScaled() * SHINE_WIDTH); + S32 x3 = x2 + llround(gViewerWindow->getWindowWidthScaled() * SHINE_WIDTH); S32 y1 = 0; - S32 y2 = gViewerWindow->getWindowHeight(); + S32 y2 = gViewerWindow->getWindowHeightScaled(); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.begin(LLRender::QUADS); { gGL.color4f(1.f, 1.f, 1.f, 0.f); gGL.vertex2i(x1, y1); - gGL.vertex2i(x1 + gViewerWindow->getWindowWidth(), y2); + gGL.vertex2i(x1 + gViewerWindow->getWindowWidthScaled(), y2); gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); - gGL.vertex2i(x2 + gViewerWindow->getWindowWidth(), y2); + gGL.vertex2i(x2 + gViewerWindow->getWindowWidthScaled(), y2); gGL.vertex2i(x2, y1); gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); gGL.vertex2i(x2, y1); - gGL.vertex2i(x2 + gViewerWindow->getWindowWidth(), y2); + gGL.vertex2i(x2 + gViewerWindow->getWindowWidthScaled(), y2); gGL.color4f(1.f, 1.f, 1.f, 0.f); - gGL.vertex2i(x3 + gViewerWindow->getWindowWidth(), y2); + gGL.vertex2i(x3 + gViewerWindow->getWindowWidthScaled(), y2); gGL.vertex2i(x3, y1); } gGL.end(); @@ -605,8 +618,8 @@ BOOL LLSnapshotLivePreview::setThumbnailImageSize() { return FALSE ; } - S32 window_width = gViewerWindow->getWindowDisplayWidth() ; - S32 window_height = gViewerWindow->getWindowDisplayHeight() ; + S32 window_width = gViewerWindow->getWindowWidthRaw() ; + S32 window_height = gViewerWindow->getWindowHeightRaw() ; F32 window_aspect_ratio = ((F32)window_width) / ((F32)window_height); @@ -714,7 +727,7 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update) if(raw) { - mThumbnailImage = new LLImageGL(raw, FALSE); + mThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); mThumbnailUpToDate = TRUE ; } @@ -862,8 +875,8 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) scaled->expandToPowerOfTwo(1024, FALSE); } - previewp->mViewerImage[previewp->mCurImageIndex] = new LLImageGL(scaled, FALSE); - LLPointer<LLImageGL> curr_preview_image = previewp->mViewerImage[previewp->mCurImageIndex]; + previewp->mViewerImage[previewp->mCurImageIndex] = LLViewerTextureManager::getLocalTexture(scaled.get(), FALSE); + LLPointer<LLViewerTexture> curr_preview_image = previewp->mViewerImage[previewp->mCurImageIndex]; gGL.getTexUnit(0)->bind(curr_preview_image); if (previewp->getSnapshotType() != SNAPSHOT_TEXTURE) { @@ -959,9 +972,9 @@ void LLSnapshotLivePreview::saveTexture() { LLVFile::writeFile(formatted->getData(), formatted->getDataSize(), gVFS, new_asset_id, LLAssetType::AT_TEXTURE); std::string pos_string; - gAgent.buildLocationString(pos_string); + LLAgentUI::buildLocationString(pos_string, LLAgentUI::LOCATION_FORMAT_FULL); std::string who_took_it; - gAgent.buildFullname(who_took_it); + LLAgentUI::buildFullname(who_took_it); LLAssetStorage::LLStoreAssetCallback callback = NULL; S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); void *userdata = NULL; @@ -970,7 +983,7 @@ void LLSnapshotLivePreview::saveTexture() "Snapshot : " + pos_string, "Taken by " + who_took_it + " at " + pos_string, 0, - LLAssetType::AT_SNAPSHOT_CATEGORY, + LLFolderType::FT_SNAPSHOT_CATEGORY, LLInventoryType::IT_SNAPSHOT, PERM_ALL, // Note: Snapshots to inventory is a special case of content upload PERM_NONE, // that ignores the user's premissions preferences and continues to @@ -981,7 +994,7 @@ void LLSnapshotLivePreview::saveTexture() } else { - LLNotifications::instance().add("ErrorEncodingSnapshot"); + LLNotificationsUtil::add("ErrorEncodingSnapshot"); llwarns << "Error encoding snapshot" << llendl; } @@ -1053,9 +1066,6 @@ public: static void updateLayout(LLFloaterSnapshot* floater); static void updateResolutionTextEntry(LLFloaterSnapshot* floater); - static LLHandle<LLView> sPreviewHandle; - static BOOL sAspectRatioCheckOff ; - private: static LLSnapshotLivePreview::ESnapshotType getTypeIndex(LLFloaterSnapshot* floater); static ESnapshotFormat getFormatIndex(LLFloaterSnapshot* floater); @@ -1068,18 +1078,14 @@ public: std::vector<LLAnimPauseRequest> mAvatarPauseHandles; LLToolset* mLastToolset; + LLHandle<LLView> mPreviewHandle; + BOOL mAspectRatioCheckOff ; }; // static -LLHandle<LLView> LLFloaterSnapshot::Impl::sPreviewHandle; - -//static -BOOL LLFloaterSnapshot::Impl::sAspectRatioCheckOff = FALSE ; - -// static LLSnapshotLivePreview* LLFloaterSnapshot::Impl::getPreviewView(LLFloaterSnapshot *floater) { - LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)sPreviewHandle.get(); + LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)floater->impl.mPreviewHandle.get(); return previewp; } @@ -1103,15 +1109,18 @@ LLSnapshotLivePreview::ESnapshotType LLFloaterSnapshot::Impl::getTypeIndex(LLFlo LLFloaterSnapshot::ESnapshotFormat LLFloaterSnapshot::Impl::getFormatIndex(LLFloaterSnapshot* floater) { ESnapshotFormat index = SNAPSHOT_FORMAT_PNG; - LLSD value = floater->childGetValue("local_format_combo"); - const std::string id = value.asString(); - if (id == "PNG") - index = SNAPSHOT_FORMAT_PNG; - else if (id == "JPEG") - index = SNAPSHOT_FORMAT_JPEG; - else if (id == "BMP") - index = SNAPSHOT_FORMAT_BMP; - return index; + if(floater->hasChild("local_format_combo")) + { + LLComboBox* local_format_combo = floater->findChild<LLComboBox>("local_format_combo"); + const std::string id = local_format_combo->getSelectedItemLabel(); + if (id == "PNG") + index = SNAPSHOT_FORMAT_PNG; + else if (id == "JPEG") + index = SNAPSHOT_FORMAT_JPEG; + else if (id == "BMP") + index = SNAPSHOT_FORMAT_BMP; + } + return index; } @@ -1160,7 +1169,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) gSavedSettings.setS32("SnapshotLocalLastResolution", 0); LLSnapshotLivePreview* previewp = getPreviewView(floaterp); - previewp->setSize(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); + previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()); } bool use_freeze_frame = floaterp->childGetValue("freeze_frame_check").asBoolean(); @@ -1186,7 +1195,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) iter != LLCharacter::sInstances.end(); ++iter) { avatarp = *iter; - sInstance->impl.mAvatarPauseHandles.push_back(avatarp->requestPause()); + floaterp->impl.mAvatarPauseHandles.push_back(avatarp->requestPause()); } // freeze everything else @@ -1194,7 +1203,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) if (LLToolMgr::getInstance()->getCurrentToolset() != gCameraToolset) { - sInstance->impl.mLastToolset = LLToolMgr::getInstance()->getCurrentToolset(); + floaterp->impl.mLastToolset = LLToolMgr::getInstance()->getCurrentToolset(); LLToolMgr::getInstance()->setCurrentToolset(gCameraToolset); } } @@ -1209,15 +1218,15 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) } //RN: thaw all avatars - sInstance->impl.mAvatarPauseHandles.clear(); + floaterp->impl.mAvatarPauseHandles.clear(); // thaw everything else gSavedSettings.setBOOL("FreezeTime", FALSE); // restore last tool (e.g. pie menu, etc) - if (sInstance->impl.mLastToolset) + if (floaterp->impl.mLastToolset) { - LLToolMgr::getInstance()->setCurrentToolset(sInstance->impl.mLastToolset); + LLToolMgr::getInstance()->setCurrentToolset(floaterp->impl.mLastToolset); } } } @@ -1248,7 +1257,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) floater->childSetVisible("upload_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE); floater->childSetVisible("send_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD); floater->childSetVisible("save_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL); - floater->childSetEnabled("keep_aspect_check", shot_type != LLSnapshotLivePreview::SNAPSHOT_TEXTURE && !sAspectRatioCheckOff); + floater->childSetEnabled("keep_aspect_check", shot_type != LLSnapshotLivePreview::SNAPSHOT_TEXTURE && !floater->impl.mAspectRatioCheckOff); floater->childSetEnabled("layer_types", shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL); BOOL is_advance = gSavedSettings.getBOOL("AdvanceSnapshot"); @@ -1295,7 +1304,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) floater->childSetColor("file_size_label", shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD && got_bytes - && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLColor4::red : gColors.getColor( "LabelTextColor" )); + && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" )); switch(shot_type) { @@ -1367,9 +1376,10 @@ void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp, void LLFloaterSnapshot::Impl::onClickDiscard(void* data) { LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; + if (view) { - view->close(); + view->closeFloater(); } } @@ -1415,7 +1425,7 @@ void LLFloaterSnapshot::Impl::onClickKeep(void* data) if (gSavedSettings.getBOOL("CloseSnapshotOnKeep")) { - view->close(); + view->closeFloater(); } else { @@ -1596,7 +1606,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde if(0 == index) //current window size { - sAspectRatioCheckOff = TRUE ; + view->impl.mAspectRatioCheckOff = TRUE ; view->childSetEnabled("keep_aspect_check", FALSE) ; if(previewp) @@ -1606,7 +1616,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde } else if(-1 == index) //custom { - sAspectRatioCheckOff = FALSE ; + view->impl.mAspectRatioCheckOff = FALSE ; //if(LLSnapshotLivePreview::SNAPSHOT_TEXTURE != gSavedSettings.getS32("LastSnapshotType")) { view->childSetEnabled("keep_aspect_check", TRUE) ; @@ -1619,7 +1629,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde } else { - sAspectRatioCheckOff = TRUE ; + view->impl.mAspectRatioCheckOff = TRUE ; view->childSetEnabled("keep_aspect_check", FALSE) ; if(previewp) @@ -1683,7 +1693,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL if (width == 0 || height == 0) { // take resolution from current window size - previewp->setSize(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); + previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()); } else if (width == -1 || height == -1) { @@ -1836,13 +1846,13 @@ BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S3 #endif if(previewp && previewp->mKeepAspectRatio) { - if(gViewerWindow->getWindowDisplayWidth() < 1 || gViewerWindow->getWindowDisplayHeight() < 1) + if(gViewerWindow->getWindowWidthRaw() < 1 || gViewerWindow->getWindowHeightRaw() < 1) { return FALSE ; } //aspect ratio of the current window - F32 aspect_ratio = (F32)gViewerWindow->getWindowDisplayWidth() / gViewerWindow->getWindowDisplayHeight() ; + F32 aspect_ratio = (F32)gViewerWindow->getWindowWidthRaw() / gViewerWindow->getWindowHeightRaw() ; //change another value proportionally if(isWidthChanged) @@ -1955,21 +1965,17 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat ///---------------------------------------------------------------------------- // Default constructor -LLFloaterSnapshot::LLFloaterSnapshot() - : LLFloater(std::string("Snapshot Floater")), +LLFloaterSnapshot::LLFloaterSnapshot(const LLSD& key) + : LLFloater(key), impl (*(new Impl)) { + //Called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this, "floater_snapshot.xml", FALSE); } // Destroys the object LLFloaterSnapshot::~LLFloaterSnapshot() { - if (sInstance == this) - { - LLView::deleteViewByHandle(Impl::sPreviewHandle); - Impl::sPreviewHandle = LLHandle<LLView>(); - sInstance = NULL; - } + LLView::deleteViewByHandle(impl.mPreviewHandle); //unfreeze everything else gSavedSettings.setBOOL("FreezeTime", FALSE); @@ -2034,16 +2040,24 @@ BOOL LLFloaterSnapshot::postBuild() childSetCommitCallback("local_size_combo", Impl::onCommitResolution, this); // create preview window - LLRect full_screen_rect = sInstance->getRootView()->getRect(); - LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(full_screen_rect); - sInstance->getRootView()->removeChild(gSnapshotFloaterView); + 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 - sInstance->getRootView()->addChild(previewp); - sInstance->getRootView()->addChild(gSnapshotFloaterView); - - Impl::sPreviewHandle = previewp->getHandle(); + parent_view->addChild(previewp); + parent_view->addChild(gSnapshotFloaterView); + + //move snapshot floater to special purpose snapshotfloaterview + gFloaterView->removeChild(this); + gSnapshotFloaterView->addChild(this); + impl.mPreviewHandle = previewp->getHandle(); impl.updateControls(this); + impl.updateLayout(this); return TRUE; } @@ -2064,8 +2078,10 @@ void LLFloaterSnapshot::draw() { if(previewp->getThumbnailImage()) { + LLRect thumbnail_rect = getChild<LLUICtrl>("thumbnail_placeholder")->getRect(); + S32 offset_x = (getRect().getWidth() - previewp->getThumbnailWidth()) / 2 ; - S32 offset_y = getRect().getHeight() - 205 + (90 - previewp->getThumbnailHeight()) / 2 ; + S32 offset_y = thumbnail_rect.mBottom + (thumbnail_rect.getHeight() - previewp->getThumbnailHeight()) / 2 ; glMatrixMode(GL_MODELVIEW); gl_draw_scaled_image(offset_x, offset_y, @@ -2077,54 +2093,32 @@ void LLFloaterSnapshot::draw() } } -void LLFloaterSnapshot::onClose(bool app_quitting) +void LLFloaterSnapshot::onOpen(const LLSD& key) { - gSnapshotFloaterView->setEnabled(FALSE); - // Set invisible so it doesn't eat tooltips. JC - gSnapshotFloaterView->setVisible(FALSE); - destroy(); -} - -// static -void LLFloaterSnapshot::show(void*) -{ - if (!sInstance) + LLSnapshotLivePreview* preview = LLFloaterSnapshot::Impl::getPreviewView(this); + if(preview) { - sInstance = new LLFloaterSnapshot(); - LLUICtrlFactory::getInstance()->buildFloater(sInstance, "floater_snapshot.xml", NULL, FALSE); - //move snapshot floater to special purpose snapshotfloaterview - gFloaterView->removeChild(sInstance); - gSnapshotFloaterView->addChild(sInstance); - - sInstance->impl.updateLayout(sInstance); - } - else // just refresh the snapshot in the existing floater instance (DEV-12255) - { - LLSnapshotLivePreview* preview = LLFloaterSnapshot::Impl::getPreviewView(sInstance); - if(preview) - { - preview->updateSnapshot(TRUE); - } + preview->updateSnapshot(TRUE); } - - sInstance->open(); /* Flawfinder: ignore */ - sInstance->focusFirstItem(FALSE); + focusFirstItem(FALSE); gSnapshotFloaterView->setEnabled(TRUE); gSnapshotFloaterView->setVisible(TRUE); - gSnapshotFloaterView->adjustToFitScreen(sInstance, FALSE); + gSnapshotFloaterView->adjustToFitScreen(this, FALSE); } -void LLFloaterSnapshot::hide(void*) +void LLFloaterSnapshot::onClose(bool app_quitting) { - if (sInstance && !sInstance->isDead()) - { - sInstance->close(); - } + getParent()->setMouseOpaque(FALSE); } + //static void LLFloaterSnapshot::update() { + LLFloaterSnapshot* inst = LLFloaterReg::findTypedInstance<LLFloaterSnapshot>("snapshot"); + if (!inst) + return; + BOOL changed = FALSE; for (std::set<LLSnapshotLivePreview*>::iterator iter = LLSnapshotLivePreview::sList.begin(); iter != LLSnapshotLivePreview::sList.end(); ++iter) @@ -2133,7 +2127,7 @@ void LLFloaterSnapshot::update() } if(changed) { - sInstance->impl.updateControls(sInstance); + inst->impl.updateControls(inst); } } @@ -2142,10 +2136,8 @@ void LLFloaterSnapshot::update() /// Class LLSnapshotFloaterView ///---------------------------------------------------------------------------- -LLSnapshotFloaterView::LLSnapshotFloaterView( const std::string& name, const LLRect& rect ) : LLFloaterView(name, rect) +LLSnapshotFloaterView::LLSnapshotFloaterView (const Params& p) : LLFloaterView (p) { - setMouseOpaque(TRUE); - setEnabled(FALSE); } LLSnapshotFloaterView::~LLSnapshotFloaterView() |