From 49fa618fd7b7c5643dc3ce047c3a2f178f402d97 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 7 Jan 2012 00:33:40 +0100 Subject: [PATCH] Open texture preview floater when clicking on disabled texture picker. Original implementation by Henri Beauchamp (Cool VL) with permission to use under LGPL (Fixes FIRE-1796) --- indra/newview/llpreviewtexture.cpp | 10 ++++++++- indra/newview/lltexturectrl.cpp | 34 +++++++++++++++++++++++------- indra/newview/lltexturectrl.h | 1 + 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 7d53db00d5..5c834d5627 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -60,7 +60,7 @@ const F32 PREVIEW_TEXTURE_MIN_ASPECT = 0.005f; LLPreviewTexture::LLPreviewTexture(const LLSD& key) - : LLPreview(key), + : LLPreview((key.has("uuid") ? key.get("uuid") : key)), // Changed for texture preview mode mLoadingFullImage( FALSE ), mShowKeepDiscard(FALSE), mCopyToInv(FALSE), @@ -78,6 +78,14 @@ LLPreviewTexture::LLPreviewTexture(const LLSD& key) { mPreviewToSave = TRUE; } + // Texture preview mode + if (key.has("preview_only")) + { + mShowKeepDiscard = FALSE; + mCopyToInv = FALSE; + mIsCopyable = FALSE; + mPreviewToSave = FALSE; + } } LLPreviewTexture::~LLPreviewTexture() diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 79b05ae8ac..1bb8faa77d 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -992,7 +992,8 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) mImageAssetID(p.image_id), mDefaultImageAssetID(p.default_image_id), mDefaultImageName(p.default_image_name), - mFallbackImage(p.fallback_image) + mFallbackImage(p.fallback_image), + mPreviewMode(!p.enabled) // For texture preview mode { setAllowNoTexture(p.allow_no_texture); setCanApplyImmediately(p.can_apply_immediately); @@ -1087,7 +1088,9 @@ void LLTextureCtrl::setEnabled( BOOL enabled ) mCaption->setEnabled( enabled ); - LLView::setEnabled( enabled ); + // Texture preview mode + LLView::setEnabled( (enabled || getValue().asUUID().notNull()) ); + mPreviewMode = !enabled; } void LLTextureCtrl::setValid(BOOL valid ) @@ -1190,11 +1193,23 @@ BOOL LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask) if (!handled && mBorder->parentPointInView(x, y)) { - showPicker(FALSE); - //grab textures first... - LLInventoryModelBackgroundFetch::instance().start(gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE)); - //...then start full inventory fetch. - LLInventoryModelBackgroundFetch::instance().start(); + if (!mPreviewMode) + { + showPicker(FALSE); + //grab textures first... + LLInventoryModelBackgroundFetch::instance().start(gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE)); + //...then start full inventory fetch. + LLInventoryModelBackgroundFetch::instance().start(); + } + else + { + // Open the preview floater for the texture + LLSD params; + params["uuid"] = getValue(); + params["preview_only"] = TRUE; + LLFloaterReg::showInstance("preview_texture", params, TRUE); + } + handled = TRUE; } @@ -1533,7 +1548,10 @@ BOOL LLTextureCtrl::handleUnicodeCharHere(llwchar uni_char) void LLTextureCtrl::setValue( const LLSD& value ) { - setImageAssetID(value.asUUID()); + // Changed for texture preview mode + LLUUID uuid = value.asUUID(); + setImageAssetID(uuid); + LLView::setEnabled( (!mPreviewMode || uuid.notNull()) ); } LLSD LLTextureCtrl::getValue() const diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 531c79667b..ab02ba4e9e 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -208,6 +208,7 @@ private: BOOL mShowLoadingPlaceholder; std::string mLoadingPlaceholderString; S32 mLabelWidth; + BOOL mPreviewMode; // If true open texture in preview floater }; // XUI HACK: When floaters converted, switch this file to lltexturepicker.h/cpp