Magic_Game/core/Shape/Rect.cpp

62 lines
1.0 KiB
C++
Raw Normal View History

2018-02-03 22:04:43 +08:00
#include "..\eshape.h"
#include "..\enodes.h"
e2d::Rect::Rect()
2017-10-28 18:48:21 +08:00
: m_pD2dRectangle(nullptr)
{
}
2018-02-27 21:07:43 +08:00
e2d::Rect::Rect(double x, double y, double width, double height)
2017-12-15 21:51:07 +08:00
: m_pD2dRectangle(nullptr)
{
this->_setRect(x, y, x + width, y + height);
}
e2d::Rect::Rect(Node * node)
2017-12-15 21:51:07 +08:00
: m_pD2dRectangle(nullptr)
{
this->_setRect(
2017-10-29 23:48:32 +08:00
0,
0,
node->getRealWidth(),
node->getRealHeight()
);
}
e2d::Rect::~Rect()
2017-10-29 23:48:32 +08:00
{
SafeReleaseInterface(&m_pD2dRectangle);
}
2018-02-27 21:07:43 +08:00
void e2d::Rect::_setRect(double left, double top, double right, double bottom)
{
SafeReleaseInterface(&m_pD2dRectangle);
Renderer::getID2D1Factory()->CreateRectangleGeometry(
2018-02-27 21:07:43 +08:00
D2D1::RectF(
static_cast<float>(left),
static_cast<float>(top),
static_cast<float>(right),
static_cast<float>(bottom)),
&m_pD2dRectangle
);
}
2018-03-07 20:14:58 +08:00
void e2d::Rect::_resize()
{
if (m_pParentNode && m_bEnable)
{
this->_setRect(
0,
0,
m_pParentNode->getRealWidth(),
m_pParentNode->getRealHeight()
);
}
}
ID2D1RectangleGeometry * e2d::Rect::_getD2dGeometry() const
{
return m_pD2dRectangle;
}