Browse Source

Tidied up a few rectangle methods.

tags/2021-05-28
jules 13 years ago
parent
commit
e87f833183
4 changed files with 17 additions and 19 deletions
  1. +1
    -1
      modules/juce_graphics/native/juce_android_GraphicsContext.cpp
  2. +3
    -3
      modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h
  3. +1
    -1
      modules/juce_gui_basics/components/juce_Component.cpp
  4. +12
    -14
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp

+ 1
- 1
modules/juce_graphics/native/juce_android_GraphicsContext.cpp 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


+ 3
- 3
modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h 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());
}


+ 1
- 1
modules/juce_gui_basics/components/juce_Component.cpp 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


+ 12
- 14
modules/juce_gui_basics/native/juce_win32_Windowing.cpp 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));
}
}


Loading…
Cancel
Save