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

master
Merov Linden 2014-01-30 18:53:05 -08:00
parent c7c755b82e
commit e970fa7f1c
13 changed files with 144 additions and 163 deletions

View File

@ -229,6 +229,34 @@ BOOL LLFacebookPhotoPanel::postBuild()
return LLPanel::postBuild();
}
// virtual
S32 LLFacebookPhotoPanel::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 LLFacebookPhotoPanel::draw()
{
LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
@ -310,6 +338,7 @@ void LLFacebookPhotoPanel::onVisibilityChange(const LLSD& new_visibility)
mPreviewHandle = previewp->getHandle();
mQuality = MAX_QUALITY;
previewp->setContainer(this);
previewp->setSnapshotType(previewp->SNAPSHOT_WEB);
previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG);
previewp->setSnapshotQuality(mQuality, false);
@ -861,38 +890,6 @@ void LLFloaterFacebook::showPhotoPanel()
parent->selectTabPanel(mFacebookPhotoPanel);
}
// static
void LLFloaterFacebook::preUpdate()
{
LLFloaterFacebook* instance = LLFloaterReg::findTypedInstance<LLFloaterFacebook>("facebook");
if (instance)
{
//Will set file size text to 'unknown'
instance->mFacebookPhotoPanel->updateControls();
}
}
// static
void LLFloaterFacebook::postUpdate()
{
LLFloaterFacebook* instance = LLFloaterReg::findTypedInstance<LLFloaterFacebook>("facebook");
if (instance)
{
//Will set the file size text
instance->mFacebookPhotoPanel->updateControls();
// The refresh button is initially hidden. We show it after the first update,
// i.e. after snapshot is taken
LLUICtrl * refresh_button = instance->mFacebookPhotoPanel->getRefreshBtn();
if (!refresh_button->getVisible())
{
refresh_button->setVisible(true);
}
}
}
void LLFloaterFacebook::draw()
{
if (mStatusErrorText && mStatusLoadingText && mStatusLoadingIndicator)

View File

@ -66,6 +66,7 @@ public:
void onVisibilityChange(const LLSD& new_visibility);
void onClickNewSnapshot();
void onSend();
S32 notify(const LLSD& info);
bool onFacebookConnectStateChange(const LLSD& data);
void sendPhoto();
@ -156,9 +157,6 @@ public:
void showPhotoPanel();
static void preUpdate();
static void postUpdate();
private:
LLFacebookPhotoPanel* mFacebookPhotoPanel;
LLTextBox* mStatusErrorText;

View File

@ -118,6 +118,34 @@ BOOL LLFlickrPhotoPanel::postBuild()
return LLPanel::postBuild();
}
// virtual
S32 LLFlickrPhotoPanel::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 LLFlickrPhotoPanel::draw()
{
LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
@ -201,6 +229,7 @@ void LLFlickrPhotoPanel::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
@ -605,38 +634,6 @@ void LLFloaterFlickr::showPhotoPanel()
parent->selectTabPanel(mFlickrPhotoPanel);
}
// static
void LLFloaterFlickr::preUpdate()
{
LLFloaterFlickr* instance = LLFloaterReg::findTypedInstance<LLFloaterFlickr>("flickr");
if (instance)
{
//Will set file size text to 'unknown'
instance->mFlickrPhotoPanel->updateControls();
}
}
// static
void LLFloaterFlickr::postUpdate()
{
LLFloaterFlickr* instance = LLFloaterReg::findTypedInstance<LLFloaterFlickr>("flickr");
if (instance)
{
//Will set the file size text
instance->mFlickrPhotoPanel->updateControls();
// The refresh button is initially hidden. We show it after the first update,
// i.e. after snapshot is taken
LLUICtrl * refresh_button = instance->mFlickrPhotoPanel->getRefreshBtn();
if (!refresh_button->getVisible())
{
refresh_button->setVisible(true);
}
}
}
void LLFloaterFlickr::draw()
{
if (mStatusErrorText && mStatusLoadingText && mStatusLoadingIndicator)

View File

@ -42,6 +42,7 @@ public:
~LLFlickrPhotoPanel();
BOOL postBuild();
S32 notify(const LLSD& info);
void draw();
LLSnapshotLivePreview* getPreviewView();
@ -73,7 +74,7 @@ private:
LLUICtrl * mTagsTextBox;
LLUICtrl * mRatingComboBox;
LLUICtrl * mPostButton;
LLUICtrl* mCancelButton;
LLUICtrl * mCancelButton;
};
class LLFlickrAccountPanel : public LLPanel
@ -114,9 +115,6 @@ public:
void showPhotoPanel();
static void preUpdate();
static void postUpdate();
private:
LLFlickrPhotoPanel* mFlickrPhotoPanel;
LLTextBox* mStatusErrorText;

