9 #include <QGraphicsRectItem>
10 #include <QGraphicsScene>
11 #include <QGraphicsTextItem>
13 #include "TutorialButton.h"
14 #include "TutorialButtonRect.h"
15 #include "TutorialButtonText.h"
17 const int HORIZONTAL_PADDING = 10;
18 const int VERTICAL_PADDING = 5;
19 const double Z_IN_FRONT = 1;
22 QGraphicsScene &scene) :
30 TutorialButton::~TutorialButton ()
32 QGraphicsScene *scene = m_rect->scene();
33 scene->removeItem (m_rect);
39 void TutorialButton::createRect (QGraphicsScene &scene)
44 m_rect->setPen (QPen (Qt::gray));
45 m_rect->setBrush (QBrush (Qt::white));
46 m_rect->setZValue (Z_IN_FRONT);
47 scene.addItem (m_rect);
50 void TutorialButton::createText (
const QString &text)
63 return QSize (qFloor (m_text->boundingRect().size().width() + 2 * HORIZONTAL_PADDING),
64 qFloor (m_text->boundingRect().size().height() + 2 * VERTICAL_PADDING));
69 LOG4CPP_INFO_S ((*mainCat)) <<
"TutorialButton::handleTriggered";
78 m_rect->setRect(pos.x(),
80 m_text->boundingRect().width() + 2 * HORIZONTAL_PADDING,
81 m_text->boundingRect().height() + 2 * VERTICAL_PADDING);
84 m_text->setPos (pos.x() + m_rect->boundingRect().width() / 2.0 - m_text->boundingRect().width() / 2.0,
85 pos.y() + m_rect->boundingRect().height() / 2.0 - m_text->boundingRect().height() / 2.0);
This class customizes QGraphicsTextItem so it performs a callback after a mouse event.