7#ifndef MYGUI_I_CROPPED_RECTANGLE_H_
8#define MYGUI_I_CROPPED_RECTANGLE_H_
19 virtual ~ICroppedRectangle() =
default;
22 ICroppedRectangle* getCroppedParent()
24 return mCroppedParent;
26 const ICroppedRectangle* getCroppedParent()
const
28 return mCroppedParent;
32 virtual void setPosition(
const IntPoint& _value)
34 mCoord.left = _value.left;
35 mCoord.top = _value.top;
38 virtual void setSize(
const IntSize& _value)
40 mCoord.width = _value.width;
41 mCoord.height = _value.height;
44 virtual void setCoord(
const IntCoord& _value)
52 return mCoord.point();
66 const IntPoint& getAbsolutePosition()
const
68 return mAbsolutePosition;
74 mAbsolutePosition.left,
75 mAbsolutePosition.top,
76 mAbsolutePosition.left + mCoord.width,
77 mAbsolutePosition.top + mCoord.height};
82 return {mAbsolutePosition.left, mAbsolutePosition.top, mCoord.width, mCoord.height};
86 int getAbsoluteLeft()
const
88 return mAbsolutePosition.
left;
91 int getAbsoluteTop()
const
93 return mAbsolutePosition.top;
104 return mCoord.right();
112 int getBottom()
const
114 return mCoord.bottom();
122 int getHeight()
const
124 return mCoord.height;
130 bool _isMargin()
const
134 virtual bool _hasRotation()
const
140 int _getViewLeft()
const
142 return mCoord.left + mMargin.left;
144 int _getViewRight()
const
146 return mCoord.right() - mMargin.right;
148 int _getViewTop()
const
150 return mCoord.top + mMargin.top;
152 int _getViewBottom()
const
154 return mCoord.bottom() - mMargin.bottom;
156 int _getViewWidth()
const
158 return mCoord.width - mMargin.left - mMargin.right;
160 int _getViewHeight()
const
162 return mCoord.height - mMargin.top - mMargin.bottom;
165 void _setCroppedParent(ICroppedRectangle* _parent)
167 mCroppedParent = _parent;
170 const IntRect& _getMargin()
const
174 int _getMarginLeft()
const
178 int _getMarginRight()
const
180 return mMargin.right;
182 int _getMarginTop()
const
186 int _getMarginBottom()
const
188 return mMargin.bottom;
195 if (_hasRotation() || mCroppedParent->_hasRotation())
202 if (getLeft() < mCroppedParent->mMargin.left)
204 mMargin.left = mCroppedParent->mMargin.left - getLeft();
213 if (getRight() > mCroppedParent->getWidth() - mCroppedParent->mMargin.right)
215 mMargin.right = getRight() - (mCroppedParent->getWidth() - mCroppedParent->mMargin.right);
224 if (getTop() < mCroppedParent->mMargin.top)
226 mMargin.top = mCroppedParent->mMargin.top - getTop();
235 if (getBottom() > mCroppedParent->getHeight() - mCroppedParent->mMargin.bottom)
237 mMargin.bottom = getBottom() - (mCroppedParent->getHeight() - mCroppedParent->mMargin.bottom);
249 bool _checkOutside()
const
251 if (_hasRotation() || mCroppedParent->_hasRotation())
253 return _checkOutsideUnrotated();
257 bool _checkOutsideUnrotated()
const
260 (getRight() < mCroppedParent->mMargin.left) ||
261 (getLeft() > mCroppedParent->getWidth() - mCroppedParent->mMargin.right) ||
262 (getBottom() < mCroppedParent->mMargin.top) ||
263 (getTop() > mCroppedParent->getHeight() - mCroppedParent->mMargin.bottom));
271 bool mIsMargin{
false};
272 ICroppedRectangle* mCroppedParent{
nullptr};
types::TRect< int > IntRect
types::TPoint< int > IntPoint
types::TCoord< int > IntCoord
types::TSize< int > IntSize