View File

@ -1091,6 +1091,7 @@ BOOL LLFloaterSnapshot::postBuild()
getChild<LLComboBox>("local_format_combo")->selectNthItem(0);
impl.mPreviewHandle = previewp->getHandle();
previewp->setContainer(this);
impl.updateControls(this);
impl.updateLayout(this);
@ -1255,6 +1256,32 @@ S32 LLFloaterSnapshot::notify(const LLSD& info)
impl.setStatus(Impl::STATUS_FINISHED, data["ok"].asBoolean(), data["msg"].asString());
return 1;
}
if (info.has("snapshot-updating"))
{
// Disable the send/post/save buttons until snapshot is ready.
impl.updateControls(this);
// Force hiding the "Refresh to save" hint because we know we've just started refresh.
impl.setNeedRefresh(this, false);
return 1;
}
if (info.has("snapshot-updated"))
{
// Enable the send/post/save buttons.
impl.updateControls(this);
// We've just done refresh.
impl.setNeedRefresh(this, false);
// The refresh button is initially hidden. We show it after the first update,
// i.e. when preview appears.
if (!mRefreshBtn->getVisible())
{
mRefreshBtn->setVisible(true);
}
return 1;
}
return 0;
}
@ -1333,43 +1360,6 @@ BOOL LLFloaterSnapshot::saveLocal()
return previewp->saveLocal();
}
// static
void LLFloaterSnapshot::preUpdate()
{
// FIXME: duplicated code
LLFloaterSnapshot* instance = LLFloaterReg::findTypedInstance<LLFloaterSnapshot>("snapshot");
if (instance)
{
// Disable the send/post/save buttons until snapshot is ready.
Impl::updateControls(instance);
// Force hiding the "Refresh to save" hint because we know we've just started refresh.
Impl::setNeedRefresh(instance, false);
}
}
// static
void LLFloaterSnapshot::postUpdate()
{
// FIXME: duplicated code
LLFloaterSnapshot* instance = LLFloaterReg::findTypedInstance<LLFloaterSnapshot>("snapshot");
if (instance)
{
// Enable the send/post/save buttons.
Impl::updateControls(instance);
// We've just done refresh.
Impl::setNeedRefresh(instance, false);
// The refresh button is initially hidden. We show it after the first update,
// i.e. when preview appears.
if (!instance->mRefreshBtn->getVisible())
{
instance->mRefreshBtn->setVisible(true);
}
}
}
// static
void LLFloaterSnapshot::postSave()
{

View File

@ -58,8 +58,6 @@ public:
static LLFloaterSnapshot* getInstance();
static void saveTexture();
static BOOL saveLocal();
static void preUpdate();
static void postUpdate();
static void postSave();
static void postPanelSwitch();
static LLPointer<LLImageFormatted> getImageData();

View File

@ -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<LLSnapshotLivePreview *>(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<LLFloaterTwitter>("twitter");
if (instance)
{
//Will set file size text to 'unknown'
instance->mTwitterPhotoPanel->updateControls();
}
}
// static
void LLFloaterTwitter::postUpdate()
{
LLFloaterTwitter* instance = LLFloaterReg::findTypedInstance<LLFloaterTwitter>("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)

View File

@ -50,6 +50,7 @@ public:
void onAddPhotoToggled();
void onClickNewSnapshot();
void onSend();
S32 notify(const LLSD& info);
bool onTwitterConnectStateChange(const LLSD& data);
void sendPhoto();
@ -75,7 +76,7 @@ private:
LLUICtrl * mLocationCheckbox;
LLUICtrl * mPhotoCheckbox;
LLUICtrl * mPostButton;
LLUICtrl* mCancelButton;
LLUICtrl * mCancelButton;
std::string mOldStatusText;
};
@ -118,9 +119,6 @@ public:
void showPhotoPanel();
static void preUpdate();
static void postUpdate();
private:
LLTwitterPhotoPanel* mTwitterPhotoPanel;
LLTextBox* mStatusErrorText;

View File

@ -94,7 +94,8 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param
mSnapshotActive(FALSE),
mSnapshotBufferType(LLViewerWindow::SNAPSHOT_TYPE_COLOR),
mFilterName(""),
mAllowRenderUI(TRUE)
mAllowRenderUI(TRUE),
mViewContainer(NULL)
{
setSnapshotQuality(gSavedSettings.getS32("SnapshotQuality"));
mSnapshotDelayTimer.setTimerExpirySec(0.0f);
@ -189,13 +190,14 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail
// Stop shining animation.
mShineAnimTimer.stop();
mSnapshotDelayTimer.start();
mSnapshotDelayTimer.setTimerExpirySec(delay);
LLFloaterSnapshot::preUpdate();
LLFloaterFacebook::preUpdate();
LLFloaterFlickr::preUpdate();
LLFloaterTwitter::preUpdate();
// Tell the floater container that the snapshot is in the process of updating itself
if (mViewContainer)
{
mViewContainer->notify(LLSD().with("snapshot-updating", true));
}
}
// Update thumbnail if requested.
@ -731,10 +733,12 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
{
previewp->generateThumbnailImage() ;
}
LLFloaterSnapshot::postUpdate();
LLFloaterFacebook::postUpdate();
LLFloaterFlickr::postUpdate();
LLFloaterTwitter::postUpdate();
// Tell the floater container that the snapshot is updated now
if (previewp->mViewContainer)
{
previewp->mViewContainer->notify(LLSD().with("snapshot-updated", true));
}
return TRUE;
}

View File

@ -61,6 +61,8 @@ public:
LLSnapshotLivePreview(const LLSnapshotLivePreview::Params& p);
~LLSnapshotLivePreview();
void setContainer(LLView* container) { mViewContainer = container; }
/*virtual*/ void draw();
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent);
@ -124,6 +126,8 @@ public:
void regionNameCallback(LLImageJPEG* snapshot, LLSD& metadata, const std::string& name, S32 x, S32 y, S32 z);
private:
LLView* mViewContainer;
LLColor4 mColor;
LLPointer<LLViewerTexture> mViewerImage[2]; //used to represent the scene when the frame is frozen.
LLRect mImageRect[2];

