summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorGilbert Gonzales <gilbert@lindenlab.com>2013-06-24 17:33:10 -0700
committerGilbert Gonzales <gilbert@lindenlab.com>2013-06-24 17:33:10 -0700
commit48cc41a0f8b7b2473e938b1cac8cd294b71d40f7 (patch)
tree1af32b9bc87446a23c716a6df64b4caa89dfb19b /indra
parent3fa5ac310c9eb3ace9f5eac70e68f7588a846309 (diff)
ACME-593: Now the photo tab of the facebook panel displays a screenshot based upon when the facebook floater was opened.
Diffstat (limited to 'indra')
-rwxr-xr-xindra/newview/llfloatersnapshot.cpp10
-rw-r--r--indra/newview/llfloatersocial.cpp138
-rw-r--r--indra/newview/llfloatersocial.h24
-rw-r--r--indra/newview/llsnapshotlivepreview.cpp2
-rw-r--r--indra/newview/llsnapshotlivepreview.h2
-rw-r--r--indra/newview/skins/default/xui/en/floater_social.xml34
6 files changed, 188 insertions, 22 deletions
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index e72de9751e..65934aa82a 100755
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -38,6 +38,7 @@
#include "llfloaterperms.h"
#include "llui.h"
#include "llfacebookconnect.h"
+#include "llfloatersocial.h"
#include "llfocusmgr.h"
#include "llbutton.h"
#include "llcombobox.h"
@@ -1136,6 +1137,9 @@ BOOL LLFloaterSnapshot::postBuild()
impl.updateControls(this);
impl.updateLayout(this);
+
+ previewp->setThumbnailPlaceholderRect(getThumbnailPlaceholderRect());
+
return TRUE;
}
@@ -1301,7 +1305,9 @@ S32 LLFloaterSnapshot::notify(const LLSD& info)
void LLFloaterSnapshot::update()
{
LLFloaterSnapshot* inst = LLFloaterReg::findTypedInstance<LLFloaterSnapshot>("snapshot");
- if (!inst)
+ LLFloaterSocial* floater_social = LLFloaterReg::findTypedInstance<LLFloaterSocial>("social");
+
+ if (!inst && !floater_social)
return;
BOOL changed = FALSE;
@@ -1320,7 +1326,7 @@ void LLFloaterSnapshot::update()
changed = true;
}
- if (changed)
+ if (inst && changed)
{
lldebugs << "changed" << llendl;
inst->impl.updateControls(inst);
diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp
index cca966bb9a..9a63a7de78 100644
--- a/indra/newview/llfloatersocial.cpp
+++ b/indra/newview/llfloatersocial.cpp
@@ -49,11 +49,131 @@ std::string get_map_url()
return map_url;
}
-LLSocialPhotoPanel::LLSocialPhotoPanel()
+LLSocialPhotoPanel::LLSocialPhotoPanel() :
+mRefreshBtn(NULL),
+mRefreshLabel(NULL),
+mSucceessLblPanel(NULL),
+mFailureLblPanel(NULL),
+mThumbnailPlaceholder(NULL)
{
mCommitCallbackRegistrar.add("PostToFacebook.Send", boost::bind(&LLSocialPhotoPanel::onSend, this));
}
+
+
+LLSocialPhotoPanel::~LLSocialPhotoPanel()
+{
+ if(mPreviewHandle.get())
+ {
+ mPreviewHandle.get()->die();
+ }
+}
+
+BOOL LLSocialPhotoPanel::postBuild()
+{
+ mRefreshBtn = getChild<LLUICtrl>("new_snapshot_btn");
+ childSetAction("new_snapshot_btn", boost::bind(&LLSocialPhotoPanel::onClickNewSnapshot, this));
+ mRefreshLabel = getChild<LLUICtrl>("refresh_lbl");
+ mSucceessLblPanel = getChild<LLUICtrl>("succeeded_panel");
+ mFailureLblPanel = getChild<LLUICtrl>("failed_panel");
+ mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder");
+
+ LLRect full_screen_rect = getRootView()->getRect();
+ LLSnapshotLivePreview::Params p;
+ p.rect(full_screen_rect);
+ LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p);
+ mPreviewHandle = previewp->getHandle();
+
+ previewp->setThumbnailPlaceholderRect(getThumbnailPlaceholderRect());
+
+ return LLPanel::postBuild();
+}
+
+void LLSocialPhotoPanel::onClickNewSnapshot()
+{
+ LLSnapshotLivePreview* previewp = static_cast<LLSnapshotLivePreview*>(mPreviewHandle.get());
+ //LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
+ if (previewp /*&& view*/)
+ {
+ //view->impl.setStatus(Impl::STATUS_READY);
+ lldebugs << "updating snapshot" << llendl;
+ previewp->updateSnapshot(TRUE);
+ }
+}
+
+void LLSocialPhotoPanel::draw()
+{
+ LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
+
+ LLPanel::draw();
+
+ if(previewp && previewp->getThumbnailImage())
+ {
+ bool working = false; //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;
+
+ LLUICtrl * snapshot_panel = getChild<LLUICtrl>("snapshot_panel");
+ snapshot_panel->localPointToOtherView(offset_x, offset_y, &offset_x, &offset_y, gFloaterView->getParentFloater(this));
+
+ 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) ;
+
+ // Draw some controls on top of the preview thumbnail.
+ static const S32 PADDING = 5;
+ static const S32 REFRESH_LBL_BG_HEIGHT = 32;
+
+ // Reshape and position the posting result message panels at the top of the thumbnail.
+ // Do this regardless of current posting status (finished or not) to avoid flicker
+ // when the result message is displayed for the first time.
+ // if (impl.getStatus() == Impl::STATUS_FINISHED)
+ {
+ LLRect result_lbl_rect = mSucceessLblPanel->getRect();
+ const S32 result_lbl_h = result_lbl_rect.getHeight();
+ result_lbl_rect.setLeftTopAndSize(local_offset_x, local_offset_y + thumbnail_h, thumbnail_w - 1, result_lbl_h);
+ mSucceessLblPanel->reshape(result_lbl_rect.getWidth(), result_lbl_h);
+ mSucceessLblPanel->setRect(result_lbl_rect);
+ mFailureLblPanel->reshape(result_lbl_rect.getWidth(), result_lbl_h);
+ mFailureLblPanel->setRect(result_lbl_rect);
+ }
+
+ // Position the refresh button in the bottom left corner of the thumbnail.
+ mRefreshBtn->setOrigin(local_offset_x + PADDING, local_offset_y + PADDING);
+
+ if (/*impl.mNeedRefresh*/false)
+ {
+ // Place the refresh hint text to the right of the refresh button.
+ const LLRect& refresh_btn_rect = mRefreshBtn->getRect();
+ mRefreshLabel->setOrigin(refresh_btn_rect.mLeft + refresh_btn_rect.getWidth() + PADDING, refresh_btn_rect.mBottom);
+
+ // Draw the refresh hint background.
+ LLRect refresh_label_bg_rect(offset_x, offset_y + REFRESH_LBL_BG_HEIGHT, offset_x + thumbnail_w - 1, offset_y);
+ gl_rect_2d(refresh_label_bg_rect, LLColor4::white % 0.9f, TRUE);
+ }
+
+ gGL.pushUIMatrix();
+ LLUI::translate((F32) thumbnail_rect.mLeft, (F32) thumbnail_rect.mBottom);
+ mThumbnailPlaceholder->draw();
+ gGL.popUIMatrix();
+ }
+}
+
void LLSocialPhotoPanel::onSend()
{
std::string caption = getChild<LLUICtrl>("caption")->getValue().asString();
@@ -124,7 +244,9 @@ void LLSocialCheckinPanel::onSend()
}
-LLFloaterSocial::LLFloaterSocial(const LLSD& key) : LLFloater(key)
+LLFloaterSocial::LLFloaterSocial(const LLSD& key) :
+LLFloater(key),
+mSocialPhotoPanel(NULL)
{
mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterSocial::onCancel, this));
}
@@ -136,5 +258,17 @@ void LLFloaterSocial::onCancel()
BOOL LLFloaterSocial::postBuild()
{
+ mSocialPhotoPanel = static_cast<LLSocialPhotoPanel*>(getChild<LLUICtrl>("social_photo_tab"));
+
return LLFloater::postBuild();
}
+
+void LLFloaterSocial::onOpen(const LLSD& key)
+{
+ LLSnapshotLivePreview* preview = static_cast<LLSnapshotLivePreview *>(mSocialPhotoPanel->mPreviewHandle.get());
+ if(preview)
+ {
+ lldebugs << "opened, updating snapshot" << llendl;
+ preview->updateSnapshot(TRUE);
+ }
+}
diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h
index aee7f2f060..118eaf17d7 100644
--- a/indra/newview/llfloatersocial.h
+++ b/indra/newview/llfloatersocial.h
@@ -29,11 +29,28 @@
#include "llfloater.h"
+#include "llsnapshotlivepreview.h"
+
class LLSocialPhotoPanel : public LLPanel
{
- public:
+
+public:
LLSocialPhotoPanel();
+ ~LLSocialPhotoPanel();
+
+ BOOL postBuild();
+ void draw();
void onSend();
+
+ const LLRect& getThumbnailPlaceholderRect() { return mThumbnailPlaceholder->getRect(); }
+ void onClickNewSnapshot();
+
+ LLHandle<LLView> mPreviewHandle;
+
+private:
+ LLUICtrl *mRefreshBtn, *mRefreshLabel;
+ LLUICtrl *mSucceessLblPanel, *mFailureLblPanel;
+ LLUICtrl* mThumbnailPlaceholder;
};
class LLSocialCheckinPanel : public LLPanel
@@ -52,6 +69,11 @@ public:
LLFloaterSocial(const LLSD& key);
BOOL postBuild();
void onCancel();
+ void onOpen(const LLSD& key);
+
+private:
+
+ LLSocialPhotoPanel * mSocialPhotoPanel;
};
#endif // LL_LLFLOATERSOCIAL_H
diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp
index 5dab804c71..7bae7c90ed 100644
--- a/indra/newview/llsnapshotlivepreview.cpp
+++ b/indra/newview/llsnapshotlivepreview.cpp
@@ -454,7 +454,7 @@ BOOL LLSnapshotLivePreview::setThumbnailImageSize()
// UI size for thumbnail
// *FIXME: the rect does not change, so maybe there's no need to recalculate max w/h.
- const LLRect& thumbnail_rect = LLFloaterSnapshot::getThumbnailPlaceholderRect();
+ const LLRect& thumbnail_rect = mThumbnailPlaceholderRect;
S32 max_width = thumbnail_rect.getWidth();
S32 max_height = thumbnail_rect.getHeight();
diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h
index 52cd87ea9f..906ef7f1c1 100644
--- a/indra/newview/llsnapshotlivepreview.h
+++ b/indra/newview/llsnapshotlivepreview.h
@@ -156,6 +156,7 @@ public:
LLPointer<LLImageRaw> getEncodedImage() const { return mPreviewImageEncoded; }
/// Sets size of preview thumbnail image and thhe surrounding rect.
+ void setThumbnailPlaceholderRect(const LLRect& rect) {mThumbnailPlaceholderRect = rect; }
BOOL setThumbnailImageSize() ;
void generateThumbnailImage(BOOL force_update = FALSE) ;
void resetThumbnailImage() { mThumbnailImage = NULL ; }
@@ -183,6 +184,7 @@ private:
LLRect mPreviewRect ;
BOOL mThumbnailUpdateLock ;
BOOL mThumbnailUpToDate ;
+ LLRect mThumbnailPlaceholderRect;
S32 mCurImageIndex;
LLPointer<LLImageRaw> mPreviewImage;
diff --git a/indra/newview/skins/default/xui/en/floater_social.xml b/indra/newview/skins/default/xui/en/floater_social.xml
index f99044b233..dc505fb200 100644
--- a/indra/newview/skins/default/xui/en/floater_social.xml
+++ b/indra/newview/skins/default/xui/en/floater_social.xml
@@ -149,12 +149,12 @@
1,031 KB
</text>
<ui_ctrl
- height="150"
- width="250"
- name="thumbnail_placeholder"
- top_pad="5"
- follows="left|top"
- left="9">
+ height="150"
+ width="250"
+ name="thumbnail_placeholder"
+ top_pad="5"
+ follows="left|top"
+ left="9">
<panel
background_visible="true"
bg_alpha_color="0.9 1 0.9 1"
@@ -168,7 +168,7 @@
right="-1"
top="0"
type="string"
- visible="true">
+ visible="false">
<text
follows="all"
font="SansSerif"
@@ -198,7 +198,7 @@
right="-1"
top="0"
type="string"
- visible="true">
+ visible="false">
<text
follows="all"
font="SansSerif"
@@ -221,7 +221,7 @@
name="working_indicator"
left="101"
top="46"
- visible="true"
+ visible="false"
width="48" />
<text
follows="left|top|right"
@@ -235,7 +235,7 @@
top="98"
translate="false"
type="string"
- visible="true"
+ visible="false"
width="130">
Working
</text>
@@ -243,23 +243,25 @@
follows="left|top"
height="22"
image_overlay="Refresh_Off"
- left="6"
+ left="20"
name="new_snapshot_btn"
- bottom="-6"
- visible="true"
+ bottom="-20"
+ visible="false"
width="22" />
<text
follows="left|top"
font="SansSerifBold"
+ halign="left"
height="18"
- left_pad="6"
+ left_pad="10"
length="1"
name="refresh_lbl"
+ right="-5"
text_color="red"
- top_delta="5"
+ top_delta="0"
translate="false"
type="string"
- visible="true"
+ visible="false"
width="130">
Refresh to save.
</text>