IntCoord ComboBox::calculateListPosition() { int length = 0; if (mFlowDirection.isVertical()) length = mList->getOptimalHeight(); else length = mMaxListLength; if (mMaxListLength > 0 && length > mMaxListLength) length = mMaxListLength; // берем глобальные координаты выджета IntCoord coord = getAbsoluteCoord(); // размер леера IntSize sizeView = mList->getParentSize(); if (mFlowDirection == FlowDirection::TopToBottom) { if ((coord.bottom() + length) <= sizeView.height) coord.top += coord.height; else coord.top -= length; coord.height = length; } else if (mFlowDirection == FlowDirection::BottomToTop) { if ((coord.top - length) >= 0) coord.top -= length; else coord.top += coord.height; coord.height = length; } else if (mFlowDirection == FlowDirection::LeftToRight) { if ((coord.right() + length) <= sizeView.width) coord.left += coord.width; else coord.left -= length; coord.width = length; } else if (mFlowDirection == FlowDirection::RightToLeft) { if ((coord.left - length) >= 0) coord.left -= length; else coord.left += coord.width; coord.width = length; } return coord; }
VectorFloatPoint cropPolygon(FloatPoint* _baseVerticiesPos, size_t _size, const IntCoord& _cropRectangle) { VectorFloatPoint resultVerticiesPos; resultVerticiesPos.resize(_size); for (size_t i = 0; i < _size; ++i) { resultVerticiesPos[i] = _baseVerticiesPos[i]; } cropPolygonSide(resultVerticiesPos, _cropRectangle.left, Left); cropPolygonSide(resultVerticiesPos, _cropRectangle.right(), Right); cropPolygonSide(resultVerticiesPos, _cropRectangle.top, Top); cropPolygonSide(resultVerticiesPos, _cropRectangle.bottom(), Bottom); return resultVerticiesPos; }