Changeset View
Changeset View
Standalone View
Standalone View
tools/selection/kpAbstractSelectionTool_Move.cpp
Show All 19 Lines | 2 | /* | |||
---|---|---|---|---|---|
20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | 26 | */ | ||
27 | 27 | | |||
28 | | ||||
29 | #define DEBUG_KP_TOOL_SELECTION 0 | | |||
30 | | ||||
31 | | ||||
32 | #include "kpAbstractSelectionTool.h" | 28 | #include "kpAbstractSelectionTool.h" | ||
33 | #include "kpAbstractSelectionToolPrivate.h" | 29 | #include "kpAbstractSelectionToolPrivate.h" | ||
34 | #include "kpLogCategories.h" | 30 | #include "kpLogCategories.h" | ||
35 | #include "layers/selections/image/kpAbstractImageSelection.h" | 31 | #include "layers/selections/image/kpAbstractImageSelection.h" | ||
36 | #include "layers/selections/kpAbstractSelection.h" | 32 | #include "layers/selections/kpAbstractSelection.h" | ||
37 | #include "commands/kpCommandHistory.h" | 33 | #include "commands/kpCommandHistory.h" | ||
38 | #include "kpDefs.h" | 34 | #include "kpDefs.h" | ||
39 | #include "document/kpDocument.h" | 35 | #include "document/kpDocument.h" | ||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | 170 | if (sel) | |||
175 | setUserShapePoints (sel->topLeft ()); | 171 | setUserShapePoints (sel->topLeft ()); | ||
176 | } | 172 | } | ||
177 | 173 | | |||
178 | //--------------------------------------------------------------------- | 174 | //--------------------------------------------------------------------- | ||
179 | 175 | | |||
180 | // private | 176 | // private | ||
181 | void kpAbstractSelectionTool::drawMove (const QPoint &thisPoint, const QRect &/*normalizedRect*/) | 177 | void kpAbstractSelectionTool::drawMove (const QPoint &thisPoint, const QRect &/*normalizedRect*/) | ||
182 | { | 178 | { | ||
183 | #if DEBUG_KP_TOOL_SELECTION && 1 | | |||
184 | qCDebug(kpLogTools) << "\tmoving selection"; | 179 | qCDebug(kpLogTools) << "\tmoving selection"; | ||
185 | #endif | | |||
186 | 180 | | |||
187 | kpAbstractSelection *sel = document ()->selection (); | 181 | kpAbstractSelection *sel = document ()->selection (); | ||
188 | 182 | | |||
189 | QRect targetSelRect (thisPoint.x () - d->startMoveDragFromSelectionTopLeft.x (), | 183 | QRect targetSelRect (thisPoint.x () - d->startMoveDragFromSelectionTopLeft.x (), | ||
190 | thisPoint.y () - d->startMoveDragFromSelectionTopLeft.y (), | 184 | thisPoint.y () - d->startMoveDragFromSelectionTopLeft.y (), | ||
191 | sel->width (), | 185 | sel->width (), | ||
192 | sel->height ()); | 186 | sel->height ()); | ||
193 | 187 | | |||
194 | #if DEBUG_KP_TOOL_SELECTION && 1 | | |||
195 | qCDebug(kpLogTools) << "\t\tstartPoint=" << startPoint () | 188 | qCDebug(kpLogTools) << "\t\tstartPoint=" << startPoint () | ||
196 | << " thisPoint=" << thisPoint | 189 | << " thisPoint=" << thisPoint | ||
197 | << " startDragFromSel=" << d->startMoveDragFromSelectionTopLeft | 190 | << " startDragFromSel=" << d->startMoveDragFromSelectionTopLeft | ||
198 | << " targetSelRect=" << targetSelRect | 191 | << " targetSelRect=" << targetSelRect; | ||
199 | << endl; | | |||
200 | #endif | | |||
201 | 192 | | |||
202 | // Try to make sure selection still intersects document so that it's | 193 | // Try to make sure selection still intersects document so that it's | ||
203 | // reachable. | 194 | // reachable. | ||
204 | 195 | | |||
205 | if (targetSelRect.right () < 0) | 196 | if (targetSelRect.right () < 0) | ||
206 | targetSelRect.translate (-targetSelRect.right (), 0); | 197 | targetSelRect.translate (-targetSelRect.right (), 0); | ||
207 | else if (targetSelRect.left () >= document ()->width ()) | 198 | else if (targetSelRect.left () >= document ()->width ()) | ||
208 | targetSelRect.translate (document ()->width () - targetSelRect.left () - 1, 0); | 199 | targetSelRect.translate (document ()->width () - targetSelRect.left () - 1, 0); | ||
209 | 200 | | |||
210 | if (targetSelRect.bottom () < 0) | 201 | if (targetSelRect.bottom () < 0) | ||
211 | targetSelRect.translate (0, -targetSelRect.bottom ()); | 202 | targetSelRect.translate (0, -targetSelRect.bottom ()); | ||
212 | else if (targetSelRect.top () >= document ()->height ()) | 203 | else if (targetSelRect.top () >= document ()->height ()) | ||
213 | targetSelRect.translate (0, document ()->height () - targetSelRect.top () - 1); | 204 | targetSelRect.translate (0, document ()->height () - targetSelRect.top () - 1); | ||
214 | 205 | | |||
215 | #if DEBUG_KP_TOOL_SELECTION && 1 | | |||
216 | qCDebug(kpLogTools) << "\t\t\tafter ensure sel rect clickable=" << targetSelRect; | 206 | qCDebug(kpLogTools) << "\t\t\tafter ensure sel rect clickable=" << targetSelRect; | ||
217 | #endif | | |||
218 | 207 | | |||
219 | 208 | | |||
220 | if (!d->dragAccepted && | 209 | if (!d->dragAccepted && | ||
221 | targetSelRect.topLeft () + d->startMoveDragFromSelectionTopLeft == startPoint ()) | 210 | targetSelRect.topLeft () + d->startMoveDragFromSelectionTopLeft == startPoint ()) | ||
222 | { | 211 | { | ||
223 | #if DEBUG_KP_TOOL_SELECTION && 1 | | |||
224 | qCDebug(kpLogTools) << "\t\t\t\tnop"; | 212 | qCDebug(kpLogTools) << "\t\t\t\tnop"; | ||
225 | #endif | | |||
226 | | ||||
227 | 213 | | |||
228 | if (!d->RMBMoveUpdateGUITimer->isActive ()) | 214 | if (!d->RMBMoveUpdateGUITimer->isActive ()) | ||
229 | { | 215 | { | ||
230 | // (slotRMBMoveUpdateGUI() calls similar line) | 216 | // (slotRMBMoveUpdateGUI() calls similar line) | ||
231 | setUserShapePoints (sel->topLeft ()); | 217 | setUserShapePoints (sel->topLeft ()); | ||
232 | } | 218 | } | ||
233 | 219 | | |||
234 | // Prevent both NOP drag-moves | 220 | // Prevent both NOP drag-moves | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
284 | d->dragAccepted = true; | 270 | d->dragAccepted = true; | ||
285 | } | 271 | } | ||
286 | 272 | | |||
287 | //--------------------------------------------------------------------- | 273 | //--------------------------------------------------------------------- | ||
288 | 274 | | |||
289 | // private | 275 | // private | ||
290 | void kpAbstractSelectionTool::cancelMove () | 276 | void kpAbstractSelectionTool::cancelMove () | ||
291 | { | 277 | { | ||
292 | #if DEBUG_KP_TOOL_SELECTION | | |||
293 | qCDebug(kpLogTools) << "\twas drag moving - undo drag and undo acquire"; | 278 | qCDebug(kpLogTools) << "\twas drag moving - undo drag and undo acquire"; | ||
294 | #endif | | |||
295 | 279 | | |||
296 | d->RMBMoveUpdateGUITimer->stop (); | 280 | d->RMBMoveUpdateGUITimer->stop (); | ||
297 | 281 | | |||
298 | // NOP drag? | 282 | // NOP drag? | ||
299 | if (!d->currentMoveCommand) | 283 | if (!d->currentMoveCommand) | ||
300 | return; | 284 | return; | ||
301 | 285 | | |||
302 | #if DEBUG_KP_TOOL_SELECTION | | |||
303 | qCDebug(kpLogTools) << "\t\tundo currentMoveCommand"; | 286 | qCDebug(kpLogTools) << "\t\tundo currentMoveCommand"; | ||
304 | #endif | | |||
305 | d->currentMoveCommand->finalize (); | 287 | d->currentMoveCommand->finalize (); | ||
306 | d->currentMoveCommand->unexecute (); | 288 | d->currentMoveCommand->unexecute (); | ||
307 | delete d->currentMoveCommand; | 289 | delete d->currentMoveCommand; | ||
308 | d->currentMoveCommand = nullptr; | 290 | d->currentMoveCommand = nullptr; | ||
309 | } | 291 | } | ||
310 | 292 | | |||
311 | //--------------------------------------------------------------------- | 293 | //--------------------------------------------------------------------- | ||
312 | 294 | | |||
Show All 12 Lines | 305 | { | |||
325 | 307 | | |||
326 | // NOP drag? | 308 | // NOP drag? | ||
327 | if (!d->currentMoveCommand) | 309 | if (!d->currentMoveCommand) | ||
328 | return; | 310 | return; | ||
329 | 311 | | |||
330 | d->currentMoveCommand->finalize (); | 312 | d->currentMoveCommand->finalize (); | ||
331 | 313 | | |||
332 | kpMacroCommand *renamedCmd = nullptr; | 314 | kpMacroCommand *renamedCmd = nullptr; | ||
333 | #if DEBUG_KP_TOOL_SELECTION | | |||
334 | qCDebug(kpLogTools) << "\thave moveCommand"; | 315 | qCDebug(kpLogTools) << "\thave moveCommand"; | ||
335 | #endif | | |||
336 | if (d->currentMoveCommandIsSmear) | 316 | if (d->currentMoveCommandIsSmear) | ||
337 | { | 317 | { | ||
338 | renamedCmd = new kpMacroCommand (i18n ("%1: Smear", | 318 | renamedCmd = new kpMacroCommand (i18n ("%1: Smear", | ||
339 | document ()->selection ()->name ()), | 319 | document ()->selection ()->name ()), | ||
340 | environ ()->commandEnvironment ()); | 320 | environ ()->commandEnvironment ()); | ||
341 | } | 321 | } | ||
342 | else | 322 | else | ||
343 | { | 323 | { | ||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |