Engauge Digitizer
2
Loading...
Searching...
No Matches
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
}
TutorialDlg.h
Z_TITLE
const double Z_TITLE
Definition
TutorialStateAbstractBase.cpp:16
TITLE_PADDING
const int TITLE_PADDING
Definition
TutorialStateAbstractBase.cpp:15
TutorialStateAbstractBase.h
TutorialStateContext.h
TutorialDlg::scene
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition
TutorialDlg.cpp:76
TutorialDlg::backgroundSize
QSize backgroundSize() const
Make geometry available for layout.
Definition
TutorialDlg.cpp:44
TutorialStateAbstractBase::~TutorialStateAbstractBase
virtual ~TutorialStateAbstractBase()
Definition
TutorialStateAbstractBase.cpp:23
TutorialStateAbstractBase::TutorialStateAbstractBase
TutorialStateAbstractBase(TutorialStateContext &context)
Single constructor.
Definition
TutorialStateAbstractBase.cpp:18
TutorialStateAbstractBase::createTitle
QGraphicsTextItem * createTitle(const QString &text)
Factory method for title items.
Definition
TutorialStateAbstractBase.cpp:57
TutorialStateAbstractBase::createTextItem
QGraphicsTextItem * createTextItem(const QString &text, const QPoint &pos)
Factory method for text items.
Definition
TutorialStateAbstractBase.cpp:47
TutorialStateAbstractBase::context
TutorialStateContext & context()
Context class for the tutorial state machine.
Definition
TutorialStateAbstractBase.cpp:32
TutorialStateAbstractBase::createPixmapItem
QGraphicsPixmapItem * createPixmapItem(const QString &resource, const QPoint &pos)
Factory method for pixmap items.
Definition
TutorialStateAbstractBase.cpp:37
TutorialStateAbstractBase::buttonMargin
int buttonMargin() const
Buttons are placed up against bottom side, and left or right side, separated by this margin.
Definition
TutorialStateAbstractBase.cpp:27
TutorialStateContext
Context class for tutorial state machine.
Definition
TutorialStateContext.h:21
TutorialStateContext::tutorialDlg
TutorialDlg & tutorialDlg()
Access to tutorial dialogs and its scene.
Definition
TutorialStateContext.cpp:109
Generated on
for Engauge Digitizer by
1.14.0