Skip to content
Snippets Groups Projects
Commit a024493c authored by Richard Linden's avatar Richard Linden
Browse files

eol fixes

parent 3f64343b
No related branches found
No related tags found
No related merge requests found
/** /**
* @file lldockcontrol.cpp * @file lldockcontrol.cpp
* @brief Creates a panel of a specific kind for a toast * @brief Creates a panel of a specific kind for a toast
* *
* $LicenseInfo:firstyear=2000&license=viewerlgpl$ * $LicenseInfo:firstyear=2000&license=viewerlgpl$
* Second Life Viewer Source Code * Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc. * Copyright (C) 2010, Linden Research, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; * License as published by the Free Software Foundation;
* version 2.1 of the License only. * version 2.1 of the License only.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
#include "linden_common.h" #include "linden_common.h"
#include "lldockcontrol.h" #include "lldockcontrol.h"
#include "lldockablefloater.h" #include "lldockablefloater.h"
LLDockControl::LLDockControl(LLView* dockWidget, LLFloater* dockableFloater, LLDockControl::LLDockControl(LLView* dockWidget, LLFloater* dockableFloater,
const LLUIImagePtr& dockTongue, DocAt dockAt, get_allowed_rect_callback_t get_allowed_rect_callback) : const LLUIImagePtr& dockTongue, DocAt dockAt, get_allowed_rect_callback_t get_allowed_rect_callback) :
mDockWidget(dockWidget), mDockWidget(dockWidget),
mDockableFloater(dockableFloater), mDockableFloater(dockableFloater),
mDockTongue(dockTongue), mDockTongue(dockTongue),
mDockTongueX(0), mDockTongueX(0),
mDockTongueY(0) mDockTongueY(0)
{ {
mDockAt = dockAt; mDockAt = dockAt;
if (dockableFloater->isDocked()) if (dockableFloater->isDocked())
{ {
on(); on();
} }
else else
{ {
off(); off();
} }
if (!(get_allowed_rect_callback)) if (!(get_allowed_rect_callback))
{ {
mGetAllowedRectCallback = boost::bind(&LLDockControl::getAllowedRect, this, _1); mGetAllowedRectCallback = boost::bind(&LLDockControl::getAllowedRect, this, _1);
} }
else else
{ {
mGetAllowedRectCallback = get_allowed_rect_callback; mGetAllowedRectCallback = get_allowed_rect_callback;
} }
if (dockWidget != NULL) if (dockWidget != NULL)
{ {
repositionDockable(); repositionDockable();
} }
if (mDockWidget != NULL) if (mDockWidget != NULL)
{ {
mDockWidgetVisible = isDockVisible(); mDockWidgetVisible = isDockVisible();
} }
else else
{ {
mDockWidgetVisible = false; mDockWidgetVisible = false;
} }
} }
LLDockControl::~LLDockControl() LLDockControl::~LLDockControl()
{ {
} }
void LLDockControl::setDock(LLView* dockWidget) void LLDockControl::setDock(LLView* dockWidget)
{ {
mDockWidget = dockWidget; mDockWidget = dockWidget;
if (mDockWidget != NULL) if (mDockWidget != NULL)
{ {
repositionDockable(); repositionDockable();
mDockWidgetVisible = isDockVisible(); mDockWidgetVisible = isDockVisible();
} }
else else
{ {
mDockWidgetVisible = false; mDockWidgetVisible = false;
} }
} }
void LLDockControl::getAllowedRect(LLRect& rect) void LLDockControl::getAllowedRect(LLRect& rect)
{ {
rect = mDockableFloater->getRootView()->getRect(); rect = mDockableFloater->getRootView()->getRect();
} }
void LLDockControl::repositionDockable() void LLDockControl::repositionDockable()
{ {
LLRect dockRect = mDockWidget->calcScreenRect(); LLRect dockRect = mDockWidget->calcScreenRect();
LLRect rootRect; LLRect rootRect;
mGetAllowedRectCallback(rootRect); mGetAllowedRectCallback(rootRect);
// recalculate dockable position if dock position changed, dock visibility changed, // recalculate dockable position if dock position changed, dock visibility changed,
// root view rect changed or recalculation is forced // root view rect changed or recalculation is forced
if (mPrevDockRect != dockRect || mDockWidgetVisible != isDockVisible() if (mPrevDockRect != dockRect || mDockWidgetVisible != isDockVisible()
|| mRootRect != rootRect || mRecalculateDocablePosition) || mRootRect != rootRect || mRecalculateDocablePosition)
{ {
// undock dockable and off() if dock not visible // undock dockable and off() if dock not visible
if (!isDockVisible()) if (!isDockVisible())
{ {
mDockableFloater->setDocked(false); mDockableFloater->setDocked(false);
// force off() since dockable may not have dockControll at this time // force off() since dockable may not have dockControll at this time
off(); off();
LLDockableFloater* dockable_floater = LLDockableFloater* dockable_floater =
dynamic_cast<LLDockableFloater*> (mDockableFloater); dynamic_cast<LLDockableFloater*> (mDockableFloater);
if(dockable_floater != NULL) if(dockable_floater != NULL)
{ {
dockable_floater->onDockHidden(); dockable_floater->onDockHidden();
} }
} }
else else
{ {
if(mEnabled) if(mEnabled)
{ {
moveDockable(); moveDockable();
} }
LLDockableFloater* dockable_floater = LLDockableFloater* dockable_floater =
dynamic_cast<LLDockableFloater*> (mDockableFloater); dynamic_cast<LLDockableFloater*> (mDockableFloater);
if(dockable_floater != NULL) if(dockable_floater != NULL)
{ {
dockable_floater->onDockShown(); dockable_floater->onDockShown();
} }
} }
mPrevDockRect = dockRect; mPrevDockRect = dockRect;
mRootRect = rootRect; mRootRect = rootRect;
mRecalculateDocablePosition = false; mRecalculateDocablePosition = false;
mDockWidgetVisible = isDockVisible(); mDockWidgetVisible = isDockVisible();
} }
} }
bool LLDockControl::isDockVisible() bool LLDockControl::isDockVisible()
{ {
bool res = true; bool res = true;
if (mDockWidget != NULL) if (mDockWidget != NULL)
{ {
//we should check all hierarchy //we should check all hierarchy
res = mDockWidget->isInVisibleChain(); res = mDockWidget->isInVisibleChain();
if (res) if (res)
{ {
LLRect dockRect = mDockWidget->calcScreenRect(); LLRect dockRect = mDockWidget->calcScreenRect();
switch (mDockAt) switch (mDockAt)
{ {
case LEFT: // to keep compiler happy case LEFT: // to keep compiler happy
break; break;
case BOTTOM: case BOTTOM:
case TOP: case TOP:
{ {
// check is dock inside parent rect // check is dock inside parent rect
// assume that parent for all dockable flaoters // assume that parent for all dockable flaoters
// is the root view // is the root view
LLRect dockParentRect = LLRect dockParentRect =
mDockWidget->getRootView()->calcScreenRect(); mDockWidget->getRootView()->calcScreenRect();
if (dockRect.mRight <= dockParentRect.mLeft if (dockRect.mRight <= dockParentRect.mLeft
|| dockRect.mLeft >= dockParentRect.mRight) || dockRect.mLeft >= dockParentRect.mRight)
{ {
res = false; res = false;
} }
break; break;
} }
default: default:
break; break;
} }
} }
} }
return res; return res;
} }
void LLDockControl::moveDockable() void LLDockControl::moveDockable()
{ {
// calculate new dockable position // calculate new dockable position
LLRect dockRect = mDockWidget->calcScreenRect(); LLRect dockRect = mDockWidget->calcScreenRect();
LLRect rootRect; LLRect rootRect;
mGetAllowedRectCallback(rootRect); mGetAllowedRectCallback(rootRect);
bool use_tongue = false; bool use_tongue = false;
LLDockableFloater* dockable_floater = LLDockableFloater* dockable_floater =
dynamic_cast<LLDockableFloater*> (mDockableFloater); dynamic_cast<LLDockableFloater*> (mDockableFloater);
if (dockable_floater != NULL) if (dockable_floater != NULL)
{ {
use_tongue = dockable_floater->getUseTongue(); use_tongue = dockable_floater->getUseTongue();
} }
LLRect dockableRect = mDockableFloater->calcScreenRect(); LLRect dockableRect = mDockableFloater->calcScreenRect();
S32 x = 0; S32 x = 0;
S32 y = 0; S32 y = 0;
LLRect dockParentRect; LLRect dockParentRect;
switch (mDockAt) switch (mDockAt)
{ {
case LEFT: case LEFT:
x = dockRect.mLeft; x = dockRect.mLeft;
y = dockRect.mTop + mDockTongue->getHeight() + dockableRect.getHeight(); y = dockRect.mTop + mDockTongue->getHeight() + dockableRect.getHeight();
// check is dockable inside root view rect // check is dockable inside root view rect
if (x < rootRect.mLeft) if (x < rootRect.mLeft)
{ {
x = rootRect.mLeft; x = rootRect.mLeft;
} }
if (x + dockableRect.getWidth() > rootRect.mRight) if (x + dockableRect.getWidth() > rootRect.mRight)
{ {
x = rootRect.mRight - dockableRect.getWidth(); x = rootRect.mRight - dockableRect.getWidth();
} }
mDockTongueX = x + dockableRect.getWidth()/2 - mDockTongue->getWidth() / 2; mDockTongueX = x + dockableRect.getWidth()/2 - mDockTongue->getWidth() / 2;
mDockTongueY = dockRect.mTop; mDockTongueY = dockRect.mTop;
break; break;
case TOP: case TOP:
x = dockRect.getCenterX() - dockableRect.getWidth() / 2; x = dockRect.getCenterX() - dockableRect.getWidth() / 2;
y = dockRect.mTop + dockableRect.getHeight(); y = dockRect.mTop + dockableRect.getHeight();
// unique docking used with dock tongue, so add tongue height to the Y coordinate // unique docking used with dock tongue, so add tongue height to the Y coordinate
if (use_tongue) if (use_tongue)
{ {
y += mDockTongue->getHeight(); y += mDockTongue->getHeight();
if ( y > rootRect.mTop) if ( y > rootRect.mTop)
{ {
y = rootRect.mTop; y = rootRect.mTop;
} }
} }
// check is dockable inside root view rect // check is dockable inside root view rect
if (x < rootRect.mLeft) if (x < rootRect.mLeft)
{ {
x = rootRect.mLeft; x = rootRect.mLeft;
} }
if (x + dockableRect.getWidth() > rootRect.mRight) if (x + dockableRect.getWidth() > rootRect.mRight)
{ {
x = rootRect.mRight - dockableRect.getWidth(); x = rootRect.mRight - dockableRect.getWidth();
} }
// calculate dock tongue position // calculate dock tongue position
dockParentRect = mDockWidget->getParent()->calcScreenRect(); dockParentRect = mDockWidget->getParent()->calcScreenRect();
if (dockRect.getCenterX() < dockParentRect.mLeft) if (dockRect.getCenterX() < dockParentRect.mLeft)
{ {
mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2; mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2;
} }
else if (dockRect.getCenterX() > dockParentRect.mRight) else if (dockRect.getCenterX() > dockParentRect.mRight)
{ {
mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;; mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;;
} }
else else
{ {
mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2; mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2;
} }
mDockTongueY = dockRect.mTop; mDockTongueY = dockRect.mTop;
break; break;
case BOTTOM: case BOTTOM:
x = dockRect.getCenterX() - dockableRect.getWidth() / 2; x = dockRect.getCenterX() - dockableRect.getWidth() / 2;
y = dockRect.mBottom; y = dockRect.mBottom;
// unique docking used with dock tongue, so add tongue height to the Y coordinate // unique docking used with dock tongue, so add tongue height to the Y coordinate
if (use_tongue) if (use_tongue)
{ {
y -= mDockTongue->getHeight(); y -= mDockTongue->getHeight();
} }
// check is dockable inside root view rect // check is dockable inside root view rect
if (x < rootRect.mLeft) if (x < rootRect.mLeft)
{ {
x = rootRect.mLeft; x = rootRect.mLeft;
} }
if (x + dockableRect.getWidth() > rootRect.mRight) if (x + dockableRect.getWidth() > rootRect.mRight)
{ {
x = rootRect.mRight - dockableRect.getWidth(); x = rootRect.mRight - dockableRect.getWidth();
} }
// calculate dock tongue position // calculate dock tongue position
dockParentRect = mDockWidget->getParent()->calcScreenRect(); dockParentRect = mDockWidget->getParent()->calcScreenRect();
if (dockRect.getCenterX() < dockParentRect.mLeft) if (dockRect.getCenterX() < dockParentRect.mLeft)
{ {
mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2; mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2;
} }
else if (dockRect.getCenterX() > dockParentRect.mRight) else if (dockRect.getCenterX() > dockParentRect.mRight)
{ {
mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;; mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;;
} }
else else
{ {
mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2; mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2;
} }
mDockTongueY = dockRect.mBottom - mDockTongue->getHeight(); mDockTongueY = dockRect.mBottom - mDockTongue->getHeight();
break; break;
} }
S32 max_available_height = rootRect.getHeight() - (rootRect.mBottom - mDockTongueY) - mDockTongue->getHeight(); 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 // 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. // there is a space between a dockable floater and a control to which it is docked.
if (use_tongue && dockableRect.getHeight() >= max_available_height) if (use_tongue && dockableRect.getHeight() >= max_available_height)
{ {
dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), max_available_height); dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), max_available_height);
mDockableFloater->reshape(dockableRect.getWidth(), dockableRect.getHeight()); mDockableFloater->reshape(dockableRect.getWidth(), dockableRect.getHeight());
} }
else else
{ {
// move dockable // move dockable
dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(),
dockableRect.getHeight()); dockableRect.getHeight());
} }
LLRect localDocableParentRect; LLRect localDocableParentRect;
mDockableFloater->getParent()->screenRectToLocal(dockableRect, mDockableFloater->getParent()->screenRectToLocal(dockableRect,
&localDocableParentRect); &localDocableParentRect);
mDockableFloater->setRect(localDocableParentRect); mDockableFloater->setRect(localDocableParentRect);
mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY, mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY,
&mDockTongueX, &mDockTongueY); &mDockTongueX, &mDockTongueY);
} }
void LLDockControl::on() void LLDockControl::on()
{ {
if (isDockVisible()) if (isDockVisible())
{ {
mEnabled = true; mEnabled = true;
mRecalculateDocablePosition = true; mRecalculateDocablePosition = true;
} }
} }
void LLDockControl::off() void LLDockControl::off()
{ {
mEnabled = false; mEnabled = false;
} }
void LLDockControl::forceRecalculatePosition() void LLDockControl::forceRecalculatePosition()
{ {
mRecalculateDocablePosition = true; mRecalculateDocablePosition = true;
} }
void LLDockControl::drawToungue() void LLDockControl::drawToungue()
{ {
bool use_tongue = false; bool use_tongue = false;
LLDockableFloater* dockable_floater = LLDockableFloater* dockable_floater =
dynamic_cast<LLDockableFloater*> (mDockableFloater); dynamic_cast<LLDockableFloater*> (mDockableFloater);
if (dockable_floater != NULL) if (dockable_floater != NULL)
{ {
use_tongue = dockable_floater->getUseTongue(); use_tongue = dockable_floater->getUseTongue();
} }
if (mEnabled && use_tongue) if (mEnabled && use_tongue)
{ {
mDockTongue->draw(mDockTongueX, mDockTongueY); mDockTongue->draw(mDockTongueX, mDockTongueY);
} }
} }
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
project(winmm_shim) project(winmm_shim)
### winmm_shim ### winmm_shim
# *HACK - override msvcrt implementation (intialized on 00-Common) to be # *HACK - override msvcrt implementation (intialized on 00-Common) to be
# statically linked for winmm.dll this relies on vc taking the last flag on # statically linked for winmm.dll this relies on vc taking the last flag on
# the command line # the command line
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(winmm_shim_SOURCE_FILES set(winmm_shim_SOURCE_FILES
forwarding_api.cpp forwarding_api.cpp
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment