Signed-off-by: falkTX <falktx@falktx.com>pull/344/head
@@ -35,8 +35,8 @@ template<typename T> | |||||
bool SubWidget::contains(const T x, const T y) const noexcept | bool SubWidget::contains(const T x, const T y) const noexcept | ||||
{ | { | ||||
return Rectangle<double>(0, 0, | return Rectangle<double>(0, 0, | ||||
static_cast<double>(getWidth()) - pData->margin.getX(), | |||||
static_cast<double>(getHeight()) - pData->margin.getY()).contains(x, y); | |||||
static_cast<double>(getWidth()), | |||||
static_cast<double>(getHeight())).contains(x, y); | |||||
} | } | ||||
template<typename T> | template<typename T> | ||||
@@ -67,9 +67,18 @@ Rectangle<int> SubWidget::getAbsoluteArea() const noexcept | |||||
Rectangle<uint> SubWidget::getConstrainedAbsoluteArea() const noexcept | Rectangle<uint> SubWidget::getConstrainedAbsoluteArea() const noexcept | ||||
{ | { | ||||
return Rectangle<uint>(static_cast<uint>(std::max(0, getAbsoluteX())), | |||||
static_cast<uint>(std::max(0, getAbsoluteY())), | |||||
getSize()); | |||||
const int x = getAbsoluteX(); | |||||
const int y = getAbsoluteY(); | |||||
if (x >= 0 && y >= 0) | |||||
return Rectangle<uint>(x, y, getSize()); | |||||
const int xOffset = std::min(0, x); | |||||
const int yOffset = std::min(0, y); | |||||
const int width = std::max(0, static_cast<int>(getWidth()) + xOffset); | |||||
const int height = std::max(0, static_cast<int>(getHeight()) + yOffset); | |||||
return Rectangle<uint>(0, 0, static_cast<uint>(width), static_cast<uint>(height)); | |||||
} | } | ||||
void SubWidget::setAbsoluteX(const int x) noexcept | void SubWidget::setAbsoluteX(const int x) noexcept | ||||
@@ -119,8 +119,8 @@ bool Widget::PrivateData::giveMouseEventForSubWidgets(MouseEvent& ev) | |||||
{ | { | ||||
if (selfw->pData->needsViewportScaling) | if (selfw->pData->needsViewportScaling) | ||||
{ | { | ||||
ev.absolutePos.setX(x - selfw->getAbsoluteX()); | |||||
ev.absolutePos.setY(y - selfw->getAbsoluteY()); | |||||
ev.absolutePos.setX(x - selfw->getAbsoluteX() + selfw->getMargin().getX()); | |||||
ev.absolutePos.setY(y - selfw->getAbsoluteY() + selfw->getMargin().getY()); | |||||
} | } | ||||
} | } | ||||
@@ -155,8 +155,8 @@ bool Widget::PrivateData::giveMotionEventForSubWidgets(MotionEvent& ev) | |||||
{ | { | ||||
if (selfw->pData->needsViewportScaling) | if (selfw->pData->needsViewportScaling) | ||||
{ | { | ||||
ev.absolutePos.setX(x - selfw->getAbsoluteX()); | |||||
ev.absolutePos.setY(y - selfw->getAbsoluteY()); | |||||
ev.absolutePos.setX(x - selfw->getAbsoluteX() + selfw->getMargin().getX()); | |||||
ev.absolutePos.setY(y - selfw->getAbsoluteY() + selfw->getMargin().getY()); | |||||
} | } | ||||
} | } | ||||
@@ -191,8 +191,8 @@ bool Widget::PrivateData::giveScrollEventForSubWidgets(ScrollEvent& ev) | |||||
{ | { | ||||
if (selfw->pData->needsViewportScaling) | if (selfw->pData->needsViewportScaling) | ||||
{ | { | ||||
ev.absolutePos.setX(x - selfw->getAbsoluteX()); | |||||
ev.absolutePos.setY(y - selfw->getAbsoluteY()); | |||||
ev.absolutePos.setX(x - selfw->getAbsoluteX() + selfw->getMargin().getX()); | |||||
ev.absolutePos.setY(y - selfw->getAbsoluteY() + selfw->getMargin().getY()); | |||||
} | } | ||||
} | } | ||||