diff options
-rwxr-xr-x | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterbigpreview.cpp | 110 | ||||
-rw-r--r-- | indra/newview/llfloaterbigpreview.h | 54 | ||||
-rw-r--r-- | indra/newview/llfloaterfacebook.cpp | 67 | ||||
-rw-r--r-- | indra/newview/llfloaterfacebook.h | 11 | ||||
-rw-r--r-- | indra/newview/llfloaterflickr.cpp | 67 | ||||
-rw-r--r-- | indra/newview/llfloaterflickr.h | 9 | ||||
-rw-r--r-- | indra/newview/llfloatertwitter.cpp | 65 | ||||
-rw-r--r-- | indra/newview/llfloatertwitter.h | 9 | ||||
-rw-r--r-- | indra/newview/llsnapshotlivepreview.cpp | 57 | ||||
-rw-r--r-- | indra/newview/llsnapshotlivepreview.h | 13 | ||||
-rwxr-xr-x | indra/newview/llviewerfloaterreg.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_big_preview.xml | 25 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_facebook_photo.xml | 16 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_flickr_photo.xml | 18 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_twitter_photo.xml | 16 |
16 files changed, 531 insertions, 10 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 793d972e1c..6d8d6b75a2 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -208,6 +208,7 @@ set(viewer_SOURCE_FILES llfloateravatarpicker.cpp llfloateravatartextures.cpp llfloaterbeacons.cpp + llfloaterbigpreview.cpp llfloaterbuildoptions.cpp llfloaterbulkpermission.cpp llfloaterbump.cpp @@ -802,6 +803,7 @@ set(viewer_HEADER_FILES llfloateravatarpicker.h llfloateravatartextures.h llfloaterbeacons.h + llfloaterbigpreview.h llfloaterbuildoptions.h llfloaterbulkpermission.h llfloaterbump.h diff --git a/indra/newview/llfloaterbigpreview.cpp b/indra/newview/llfloaterbigpreview.cpp new file mode 100644 index 0000000000..b516e9dd01 --- /dev/null +++ b/indra/newview/llfloaterbigpreview.cpp @@ -0,0 +1,110 @@ +/** +* @file llfloaterbigpreview.cpp +* @brief Display of extended (big) preview for snapshots and SL Share +* @author merov@lindenlab.com +* +* $LicenseInfo:firstyear=2013&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2013, 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 "llfloaterbigpreview.h" +#include "llsnapshotlivepreview.h" + +/////////////////////// +//LLFloaterBigPreview// +/////////////////////// + +LLFloaterBigPreview::LLFloaterBigPreview(const LLSD& key) : LLFloater(key), + mPreviewPlaceholder(NULL), + mFloaterOwner(NULL) +{ +} + +LLFloaterBigPreview::~LLFloaterBigPreview() +{ + if (mPreviewHandle.get()) + { + mPreviewHandle.get()->die(); + } +} + +void LLFloaterBigPreview::onCancel() +{ + closeFloater(); +} + +void LLFloaterBigPreview::closeOnFloaterOwnerClosing(LLFloater* floaterp) +{ + if (isFloaterOwner(floaterp)) + { + closeFloater(); + } +} + +BOOL LLFloaterBigPreview::postBuild() +{ + mPreviewPlaceholder = getChild<LLUICtrl>("big_preview_placeholder"); + return LLFloater::postBuild(); +} + +void LLFloaterBigPreview::draw() +{ + LLFloater::draw(); + + LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get()); + + // Display the preview if one is available + if (previewp && previewp->getBigThumbnailImage()) + { + // Get the preview rect + const LLRect& preview_rect = mPreviewPlaceholder->getRect(); + + // Get the preview texture size + S32 thumbnail_w = previewp->getBigThumbnailWidth(); + S32 thumbnail_h = previewp->getBigThumbnailHeight(); + + // Compute the scaling ratio and the size of the final texture in the rect: we want to prevent anisotropic scaling (distorted in x and y) + F32 ratio = llmax((F32)(thumbnail_w)/(F32)(preview_rect.getWidth()), (F32)(thumbnail_h)/(F32)(preview_rect.getHeight())); + thumbnail_w = (S32)((F32)(thumbnail_w)/ratio); + thumbnail_h = (S32)((F32)(thumbnail_h)/ratio); + + // Compute the preview offset within the preview rect: we want to center that preview in the available rect + const S32 local_offset_x = (preview_rect.getWidth() - thumbnail_w) / 2 ; + const S32 local_offset_y = (preview_rect.getHeight() - thumbnail_h) / 2 ; + + // Compute preview offset within the floater rect + S32 offset_x = preview_rect.mLeft + local_offset_x; + S32 offset_y = preview_rect.mBottom + local_offset_y; + + gGL.matrixMode(LLRender::MM_MODELVIEW); + // Apply floater transparency to the texture unless the floater is focused. + F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); + LLColor4 color = LLColor4::white; + + // Draw the preview texture + gl_draw_scaled_image(offset_x, offset_y, + thumbnail_w, thumbnail_h, + previewp->getBigThumbnailImage(), color % alpha); + } +} + diff --git a/indra/newview/llfloaterbigpreview.h b/indra/newview/llfloaterbigpreview.h new file mode 100644 index 0000000000..63c6784d36 --- /dev/null +++ b/indra/newview/llfloaterbigpreview.h @@ -0,0 +1,54 @@ +/** +* @file llfloaterbigpreview.h +* @brief Display of extended (big) preview for snapshots and SL Share +* @author merov@lindenlab.com +* +* $LicenseInfo:firstyear=2013&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2013, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ +#ifndef LL_LLFLOATERBIGPREVIEW_H +#define LL_LLFLOATERBIGPREVIEW_H + +#include "llfloater.h" + +class LLFloaterBigPreview : public LLFloater +{ +public: + LLFloaterBigPreview(const LLSD& key); + ~LLFloaterBigPreview(); + + BOOL postBuild(); + void draw(); + void onCancel(); + + void setPreview(LLView* previewp) { mPreviewHandle = previewp->getHandle(); } + void setFloaterOwner(LLFloater* floaterp) { mFloaterOwner = floaterp; } + bool isFloaterOwner(LLFloater* floaterp) const { return (mFloaterOwner == floaterp); } + void closeOnFloaterOwnerClosing(LLFloater* floaterp); + +private: + LLHandle<LLView> mPreviewHandle; + LLUICtrl* mPreviewPlaceholder; + LLFloater* mFloaterOwner; +}; + +#endif // LL_LLFLOATERBIGPREVIEW_H + diff --git a/indra/newview/llfloaterfacebook.cpp b/indra/newview/llfloaterfacebook.cpp index de849b6b3f..5589d4897d 100644 --- a/indra/newview/llfloaterfacebook.cpp +++ b/indra/newview/llfloaterfacebook.cpp @@ -34,6 +34,7 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "llfacebookconnect.h" +#include "llfloaterbigpreview.h" #include "llfloaterreg.h" #include "lliconctrl.h" #include "llimagefiltersmanager.h" @@ -185,15 +186,18 @@ LLFacebookPhotoPanel::LLFacebookPhotoPanel() : mSnapshotPanel(NULL), mResolutionComboBox(NULL), mRefreshBtn(NULL), +mBtnPreview(NULL), mWorkingLabel(NULL), mThumbnailPlaceholder(NULL), mCaptionTextBox(NULL), mLocationCheckbox(NULL), mPostButton(NULL), +mBigPreviewFloater(NULL), mQuality(MAX_QUALITY) { mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLFacebookPhotoPanel::onSend, this)); mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLFacebookPhotoPanel::onClickNewSnapshot, this)); + mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLFacebookPhotoPanel::onClickBigPreview, this)); } LLFacebookPhotoPanel::~LLFacebookPhotoPanel() @@ -215,12 +219,14 @@ BOOL LLFacebookPhotoPanel::postBuild() mFilterComboBox = getChild<LLUICtrl>("filters_combobox"); mFilterComboBox->setCommitCallback(boost::bind(&LLFacebookPhotoPanel::updateResolution, this, TRUE)); mRefreshBtn = getChild<LLUICtrl>("new_snapshot_btn"); + mBtnPreview = getChild<LLButton>("big_preview_btn"); mWorkingLabel = getChild<LLUICtrl>("working_lbl"); mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder"); mCaptionTextBox = getChild<LLUICtrl>("photo_caption"); mLocationCheckbox = getChild<LLUICtrl>("add_location_cb"); mPostButton = getChild<LLUICtrl>("post_photo_btn"); mCancelButton = getChild<LLUICtrl>("cancel_photo_btn"); + mBigPreviewFloater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); // Update filter list std::vector<std::string> filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); @@ -272,9 +278,20 @@ void LLFacebookPhotoPanel::draw() mResolutionComboBox->setEnabled(no_ongoing_connection); mFilterComboBox->setEnabled(no_ongoing_connection); mRefreshBtn->setEnabled(no_ongoing_connection); + mBtnPreview->setEnabled(no_ongoing_connection); mLocationCheckbox->setEnabled(no_ongoing_connection); + + // Reassign the preview floater if we have the focus and the preview exists + if (hasFocus() && isPreviewVisible()) + { + attachPreview(); + } + + // Toggle the button state as appropriate + bool preview_active = (isPreviewVisible() && mBigPreviewFloater->isFloaterOwner(getParentByType<LLFloater>())); + mBtnPreview->setToggleState(preview_active); - // Display the preview if one is available + // Display the thumbnail if one is available if (previewp && previewp->getThumbnailImage()) { const LLRect& thumbnail_rect = mThumbnailPlaceholder->getRect(); @@ -365,6 +382,35 @@ void LLFacebookPhotoPanel::onClickNewSnapshot() } } +void LLFacebookPhotoPanel::onClickBigPreview() +{ + // Toggle the preview + if (isPreviewVisible()) + { + LLFloaterReg::hideInstance("big_preview"); + } + else + { + attachPreview(); + LLFloaterReg::showInstance("big_preview"); + } +} + +bool LLFacebookPhotoPanel::isPreviewVisible() +{ + return (mBigPreviewFloater && mBigPreviewFloater->getVisible()); +} + +void LLFacebookPhotoPanel::attachPreview() +{ + if (mBigPreviewFloater) + { + LLSnapshotLivePreview* previewp = getPreviewView(); + mBigPreviewFloater->setPreview(previewp); + mBigPreviewFloater->setFloaterOwner(getParentByType<LLFloater>()); + } +} + void LLFacebookPhotoPanel::onSend() { LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLFacebookPhotoPanel"); // just in case it is already listening @@ -439,6 +485,10 @@ void LLFacebookPhotoPanel::clearAndClose() if (floater) { floater->closeFloater(); + if (mBigPreviewFloater) + { + mBigPreviewFloater->closeOnFloaterOwnerClosing(floater); + } } } @@ -964,8 +1014,23 @@ LLFloaterFacebook::LLFloaterFacebook(const LLSD& key) : LLFloater(key), mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterFacebook::onCancel, this)); } +void LLFloaterFacebook::onClose(bool app_quitting) +{ + LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); + if (big_preview_floater) + { + big_preview_floater->closeOnFloaterOwnerClosing(this); + } + LLFloater::onClose(app_quitting); +} + void LLFloaterFacebook::onCancel() { + LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); + if (big_preview_floater) + { + big_preview_floater->closeOnFloaterOwnerClosing(this); + } closeFloater(); } diff --git a/indra/newview/llfloaterfacebook.h b/indra/newview/llfloaterfacebook.h index 20c401d0c1..08c5f24e4d 100644 --- a/indra/newview/llfloaterfacebook.h +++ b/indra/newview/llfloaterfacebook.h @@ -35,6 +35,7 @@ class LLIconCtrl; class LLCheckBoxCtrl; class LLSnapshotLivePreview; class LLAvatarList; +class LLFloaterBigPreview; class LLFacebookStatusPanel : public LLPanel { @@ -65,6 +66,7 @@ public: LLSnapshotLivePreview* getPreviewView(); void onVisibilityChange(const LLSD& new_visibility); + void onClickBigPreview(); void onClickNewSnapshot(); void onSend(); S32 notify(const LLSD& info); @@ -79,6 +81,9 @@ public: LLUICtrl* getRefreshBtn(); private: + bool isPreviewVisible(); + void attachPreview(); + LLHandle<LLView> mPreviewHandle; LLUICtrl * mSnapshotPanel; @@ -90,7 +95,10 @@ private: LLUICtrl * mCaptionTextBox; LLUICtrl * mLocationCheckbox; LLUICtrl * mPostButton; - LLUICtrl* mCancelButton; + LLUICtrl * mCancelButton; + LLButton * mBtnPreview; + + LLFloaterBigPreview * mBigPreviewFloater; S32 mQuality; // Compression quality }; @@ -167,6 +175,7 @@ public: LLFloaterFacebook(const LLSD& key); BOOL postBuild(); void draw(); + void onClose(bool app_quitting); void onCancel(); void showPhotoPanel(); diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp index 8c3db46d76..8c4c36538b 100644 --- a/indra/newview/llfloaterflickr.cpp +++ b/indra/newview/llfloaterflickr.cpp @@ -44,6 +44,7 @@ #include "llslurl.h" #include "lltrans.h" #include "llsnapshotlivepreview.h" +#include "llfloaterbigpreview.h" #include "llviewerregion.h" #include "llviewercontrol.h" #include "llviewermedia.h" @@ -67,6 +68,7 @@ LLFlickrPhotoPanel::LLFlickrPhotoPanel() : mSnapshotPanel(NULL), mResolutionComboBox(NULL), mRefreshBtn(NULL), +mBtnPreview(NULL), mWorkingLabel(NULL), mThumbnailPlaceholder(NULL), mTitleTextBox(NULL), @@ -74,10 +76,12 @@ mDescriptionTextBox(NULL), mLocationCheckbox(NULL), mTagsTextBox(NULL), mRatingComboBox(NULL), +mBigPreviewFloater(NULL), mPostButton(NULL) { mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLFlickrPhotoPanel::onSend, this)); mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLFlickrPhotoPanel::onClickNewSnapshot, this)); + mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLFlickrPhotoPanel::onClickBigPreview, this)); } LLFlickrPhotoPanel::~LLFlickrPhotoPanel() @@ -98,6 +102,7 @@ BOOL LLFlickrPhotoPanel::postBuild() mFilterComboBox = getChild<LLUICtrl>("filters_combobox"); mFilterComboBox->setCommitCallback(boost::bind(&LLFlickrPhotoPanel::updateResolution, this, TRUE)); mRefreshBtn = getChild<LLUICtrl>("new_snapshot_btn"); + mBtnPreview = getChild<LLButton>("big_preview_btn"); mWorkingLabel = getChild<LLUICtrl>("working_lbl"); mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder"); mTitleTextBox = getChild<LLUICtrl>("photo_title"); @@ -108,6 +113,7 @@ BOOL LLFlickrPhotoPanel::postBuild() mRatingComboBox = getChild<LLUICtrl>("rating_combobox"); mPostButton = getChild<LLUICtrl>("post_photo_btn"); mCancelButton = getChild<LLUICtrl>("cancel_photo_btn"); + mBigPreviewFloater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); // Update filter list std::vector<std::string> filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); @@ -162,8 +168,19 @@ void LLFlickrPhotoPanel::draw() mResolutionComboBox->setEnabled(no_ongoing_connection); mFilterComboBox->setEnabled(no_ongoing_connection); mRefreshBtn->setEnabled(no_ongoing_connection); + mBtnPreview->setEnabled(no_ongoing_connection); mLocationCheckbox->setEnabled(no_ongoing_connection); + // Reassign the preview floater if we have the focus and the preview exists + if (hasFocus() && isPreviewVisible()) + { + attachPreview(); + } + + // Toggle the button state as appropriate + bool preview_active = (isPreviewVisible() && mBigPreviewFloater->isFloaterOwner(getParentByType<LLFloater>())); + mBtnPreview->setToggleState(preview_active); + // Display the preview if one is available if (previewp && previewp->getThumbnailImage()) { @@ -229,7 +246,7 @@ void LLFlickrPhotoPanel::onVisibilityChange(const LLSD& new_visibility) LLSnapshotLivePreview::Params p; p.rect(full_screen_rect); LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); - mPreviewHandle = previewp->getHandle(); + mPreviewHandle = previewp->getHandle(); previewp->setContainer(this); previewp->setSnapshotType(previewp->SNAPSHOT_WEB); @@ -253,6 +270,35 @@ void LLFlickrPhotoPanel::onClickNewSnapshot() } } +void LLFlickrPhotoPanel::onClickBigPreview() +{ + // Toggle the preview + if (isPreviewVisible()) + { + LLFloaterReg::hideInstance("big_preview"); + } + else + { + attachPreview(); + LLFloaterReg::showInstance("big_preview"); + } +} + +bool LLFlickrPhotoPanel::isPreviewVisible() +{ + return (mBigPreviewFloater && mBigPreviewFloater->getVisible()); +} + +void LLFlickrPhotoPanel::attachPreview() +{ + if (mBigPreviewFloater) + { + LLSnapshotLivePreview* previewp = getPreviewView(); + mBigPreviewFloater->setPreview(previewp); + mBigPreviewFloater->setFloaterOwner(getParentByType<LLFloater>()); + } +} + void LLFlickrPhotoPanel::onSend() { LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrPhotoPanel"); // just in case it is already listening @@ -363,6 +409,10 @@ void LLFlickrPhotoPanel::clearAndClose() if (floater) { floater->closeFloater(); + if (mBigPreviewFloater) + { + mBigPreviewFloater->closeOnFloaterOwnerClosing(floater); + } } } @@ -637,8 +687,23 @@ LLFloaterFlickr::LLFloaterFlickr(const LLSD& key) : LLFloater(key), mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterFlickr::onCancel, this)); } +void LLFloaterFlickr::onClose(bool app_quitting) +{ + LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); + if (big_preview_floater) + { + big_preview_floater->closeOnFloaterOwnerClosing(this); + } + LLFloater::onClose(app_quitting); +} + void LLFloaterFlickr::onCancel() { + LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); + if (big_preview_floater) + { + big_preview_floater->closeOnFloaterOwnerClosing(this); + } closeFloater(); } diff --git a/indra/newview/llfloaterflickr.h b/indra/newview/llfloaterflickr.h index 319ab1278f..7a5453d32a 100644 --- a/indra/newview/llfloaterflickr.h +++ b/indra/newview/llfloaterflickr.h @@ -34,6 +34,7 @@ class LLIconCtrl; class LLCheckBoxCtrl; class LLSnapshotLivePreview; +class LLFloaterBigPreview; class LLFlickrPhotoPanel : public LLPanel { @@ -48,6 +49,7 @@ public: LLSnapshotLivePreview* getPreviewView(); void onVisibilityChange(const LLSD& new_visibility); void onClickNewSnapshot(); + void onClickBigPreview(); void onSend(); bool onFlickrConnectStateChange(const LLSD& data); @@ -60,6 +62,9 @@ public: LLUICtrl* getRefreshBtn(); private: + bool isPreviewVisible(); + void attachPreview(); + LLHandle<LLView> mPreviewHandle; LLUICtrl * mSnapshotPanel; @@ -75,6 +80,9 @@ private: LLUICtrl * mRatingComboBox; LLUICtrl * mPostButton; LLUICtrl * mCancelButton; + LLButton * mBtnPreview; + + LLFloaterBigPreview * mBigPreviewFloater; }; class LLFlickrAccountPanel : public LLPanel @@ -111,6 +119,7 @@ public: LLFloaterFlickr(const LLSD& key); BOOL postBuild(); void draw(); + void onClose(bool app_quitting); void onCancel(); void showPhotoPanel(); diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index e9db6e01dd..0b2987a3c1 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -34,6 +34,7 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lltwitterconnect.h" +#include "llfloaterbigpreview.h" #include "llfloaterreg.h" #include "lliconctrl.h" #include "llimagefiltersmanager.h" @@ -66,16 +67,19 @@ LLTwitterPhotoPanel::LLTwitterPhotoPanel() : mSnapshotPanel(NULL), mResolutionComboBox(NULL), mRefreshBtn(NULL), +mBtnPreview(NULL), mWorkingLabel(NULL), mThumbnailPlaceholder(NULL), mStatusCounterLabel(NULL), mStatusTextBox(NULL), mLocationCheckbox(NULL), mPhotoCheckbox(NULL), +mBigPreviewFloater(NULL), mPostButton(NULL) { mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLTwitterPhotoPanel::onSend, this)); mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLTwitterPhotoPanel::onClickNewSnapshot, this)); + mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLTwitterPhotoPanel::onClickBigPreview, this)); } LLTwitterPhotoPanel::~LLTwitterPhotoPanel() @@ -97,6 +101,7 @@ BOOL LLTwitterPhotoPanel::postBuild() mFilterComboBox = getChild<LLUICtrl>("filters_combobox"); mFilterComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); mRefreshBtn = getChild<LLUICtrl>("new_snapshot_btn"); + mBtnPreview = getChild<LLButton>("big_preview_btn"); mWorkingLabel = getChild<LLUICtrl>("working_lbl"); mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder"); mStatusCounterLabel = getChild<LLUICtrl>("status_counter_label"); @@ -108,6 +113,7 @@ BOOL LLTwitterPhotoPanel::postBuild() mPhotoCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddPhotoToggled, this)); mPostButton = getChild<LLUICtrl>("post_photo_btn"); mCancelButton = getChild<LLUICtrl>("cancel_photo_btn"); + mBigPreviewFloater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); // Update filter list std::vector<std::string> filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); @@ -160,6 +166,7 @@ void LLTwitterPhotoPanel::draw() mResolutionComboBox->setEnabled(no_ongoing_connection && photo_checked); mFilterComboBox->setEnabled(no_ongoing_connection && photo_checked); mRefreshBtn->setEnabled(no_ongoing_connection && photo_checked); + mBtnPreview->setEnabled(no_ongoing_connection); mLocationCheckbox->setEnabled(no_ongoing_connection); mPhotoCheckbox->setEnabled(no_ongoing_connection); @@ -167,6 +174,16 @@ void LLTwitterPhotoPanel::draw() bool add_photo = mPhotoCheckbox->getValue().asBoolean(); updateStatusTextLength(false); + // Reassign the preview floater if we have the focus and the preview exists + if (hasFocus() && isPreviewVisible()) + { + attachPreview(); + } + + // Toggle the button state as appropriate + bool preview_active = (isPreviewVisible() && mBigPreviewFloater->isFloaterOwner(getParentByType<LLFloater>())); + mBtnPreview->setToggleState(preview_active); + // Display the preview if one is available if (previewp && previewp->getThumbnailImage()) { @@ -268,6 +285,35 @@ void LLTwitterPhotoPanel::onClickNewSnapshot() } } +void LLTwitterPhotoPanel::onClickBigPreview() +{ + // Toggle the preview + if (isPreviewVisible()) + { + LLFloaterReg::hideInstance("big_preview"); + } + else + { + attachPreview(); + LLFloaterReg::showInstance("big_preview"); + } +} + +bool LLTwitterPhotoPanel::isPreviewVisible() +{ + return (mBigPreviewFloater && mBigPreviewFloater->getVisible()); +} + +void LLTwitterPhotoPanel::attachPreview() +{ + if (mBigPreviewFloater) + { + LLSnapshotLivePreview* previewp = getPreviewView(); + mBigPreviewFloater->setPreview(previewp); + mBigPreviewFloater->setFloaterOwner(getParentByType<LLFloater>()); + } +} + void LLTwitterPhotoPanel::onSend() { LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterPhotoPanel"); // just in case it is already listening @@ -359,6 +405,10 @@ void LLTwitterPhotoPanel::clearAndClose() if (floater) { floater->closeFloater(); + if (mBigPreviewFloater) + { + mBigPreviewFloater->closeOnFloaterOwnerClosing(floater); + } } } @@ -672,8 +722,23 @@ LLFloaterTwitter::LLFloaterTwitter(const LLSD& key) : LLFloater(key), mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterTwitter::onCancel, this)); } +void LLFloaterTwitter::onClose(bool app_quitting) +{ + LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); + if (big_preview_floater) + { + big_preview_floater->closeOnFloaterOwnerClosing(this); + } + LLFloater::onClose(app_quitting); +} + void LLFloaterTwitter::onCancel() { + LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview")); + if (big_preview_floater) + { + big_preview_floater->closeOnFloaterOwnerClosing(this); + } closeFloater(); } diff --git a/indra/newview/llfloatertwitter.h b/indra/newview/llfloatertwitter.h index bb88557ad8..659ab7779a 100644 --- a/indra/newview/llfloatertwitter.h +++ b/indra/newview/llfloatertwitter.h @@ -34,6 +34,7 @@ class LLIconCtrl; class LLCheckBoxCtrl; class LLSnapshotLivePreview; +class LLFloaterBigPreview; class LLTwitterPhotoPanel : public LLPanel { @@ -48,6 +49,7 @@ public: void onVisibilityChange(const LLSD& new_visibility); void onAddLocationToggled(); void onAddPhotoToggled(); + void onClickBigPreview(); void onClickNewSnapshot(); void onSend(); S32 notify(const LLSD& info); @@ -63,6 +65,9 @@ public: LLUICtrl* getRefreshBtn(); private: + bool isPreviewVisible(); + void attachPreview(); + LLHandle<LLView> mPreviewHandle; LLUICtrl * mSnapshotPanel; @@ -77,7 +82,10 @@ private: LLUICtrl * mPhotoCheckbox; LLUICtrl * mPostButton; LLUICtrl * mCancelButton; + LLButton * mBtnPreview; + LLFloaterBigPreview * mBigPreviewFloater; + std::string mOldStatusText; }; @@ -115,6 +123,7 @@ public: LLFloaterTwitter(const LLSD& key); BOOL postBuild(); void draw(); + void onClose(bool app_quitting); void onCancel(); void showPhotoPanel(); diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index eef4ed78c8..db203c7c78 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -75,7 +75,8 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param mColor(1.f, 0.f, 0.f, 0.5f), mCurImageIndex(0), mPreviewImage(NULL), - mThumbnailImage(NULL) , + mThumbnailImage(NULL) , + mBigThumbnailImage(NULL) , mThumbnailWidth(0), mThumbnailHeight(0), mThumbnailSubsampled(FALSE), @@ -115,6 +116,7 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ; mThumbnailUpdateLock = FALSE ; mThumbnailUpToDate = FALSE ; + mBigThumbnailUpToDate = FALSE ; } LLSnapshotLivePreview::~LLSnapshotLivePreview() @@ -205,6 +207,7 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail if (new_thumbnail) { mThumbnailUpToDate = FALSE ; + mBigThumbnailUpToDate = FALSE; } } @@ -542,6 +545,9 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update) return ; } + // Invalidate the big thumbnail when we regenerate the small one + mBigThumbnailUpToDate = FALSE; + if(mThumbnailImage) { resetThumbnailImage() ; @@ -602,6 +608,55 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update) mThumbnailUpdateLock = FALSE ; } +LLViewerTexture* LLSnapshotLivePreview::getBigThumbnailImage() +{ + if (mThumbnailUpdateLock) //in the process of updating + { + return NULL; + } + if (mBigThumbnailUpToDate && mBigThumbnailImage)//already updated + { + return mBigThumbnailImage; + } + + LLPointer<LLImageRaw> raw = new LLImageRaw; + + // The big thumbnail is be a subsampled version of the preview (used in SL Share previews, i.e. Flickr, Twitter, Facebook) + raw->resize( mPreviewImage->getWidth(), + mPreviewImage->getHeight(), + mPreviewImage->getComponents()); + raw->copy(mPreviewImage); + // Scale to the big thumbnail size + if (!raw->scale(getBigThumbnailWidth(), getBigThumbnailHeight())) + { + raw = NULL ; + } + + if (raw) + { + // Filter + // Note: filtering needs to be done *before* the scaling to power of 2 or the effect is distorted + if (getFilter() != "") + { + std::string filter_path = LLImageFiltersManager::getInstance()->getFilterPath(getFilter()); + if (filter_path != "") + { + LLImageFilter filter(filter_path); + filter.executeFilter(raw); + } + else + { + llwarns << "Couldn't find a path to the following filter : " << getFilter() << llendl; + } + } + // Scale to a power of 2 so it can be mapped to a texture + raw->expandToPowerOfTwo(); + mBigThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); + mBigThumbnailUpToDate = TRUE ; + } + + return mBigThumbnailImage ; +} // Called often. Checks whether it's time to grab a new snapshot and if so, does it. // Returns TRUE if new snapshot generated, FALSE otherwise. diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h index 7f3e7a080b..0e918d165e 100644 --- a/indra/newview/llsnapshotlivepreview.h +++ b/indra/newview/llsnapshotlivepreview.h @@ -28,6 +28,7 @@ #define LL_LLSNAPSHOTLIVEPREVIEW_H #include "llpanelsnapshot.h" +#include "llviewertexture.h" #include "llviewerwindow.h" class LLImageJPEG; @@ -113,13 +114,18 @@ public: LLPointer<LLImageFormatted> getFormattedImage(); LLPointer<LLImageRaw> getEncodedImage(); - /// Sets size of preview thumbnail image and thhe surrounding rect. + /// Sets size of preview thumbnail image and the surrounding rect. void setThumbnailPlaceholderRect(const LLRect& rect) {mThumbnailPlaceholderRect = rect; } BOOL setThumbnailImageSize() ; void generateThumbnailImage(BOOL force_update = FALSE) ; void resetThumbnailImage() { mThumbnailImage = NULL ; } void drawPreviewRect(S32 offset_x, S32 offset_y) ; + + LLViewerTexture* getBigThumbnailImage(); + S32 getBigThumbnailWidth() const { return 3*mThumbnailWidth ; } + S32 getBigThumbnailHeight() const { return 3*mThumbnailHeight ; } + // Returns TRUE when snapshot generated, FALSE otherwise. static BOOL onIdle( void* snapshot_preview ); @@ -145,7 +151,10 @@ private: BOOL mThumbnailUpdateLock ; BOOL mThumbnailUpToDate ; LLRect mThumbnailPlaceholderRect; - BOOL mThumbnailSubsampled; // TRUE is the thumbnail is a subsampled version of the mPreviewImage + BOOL mThumbnailSubsampled; // TRUE if the thumbnail is a subsampled version of the mPreviewImage + + LLPointer<LLViewerTexture> mBigThumbnailImage ; + BOOL mBigThumbnailUpToDate; S32 mCurImageIndex; // The logic is mPreviewImage (raw frame) -> mFormattedImage (formatted / filtered) -> mPreviewImageEncoded (decoded back, to show artifacts) diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 1f25110aa3..982522955c 100755 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -38,6 +38,7 @@ #include "llfloateravatar.h" #include "llfloateravatarpicker.h" #include "llfloateravatartextures.h" +#include "llfloaterbigpreview.h" #include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" #include "llfloaterbuy.h" @@ -324,6 +325,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("facebook", "floater_facebook.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFacebook>); LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFlickr>); LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTwitter>); + LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBigPreview>); LLFloaterUIPreviewUtil::registerFloater(); LLFloaterReg::add("upload_anim_bvh", "floater_animation_bvh_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBvhPreview>, "upload"); diff --git a/indra/newview/skins/default/xui/en/floater_big_preview.xml b/indra/newview/skins/default/xui/en/floater_big_preview.xml new file mode 100644 index 0000000000..c0bdd3d9bd --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_big_preview.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<floater + positioning="cascading" + can_close="true" + can_resize="true" + can_minimize="false" + help_topic="floater_big_preview" + layout="topleft" + name="floater_big_preview" + save_rect="true" + single_instance="true" + reuse_instance="true" + title="PREVIEW" + height="465" + width="770"> + <panel + height="450" + width="750" + visible="true" + name="big_preview_placeholder" + top="5" + follows="all" + left="10"> + </panel> +</floater> diff --git a/indra/newview/skins/default/xui/en/panel_facebook_photo.xml b/indra/newview/skins/default/xui/en/panel_facebook_photo.xml index 0cde43a20c..1d826fdbe1 100644 --- a/indra/newview/skins/default/xui/en/panel_facebook_photo.xml +++ b/indra/newview/skins/default/xui/en/panel_facebook_photo.xml @@ -86,7 +86,7 @@ text_color="EmphasisColor" height="14" top_pad="-19" - left_pad="-20" + left_pad="-30" length="1" halign="center" name="working_lbl" @@ -96,6 +96,20 @@ width="150"> Refreshing... </text> + <button + follows="right|top" + height="23" + label="Preview" + left="200" + top_pad="-19" + name="big_preview_btn" + tool_tip="Click to toggle preview" + is_toggle="true" + visible="true" + width="100" > + <button.commit_callback + function="SocialSharing.BigPreview" /> + </button> <text length="1" follows="top|left|right" diff --git a/indra/newview/skins/default/xui/en/panel_flickr_photo.xml b/indra/newview/skins/default/xui/en/panel_flickr_photo.xml index 4516c01670..8d8ef45c0d 100644 --- a/indra/newview/skins/default/xui/en/panel_flickr_photo.xml +++ b/indra/newview/skins/default/xui/en/panel_flickr_photo.xml @@ -82,7 +82,7 @@ text_color="EmphasisColor" height="14" top_pad="-19" - left_pad="-20" + left_pad="-30" length="1" halign="center" name="working_lbl" @@ -92,6 +92,20 @@ width="150"> Refreshing... </text> + <button + follows="right|top" + height="23" + label="Preview" + left="200" + top_pad="-19" + name="big_preview_btn" + tool_tip="Click to toggle preview" + is_toggle="true" + visible="true" + width="100" > + <button.commit_callback + function="SocialSharing.BigPreview" /> + </button> <text length="1" follows="top|left|right" @@ -99,7 +113,7 @@ height="16" left="9" name="title_label" - top_pad="20" + top_pad="15" type="string"> Title: </text> diff --git a/indra/newview/skins/default/xui/en/panel_twitter_photo.xml b/indra/newview/skins/default/xui/en/panel_twitter_photo.xml index bcec09ebab..c2be56da21 100644 --- a/indra/newview/skins/default/xui/en/panel_twitter_photo.xml +++ b/indra/newview/skins/default/xui/en/panel_twitter_photo.xml @@ -138,7 +138,7 @@ text_color="EmphasisColor" height="14" top_pad="-19" - left_pad="-20" + left_pad="-30" length="1" halign="center" name="working_lbl" @@ -148,6 +148,20 @@ width="150"> Refreshing... </text> + <button + follows="right|top" + height="23" + label="Preview" + left="200" + top_pad="-19" + name="big_preview_btn" + tool_tip="Click to toggle preview" + is_toggle="true" + visible="true" + width="100" > + <button.commit_callback + function="SocialSharing.BigPreview" /> + </button> </layout_panel> <layout_panel name="photo_button_panel" |