Engauge Digitizer
2
Tutorial
TutorialStateAbstractBase.cpp
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5
******************************************************************************************************/
6
7
#include <QGraphicsPixmapItem>
8
#include <QGraphicsScene>
9
#include <QGraphicsTextItem>
10
#include "
TutorialDlg.h
"
11
#include "
TutorialStateAbstractBase.h
"
12
#include "
TutorialStateContext.h
"
13
14
//const int DELTA_FONT_SIZE = 2;
15
const
int
TITLE_PADDING
= 5;
16
const
double
Z_TITLE
= 2.0;
// On top of everything else
17
18
TutorialStateAbstractBase::TutorialStateAbstractBase
(
TutorialStateContext
&context) :
19
m_context (context)
20
{
21
}
22
23
TutorialStateAbstractBase::~TutorialStateAbstractBase
()
24
{
25
}
26
27
int
TutorialStateAbstractBase::buttonMargin
()
const
28
{
29
return
10;
30
}
31
32
TutorialStateContext
&
TutorialStateAbstractBase::context
()
33
{
34
return
m_context;
35
}
36
37
QGraphicsPixmapItem *
TutorialStateAbstractBase::createPixmapItem
(
const
QString &resource,
38
const
QPoint &pos)
39
{
40
QGraphicsPixmapItem *item =
new
QGraphicsPixmapItem (QPixmap (resource));
41
item->setPos (pos);
42
context
().
tutorialDlg
().
scene
().addItem (item);
43
44
return
item;
45
}
46
47
QGraphicsTextItem *
TutorialStateAbstractBase::createTextItem
(
const
QString &text,
48
const
QPoint &pos)
49
{
50
QGraphicsTextItem *item =
new
QGraphicsTextItem (text);
51
item->setPos (pos);
52
context
().
tutorialDlg
().
scene
().addItem (item);
53
54
return
item;
55
}
56
57
QGraphicsTextItem *
TutorialStateAbstractBase::createTitle
(
const
QString &text)
58
{
59
QSize backgroundSize =
context
().
tutorialDlg
().
backgroundSize
();
60
61
QGraphicsTextItem *item =
new
QGraphicsTextItem (text);
62
item->setZValue(
Z_TITLE
);
63
item->setPos (backgroundSize.width() / 2.0 - item->boundingRect().width() / 2.0,
64
TITLE_PADDING
);
65
context
().
tutorialDlg
().
scene
().addItem (item);
66
67
// Highlight the text
68
QFont font = item->font();
69
font.setBold (
true
);
70
// font.setPixelSize (font.pixelSize() + DELTA_FONT_SIZE);
71
item->setFont (font);
72
return
item;
73
}
TutorialStateAbstractBase::context
TutorialStateContext & context()
Context class for the tutorial state machine.
Definition:
TutorialStateAbstractBase.cpp:31
TutorialStateContext
Context class for tutorial state machine.
Definition:
TutorialStateContext.h:19
TutorialStateAbstractBase.h
TutorialStateAbstractBase::createTextItem
QGraphicsTextItem * createTextItem(const QString &text, const QPoint &pos)
Factory method for text items.
Definition:
TutorialStateAbstractBase.cpp:46
TITLE_PADDING
const int TITLE_PADDING
Definition:
TutorialStateAbstractBase.cpp:14
TutorialDlg::scene
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition:
TutorialDlg.cpp:76
Z_TITLE
const double Z_TITLE
Definition:
TutorialStateAbstractBase.cpp:15
TutorialStateAbstractBase::buttonMargin
int buttonMargin() const
Buttons are placed up against bottom side, and left or right side, separated by this margin.
Definition:
TutorialStateAbstractBase.cpp:26
TutorialStateAbstractBase::~TutorialStateAbstractBase
virtual ~TutorialStateAbstractBase()
Definition:
TutorialStateAbstractBase.cpp:22
TutorialStateAbstractBase::createTitle
QGraphicsTextItem * createTitle(const QString &text)
Factory method for title items.
Definition:
TutorialStateAbstractBase.cpp:56
TutorialStateContext.h
TutorialDlg::backgroundSize
QSize backgroundSize() const
Make geometry available for layout.
Definition:
TutorialDlg.cpp:44
TutorialDlg.h
TutorialStateAbstractBase::createPixmapItem
QGraphicsPixmapItem * createPixmapItem(const QString &resource, const QPoint &pos)
Factory method for pixmap items.
Definition:
TutorialStateAbstractBase.cpp:36
TutorialStateAbstractBase::TutorialStateAbstractBase
TutorialStateAbstractBase(TutorialStateContext &context)
Single constructor.
Definition:
TutorialStateAbstractBase.cpp:17
TutorialStateContext::tutorialDlg
TutorialDlg & tutorialDlg()
Access to tutorial dialogs and its scene.
Definition:
TutorialStateContext.cpp:109
Generated on Sat Jan 4 2020 12:00:00 for Engauge Digitizer by
1.8.16