From 48cc41a0f8b7b2473e938b1cac8cd294b71d40f7 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Mon, 24 Jun 2013 17:33:10 -0700 Subject: ACME-593: Now the photo tab of the facebook panel displays a screenshot based upon when the facebook floater was opened. --- indra/newview/llfloatersocial.cpp | 138 +++++++++++++++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatersocial.cpp') 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("new_snapshot_btn"); + childSetAction("new_snapshot_btn", boost::bind(&LLSocialPhotoPanel::onClickNewSnapshot, this)); + mRefreshLabel = getChild("refresh_lbl"); + mSucceessLblPanel = getChild("succeeded_panel"); + mFailureLblPanel = getChild("failed_panel"); + mThumbnailPlaceholder = getChild("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(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(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("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("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(getChild("social_photo_tab")); + return LLFloater::postBuild(); } + +void LLFloaterSocial::onOpen(const LLSD& key) +{ + LLSnapshotLivePreview* preview = static_cast(mSocialPhotoPanel->mPreviewHandle.get()); + if(preview) + { + lldebugs << "opened, updating snapshot" << llendl; + preview->updateSnapshot(TRUE); + } +} -- cgit v1.3 From 4441edecdf27b9324b61d9e415c257e50e4909a6 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Tue, 25 Jun 2013 10:54:59 -0700 Subject: ACME-587 Add the 'refresh' button on top the image --- indra/newview/llfloatersocial.cpp | 181 ++++++++++++++++++++- indra/newview/llfloatersocial.h | 17 +- indra/newview/llsnapshotlivepreview.cpp | 4 +- .../skins/default/xui/en/floater_social.xml | 6 +- 4 files changed, 199 insertions(+), 9 deletions(-) (limited to 'indra/newview/llfloatersocial.cpp') diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index fe5c324d0b..f2110e09c1 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -42,6 +42,8 @@ static LLRegisterPanelClassWrapper t_panel_status("llsocial static LLRegisterPanelClassWrapper t_panel_photo("llsocialphotopanel"); static LLRegisterPanelClassWrapper t_panel_checkin("llsocialcheckinpanel"); +const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte + std::string get_map_url() { LLVector3d center_agent; @@ -94,6 +96,8 @@ LLSocialPhotoPanel::~LLSocialPhotoPanel() BOOL LLSocialPhotoPanel::postBuild() { + mResolutionComboBox = getChild("resolution_combobox"); + mResolutionComboBox->setCommitCallback(boost::bind(&LLSocialPhotoPanel::onResolutionComboCommit, this)); mRefreshBtn = getChild("new_snapshot_btn"); childSetAction("new_snapshot_btn", boost::bind(&LLSocialPhotoPanel::onClickNewSnapshot, this)); mRefreshLabel = getChild("refresh_lbl"); @@ -112,6 +116,12 @@ BOOL LLSocialPhotoPanel::postBuild() return LLPanel::postBuild(); } +void LLSocialPhotoPanel::onResolutionComboCommit() +{ + LLFloaterSocial* instance = LLFloaterReg::findTypedInstance("social"); + updateResolution(mResolutionComboBox, instance); +} + void LLSocialPhotoPanel::onClickNewSnapshot() { LLSnapshotLivePreview* previewp = static_cast(mPreviewHandle.get()); @@ -124,6 +134,131 @@ void LLSocialPhotoPanel::onClickNewSnapshot() } } +void LLSocialPhotoPanel::updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update) +{ + LLComboBox* combobox = (LLComboBox*)ctrl; + LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; + + if (!view || !combobox) + { + llassert(view && combobox); + return; + } + + std::string sdstring = combobox->getSelectedValue(); + LLSD sdres; + std::stringstream sstream(sdstring); + LLSDSerialize::fromNotation(sdres, sstream, sdstring.size()); + + S32 width = sdres[0]; + S32 height = sdres[1]; + + LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); + if (previewp && combobox->getCurrentIndex() >= 0) + { + S32 original_width = 0 , original_height = 0 ; + previewp->getSize(original_width, original_height) ; + + if (width == 0 || height == 0) + { + // take resolution from current window size + lldebugs << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << llendl; + previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()); + } + else + { + // use the resolution from the selected pre-canned drop-down choice + lldebugs << "Setting preview res selected from combo: " << width << "x" << height << llendl; + previewp->setSize(width, height); + } + + checkAspectRatio(view, width) ; + + previewp->getSize(width, height); + + if(original_width != width || original_height != height) + { + previewp->setSize(width, height); + + // hide old preview as the aspect ratio could be wrong + lldebugs << "updating thumbnail" << llendl; + + previewp->updateSnapshot(FALSE, TRUE); + if(do_update) + { + lldebugs << "Will update controls" << llendl; + updateControls(); + setNeedRefresh(true); + } + } + + } +} + +void LLSocialPhotoPanel::setNeedRefresh(bool need) +{ + mRefreshLabel->setVisible(need); + mNeedRefresh = need; +} + +void LLSocialPhotoPanel::checkAspectRatio(LLFloaterSnapshot *view, S32 index) +{ + LLSnapshotLivePreview *previewp = getPreviewView() ; + + BOOL keep_aspect = FALSE; + + if (0 == index) // current window size + { + keep_aspect = TRUE; + } + else // predefined resolution + { + keep_aspect = FALSE; + } + + if (previewp) + { + previewp->mKeepAspectRatio = keep_aspect; + } +} + +LLSnapshotLivePreview* LLSocialPhotoPanel::getPreviewView() +{ + LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get(); + return previewp; +} + + +void LLSocialPhotoPanel::updateControls() +{ + + + LLSnapshotLivePreview* previewp = getPreviewView(); + BOOL got_bytes = previewp && previewp->getDataSize() > 0; + BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); + + // *TODO: Separate maximum size for Web images from postcards + lldebugs << "Is snapshot up-to-date? " << got_snap << llendl; + + LLLocale locale(LLLocale::USER_LOCALE); + std::string bytes_string; + if (got_snap) + { + LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); + } + + //getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : getString("unknown")); + getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : "unknown"); + getChild("file_size_label")->setColor( + true + && got_bytes + && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" )); + + LLComboBox* combo = getChild("resolution_combobox"); + LLFloaterSocial* instance = LLFloaterReg::findTypedInstance("social"); + updateResolution(combo, instance, FALSE); +} + void LLSocialPhotoPanel::draw() { LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); @@ -179,7 +314,7 @@ void LLSocialPhotoPanel::draw() // 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) + if (mNeedRefresh) { // Place the refresh hint text to the right of the refresh button. const LLRect& refresh_btn_rect = mRefreshBtn->getRect(); @@ -191,7 +326,11 @@ void LLSocialPhotoPanel::draw() } gGL.pushUIMatrix(); - LLUI::translate((F32) thumbnail_rect.mLeft, (F32) thumbnail_rect.mBottom); + S32 x_pos; + S32 y_pos; + snapshot_panel->localPointToOtherView(thumbnail_rect.mLeft, thumbnail_rect.mBottom, &x_pos, &y_pos, gFloaterView->getParentFloater(this)); + + LLUI::translate((F32) x_pos, (F32) y_pos); mThumbnailPlaceholder->draw(); gGL.popUIMatrix(); } @@ -313,3 +452,41 @@ void LLFloaterSocial::onOpen(const LLSD& key) preview->updateSnapshot(TRUE); } } + +// static +void LLFloaterSocial::preUpdate() +{ + // FIXME: duplicated code + LLFloaterSocial* instance = LLFloaterReg::findTypedInstance("social"); + if (instance) + { + // Disable the send/post/save buttons until snapshot is ready. + instance->mSocialPhotoPanel->updateControls(); + + // Force hiding the "Refresh to save" hint because we know we've just started refresh. + instance->mSocialPhotoPanel->setNeedRefresh(false); + } +} + +// static +void LLFloaterSocial::postUpdate() +{ + // FIXME: duplicated code + LLFloaterSocial* instance = LLFloaterReg::findTypedInstance("social"); + if (instance) + { + // Enable the send/post/save buttons. + instance->mSocialPhotoPanel->updateControls(); + + // We've just done refresh. + instance->mSocialPhotoPanel->setNeedRefresh(false); + + // The refresh button is initially hidden. We show it after the first update, + // i.e. when preview appears. + if (!instance->mSocialPhotoPanel->mRefreshBtn->getVisible()) + { + instance->mSocialPhotoPanel->mRefreshBtn->setVisible(true); + } + + } +} diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h index a08bbb99ad..7b8db2d64a 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -51,14 +51,24 @@ class LLSocialPhotoPanel : public LLPanel void onSend(); const LLRect& getThumbnailPlaceholderRect() { return mThumbnailPlaceholder->getRect(); } + void onResolutionComboCommit(); void onClickNewSnapshot(); LLHandle mPreviewHandle; -private: + void updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update = TRUE); + void setNeedRefresh(bool need); + void checkAspectRatio(LLFloaterSnapshot *view, S32 index); + LLSnapshotLivePreview* getPreviewView(); + + void updateControls(); + + LLUICtrl * mResolutionComboBox; LLUICtrl *mRefreshBtn, *mRefreshLabel; LLUICtrl *mSucceessLblPanel, *mFailureLblPanel; LLUICtrl* mThumbnailPlaceholder; + + bool mNeedRefresh; }; class LLSocialCheckinPanel : public LLPanel @@ -76,6 +86,11 @@ public: void onCancel(); void onOpen(const LLSD& key); /*virtual*/ void draw(); + + + static void preUpdate(); + static void postUpdate(); + private: LLSocialPhotoPanel * mSocialPhotoPanel; std::string mMapUrl; diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 7bae7c90ed..70c0584231 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -29,7 +29,7 @@ #include "llsnapshotlivepreview.h" - +#include "llfloatersocial.h" const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; @@ -186,6 +186,7 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail mSnapshotDelayTimer.start(); mSnapshotDelayTimer.setTimerExpirySec(delay); LLFloaterSnapshot::preUpdate(); + LLFloaterSocial::preUpdate(); } // Update thumbnail if requested. @@ -742,6 +743,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) } lldebugs << "done creating snapshot" << llendl; LLFloaterSnapshot::postUpdate(); + LLFloaterSocial::postUpdate(); return TRUE; } diff --git a/indra/newview/skins/default/xui/en/floater_social.xml b/indra/newview/skins/default/xui/en/floater_social.xml index 5c910ad986..1ae8f7ed65 100644 --- a/indra/newview/skins/default/xui/en/floater_social.xml +++ b/indra/newview/skins/default/xui/en/floater_social.xml @@ -131,10 +131,6 @@ label="1024x768" name="1024x768" value="[i1024,i768]" /> - - 1,031 KB + [SIZE] KB Date: Tue, 25 Jun 2013 19:49:13 +0100 Subject: made status update post button disabled for ACME-571 --- indra/newview/llfloatersocial.cpp | 45 +++++++++++++++++----- indra/newview/llfloatersocial.h | 6 +++ .../skins/default/xui/en/floater_social.xml | 4 +- 3 files changed, 43 insertions(+), 12 deletions(-) (limited to 'indra/newview/llfloatersocial.cpp') diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index f2110e09c1..92a291e51c 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -57,21 +57,48 @@ std::string get_map_url() return map_url; } -LLSocialStatusPanel::LLSocialStatusPanel() +LLSocialStatusPanel::LLSocialStatusPanel() : + mMessageTextEditor(NULL), + mPostStatusButton(NULL) { mCommitCallbackRegistrar.add("SocialSharing.SendStatus", boost::bind(&LLSocialStatusPanel::onSend, this)); } +BOOL LLSocialStatusPanel::postBuild() +{ + mMessageTextEditor = getChild("status_message"); + mPostStatusButton = getChild("post_status_btn"); + + return LLPanel::postBuild(); +} + +void LLSocialStatusPanel::draw() +{ + if (mMessageTextEditor && mPostStatusButton) + { + std::string message = mMessageTextEditor->getValue().asString(); + mPostStatusButton->setEnabled(!message.empty()); + } + + LLPanel::draw(); +} + void LLSocialStatusPanel::onSend() { - std::string message = getChild("message")->getValue().asString(); - LLFacebookConnect::instance().updateStatus(message); + if (mMessageTextEditor) + { + std::string message = mMessageTextEditor->getValue().asString(); + if (!message.empty()) + { + LLFacebookConnect::instance().updateStatus(message); - LLFloater* floater = getParentByType(); - if (floater) - { - floater->closeFloater(); - } + LLFloater* floater = getParentByType(); + if (floater) + { + floater->closeFloater(); + } + } + } } LLSocialPhotoPanel::LLSocialPhotoPanel() : @@ -84,8 +111,6 @@ mThumbnailPlaceholder(NULL) mCommitCallbackRegistrar.add("PostToFacebook.Send", boost::bind(&LLSocialPhotoPanel::onSend, this)); } - - LLSocialPhotoPanel::~LLSocialPhotoPanel() { if(mPreviewHandle.get()) diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h index 7b8db2d64a..1e28e3cb7e 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -36,7 +36,13 @@ class LLSocialStatusPanel : public LLPanel { public: LLSocialStatusPanel(); + BOOL postBuild(); + void draw(); void onSend(); + +private: + LLUICtrl* mMessageTextEditor; + LLUICtrl* mPostStatusButton; }; class LLSocialPhotoPanel : public LLPanel diff --git a/indra/newview/skins/default/xui/en/floater_social.xml b/indra/newview/skins/default/xui/en/floater_social.xml index 1ae8f7ed65..3b19a2f4cb 100644 --- a/indra/newview/skins/default/xui/en/floater_social.xml +++ b/indra/newview/skins/default/xui/en/floater_social.xml @@ -49,7 +49,7 @@ left="9" length="1" max_length="700" - name="message" + name="status_message" type="string" word_wrap="true"> @@ -57,7 +57,7 @@ follows="left|top" height="23" label="Post" - name="post_btn" + name="post_status_btn" top_pad="18" width="100">