From d220657d8525ccfa246e0f49904e18cc36458b28 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 25 Feb 2014 21:54:09 -0800 Subject: ACME-1327 : WIP : Added big preview to the Flickr photo panel, uses the thumbnail for the moment --- indra/newview/llfloaterbigpreview.cpp | 109 ++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 indra/newview/llfloaterbigpreview.cpp (limited to 'indra/newview/llfloaterbigpreview.cpp') diff --git a/indra/newview/llfloaterbigpreview.cpp b/indra/newview/llfloaterbigpreview.cpp new file mode 100644 index 0000000000..84a1523e7c --- /dev/null +++ b/indra/newview/llfloaterbigpreview.cpp @@ -0,0 +1,109 @@ +/** +* @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 "llfloaterreg.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 (floaterp == mFloaterOwner) + { + closeFloater(); + } +} + +BOOL LLFloaterBigPreview::postBuild() +{ + mPreviewPlaceholder = getChild("big_preview_placeholder"); + return LLFloater::postBuild(); +} + +void LLFloaterBigPreview::draw() +{ + LLFloater::draw(); + + LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); + + // Display the preview if one is available + // HACK!!! We use the puny thumbnail image for the moment + // *TODO : Use the real large preview + if (previewp && previewp->getThumbnailImage()) + { + const LLRect& preview_rect = mPreviewPlaceholder->getRect(); +// const S32 thumbnail_w = previewp->getThumbnailWidth(); +// const S32 thumbnail_h = previewp->getThumbnailHeight(); + + // calc preview offset within the preview rect +// const S32 local_offset_x = (preview_rect.getWidth() - thumbnail_w) / 2 ; +// const S32 local_offset_y = (preview_rect.getHeight() - thumbnail_h) / 2 ; + const S32 local_offset_x = 0 ; + const S32 local_offset_y = 0 ; + + // calc preview offset within the floater rect + S32 offset_x = preview_rect.mLeft + local_offset_x; + S32 offset_y = preview_rect.mBottom + local_offset_y; + + //llinfos << "Merov : draw, offset x = " << offset_x << ", y = " << offset_y << ", thumbnail w = " << thumbnail_w << ", h = " << thumbnail_h << ", rect w = " << preview_rect.getWidth() << ", h = " << preview_rect.getHeight() << llendl; + + 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; + gl_draw_scaled_image(offset_x, offset_y, + //thumbnail_w, thumbnail_h, + preview_rect.getWidth(), preview_rect.getHeight(), + previewp->getThumbnailImage(), color % alpha); + } +} + -- cgit v1.2.3 From 6dfcd7fc2bd0f502673c43f1a54cda2a8d74e391 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 25 Feb 2014 23:01:52 -0800 Subject: ACME-1327 : WIP : Added computation of the big preview, allow big preview to be resizable --- indra/newview/llfloaterbigpreview.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfloaterbigpreview.cpp') diff --git a/indra/newview/llfloaterbigpreview.cpp b/indra/newview/llfloaterbigpreview.cpp index 84a1523e7c..d5f25d5f95 100644 --- a/indra/newview/llfloaterbigpreview.cpp +++ b/indra/newview/llfloaterbigpreview.cpp @@ -78,7 +78,7 @@ void LLFloaterBigPreview::draw() // Display the preview if one is available // HACK!!! We use the puny thumbnail image for the moment // *TODO : Use the real large preview - if (previewp && previewp->getThumbnailImage()) + if (previewp && previewp->getBigThumbnailImage()) { const LLRect& preview_rect = mPreviewPlaceholder->getRect(); // const S32 thumbnail_w = previewp->getThumbnailWidth(); @@ -93,9 +93,7 @@ void LLFloaterBigPreview::draw() // calc preview offset within the floater rect S32 offset_x = preview_rect.mLeft + local_offset_x; S32 offset_y = preview_rect.mBottom + local_offset_y; - - //llinfos << "Merov : draw, offset x = " << offset_x << ", y = " << offset_y << ", thumbnail w = " << thumbnail_w << ", h = " << thumbnail_h << ", rect w = " << preview_rect.getWidth() << ", h = " << preview_rect.getHeight() << llendl; - + gGL.matrixMode(LLRender::MM_MODELVIEW); // Apply floater transparency to the texture unless the floater is focused. F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); @@ -103,7 +101,7 @@ void LLFloaterBigPreview::draw() gl_draw_scaled_image(offset_x, offset_y, //thumbnail_w, thumbnail_h, preview_rect.getWidth(), preview_rect.getHeight(), - previewp->getThumbnailImage(), color % alpha); + previewp->getBigThumbnailImage(), color % alpha); } } -- cgit v1.2.3 From ed38a0aede09f42c4fe7eb4dd53ecd6490d12ca0 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 26 Feb 2014 17:22:16 -0800 Subject: ACME-1327 : WIP : Make rescale of preview isotropic, make preview button a toggle --- indra/newview/llfloaterbigpreview.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'indra/newview/llfloaterbigpreview.cpp') diff --git a/indra/newview/llfloaterbigpreview.cpp b/indra/newview/llfloaterbigpreview.cpp index d5f25d5f95..b516e9dd01 100644 --- a/indra/newview/llfloaterbigpreview.cpp +++ b/indra/newview/llfloaterbigpreview.cpp @@ -28,8 +28,6 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterbigpreview.h" - -#include "llfloaterreg.h" #include "llsnapshotlivepreview.h" /////////////////////// @@ -57,7 +55,7 @@ void LLFloaterBigPreview::onCancel() void LLFloaterBigPreview::closeOnFloaterOwnerClosing(LLFloater* floaterp) { - if (floaterp == mFloaterOwner) + if (isFloaterOwner(floaterp)) { closeFloater(); } @@ -76,21 +74,25 @@ void LLFloaterBigPreview::draw() LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); // Display the preview if one is available - // HACK!!! We use the puny thumbnail image for the moment - // *TODO : Use the real large preview if (previewp && previewp->getBigThumbnailImage()) { + // Get the preview rect const LLRect& preview_rect = mPreviewPlaceholder->getRect(); -// const S32 thumbnail_w = previewp->getThumbnailWidth(); -// const S32 thumbnail_h = previewp->getThumbnailHeight(); - // calc preview offset within the preview rect -// const S32 local_offset_x = (preview_rect.getWidth() - thumbnail_w) / 2 ; -// const S32 local_offset_y = (preview_rect.getHeight() - thumbnail_h) / 2 ; - const S32 local_offset_x = 0 ; - const S32 local_offset_y = 0 ; + // 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); - // calc preview offset within the floater rect + // 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; @@ -98,9 +100,10 @@ void LLFloaterBigPreview::draw() // 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, - preview_rect.getWidth(), preview_rect.getHeight(), + thumbnail_w, thumbnail_h, previewp->getBigThumbnailImage(), color % alpha); } } -- cgit v1.2.3