diff options
author | Oz Linden <oz@lindenlab.com> | 2011-04-10 22:19:11 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-04-10 22:19:11 -0400 |
commit | c77fcfb7a8aeb2f271b050171bf0d6a9bd4c955b (patch) | |
tree | d30164242aa4af36f721033eb7a93fb2f2198de4 /indra/llui | |
parent | f1b1dbaba54ce678e6ec5311d4b50ded3f91d58c (diff) | |
parent | e0adaa188ba06b6d3f3282121d149193de87c6e6 (diff) |
merge changes for storm-250
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lldockcontrol.cpp | 722 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 7 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 1 | ||||
-rw-r--r-- | indra/llui/llfloaterreglistener.cpp | 17 | ||||
-rw-r--r-- | indra/llui/llfloaterreglistener.h | 1 | ||||
-rw-r--r-- | indra/llui/lliconctrl.h | 1 | ||||
-rw-r--r-- | indra/llui/lllineeditor.cpp | 5 | ||||
-rw-r--r-- | indra/llui/lllineeditor.h | 1 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 11 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 49 | ||||
-rw-r--r-- | indra/llui/llui.h | 27 | ||||
-rw-r--r-- | indra/llui/tests/llurlentry_stub.cpp | 4 |
12 files changed, 474 insertions, 372 deletions
diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp index 3f81c2b28f..b1c27126d9 100644 --- a/indra/llui/lldockcontrol.cpp +++ b/indra/llui/lldockcontrol.cpp @@ -1,361 +1,361 @@ -/**
- * @file lldockcontrol.cpp
- * @brief Creates a panel of a specific kind for a toast
- *
- * $LicenseInfo:firstyear=2000&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, 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 "linden_common.h"
-
-#include "lldockcontrol.h"
-#include "lldockablefloater.h"
-
-LLDockControl::LLDockControl(LLView* dockWidget, LLFloater* dockableFloater,
- const LLUIImagePtr& dockTongue, DocAt dockAt, get_allowed_rect_callback_t get_allowed_rect_callback) :
- mDockWidget(dockWidget),
- mDockableFloater(dockableFloater),
- mDockTongue(dockTongue),
- mDockTongueX(0),
- mDockTongueY(0)
-{
- mDockAt = dockAt;
-
- if (dockableFloater->isDocked())
- {
- on();
- }
- else
- {
- off();
- }
-
- if (!(get_allowed_rect_callback))
- {
- mGetAllowedRectCallback = boost::bind(&LLDockControl::getAllowedRect, this, _1);
- }
- else
- {
- mGetAllowedRectCallback = get_allowed_rect_callback;
- }
-
- if (dockWidget != NULL)
- {
- repositionDockable();
- }
-
- if (mDockWidget != NULL)
- {
- mDockWidgetVisible = isDockVisible();
- }
- else
- {
- mDockWidgetVisible = false;
- }
-}
-
-LLDockControl::~LLDockControl()
-{
-}
-
-void LLDockControl::setDock(LLView* dockWidget)
-{
- mDockWidget = dockWidget;
- if (mDockWidget != NULL)
- {
- repositionDockable();
- mDockWidgetVisible = isDockVisible();
- }
- else
- {
- mDockWidgetVisible = false;
- }
-}
-
-void LLDockControl::getAllowedRect(LLRect& rect)
-{
- rect = mDockableFloater->getRootView()->getRect();
-}
-
-void LLDockControl::repositionDockable()
-{
- LLRect dockRect = mDockWidget->calcScreenRect();
- LLRect rootRect;
- mGetAllowedRectCallback(rootRect);
-
- // recalculate dockable position if dock position changed, dock visibility changed,
- // root view rect changed or recalculation is forced
- if (mPrevDockRect != dockRect || mDockWidgetVisible != isDockVisible()
- || mRootRect != rootRect || mRecalculateDocablePosition)
- {
- // undock dockable and off() if dock not visible
- if (!isDockVisible())
- {
- mDockableFloater->setDocked(false);
- // force off() since dockable may not have dockControll at this time
- off();
- LLDockableFloater* dockable_floater =
- dynamic_cast<LLDockableFloater*> (mDockableFloater);
- if(dockable_floater != NULL)
- {
- dockable_floater->onDockHidden();
- }
- }
- else
- {
- if(mEnabled)
- {
- moveDockable();
- }
- LLDockableFloater* dockable_floater =
- dynamic_cast<LLDockableFloater*> (mDockableFloater);
- if(dockable_floater != NULL)
- {
- dockable_floater->onDockShown();
- }
- }
-
- mPrevDockRect = dockRect;
- mRootRect = rootRect;
- mRecalculateDocablePosition = false;
- mDockWidgetVisible = isDockVisible();
- }
-}
-
-bool LLDockControl::isDockVisible()
-{
- bool res = true;
-
- if (mDockWidget != NULL)
- {
- //we should check all hierarchy
- res = mDockWidget->isInVisibleChain();
- if (res)
- {
- LLRect dockRect = mDockWidget->calcScreenRect();
-
- switch (mDockAt)
- {
- case LEFT: // to keep compiler happy
- break;
- case BOTTOM:
- case TOP:
- {
- // check is dock inside parent rect
- // assume that parent for all dockable flaoters
- // is the root view
- LLRect dockParentRect =
- mDockWidget->getRootView()->calcScreenRect();
- if (dockRect.mRight <= dockParentRect.mLeft
- || dockRect.mLeft >= dockParentRect.mRight)
- {
- res = false;
- }
- break;
- }
- default:
- break;
- }
- }
- }
-
- return res;
-}
-
-void LLDockControl::moveDockable()
-{
- // calculate new dockable position
- LLRect dockRect = mDockWidget->calcScreenRect();
- LLRect rootRect;
- mGetAllowedRectCallback(rootRect);
-
- bool use_tongue = false;
- LLDockableFloater* dockable_floater =
- dynamic_cast<LLDockableFloater*> (mDockableFloater);
- if (dockable_floater != NULL)
- {
- use_tongue = dockable_floater->getUseTongue();
- }
-
- LLRect dockableRect = mDockableFloater->calcScreenRect();
- S32 x = 0;
- S32 y = 0;
- LLRect dockParentRect;
- switch (mDockAt)
- {
- case LEFT:
- x = dockRect.mLeft;
- y = dockRect.mTop + mDockTongue->getHeight() + dockableRect.getHeight();
- // check is dockable inside root view rect
- if (x < rootRect.mLeft)
- {
- x = rootRect.mLeft;
- }
- if (x + dockableRect.getWidth() > rootRect.mRight)
- {
- x = rootRect.mRight - dockableRect.getWidth();
- }
-
- mDockTongueX = x + dockableRect.getWidth()/2 - mDockTongue->getWidth() / 2;
-
- mDockTongueY = dockRect.mTop;
- break;
-
- case TOP:
- x = dockRect.getCenterX() - dockableRect.getWidth() / 2;
- y = dockRect.mTop + dockableRect.getHeight();
- // unique docking used with dock tongue, so add tongue height to the Y coordinate
- if (use_tongue)
- {
- y += mDockTongue->getHeight();
-
- if ( y > rootRect.mTop)
- {
- y = rootRect.mTop;
- }
- }
-
- // check is dockable inside root view rect
- if (x < rootRect.mLeft)
- {
- x = rootRect.mLeft;
- }
- if (x + dockableRect.getWidth() > rootRect.mRight)
- {
- x = rootRect.mRight - dockableRect.getWidth();
- }
-
-
- // calculate dock tongue position
- dockParentRect = mDockWidget->getParent()->calcScreenRect();
- if (dockRect.getCenterX() < dockParentRect.mLeft)
- {
- mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2;
- }
- else if (dockRect.getCenterX() > dockParentRect.mRight)
- {
- mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;;
- }
- else
- {
- mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2;
- }
- mDockTongueY = dockRect.mTop;
-
- break;
- case BOTTOM:
- x = dockRect.getCenterX() - dockableRect.getWidth() / 2;
- y = dockRect.mBottom;
- // unique docking used with dock tongue, so add tongue height to the Y coordinate
- if (use_tongue)
- {
- y -= mDockTongue->getHeight();
- }
-
- // check is dockable inside root view rect
- if (x < rootRect.mLeft)
- {
- x = rootRect.mLeft;
- }
- if (x + dockableRect.getWidth() > rootRect.mRight)
- {
- x = rootRect.mRight - dockableRect.getWidth();
- }
-
- // calculate dock tongue position
- dockParentRect = mDockWidget->getParent()->calcScreenRect();
- if (dockRect.getCenterX() < dockParentRect.mLeft)
- {
- mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2;
- }
- else if (dockRect.getCenterX() > dockParentRect.mRight)
- {
- mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;;
- }
- else
- {
- mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2;
- }
- mDockTongueY = dockRect.mBottom - mDockTongue->getHeight();
-
- break;
- }
-
- S32 max_available_height = rootRect.getHeight() - (rootRect.mBottom - mDockTongueY) - mDockTongue->getHeight();
-
- // A floater should be shrunk so it doesn't cover a part of its docking tongue and
- // there is a space between a dockable floater and a control to which it is docked.
- if (use_tongue && dockableRect.getHeight() >= max_available_height)
- {
- dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), max_available_height);
- mDockableFloater->reshape(dockableRect.getWidth(), dockableRect.getHeight());
- }
- else
- {
- // move dockable
- dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(),
- dockableRect.getHeight());
- }
- LLRect localDocableParentRect;
- mDockableFloater->getParent()->screenRectToLocal(dockableRect,
- &localDocableParentRect);
- mDockableFloater->setRect(localDocableParentRect);
-
- mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY,
- &mDockTongueX, &mDockTongueY);
-
-}
-
-void LLDockControl::on()
-{
- if (isDockVisible())
- {
- mEnabled = true;
- mRecalculateDocablePosition = true;
- }
-}
-
-void LLDockControl::off()
-{
- mEnabled = false;
-}
-
-void LLDockControl::forceRecalculatePosition()
-{
- mRecalculateDocablePosition = true;
-}
-
-void LLDockControl::drawToungue()
-{
- bool use_tongue = false;
- LLDockableFloater* dockable_floater =
- dynamic_cast<LLDockableFloater*> (mDockableFloater);
- if (dockable_floater != NULL)
- {
- use_tongue = dockable_floater->getUseTongue();
- }
-
- if (mEnabled && use_tongue)
- {
- mDockTongue->draw(mDockTongueX, mDockTongueY);
- }
-}
-
+/** + * @file lldockcontrol.cpp + * @brief Creates a panel of a specific kind for a toast + * + * $LicenseInfo:firstyear=2000&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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 "linden_common.h" + +#include "lldockcontrol.h" +#include "lldockablefloater.h" + +LLDockControl::LLDockControl(LLView* dockWidget, LLFloater* dockableFloater, + const LLUIImagePtr& dockTongue, DocAt dockAt, get_allowed_rect_callback_t get_allowed_rect_callback) : + mDockWidget(dockWidget), + mDockableFloater(dockableFloater), + mDockTongue(dockTongue), + mDockTongueX(0), + mDockTongueY(0) +{ + mDockAt = dockAt; + + if (dockableFloater->isDocked()) + { + on(); + } + else + { + off(); + } + + if (!(get_allowed_rect_callback)) + { + mGetAllowedRectCallback = boost::bind(&LLDockControl::getAllowedRect, this, _1); + } + else + { + mGetAllowedRectCallback = get_allowed_rect_callback; + } + + if (dockWidget != NULL) + { + repositionDockable(); + } + + if (mDockWidget != NULL) + { + mDockWidgetVisible = isDockVisible(); + } + else + { + mDockWidgetVisible = false; + } +} + +LLDockControl::~LLDockControl() +{ +} + +void LLDockControl::setDock(LLView* dockWidget) +{ + mDockWidget = dockWidget; + if (mDockWidget != NULL) + { + repositionDockable(); + mDockWidgetVisible = isDockVisible(); + } + else + { + mDockWidgetVisible = false; + } +} + +void LLDockControl::getAllowedRect(LLRect& rect) +{ + rect = mDockableFloater->getRootView()->getRect(); +} + +void LLDockControl::repositionDockable() +{ + LLRect dockRect = mDockWidget->calcScreenRect(); + LLRect rootRect; + mGetAllowedRectCallback(rootRect); + + // recalculate dockable position if dock position changed, dock visibility changed, + // root view rect changed or recalculation is forced + if (mPrevDockRect != dockRect || mDockWidgetVisible != isDockVisible() + || mRootRect != rootRect || mRecalculateDocablePosition) + { + // undock dockable and off() if dock not visible + if (!isDockVisible()) + { + mDockableFloater->setDocked(false); + // force off() since dockable may not have dockControll at this time + off(); + LLDockableFloater* dockable_floater = + dynamic_cast<LLDockableFloater*> (mDockableFloater); + if(dockable_floater != NULL) + { + dockable_floater->onDockHidden(); + } + } + else + { + if(mEnabled) + { + moveDockable(); + } + LLDockableFloater* dockable_floater = + dynamic_cast<LLDockableFloater*> (mDockableFloater); + if(dockable_floater != NULL) + { + dockable_floater->onDockShown(); + } + } + + mPrevDockRect = dockRect; + mRootRect = rootRect; + mRecalculateDocablePosition = false; + mDockWidgetVisible = isDockVisible(); + } +} + +bool LLDockControl::isDockVisible() +{ + bool res = true; + + if (mDockWidget != NULL) + { + //we should check all hierarchy + res = mDockWidget->isInVisibleChain(); + if (res) + { + LLRect dockRect = mDockWidget->calcScreenRect(); + + switch (mDockAt) + { + case LEFT: // to keep compiler happy + break; + case BOTTOM: + case TOP: + { + // check is dock inside parent rect + // assume that parent for all dockable flaoters + // is the root view + LLRect dockParentRect = + mDockWidget->getRootView()->calcScreenRect(); + if (dockRect.mRight <= dockParentRect.mLeft + || dockRect.mLeft >= dockParentRect.mRight) + { + res = false; + } + break; + } + default: + break; + } + } + } + + return res; +} + +void LLDockControl::moveDockable() +{ + // calculate new dockable position + LLRect dockRect = mDockWidget->calcScreenRect(); + LLRect rootRect; + mGetAllowedRectCallback(rootRect); + + bool use_tongue = false; + LLDockableFloater* dockable_floater = + dynamic_cast<LLDockableFloater*> (mDockableFloater); + if (dockable_floater != NULL) + { + use_tongue = dockable_floater->getUseTongue(); + } + + LLRect dockableRect = mDockableFloater->calcScreenRect(); + S32 x = 0; + S32 y = 0; + LLRect dockParentRect; + switch (mDockAt) + { + case LEFT: + x = dockRect.mLeft; + y = dockRect.mTop + mDockTongue->getHeight() + dockableRect.getHeight(); + // check is dockable inside root view rect + if (x < rootRect.mLeft) + { + x = rootRect.mLeft; + } + if (x + dockableRect.getWidth() > rootRect.mRight) + { + x = rootRect.mRight - dockableRect.getWidth(); + } + + mDockTongueX = x + dockableRect.getWidth()/2 - mDockTongue->getWidth() / 2; + + mDockTongueY = dockRect.mTop; + break; + + case TOP: + x = dockRect.getCenterX() - dockableRect.getWidth() / 2; + y = dockRect.mTop + dockableRect.getHeight(); + // unique docking used with dock tongue, so add tongue height to the Y coordinate + if (use_tongue) + { + y += mDockTongue->getHeight(); + + if ( y > rootRect.mTop) + { + y = rootRect.mTop; + } + } + + // check is dockable inside root view rect + if (x < rootRect.mLeft) + { + x = rootRect.mLeft; + } + if (x + dockableRect.getWidth() > rootRect.mRight) + { + x = rootRect.mRight - dockableRect.getWidth(); + } + + + // calculate dock tongue position + dockParentRect = mDockWidget->getParent()->calcScreenRect(); + if (dockRect.getCenterX() < dockParentRect.mLeft) + { + mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2; + } + else if (dockRect.getCenterX() > dockParentRect.mRight) + { + mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;; + } + else + { + mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2; + } + mDockTongueY = dockRect.mTop; + + break; + case BOTTOM: + x = dockRect.getCenterX() - dockableRect.getWidth() / 2; + y = dockRect.mBottom; + // unique docking used with dock tongue, so add tongue height to the Y coordinate + if (use_tongue) + { + y -= mDockTongue->getHeight(); + } + + // check is dockable inside root view rect + if (x < rootRect.mLeft) + { + x = rootRect.mLeft; + } + if (x + dockableRect.getWidth() > rootRect.mRight) + { + x = rootRect.mRight - dockableRect.getWidth(); + } + + // calculate dock tongue position + dockParentRect = mDockWidget->getParent()->calcScreenRect(); + if (dockRect.getCenterX() < dockParentRect.mLeft) + { + mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2; + } + else if (dockRect.getCenterX() > dockParentRect.mRight) + { + mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;; + } + else + { + mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2; + } + mDockTongueY = dockRect.mBottom - mDockTongue->getHeight(); + + break; + } + + S32 max_available_height = rootRect.getHeight() - (rootRect.mBottom - mDockTongueY) - mDockTongue->getHeight(); + + // A floater should be shrunk so it doesn't cover a part of its docking tongue and + // there is a space between a dockable floater and a control to which it is docked. + if (use_tongue && dockableRect.getHeight() >= max_available_height) + { + dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), max_available_height); + mDockableFloater->reshape(dockableRect.getWidth(), dockableRect.getHeight()); + } + else + { + // move dockable + dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), + dockableRect.getHeight()); + } + LLRect localDocableParentRect; + mDockableFloater->getParent()->screenRectToLocal(dockableRect, + &localDocableParentRect); + mDockableFloater->setRect(localDocableParentRect); + + mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY, + &mDockTongueX, &mDockTongueY); + +} + +void LLDockControl::on() +{ + if (isDockVisible()) + { + mEnabled = true; + mRecalculateDocablePosition = true; + } +} + +void LLDockControl::off() +{ + mEnabled = false; +} + +void LLDockControl::forceRecalculatePosition() +{ + mRecalculateDocablePosition = true; +} + +void LLDockControl::drawToungue() +{ + bool use_tongue = false; + LLDockableFloater* dockable_floater = + dynamic_cast<LLDockableFloater*> (mDockableFloater); + if (dockable_floater != NULL) + { + use_tongue = dockable_floater->getUseTongue(); + } + + if (mEnabled && use_tongue) + { + mDockTongue->draw(mDockTongueX, mDockTongueY); + } +} + diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 35e0d9d890..d19e33ea55 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2869,7 +2869,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p) // close callback if (p.close_callback.isProvided()) { - mCloseSignal.connect(initCommitCallback(p.close_callback)); + setCloseCallback(initCommitCallback(p.close_callback)); } } @@ -2879,6 +2879,11 @@ boost::signals2::connection LLFloater::setMinimizeCallback( const commit_signal_ return mMinimizeSignal->connect(cb); } +boost::signals2::connection LLFloater::setCloseCallback( const commit_signal_t::slot_type& cb ) +{ + return mCloseSignal.connect(cb); +} + LLFastTimer::DeclareTimer POST_BUILD("Floater Post Build"); bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 0e83b80c89..5b7b020881 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -144,6 +144,7 @@ public: bool buildFromFile(const std::string &filename, LLXMLNodePtr output_node = NULL); boost::signals2::connection setMinimizeCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setCloseCallback( const commit_signal_t::slot_type& cb ); void initFromParams(const LLFloater::Params& p); bool initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node = NULL); diff --git a/indra/llui/llfloaterreglistener.cpp b/indra/llui/llfloaterreglistener.cpp index 821d4543ae..7525b8cab3 100644 --- a/indra/llui/llfloaterreglistener.cpp +++ b/indra/llui/llfloaterreglistener.cpp @@ -60,6 +60,11 @@ LLFloaterRegListener::LLFloaterRegListener(): "Ask to toggle the state of the floater specified in [\"name\"]", &LLFloaterRegListener::toggleInstance, requiredName); + add("instanceVisible", + "Return on [\"reply\"] an event whose [\"visible\"] indicates the visibility " + "of the floater specified in [\"name\"]", + &LLFloaterRegListener::instanceVisible, + requiredName); LLSD requiredNameButton; requiredNameButton["name"] = LLSD(); requiredNameButton["button"] = LLSD(); @@ -71,9 +76,7 @@ LLFloaterRegListener::LLFloaterRegListener(): void LLFloaterRegListener::getBuildMap(const LLSD& event) const { - // Honor the "reqid" convention by echoing event["reqid"] in our reply packet. - LLReqID reqID(event); - LLSD reply(reqID.makeResponse()); + LLSD reply; // Build an LLSD map that mirrors sBuildMap. Since we have no good way to // represent a C++ callable in LLSD, the only part of BuildData we can // store is the filename. For each LLSD map entry, it would be more @@ -86,7 +89,7 @@ void LLFloaterRegListener::getBuildMap(const LLSD& event) const reply[mi->first] = mi->second.mFile; } // Send the reply to the LLEventPump named in event["reply"]. - LLEventPumps::instance().obtain(event["reply"]).post(reply); + sendReply(reply, event); } void LLFloaterRegListener::showInstance(const LLSD& event) const @@ -104,6 +107,12 @@ void LLFloaterRegListener::toggleInstance(const LLSD& event) const LLFloaterReg::toggleInstance(event["name"], event["key"]); } +void LLFloaterRegListener::instanceVisible(const LLSD& event) const +{ + sendReply(LLSDMap("visible", LLFloaterReg::instanceVisible(event["name"], event["key"])), + event); +} + void LLFloaterRegListener::clickButton(const LLSD& event) const { // If the caller requests a reply, build the reply. diff --git a/indra/llui/llfloaterreglistener.h b/indra/llui/llfloaterreglistener.h index 586656667c..24311a2dfa 100644 --- a/indra/llui/llfloaterreglistener.h +++ b/indra/llui/llfloaterreglistener.h @@ -47,6 +47,7 @@ private: void showInstance(const LLSD& event) const; void hideInstance(const LLSD& event) const; void toggleInstance(const LLSD& event) const; + void instanceVisible(const LLSD& event) const; void clickButton(const LLSD& event) const; }; diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index e9bdab2d47..669e126266 100644 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -69,6 +69,7 @@ public: void setColor(const LLColor4& color) { mColor = color; } void setImage(LLPointer<LLUIImage> image) { mImagep = image; } + const LLPointer<LLUIImage> getImage() { return mImagep; } private: void setIconImageDrawSize() ; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 7e348656a9..d99ee5a545 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -2290,3 +2290,8 @@ void LLLineEditor::setContextMenu(LLContextMenu* new_context_menu) else mContextMenuHandle.markDead(); } + +void LLLineEditor::setFont(const LLFontGL* font) +{ + mGLFont = font; +} diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 723423a5b9..7b5fa218f2 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -201,6 +201,7 @@ public: const LLColor4& getTentativeFgColor() const { return mTentativeFgColor.get(); } const LLFontGL* getFont() const { return mGLFont; } + void setFont(const LLFontGL* font); void setIgnoreArrowKeys(BOOL b) { mIgnoreArrowKeys = b; } void setIgnoreTab(BOOL b) { mIgnoreTab = b; } diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 32d7be377a..8de9c769e2 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1936,9 +1936,15 @@ bool LLMenuGL::scrollItems(EScrollingDirection direction) { item_list_t::reverse_iterator first_visible_item_iter = mItems.rend(); + // Need to scroll through number of actual existing items in menu. + // Otherwise viewer will hang for a time needed to scroll U32_MAX + // times in std::advance(). STORM-659. + size_t nitems = mItems.size(); + U32 scrollable_items = nitems < mMaxScrollableItems ? nitems : mMaxScrollableItems; + // Advance by mMaxScrollableItems back from the end of the list // to make the last item visible. - std::advance(first_visible_item_iter, mMaxScrollableItems); + std::advance(first_visible_item_iter, scrollable_items); mFirstVisibleItem = *first_visible_item_iter; break; } @@ -3099,9 +3105,6 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) CURSOR_HEIGHT + MOUSE_CURSOR_PADDING * 2); menu->translateIntoRectWithExclusion( menu_region_rect, mouse_rect, FALSE ); menu->getParent()->sendChildToFront(menu); - - - } ///============================================================================ diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index c300fe55d9..87669574c2 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -61,6 +61,8 @@ // for XUIParse #include "llquaternion.h" #include <boost/tokenizer.hpp> +#include <boost/algorithm/string/find_iterator.hpp> +#include <boost/algorithm/string/finder.hpp> // // Globals @@ -2020,6 +2022,53 @@ void LLUI::positionViewNearMouse(LLView* view, S32 spawn_x, S32 spawn_y) view->translateIntoRectWithExclusion( virtual_window_rect, mouse_rect, FALSE ); } +LLView* LLUI::resolvePath(LLView* context, const std::string& path) +{ + // Nothing about resolvePath() should require non-const LLView*. If caller + // wants non-const, call the const flavor and then cast away const-ness. + return const_cast<LLView*>(resolvePath(const_cast<const LLView*>(context), path)); +} + +const LLView* LLUI::resolvePath(const LLView* context, const std::string& path) +{ + // Create an iterator over slash-separated parts of 'path'. Dereferencing + // this iterator returns an iterator_range over the substring. Unlike + // LLStringUtil::getTokens(), this split_iterator doesn't combine adjacent + // delimiters: leading/trailing slash produces an empty substring, double + // slash produces an empty substring. That's what we need. + boost::split_iterator<std::string::const_iterator> ti(path, boost::first_finder("/")), tend; + + if (ti == tend) + { + // 'path' is completely empty, no navigation + return context; + } + + // leading / means "start at root" + if (ti->empty()) + { + context = getRootView(); + ++ti; + } + + bool recurse = false; + for (; ti != tend && context; ++ti) + { + if (ti->empty()) + { + recurse = true; + } + else + { + std::string part(ti->begin(), ti->end()); + context = context->findChildView(part, recurse); + recurse = false; + } + } + + return context; +} + // LLLocalClipRect and LLScreenClipRect moved to lllocalcliprect.h/cpp diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 62d10df8b2..50cb9e6632 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -185,6 +185,33 @@ public: //helper functions (should probably move free standing rendering helper functions here) static LLView* getRootView() { return sRootView; } static void setRootView(LLView* view) { sRootView = view; } + /** + * Walk the LLView tree to resolve a path + * Paths can be discovered using Develop > XUI > Show XUI Paths + * + * A leading "/" indicates the root of the tree is the starting + * position of the search, (otherwise the context node is used) + * + * Adjacent "//" mean that the next level of the search is done + * recursively ("descendant" rather than "child"). + * + * Return values: If no match is found, NULL is returned, + * otherwise the matching LLView* is returned. + * + * Examples: + * + * "/" -> return the root view + * "/foo" -> find "foo" as a direct child of the root + * "foo" -> find "foo" as a direct child of the context node + * "//foo" -> find the first "foo" child anywhere in the tree + * "/foo/bar" -> find "foo" as direct child of the root, and + * "bar" as a direct child of "foo" + * "//foo//bar/baz" -> find the first "foo" anywhere in the + * tree, the first "bar" anywhere under it, and "baz" + * as a direct child of that + */ + static const LLView* resolvePath(const LLView* context, const std::string& path); + static LLView* resolvePath(LLView* context, const std::string& path); static std::string locateSkin(const std::string& filename); static void setMousePositionScreen(S32 x, S32 y); static void getMousePositionScreen(S32 *x, S32 *y); diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index 96ebe83826..ac2412c928 100644 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -193,8 +193,8 @@ LLFontGL* LLFontGL::getFontDefault() return NULL; } -char* _PREHASH_AgentData = "AgentData"; -char* _PREHASH_AgentID = "AgentID"; +char const* const _PREHASH_AgentData = (char *)"AgentData"; +char const* const _PREHASH_AgentID = (char *)"AgentID"; LLHost LLHost::invalid(INVALID_PORT,INVALID_HOST_IP_ADDRESS); |