1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-14 00:14:18 +00:00

Tidied up a few rectangle methods.

This commit is contained in:
jules 2012-03-18 17:22:05 +00:00
parent 49870de020
commit e87f833183
4 changed files with 17 additions and 19 deletions

View file

@ -411,7 +411,7 @@ public:
const int bottom = env->GetIntField (rect, RectClass.bottom);
env->DeleteLocalRef (rect);
return Rectangle<int> (left, top, right - left, bottom - top);
return Rectangle<int>::leftTopRightBottom (left, top, right, bottom);
}
bool isClipEmpty() const

View file

@ -31,19 +31,19 @@
namespace
{
template <class RectType>
Rectangle<int> convertToRectInt (const RectType& r)
Rectangle<int> convertToRectInt (const RectType& r) noexcept
{
return Rectangle<int> ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height);
}
template <class RectType>
Rectangle<float> convertToRectFloat (const RectType& r)
Rectangle<float> convertToRectFloat (const RectType& r) noexcept
{
return Rectangle<float> (r.origin.x, r.origin.y, r.size.width, r.size.height);
}
template <class RectType>
CGRect convertToCGRect (const RectType& r)
CGRect convertToCGRect (const RectType& r) noexcept
{
return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight());
}

View file

@ -2124,7 +2124,7 @@ void Component::setPositioner (Positioner* newPositioner)
//==============================================================================
Rectangle<int> Component::getLocalBounds() const noexcept
{
return Rectangle<int> (getWidth(), getHeight());
return bounds.withZeroOrigin();
}
Rectangle<int> Component::getBoundsInParent() const noexcept

View file

@ -117,6 +117,11 @@ static bool canUseMultiTouch()
return registerTouchWindow != nullptr;
}
static inline Rectangle<int> rectangleFromRECT (const RECT& r) noexcept
{
return Rectangle<int>::leftTopRightBottom ((int) r.left, (int) r.top, (int) r.right, (int) r.bottom);
}
//==============================================================================
Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
{
@ -602,8 +607,7 @@ public:
{
RECT r;
GetWindowRect (hwnd, &r);
Rectangle<int> bounds (r.left, r.top, r.right - r.left, r.bottom - r.top);
Rectangle<int> bounds (rectangleFromRECT (r));
HWND parentH = GetParent (hwnd);
if (parentH != 0)
@ -1357,7 +1361,7 @@ private:
if (GetUpdateRect (hwnd, &r, false))
{
direct2DContext->start();
direct2DContext->clipToRectangle (Rectangle<int> (r.left, r.top, r.right - r.left, r.bottom - r.top));
direct2DContext->clipToRectangle (rectangleFromRECT (r));
handlePaint (*direct2DContext);
direct2DContext->end();
}
@ -1412,7 +1416,7 @@ private:
Image& offscreenImage = offscreenImageGenerator.getImage (transparent, w, h);
RectangleList contextClip;
const Rectangle<int> clipBounds (0, 0, w, h);
const Rectangle<int> clipBounds (w, h);
bool needToPaintAll = true;
@ -1954,7 +1958,7 @@ private:
{
if (isConstrainedNativeWindow())
{
Rectangle<int> pos (r->left, r->top, r->right - r->left, r->bottom - r->top);
Rectangle<int> pos (rectangleFromRECT (*r));
constrainer->checkBounds (pos, windowBorder.addedTo (component->getBounds()),
Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(),
@ -3027,7 +3031,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis
static BOOL CALLBACK enumMonitorsProc (HMONITOR, HDC, LPRECT r, LPARAM userInfo)
{
Array <Rectangle<int> >* const monitorCoords = (Array <Rectangle<int> >*) userInfo;
monitorCoords->add (Rectangle<int> (r->left, r->top, r->right - r->left, r->bottom - r->top));
monitorCoords->add (rectangleFromRECT (*r));
return TRUE;
}
@ -3044,8 +3048,7 @@ void Desktop::getCurrentMonitorPositions (Array <Rectangle<int> >& monitorCoords
{
RECT r;
GetWindowRect (GetDesktopWindow(), &r);
monitorCoords.add (Rectangle<int> (r.left, r.top, r.right - r.left, r.bottom - r.top));
monitorCoords.add (rectangleFromRECT (r));
}
if (clipToWorkArea)
@ -3055,12 +3058,7 @@ void Desktop::getCurrentMonitorPositions (Array <Rectangle<int> >& monitorCoords
SystemParametersInfo (SPI_GETWORKAREA, 0, &r, 0);
Rectangle<int>& screen = monitorCoords.getReference (0);
screen.setPosition (jmax (screen.getX(), (int) r.left),
jmax (screen.getY(), (int) r.top));
screen.setSize (jmin (screen.getRight(), (int) r.right) - screen.getX(),
jmin (screen.getBottom(), (int) r.bottom) - screen.getY());
screen = screen.getIntersection (rectangleFromRECT (r));
}
}