File indexing completed on 2024-12-08 11:07:18
0001 /*************************************************************************** 0002 * Copyright (C) 2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #include "resizeoverlay.h" 0012 #include "itemdocument.h" 0013 #include "mechanicsitem.h" 0014 0015 #include <QPainter> 0016 #include <cmath> 0017 0018 #include <ktechlab_debug.h> 0019 0020 #define DPR (180.0 / M_PI) 0021 0022 // BEGIN class ResizeOverlay 0023 ResizeOverlay::ResizeOverlay(Item *parent) 0024 : QObject(parent) 0025 { 0026 b_showResizeHandles = false; 0027 b_visible = true; 0028 p_item = parent; 0029 } 0030 0031 ResizeOverlay::~ResizeOverlay() 0032 { 0033 const ResizeHandleMap::iterator end = m_resizeHandleMap.end(); 0034 for (ResizeHandleMap::iterator it = m_resizeHandleMap.begin(); it != end; ++it) { 0035 if (it.value()) 0036 it.value()->setCanvas(nullptr); 0037 delete static_cast<ResizeHandle *>(it.value()); 0038 } 0039 m_resizeHandleMap.clear(); 0040 } 0041 0042 void ResizeOverlay::showResizeHandles(bool show) 0043 { 0044 b_showResizeHandles = show; 0045 const ResizeHandleMap::iterator end = m_resizeHandleMap.end(); 0046 for (ResizeHandleMap::iterator it = m_resizeHandleMap.begin(); it != end; ++it) { 0047 it.value()->setVisible(b_showResizeHandles && b_visible); 0048 } 0049 } 0050 0051 void ResizeOverlay::setVisible(bool visible) 0052 { 0053 b_visible = visible; 0054 const ResizeHandleMap::iterator end = m_resizeHandleMap.end(); 0055 for (ResizeHandleMap::iterator it = m_resizeHandleMap.begin(); it != end; ++it) { 0056 it.value()->setVisible(b_showResizeHandles && b_visible); 0057 } 0058 } 0059 0060 ResizeHandle *ResizeOverlay::createResizeHandle(int id, ResizeHandle::DrawType drawType, int xsnap, int ysnap) 0061 { 0062 ResizeHandleMap::iterator it = m_resizeHandleMap.find(id); 0063 if (it != m_resizeHandleMap.end()) 0064 return it.value(); 0065 0066 ResizeHandle *newResizeHandle = new ResizeHandle(this, id, drawType, xsnap, ysnap); 0067 m_resizeHandleMap[id] = newResizeHandle; 0068 connect(newResizeHandle, &ResizeHandle::rhMovedBy, this, &ResizeOverlay::slotResizeHandleMoved); 0069 return newResizeHandle; 0070 } 0071 0072 void ResizeOverlay::removeResizeHandle(int id) 0073 { 0074 ResizeHandleMap::iterator it = m_resizeHandleMap.find(id); 0075 if (it == m_resizeHandleMap.end()) 0076 return; 0077 0078 ResizeHandle *rh = it.value(); 0079 disconnect(rh, &ResizeHandle::rhMovedBy, this, &ResizeOverlay::slotResizeHandleMoved); 0080 delete rh; 0081 m_resizeHandleMap.erase(it); 0082 } 0083 0084 ResizeHandle *ResizeOverlay::resizeHandle(int id) 0085 { 0086 ResizeHandleMap::iterator it = m_resizeHandleMap.find(id); 0087 if (it != m_resizeHandleMap.end()) 0088 return it.value(); 0089 return nullptr; 0090 } 0091 0092 void ResizeOverlay::slotMoveAllResizeHandles(double dx, double dy) 0093 { 0094 const ResizeHandleMap::iterator end = m_resizeHandleMap.end(); 0095 for (ResizeHandleMap::iterator it = m_resizeHandleMap.begin(); it != end; ++it) { 0096 it.value()->moveBy(dx, dy); 0097 } 0098 } 0099 0100 void ResizeOverlay::syncX(ResizeHandle *rh1, ResizeHandle *rh2, ResizeHandle *rh3) 0101 { 0102 syncX(rh1, rh2); 0103 syncX(rh1, rh3); 0104 syncX(rh2, rh3); 0105 } 0106 void ResizeOverlay::syncY(ResizeHandle *rh1, ResizeHandle *rh2, ResizeHandle *rh3) 0107 { 0108 syncY(rh1, rh2); 0109 syncY(rh1, rh3); 0110 syncY(rh2, rh3); 0111 } 0112 void ResizeOverlay::syncX(ResizeHandle *rh1, ResizeHandle *rh2) 0113 { 0114 if (!rh1 || !rh2) 0115 return; 0116 connect(rh1, &ResizeHandle::rhMovedByX, rh2, &ResizeHandle::slotMoveByX); 0117 connect(rh2, &ResizeHandle::rhMovedByX, rh1, &ResizeHandle::slotMoveByX); 0118 } 0119 void ResizeOverlay::syncY(ResizeHandle *rh1, ResizeHandle *rh2) 0120 { 0121 if (!rh1 || !rh2) 0122 return; 0123 connect(rh1, &ResizeHandle::rhMovedByY, rh2, &ResizeHandle::slotMoveByY); 0124 connect(rh2, &ResizeHandle::rhMovedByY, rh1, &ResizeHandle::slotMoveByY); 0125 } 0126 // END class ResizeOverlay 0127 0128 // BEGIN class MechanicsItemOverlay 0129 MechanicsItemOverlay::MechanicsItemOverlay(MechanicsItem *parent) 0130 : ResizeOverlay(parent) 0131 { 0132 p_mechanicsItem = parent; 0133 connect(parent, &MechanicsItem::moved, this, &MechanicsItemOverlay::slotUpdateResizeHandles); 0134 connect(parent, &MechanicsItem::resized, this, &MechanicsItemOverlay::slotUpdateResizeHandles); 0135 0136 m_tl = createResizeHandle(ResizeHandle::rhp_topLeft, ResizeHandle::dt_resize_backwardsDiagonal); 0137 m_tm = createResizeHandle(ResizeHandle::rhp_topMiddle, ResizeHandle::dt_resize_vertical); 0138 m_tr = createResizeHandle(ResizeHandle::rhp_topRight, ResizeHandle::dt_resize_forwardsDiagonal); 0139 m_mr = createResizeHandle(ResizeHandle::rhp_middleRight, ResizeHandle::dt_resize_horizontal); 0140 m_br = createResizeHandle(ResizeHandle::rhp_bottomRight, ResizeHandle::dt_resize_backwardsDiagonal); 0141 m_bm = createResizeHandle(ResizeHandle::rhp_bottomMiddle, ResizeHandle::dt_resize_vertical); 0142 m_bl = createResizeHandle(ResizeHandle::rhp_bottomLeft, ResizeHandle::dt_resize_forwardsDiagonal); 0143 m_ml = createResizeHandle(ResizeHandle::rhp_middleLeft, ResizeHandle::dt_resize_horizontal); 0144 m_mm = createResizeHandle(ResizeHandle::rhp_center, ResizeHandle::dt_point_crosshair); 0145 0146 slotUpdateResizeHandles(); 0147 } 0148 0149 MechanicsItemOverlay::~MechanicsItemOverlay() 0150 { 0151 } 0152 0153 void MechanicsItemOverlay::slotUpdateResizeHandles() 0154 { 0155 const PositionInfo absPos = p_mechanicsItem->absolutePosition(); 0156 const QRect sizeRect = p_mechanicsItem->sizeRect(); 0157 0158 QPolygon pa(9); 0159 pa[0] = sizeRect.topLeft(); 0160 pa[2] = sizeRect.topRight(); 0161 pa[1] = (pa[0] + pa[2]) / 2; 0162 pa[4] = sizeRect.bottomRight(); 0163 pa[3] = (pa[2] + pa[4]) / 2; 0164 pa[6] = sizeRect.bottomLeft(); 0165 pa[5] = (pa[4] + pa[6]) / 2; 0166 pa[7] = (pa[6] + pa[0]) / 2; 0167 pa[8] = QPoint(0, 0); 0168 0169 QTransform m; 0170 m.rotate(absPos.angle() * DPR); 0171 0172 pa = m.map(pa); 0173 0174 m_tl->move(absPos.x() + pa[0].x(), absPos.y() + pa[0].y()); 0175 m_tm->move(absPos.x() + pa[1].x(), absPos.y() + pa[1].y()); 0176 m_tr->move(absPos.x() + pa[2].x(), absPos.y() + pa[2].y()); 0177 m_mr->move(absPos.x() + pa[3].x(), absPos.y() + pa[3].y()); 0178 m_br->move(absPos.x() + pa[4].x(), absPos.y() + pa[4].y()); 0179 m_bm->move(absPos.x() + pa[5].x(), absPos.y() + pa[5].y()); 0180 m_bl->move(absPos.x() + pa[6].x(), absPos.y() + pa[6].y()); 0181 m_ml->move(absPos.x() + pa[7].x(), absPos.y() + pa[7].y()); 0182 m_mm->move(absPos.x() + pa[8].x(), absPos.y() + pa[8].y()); 0183 } 0184 0185 void MechanicsItemOverlay::slotResizeHandleMoved(int id, double dx, double dy) 0186 { 0187 Q_UNUSED(id); 0188 Q_UNUSED(dx); 0189 Q_UNUSED(dy); 0190 0191 switch (id) { 0192 case ResizeHandle::rhp_topLeft: 0193 break; 0194 case ResizeHandle::rhp_topMiddle: 0195 break; 0196 case ResizeHandle::rhp_topRight: 0197 break; 0198 case ResizeHandle::rhp_middleRight: 0199 break; 0200 case ResizeHandle::rhp_bottomRight: 0201 break; 0202 case ResizeHandle::rhp_bottomMiddle: 0203 break; 0204 case ResizeHandle::rhp_bottomLeft: 0205 break; 0206 case ResizeHandle::rhp_middleLeft: 0207 break; 0208 case ResizeHandle::rhp_center: 0209 break; 0210 default: 0211 qCCritical(KTL_LOG) << "Unknown resize handle id " << id; 0212 break; 0213 } 0214 } 0215 // END class MechanicsItemOverlay 0216 0217 // BEGIN class RectangularOverlay 0218 RectangularOverlay::RectangularOverlay(Item *parent, int xsnap, int ysnap) 0219 : ResizeOverlay(parent) 0220 { 0221 connect(parent, &Item::resized, this, &RectangularOverlay::slotUpdateResizeHandles); 0222 connect(parent, &Item::movedBy, this, &RectangularOverlay::slotMoveAllResizeHandles); 0223 0224 m_tl = createResizeHandle(ResizeHandle::rhp_topLeft, ResizeHandle::dt_resize_backwardsDiagonal, xsnap, ysnap); 0225 m_tm = createResizeHandle(ResizeHandle::rhp_topMiddle, ResizeHandle::dt_resize_vertical, xsnap, ysnap); 0226 m_tr = createResizeHandle(ResizeHandle::rhp_topRight, ResizeHandle::dt_resize_forwardsDiagonal, xsnap, ysnap); 0227 m_mr = createResizeHandle(ResizeHandle::rhp_middleRight, ResizeHandle::dt_resize_horizontal, xsnap, ysnap); 0228 m_br = createResizeHandle(ResizeHandle::rhp_bottomRight, ResizeHandle::dt_resize_backwardsDiagonal, xsnap, ysnap); 0229 m_bm = createResizeHandle(ResizeHandle::rhp_bottomMiddle, ResizeHandle::dt_resize_vertical, xsnap, ysnap); 0230 m_bl = createResizeHandle(ResizeHandle::rhp_bottomLeft, ResizeHandle::dt_resize_forwardsDiagonal, xsnap, ysnap); 0231 m_ml = createResizeHandle(ResizeHandle::rhp_middleLeft, ResizeHandle::dt_resize_horizontal, xsnap, ysnap); 0232 0233 syncX(m_tl, m_ml, m_bl); 0234 syncX(m_tr, m_mr, m_br); 0235 syncY(m_tl, m_tm, m_tr); 0236 syncY(m_bl, m_bm, m_br); 0237 0238 slotUpdateResizeHandles(); 0239 } 0240 0241 void RectangularOverlay::removeTopMiddle() 0242 { 0243 if (!m_tm) 0244 return; 0245 removeResizeHandle(m_tm->id()); 0246 m_tm = nullptr; 0247 } 0248 0249 void RectangularOverlay::removeBotMiddle() 0250 { 0251 if (!m_bm) 0252 return; 0253 removeResizeHandle(m_bm->id()); 0254 m_bm = nullptr; 0255 } 0256 0257 void RectangularOverlay::slotUpdateResizeHandles() 0258 { 0259 const QRect sizeRect = p_item->sizeRect(); 0260 0261 int x1 = sizeRect.left() + int(p_item->x()); 0262 int x2 = x1 + sizeRect.width(); 0263 0264 int y1 = sizeRect.top() + int(p_item->y()); 0265 int y2 = y1 + sizeRect.height(); 0266 0267 m_tl->move(x1, y1); 0268 if (m_tm) 0269 m_tm->move((x1 + x2) / 2, y1); 0270 m_tr->move(x2, y1); 0271 m_mr->move(x2, (y1 + y2) / 2); 0272 m_br->move(x2, y2); 0273 if (m_bm) 0274 m_bm->move((x1 + x2) / 2, y2); 0275 m_bl->move(x1, y2); 0276 m_ml->move(x1, (y1 + y2) / 2); 0277 } 0278 0279 bool RectangularOverlay::isValidXPos(ResizeHandle *rh) 0280 { 0281 Q_UNUSED(rh); 0282 bool ok; 0283 getSizeRect(nullptr, &ok, nullptr); 0284 return ok; 0285 } 0286 0287 bool RectangularOverlay::isValidYPos(ResizeHandle *rh) 0288 { 0289 Q_UNUSED(rh); 0290 bool ok; 0291 getSizeRect(nullptr, nullptr, &ok); 0292 return ok; 0293 } 0294 0295 void RectangularOverlay::slotResizeHandleMoved(int id, double dx, double dy) 0296 { 0297 Q_UNUSED(id); 0298 Q_UNUSED(dx); 0299 Q_UNUSED(dy); 0300 0301 bool ok; 0302 QRect sizeRect = getSizeRect(&ok); 0303 if (!ok) 0304 return; 0305 0306 p_item->setSize(sizeRect); 0307 slotUpdateResizeHandles(); 0308 } 0309 0310 QRect RectangularOverlay::getSizeRect(bool *ok, bool *widthOk, bool *heightOk) const 0311 { 0312 bool t1, t2, t3; 0313 if (!ok) 0314 ok = &t1; 0315 if (!widthOk) 0316 widthOk = &t2; 0317 if (!heightOk) 0318 heightOk = &t3; 0319 0320 int width = int(m_br->x() - m_tl->x()); 0321 int height = int(m_br->y() - m_tl->y()); 0322 0323 QRect sizeRect(int(m_tl->x() - p_item->x()), int(m_tl->y() - p_item->y()), width, height); 0324 0325 *widthOk = sizeRect.width() >= p_item->minimumSize().width(); 0326 *heightOk = sizeRect.height() >= p_item->minimumSize().height(); 0327 *ok = *widthOk && *heightOk; 0328 0329 return sizeRect; 0330 } 0331 // END class RectangularOverlay 0332 0333 // BEGIN class LineOverlay 0334 LineOverlay::LineOverlay(Item *parent) 0335 : ResizeOverlay(parent) 0336 { 0337 connect(parent, &Item::resized, this, &LineOverlay::slotUpdateResizeHandles); 0338 connect(parent, &Item::movedBy, this, &LineOverlay::slotMoveAllResizeHandles); 0339 0340 m_pStart = createResizeHandle(ResizeHandle::rhp_start, ResizeHandle::dt_point_rect); 0341 m_pEnd = createResizeHandle(ResizeHandle::rhp_end, ResizeHandle::dt_point_rect); 0342 0343 slotUpdateResizeHandles(); 0344 } 0345 0346 QPoint LineOverlay::startPoint() const 0347 { 0348 return QPoint(int(m_pStart->x()), int(m_pStart->y())); 0349 } 0350 QPoint LineOverlay::endPoint() const 0351 { 0352 return QPoint(int(m_pEnd->x()), int(m_pEnd->y())); 0353 } 0354 0355 void LineOverlay::slotUpdateResizeHandles() 0356 { 0357 int _x = int(p_item->x() + p_item->offsetX()); 0358 int _y = int(p_item->y() + p_item->offsetY()); 0359 0360 m_pStart->move(_x, _y); 0361 m_pEnd->move(_x + p_item->width(), _y + p_item->height()); 0362 } 0363 0364 void LineOverlay::slotResizeHandleMoved(int id, double dx, double dy) 0365 { 0366 Q_UNUSED(id); 0367 Q_UNUSED(dx); 0368 Q_UNUSED(dy); 0369 0370 p_item->setSize(int(m_pStart->x() - p_item->x()), int(m_pStart->y() - p_item->y()), int(m_pEnd->x() - m_pStart->x()), int(m_pEnd->y() - m_pStart->y())); 0371 } 0372 // END class LineOverlay 0373 0374 // BEGIN class ResizeHandle 0375 ResizeHandle::ResizeHandle(ResizeOverlay *resizeOverlay, int id, DrawType drawType, int xsnap, int ysnap) 0376 : // QObject(), 0377 KtlQCanvasRectangle(0, 0, 13, 13, resizeOverlay->parentItem()->canvas()) 0378 { 0379 p_resizeOverlay = resizeOverlay; 0380 m_drawType = drawType; 0381 m_id = id; 0382 b_hover = false; 0383 m_xsnap = xsnap; 0384 m_ysnap = ysnap; 0385 setZ(ItemDocument::Z::ResizeHandle); 0386 } 0387 0388 ResizeHandle::~ResizeHandle() 0389 { 0390 hide(); 0391 } 0392 0393 void ResizeHandle::setHover(bool hover) 0394 { 0395 if (b_hover == hover) 0396 return; 0397 0398 b_hover = hover; 0399 canvas()->setChanged(QRect(int(x()) - 8, int(y()) - 8, 15, 15)); 0400 } 0401 0402 QPolygon ResizeHandle::areaPoints() const 0403 { 0404 // QPolygon pa = KtlQCanvasRectangle::areaPoints(); 0405 // pa.translate( -7, -7 ); 0406 // return pa; 0407 return QPolygon(QRect(int(x()) - 8, int(y()) - 8, 15, 15)); 0408 } 0409 0410 void ResizeHandle::moveRH(double _x, double _y) 0411 { 0412 double dx = int((_x - 4) / m_xsnap) * m_xsnap + 4 - x(); 0413 double dy = int((_y - 4) / m_ysnap) * m_ysnap + 4 - y(); 0414 if ((dx == 0) && (dy == 0)) 0415 return; 0416 0417 // BEGIN Move and check 0418 moveBy(dx, dy); 0419 if (dx != 0) 0420 emit rhMovedByX(dx); 0421 if (dy != 0) 0422 emit rhMovedByY(dy); 0423 0424 bool xOk = p_resizeOverlay->isValidXPos(this); 0425 bool yOk = p_resizeOverlay->isValidYPos(this); 0426 0427 if (!xOk) { 0428 moveBy(-dx, 0); 0429 emit rhMovedByX(-dx); 0430 dx = 0; 0431 } 0432 if (!yOk) { 0433 moveBy(0, -dy); 0434 emit rhMovedByY(-dy); 0435 dy = 0; 0436 } 0437 0438 if (!xOk && !yOk) 0439 return; 0440 // END Move and check 0441 0442 emit rhMovedBy(id(), dx, dy); 0443 } 0444 0445 void ResizeHandle::setDrawType(DrawType drawType) 0446 { 0447 m_drawType = drawType; 0448 canvas()->setChanged(boundingRect()); 0449 } 0450 0451 void ResizeHandle::drawShape(QPainter &p) 0452 { 0453 p.drawPixmap(rect().topLeft() - QPoint(7, 7), handlePixmap(m_drawType, b_hover)); 0454 } 0455 0456 const QPixmap &ResizeHandle::handlePixmap(DrawType drawType, bool hover) 0457 { 0458 const char *resize_forwardsDiagonal_hover_xpm[] = {"13 13 3 1", 0459 " c None", 0460 ". c #000000", 0461 "+ c #8EA5D0", 0462 " ", 0463 " ....... ", 0464 " ..+++. ", 0465 " .++++. ", 0466 " .+++++. ", 0467 " . .+++++.. ", 0468 " ...+++++... ", 0469 " ..+++++. . ", 0470 " .+++++. ", 0471 " .++++. ", 0472 " .+++.. ", 0473 " ....... ", 0474 " "}; 0475 static QPixmap pixmap_forwardsDiagonal_hover(resize_forwardsDiagonal_hover_xpm); 0476 0477 const char *resize_forwardsDiagonal_nohover_xpm[] = {"13 13 2 1", 0478 " c None", 0479 ". c #000000", 0480 " ", 0481 " ....... ", 0482 " ...... ", 0483 " ...... ", 0484 " ....... ", 0485 " . ........ ", 0486 " ........... ", 0487 " ........ . ", 0488 " ....... ", 0489 " ...... ", 0490 " ...... ", 0491 " ....... ", 0492 " "}; 0493 static QPixmap pixmap_forwardsDiagonal_nohover(resize_forwardsDiagonal_nohover_xpm); 0494 0495 const char *resize_backwardsDiagonal_hover_xpm[] = {"13 13 3 1", 0496 " c None", 0497 ". c #000000", 0498 "+ c #8EA5D0", 0499 " ", 0500 " ....... ", 0501 " .+++.. ", 0502 " .++++. ", 0503 " .+++++. ", 0504 " ..+++++. . ", 0505 " ...+++++... ", 0506 " . .+++++.. ", 0507 " .+++++. ", 0508 " .++++. ", 0509 " ..+++. ", 0510 " ....... ", 0511 " "}; 0512 static QPixmap pixmap_backwardsDiagonal_hover(resize_backwardsDiagonal_hover_xpm); 0513 0514 const char *resize_backwardsDiagonal_nohover_xpm[] = {"13 13 2 1", 0515 " c None", 0516 ". c #000000", 0517 " ", 0518 " ....... ", 0519 " ...... ", 0520 " ...... ", 0521 " ....... ", 0522 " ........ . ", 0523 " ........... ", 0524 " . ........ ", 0525 " ....... ", 0526 " ...... ", 0527 " ...... ", 0528 " ....... ", 0529 " "}; 0530 static QPixmap pixmap_backwardsDiagonal_nohover(resize_backwardsDiagonal_nohover_xpm); 0531 0532 const char *resize_vertical_hover_xpm[] = {"13 13 3 1", 0533 " c None", 0534 ". c #000000", 0535 "+ c #8EA5D0", 0536 " . ", 0537 " ... ", 0538 " ..+.. ", 0539 " ..+++.. ", 0540 " ..+++++.. ", 0541 " .+++. ", 0542 " .+++. ", 0543 " .+++. ", 0544 " ..+++++.. ", 0545 " ..+++.. ", 0546 " ..+.. ", 0547 " ... ", 0548 " . "}; 0549 static QPixmap pixmap_vertical_hover(resize_vertical_hover_xpm); 0550 0551 const char *resize_vertical_nohover_xpm[] = {"13 13 2 1", 0552 " c None", 0553 ". c #000000", 0554 " . ", 0555 " ... ", 0556 " ..... ", 0557 " ....... ", 0558 " ......... ", 0559 " ..... ", 0560 " ..... ", 0561 " ..... ", 0562 " ......... ", 0563 " ....... ", 0564 " ..... ", 0565 " ... ", 0566 " . "}; 0567 static QPixmap pixmap_vertical_nohover(resize_vertical_nohover_xpm); 0568 0569 const char *resize_horizontal_hover_xpm[] = {"13 13 3 1", 0570 " c None", 0571 ". c #000000", 0572 "+ c #8EA5D0", 0573 " ", 0574 " ", 0575 " . . ", 0576 " .. .. ", 0577 " ..+...+.. ", 0578 " ..+++++++.. ", 0579 "..+++++++++..", 0580 " ..+++++++.. ", 0581 " ..+...+.. ", 0582 " .. .. ", 0583 " . . ", 0584 " ", 0585 " "}; 0586 static QPixmap pixmap_horizontal_hover(resize_horizontal_hover_xpm); 0587 0588 const char *resize_horizontal_nohover_xpm[] = {"13 13 2 1", 0589 " c None", 0590 ". c #000000", 0591 " ", 0592 " ", 0593 " . . ", 0594 " .. .. ", 0595 " ......... ", 0596 " ........... ", 0597 ".............", 0598 " ........... ", 0599 " ......... ", 0600 " .. .. ", 0601 " . . ", 0602 " ", 0603 " "}; 0604 static QPixmap pixmap_horizontal_nohover(resize_horizontal_nohover_xpm); 0605 0606 const char *point_rect_hover_xpm[] = {"13 13 3 1", 0607 " c None", 0608 ". c #000000", 0609 "+ c #8EA5D0", 0610 " ", 0611 " ", 0612 " ", 0613 " ", 0614 " ", 0615 " ..... ", 0616 " .+++. ", 0617 " .+++. ", 0618 " .+++. ", 0619 " ..... ", 0620 " ", 0621 " ", 0622 " "}; 0623 static QPixmap pixmap_point_rect_hover(point_rect_hover_xpm); 0624 0625 const char *point_rect_nohover_xpm[] = {"13 13 3 1", 0626 " c None", 0627 ". c #000000", 0628 "+ c #FFFFFF", 0629 " ", 0630 " ", 0631 " ", 0632 " ", 0633 " ", 0634 " ..... ", 0635 " .+++. ", 0636 " .+++. ", 0637 " .+++. ", 0638 " ..... ", 0639 " ", 0640 " ", 0641 " "}; 0642 static QPixmap pixmap_point_rect_nohover(point_rect_nohover_xpm); 0643 0644 if (hover) { 0645 switch (drawType) { 0646 case ResizeHandle::dt_resize_forwardsDiagonal: 0647 return pixmap_forwardsDiagonal_hover; 0648 case ResizeHandle::dt_resize_backwardsDiagonal: 0649 return pixmap_backwardsDiagonal_hover; 0650 case ResizeHandle::dt_resize_vertical: 0651 return pixmap_vertical_hover; 0652 case ResizeHandle::dt_resize_horizontal: 0653 return pixmap_horizontal_hover; 0654 case ResizeHandle::dt_point_rect: 0655 return pixmap_point_rect_hover; 0656 0657 case ResizeHandle::dt_point_crosshair: 0658 case ResizeHandle::dt_rotate_topLeft: 0659 case ResizeHandle::dt_rotate_topRight: 0660 case ResizeHandle::dt_rotate_bottomRight: 0661 case ResizeHandle::dt_rotate_bottomLeft: 0662 qCWarning(KTL_LOG) << "ResizeHandle of type " << drawType << " does not have an image."; 0663 } 0664 } else { 0665 switch (drawType) { 0666 case ResizeHandle::dt_resize_forwardsDiagonal: 0667 return pixmap_forwardsDiagonal_nohover; 0668 case ResizeHandle::dt_resize_backwardsDiagonal: 0669 return pixmap_backwardsDiagonal_nohover; 0670 case ResizeHandle::dt_resize_vertical: 0671 return pixmap_vertical_nohover; 0672 case ResizeHandle::dt_resize_horizontal: 0673 return pixmap_horizontal_nohover; 0674 case ResizeHandle::dt_point_rect: 0675 return pixmap_point_rect_nohover; 0676 0677 case ResizeHandle::dt_point_crosshair: 0678 case ResizeHandle::dt_rotate_topLeft: 0679 case ResizeHandle::dt_rotate_topRight: 0680 case ResizeHandle::dt_rotate_bottomRight: 0681 case ResizeHandle::dt_rotate_bottomLeft: 0682 qCWarning(KTL_LOG) << "ResizeHandle of type " << drawType << " does not have an image."; 0683 } 0684 } 0685 0686 static QPixmap blank; 0687 return blank; 0688 } 0689 // END class ResizeHandle 0690 0691 #include "moc_resizeoverlay.cpp"