Rev 11645 | Rev 12171 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
11423 | jghali | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | /*************************************************************************** |
||
8 | * * |
||
9 | * This program is free software; you can redistribute it and/or modify * |
||
10 | * it under the terms of the GNU General Public License as published by * |
||
11 | * the Free Software Foundation; either version 2 of the License, or * |
||
12 | * (at your option) any later version. * |
||
13 | * * |
||
14 | ***************************************************************************/ |
||
15 | |||
16 | #include "canvasgesture_resize.h" |
||
17 | |||
18 | #include <QMouseEvent> |
||
19 | #include <QPainter> |
||
20 | #include <QPen> |
||
21 | #include <QRubberBand> |
||
22 | |||
23 | #include "scribusdoc.h" |
||
24 | #include "scribusview.h" |
||
25 | #include "selection.h" |
||
11490 | avox | 26 | #include "undomanager.h" |
11423 | jghali | 27 | |
11491 | jghali | 28 | ResizeGesture::ResizeGesture (CanvasMode* parent) : CanvasGesture(parent) |
29 | { |
||
11576 | avox | 30 | m_transactionStarted = NULL; |
11491 | jghali | 31 | } |
11423 | jghali | 32 | |
33 | void ResizeGesture::prepare(Canvas::FrameHandle framehandle) |
||
34 | { |
||
35 | if (framehandle > 0) |
||
36 | m_handle = framehandle; |
||
37 | |||
38 | if (m_doc->m_Selection->count() == 0) |
||
39 | { |
||
40 | m_handle = Canvas::OUTSIDE; |
||
41 | return; |
||
42 | } |
||
43 | else if (m_doc->m_Selection->isMultipleSelection()) |
||
44 | { |
||
45 | double gx, gy, gh, gw; |
||
46 | m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh); |
||
47 | m_bounds = QRectF(QPointF(gx,gy), QSizeF(gw, gh)); |
||
48 | m_rotation = 0.0; |
||
49 | } |
||
50 | else // we keep m_bounds non-rotated |
||
51 | { |
||
52 | PageItem* currItem = m_doc->m_Selection->itemAt(0); |
||
53 | m_bounds = QRectF(currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height()); |
||
54 | m_rotation = currItem->rotation(); |
||
55 | currItem->OldB2 = currItem->width(); |
||
56 | currItem->OldH2 = currItem->height(); |
||
57 | } |
||
58 | m_origRatio = m_bounds.width() / m_bounds.height(); |
||
59 | m_origBounds = m_bounds; |
||
60 | } |
||
61 | |||
62 | |||
63 | void ResizeGesture::clear() |
||
64 | { |
||
65 | m_handle = Canvas::OUTSIDE; |
||
11490 | avox | 66 | if (m_transactionStarted) |
67 | { |
||
11645 | fschmid | 68 | // qDebug() << "ResizeGesture::clear: cancel transaction" << m_transactionStarted; |
11576 | avox | 69 | m_transactionStarted->cancel(); |
70 | delete m_transactionStarted; |
||
71 | m_transactionStarted = NULL; |
||
11490 | avox | 72 | } |
11423 | jghali | 73 | } |
74 | |||
75 | void ResizeGesture::activate(bool flag) |
||
76 | { |
||
11645 | fschmid | 77 | // qDebug() << "ResizeGesture::activate" << flag; |
11423 | jghali | 78 | } |
79 | |||
80 | |||
81 | |||
11490 | avox | 82 | void ResizeGesture::deactivate(bool forgesture) |
11423 | jghali | 83 | { |
11645 | fschmid | 84 | // qDebug() << "ResizeGesture::deactivate" << forgesture; |
11490 | avox | 85 | if (!forgesture) |
86 | clear(); |
||
11423 | jghali | 87 | } |
88 | |||
89 | |||
90 | |||
91 | void ResizeGesture::drawControls(QPainter* p) |
||
92 | { |
||
93 | QColor drawColor = qApp->palette().color(QPalette::Active, QPalette::Highlight); |
||
94 | QRect localRect = m_canvas->canvasToLocal(m_bounds); |
||
95 | p->save(); |
||
96 | // p->setPen(QPen(Qt::black, 1, Qt::DashLine, Qt::FlatCap, Qt::MiterJoin)); |
||
97 | // p->drawRect(localRect); |
||
98 | if (m_rotation != 0) |
||
99 | { |
||
100 | p->setRenderHint(QPainter::Antialiasing); |
||
101 | p->translate(localRect.x(), localRect.y()); |
||
102 | p->rotate(m_rotation); |
||
103 | p->translate(-localRect.x(), -localRect.y()); |
||
104 | } |
||
105 | p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
||
106 | drawColor.setAlpha(64); |
||
107 | p->setBrush(drawColor); |
||
108 | p->drawRect(localRect); |
||
109 | // p->setPen(Qt::darkMagenta); |
||
110 | // p->drawLine(localRect.topLeft(), localRect.bottomRight()); |
||
111 | p->restore(); |
||
112 | |||
113 | if (m_origBounds != m_bounds) |
||
114 | { |
||
115 | p->save(); |
||
116 | // p->translate(m_bounds.topLeft() - m_origBounds.topLeft()); |
||
117 | drawOutline(p, qAbs(m_bounds.width()) / qMax(qAbs(m_origBounds.width()), 1.0), |
||
118 | qAbs(m_bounds.height()) / qMax(qAbs(m_origBounds.height()), 1.0), |
||
119 | m_bounds.left() - m_origBounds.left(), |
||
120 | m_bounds.top() - m_origBounds.top()); |
||
121 | p->restore(); |
||
122 | } |
||
123 | } |
||
124 | |||
125 | |||
126 | |||
127 | void ResizeGesture::mouseReleaseEvent(QMouseEvent *m) |
||
128 | { |
||
129 | adjustBounds(m); |
||
130 | if (m_doc->m_Selection->count() != 0) |
||
131 | { |
||
132 | PageItem* currItem = m_doc->m_Selection->itemAt(0); |
||
11645 | fschmid | 133 | // qDebug() << "ResizeGesture::release: new bounds" << m_bounds; |
11423 | jghali | 134 | doResize(m->modifiers() & Qt::AltModifier); |
135 | m_doc->setRedrawBounding(currItem); |
||
136 | if (currItem->asImageFrame()) |
||
137 | currItem->AdjustPictScale(); |
||
11576 | avox | 138 | m_view->resetMousePressed(); |
139 | // necessary since mousebutton is still recorded pressed, and otherwise checkchages() will do nothing |
||
140 | currItem->checkChanges(); |
||
11423 | jghali | 141 | currItem->invalidateLayout(); |
142 | currItem->update(); |
||
143 | } |
||
11576 | avox | 144 | // qDebug() << "ResizeGesture::release: transaction" << m_transactionStarted; |
11490 | avox | 145 | if (m_transactionStarted) |
146 | { |
||
11576 | avox | 147 | m_transactionStarted->commit(); |
148 | delete m_transactionStarted; |
||
149 | m_transactionStarted = NULL; |
||
11490 | avox | 150 | } |
11423 | jghali | 151 | m->accept(); |
152 | m_canvas->update(); |
||
153 | m_view->stopGesture(); |
||
154 | } |
||
155 | |||
156 | |||
157 | void ResizeGesture::doResize(bool scaleContent) |
||
158 | { |
||
11576 | avox | 159 | PageItem* currItem = m_doc->m_Selection->itemAt(0); |
160 | QString targetName = Um::SelectionGroup; |
||
161 | QPixmap* targetIcon = Um::IGroup; |
||
162 | if (!m_doc->m_Selection->isMultipleSelection()) |
||
163 | { |
||
164 | targetName = currItem->getUName(); |
||
165 | targetIcon = currItem->getUPixmap(); |
||
166 | } |
||
11490 | avox | 167 | if (!m_transactionStarted) |
168 | { |
||
11576 | avox | 169 | m_transactionStarted = new UndoTransaction(Um::instance()->beginTransaction(targetName, targetIcon, |
170 | Um::Resize, "", Um::IResize)); |
||
171 | // qDebug() << "ResizeGesture::doResize: begin transaction" << m_transactionStarted; |
||
11490 | avox | 172 | } |
11423 | jghali | 173 | QRectF newBounds = m_bounds.normalized(); |
174 | if (m_doc->m_Selection->isMultipleSelection()) |
||
175 | { |
||
176 | double gx, gy, gh, gw; |
||
177 | m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh); |
||
178 | QRectF oldBounds(gx, gy, gw, gh); |
||
179 | double scx = oldBounds.width() == 0? 1.0 : newBounds.width() / oldBounds.width(); |
||
180 | double scy = oldBounds.height() == 0? 1.0 : newBounds.height() / oldBounds.height(); |
||
181 | //CB #3012 only scale text in a group if alt is pressed |
||
182 | if ((currItem->itemType() == PageItem::TextFrame) && scaleContent) |
||
11490 | avox | 183 | m_doc->scaleGroup(scx, scy, true); |
11423 | jghali | 184 | else |
11490 | avox | 185 | m_doc->scaleGroup(scx, scy, false); |
11423 | jghali | 186 | double dx = newBounds.x() - oldBounds.x(); |
187 | double dy = newBounds.y() - oldBounds.y(); |
||
188 | if (dx != 0 || dy != 0) |
||
11490 | avox | 189 | m_doc->moveGroup(dx, dy); |
11423 | jghali | 190 | } |
191 | else |
||
192 | { |
||
11408 | jghali | 193 | if ((currItem->itemType() == PageItem::ImageFrame) && scaleContent) |
194 | { |
||
195 | double divX = (currItem->width() != 0) ? currItem->width() : 1.0; |
||
196 | double divY = (currItem->height() != 0) ? currItem->height() : 1.0; |
||
197 | double imgScX = newBounds.width() / divX * currItem->imageXScale(); |
||
198 | double imgScY = newBounds.height() / divY * currItem->imageYScale(); |
||
199 | // The aspect ratio has been fixed, so make the modification in the direction of the larger movement. |
||
200 | if (currItem->keepAspectRatio() && currItem->fitImageToFrame()) |
||
201 | { |
||
202 | if (qAbs(newBounds.width() - currItem->width()) > qAbs(newBounds.height() - currItem->height())) |
||
203 | imgScY = imgScX; |
||
204 | else |
||
205 | imgScX = imgScY; |
||
206 | } |
||
11423 | jghali | 207 | currItem->setImageXYScale(imgScX, imgScY); |
208 | } |
||
209 | currItem->setXYPos(newBounds.x(), newBounds.y()); |
||
210 | currItem->setWidth(newBounds.width()); |
||
211 | currItem->setHeight(newBounds.height()); |
||
212 | // rotation does not change |
||
213 | } |
||
214 | m_origBounds = m_bounds; |
||
215 | currItem->updateClip(); |
||
216 | } |
||
217 | |||
218 | |||
219 | void ResizeGesture::mouseMoveEvent(QMouseEvent *m) |
||
220 | { |
||
221 | adjustBounds(m); |
||
222 | FPoint where = m_canvas->globalToCanvas(m->globalPos()); |
||
223 | if (// directly after a create the shape of an item isnt really usable, so we fix here |
||
224 | m_origBounds.width() < 20 || m_origBounds.height() < 20 || |
||
225 | // and if we resize outside of the current canvas dimensions, we need to enlarge it |
||
226 | where.x() < m_doc->minCanvasCoordinate.x() || where.y() < m_doc->minCanvasCoordinate.y() || |
||
227 | where.x() > m_doc->maxCanvasCoordinate.x() || where.y() > m_doc->maxCanvasCoordinate.y()) |
||
228 | { |
||
229 | doResize(m->modifiers() & Qt::AltModifier); |
||
230 | } |
||
231 | m->accept(); |
||
232 | QPoint point = m->globalPos() - m_canvas->mapToGlobal(QPoint(0,0)); |
||
233 | m_view->ensureVisible(point.x(), point.y(), 20, 20); |
||
234 | m_canvas->repaint(); |
||
235 | } |
||
236 | |||
237 | |||
238 | |||
239 | void ResizeGesture::adjustBounds(QMouseEvent *m) |
||
240 | { |
||
241 | QMatrix rotation; |
||
242 | FPoint docPoint = m_canvas->globalToCanvas(m->globalPos()); |
||
243 | QPointF oldXY = m_bounds.topLeft(); |
||
244 | // proportional resize |
||
245 | bool constrainRatio = ((m->modifiers() & Qt::ControlModifier) != Qt::NoModifier); |
||
246 | |||
247 | |||
248 | // snap to grid + snap to guides |
||
249 | bool isCorner = m_handle == Canvas::NORTHWEST || m_handle == Canvas::NORTHEAST |
||
250 | || m_handle == Canvas::SOUTHWEST || m_handle == Canvas::SOUTHEAST; |
||
251 | if (m_rotation == 0 || isCorner) |
||
252 | { |
||
253 | FPoint snappedPoint = m_doc->ApplyGridF(docPoint); |
||
254 | double x = snappedPoint.x(), y = snappedPoint.y(); |
||
11887 | fschmid | 255 | m_doc->ApplyGuides(&x, &y); |
11645 | fschmid | 256 | // if (m_doc->ApplyGuides(&x, &y)) |
257 | // qDebug() << "guides applied:" << snappedPoint.x() << snappedPoint.y() << "to" << x << y; |
||
11423 | jghali | 258 | if (m_handle == Canvas::NORTH || m_handle == Canvas::SOUTH) |
259 | // only snap on y-axis |
||
260 | docPoint = FPoint(docPoint.x(), y); |
||
261 | else if (m_handle == Canvas::EAST || m_handle == Canvas::WEST) |
||
262 | // only snap on x-axis |
||
263 | docPoint = FPoint(x, docPoint.y()); |
||
264 | else |
||
265 | docPoint = FPoint(x,y); |
||
11645 | fschmid | 266 | // qDebug() << "resize snap grid/guides:" << m->globalPos() << "-->" << m_canvas->canvasToGlobal(docPoint); |
11423 | jghali | 267 | } |
268 | |||
269 | // un-rotate point |
||
270 | if (m_rotation != 0) |
||
271 | { |
||
272 | // rotate point around item position |
||
273 | rotation.translate(m_bounds.x(), m_bounds.y()); |
||
274 | rotation.rotate(m_rotation); |
||
275 | rotation.translate(-m_bounds.x(), -m_bounds.y()); |
||
276 | // qDebug() << "resize rotated" << m_rotation << "°" << m_bounds << rotation << ":" << point-globalBounds.topLeft() << "-->" << rotation.map(point)-globalBounds.topLeft(); |
||
277 | QPointF qp = QPointF(docPoint.x(), docPoint.y()); |
||
278 | qp = rotation.inverted().map(qp); |
||
279 | docPoint = FPoint(qp.x(), qp.y()); |
||
280 | } |
||
281 | |||
282 | // adjust bounds vertically |
||
283 | switch (m_handle) |
||
284 | { |
||
285 | case Canvas::NORTHWEST: |
||
286 | case Canvas::NORTH: |
||
287 | case Canvas::NORTHEAST: |
||
288 | // qDebug() << "ResizeGesture: top to" << point.y(); |
||
289 | m_bounds.setTop(docPoint.y()); |
||
290 | break; |
||
291 | case Canvas::SOUTHWEST: |
||
292 | case Canvas::SOUTH: |
||
293 | case Canvas::SOUTHEAST: |
||
294 | // qDebug() << "ResizeGesture: bottom to" << point.y(); |
||
295 | m_bounds.setBottom(docPoint.y()); |
||
296 | break; |
||
297 | default: |
||
298 | break; |
||
299 | } |
||
300 | // adjust bounds horizontally |
||
301 | switch (m_handle) |
||
302 | { |
||
303 | case Canvas::NORTHWEST: |
||
304 | case Canvas::WEST: |
||
305 | case Canvas::SOUTHWEST: |
||
306 | // qDebug() << "ResizeGesture: left to" << point.x(); |
||
307 | m_bounds.setLeft(docPoint.x()); |
||
308 | break; |
||
309 | case Canvas::NORTHEAST: |
||
310 | case Canvas::EAST: |
||
311 | case Canvas::SOUTHEAST: |
||
312 | // qDebug() << "ResizeGesture: right to" << point.x(); |
||
313 | m_bounds.setRight(docPoint.x()); |
||
314 | break; |
||
315 | default: |
||
316 | break; |
||
317 | } |
||
318 | |||
319 | // constrain ratio |
||
320 | double newRatio = double(m_bounds.width()) / double(m_bounds.height()); |
||
321 | if (constrainRatio && m_origRatio != newRatio) |
||
322 | { |
||
11645 | fschmid | 323 | // qDebug() << "constrain ratio:" << m_bounds << newRatio << "to" << m_origRatio; |
11423 | jghali | 324 | int newWidth = qRound(m_bounds.height() * m_origRatio); |
325 | int newHeight = qRound(m_bounds.width() / m_origRatio); |
||
326 | switch (m_handle) |
||
327 | { |
||
328 | case Canvas::NORTHWEST: |
||
329 | // axis: topleft + t*[origRatio, 1] t:= y-top |
||
330 | // [x',y] = [left, top] + [(y-top)*origRatio, y-top] |
||
331 | // = [left + (y-top)*origRatio, y] |
||
332 | // x < x' => mouse is WEST, x > x' => mouse is NORTH |
||
333 | // x < left + (y-top)*origratio <=> x - left < (y - top) * origratio |
||
334 | |||
335 | // qDebug() << "NORTHWEST" << point << m_origBounds.topLeft() << m_origRatio |
||
336 | // << (point.x() - m_origBounds.left() < (point.y()-m_origBounds.top()) * m_origRatio); |
||
337 | |||
338 | if (docPoint.x() - m_origBounds.left() < (docPoint.y()-m_origBounds.top()) * m_origRatio) |
||
339 | m_bounds.setTop(m_bounds.top() - newHeight + m_bounds.height()); |
||
340 | else |
||
341 | m_bounds.setLeft(m_bounds.left() - newWidth + m_bounds.width()); |
||
342 | break; |
||
343 | case Canvas::SOUTHWEST: |
||
344 | // axis: bottomleft + t*[origRatio, -1] t:= bottom-y |
||
345 | // (x',y) = [left, bottom] + [(bottom-y)*origRatio, -bottom+y] |
||
346 | // = [left + (bottom-y)*origRatio, y] |
||
347 | // x < x' => mouse is WEST, x > x' => mouse is SOUTH |
||
348 | // x < left + (bottom-y)*origratio <=> x - left < (bottom-y) * origratio |
||
349 | |||
350 | // qDebug() << "SOUTHWEST" << point << m_origBounds.bottomLeft() << m_origRatio |
||
351 | // << (point.x() - m_origBounds.left() < (m_origBounds.bottom() - point.y()) * m_origRatio); |
||
352 | |||
353 | if (docPoint.x() - m_origBounds.left() < (m_origBounds.bottom() - docPoint.y()) * m_origRatio) |
||
354 | m_bounds.setHeight(newHeight); |
||
355 | else |
||
356 | m_bounds.setLeft(m_bounds.left() - newWidth + m_bounds.width()); |
||
357 | break; |
||
358 | case Canvas::NORTHEAST: |
||
359 | // cf. SOUTHWEST |
||
360 | if (docPoint.x() - m_origBounds.left() > (m_origBounds.bottom() - docPoint.y()) * m_origRatio) |
||
361 | m_bounds.setTop(m_bounds.top() - newHeight + m_bounds.height()); |
||
362 | else |
||
363 | m_bounds.setWidth(newWidth); |
||
364 | break; |
||
365 | case Canvas::SOUTHEAST: |
||
366 | // cf. NORTHWEST |
||
367 | if (docPoint.x() - m_origBounds.left() > (docPoint.y()-m_origBounds.top()) * m_origRatio) |
||
368 | m_bounds.setHeight(newHeight); |
||
369 | else |
||
370 | m_bounds.setWidth(newWidth); |
||
371 | break; |
||
372 | case Canvas::WEST: |
||
373 | case Canvas::EAST: |
||
374 | // (origBounds.top + origBounds.bottom) / 2 is the horizontal axis |
||
375 | // keep that fixed |
||
376 | m_bounds.setTop(((m_origBounds.top() + m_origBounds.bottom()) / 2) - newHeight / 2); |
||
377 | m_bounds.setHeight(newHeight); |
||
378 | break; |
||
379 | case Canvas::NORTH: |
||
380 | case Canvas::SOUTH: |
||
381 | // (origBounds.left + origBounds.right) / 2 is the vertical axis |
||
382 | // keep that fixed |
||
383 | m_bounds.setLeft(((m_origBounds.left() + m_origBounds.right()) / 2) - newWidth / 2); |
||
384 | m_bounds.setWidth(newWidth); |
||
385 | break; |
||
386 | default: |
||
387 | break; |
||
388 | } |
||
11645 | fschmid | 389 | // qDebug() << "constrained:" << m_bounds << double(m_bounds.width()) / m_bounds.height(); |
11423 | jghali | 390 | } |
391 | |||
392 | // re-rotate: if top left has changed, then it needs rotation |
||
393 | if (m_rotation != 0 && oldXY != m_bounds.topLeft()) |
||
394 | { |
||
395 | m_bounds.moveTo(rotation.map(m_bounds.topLeft())); |
||
396 | // fix opposite corner to avoid aggregating rounding errors |
||
397 | QPointF origFixPoint, newFixPoint; |
||
398 | switch (m_handle) |
||
399 | { |
||
400 | case Canvas::NORTHWEST: |
||
401 | origFixPoint = m_origBounds.bottomRight(); |
||
402 | newFixPoint = m_bounds.bottomRight(); |
||
403 | break; |
||
404 | case Canvas::WEST: |
||
405 | origFixPoint = m_origBounds.topRight() + QPointF(0, m_origBounds.height()/2); |
||
406 | newFixPoint = m_bounds.topRight() + QPointF(0, m_bounds.height()/2); |
||
407 | break; |
||
408 | case Canvas::SOUTHWEST: |
||
409 | origFixPoint = m_origBounds.topRight(); |
||
410 | newFixPoint = m_bounds.topRight(); |
||
411 | break; |
||
412 | case Canvas::SOUTH: |
||
413 | origFixPoint = m_origBounds.topLeft() + QPointF(m_origBounds.width()/2, 0); |
||
414 | newFixPoint = m_bounds.topLeft() + QPointF(m_bounds.width()/2, 0); |
||
415 | break; |
||
416 | case Canvas::SOUTHEAST: |
||
417 | origFixPoint = m_origBounds.topLeft(); |
||
418 | newFixPoint = m_bounds.topLeft(); |
||
419 | break; |
||
420 | case Canvas::EAST: |
||
421 | origFixPoint = m_origBounds.topLeft() + QPointF(0, m_origBounds.height()/2); |
||
422 | newFixPoint = m_bounds.topLeft() + QPointF(0, m_bounds.height()/2); |
||
423 | break; |
||
424 | case Canvas::NORTHEAST: |
||
425 | origFixPoint = m_origBounds.bottomLeft(); |
||
426 | newFixPoint = m_bounds.bottomLeft(); |
||
427 | break; |
||
428 | case Canvas::NORTH: |
||
429 | origFixPoint = m_origBounds.bottomLeft() + QPointF(m_origBounds.width()/2, 0); |
||
430 | newFixPoint = m_bounds.bottomLeft() + QPointF(m_bounds.width()/2, 0); |
||
431 | break; |
||
432 | default: |
||
433 | origFixPoint = m_origBounds.topLeft(); |
||
434 | newFixPoint = m_bounds.topLeft(); |
||
435 | break; |
||
436 | } |
||
437 | origFixPoint = m_origBounds.topLeft() + rotation.map(origFixPoint - m_origBounds.topLeft()); |
||
438 | newFixPoint = m_bounds.topLeft() + rotation.map(newFixPoint - m_bounds.topLeft()); |
||
439 | if (origFixPoint != newFixPoint) |
||
440 | m_bounds.translate(origFixPoint - newFixPoint); |
||
441 | } |
||
442 | } |
||
443 | |||
444 | |||
445 | |||
446 | void ResizeGesture::mousePressEvent(QMouseEvent *m) |
||
447 | { |
||
448 | FPoint point = m_canvas->globalToCanvas(m->globalPos()); |
||
449 | if (m_doc->m_Selection->count() == 0) |
||
450 | { |
||
451 | m_handle = Canvas::OUTSIDE; |
||
452 | } |
||
453 | else if (m_doc->m_Selection->isMultipleSelection()) |
||
454 | { |
||
455 | double gx, gy, gh, gw; |
||
456 | m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh); |
||
457 | m_handle = m_canvas->frameHitTest(QPointF(point.x(), point.y()), QRectF(gx,gy,gw,gh)); |
||
458 | } |
||
459 | else |
||
460 | { |
||
461 | m_handle = m_canvas->frameHitTest(QPointF(point.x(), point.y()), m_doc->m_Selection->itemAt(0)); |
||
462 | } |
||
463 | if (m_handle > 0) |
||
464 | { |
||
465 | prepare(m_handle); |
||
466 | m->accept(); |
||
467 | } |
||
468 | } |