WIP: floater_snapshot_feed.xml and code.
This is just a skeleton, roughly copied from the Postcoard code, which is very similar. Nothing in indra/newview/llfloaterfeed.cpp has been changed yet, apart from a few deletions (to make it compile) and the literal replacement of "Postcard" with "Feed". indra/newview/llfloatersnapshot.cpp was updated however to open the new floater when one tries to upload a snapshot to the feed. It is still needed to make a callback to saveFeed(), or rather to move that function to the saveFeed that is in llfloatersnapshot.cpp.
This commit is contained in:
@@ -241,6 +241,7 @@ set(viewer_SOURCE_FILES
|
||||
llfloatersellland.cpp
|
||||
llfloatersettingsdebug.cpp
|
||||
llfloatersnapshot.cpp
|
||||
llfloaterfeed.cpp
|
||||
llfloaterstats.cpp
|
||||
llfloatertelehub.cpp
|
||||
llfloaterteleporthistory.cpp
|
||||
@@ -748,6 +749,7 @@ set(viewer_HEADER_FILES
|
||||
llfloatersellland.h
|
||||
llfloatersettingsdebug.h
|
||||
llfloatersnapshot.h
|
||||
llfloaterfeed.h
|
||||
llfloaterstats.h
|
||||
llfloatertelehub.h
|
||||
llfloaterteleporthistory.h
|
||||
|
||||
@@ -6586,6 +6586,22 @@ This should be as low as possible, but too low may break functionality</string>
|
||||
<integer>400</integer>
|
||||
</array>
|
||||
</map>
|
||||
<key>FloaterSnapshotFeedRect</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Rectangle for snapshot feed window</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Rect</string>
|
||||
<key>Value</key>
|
||||
<array>
|
||||
<integer>0</integer>
|
||||
<integer>200</integer>
|
||||
<integer>200</integer>
|
||||
<integer>400</integer>
|
||||
</array>
|
||||
</map>
|
||||
<key>FloaterSoundsRect</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
|
||||
239
indra/newview/llfloaterfeed.cpp
Normal file
239
indra/newview/llfloaterfeed.cpp
Normal file
@@ -0,0 +1,239 @@
|
||||
/**
|
||||
* @file llfloaterfeed.cpp
|
||||
* @brief Feed send floater, allows setting caption and whether or to add location, etc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2012&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2004-2009, Linden Research, Inc.
|
||||
* Copyright (c) 2012, Aleric Ingelwood.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
|
||||
#include "llfloaterfeed.h"
|
||||
|
||||
#include "llfontgl.h"
|
||||
#include "llsys.h"
|
||||
#include "llgl.h"
|
||||
#include "v3dmath.h"
|
||||
#include "lldir.h"
|
||||
|
||||
#include "llagent.h"
|
||||
#include "llui.h"
|
||||
#include "lllineeditor.h"
|
||||
#include "llviewertexteditor.h"
|
||||
#include "llbutton.h"
|
||||
#include "llnotificationsutil.h"
|
||||
#include "llviewercontrol.h"
|
||||
#include "llviewernetwork.h"
|
||||
#include "lluictrlfactory.h"
|
||||
#include "lluploaddialog.h"
|
||||
#include "llviewerstats.h"
|
||||
#include "llviewerwindow.h"
|
||||
#include "llstatusbar.h"
|
||||
#include "llviewerregion.h"
|
||||
#include "lleconomy.h"
|
||||
#include "lltrans.h"
|
||||
|
||||
#include "llgl.h"
|
||||
#include "llglheaders.h"
|
||||
#include "llimagepng.h"
|
||||
#include "llimagej2c.h"
|
||||
#include "llvfile.h"
|
||||
#include "llvfs.h"
|
||||
|
||||
#include "llassetuploadresponders.h"
|
||||
|
||||
#include "hippogridmanager.h"
|
||||
|
||||
///----------------------------------------------------------------------------
|
||||
/// Class LLFloaterFeed
|
||||
///----------------------------------------------------------------------------
|
||||
|
||||
LLFloaterFeed::LLFloaterFeed(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale, LLVector3d const& pos_taken_global) :
|
||||
LLFloater(std::string("Feed Floater")),
|
||||
mPNGImage(png), mViewerImage(img), mImageScale(img_scale), mPosTakenGlobal(pos_taken_global), mHasFirstMsgFocus(false)
|
||||
{
|
||||
}
|
||||
|
||||
// Destroys the object
|
||||
LLFloaterFeed::~LLFloaterFeed()
|
||||
{
|
||||
mPNGImage = NULL;
|
||||
}
|
||||
|
||||
BOOL LLFloaterFeed::postBuild()
|
||||
{
|
||||
childSetAction("cancel_btn", onClickCancel, this);
|
||||
childSetAction("send_btn", onClickSend, this);
|
||||
|
||||
childDisable("from_form");
|
||||
|
||||
std::string name_string;
|
||||
gAgent.buildFullname(name_string);
|
||||
childSetValue("name_form", LLSD(name_string));
|
||||
|
||||
LLTextEditor* MsgField = getChild<LLTextEditor>("msg_form");
|
||||
if (MsgField)
|
||||
{
|
||||
MsgField->setWordWrap(TRUE);
|
||||
|
||||
// For the first time a user focusess to .the msg box, all text will be selected.
|
||||
MsgField->setFocusChangedCallback(boost::bind(&LLFloaterFeed::onMsgFormFocusRecieved, this, _1, MsgField));
|
||||
}
|
||||
|
||||
childSetFocus("to_form", TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// static
|
||||
LLFloaterFeed* LLFloaterFeed::showFromSnapshot(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& image_scale, LLVector3d const& pos_taken_global)
|
||||
{
|
||||
// Take the images from the caller
|
||||
// It's now our job to clean them up
|
||||
LLFloaterFeed* instance = new LLFloaterFeed(png, img, image_scale, pos_taken_global);
|
||||
|
||||
LLUICtrlFactory::getInstance()->buildFloater(instance, "floater_snapshot_feed.xml");
|
||||
|
||||
S32 left, top;
|
||||
gFloaterView->getNewFloaterPosition(&left, &top);
|
||||
instance->setOrigin(left, top - instance->getRect().getHeight());
|
||||
|
||||
instance->open();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void LLFloaterFeed::draw(void)
|
||||
{
|
||||
LLGLSUIDefault gls_ui;
|
||||
LLFloater::draw();
|
||||
|
||||
if (!isMinimized() && mViewerImage.notNull() && mPNGImage.notNull())
|
||||
{
|
||||
LLRect rect(getRect());
|
||||
|
||||
// First set the max extents of our preview.
|
||||
rect.translate(-rect.mLeft, -rect.mBottom);
|
||||
rect.mLeft += 10;
|
||||
rect.mRight -= 10;
|
||||
rect.mTop -= 25;
|
||||
rect.mBottom = rect.mTop - 150;
|
||||
|
||||
// Then fix the aspect ratio.
|
||||
F32 ratio = (F32)mPNGImage->getWidth() / (F32)mPNGImage->getHeight();
|
||||
if ((F32)rect.getWidth() / (F32)rect.getHeight() >= ratio)
|
||||
{
|
||||
rect.mRight = (S32)((F32)rect.mLeft + ((F32)rect.getHeight() * ratio));
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.mBottom = (S32)((F32)rect.mTop - ((F32)rect.getWidth() / ratio));
|
||||
}
|
||||
{
|
||||
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
|
||||
gl_rect_2d(rect, LLColor4(0.f, 0.f, 0.f, 1.f));
|
||||
rect.stretch(-1);
|
||||
}
|
||||
{
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
gGL.scalef(mImageScale.mV[VX], mImageScale.mV[VY], 1.f);
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
gl_draw_scaled_image(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), mViewerImage, LLColor4::white);
|
||||
}
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.popMatrix();
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLFloaterFeed::onClickCancel(void* data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
LLFloaterFeed* self = (LLFloaterFeed*)data;
|
||||
|
||||
self->close(false);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLFloaterFeed::onClickSend(void* data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
LLFloaterFeed* self = (LLFloaterFeed*)data;
|
||||
|
||||
std::string from(self->childGetValue("from_form").asString());
|
||||
std::string to(self->childGetValue("to_form").asString());
|
||||
|
||||
if (self->mPNGImage.notNull())
|
||||
{
|
||||
self->sendFeed();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLNotificationsUtil::add("ErrorProcessingSnapshot");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLFloaterFeed::onMsgFormFocusRecieved(LLFocusableElement* receiver, LLTextEditor* msg_form)
|
||||
{
|
||||
if (msg_form && msg_form == receiver && msg_form->hasFocus() && !(mHasFirstMsgFocus))
|
||||
{
|
||||
mHasFirstMsgFocus = true;
|
||||
msg_form->setText(LLStringUtil::null);
|
||||
}
|
||||
}
|
||||
|
||||
void LLFloaterFeed::sendFeed(void)
|
||||
{
|
||||
// upload the image
|
||||
// DO THE UPLOAD HERE
|
||||
|
||||
// give user feedback of the event
|
||||
gViewerWindow->playSnapshotAnimAndSound();
|
||||
LLUploadDialog::modalUploadDialog(getString("upload_message"));
|
||||
|
||||
// don't destroy the window until the upload is done
|
||||
// this way we keep the information in the form
|
||||
setVisible(FALSE);
|
||||
|
||||
// also remove any dependency on another floater
|
||||
// so that we can be sure to outlive it while we
|
||||
// need to.
|
||||
LLFloater* dependee = getDependee();
|
||||
if (dependee)
|
||||
{
|
||||
dependee->removeDependentFloater(this);
|
||||
}
|
||||
}
|
||||
78
indra/newview/llfloaterfeed.h
Normal file
78
indra/newview/llfloaterfeed.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file llfloaterfeed.h
|
||||
* @brief Feed send floater, allows setting caption and whether or not to include location.
|
||||
*
|
||||
* Copyright (c) 2004-2009, Linden Research, Inc.
|
||||
* Copyright (c) 2012, Aleric Inglewood.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLFLOATERFEED_H
|
||||
#define LL_LLFLOATERFEED_H
|
||||
|
||||
#include "llfloater.h" // LLFloater
|
||||
#include "v2math.h" // LLVector2
|
||||
#include "v3dmath.h" // LLVector3d
|
||||
#include "llpointer.h" // LLPointer
|
||||
#include "llextendedstatus.h" // LLExtStat
|
||||
|
||||
class LLImagePNG;
|
||||
class LLViewerTexture;
|
||||
class LLUUID;
|
||||
class LLFocusableElement;
|
||||
class LLTextEditor;
|
||||
class LLSD;
|
||||
|
||||
class LLFloaterFeed : public LLFloater
|
||||
{
|
||||
public:
|
||||
LLFloaterFeed(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale, LLVector3d const& pos_taken_global);
|
||||
virtual ~LLFloaterFeed();
|
||||
|
||||
virtual BOOL postBuild(void);
|
||||
virtual void draw(void);
|
||||
|
||||
static LLFloaterFeed* showFromSnapshot(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale, LLVector3d const& pos_taken_global);
|
||||
|
||||
static void onClickCancel(void* data);
|
||||
static void onClickSend(void* data);
|
||||
|
||||
static void uploadCallback(LLUUID const& asset_id, void* user_data, S32 result, LLExtStat ext_status);
|
||||
|
||||
void onMsgFormFocusRecieved(LLFocusableElement* receiver, LLTextEditor* msg_form);
|
||||
bool missingSubjMsgAlertCallback(LLSD const& notification, LLSD const& response);
|
||||
|
||||
void sendFeed(void);
|
||||
|
||||
protected:
|
||||
|
||||
LLPointer<LLImagePNG> mPNGImage;
|
||||
LLPointer<LLViewerTexture> mViewerImage;
|
||||
LLVector2 mImageScale;
|
||||
LLVector3d mPosTakenGlobal;
|
||||
bool mHasFirstMsgFocus;
|
||||
};
|
||||
|
||||
#endif // LL_LLFLOATERFEED_H
|
||||
@@ -65,6 +65,7 @@
|
||||
#include "llwindow.h"
|
||||
#include "llviewermenufile.h" // upload_new_resource()
|
||||
#include "llfloaterpostcard.h"
|
||||
#include "llfloaterfeed.h"
|
||||
#include "llcheckboxctrl.h"
|
||||
#include "llradiogroup.h"
|
||||
#include "lltoolfocus.h"
|
||||
@@ -174,7 +175,8 @@ public:
|
||||
void setSnapshotBufferType(LLFloaterSnapshot* floater, LLViewerWindow::ESnapshotType type);
|
||||
void showFreezeFrameSnapshot(bool show);
|
||||
void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f);
|
||||
void saveFeed();
|
||||
LLFloaterFeed* getCaptionAndSaveFeed();
|
||||
void saveFeed(std::string const& caption, bool add_location);
|
||||
LLFloaterPostcard* savePostcard();
|
||||
void saveTexture();
|
||||
void saveTextureDone(bool success);
|
||||
@@ -1180,17 +1182,43 @@ void LLSnapshotLivePreview::getRawSize(S32& w, S32& h) const
|
||||
h = mRawSnapshotHeight;
|
||||
}
|
||||
|
||||
void LLSnapshotLivePreview::saveFeed()
|
||||
LLFloaterFeed* LLSnapshotLivePreview::getCaptionAndSaveFeed()
|
||||
{
|
||||
DoutEntering(dc::notice, "LLSnapshotLivePreview::saveFeed()");
|
||||
|
||||
mCallbackHappened = false;
|
||||
mSaveSuccessful = false;
|
||||
mCloseCalled = NULL;
|
||||
|
||||
std::string caption = "This is a test caption.";
|
||||
bool add_location = true;
|
||||
if (mFullScreenPreviewTexture.isNull())
|
||||
{
|
||||
// This should never happen!
|
||||
llwarns << "The snapshot image has not been generated!" << llendl;
|
||||
saveFeedDone(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Calculate and pass in image scale in case image data only uses portion of viewerimage buffer.
|
||||
F32 uv_width = mFullScreenPreviewTextureNeedsScaling ? llmin((F32)mFormattedWidth / (F32)mFullScreenPreviewTexture->getWidth(), 1.f) : 1.f;
|
||||
F32 uv_height = mFullScreenPreviewTextureNeedsScaling ? llmin((F32)mFormattedHeight / (F32)mFullScreenPreviewTexture->getHeight(), 1.f) : 1.f;
|
||||
LLVector2 image_scale(uv_width, uv_height);
|
||||
|
||||
LLImagePNG* png = dynamic_cast<LLImagePNG*>(mFormattedImage.get());
|
||||
if (!png)
|
||||
{
|
||||
llwarns << "Formatted image not a PNG" << llendl;
|
||||
saveFeedDone(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LLFloaterFeed* floater = LLFloaterFeed::showFromSnapshot(png, mFullScreenPreviewTexture, image_scale, mPosTakenGlobal);
|
||||
|
||||
//updateSnapshot(FALSE, FALSE);
|
||||
|
||||
return floater;
|
||||
}
|
||||
|
||||
void LLSnapshotLivePreview::saveFeed(std::string const& caption, bool add_location)
|
||||
{
|
||||
DoutEntering(dc::notice, "LLSnapshotLivePreview::saveFeed()");
|
||||
LLWebProfile::setImageUploadResultCallback(boost::bind(&LLFloaterSnapshot::saveFeedDone, _1));
|
||||
LLWebProfile::uploadImage(mFormattedImage, caption, add_location);
|
||||
}
|
||||
@@ -1910,7 +1938,15 @@ void LLFloaterSnapshot::Impl::onClickKeep(void* data)
|
||||
{
|
||||
if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_FEED)
|
||||
{
|
||||
previewp->saveFeed();
|
||||
LLFloaterFeed* floater = previewp->getCaptionAndSaveFeed();
|
||||
// If still in snapshot mode, put feed floater in snapshot floaterview
|
||||
// and link it to snapshot floater.
|
||||
if (floater && !gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
|
||||
{
|
||||
gFloaterView->removeChild(floater);
|
||||
gSnapshotFloaterView->addChild(floater);
|
||||
view->addDependentFloater(floater, FALSE);
|
||||
}
|
||||
}
|
||||
else if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_POSTCARD)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<floater
|
||||
can_minimize="false"
|
||||
title="Post to My Profile Feed"
|
||||
height="380"
|
||||
width="480"
|
||||
layout="topleft"
|
||||
name="floater_snapshot_profile"
|
||||
rect_control="FloaterSnapshotFeedRect">
|
||||
<text
|
||||
length="1"
|
||||
follows="top|left"
|
||||
top="-180"
|
||||
font="SansSerif"
|
||||
height="16"
|
||||
layout="topleft"
|
||||
left="10"
|
||||
name="caption_label"
|
||||
right="-10"
|
||||
type="string">
|
||||
Enter text to post below:
|
||||
</text>
|
||||
<text_editor
|
||||
follows="all"
|
||||
height="155"
|
||||
layout="topleft"
|
||||
length="1"
|
||||
max_length="700"
|
||||
name="caption"
|
||||
right="-10"
|
||||
bottom_delta="30"
|
||||
type="string"
|
||||
word_wrap="true"/>
|
||||
<check_box
|
||||
follows="left|bottom"
|
||||
initial_value="true"
|
||||
label="Include location"
|
||||
layout="topleft"
|
||||
left_delta="0"
|
||||
name="add_location_cb"
|
||||
bottom_delta="-25" />
|
||||
<button
|
||||
follows="right|bottom"
|
||||
height="23"
|
||||
label="Cancel"
|
||||
layout="topleft"
|
||||
name="cancel_btn"
|
||||
right="-10"
|
||||
bottom="10"
|
||||
width="100"/>
|
||||
<button
|
||||
follows="right|bottom"
|
||||
height="23"
|
||||
label="Post"
|
||||
layout="topleft"
|
||||
left_delta="-106"
|
||||
name="post_btn"
|
||||
bottom_delta="0"
|
||||
width="100"/>
|
||||
</floater>
|
||||
Reference in New Issue
Block a user