View File

@ -15,7 +15,7 @@
name="snapshot_panel"
height="367">
<combo_box
control_name="SocialPhotoResolution"
control_name="FacebookPhotoResolution"
follows="left|top"
top="6"
left="9"
@ -45,7 +45,7 @@
value="[i1200,i630]" />
</combo_box>
<combo_box
control_name="SocialPhotoFilters"
control_name="FacebookPhotoFilters"
follows="right|top"
name="filters_combobox"
tool_tip="Image filters"

View File

@ -15,7 +15,7 @@
name="snapshot_panel"
height="507">
<combo_box
control_name="SocialPhotoResolution"
control_name="FlickrPhotoResolution"
follows="left|top"
top="6"
left="9"
@ -41,7 +41,7 @@
value="[i1024,i768]" />
</combo_box>
<combo_box
control_name="SocialPhotoFilters"
control_name="FlickrPhotoFilters"
follows="right|top"
name="filters_combobox"
tool_tip="Image filters"

View File

@ -71,7 +71,7 @@
name="snapshot_panel"
height="227">
<combo_box
control_name="SocialPhotoResolution"
control_name="TwitterPhotoResolution"
follows="left|top"
top="6"
left="9"
@ -97,7 +97,7 @@
value="[i1024,i768]" />
</combo_box>
<combo_box
control_name="SocialPhotoFilters"
control_name="TwitterPhotoFilters"
follows="right|top"
name="filters_combobox"
tool_tip="Image filters"