ManaPlus
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 
23 
25 
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);
77 
78  // TRANSLATORS: settings option
79  new SetupItemLabel(_("Onscreen keyboard"), "", this,
81 
82  // TRANSLATORS: settings option
83  new SetupItemCheckBox(_("Show onscreen keyboard icon"), "",
84  "showScreenKeyboard", this, "showScreenKeyboardEvent",
86 
87  // TRANSLATORS: settings option
88  new SetupActionDropDown(_("Keyboard icon action"), "",
89  "screenActionKeyboard", this, "screenActionKeyboardEvent",
91 
92 
93  // TRANSLATORS: settings group
94  new SetupItemLabel(_("Onscreen joystick"), "", this,
96 
97  // TRANSLATORS: settings option
98  new SetupItemCheckBox(_("Show onscreen joystick"), "",
99  "showScreenJoystick", this, "showScreenJoystickEvent",
101 
102  // TRANSLATORS: settings option
103  new SetupItemDropDown(_("Joystick size"), "", "screenJoystickSize", this,
104  "screenJoystickEvent", mSizeList, 100,
106 
107 
108  // TRANSLATORS: settings group
109  new SetupItemLabel(_("Onscreen buttons"), "", this,
111 
112  // TRANSLATORS: settings option
113  new SetupItemCheckBox(_("Show onscreen buttons"), "",
114  "showScreenButtons", this, "showScreenButtonsEvent",
116 
117  // TRANSLATORS: settings option
118  new SetupItemDropDown(_("Buttons format"), "", "screenButtonsFormat", this,
119  "screenButtonsFormatEvent", mFormatList, 100,
121 
122  // TRANSLATORS: settings option
123  new SetupItemDropDown(_("Buttons size"), "", "screenButtonsSize", this,
124  "screenButtonsSizeEvent", mSizeList, 100,
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 
140 {
144 }
ContainerPlacer getPlacer(const int x, const int y)
void fillFromArray(const char *const *const arr, const std::size_t size)
Definition: namesmodel.cpp:52
Definition: rect.h:74
ScrollArea * mScroll
void setName(const std::string &name)
Definition: setuptab.h:68
NamesModel * mSizeList
Definition: setup_touch.h:40
NamesModel * mFormatList
Definition: setup_touch.h:41
Setup_Touch(const Widget2 *const widget)
Definition: setup_touch.cpp:63
TouchActionsModel * mActionsList
Definition: setup_touch.h:42
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
#define new
Definition: debug_new.h:147
#define delete2(var)
Definition: delete2.h:25
#define N_(s)
Definition: gettext.h:36
#define _(s)
Definition: gettext.h:35
const bool MainConfig_true
Definition: mainconfig.h:30
const bool Separator_true
Definition: separator.h:30
static const char *const formatList[]
Definition: setup_touch.cpp:53
static const int formatListSize
Definition: setup_touch.cpp:51
static const int sizeListSize
Definition: setup_touch.cpp:37
static const char *const sizeList[]
Definition: setup_touch.cpp:39
std::string strprintf(const char *const format,...)