From cea9ffe89ce98f04e311aa989cce5955e77a15ff Mon Sep 17 00:00:00 2001 From: Cho Date: Mon, 4 Nov 2013 23:42:21 +0000 Subject: added Twitter floater for ACME-1146, ACME-1147, ACME-1148, ACME-1149, and ACME-1150 --- indra/newview/llfloatertwitter.cpp | 669 +++++++++++++++++++++++++++++++++++++ 1 file changed, 669 insertions(+) create mode 100644 indra/newview/llfloatertwitter.cpp (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp new file mode 100644 index 0000000000..b45cf32945 --- /dev/null +++ b/indra/newview/llfloatertwitter.cpp @@ -0,0 +1,669 @@ +/** +* @file llfloatertwitter.cpp +* @brief Implementation of llfloatertwitter +* @author cho@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 "llfloatertwitter.h" + +#include "llagent.h" +#include "llagentui.h" +#include "llcheckboxctrl.h" +#include "llcombobox.h" +#include "lltwitterconnect.h" +#include "llfloaterreg.h" +#include "lliconctrl.h" +#include "llresmgr.h" // LLLocale +#include "llsdserialize.h" +#include "llloadingindicator.h" +#include "llplugincookiestore.h" +#include "llslurl.h" +#include "lltrans.h" +#include "llsnapshotlivepreview.h" +#include "llviewerregion.h" +#include "llviewercontrol.h" +#include "llviewermedia.h" + +static LLRegisterPanelClassWrapper t_panel_photo("lltwitterphotopanel"); +static LLRegisterPanelClassWrapper t_panel_account("lltwitteraccountpanel"); + +const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte +const std::string DEFAULT_PHOTO_QUERY_PARAMETERS = "?sourceid=slshare_photo&utm_source=twitter&utm_medium=photo&utm_campaign=slshare"; + +/////////////////////////// +//LLTwitterPhotoPanel/////// +/////////////////////////// + +LLTwitterPhotoPanel::LLTwitterPhotoPanel() : +mSnapshotPanel(NULL), +mResolutionComboBox(NULL), +mRefreshBtn(NULL), +mWorkingLabel(NULL), +mThumbnailPlaceholder(NULL), +mCaptionTextBox(NULL), +mLocationCheckbox(NULL), +mPostButton(NULL) +{ + mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLTwitterPhotoPanel::onSend, this)); + mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLTwitterPhotoPanel::onClickNewSnapshot, this)); +} + +LLTwitterPhotoPanel::~LLTwitterPhotoPanel() +{ + if(mPreviewHandle.get()) + { + mPreviewHandle.get()->die(); + } +} + +BOOL LLTwitterPhotoPanel::postBuild() +{ + setVisibleCallback(boost::bind(&LLTwitterPhotoPanel::onVisibilityChange, this, _2)); + + mSnapshotPanel = getChild("snapshot_panel"); + mResolutionComboBox = getChild("resolution_combobox"); + mResolutionComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); + mRefreshBtn = getChild("new_snapshot_btn"); + mWorkingLabel = getChild("working_lbl"); + mThumbnailPlaceholder = getChild("thumbnail_placeholder"); + mCaptionTextBox = getChild("photo_caption"); + mLocationCheckbox = getChild("add_location_cb"); + mPostButton = getChild("post_photo_btn"); + mCancelButton = getChild("cancel_photo_btn"); + + return LLPanel::postBuild(); +} + +void LLTwitterPhotoPanel::draw() +{ + LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); + + // Enable interaction only if no transaction with the service is on-going (prevent duplicated posts) + bool no_ongoing_connection = !(LLTwitterConnect::instance().isTransactionOngoing()); + mCancelButton->setEnabled(no_ongoing_connection); + mCaptionTextBox->setEnabled(no_ongoing_connection); + mResolutionComboBox->setEnabled(no_ongoing_connection); + mRefreshBtn->setEnabled(no_ongoing_connection); + mLocationCheckbox->setEnabled(no_ongoing_connection); + + // Display the preview if one is available + if (previewp && previewp->getThumbnailImage()) + { + const LLRect& thumbnail_rect = mThumbnailPlaceholder->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 = (thumbnail_rect.getWidth() - thumbnail_w) / 2 ; + const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2 ; + + // calc preview offset within the floater rect + // Hack : To get the full offset, we need to take into account each and every offset of each widgets up to the floater. + // This is almost as arbitrary as using a fixed offset so that's what we do here for the sake of simplicity. + // *TODO : Get the offset looking through the hierarchy of widgets, should be done in postBuild() so to avoid traversing the hierarchy each time. + S32 offset_x = thumbnail_rect.mLeft + local_offset_x - 1; + S32 offset_y = thumbnail_rect.mBottom + local_offset_y - 39; + + mSnapshotPanel->localPointToOtherView(offset_x, offset_y, &offset_x, &offset_y, getParentByType()); + + 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, + previewp->getThumbnailImage(), color % alpha); + + previewp->drawPreviewRect(offset_x, offset_y) ; + } + + // Update the visibility of the working (computing preview) label + mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate())); + + // Enable Post if we have a preview to send and no on going connection being processed + mPostButton->setEnabled(no_ongoing_connection && (previewp && previewp->getSnapshotUpToDate())); + + // Draw the rest of the panel on top of it + LLPanel::draw(); +} + +LLSnapshotLivePreview* LLTwitterPhotoPanel::getPreviewView() +{ + LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get(); + return previewp; +} + +void LLTwitterPhotoPanel::onVisibilityChange(const LLSD& new_visibility) +{ + bool visible = new_visibility.asBoolean(); + if (visible) + { + if (mPreviewHandle.get()) + { + LLSnapshotLivePreview* preview = getPreviewView(); + if(preview) + { + lldebugs << "opened, updating snapshot" << llendl; + preview->updateSnapshot(TRUE); + } + } + else + { + LLRect full_screen_rect = getRootView()->getRect(); + LLSnapshotLivePreview::Params p; + p.rect(full_screen_rect); + LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); + mPreviewHandle = previewp->getHandle(); + + previewp->setSnapshotType(previewp->SNAPSHOT_WEB); + previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); + //previewp->setSnapshotQuality(98); + previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect()); + + updateControls(); + } + } +} + +void LLTwitterPhotoPanel::onClickNewSnapshot() +{ + LLSnapshotLivePreview* previewp = getPreviewView(); + if (previewp) + { + //setStatus(Impl::STATUS_READY); + lldebugs << "updating snapshot" << llendl; + previewp->updateSnapshot(TRUE); + } +} + +void LLTwitterPhotoPanel::onSend() +{ + LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterPhotoPanel"); // just in case it is already listening + LLEventPumps::instance().obtain("TwitterConnectState").listen("LLTwitterPhotoPanel", boost::bind(&LLTwitterPhotoPanel::onTwitterConnectStateChange, this, _1)); + + // Connect to Twitter if necessary and then post + if (LLTwitterConnect::instance().isConnected()) + { + sendPhoto(); + } + else + { + LLTwitterConnect::instance().checkConnectionToTwitter(true); + } +} + +bool LLTwitterPhotoPanel::onTwitterConnectStateChange(const LLSD& data) +{ + switch (data.get("enum").asInteger()) + { + case LLTwitterConnect::TWITTER_CONNECTED: + sendPhoto(); + break; + + case LLTwitterConnect::TWITTER_POSTED: + LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterPhotoPanel"); + clearAndClose(); + break; + } + + return false; +} + +void LLTwitterPhotoPanel::sendPhoto() +{ + // Get the caption + std::string caption = mCaptionTextBox->getValue().asString(); + + // Add the location if required + bool add_location = mLocationCheckbox->getValue().asBoolean(); + if (add_location) + { + // Get the SLURL for the location + LLSLURL slurl; + LLAgentUI::buildSLURL(slurl); + std::string slurl_string = slurl.getSLURLString(); + + // Add query parameters so Google Analytics can track incoming clicks! + slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS; + + // Add it to the caption (pretty crude, but we don't have a better option with photos) + if (caption.empty()) + caption = slurl_string; + else + caption = caption + " " + slurl_string; + } + + // Get the image + LLSnapshotLivePreview* previewp = getPreviewView(); + + // Post to Twitter + LLTwitterConnect::instance().uploadPhoto(previewp->getFormattedImage(), caption); + + updateControls(); +} + +void LLTwitterPhotoPanel::clearAndClose() +{ + mCaptionTextBox->setValue(""); + + LLFloater* floater = getParentByType(); + if (floater) + { + floater->closeFloater(); + } +} + +void LLTwitterPhotoPanel::updateControls() +{ + LLSnapshotLivePreview* previewp = getPreviewView(); + BOOL got_bytes = previewp && previewp->getDataSize() > 0; + BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); + LLSnapshotLivePreview::ESnapshotType shot_type = (previewp ? previewp->getSnapshotType() : LLSnapshotLivePreview::SNAPSHOT_POSTCARD); + + // *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")); <---uses localized string + getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : "unknown"); + getChild("file_size_label")->setColor( + shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD + && got_bytes + && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" )); + + updateResolution(FALSE); +} + +void LLTwitterPhotoPanel::updateResolution(BOOL do_update) +{ + LLComboBox* combobox = static_cast(mResolutionComboBox); + + 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(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(); + LLTwitterPhotoPanel::onClickNewSnapshot(); + } + } + + } +} + +void LLTwitterPhotoPanel::checkAspectRatio(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; + } +} + +LLUICtrl* LLTwitterPhotoPanel::getRefreshBtn() +{ + return mRefreshBtn; +} + +/////////////////////////// +//LLTwitterAccountPanel////// +/////////////////////////// + +LLTwitterAccountPanel::LLTwitterAccountPanel() : +mAccountCaptionLabel(NULL), +mAccountNameLabel(NULL), +mPanelButtons(NULL), +mConnectButton(NULL), +mDisconnectButton(NULL) +{ + mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLTwitterAccountPanel::onConnect, this)); + mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLTwitterAccountPanel::onDisconnect, this)); + + setVisibleCallback(boost::bind(&LLTwitterAccountPanel::onVisibilityChange, this, _2)); +} + +BOOL LLTwitterAccountPanel::postBuild() +{ + mAccountCaptionLabel = getChild("account_caption_label"); + mAccountNameLabel = getChild("account_name_label"); + mPanelButtons = getChild("panel_buttons"); + mConnectButton = getChild("connect_btn"); + mDisconnectButton = getChild("disconnect_btn"); + + return LLPanel::postBuild(); +} + +void LLTwitterAccountPanel::draw() +{ + LLTwitterConnect::EConnectionState connection_state = LLTwitterConnect::instance().getConnectionState(); + + //Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress + bool disconnecting = connection_state == LLTwitterConnect::TWITTER_DISCONNECTING; + mDisconnectButton->setEnabled(!disconnecting); + + //Disable the 'connect' button when a connection is in progress + bool connecting = connection_state == LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS; + mConnectButton->setEnabled(!connecting); + + LLPanel::draw(); +} + +void LLTwitterAccountPanel::onVisibilityChange(const LLSD& new_visibility) +{ + bool visible = new_visibility.asBoolean(); + + if(visible) + { + LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterAccountPanel"); + LLEventPumps::instance().obtain("TwitterConnectState").listen("LLTwitterAccountPanel", boost::bind(&LLTwitterAccountPanel::onTwitterConnectStateChange, this, _1)); + + LLEventPumps::instance().obtain("TwitterConnectInfo").stopListening("LLTwitterAccountPanel"); + LLEventPumps::instance().obtain("TwitterConnectInfo").listen("LLTwitterAccountPanel", boost::bind(&LLTwitterAccountPanel::onTwitterConnectInfoChange, this)); + + //Connected + if(LLTwitterConnect::instance().isConnected()) + { + showConnectedLayout(); + } + //Check if connected (show disconnected layout in meantime) + else + { + showDisconnectedLayout(); + } + if ((LLTwitterConnect::instance().getConnectionState() == LLTwitterConnect::TWITTER_NOT_CONNECTED) || + (LLTwitterConnect::instance().getConnectionState() == LLTwitterConnect::TWITTER_CONNECTION_FAILED)) + { + LLTwitterConnect::instance().checkConnectionToTwitter(); + } + } + else + { + LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterAccountPanel"); + LLEventPumps::instance().obtain("TwitterConnectInfo").stopListening("LLTwitterAccountPanel"); + } +} + +bool LLTwitterAccountPanel::onTwitterConnectStateChange(const LLSD& data) +{ + if(LLTwitterConnect::instance().isConnected()) + { + //In process of disconnecting so leave the layout as is + if(data.get("enum").asInteger() != LLTwitterConnect::TWITTER_DISCONNECTING) + { + showConnectedLayout(); + } + } + else + { + showDisconnectedLayout(); + } + + return false; +} + +bool LLTwitterAccountPanel::onTwitterConnectInfoChange() +{ + LLSD info = LLTwitterConnect::instance().getInfo(); + std::string clickable_name; + + //Strings of format [http://www.somewebsite.com Click Me] become clickable text + if(info.has("link") && info.has("name")) + { + clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]"; + } + + mAccountNameLabel->setText(clickable_name); + + return false; +} + +void LLTwitterAccountPanel::showConnectButton() +{ + if(!mConnectButton->getVisible()) + { + mConnectButton->setVisible(TRUE); + mDisconnectButton->setVisible(FALSE); + } +} + +void LLTwitterAccountPanel::hideConnectButton() +{ + if(mConnectButton->getVisible()) + { + mConnectButton->setVisible(FALSE); + mDisconnectButton->setVisible(TRUE); + } +} + +void LLTwitterAccountPanel::showDisconnectedLayout() +{ + mAccountCaptionLabel->setText(getString("twitter_disconnected")); + mAccountNameLabel->setText(std::string("")); + showConnectButton(); +} + +void LLTwitterAccountPanel::showConnectedLayout() +{ + LLTwitterConnect::instance().loadTwitterInfo(); + + mAccountCaptionLabel->setText(getString("twitter_connected")); + hideConnectButton(); +} + +void LLTwitterAccountPanel::onConnect() +{ + LLTwitterConnect::instance().checkConnectionToTwitter(true); + + //Clear only the twitter browser cookies so that the twitter login screen appears + LLViewerMedia::getCookieStore()->removeCookiesByDomain(".twitter.com"); +} + +void LLTwitterAccountPanel::onDisconnect() +{ + LLTwitterConnect::instance().disconnectFromTwitter(); + + LLViewerMedia::getCookieStore()->removeCookiesByDomain(".twitter.com"); +} + +//////////////////////// +//LLFloaterTwitter/////// +//////////////////////// + +LLFloaterTwitter::LLFloaterTwitter(const LLSD& key) : LLFloater(key), + mSocialPhotoPanel(NULL), + mStatusErrorText(NULL), + mStatusLoadingText(NULL), + mStatusLoadingIndicator(NULL) +{ + mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterTwitter::onCancel, this)); +} + +void LLFloaterTwitter::onCancel() +{ + closeFloater(); +} + +BOOL LLFloaterTwitter::postBuild() +{ + // Keep tab of the Photo Panel + mSocialPhotoPanel = static_cast(getChild("panel_twitter_photo")); + // Connection status widgets + mStatusErrorText = getChild("connection_error_text"); + mStatusLoadingText = getChild("connection_loading_text"); + mStatusLoadingIndicator = getChild("connection_loading_indicator"); + return LLFloater::postBuild(); +} + +// static +void LLFloaterTwitter::preUpdate() +{ + LLFloaterTwitter* instance = LLFloaterReg::findTypedInstance("twitter"); + if (instance) + { + //Will set file size text to 'unknown' + instance->mSocialPhotoPanel->updateControls(); + } +} + +// static +void LLFloaterTwitter::postUpdate() +{ + LLFloaterTwitter* instance = LLFloaterReg::findTypedInstance("twitter"); + if (instance) + { + //Will set the file size text + instance->mSocialPhotoPanel->updateControls(); + + // The refresh button is initially hidden. We show it after the first update, + // i.e. after snapshot is taken + LLUICtrl * refresh_button = instance->mSocialPhotoPanel->getRefreshBtn(); + + if (!refresh_button->getVisible()) + { + refresh_button->setVisible(true); + } + + } +} + +void LLFloaterTwitter::draw() +{ + if (mStatusErrorText && mStatusLoadingText && mStatusLoadingIndicator) + { + mStatusErrorText->setVisible(false); + mStatusLoadingText->setVisible(false); + mStatusLoadingIndicator->setVisible(false); + LLTwitterConnect::EConnectionState connection_state = LLTwitterConnect::instance().getConnectionState(); + std::string status_text; + + switch (connection_state) + { + case LLTwitterConnect::TWITTER_NOT_CONNECTED: + // No status displayed when first opening the panel and no connection done + case LLTwitterConnect::TWITTER_CONNECTED: + // When successfully connected, no message is displayed + case LLTwitterConnect::TWITTER_POSTED: + // No success message to show since we actually close the floater after successful posting completion + break; + case LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS: + // Connection loading indicator + mStatusLoadingText->setVisible(true); + status_text = LLTrans::getString("SocialTwitterConnecting"); + mStatusLoadingText->setValue(status_text); + mStatusLoadingIndicator->setVisible(true); + break; + case LLTwitterConnect::TWITTER_POSTING: + // Posting indicator + mStatusLoadingText->setVisible(true); + status_text = LLTrans::getString("SocialTwitterPosting"); + mStatusLoadingText->setValue(status_text); + mStatusLoadingIndicator->setVisible(true); + break; + case LLTwitterConnect::TWITTER_CONNECTION_FAILED: + // Error connecting to the service + mStatusErrorText->setVisible(true); + status_text = LLTrans::getString("SocialTwitterErrorConnecting"); + mStatusErrorText->setValue(status_text); + break; + case LLTwitterConnect::TWITTER_POST_FAILED: + // Error posting to the service + mStatusErrorText->setVisible(true); + status_text = LLTrans::getString("SocialTwitterErrorPosting"); + mStatusErrorText->setValue(status_text); + break; + case LLTwitterConnect::TWITTER_DISCONNECTING: + // Disconnecting loading indicator + mStatusLoadingText->setVisible(true); + status_text = LLTrans::getString("SocialTwitterDisconnecting"); + mStatusLoadingText->setValue(status_text); + mStatusLoadingIndicator->setVisible(true); + break; + case LLTwitterConnect::TWITTER_DISCONNECT_FAILED: + // Error disconnecting from the service + mStatusErrorText->setVisible(true); + status_text = LLTrans::getString("SocialTwitterErrorDisconnecting"); + mStatusErrorText->setValue(status_text); + break; + } + } + LLFloater::draw(); +} + -- cgit v1.2.3 From 389ddfd5add78998aaadb171593b5b036d2dbee0 Mon Sep 17 00:00:00 2001 From: Cho Date: Thu, 7 Nov 2013 19:06:39 +0000 Subject: updated panel_twitter_photo.xml to match design spec for ACME-1153 --- indra/newview/llfloatertwitter.cpp | 61 ++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 35 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index b45cf32945..5a2402cdd6 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -63,8 +63,8 @@ mResolutionComboBox(NULL), mRefreshBtn(NULL), mWorkingLabel(NULL), mThumbnailPlaceholder(NULL), -mCaptionTextBox(NULL), -mLocationCheckbox(NULL), +mStatusTextBox(NULL), +mPhotoCheckbox(NULL), mPostButton(NULL) { mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLTwitterPhotoPanel::onSend, this)); @@ -89,8 +89,8 @@ BOOL LLTwitterPhotoPanel::postBuild() mRefreshBtn = getChild("new_snapshot_btn"); mWorkingLabel = getChild("working_lbl"); mThumbnailPlaceholder = getChild("thumbnail_placeholder"); - mCaptionTextBox = getChild("photo_caption"); - mLocationCheckbox = getChild("add_location_cb"); + mStatusTextBox = getChild("photo_status"); + mPhotoCheckbox = getChild("add_photo_cb"); mPostButton = getChild("post_photo_btn"); mCancelButton = getChild("cancel_photo_btn"); @@ -104,11 +104,11 @@ void LLTwitterPhotoPanel::draw() // Enable interaction only if no transaction with the service is on-going (prevent duplicated posts) bool no_ongoing_connection = !(LLTwitterConnect::instance().isTransactionOngoing()); mCancelButton->setEnabled(no_ongoing_connection); - mCaptionTextBox->setEnabled(no_ongoing_connection); - mResolutionComboBox->setEnabled(no_ongoing_connection); - mRefreshBtn->setEnabled(no_ongoing_connection); - mLocationCheckbox->setEnabled(no_ongoing_connection); - + mStatusTextBox->setEnabled(no_ongoing_connection); + mResolutionComboBox->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean()); + mRefreshBtn->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean()); + mPhotoCheckbox->setEnabled(no_ongoing_connection); + // Display the preview if one is available if (previewp && previewp->getThumbnailImage()) { @@ -131,7 +131,7 @@ void LLTwitterPhotoPanel::draw() gGL.matrixMode(LLRender::MM_MODELVIEW); // Apply floater transparency to the texture unless the floater is focused. - F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); + F32 alpha = (mPhotoCheckbox->getValue().asBoolean() ? (getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency()) : 0.5f); LLColor4 color = LLColor4::white; gl_draw_scaled_image(offset_x, offset_y, thumbnail_w, thumbnail_h, @@ -234,40 +234,31 @@ bool LLTwitterPhotoPanel::onTwitterConnectStateChange(const LLSD& data) void LLTwitterPhotoPanel::sendPhoto() { - // Get the caption - std::string caption = mCaptionTextBox->getValue().asString(); + // Get the status text + std::string status = mStatusTextBox->getValue().asString(); - // Add the location if required - bool add_location = mLocationCheckbox->getValue().asBoolean(); - if (add_location) + // Add the photo if required + bool add_photo = mPhotoCheckbox->getValue().asBoolean(); + if (add_photo) { - // Get the SLURL for the location - LLSLURL slurl; - LLAgentUI::buildSLURL(slurl); - std::string slurl_string = slurl.getSLURLString(); - - // Add query parameters so Google Analytics can track incoming clicks! - slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS; - - // Add it to the caption (pretty crude, but we don't have a better option with photos) - if (caption.empty()) - caption = slurl_string; - else - caption = caption + " " + slurl_string; - } - - // Get the image - LLSnapshotLivePreview* previewp = getPreviewView(); + // Get the image + LLSnapshotLivePreview* previewp = getPreviewView(); - // Post to Twitter - LLTwitterConnect::instance().uploadPhoto(previewp->getFormattedImage(), caption); + // Post to Twitter + LLTwitterConnect::instance().uploadPhoto(previewp->getFormattedImage(), status); + } + else + { + // Just post the status to Twitter + LLTwitterConnect::instance().updateStatus(status); + } updateControls(); } void LLTwitterPhotoPanel::clearAndClose() { - mCaptionTextBox->setValue(""); + mStatusTextBox->setValue(""); LLFloater* floater = getParentByType(); if (floater) -- cgit v1.2.3 From 15434d53ea1f1bca37b7b9d6d569b3cb61d09bbe Mon Sep 17 00:00:00 2001 From: Cho Date: Fri, 8 Nov 2013 00:33:14 +0000 Subject: added SLShare links to snapshot floater for ACME-1167 --- indra/newview/llfloatertwitter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 5a2402cdd6..1324bd5fd8 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -109,6 +109,8 @@ void LLTwitterPhotoPanel::draw() mRefreshBtn->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean()); mPhotoCheckbox->setEnabled(no_ongoing_connection); + bool add_photo = mPhotoCheckbox->getValue().asBoolean(); + // Display the preview if one is available if (previewp && previewp->getThumbnailImage()) { @@ -131,7 +133,7 @@ void LLTwitterPhotoPanel::draw() gGL.matrixMode(LLRender::MM_MODELVIEW); // Apply floater transparency to the texture unless the floater is focused. - F32 alpha = (mPhotoCheckbox->getValue().asBoolean() ? (getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency()) : 0.5f); + F32 alpha = (add_photo ? (getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency()) : 0.5f); LLColor4 color = LLColor4::white; gl_draw_scaled_image(offset_x, offset_y, thumbnail_w, thumbnail_h, @@ -144,7 +146,7 @@ void LLTwitterPhotoPanel::draw() mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate())); // Enable Post if we have a preview to send and no on going connection being processed - mPostButton->setEnabled(no_ongoing_connection && (previewp && previewp->getSnapshotUpToDate())); + mPostButton->setEnabled(no_ongoing_connection && ((add_photo && previewp && previewp->getSnapshotUpToDate()) || !mStatusTextBox->getValue().asString().empty())); // Draw the rest of the panel on top of it LLPanel::draw(); -- cgit v1.2.3 From dbab46ae786166ac5d6c929e2c444d8f490edd58 Mon Sep 17 00:00:00 2001 From: Cho Date: Mon, 11 Nov 2013 23:13:01 +0000 Subject: made floater_snapshot links open the photo tab on the corresponding floater for ACME-1168 --- indra/newview/llfloatertwitter.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 1324bd5fd8..0da0d64426 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -46,6 +46,7 @@ #include "llviewerregion.h" #include "llviewercontrol.h" #include "llviewermedia.h" +#include "lltabcontainer.h" static LLRegisterPanelClassWrapper t_panel_photo("lltwitterphotopanel"); static LLRegisterPanelClassWrapper t_panel_account("lltwitteraccountpanel"); @@ -565,6 +566,18 @@ BOOL LLFloaterTwitter::postBuild() return LLFloater::postBuild(); } +void LLFloaterTwitter::showPhotoPanel() +{ + LLTabContainer* parent = dynamic_cast(mSocialPhotoPanel->getParent()); + if (!parent) + { + llwarns << "Cannot find panel container" << llendl; + return; + } + + parent->selectTabPanel(mSocialPhotoPanel); +} + // static void LLFloaterTwitter::preUpdate() { -- cgit v1.2.3 From 9e6dd1811e890d6d5e23059c67f13d9960e56366 Mon Sep 17 00:00:00 2001 From: Cho Date: Tue, 12 Nov 2013 22:18:05 +0000 Subject: implemented Twitter character limits for status text box for ACME-1171 and ACME-1172 --- indra/newview/llfloatertwitter.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 0da0d64426..46cad7ec45 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -47,6 +47,7 @@ #include "llviewercontrol.h" #include "llviewermedia.h" #include "lltabcontainer.h" +#include "lltexteditor.h" static LLRegisterPanelClassWrapper t_panel_photo("lltwitterphotopanel"); static LLRegisterPanelClassWrapper t_panel_account("lltwitteraccountpanel"); @@ -112,6 +113,18 @@ void LLTwitterPhotoPanel::draw() bool add_photo = mPhotoCheckbox->getValue().asBoolean(); + // Restrict the status text length to Twitter's character limit + LLTextEditor* status_text_box = dynamic_cast(mStatusTextBox); + if (status_text_box) + { + int max_status_length = add_photo ? 119 : 140; + status_text_box->setMaxTextLength(max_status_length); + if (status_text_box->getText().length() > max_status_length) + { + status_text_box->setText(status_text_box->getText().substr(0, max_status_length)); + } + } + // Display the preview if one is available if (previewp && previewp->getThumbnailImage()) { -- cgit v1.2.3 From 47918f4537ee924c4cb9652a72561b5febbddeb6 Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 13 Nov 2013 18:44:33 +0000 Subject: changed Twitter photo character limit to 100 just to be safe, and switched to use cap server for Flickr and Twitter service --- indra/newview/llfloatertwitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 46cad7ec45..6f8ad109c6 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -117,7 +117,7 @@ void LLTwitterPhotoPanel::draw() LLTextEditor* status_text_box = dynamic_cast(mStatusTextBox); if (status_text_box) { - int max_status_length = add_photo ? 119 : 140; + int max_status_length = add_photo ? 100 : 140; status_text_box->setMaxTextLength(max_status_length); if (status_text_box->getText().length() > max_status_length) { -- cgit v1.2.3 From 758f656100406015bc8b27284670088decbbfabb Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 13 Nov 2013 21:38:19 +0000 Subject: made Twitter status text truncate and untruncate for ACME-1183 --- indra/newview/llfloatertwitter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 6f8ad109c6..06d0fb5542 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -119,9 +119,18 @@ void LLTwitterPhotoPanel::draw() { int max_status_length = add_photo ? 100 : 140; status_text_box->setMaxTextLength(max_status_length); + if (!add_photo) + { + if (mOldStatusText.length() > status_text_box->getText().length() && status_text_box->getText() == mOldStatusText.substr(0, status_text_box->getText().length())) + { + status_text_box->setText(mOldStatusText); + } + mOldStatusText = ""; + } if (status_text_box->getText().length() > max_status_length) { - status_text_box->setText(status_text_box->getText().substr(0, max_status_length)); + mOldStatusText = status_text_box->getText(); + status_text_box->setText(mOldStatusText.substr(0, max_status_length)); } } -- cgit v1.2.3 From b6d02ae9c84e185f2507323c47c0475ce43f9e7a Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 4 Dec 2013 18:19:47 +0000 Subject: Added SLURL checkbox to floater_twitter for ACME-1216 --- indra/newview/llfloatertwitter.cpp | 96 +++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 22 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 06d0fb5542..ea17497d95 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -66,6 +66,7 @@ mRefreshBtn(NULL), mWorkingLabel(NULL), mThumbnailPlaceholder(NULL), mStatusTextBox(NULL), +mLocationCheckbox(NULL), mPhotoCheckbox(NULL), mPostButton(NULL) { @@ -92,7 +93,10 @@ BOOL LLTwitterPhotoPanel::postBuild() mWorkingLabel = getChild("working_lbl"); mThumbnailPlaceholder = getChild("thumbnail_placeholder"); mStatusTextBox = getChild("photo_status"); + mLocationCheckbox = getChild("add_location_cb"); + mLocationCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddLocationToggled, this)); mPhotoCheckbox = getChild("add_photo_cb"); + mPhotoCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddPhotoToggled, this)); mPostButton = getChild("post_photo_btn"); mCancelButton = getChild("cancel_photo_btn"); @@ -109,30 +113,12 @@ void LLTwitterPhotoPanel::draw() mStatusTextBox->setEnabled(no_ongoing_connection); mResolutionComboBox->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean()); mRefreshBtn->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean()); + mLocationCheckbox->setEnabled(no_ongoing_connection); mPhotoCheckbox->setEnabled(no_ongoing_connection); + bool add_location = mLocationCheckbox->getValue().asBoolean(); bool add_photo = mPhotoCheckbox->getValue().asBoolean(); - - // Restrict the status text length to Twitter's character limit - LLTextEditor* status_text_box = dynamic_cast(mStatusTextBox); - if (status_text_box) - { - int max_status_length = add_photo ? 100 : 140; - status_text_box->setMaxTextLength(max_status_length); - if (!add_photo) - { - if (mOldStatusText.length() > status_text_box->getText().length() && status_text_box->getText() == mOldStatusText.substr(0, status_text_box->getText().length())) - { - status_text_box->setText(mOldStatusText); - } - mOldStatusText = ""; - } - if (status_text_box->getText().length() > max_status_length) - { - mOldStatusText = status_text_box->getText(); - status_text_box->setText(mOldStatusText.substr(0, max_status_length)); - } - } + updateStatusTextLength(false); // Display the preview if one is available if (previewp && previewp->getThumbnailImage()) @@ -169,7 +155,7 @@ void LLTwitterPhotoPanel::draw() mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate())); // Enable Post if we have a preview to send and no on going connection being processed - mPostButton->setEnabled(no_ongoing_connection && ((add_photo && previewp && previewp->getSnapshotUpToDate()) || !mStatusTextBox->getValue().asString().empty())); + mPostButton->setEnabled(no_ongoing_connection && ((add_photo && previewp && previewp->getSnapshotUpToDate()) || add_location || !mStatusTextBox->getValue().asString().empty())); // Draw the rest of the panel on top of it LLPanel::draw(); @@ -213,6 +199,18 @@ void LLTwitterPhotoPanel::onVisibilityChange(const LLSD& new_visibility) } } +void LLTwitterPhotoPanel::onAddLocationToggled() +{ + bool add_location = mLocationCheckbox->getValue().asBoolean(); + updateStatusTextLength(!add_location); +} + +void LLTwitterPhotoPanel::onAddPhotoToggled() +{ + bool add_photo = mPhotoCheckbox->getValue().asBoolean(); + updateStatusTextLength(!add_photo); +} + void LLTwitterPhotoPanel::onClickNewSnapshot() { LLSnapshotLivePreview* previewp = getPreviewView(); @@ -261,6 +259,26 @@ void LLTwitterPhotoPanel::sendPhoto() { // Get the status text std::string status = mStatusTextBox->getValue().asString(); + + // Add the location if required + bool add_location = mLocationCheckbox->getValue().asBoolean(); + if (add_location) + { + // Get the SLURL for the location + LLSLURL slurl; + LLAgentUI::buildSLURL(slurl); + std::string slurl_string = slurl.getSLURLString(); + + // Add query parameters so Google Analytics can track incoming clicks! + slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS; + + // Add it to the status (pretty crude, but we don't have a better option with photos) + if (status.empty()) + status = slurl_string; + else + status = status + " " + slurl_string; + } + // Add the photo if required bool add_photo = mPhotoCheckbox->getValue().asBoolean(); @@ -292,6 +310,40 @@ void LLTwitterPhotoPanel::clearAndClose() } } +void LLTwitterPhotoPanel::updateStatusTextLength(BOOL restore_old_status_text) +{ + bool add_location = mLocationCheckbox->getValue().asBoolean(); + bool add_photo = mPhotoCheckbox->getValue().asBoolean(); + + // Restrict the status text length to Twitter's character limit + LLTextEditor* status_text_box = dynamic_cast(mStatusTextBox); + if (status_text_box) + { + int max_status_length = 140 - (add_location ? 40 : 0) - (add_photo ? 40 : 0); + status_text_box->setMaxTextLength(max_status_length); + if (restore_old_status_text) + { + if (mOldStatusText.length() > status_text_box->getText().length() && status_text_box->getText() == mOldStatusText.substr(0, status_text_box->getText().length())) + { + status_text_box->setText(mOldStatusText); + } + if (mOldStatusText.length() <= max_status_length) + { + mOldStatusText = ""; + } + } + if (status_text_box->getText().length() > max_status_length) + { + if (mOldStatusText.length() < status_text_box->getText().length() || status_text_box->getText() != mOldStatusText.substr(0, status_text_box->getText().length())) + { + mOldStatusText = status_text_box->getText(); + } + status_text_box->setText(mOldStatusText.substr(0, max_status_length)); + } + } + +} + void LLTwitterPhotoPanel::updateControls() { LLSnapshotLivePreview* previewp = getPreviewView(); -- cgit v1.2.3 From 187fb979d365ac3052f6a95e278a1f92c3117d17 Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 4 Dec 2013 19:45:26 +0000 Subject: Add character count display to floater_twitter for ACME-1215 --- indra/newview/llfloatertwitter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index ea17497d95..82ed066b1a 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -65,6 +65,7 @@ mResolutionComboBox(NULL), mRefreshBtn(NULL), mWorkingLabel(NULL), mThumbnailPlaceholder(NULL), +mStatusCounterLabel(NULL), mStatusTextBox(NULL), mLocationCheckbox(NULL), mPhotoCheckbox(NULL), @@ -92,6 +93,7 @@ BOOL LLTwitterPhotoPanel::postBuild() mRefreshBtn = getChild("new_snapshot_btn"); mWorkingLabel = getChild("working_lbl"); mThumbnailPlaceholder = getChild("thumbnail_placeholder"); + mStatusCounterLabel = getChild("status_counter_label"); mStatusTextBox = getChild("photo_status"); mLocationCheckbox = getChild("add_location_cb"); mLocationCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddLocationToggled, this)); @@ -340,6 +342,10 @@ void LLTwitterPhotoPanel::updateStatusTextLength(BOOL restore_old_status_text) } status_text_box->setText(mOldStatusText.substr(0, max_status_length)); } + + // Update the status character counter + int characters_remaining = max_status_length - status_text_box->getText().length(); + mStatusCounterLabel->setValue(characters_remaining); } } -- cgit v1.2.3 From 9108354e9d39d93dadbad34ff5ba7ecb7abc7bf9 Mon Sep 17 00:00:00 2001 From: Cho Date: Thu, 5 Dec 2013 00:28:28 +0000 Subject: Renamed floater_social to floater_facebook for ACME-1205 --- indra/newview/llfloatertwitter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 82ed066b1a..18a1fcbba9 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -622,7 +622,7 @@ void LLTwitterAccountPanel::onDisconnect() //////////////////////// LLFloaterTwitter::LLFloaterTwitter(const LLSD& key) : LLFloater(key), - mSocialPhotoPanel(NULL), + mTwitterPhotoPanel(NULL), mStatusErrorText(NULL), mStatusLoadingText(NULL), mStatusLoadingIndicator(NULL) @@ -638,7 +638,7 @@ void LLFloaterTwitter::onCancel() BOOL LLFloaterTwitter::postBuild() { // Keep tab of the Photo Panel - mSocialPhotoPanel = static_cast(getChild("panel_twitter_photo")); + mTwitterPhotoPanel = static_cast(getChild("panel_twitter_photo")); // Connection status widgets mStatusErrorText = getChild("connection_error_text"); mStatusLoadingText = getChild("connection_loading_text"); @@ -648,14 +648,14 @@ BOOL LLFloaterTwitter::postBuild() void LLFloaterTwitter::showPhotoPanel() { - LLTabContainer* parent = dynamic_cast(mSocialPhotoPanel->getParent()); + LLTabContainer* parent = dynamic_cast(mTwitterPhotoPanel->getParent()); if (!parent) { llwarns << "Cannot find panel container" << llendl; return; } - parent->selectTabPanel(mSocialPhotoPanel); + parent->selectTabPanel(mTwitterPhotoPanel); } // static @@ -665,7 +665,7 @@ void LLFloaterTwitter::preUpdate() if (instance) { //Will set file size text to 'unknown' - instance->mSocialPhotoPanel->updateControls(); + instance->mTwitterPhotoPanel->updateControls(); } } @@ -676,11 +676,11 @@ void LLFloaterTwitter::postUpdate() if (instance) { //Will set the file size text - instance->mSocialPhotoPanel->updateControls(); + instance->mTwitterPhotoPanel->updateControls(); // The refresh button is initially hidden. We show it after the first update, // i.e. after snapshot is taken - LLUICtrl * refresh_button = instance->mSocialPhotoPanel->getRefreshBtn(); + LLUICtrl * refresh_button = instance->mTwitterPhotoPanel->getRefreshBtn(); if (!refresh_button->getVisible()) { -- cgit v1.2.3 From 88f139594bb819bc31b438edcceaf9cd661b3f82 Mon Sep 17 00:00:00 2001 From: Cho Date: Tue, 10 Dec 2013 18:55:49 +0000 Subject: Added placeholder http SLURL for Twitter sharing on Aditi for ACME-1216 --- indra/newview/llfloatertwitter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 18a1fcbba9..ea263566a6 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -53,6 +53,7 @@ static LLRegisterPanelClassWrapper t_panel_photo("lltwitter static LLRegisterPanelClassWrapper t_panel_account("lltwitteraccountpanel"); const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte +const std::string DEFAULT_PHOTO_LOCATION_URL = "http://maps.secondlife.com/"; const std::string DEFAULT_PHOTO_QUERY_PARAMETERS = "?sourceid=slshare_photo&utm_source=twitter&utm_medium=photo&utm_campaign=slshare"; /////////////////////////// @@ -271,6 +272,13 @@ void LLTwitterPhotoPanel::sendPhoto() LLAgentUI::buildSLURL(slurl); std::string slurl_string = slurl.getSLURLString(); + // Use a valid http:// URL if the scheme is secondlife:// + LLURI slurl_uri(slurl_string); + if (slurl_uri.scheme() == LLSLURL::SLURL_SECONDLIFE_SCHEME) + { + slurl_string = DEFAULT_PHOTO_LOCATION_URL; + } + // Add query parameters so Google Analytics can track incoming clicks! slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS; @@ -281,7 +289,6 @@ void LLTwitterPhotoPanel::sendPhoto() status = status + " " + slurl_string; } - // Add the photo if required bool add_photo = mPhotoCheckbox->getValue().asBoolean(); if (add_photo) -- cgit v1.2.3 From 6bf3cb875cef4da7c35850ebbea5100dc5244601 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 28 Jan 2014 10:19:57 -0800 Subject: ACME-1195 : WIP : Lazy evaluate intermediate images in snapshot preview so perf is better in common cases, allow thumbnail to be computed from grabed frame (for SL Share), thumbnail display still buggy in SL Share --- indra/newview/llfloatertwitter.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index ea263566a6..68bc4f1c3c 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -150,8 +150,6 @@ void LLTwitterPhotoPanel::draw() gl_draw_scaled_image(offset_x, offset_y, thumbnail_w, thumbnail_h, previewp->getThumbnailImage(), color % alpha); - - previewp->drawPreviewRect(offset_x, offset_y) ; } // Update the visibility of the working (computing preview) label @@ -190,11 +188,11 @@ void LLTwitterPhotoPanel::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->setSnapshotType(previewp->SNAPSHOT_WEB); previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); - //previewp->setSnapshotQuality(98); + previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect()); updateControls(); -- cgit v1.2.3 From b35889a6510440692be4b7f1aa590cf645fbba90 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 28 Jan 2014 17:45:48 -0800 Subject: ACME-1195 : Complete perf improvements. Also we do not regrab/refresh when we don't have to (e.g. change format) in particular when changing filter. Better control that way and faster UI. --- indra/newview/llfloatertwitter.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 68bc4f1c3c..5e0f652264 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -217,8 +217,6 @@ void LLTwitterPhotoPanel::onClickNewSnapshot() LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp) { - //setStatus(Impl::STATUS_READY); - lldebugs << "updating snapshot" << llendl; previewp->updateSnapshot(TRUE); } } @@ -417,22 +415,15 @@ void LLTwitterPhotoPanel::updateResolution(BOOL do_update) previewp->getSize(width, height); - if(original_width != width || original_height != 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) + if (do_update) { - lldebugs << "Will update controls" << llendl; + previewp->updateSnapshot(TRUE); updateControls(); - LLTwitterPhotoPanel::onClickNewSnapshot(); } } - } } -- cgit v1.2.3 From f7a90c680a007775efe0f8556c6712a08e489aab Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 28 Jan 2014 19:00:46 -0800 Subject: ACME-1275 : Implemented filters to the Twitter and Facebook panels --- indra/newview/llfloatertwitter.cpp | 45 +++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 5e0f652264..0b20b77c19 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -36,6 +36,7 @@ #include "lltwitterconnect.h" #include "llfloaterreg.h" #include "lliconctrl.h" +#include "llimagefiltersmanager.h" #include "llresmgr.h" // LLLocale #include "llsdserialize.h" #include "llloadingindicator.h" @@ -91,6 +92,8 @@ BOOL LLTwitterPhotoPanel::postBuild() mSnapshotPanel = getChild("snapshot_panel"); mResolutionComboBox = getChild("resolution_combobox"); mResolutionComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); + mFilterComboBox = getChild("filters_combobox"); + mFilterComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); mRefreshBtn = getChild("new_snapshot_btn"); mWorkingLabel = getChild("working_lbl"); mThumbnailPlaceholder = getChild("thumbnail_placeholder"); @@ -103,6 +106,14 @@ BOOL LLTwitterPhotoPanel::postBuild() mPostButton = getChild("post_photo_btn"); mCancelButton = getChild("cancel_photo_btn"); + // Update filter list + std::vector filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); + LLComboBox* filterbox = static_cast(mFilterComboBox); + for (U32 i = 0; i < filter_list.size(); i++) + { + filterbox->add(filter_list[i]); + } + return LLPanel::postBuild(); } @@ -356,33 +367,18 @@ void LLTwitterPhotoPanel::updateStatusTextLength(BOOL restore_old_status_text) void LLTwitterPhotoPanel::updateControls() { LLSnapshotLivePreview* previewp = getPreviewView(); - BOOL got_bytes = previewp && previewp->getDataSize() > 0; BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); - LLSnapshotLivePreview::ESnapshotType shot_type = (previewp ? previewp->getSnapshotType() : LLSnapshotLivePreview::SNAPSHOT_POSTCARD); - + // *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")); <---uses localized string - getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : "unknown"); - getChild("file_size_label")->setColor( - shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD - && got_bytes - && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" )); - + updateResolution(FALSE); } void LLTwitterPhotoPanel::updateResolution(BOOL do_update) { LLComboBox* combobox = static_cast(mResolutionComboBox); + LLComboBox* filterbox = static_cast(mFilterComboBox); std::string sdstring = combobox->getSelectedValue(); LLSD sdres; @@ -392,6 +388,8 @@ void LLTwitterPhotoPanel::updateResolution(BOOL do_update) S32 width = sdres[0]; S32 height = sdres[1]; + const std::string& filter_name = filterbox->getSimple(); + LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); if (previewp && combobox->getCurrentIndex() >= 0) { @@ -424,6 +422,17 @@ void LLTwitterPhotoPanel::updateResolution(BOOL do_update) updateControls(); } } + // Get the old filter, compare to the current one "filter_name" and set if changed + std::string original_filter = previewp->getFilter(); + if (original_filter != filter_name) + { + previewp->setFilter(filter_name); + if (do_update) + { + previewp->updateSnapshot(FALSE, TRUE); + updateControls(); + } + } } } -- cgit v1.2.3 From b4405c5388d1d9f562d6450092ca55cdea4c94a3 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 28 Jan 2014 19:35:39 -0800 Subject: ACME-1282 : Prevent rendering of UI in SL Share snapshots --- indra/newview/llfloatertwitter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 0b20b77c19..09821a2593 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -204,6 +204,7 @@ void LLTwitterPhotoPanel::onVisibilityChange(const LLSD& new_visibility) previewp->setSnapshotType(previewp->SNAPSHOT_WEB); previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image + previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect()); updateControls(); -- cgit v1.2.3 From c7c755b82e736050a514792a4c4bbdee9bf981d3 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 29 Jan 2014 14:21:43 -0800 Subject: ACME-1272, ACME-1292 : Disable filter drop down when necessary --- indra/newview/llfloatertwitter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 09821a2593..2c327b4cd3 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -123,10 +123,12 @@ void LLTwitterPhotoPanel::draw() // Enable interaction only if no transaction with the service is on-going (prevent duplicated posts) bool no_ongoing_connection = !(LLTwitterConnect::instance().isTransactionOngoing()); + bool photo_checked = mPhotoCheckbox->getValue().asBoolean(); mCancelButton->setEnabled(no_ongoing_connection); mStatusTextBox->setEnabled(no_ongoing_connection); - mResolutionComboBox->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean()); - mRefreshBtn->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean()); + mResolutionComboBox->setEnabled(no_ongoing_connection && photo_checked); + mFilterComboBox->setEnabled(no_ongoing_connection && photo_checked); + mRefreshBtn->setEnabled(no_ongoing_connection && photo_checked); mLocationCheckbox->setEnabled(no_ongoing_connection); mPhotoCheckbox->setEnabled(no_ongoing_connection); -- cgit v1.2.3 From e970fa7f1ce9190b8a26e72bebbcceed04fb7494 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 30 Jan 2014 18:53:05 -0800 Subject: ACME-1293 : Use notification to signal from the snapshot panel to its container rather than grabbing global instances, use unique control_name for widgets, fix Post button visibility on Twitter --- indra/newview/llfloatertwitter.cpp | 63 ++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 33 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 2c327b4cd3..ffe2609972 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -117,6 +117,34 @@ BOOL LLTwitterPhotoPanel::postBuild() return LLPanel::postBuild(); } +// virtual +S32 LLTwitterPhotoPanel::notify(const LLSD& info) +{ + if (info.has("snapshot-updating")) + { + // Disable the Post button and whatever else while the snapshot is not updated + // updateControls(); + return 1; + } + + if (info.has("snapshot-updated")) + { + // Enable the send/post/save buttons. + updateControls(); + + // The refresh button is initially hidden. We show it after the first update, + // i.e. after snapshot is taken + LLUICtrl * refresh_button = getRefreshBtn(); + if (!refresh_button->getVisible()) + { + refresh_button->setVisible(true); + } + return 1; + } + + return 0; +} + void LLTwitterPhotoPanel::draw() { LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); @@ -169,7 +197,7 @@ void LLTwitterPhotoPanel::draw() mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate())); // Enable Post if we have a preview to send and no on going connection being processed - mPostButton->setEnabled(no_ongoing_connection && ((add_photo && previewp && previewp->getSnapshotUpToDate()) || add_location || !mStatusTextBox->getValue().asString().empty())); + mPostButton->setEnabled(no_ongoing_connection && (previewp && previewp->getSnapshotUpToDate()) && (add_photo || add_location || !mStatusTextBox->getValue().asString().empty())); // Draw the rest of the panel on top of it LLPanel::draw(); @@ -203,6 +231,7 @@ void LLTwitterPhotoPanel::onVisibilityChange(const LLSD& new_visibility) LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); mPreviewHandle = previewp->getHandle(); + previewp->setContainer(this); previewp->setSnapshotType(previewp->SNAPSHOT_WEB); previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image @@ -666,38 +695,6 @@ void LLFloaterTwitter::showPhotoPanel() parent->selectTabPanel(mTwitterPhotoPanel); } -// static -void LLFloaterTwitter::preUpdate() -{ - LLFloaterTwitter* instance = LLFloaterReg::findTypedInstance("twitter"); - if (instance) - { - //Will set file size text to 'unknown' - instance->mTwitterPhotoPanel->updateControls(); - } -} - -// static -void LLFloaterTwitter::postUpdate() -{ - LLFloaterTwitter* instance = LLFloaterReg::findTypedInstance("twitter"); - if (instance) - { - //Will set the file size text - instance->mTwitterPhotoPanel->updateControls(); - - // The refresh button is initially hidden. We show it after the first update, - // i.e. after snapshot is taken - LLUICtrl * refresh_button = instance->mTwitterPhotoPanel->getRefreshBtn(); - - if (!refresh_button->getVisible()) - { - refresh_button->setVisible(true); - } - - } -} - void LLFloaterTwitter::draw() { if (mStatusErrorText && mStatusLoadingText && mStatusLoadingIndicator) -- cgit v1.2.3 From 9099cddb553bf9a2239bba86e6f1135bca76ed8b Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 3 Feb 2014 14:57:56 -0800 Subject: ACME-1295 : Implement an mAllowFullScreenPreview flag in snapshot --- indra/newview/llfloatertwitter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index ffe2609972..08b0cb6097 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -236,6 +236,7 @@ void LLTwitterPhotoPanel::onVisibilityChange(const LLSD& new_visibility) previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG); previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots + previewp->setAllowFullScreenPreview(FALSE); // No full screen preview in SL Share mode previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect()); updateControls(); -- cgit v1.2.3 From 4e1c0f2c31475132f1d40cea96b243d7e99e00ff Mon Sep 17 00:00:00 2001 From: Cho Date: Thu, 6 Feb 2014 21:58:54 +0000 Subject: changed Facebook default image upload size to 1200x630 and Twitter to 800x600 --- indra/newview/llfloatertwitter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 08b0cb6097..ab5a8e6859 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -91,6 +91,7 @@ BOOL LLTwitterPhotoPanel::postBuild() mSnapshotPanel = getChild("snapshot_panel"); mResolutionComboBox = getChild("resolution_combobox"); + mResolutionComboBox->setValue("[i800,i600]"); // hardcoded defaults ftw! mResolutionComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); mFilterComboBox = getChild("filters_combobox"); mFilterComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); -- cgit v1.2.3 From 5f7e462d0f4cb3d9bdb84a51e8922b5e9130366c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 10 Feb 2014 14:22:53 -0800 Subject: ACME-1318 : Handle No filter a bit more smartly so we don't fail on an unknown filter to do nothing... --- indra/newview/llfloatertwitter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index ab5a8e6859..c37e3ad396 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -422,7 +422,8 @@ void LLTwitterPhotoPanel::updateResolution(BOOL do_update) S32 width = sdres[0]; S32 height = sdres[1]; - const std::string& filter_name = filterbox->getSimple(); + // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale + std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : ""); LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); if (previewp && combobox->getCurrentIndex() >= 0) -- cgit v1.2.3 From de89552dc968f5b87c305fc661d15a50956a70d6 Mon Sep 17 00:00:00 2001 From: Cho Date: Tue, 11 Feb 2014 00:37:46 +0000 Subject: Added #SecondLife to default Twitter status for ACME-1319 --- indra/newview/llfloatertwitter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index ab5a8e6859..d5039bd933 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -56,6 +56,7 @@ static LLRegisterPanelClassWrapper t_panel_account("lltwi const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte const std::string DEFAULT_PHOTO_LOCATION_URL = "http://maps.secondlife.com/"; const std::string DEFAULT_PHOTO_QUERY_PARAMETERS = "?sourceid=slshare_photo&utm_source=twitter&utm_medium=photo&utm_campaign=slshare"; +const std::string DEFAULT_STATUS_TEXT = " #SecondLife"; /////////////////////////// //LLTwitterPhotoPanel/////// @@ -100,6 +101,7 @@ BOOL LLTwitterPhotoPanel::postBuild() mThumbnailPlaceholder = getChild("thumbnail_placeholder"); mStatusCounterLabel = getChild("status_counter_label"); mStatusTextBox = getChild("photo_status"); + mStatusTextBox->setValue(DEFAULT_STATUS_TEXT); mLocationCheckbox = getChild("add_location_cb"); mLocationCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddLocationToggled, this)); mPhotoCheckbox = getChild("add_photo_cb"); @@ -351,7 +353,7 @@ void LLTwitterPhotoPanel::sendPhoto() void LLTwitterPhotoPanel::clearAndClose() { - mStatusTextBox->setValue(""); + mStatusTextBox->setValue(DEFAULT_STATUS_TEXT); LLFloater* floater = getParentByType(); if (floater) -- cgit v1.2.3 From 279e9b0743dfd86f9b40f693349aae9fc1268d35 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 27 Feb 2014 13:04:23 -0800 Subject: ACME-1327 : Implemented preview in all SL Share panels, switch ownership of preview to focused SL Share photo panel --- indra/newview/llfloatertwitter.cpp | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'indra/newview/llfloatertwitter.cpp') 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("filters_combobox"); mFilterComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); mRefreshBtn = getChild("new_snapshot_btn"); + mBtnPreview = getChild("big_preview_btn"); mWorkingLabel = getChild("working_lbl"); mThumbnailPlaceholder = getChild("thumbnail_placeholder"); mStatusCounterLabel = getChild("status_counter_label"); @@ -108,6 +113,7 @@ BOOL LLTwitterPhotoPanel::postBuild() mPhotoCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddPhotoToggled, this)); mPostButton = getChild("post_photo_btn"); mCancelButton = getChild("cancel_photo_btn"); + mBigPreviewFloater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); // Update filter list std::vector 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())); + 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()); + } +} + 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(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(LLFloaterReg::getInstance("big_preview")); + if (big_preview_floater) + { + big_preview_floater->closeOnFloaterOwnerClosing(this); + } closeFloater(); } -- cgit v1.2.3 From e1337ce16e1575c544906dfb5c396fa7b517f112 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 10 Mar 2014 16:01:50 -0700 Subject: MAINT-3555 : Consitency fix after merge of changeset f269634 in viewer-acme --- indra/newview/llfloatertwitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index 0b2987a3c1..f20d886b7f 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -51,8 +51,8 @@ #include "lltabcontainer.h" #include "lltexteditor.h" -static LLRegisterPanelClassWrapper t_panel_photo("lltwitterphotopanel"); -static LLRegisterPanelClassWrapper t_panel_account("lltwitteraccountpanel"); +static LLPanelInjector t_panel_photo("lltwitterphotopanel"); +static LLPanelInjector t_panel_account("lltwitteraccountpanel"); const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte const std::string DEFAULT_PHOTO_LOCATION_URL = "http://maps.secondlife.com/"; -- cgit v1.2.3 From 3eb53f5426a710b0403a84bd6849fe48553194eb Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 7 May 2014 07:42:48 -0700 Subject: Fix Windows build issues: change in onVisibility() profile needed to percolate to SL Share panels --- indra/newview/llfloatertwitter.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfloatertwitter.cpp') diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp index f20d886b7f..78e9259919 100644 --- a/indra/newview/llfloatertwitter.cpp +++ b/indra/newview/llfloatertwitter.cpp @@ -229,9 +229,8 @@ LLSnapshotLivePreview* LLTwitterPhotoPanel::getPreviewView() return previewp; } -void LLTwitterPhotoPanel::onVisibilityChange(const LLSD& new_visibility) +void LLTwitterPhotoPanel::onVisibilityChange(BOOL visible) { - bool visible = new_visibility.asBoolean(); if (visible) { if (mPreviewHandle.get()) @@ -592,10 +591,8 @@ void LLTwitterAccountPanel::draw() LLPanel::draw(); } -void LLTwitterAccountPanel::onVisibilityChange(const LLSD& new_visibility) +void LLTwitterAccountPanel::onVisibilityChange(BOOL visible) { - bool visible = new_visibility.asBoolean(); - if(visible) { LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterAccountPanel"); -- cgit v1.2.3