Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/tool/kis_selection_tool_helper.cpp
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 99 | KUndo2Command* paint() override { | |||
---|---|---|---|---|---|
100 | 100 | | |||
101 | KisPixelSelectionSP pixelSelection = m_view->selection()->pixelSelection(); | 101 | KisPixelSelectionSP pixelSelection = m_view->selection()->pixelSelection(); | ||
102 | KIS_ASSERT_RECOVER(pixelSelection) { return 0; } | 102 | KIS_ASSERT_RECOVER(pixelSelection) { return 0; } | ||
103 | 103 | | |||
104 | bool hasSelection = !pixelSelection->isEmpty(); | 104 | bool hasSelection = !pixelSelection->isEmpty(); | ||
105 | 105 | | |||
106 | KisSelectionTransaction transaction(pixelSelection); | 106 | KisSelectionTransaction transaction(pixelSelection); | ||
107 | 107 | | |||
108 | if (!hasSelection && m_action == SELECTION_SUBTRACT) { | 108 | if (!hasSelection && m_action == SELECTION_SYMMETRICDIFFERENCE) { | ||
109 | pixelSelection->invert(); | 109 | pixelSelection->invert(); | ||
110 | } | 110 | } | ||
111 | 111 | | |||
112 | pixelSelection->applySelection(m_selection, m_action); | 112 | pixelSelection->applySelection(m_selection, m_action); | ||
113 | 113 | | |||
114 | QRect dirtyRect = m_view->image()->bounds(); | 114 | QRect dirtyRect = m_view->image()->bounds(); | ||
115 | if (hasSelection && m_action != SELECTION_REPLACE && m_action != SELECTION_INTERSECT) { | 115 | if (hasSelection && m_action != SELECTION_REPLACE && m_action != SELECTION_SYMMETRICDIFFERENCE) { | ||
116 | dirtyRect = m_selection->selectedRect(); | 116 | dirtyRect = m_selection->selectedRect(); | ||
117 | } | 117 | } | ||
118 | m_view->selection()->updateProjection(dirtyRect); | 118 | m_view->selection()->updateProjection(dirtyRect); | ||
119 | 119 | | |||
120 | KUndo2Command *savedCommand = transaction.endAndTake(); | 120 | KUndo2Command *savedCommand = transaction.endAndTake(); | ||
121 | pixelSelection->setDirty(dirtyRect); | 121 | pixelSelection->setDirty(dirtyRect); | ||
122 | 122 | | |||
123 | if (m_view->selection()->selectedExactRect().isEmpty()) { | 123 | if (m_view->selection()->selectedExactRect().isEmpty()) { | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 205 | if (existingShapes.size() == 1) { | |||
221 | 221 | | |||
222 | case SELECTION_ADD: | 222 | case SELECTION_ADD: | ||
223 | path = path1 | path2; | 223 | path = path1 | path2; | ||
224 | break; | 224 | break; | ||
225 | 225 | | |||
226 | case SELECTION_SUBTRACT: | 226 | case SELECTION_SUBTRACT: | ||
227 | path = path1 - path2; | 227 | path = path1 - path2; | ||
228 | break; | 228 | break; | ||
229 | case SELECTION_SYMMETRICDIFFERENCE: | ||||
230 | path = (path1 | path2) - (path1 & path2); | ||||
231 | break; | ||||
229 | } | 232 | } | ||
230 | 233 | | |||
231 | KoShape *newShape = KoPathShape::createShapeFromPainterPath(path); | 234 | KoShape *newShape = KoPathShape::createShapeFromPainterPath(path); | ||
232 | newShape->setUserData(new KisShapeSelectionMarker); | 235 | newShape->setUserData(new KisShapeSelectionMarker); | ||
233 | 236 | | |||
234 | KUndo2Command *parentCommand = new KUndo2Command(); | 237 | KUndo2Command *parentCommand = new KUndo2Command(); | ||
235 | 238 | | |||
236 | m_view->canvasBase()->shapeController()->removeShape(currentShape, parentCommand); | 239 | m_view->canvasBase()->shapeController()->removeShape(currentShape, parentCommand); | ||
Show All 24 Lines | 263 | Q_FOREACH (KoShape* shape, shapes) { | |||
261 | applicator.applyCommand( | 264 | applicator.applyCommand( | ||
262 | new KisGuiContextCommand(new AddSelectionShape(view, shape, action), view)); | 265 | new KisGuiContextCommand(new AddSelectionShape(view, shape, action), view)); | ||
263 | } | 266 | } | ||
264 | applicator.end(); | 267 | applicator.end(); | ||
265 | } | 268 | } | ||
266 | 269 | | |||
267 | bool KisSelectionToolHelper::canShortcutToDeselect(const QRect &rect, SelectionAction action) | 270 | bool KisSelectionToolHelper::canShortcutToDeselect(const QRect &rect, SelectionAction action) | ||
268 | { | 271 | { | ||
269 | return rect.isEmpty() && (action == SELECTION_INTERSECT || action == SELECTION_REPLACE); | 272 | return rect.isEmpty() && (action == SELECTION_INTERSECT || action == SELECTION_REPLACE); | ||
dkazakov: Is it correct that INTERSECT is not a part of the condition anymore? | |||||
270 | } | 273 | } | ||
271 | 274 | | |||
272 | bool KisSelectionToolHelper::canShortcutToNoop(const QRect &rect, SelectionAction action) | 275 | bool KisSelectionToolHelper::canShortcutToNoop(const QRect &rect, SelectionAction action) | ||
273 | { | 276 | { | ||
274 | return rect.isEmpty() && action == SELECTION_ADD; | 277 | return rect.isEmpty() && action == SELECTION_ADD; | ||
275 | } | 278 | } | ||
276 | 279 | | |||
277 | bool KisSelectionToolHelper::tryDeselectCurrentSelection(const QRectF selectionViewRect, SelectionAction action) | 280 | bool KisSelectionToolHelper::tryDeselectCurrentSelection(const QRectF selectionViewRect, SelectionAction action) | ||
278 | { | 281 | { | ||
279 | bool result = false; | 282 | bool result = false; | ||
280 | 283 | | |||
281 | if (KisAlgebra2D::maxDimension(selectionViewRect) < KisConfig(true).selectionViewSizeMinimum() && | 284 | if (KisAlgebra2D::maxDimension(selectionViewRect) < KisConfig(true).selectionViewSizeMinimum() && | ||
282 | (action == SELECTION_INTERSECT || action == SELECTION_REPLACE)) { | 285 | (action == SELECTION_SYMMETRICDIFFERENCE || action == SELECTION_REPLACE)) { | ||
283 | 286 | | |||
284 | // Queueing this action to ensure we avoid a race condition when unlocking the node system | 287 | // Queueing this action to ensure we avoid a race condition when unlocking the node system | ||
285 | QTimer::singleShot(0, m_canvas->viewManager()->selectionManager(), SLOT(deselect())); | 288 | QTimer::singleShot(0, m_canvas->viewManager()->selectionManager(), SLOT(deselect())); | ||
286 | result = true; | 289 | result = true; | ||
287 | } | 290 | } | ||
288 | 291 | | |||
289 | return result; | 292 | return result; | ||
290 | } | 293 | } | ||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |
Is it correct that INTERSECT is not a part of the condition anymore?