forked from qt-creator/qt-creator
ScreenRecorder: Turn lambda into member function
m_rect has otherwise invalid data at some point. Change-Id: I325522123ca4b0240235cf95cd6fb026f4ab9c98 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -59,15 +59,6 @@ void CropScene::initMouseInteraction(const QPoint &imagePos)
|
||||
return inRange;
|
||||
};
|
||||
|
||||
static const auto inMoveArea = [this, &imagePos] {
|
||||
const qreal minRatio = 0.25; // 25% width / height of selection
|
||||
const int minAbsoluteSize = 40;
|
||||
QRect result(0, 0, qMax(int(m_cropRect.width() * minRatio), minAbsoluteSize),
|
||||
qMax(int(m_cropRect.height() * minRatio), minAbsoluteSize));
|
||||
result.moveCenter(m_cropRect.center());
|
||||
return result.contains(imagePos);
|
||||
};
|
||||
|
||||
m_mouse.clickOffset = {};
|
||||
if (inGripRange(imagePos.x(), m_cropRect.left(), m_mouse.clickOffset.rx())) {
|
||||
m_mouse.margin = EdgeLeft;
|
||||
@@ -81,7 +72,7 @@ void CropScene::initMouseInteraction(const QPoint &imagePos)
|
||||
} else if (inGripRange(imagePos.y(), m_cropRect.bottom(), m_mouse.clickOffset.ry())) {
|
||||
m_mouse.margin = EdgeBottom;
|
||||
m_mouse.cursorShape = Qt::SizeVerCursor;
|
||||
} else if (!fullySelected() && inMoveArea()) {
|
||||
} else if (!fullySelected() && activeMoveArea().contains(imagePos)) {
|
||||
m_mouse.margin = Move;
|
||||
m_mouse.cursorShape = Qt::SizeAllCursor;
|
||||
m_mouse.clickOffset = imagePos - m_cropRect.topLeft();
|
||||
@@ -138,6 +129,16 @@ QPoint CropScene::toImagePos(const QPoint &widgetPos) const
|
||||
return {(widgetPos.x() - lineWidth) * dpr, (widgetPos.y() - lineWidth) * dpr};
|
||||
}
|
||||
|
||||
QRect CropScene::activeMoveArea() const
|
||||
{
|
||||
const qreal minRatio = 0.22; // At least 22% width and height of current selection
|
||||
const int minAbsoluteSize = 40;
|
||||
QRect result(0, 0, qMax(int(m_cropRect.width() * minRatio), minAbsoluteSize),
|
||||
qMax(int(m_cropRect.height() * minRatio), minAbsoluteSize));
|
||||
result.moveCenter(m_cropRect.center());
|
||||
return result;
|
||||
}
|
||||
|
||||
QRect CropScene::cropRect() const
|
||||
{
|
||||
return m_cropRect;
|
||||
|
||||
@@ -52,6 +52,7 @@ private:
|
||||
void initMouseInteraction(const QPoint &pos);
|
||||
void updateBuffer();
|
||||
QPoint toImagePos(const QPoint &widgetCoordinate) const;
|
||||
QRect activeMoveArea() const;
|
||||
|
||||
const static int m_gripWidth = 8;
|
||||
QRect m_cropRect;
|
||||
|
||||
Reference in New Issue
Block a user