9#include <QGraphicsRectItem>
10#include <QGraphicsScene>
11#include <QGraphicsTextItem>
12#include "TutorialButton.h"
13#include "TutorialButtonRect.h"
14#include "TutorialButtonText.h"
16const int HORIZONTAL_PADDING = 10;
17const int VERTICAL_PADDING = 5;
18const double Z_IN_FRONT = 1;
21 QGraphicsScene &scene)
27TutorialButton::~TutorialButton ()
29 QGraphicsScene *scene = m_rect->scene();
30 scene->removeItem (m_rect);
33void TutorialButton::createRect (QGraphicsScene &scene)
38 m_rect->setPen (QPen (Qt::gray));
39 m_rect->setBrush (QBrush (Qt::white));
40 m_rect->setZValue (Z_IN_FRONT);
41 scene.addItem (m_rect);
44void TutorialButton::createText (
const QString &text)
57 return QSize (m_text->boundingRect().size().width() + 2 * HORIZONTAL_PADDING,
58 m_text->boundingRect().size().height() + 2 * VERTICAL_PADDING);
63 LOG4CPP_INFO_S ((*mainCat)) <<
"TutorialButton::handleTriggered";
72 m_rect->setRect(pos.x(),
74 m_text->boundingRect().width() + 2 * HORIZONTAL_PADDING,
75 m_text->boundingRect().height() + 2 * VERTICAL_PADDING);
78 m_text->setPos (pos.x() + m_rect->boundingRect().width() / 2.0 - m_text->boundingRect().width() / 2.0,
79 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.