summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/lldockablefloater.cpp4
-rw-r--r--indra/llui/lldockablefloater.h2
-rw-r--r--indra/newview/llscriptfloater.cpp113
-rw-r--r--indra/newview/llscriptfloater.h35
4 files changed, 133 insertions, 21 deletions
diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp
index 57baf28dab..a94f0206a6 100644
--- a/indra/llui/lldockablefloater.cpp
+++ b/indra/llui/lldockablefloater.cpp
@@ -223,10 +223,10 @@ void LLDockableFloater::draw()
LLFloater::draw();
}
-void LLDockableFloater::setDockControl(LLDockControl* dockControl)
+void LLDockableFloater::setDockControl(LLDockControl* dockControl, bool docked /* = true */)
{
mDockControl.reset(dockControl);
- setDocked(mDockControl.get() != NULL && mDockControl.get()->isDockVisible());
+ setDocked(docked && mDockControl.get() != NULL && mDockControl.get()->isDockVisible());
}
const LLUIImagePtr& LLDockableFloater::getDockTongue()
diff --git a/indra/llui/lldockablefloater.h b/indra/llui/lldockablefloater.h
index 2b1ce99ae2..4d747390af 100644
--- a/indra/llui/lldockablefloater.h
+++ b/indra/llui/lldockablefloater.h
@@ -127,7 +127,7 @@ private:
void resetInstance();
protected:
- void setDockControl(LLDockControl* dockControl);
+ void setDockControl(LLDockControl* dockControl, bool docked = true);
const LLUIImagePtr& getDockTongue();
private:
diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp
index a81ec61263..d452ef2228 100644
--- a/indra/newview/llscriptfloater.cpp
+++ b/indra/newview/llscriptfloater.cpp
@@ -67,6 +67,7 @@ LLUUID notification_id_to_object_id(const LLUUID& notification_id)
LLScriptFloater::LLScriptFloater(const LLSD& key)
: LLDockableFloater(NULL, true, key)
, mScriptForm(NULL)
+, mSaveFloaterPosition(false)
{
setMouseDownCallback(boost::bind(&LLScriptFloater::onMouseDown, this));
setOverlapsScreenChannel(true);
@@ -105,27 +106,29 @@ LLScriptFloater* LLScriptFloater::show(const LLUUID& notification_id)
LLScriptFloater* floater = LLFloaterReg::getTypedInstance<LLScriptFloater>("script_floater", notification_id);
floater->setNotificationId(notification_id);
floater->createForm(notification_id);
- LLFloaterReg::showTypedInstance<LLScriptFloater>("script_floater", notification_id, TRUE);
- if (floater->getDockControl() == NULL)
+ if(LLScriptFloaterManager::OBJ_SCRIPT == LLScriptFloaterManager::getObjectType(notification_id))
{
- LLChiclet* chiclet = LLBottomTray::getInstance()->getChicletPanel()->findChiclet<LLChiclet>(notification_id);
- if (chiclet == NULL)
- {
- llerror("Dock chiclet for LLScriptFloater doesn't exist", 0);
- }
- else
- {
- LLBottomTray::getInstance()->getChicletPanel()->scrollToChiclet(chiclet);
- }
-
- floater->setDockControl(new LLDockControl(chiclet, floater, floater->getDockTongue(),
- LLDockControl::TOP, boost::bind(&LLScriptFloater::getAllowedRect, floater, _1)));
+ floater->setSavePosition(true);
+ floater->restorePosition();
+ }
+ else
+ {
+ floater->dockToChiclet(true);
}
+ LLFloaterReg::showTypedInstance<LLScriptFloater>("script_floater", notification_id, TRUE);
+
return floater;
}
+void LLScriptFloater::setNotificationId(const LLUUID& id)
+{
+ mNotificationId = id;
+ // Lets save object id now while notification exists
+ mObjectId = notification_id_to_object_id(id);
+}
+
void LLScriptFloater::getAllowedRect(LLRect& rect)
{
rect = gViewerWindow->getWorldViewRectRaw();
@@ -162,6 +165,8 @@ void LLScriptFloater::createForm(const LLUUID& notification_id)
void LLScriptFloater::onClose(bool app_quitting)
{
+ savePosition();
+
if(getNotificationId().notNull())
{
LLScriptFloaterManager::getInstance()->onRemoveNotification(getNotificationId());
@@ -172,6 +177,8 @@ void LLScriptFloater::setDocked(bool docked, bool pop_on_undock /* = true */)
{
LLDockableFloater::setDocked(docked, pop_on_undock);
+ savePosition();
+
hideToastsIfNeeded();
}
@@ -208,6 +215,33 @@ void LLScriptFloater::onMouseDown()
}
}
+void LLScriptFloater::savePosition()
+{
+ if(getSavePosition() && mObjectId.notNull())
+ {
+ LLScriptFloaterManager::FloaterPositionInfo fpi = {getRect(), isDocked()};
+ LLScriptFloaterManager::getInstance()->saveFloaterPosition(mObjectId, fpi);
+ }
+}
+
+void LLScriptFloater::restorePosition()
+{
+ LLScriptFloaterManager::FloaterPositionInfo fpi;
+ if(LLScriptFloaterManager::getInstance()->getFloaterPosition(mObjectId, fpi))
+ {
+ dockToChiclet(fpi.mDockState);
+ if(!fpi.mDockState)
+ {
+ // Un-docked floater is opened in 0,0, now move it to saved position
+ translate(fpi.mRect.mLeft - getRect().mLeft, fpi.mRect.mTop - getRect().mTop);
+ }
+ }
+ else
+ {
+ dockToChiclet(true);
+ }
+}
+
void LLScriptFloater::onFocusLost()
{
if(getNotificationId().notNull())
@@ -225,6 +259,33 @@ void LLScriptFloater::onFocusReceived()
}
}
+void LLScriptFloater::dockToChiclet(bool dock)
+{
+ if (getDockControl() == NULL)
+ {
+ LLChiclet* chiclet = LLBottomTray::getInstance()->getChicletPanel()->findChiclet<LLChiclet>(getNotificationId());
+ if (chiclet == NULL)
+ {
+ llwarns << "Dock chiclet for LLScriptFloater doesn't exist" << llendl;
+ return;
+ }
+ else
+ {
+ LLBottomTray::getInstance()->getChicletPanel()->scrollToChiclet(chiclet);
+ }
+
+ // Stop saving position while we dock floater
+ bool save = getSavePosition();
+ setSavePosition(false);
+
+ setDockControl(new LLDockControl(chiclet, this, getDockTongue(),
+ LLDockControl::TOP, boost::bind(&LLScriptFloater::getAllowedRect, this, _1)), dock);
+
+ // Restore saving
+ setSavePosition(save);
+ }
+}
+
void LLScriptFloater::hideToastsIfNeeded()
{
using namespace LLNotificationsUI;
@@ -326,6 +387,7 @@ void LLScriptFloaterManager::onRemoveNotification(const LLUUID& notification_id)
LLScriptFloater* floater = LLFloaterReg::findTypedInstance<LLScriptFloater>("script_floater", notification_id);
if(floater)
{
+ floater->savePosition();
floater->setNotificationId(LLUUID::null);
floater->closeFloater();
}
@@ -445,4 +507,27 @@ LLScriptFloaterManager::script_notification_map_t::const_iterator LLScriptFloate
return mNotifications.end();
}
+void LLScriptFloaterManager::saveFloaterPosition(const LLUUID& object_id, const FloaterPositionInfo& fpi)
+{
+ if(object_id.notNull())
+ {
+ LLScriptFloaterManager::getInstance()->mFloaterPositions[object_id] = fpi;
+ }
+ else
+ {
+ llwarns << "Invalid object id" << llendl;
+ }
+}
+
+bool LLScriptFloaterManager::getFloaterPosition(const LLUUID& object_id, FloaterPositionInfo& fpi)
+{
+ floater_position_map_t::const_iterator it = mFloaterPositions.find(object_id);
+ if(LLScriptFloaterManager::getInstance()->mFloaterPositions.end() != it)
+ {
+ fpi = it->second;
+ return true;
+ }
+ return false;
+}
+
// EOF
diff --git a/indra/newview/llscriptfloater.h b/indra/newview/llscriptfloater.h
index f7efff83f9..f0d489dcf6 100644
--- a/indra/newview/llscriptfloater.h
+++ b/indra/newview/llscriptfloater.h
@@ -84,9 +84,9 @@ public:
static std::string getObjectName(const LLUUID& notification_id);
- /**
- * Callback for notification toast buttons.
- */
+ /**
+ * Callback for notification toast buttons.
+ */
static void onToastButtonClick(const LLSD&notification, const LLSD&response);
typedef boost::signals2::signal<void(const LLSD&)> object_signal_t;
@@ -94,6 +94,16 @@ public:
boost::signals2::connection addNewObjectCallback(const object_signal_t::slot_type& cb) { return mNewObjectSignal.connect(cb); }
boost::signals2::connection addToggleObjectFloaterCallback(const object_signal_t::slot_type& cb) { return mToggleFloaterSignal.connect(cb); }
+ struct FloaterPositionInfo
+ {
+ LLRect mRect;
+ bool mDockState;
+ };
+
+ void saveFloaterPosition(const LLUUID& object_id, const FloaterPositionInfo& fpi);
+
+ bool getFloaterPosition(const LLUUID& object_id, FloaterPositionInfo& fpi);
+
protected:
typedef std::map<std::string, EObjectType> object_type_map;
@@ -111,6 +121,11 @@ private:
object_signal_t mNewObjectSignal;
object_signal_t mToggleFloaterSignal;
+
+ // <object_id, floater position>
+ typedef std::map<LLUUID, FloaterPositionInfo> floater_position_map_t;
+
+ floater_position_map_t mFloaterPositions;
};
/**
@@ -141,7 +156,7 @@ public:
const LLUUID& getNotificationId() { return mNotificationId; }
- void setNotificationId(const LLUUID& id) { mNotificationId = id; }
+ void setNotificationId(const LLUUID& id);
/**
* Close notification if script floater is closed.
@@ -158,6 +173,14 @@ public:
*/
/*virtual*/ void setVisible(BOOL visible);
+ bool getSavePosition() { return mSaveFloaterPosition; }
+
+ void setSavePosition(bool save) { mSaveFloaterPosition = save; }
+
+ void savePosition();
+
+ void restorePosition();
+
protected:
/**
@@ -181,9 +204,13 @@ protected:
/*virtual*/ void onFocusReceived();
+ void dockToChiclet(bool dock);
+
private:
LLToastNotifyPanel* mScriptForm;
LLUUID mNotificationId;
+ LLUUID mObjectId;
+ bool mSaveFloaterPosition;
};
#endif //LL_SCRIPTFLOATER_H