2011-06-24 10:41:16 -07:00
|
|
|
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-05-26 12:41:33 -07:00
|
|
|
|
2011-06-24 10:41:16 -07:00
|
|
|
#ifndef MOZILLA_GFX_RECT_H_
|
|
|
|
#define MOZILLA_GFX_RECT_H_
|
|
|
|
|
|
|
|
#include "BaseRect.h"
|
|
|
|
#include "BaseMargin.h"
|
|
|
|
#include "Point.h"
|
2011-05-26 12:41:33 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
2011-06-24 10:41:16 -07:00
|
|
|
namespace gfx {
|
2011-05-26 12:41:33 -07:00
|
|
|
|
2011-06-24 10:41:16 -07:00
|
|
|
struct Margin :
|
|
|
|
public BaseMargin<Float, Margin> {
|
|
|
|
typedef BaseMargin<Float, Margin> Super;
|
2011-05-26 12:41:33 -07:00
|
|
|
|
|
|
|
// Constructors
|
2011-06-24 10:41:16 -07:00
|
|
|
Margin(const Margin& aMargin) : Super(aMargin) {}
|
|
|
|
Margin(Float aLeft, Float aTop, Float aRight, Float aBottom)
|
|
|
|
: Super(aLeft, aTop, aRight, aBottom) {}
|
|
|
|
};
|
2011-05-26 12:41:33 -07:00
|
|
|
|
2011-06-24 10:41:16 -07:00
|
|
|
struct IntRect :
|
|
|
|
public BaseRect<int32_t, IntRect, IntPoint, IntSize, Margin> {
|
|
|
|
typedef BaseRect<int32_t, IntRect, IntPoint, mozilla::gfx::IntSize, Margin> Super;
|
2011-05-26 12:41:33 -07:00
|
|
|
|
2011-06-24 10:41:16 -07:00
|
|
|
IntRect() : Super() {}
|
|
|
|
IntRect(IntPoint aPos, mozilla::gfx::IntSize aSize) :
|
|
|
|
Super(aPos, aSize) {}
|
|
|
|
IntRect(int32_t _x, int32_t _y, int32_t _width, int32_t _height) :
|
|
|
|
Super(_x, _y, _width, _height) {}
|
2011-11-13 20:29:14 -08:00
|
|
|
|
|
|
|
// Rounding isn't meaningful on an integer rectangle.
|
|
|
|
void Round() {}
|
|
|
|
void RoundIn() {}
|
|
|
|
void RoundOut() {}
|
2011-05-26 12:41:33 -07:00
|
|
|
};
|
|
|
|
|
2011-11-13 20:29:01 -08:00
|
|
|
struct Rect :
|
|
|
|
public BaseRect<Float, Rect, Point, Size, Margin> {
|
|
|
|
typedef BaseRect<Float, Rect, Point, mozilla::gfx::Size, Margin> Super;
|
|
|
|
|
|
|
|
Rect() : Super() {}
|
|
|
|
Rect(Point aPos, mozilla::gfx::Size aSize) :
|
|
|
|
Super(aPos, aSize) {}
|
|
|
|
Rect(Float _x, Float _y, Float _width, Float _height) :
|
|
|
|
Super(_x, _y, _width, _height) {}
|
|
|
|
explicit Rect(const IntRect& rect) :
|
2011-11-21 06:56:24 -08:00
|
|
|
Super(float(rect.x), float(rect.y),
|
|
|
|
float(rect.width), float(rect.height)) {}
|
2012-05-03 14:41:37 -07:00
|
|
|
|
|
|
|
bool ToIntRect(IntRect *aOut)
|
|
|
|
{
|
|
|
|
*aOut = IntRect(int32_t(X()), int32_t(Y()),
|
|
|
|
int32_t(Width()), int32_t(Height()));
|
2012-05-14 16:01:05 -07:00
|
|
|
return Rect(Float(aOut->x), Float(aOut->y),
|
|
|
|
Float(aOut->width), Float(aOut->height)).IsEqualEdges(*this);
|
2012-05-03 14:41:37 -07:00
|
|
|
}
|
2011-11-13 20:29:01 -08:00
|
|
|
};
|
|
|
|
|
2011-06-24 10:41:16 -07:00
|
|
|
}
|
2011-05-26 12:41:33 -07:00
|
|
|
}
|
|
|
|
|
2011-06-24 10:41:16 -07:00
|
|
|
#endif /* MOZILLA_GFX_RECT_H_ */
|