summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermediabrowser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatermediabrowser.cpp')
-rw-r--r--indra/newview/llfloatermediabrowser.cpp146
1 files changed, 137 insertions, 9 deletions
diff --git a/indra/newview/llfloatermediabrowser.cpp b/indra/newview/llfloatermediabrowser.cpp
index 434d0681ab..d20092e344 100644
--- a/indra/newview/llfloatermediabrowser.cpp
+++ b/indra/newview/llfloatermediabrowser.cpp
@@ -45,7 +45,11 @@
#include "llviewermedia.h"
#include "llviewerparcelmedia.h"
#include "llcombobox.h"
+#include "llwindow.h"
+#include "lllayoutstack.h"
+#include "llcheckboxctrl.h"
+#include "llnotifications.h"
// TEMP
#include "llsdutil.h"
@@ -53,10 +57,124 @@
LLFloaterMediaBrowser::LLFloaterMediaBrowser(const LLSD& key)
: LLFloater(key)
{
-// LLUICtrlFactory::getInstance()->buildFloater(this, "floater_media_browser.xml");
+}
+//static
+void LLFloaterMediaBrowser::create(const std::string &url, const std::string& target, const std::string& uuid)
+{
+ lldebugs << "url = " << url << ", target = " << target << ", uuid = " << uuid << llendl;
+
+ std::string tag = target;
+
+ if(target.empty() || target == "_blank")
+ {
+ if(!uuid.empty())
+ {
+ tag = uuid;
+ }
+ else
+ {
+ // create a unique tag for this instance
+ LLUUID id;
+ id.generate();
+ tag = id.asString();
+ }
+ }
+
+ S32 browser_window_limit = gSavedSettings.getS32("MediaBrowserWindowLimit");
+
+ if(LLFloaterReg::findInstance("media_browser", tag) != NULL)
+ {
+ // There's already a media browser for this tag, so we won't be opening a new window.
+ }
+ else if(browser_window_limit != 0)
+ {
+ // showInstance will open a new window. Figure out how many media browsers are already open,
+ // and close the least recently opened one if this will put us over the limit.
+
+ LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList("media_browser");
+ lldebugs << "total instance count is " << instances.size() << llendl;
+
+ for(LLFloaterReg::const_instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); iter++)
+ {
+ lldebugs << " " << (*iter)->getKey() << llendl;
+ }
+
+ if(instances.size() >= (size_t)browser_window_limit)
+ {
+ // Destroy the least recently opened instance
+ (*instances.begin())->closeFloater();
+ }
+ }
+
+ LLFloaterMediaBrowser *browser = dynamic_cast<LLFloaterMediaBrowser*> (LLFloaterReg::showInstance("media_browser", tag));
+ llassert(browser);
+ if(browser)
+ {
+ browser->mUUID = uuid;
+
+ // tell the browser instance to load the specified URL
+ browser->openMedia(url, target);
+ LLViewerMedia::proxyWindowOpened(target, uuid);
+ }
}
+//static
+void LLFloaterMediaBrowser::closeRequest(const std::string &uuid)
+{
+ LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("media_browser");
+ lldebugs << "instance list size is " << inst_list.size() << ", incoming uuid is " << uuid << llendl;
+ for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end(); ++iter)
+ {
+ LLFloaterMediaBrowser* i = dynamic_cast<LLFloaterMediaBrowser*>(*iter);
+ lldebugs << " " << i->mUUID << llendl;
+ if (i && i->mUUID == uuid)
+ {
+ i->closeFloater(false);
+ return;
+ }
+ }
+}
+
+//static
+void LLFloaterMediaBrowser::geometryChanged(const std::string &uuid, S32 x, S32 y, S32 width, S32 height)
+{
+ LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("media_browser");
+ lldebugs << "instance list size is " << inst_list.size() << ", incoming uuid is " << uuid << llendl;
+ for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end(); ++iter)
+ {
+ LLFloaterMediaBrowser* i = dynamic_cast<LLFloaterMediaBrowser*>(*iter);
+ lldebugs << " " << i->mUUID << llendl;
+ if (i && i->mUUID == uuid)
+ {
+ i->geometryChanged(x, y, width, height);
+ return;
+ }
+}
+}
+
+void LLFloaterMediaBrowser::geometryChanged(S32 x, S32 y, S32 width, S32 height)
+{
+ // Make sure the layout of the browser control is updated, so this calculation is correct.
+ LLLayoutStack::updateClass();
+
+ // TODO: need to adjust size and constrain position to make sure floaters aren't moved outside the window view, etc.
+ LLCoordWindow window_size;
+ getWindow()->getSize(&window_size);
+
+ // Adjust width and height for the size of the chrome on the Media Browser window.
+ width += getRect().getWidth() - mBrowser->getRect().getWidth();
+ height += getRect().getHeight() - mBrowser->getRect().getHeight();
+
+ LLRect geom;
+ geom.setOriginAndSize(x, window_size.mY - (y + height), width, height);
+
+ lldebugs << "geometry change: " << geom << llendl;
+
+ handleReshape(geom,false);
+}
+
+
void LLFloaterMediaBrowser::draw()
{
getChildView("go")->setEnabled(!mAddressCombo->getValue().asString().empty());
@@ -99,6 +217,7 @@ BOOL LLFloaterMediaBrowser::postBuild()
mAddressCombo = getChild<LLComboBox>("address");
mAddressCombo->setCommitCallback(onEnterAddress, this);
+ mAddressCombo->sortByName();
childSetAction("back", onClickBack, this);
childSetAction("forward", onClickForward, this);
@@ -114,6 +233,7 @@ BOOL LLFloaterMediaBrowser::postBuild()
childSetAction("assign", onClickAssign, this);
buildURLHistory();
+
return TRUE;
}
@@ -154,6 +274,7 @@ std::string LLFloaterMediaBrowser::getSupportURL()
//virtual
void LLFloaterMediaBrowser::onClose(bool app_quitting)
{
+ LLViewerMedia::proxyWindowClosed(mUUID);
//setVisible(FALSE);
destroy();
}
@@ -170,7 +291,17 @@ void LLFloaterMediaBrowser::handleMediaEvent(LLPluginClassMedia* self, EMediaEve
getChildView("back")->setEnabled(self->getHistoryBackAvailable());
getChildView("forward")->setEnabled(self->getHistoryForwardAvailable());
}
+ else if(event == MEDIA_EVENT_CLOSE_REQUEST)
+ {
+ // The browser instance wants its window closed.
+ closeFloater();
+ }
+ else if(event == MEDIA_EVENT_GEOMETRY_CHANGE)
+ {
+ geometryChanged(self->getGeometryX(), self->getGeometryY(), self->getGeometryWidth(), self->getGeometryHeight());
+ }
}
+
void LLFloaterMediaBrowser::setCurrentURL(const std::string& url)
{
mCurrentURL = url;
@@ -179,7 +310,7 @@ void LLFloaterMediaBrowser::setCurrentURL(const std::string& url)
if (mCurrentURL != "about:blank")
{
mAddressCombo->remove(mCurrentURL);
- mAddressCombo->add(mCurrentURL, ADD_SORTED);
+ mAddressCombo->add(mCurrentURL);
mAddressCombo->selectByValue(mCurrentURL);
// Serialize url history
@@ -191,12 +322,6 @@ void LLFloaterMediaBrowser::setCurrentURL(const std::string& url)
getChildView("reload")->setEnabled(TRUE);
}
-void LLFloaterMediaBrowser::onOpen(const LLSD& media_url)
-{
- LLFloater::onOpen(media_url);
- openMedia(media_url.asString());
-}
-
//static
void LLFloaterMediaBrowser::onEnterAddress(LLUICtrl* ctrl, void* user_data)
{
@@ -322,9 +447,12 @@ void LLFloaterMediaBrowser::onClickSeek(void* user_data)
if(self->mBrowser->getMediaPlugin())
self->mBrowser->getMediaPlugin()->start(2.0f);
}
-void LLFloaterMediaBrowser::openMedia(const std::string& media_url)
+void LLFloaterMediaBrowser::openMedia(const std::string& media_url, const std::string& target)
{
mBrowser->setHomePageUrl(media_url);
+ mBrowser->setTarget(target);
mBrowser->navigateTo(media_url);
setCurrentURL(media_url);
}
+
+