28 #ifndef _BIBLIOTEQ_GRAPHICSITEMPIXMAP_H_
29 #define _BIBLIOTEQ_GRAPHICSITEMPIXMAP_H_
31 static void qt_graphicsItem_highlightSelected
34 const QStyleOptionGraphicsItem *option)
36 if(!item || !option || !painter)
39 const auto &marect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
41 if(qFuzzyIsNull(qMax(marect.height(), marect.width())))
44 const auto &mbrect = painter->transform().mapRect(item->boundingRect());
46 if(qMin(mbrect.height(), mbrect.width()) < qreal(1.0))
49 const QColor bgcolor(70, 130, 180);
50 const qreal pad = 0.0;
51 const qreal penWidth = 2.5;
53 painter->setBrush(Qt::NoBrush);
54 painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));
55 painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
62 QGraphicsPixmapItem(pixmap, parent)
70 void paint(QPainter *painter,
71 const QStyleOptionGraphicsItem *option,
72 QWidget *widget =
nullptr)
76 if(!option || !painter)
79 painter->setRenderHint(QPainter::SmoothPixmapTransform,
true);
81 auto exposed_rect(option->exposedRect.adjusted(-1, -1, 1, 1));
83 exposed_rect &= QRectF(offset().x(),
88 (exposed_rect, pixmap(), exposed_rect.translated(-offset()));
90 if(option->state & (QStyle::State_HasFocus | QStyle::State_Selected))
91 qt_graphicsItem_highlightSelected(
this, painter, option);
Definition: biblioteq_graphicsitempixmap.h:59