ManaPlus
src
gui
widgets
tabs
setup_touch.cpp
Go to the documentation of this file.
1
/*
2
* The ManaPlus Client
3
* Copyright (C) 2012-2019 The ManaPlus Developers
4
* Copyright (C) 2019-2021 Andrei Karas
5
*
6
* This file is part of The ManaPlus Client.
7
*
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#include "
gui/widgets/tabs/setup_touch.h
"
23
24
#include "
gui/models/touchactionmodel.h
"
25
26
#include "
gui/widgets/containerplacer.h
"
27
#include "
gui/widgets/layouthelper.h
"
28
#include "
gui/widgets/setuptouchitem.h
"
29
#include "
gui/widgets/scrollarea.h
"
30
31
#include "
utils/delete2.h
"
32
#include "
utils/gettext.h
"
33
#include "
utils/stringutils.h
"
34
35
#include "
debug.h
"
36
37
static
const
int
sizeListSize
= 4;
38
39
static
const
char
*
const
sizeList
[] =
40
{
41
// TRANSLATORS: onscreen button size
42
N_
(
"Small"
),
43
// TRANSLATORS: onscreen button size
44
N_
(
"Normal"
),
45
// TRANSLATORS: onscreen button size
46
N_
(
"Medium"
),
47
// TRANSLATORS: onscreen button size
48
N_
(
"Large"
)
49
};
50
51
static
const
int
formatListSize
= 6;
52
53
static
const
char
*
const
formatList
[] =
54
{
55
"2x1"
,
56
"2x2"
,
57
"3x3"
,
58
"4x2"
,
59
"4x3"
,
60
"3x2"
61
};
62
63
Setup_Touch::Setup_Touch
(
const
Widget2
*
const
widget) :
64
SetupTabScroll
(widget),
65
mSizeList(
new
NamesModel
),
66
mFormatList(
new
NamesModel
),
67
mActionsList(
new
TouchActionsModel
)
68
{
69
// TRANSLATORS: touch settings tab
70
setName
(
_
(
"Touch"
));
71
72
LayoutHelper
h(
this
);
73
ContainerPlacer
place = h.
getPlacer
(0, 0);
74
place(0, 0,
mScroll
, 10, 10);
75
mSizeList
->
fillFromArray
(&
sizeList
[0],
sizeListSize
);
76
mFormatList
->
fillFromArray
(&
formatList
[0],
formatListSize
);
77
78
// TRANSLATORS: settings option
79
new
SetupItemLabel
(
_
(
"Onscreen keyboard"
),
""
,
this
,
80
Separator_true
);
81
82
// TRANSLATORS: settings option
83
new
SetupItemCheckBox
(
_
(
"Show onscreen keyboard icon"
),
""
,
84
"showScreenKeyboard"
,
this
,
"showScreenKeyboardEvent"
,
85
MainConfig_true
);
86
87
// TRANSLATORS: settings option
88
new
SetupActionDropDown
(
_
(
"Keyboard icon action"
),
""
,
89
"screenActionKeyboard"
,
this
,
"screenActionKeyboardEvent"
,
90
mActionsList
, 250,
MainConfig_true
);
91
92
93
// TRANSLATORS: settings group
94
new
SetupItemLabel
(
_
(
"Onscreen joystick"
),
""
,
this
,
95
Separator_true
);
96
97
// TRANSLATORS: settings option
98
new
SetupItemCheckBox
(
_
(
"Show onscreen joystick"
),
""
,
99
"showScreenJoystick"
,
this
,
"showScreenJoystickEvent"
,
100
MainConfig_true
);
101
102
// TRANSLATORS: settings option
103
new
SetupItemDropDown
(
_
(
"Joystick size"
),
""
,
"screenJoystickSize"
,
this
,
104
"screenJoystickEvent"
,
mSizeList
, 100,
105
MainConfig_true
);
106
107
108
// TRANSLATORS: settings group
109
new
SetupItemLabel
(
_
(
"Onscreen buttons"
),
""
,
this
,
110
Separator_true
);
111
112
// TRANSLATORS: settings option
113
new
SetupItemCheckBox
(
_
(
"Show onscreen buttons"
),
""
,
114
"showScreenButtons"
,
this
,
"showScreenButtonsEvent"
,
115
MainConfig_true
);
116
117
// TRANSLATORS: settings option
118
new
SetupItemDropDown
(
_
(
"Buttons format"
),
""
,
"screenButtonsFormat"
,
this
,
119
"screenButtonsFormatEvent"
,
mFormatList
, 100,
120
MainConfig_true
);
121
122
// TRANSLATORS: settings option
123
new
SetupItemDropDown
(
_
(
"Buttons size"
),
""
,
"screenButtonsSize"
,
this
,
124
"screenButtonsSizeEvent"
,
mSizeList
, 100,
125
MainConfig_true
);
126
127
for
(
unsigned
int
f = 0; f < 12; f ++)
128
{
129
std::string key =
strprintf
(
"screenActionButton%u"
, f);
130
std::string
event
=
strprintf
(
"screenActionButton%uEvent"
, f);
131
// TRANSLATORS: settings option
132
new
SetupActionDropDown
(
strprintf
(
_
(
"Button %u action"
), f + 1),
""
,
133
key,
this
, event,
mActionsList
, 250,
MainConfig_true
);
134
}
135
136
setDimension
(
Rect
(0, 0, 550, 350));
137
}
138
139
Setup_Touch::~Setup_Touch
()
140
{
141
delete2
(
mSizeList
)
142
delete2
(
mFormatList
)
143
delete2
(
mActionsList
)
144
}
ContainerPlacer
Definition:
containerplacer.h:37
LayoutHelper
Definition:
layouthelper.h:40
LayoutHelper::getPlacer
ContainerPlacer getPlacer(const int x, const int y)
Definition:
layouthelper.cpp:60
NamesModel
Definition:
namesmodel.h:32
NamesModel::fillFromArray
void fillFromArray(const char *const *const arr, const std::size_t size)
Definition:
namesmodel.cpp:52
Rect
Definition:
rect.h:74
SetupActionDropDown
Definition:
setuptouchitem.h:30
SetupItemCheckBox
Definition:
setupitem.h:155
SetupItemDropDown
Definition:
setupitem.h:313
SetupItemLabel
Definition:
setupitem.h:286
SetupTabScroll
Definition:
setuptabscroll.h:34
SetupTabScroll::mScroll
ScrollArea * mScroll
Definition:
setuptabscroll.h:76
SetupTab::setName
void setName(const std::string &name)
Definition:
setuptab.h:68
Setup_Touch::mSizeList
NamesModel * mSizeList
Definition:
setup_touch.h:40
Setup_Touch::mFormatList
NamesModel * mFormatList
Definition:
setup_touch.h:41
Setup_Touch::Setup_Touch
Setup_Touch(const Widget2 *const widget)
Definition:
setup_touch.cpp:63
Setup_Touch::~Setup_Touch
~Setup_Touch()
Definition:
setup_touch.cpp:139
Setup_Touch::mActionsList
TouchActionsModel * mActionsList
Definition:
setup_touch.h:42
TouchActionsModel
Definition:
touchactionmodel.h:32
Widget2
Definition:
widget2.h:37
Widget::setDimension
void setDimension(const Rect &dimension)
Definition:
widget.cpp:169
containerplacer.h
debug.h
new
#define new
Definition:
debug_new.h:147
delete2.h
delete2
#define delete2(var)
Definition:
delete2.h:25
gettext.h
N_
#define N_(s)
Definition:
gettext.h:36
_
#define _(s)
Definition:
gettext.h:35
layouthelper.h
MainConfig_true
const bool MainConfig_true
Definition:
mainconfig.h:30
scrollarea.h
Separator_true
const bool Separator_true
Definition:
separator.h:30
formatList
static const char *const formatList[]
Definition:
setup_touch.cpp:53
formatListSize
static const int formatListSize
Definition:
setup_touch.cpp:51
sizeListSize
static const int sizeListSize
Definition:
setup_touch.cpp:37
sizeList
static const char *const sizeList[]
Definition:
setup_touch.cpp:39
setup_touch.h
setuptouchitem.h
strprintf
std::string strprintf(const char *const format,...)
Definition:
stringutils.cpp:100
stringutils.h
touchactionmodel.h
Generated on Wed Mar 17 2021 19:19:07 for ManaPlus by
1.9.1