Changeset View
Changeset View
Standalone View
Standalone View
src/QuickEditor/QuickEditor.cpp
Show All 14 Lines | |||||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "QuickEditor.h" | 20 | #include "QuickEditor.h" | ||
21 | 21 | | |||
22 | #include "SpectacleConfig.h" | 22 | #include "SpectacleConfig.h" | ||
23 | #include <QDebug> | ||||
23 | 24 | | |||
24 | const qreal QuickEditor::mouseAreaSize = 20.0; | 25 | const qreal QuickEditor::mouseAreaSize = 20.0; | ||
25 | const qreal QuickEditor::cornerHandleRadius = 8.0; | 26 | const qreal QuickEditor::cornerHandleRadius = 8.0; | ||
26 | const qreal QuickEditor::midHandleRadius = 5.0; | 27 | const qreal QuickEditor::midHandleRadius = 5.0; | ||
27 | const int QuickEditor::selectionSizeThreshold = 100; | 28 | const int QuickEditor::selectionSizeThreshold = 100; | ||
28 | 29 | | |||
29 | const int QuickEditor::selectionBoxPaddingX = 5; | 30 | const int QuickEditor::selectionBoxPaddingX = 5; | ||
30 | const int QuickEditor::selectionBoxPaddingY = 4; | 31 | const int QuickEditor::selectionBoxPaddingY = 4; | ||
31 | const int QuickEditor::selectionBoxMarginY = 2; | 32 | const int QuickEditor::selectionBoxMarginY = 2; | ||
32 | 33 | | |||
33 | const int QuickEditor::bottomHelpBoxPaddingX = 12; | 34 | const int QuickEditor::bottomHelpBoxPaddingX = 12; | ||
34 | const int QuickEditor::bottomHelpBoxPaddingY = 8; | 35 | const int QuickEditor::bottomHelpBoxPaddingY = 8; | ||
35 | const int QuickEditor::bottomHelpBoxPairSpacing = 6; | 36 | const int QuickEditor::bottomHelpBoxPairSpacing = 6; | ||
36 | const int QuickEditor::bottomHelpBoxLineHeight = 24; | 37 | const int QuickEditor::bottomHelpBoxLineHeight = 24; | ||
37 | 38 | | |||
39 | const int QuickEditor::magZoom = 5; | ||||
40 | const int QuickEditor::magPixels = 16; | ||||
41 | | ||||
38 | QuickEditor::QuickEditor(const QPixmap& pixmap, QObject* parent) : | 42 | QuickEditor::QuickEditor(const QPixmap& pixmap, QObject* parent) : | ||
39 | mMaskColour(QColor::fromRgbF(0, 0, 0, 0.15)), | 43 | mMaskColour(QColor::fromRgbF(0, 0, 0, 0.15)), | ||
40 | mStrokeColor(palette().highlight().color()), | 44 | mStrokeColour(palette().highlight().color()), | ||
45 | mCrossColour(QColor::fromRgbF(mStrokeColour.redF(), mStrokeColour.greenF(), mStrokeColour.blueF(), 0.7)), | ||||
41 | mLabelBackgroundColour(QColor::fromRgbF( | 46 | mLabelBackgroundColour(QColor::fromRgbF( | ||
42 | palette().light().color().redF(), | 47 | palette().light().color().redF(), | ||
43 | palette().light().color().greenF(), | 48 | palette().light().color().greenF(), | ||
44 | palette().light().color().blueF(), | 49 | palette().light().color().blueF(), | ||
45 | 0.85 | 50 | 0.85 | ||
46 | )), | 51 | )), | ||
47 | mLabelForegroundColour(palette().windowText().color()), | 52 | mLabelForegroundColour(palette().windowText().color()), | ||
48 | mMidHelpText(tr("Click and drag to draw a selection rectangle,\nor press Esc to quit")), | 53 | mMidHelpText(tr("Click and drag to draw a selection rectangle,\nor press Esc to quit")), | ||
49 | mMidHelpTextFont(font()), | 54 | mMidHelpTextFont(font()), | ||
50 | mBottomHelpText({ | 55 | mBottomHelpText({ | ||
51 | {QStaticText(tr("Enter, double-click:")), QStaticText(tr("Take screenshot"))}, | 56 | {QStaticText(tr("Enter, double-click:")), QStaticText(tr("Take screenshot"))}, | ||
52 | {QStaticText(tr("Shift:")), QStaticText(tr("Hold to toggle magnifier"))}, | 57 | {QStaticText(tr("Shift:")), QStaticText(tr("Hold to toggle magnifier"))}, | ||
53 | {QStaticText(tr("Right-click:")), QStaticText(tr("Reset selection"))}, | 58 | {QStaticText(tr("Right-click:")), QStaticText(tr("Reset selection"))}, | ||
54 | {QStaticText(tr("Esc:")), QStaticText(tr("Cancel"))}, | 59 | {QStaticText(tr("Esc:")), QStaticText(tr("Cancel"))}, | ||
55 | }), | 60 | }), | ||
56 | mBottomHelpTextFont(font()), | 61 | mBottomHelpTextFont(font()), | ||
57 | mBottomHelpGridLeftWidth(0), | 62 | mBottomHelpGridLeftWidth(0), | ||
58 | mMouseDragState(MouseState::None), | 63 | mMouseDragState(MouseState::None), | ||
59 | mPixmap(pixmap) | 64 | mPixmap(pixmap), | ||
65 | mMagnifierAllowed(false), | ||||
66 | mShowMagnifier(SpectacleConfig::instance()->showMagnifierChecked()), | ||||
67 | mToggleMagnifier(false) | ||||
60 | { | 68 | { | ||
61 | Q_UNUSED(parent); | 69 | Q_UNUSED(parent); | ||
62 | 70 | | |||
63 | SpectacleConfig *config = SpectacleConfig::instance(); | 71 | SpectacleConfig *config = SpectacleConfig::instance(); | ||
64 | if (config->useLightRegionMaskColour()) { | 72 | if (config->useLightRegionMaskColour()) { | ||
65 | mMaskColour = QColor(255, 255, 255, 100); | 73 | mMaskColour = QColor(255, 255, 255, 100); | ||
66 | } | 74 | } | ||
67 | 75 | | |||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 132 | case Qt::Key_Escape: | |||
126 | delete this; | 134 | delete this; | ||
127 | break; | 135 | break; | ||
128 | case Qt::Key_Return: | 136 | case Qt::Key_Return: | ||
129 | case Qt::Key_Enter: | 137 | case Qt::Key_Enter: | ||
130 | acceptSelection(); | 138 | acceptSelection(); | ||
131 | default: | 139 | default: | ||
132 | break; | 140 | break; | ||
133 | } | 141 | } | ||
142 | if (event->modifiers() & Qt::ShiftModifier) { | ||||
143 | mToggleMagnifier = true; | ||||
144 | update(); | ||||
145 | } | ||||
146 | event->accept(); | ||||
147 | } | ||||
148 | | ||||
149 | void QuickEditor::keyReleaseEvent(QKeyEvent* event) | ||||
150 | { | ||||
151 | if (mToggleMagnifier && !(event->modifiers() & Qt::ShiftModifier)) { | ||||
152 | mToggleMagnifier = false; | ||||
153 | update(); | ||||
154 | } | ||||
155 | event->accept(); | ||||
134 | } | 156 | } | ||
135 | 157 | | |||
136 | void QuickEditor::mousePressEvent(QMouseEvent* event) | 158 | void QuickEditor::mousePressEvent(QMouseEvent* event) | ||
137 | { | 159 | { | ||
138 | if (event->button() & Qt::LeftButton) { | 160 | if (event->button() & Qt::LeftButton) { | ||
139 | const QPointF& pos = event->screenPos(); | 161 | const QPointF& pos = event->screenPos(); | ||
162 | mMousePos = pos; | ||||
163 | mMagnifierAllowed = true; | ||||
140 | mMouseDragState = whereIsTheMouse(pos); | 164 | mMouseDragState = whereIsTheMouse(pos); | ||
141 | switch(mMouseDragState) { | 165 | switch(mMouseDragState) { | ||
142 | case MouseState::Outside: | 166 | case MouseState::Outside: | ||
143 | mStartPos = pos; | 167 | mStartPos = pos; | ||
144 | break; | 168 | break; | ||
145 | case MouseState::Inside: | 169 | case MouseState::Inside: | ||
146 | mStartPos = pos; | 170 | mStartPos = pos; | ||
171 | mMagnifierAllowed = false; | ||||
147 | mInitialTopLeft = mSelection.topLeft(); | 172 | mInitialTopLeft = mSelection.topLeft(); | ||
148 | setCursor(Qt::ClosedHandCursor); | 173 | setCursor(Qt::ClosedHandCursor); | ||
149 | break; | 174 | break; | ||
150 | case MouseState::Top: | 175 | case MouseState::Top: | ||
151 | case MouseState::Left: | 176 | case MouseState::Left: | ||
152 | case MouseState::TopLeft: | 177 | case MouseState::TopLeft: | ||
153 | mStartPos = mSelection.bottomRight(); | 178 | mStartPos = mSelection.bottomRight(); | ||
154 | break; | 179 | break; | ||
155 | case MouseState::Bottom: | 180 | case MouseState::Bottom: | ||
156 | case MouseState::Right: | 181 | case MouseState::Right: | ||
157 | case MouseState::BottomRight: | 182 | case MouseState::BottomRight: | ||
158 | mStartPos = mSelection.topLeft(); | 183 | mStartPos = mSelection.topLeft(); | ||
159 | break; | 184 | break; | ||
160 | case MouseState::TopRight: | 185 | case MouseState::TopRight: | ||
161 | mStartPos = mSelection.bottomLeft(); | 186 | mStartPos = mSelection.bottomLeft(); | ||
162 | break; | 187 | break; | ||
163 | case MouseState::BottomLeft: | 188 | case MouseState::BottomLeft: | ||
164 | mStartPos = mSelection.topRight(); | 189 | mStartPos = mSelection.topRight(); | ||
165 | default: | 190 | default: | ||
166 | break; | 191 | break; | ||
167 | } | 192 | } | ||
168 | } | 193 | } | ||
194 | if (mMagnifierAllowed) { | ||||
195 | update(); | ||||
196 | } | ||||
169 | event->accept(); | 197 | event->accept(); | ||
170 | } | 198 | } | ||
171 | 199 | | |||
172 | void QuickEditor::mouseMoveEvent(QMouseEvent* event) | 200 | void QuickEditor::mouseMoveEvent(QMouseEvent* event) | ||
173 | { | 201 | { | ||
174 | const QPointF& pos = event->screenPos(); | 202 | const QPointF& pos = event->screenPos(); | ||
203 | mMousePos = pos; | ||||
204 | mMagnifierAllowed = true; | ||||
175 | switch (mMouseDragState) { | 205 | switch (mMouseDragState) { | ||
176 | case MouseState::None: { | 206 | case MouseState::None: { | ||
177 | setMouseCursor(pos); | 207 | setMouseCursor(pos); | ||
208 | mMagnifierAllowed = false; | ||||
178 | break; | 209 | break; | ||
179 | } | 210 | } | ||
180 | case MouseState::TopLeft: | 211 | case MouseState::TopLeft: | ||
181 | case MouseState::TopRight: | 212 | case MouseState::TopRight: | ||
182 | case MouseState::BottomRight: | 213 | case MouseState::BottomRight: | ||
183 | case MouseState::BottomLeft: | 214 | case MouseState::BottomLeft: | ||
184 | case MouseState::Outside: { | 215 | case MouseState::Outside: { | ||
185 | const qreal dprI = 1.0 / devicePixelRatioF(); | 216 | const qreal dprI = 1.0 / devicePixelRatioF(); | ||
Show All 26 Lines | 241 | mSelection.setRect( | |||
212 | mSelection.y(), | 243 | mSelection.y(), | ||
213 | qAbs(pos.x() - mStartPos.x()) + dprI, | 244 | qAbs(pos.x() - mStartPos.x()) + dprI, | ||
214 | mSelection.height() | 245 | mSelection.height() | ||
215 | ); | 246 | ); | ||
216 | update(); | 247 | update(); | ||
217 | break; | 248 | break; | ||
218 | } | 249 | } | ||
219 | case MouseState::Inside: { | 250 | case MouseState::Inside: { | ||
251 | mMagnifierAllowed = false; | ||||
220 | // We use some math here to figure out if the diff with which we | 252 | // We use some math here to figure out if the diff with which we | ||
221 | // move the rectangle with moves it out of bounds, | 253 | // move the rectangle with moves it out of bounds, | ||
222 | // in which case we adjust the diff to not let that happen | 254 | // in which case we adjust the diff to not let that happen | ||
223 | 255 | | |||
224 | // new top left point of the rectangle | 256 | // new top left point of the rectangle | ||
225 | QPointF newTopLeft = pos - mStartPos + mInitialTopLeft; | 257 | QPointF newTopLeft = pos - mStartPos + mInitialTopLeft; | ||
226 | 258 | | |||
227 | const qreal dprI = 1.0 / devicePixelRatioF(); | 259 | const qreal dprI = 1.0 / devicePixelRatioF(); | ||
Show All 27 Lines | |||||
255 | if (newTopLeft != mSelection.topLeft()) { | 287 | if (newTopLeft != mSelection.topLeft()) { | ||
256 | mSelection.moveTo(newTopLeft); | 288 | mSelection.moveTo(newTopLeft); | ||
257 | update(); | 289 | update(); | ||
258 | } | 290 | } | ||
259 | } | 291 | } | ||
260 | default: | 292 | default: | ||
261 | break; | 293 | break; | ||
262 | } | 294 | } | ||
295 | | ||||
263 | event->accept(); | 296 | event->accept(); | ||
264 | } | 297 | } | ||
265 | 298 | | |||
266 | void QuickEditor::mouseReleaseEvent(QMouseEvent* event) | 299 | void QuickEditor::mouseReleaseEvent(QMouseEvent* event) | ||
267 | { | 300 | { | ||
268 | const auto button = event->button(); | 301 | const auto button = event->button(); | ||
269 | if (button == Qt::LeftButton && mMouseDragState == MouseState::Inside) { | 302 | if (button == Qt::LeftButton && mMouseDragState == MouseState::Inside) { | ||
270 | setCursor(Qt::OpenHandCursor); | 303 | setCursor(Qt::OpenHandCursor); | ||
Show All 14 Lines | 314 | { | |||
285 | } | 318 | } | ||
286 | } | 319 | } | ||
287 | 320 | | |||
288 | void QuickEditor::paintEvent(QPaintEvent*) | 321 | void QuickEditor::paintEvent(QPaintEvent*) | ||
289 | { | 322 | { | ||
290 | QPainter painter(this); | 323 | QPainter painter(this); | ||
291 | painter.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing); | 324 | painter.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing); | ||
292 | const QRect& fullRect = geometry(); | 325 | const QRect& fullRect = geometry(); | ||
293 | painter.drawPixmap(fullRect, mPixmap); | 326 | // painter.drawPixmap(fullRect, mPixmap); | ||
294 | if (!mSelection.size().isEmpty() || mMouseDragState != MouseState::None) { | 327 | if (!mSelection.size().isEmpty() || mMouseDragState != MouseState::None) { | ||
295 | painter.setPen(mStrokeColor); | 328 | painter.setPen(mStrokeColour); | ||
296 | painter.drawRect(mSelection); | 329 | painter.drawRect(mSelection); | ||
297 | 330 | | |||
298 | QRectF top(0, 0, fullRect.width(), mSelection.top()); | 331 | QRectF top(0, 0, fullRect.width(), mSelection.top()); | ||
299 | QRectF right(mSelection.right(), mSelection.top(), fullRect.width() - mSelection.right(), mSelection.height()); | 332 | QRectF right(mSelection.right(), mSelection.top(), fullRect.width() - mSelection.right(), mSelection.height()); | ||
300 | QRectF bottom(0, mSelection.bottom(), fullRect.width(), fullRect.height() - mSelection.bottom()); | 333 | QRectF bottom(0, mSelection.bottom(), fullRect.width(), fullRect.height() - mSelection.bottom()); | ||
301 | QRectF left(0, mSelection.top(), mSelection.left(), mSelection.height()); | 334 | QRectF left(0, mSelection.top(), mSelection.left(), mSelection.height()); | ||
302 | for (auto& rect : { top, right, bottom, left }) { | 335 | for (auto& rect : { top, right, bottom, left }) { | ||
303 | painter.fillRect(rect, mMaskColour); | 336 | painter.fillRect(rect, mMaskColour); | ||
304 | } | 337 | } | ||
305 | 338 | | |||
306 | drawSelectionSizeTooltip(painter); | 339 | drawSelectionSizeTooltip(painter); | ||
307 | if (mMouseDragState == MouseState::None) { // mouse is up | 340 | if (mMouseDragState == MouseState::None) { // mouse is up | ||
308 | if ((mSelection.width() > 20) && (mSelection.height() > 20)) { | 341 | if ((mSelection.width() > 20) && (mSelection.height() > 20)) { | ||
309 | drawDragHandles(painter); | 342 | drawDragHandles(painter); | ||
310 | } | 343 | } | ||
311 | 344 | | |||
312 | drawBottomHelpText(painter); | 345 | drawBottomHelpText(painter); | ||
346 | } else if (mMagnifierAllowed && (mShowMagnifier ^ mToggleMagnifier)) { | ||||
347 | drawMagnifier(painter); | ||||
313 | } | 348 | } | ||
314 | } else { | 349 | } else { | ||
315 | drawMidHelpText(painter); | 350 | drawMidHelpText(painter); | ||
316 | } | 351 | } | ||
317 | } | 352 | } | ||
318 | 353 | | |||
319 | inline void QuickEditor::layoutBottomHelpText() | 354 | inline void QuickEditor::layoutBottomHelpText() | ||
320 | { | 355 | { | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 404 | { | |||
410 | path.moveTo(centerX, bottomY); | 445 | path.moveTo(centerX, bottomY); | ||
411 | path.arcTo(centerX - midHandleRadius, bottomY - midHandleRadius, midHandleDiameter, midHandleDiameter, 0, 180); | 446 | path.arcTo(centerX - midHandleRadius, bottomY - midHandleRadius, midHandleDiameter, midHandleDiameter, 0, 180); | ||
412 | 447 | | |||
413 | // left-center handle | 448 | // left-center handle | ||
414 | path.moveTo(leftX, centerY); | 449 | path.moveTo(leftX, centerY); | ||
415 | path.arcTo(leftX - midHandleRadius, centerY - midHandleRadius, midHandleDiameter, midHandleDiameter, 90, -180); | 450 | path.arcTo(leftX - midHandleRadius, centerY - midHandleRadius, midHandleDiameter, midHandleDiameter, 90, -180); | ||
416 | 451 | | |||
417 | // draw the path | 452 | // draw the path | ||
418 | painter.fillPath(path, mStrokeColor); | 453 | painter.fillPath(path, mStrokeColour); | ||
454 | } | ||||
455 | | ||||
456 | inline void QuickEditor::drawMagnifier(QPainter &painter) | ||||
457 | { | ||||
458 | const int pixels = 2 * magPixels + 1; | ||||
459 | int magX = mMousePos.x() * devicePixelRatioF() - magPixels; | ||||
460 | int offsetX = 0; | ||||
461 | if (magX < 0) { | ||||
462 | offsetX = magX; | ||||
463 | magX = 0; | ||||
464 | } else { | ||||
465 | const int maxX = mPixmap.width() - pixels; | ||||
466 | if (magX > maxX) { | ||||
467 | offsetX = magX - maxX; | ||||
468 | magX = maxX; | ||||
469 | } | ||||
470 | } | ||||
471 | int magY = mMousePos.y() * devicePixelRatioF() - magPixels; | ||||
472 | int offsetY = 0; | ||||
473 | if (magY < 0) { | ||||
474 | offsetY = magY; | ||||
475 | magY = 0; | ||||
476 | } else { | ||||
477 | const int maxY = mPixmap.height() - pixels; | ||||
478 | if (magY > maxY) { | ||||
479 | offsetY = magY - maxY; | ||||
480 | magY = maxY; | ||||
481 | } | ||||
482 | } | ||||
483 | QRectF magniRect(magX, magY, pixels, pixels); | ||||
484 | qDebug() << pixels * magZoom << mMousePos.x() << width() - pixels * magZoom; | ||||
485 | const qreal gg = 32; | ||||
486 | qreal drawPosX = mMousePos.x() + gg + pixels * magZoom / 2; | ||||
487 | if (drawPosX > width() - pixels * magZoom / 2) { | ||||
488 | drawPosX = mMousePos.x() - gg - pixels * magZoom / 2; | ||||
489 | } | ||||
490 | qreal drawPosY = mMousePos.y() + gg + pixels * magZoom / 2; | ||||
491 | if (drawPosY > height() - pixels * magZoom / 2) { | ||||
492 | drawPosY = mMousePos.y() - gg - pixels * magZoom / 2; | ||||
493 | } | ||||
494 | QPointF drawPos(drawPosX, drawPosY); | ||||
495 | qDebug() << devicePixelRatioF(); | ||||
496 | QRectF crossHairTop(drawPos.x() + magZoom * (offsetX - 1.0/devicePixelRatioF()), drawPos.y() - magZoom * (magPixels + 0.5), magZoom, magZoom * (magPixels + offsetY)); | ||||
497 | QRectF crossHairRight(drawPos.x() + magZoom * (0.5 + offsetX), drawPos.y() + magZoom * (offsetY - 0.5), magZoom * (magPixels - offsetX), magZoom); | ||||
498 | QRectF crossHairBottom(drawPos.x() + magZoom * (offsetX - 0.5), drawPos.y() + magZoom * (0.5 + offsetY), magZoom, magZoom * (magPixels - offsetY)); | ||||
499 | QRectF crossHairLeft(drawPos.x() - magZoom * (magPixels + 0.5), drawPos.y() + magZoom * (offsetY - 0.5), magZoom * (magPixels + offsetX), magZoom); | ||||
500 | const auto frag = QPainter::PixmapFragment::create(drawPos, magniRect, magZoom, magZoom); | ||||
501 | painter.drawPixmapFragments(&frag, 1, mPixmap, QPainter::OpaqueHint); | ||||
502 | painter.setCompositionMode(QPainter::CompositionMode_SourceOver); | ||||
503 | for (auto& rect : { crossHairTop, crossHairRight, crossHairBottom, crossHairLeft }) { | ||||
504 | painter.fillRect(rect, mCrossColour); | ||||
505 | } | ||||
419 | } | 506 | } | ||
420 | 507 | | |||
421 | inline void QuickEditor::drawMidHelpText(QPainter &painter) | 508 | inline void QuickEditor::drawMidHelpText(QPainter &painter) | ||
422 | { | 509 | { | ||
423 | const QRect& fullRect = geometry(); | 510 | const QRect& fullRect = geometry(); | ||
424 | painter.fillRect(fullRect, mMaskColour); | 511 | painter.fillRect(fullRect, mMaskColour); | ||
425 | painter.setFont(mMidHelpTextFont); | 512 | painter.setFont(mMidHelpTextFont); | ||
426 | QRect textSize = painter.boundingRect(fullRect, Qt::AlignCenter, mMidHelpText); | 513 | QRect textSize = painter.boundingRect(fullRect, Qt::AlignCenter, mMidHelpText); | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 570 | { | |||
495 | } else { | 582 | } else { | ||
496 | setCursor(Qt::OpenHandCursor); | 583 | setCursor(Qt::OpenHandCursor); | ||
497 | } | 584 | } | ||
498 | } | 585 | } | ||
499 | 586 | | |||
500 | QuickEditor::MouseState QuickEditor::whereIsTheMouse(const QPointF& pos) | 587 | QuickEditor::MouseState QuickEditor::whereIsTheMouse(const QPointF& pos) | ||
501 | { | 588 | { | ||
502 | if (mSelection.contains(pos)) { | 589 | if (mSelection.contains(pos)) { | ||
503 | const qreal verSize = qMin(mouseAreaSize, mSelection.height()); | 590 | const qreal verSize = qMin(mouseAreaSize, mSelection.height() / 2); | ||
504 | const qreal horSize = qMin(mouseAreaSize, mSelection.width()); | 591 | const qreal horSize = qMin(mouseAreaSize, mSelection.width() / 2); | ||
505 | 592 | | |||
506 | auto withinThreshold = [](const qreal offset, const qreal size) { | 593 | auto withinThreshold = [](const qreal offset, const qreal size) { | ||
507 | return offset <= size && offset >= 0; | 594 | return offset <= size && offset >= 0; | ||
508 | }; | 595 | }; | ||
509 | 596 | | |||
510 | const bool withinTopEdge = withinThreshold(pos.y() - mSelection.top(), verSize); | 597 | const bool withinTopEdge = withinThreshold(pos.y() - mSelection.top(), verSize); | ||
511 | const bool withinRightEdge = withinThreshold(mSelection.right() - pos.x(), horSize); | 598 | const bool withinRightEdge = withinThreshold(mSelection.right() - pos.x(), horSize); | ||
512 | const bool withinBottomEdge = !withinTopEdge && withinThreshold(mSelection.bottom() - pos.y(), verSize); | 599 | const bool withinBottomEdge = !withinTopEdge && withinThreshold(mSelection.bottom() - pos.y(), verSize); | ||
Show All 29 Lines |