mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-05 04:25:19 +02:00
Remove all touch-screen-related code
It didn't work anymore, at all. Touchscreen polling occurred only *after* waiting for a button had completed. So the touchscreen events, if any, would be ignored until the user had pressed a button, possibly firing off another action with that button press and forwarding the touchscreen event to the next interface that got brought up as a result. Reusing this code and fixing it would require far more work than rewriting everything anew with touchscreen devices in mind from the beginning. MtH: Resolved conflicts, mainly from the GMenu2X pointer to reference change I did on 2015-04-21.
This commit is contained in:
parent
16aa3dd999
commit
2a2634b364
@ -9,7 +9,7 @@ gmenu2x_SOURCES = font.cpp cpu.cpp dirdialog.cpp filedialog.cpp \
|
|||||||
menusettingstringbase.cpp \
|
menusettingstringbase.cpp \
|
||||||
messagebox.cpp selector.cpp \
|
messagebox.cpp selector.cpp \
|
||||||
settingsdialog.cpp surfacecollection.cpp surface.cpp \
|
settingsdialog.cpp surfacecollection.cpp surface.cpp \
|
||||||
textdialog.cpp textmanualdialog.cpp touchscreen.cpp translator.cpp \
|
textdialog.cpp textmanualdialog.cpp translator.cpp \
|
||||||
utilities.cpp wallpaperdialog.cpp \
|
utilities.cpp wallpaperdialog.cpp \
|
||||||
browsedialog.cpp buttonbox.cpp dialog.cpp \
|
browsedialog.cpp buttonbox.cpp dialog.cpp \
|
||||||
imageio.cpp powersaver.cpp monitor.cpp mediamonitor.cpp clock.cpp \
|
imageio.cpp powersaver.cpp monitor.cpp mediamonitor.cpp clock.cpp \
|
||||||
@ -24,7 +24,7 @@ noinst_HEADERS = font.h cpu.h dirdialog.h \
|
|||||||
menusettingstringbase.h \
|
menusettingstringbase.h \
|
||||||
messagebox.h selector.h settingsdialog.h \
|
messagebox.h selector.h settingsdialog.h \
|
||||||
surfacecollection.h surface.h textdialog.h textmanualdialog.h \
|
surfacecollection.h surface.h textdialog.h textmanualdialog.h \
|
||||||
touchscreen.h translator.h utilities.h wallpaperdialog.h \
|
translator.h utilities.h wallpaperdialog.h \
|
||||||
browsedialog.h buttonbox.h dialog.h \
|
browsedialog.h buttonbox.h dialog.h \
|
||||||
imageio.h powersaver.h monitor.h mediamonitor.h clock.h \
|
imageio.h powersaver.h monitor.h mediamonitor.h clock.h \
|
||||||
layer.h helppopup.h contextmenu.h background.h battery.h
|
layer.h helppopup.h contextmenu.h background.h battery.h
|
||||||
|
@ -40,7 +40,3 @@ bool Background::handleButtonPress(InputManager::Button button) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Background::handleTouchscreen(Touchscreen&) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
@ -21,7 +21,6 @@ public:
|
|||||||
// Layer implementation:
|
// Layer implementation:
|
||||||
virtual void paint(Surface& s);
|
virtual void paint(Surface& s);
|
||||||
virtual bool handleButtonPress(InputManager::Button button);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual bool handleTouchscreen(Touchscreen& ts);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GMenu2X& gmenu2x;
|
GMenu2X& gmenu2x;
|
||||||
|
@ -11,33 +11,31 @@ using std::string;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
BrowseDialog::BrowseDialog(
|
BrowseDialog::BrowseDialog(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
GMenu2X& gmenu2x,
|
||||||
const string &title, const string &subtitle)
|
const string &title, const string &subtitle)
|
||||||
: Dialog(gmenu2x)
|
: Dialog(gmenu2x)
|
||||||
, ts(ts_)
|
|
||||||
, title(title)
|
, title(title)
|
||||||
, subtitle(subtitle)
|
, subtitle(subtitle)
|
||||||
, ts_pressed(false)
|
|
||||||
{
|
{
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/left.png")));
|
gmenu2x, "skin:imgs/buttons/left.png")));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
gmenu2x, "skin:imgs/buttons/cancel.png",
|
||||||
gmenu2x.tr["Up one folder"],
|
gmenu2x.tr["Up one folder"],
|
||||||
bind(&BrowseDialog::directoryUp, this))));
|
bind(&BrowseDialog::directoryUp, this))));
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
gmenu2x, "skin:imgs/buttons/accept.png",
|
||||||
gmenu2x.tr["Select"],
|
gmenu2x.tr["Select"],
|
||||||
bind(&BrowseDialog::directoryEnter, this))));
|
bind(&BrowseDialog::directoryEnter, this))));
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/start.png",
|
gmenu2x, "skin:imgs/buttons/start.png",
|
||||||
gmenu2x.tr["Confirm"],
|
gmenu2x.tr["Confirm"],
|
||||||
bind(&BrowseDialog::confirm, this))));
|
bind(&BrowseDialog::confirm, this))));
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/select.png",
|
gmenu2x, "skin:imgs/buttons/select.png",
|
||||||
gmenu2x.tr["Exit"],
|
gmenu2x.tr["Exit"],
|
||||||
bind(&BrowseDialog::quit, this))));
|
bind(&BrowseDialog::quit, this))));
|
||||||
|
|
||||||
@ -67,18 +65,10 @@ bool BrowseDialog::exec()
|
|||||||
static_cast<Uint16>(gmenu2x.resX - 9),
|
static_cast<Uint16>(gmenu2x.resX - 9),
|
||||||
static_cast<Uint16>(gmenu2x.resY - topBarHeight - 25)
|
static_cast<Uint16>(gmenu2x.resY - topBarHeight - 25)
|
||||||
};
|
};
|
||||||
touchRect = (SDL_Rect) {
|
|
||||||
2,
|
|
||||||
static_cast<Sint16>(topBarHeight + 4),
|
|
||||||
static_cast<Uint16>(gmenu2x.resX - 12),
|
|
||||||
clipRect.h
|
|
||||||
};
|
|
||||||
|
|
||||||
selected = 0;
|
selected = 0;
|
||||||
close = false;
|
close = false;
|
||||||
while (!close) {
|
while (!close) {
|
||||||
if (ts.available()) ts.poll();
|
|
||||||
|
|
||||||
paint();
|
paint();
|
||||||
|
|
||||||
handleInput();
|
handleInput();
|
||||||
@ -115,18 +105,7 @@ BrowseDialog::Action BrowseDialog::getAction(InputManager::Button button)
|
|||||||
void BrowseDialog::handleInput()
|
void BrowseDialog::handleInput()
|
||||||
{
|
{
|
||||||
InputManager::Button button = gmenu2x.input.waitForPressedButton();
|
InputManager::Button button = gmenu2x.input.waitForPressedButton();
|
||||||
|
BrowseDialog::Action action = getAction(button);
|
||||||
BrowseDialog::Action action;
|
|
||||||
if (ts_pressed && !ts.pressed()) {
|
|
||||||
action = BrowseDialog::ACT_SELECT;
|
|
||||||
ts_pressed = false;
|
|
||||||
} else {
|
|
||||||
action = getAction(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ts.available() && ts.pressed() && !ts.inRect(touchRect)) {
|
|
||||||
ts_pressed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action == BrowseDialog::ACT_SELECT && fl[selected] == "..") {
|
if (action == BrowseDialog::ACT_SELECT && fl[selected] == "..") {
|
||||||
action = BrowseDialog::ACT_GOUP;
|
action = BrowseDialog::ACT_GOUP;
|
||||||
@ -174,8 +153,6 @@ void BrowseDialog::handleInput()
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonBox.handleTS();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowseDialog::directoryUp()
|
void BrowseDialog::directoryUp()
|
||||||
@ -274,12 +251,6 @@ void BrowseDialog::paint()
|
|||||||
gmenu2x.font->write(s, fl[i], 24, offsetY + rowHeight / 2,
|
gmenu2x.font->write(s, fl[i], 24, offsetY + rowHeight / 2,
|
||||||
Font::HAlignLeft, Font::VAlignMiddle);
|
Font::HAlignLeft, Font::VAlignMiddle);
|
||||||
|
|
||||||
if (ts.available() && ts.pressed()
|
|
||||||
&& ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) {
|
|
||||||
ts_pressed = true;
|
|
||||||
selected = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
offsetY += rowHeight;
|
offsetY += rowHeight;
|
||||||
}
|
}
|
||||||
s.clearClipRect();
|
s.clearClipRect();
|
||||||
|
@ -30,12 +30,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class OffscreenSurface;
|
class OffscreenSurface;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class BrowseDialog : protected Dialog {
|
class BrowseDialog : protected Dialog {
|
||||||
protected:
|
protected:
|
||||||
BrowseDialog(
|
BrowseDialog(GMenu2X& gmenu2x,
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
|
||||||
const std::string &title, const std::string &subtitle);
|
const std::string &title, const std::string &subtitle);
|
||||||
virtual ~BrowseDialog();
|
virtual ~BrowseDialog();
|
||||||
|
|
||||||
@ -60,7 +58,6 @@ private:
|
|||||||
ACT_CONFIRM,
|
ACT_CONFIRM,
|
||||||
};
|
};
|
||||||
|
|
||||||
Touchscreen &ts;
|
|
||||||
bool close, result;
|
bool close, result;
|
||||||
|
|
||||||
std::string title;
|
std::string title;
|
||||||
@ -68,13 +65,10 @@ private:
|
|||||||
std::string path;
|
std::string path;
|
||||||
|
|
||||||
SDL_Rect clipRect;
|
SDL_Rect clipRect;
|
||||||
SDL_Rect touchRect;
|
|
||||||
|
|
||||||
unsigned int numRows;
|
unsigned int numRows;
|
||||||
unsigned int rowHeight;
|
unsigned int rowHeight;
|
||||||
|
|
||||||
bool ts_pressed;
|
|
||||||
|
|
||||||
OffscreenSurface *iconGoUp;
|
OffscreenSurface *iconGoUp;
|
||||||
OffscreenSurface *iconFolder;
|
OffscreenSurface *iconFolder;
|
||||||
OffscreenSurface *iconFile;
|
OffscreenSurface *iconFile;
|
||||||
|
@ -25,10 +25,3 @@ void ButtonBox::paint(Surface& s, int x, int y)
|
|||||||
x += button->getRect().w + 6;
|
x += button->getRect().w + 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonBox::handleTS()
|
|
||||||
{
|
|
||||||
for (auto& button : buttons) {
|
|
||||||
button->handleTS();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -16,7 +16,6 @@ public:
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void paint(Surface& s, int x, int y);
|
void paint(Surface& s, int x, int y);
|
||||||
void handleTS();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::unique_ptr<IconButton>> buttons;
|
std::vector<std::unique_ptr<IconButton>> buttons;
|
||||||
|
@ -157,21 +157,3 @@ bool ContextMenu::handleButtonPress(InputManager::Button button) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContextMenu::handleTouchscreen(Touchscreen &ts) {
|
|
||||||
if (ts.inRect(box)) {
|
|
||||||
int i = std::max(0, std::min(static_cast<int>(options.size()) - 1,
|
|
||||||
(ts.getY() - (box.y + 4)) / (gmenu2x.font->getLineSpacing() + 2)));
|
|
||||||
if (ts.released()) {
|
|
||||||
options[i]->action();
|
|
||||||
dismiss();
|
|
||||||
} else if (ts.pressed()) {
|
|
||||||
selected = i;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ts.released()) {
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -24,7 +24,6 @@ public:
|
|||||||
virtual bool runAnimations();
|
virtual bool runAnimations();
|
||||||
virtual void paint(Surface &s);
|
virtual void paint(Surface &s);
|
||||||
virtual bool handleButtonPress(InputManager::Button button);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual bool handleTouchscreen(Touchscreen &ts);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MenuOption;
|
struct MenuOption;
|
||||||
|
@ -24,10 +24,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
DirDialog::DirDialog(
|
DirDialog::DirDialog(GMenu2X& gmenu2x, const string &text, const string &dir)
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
: BrowseDialog(gmenu2x, "Directory Browser", text)
|
||||||
const string &text, const string &dir)
|
|
||||||
: BrowseDialog(gmenu2x, ts, "Directory Browser", text)
|
|
||||||
{
|
{
|
||||||
fl.setShowFiles(false);
|
fl.setShowFiles(false);
|
||||||
setPath(dir);
|
setPath(dir);
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
|
|
||||||
class DirDialog : public BrowseDialog {
|
class DirDialog : public BrowseDialog {
|
||||||
public:
|
public:
|
||||||
DirDialog(
|
DirDialog(GMenu2X& gmenu2x,
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
|
||||||
const std::string &text, const std::string &dir = "");
|
const std::string &text, const std::string &dir = "");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FileDialog::FileDialog(
|
FileDialog::FileDialog(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts, const string &text,
|
GMenu2X& gmenu2x, const string &text,
|
||||||
const string &filter, const string &file, const string &title)
|
const string &filter, const string &file, const string &title)
|
||||||
: BrowseDialog(gmenu2x, ts, title, text)
|
: BrowseDialog(gmenu2x, title, text)
|
||||||
{
|
{
|
||||||
string path(CARD_ROOT);
|
string path(CARD_ROOT);
|
||||||
if (!file.empty()) {
|
if (!file.empty()) {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
class FileDialog : public BrowseDialog {
|
class FileDialog : public BrowseDialog {
|
||||||
public:
|
public:
|
||||||
FileDialog(
|
FileDialog(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts, const std::string &text,
|
GMenu2X& gmenu2x, const std::string &text,
|
||||||
const std::string &filter="*", const std::string &file="",
|
const std::string &filter="*", const std::string &file="",
|
||||||
const std::string &title = "File Dialog");
|
const std::string &title = "File Dialog");
|
||||||
bool exec();
|
bool exec();
|
||||||
|
@ -376,7 +376,7 @@ void GMenu2X::initFont() {
|
|||||||
|
|
||||||
void GMenu2X::initMenu() {
|
void GMenu2X::initMenu() {
|
||||||
//Menu structure handler
|
//Menu structure handler
|
||||||
menu.reset(new Menu(*this, ts));
|
menu.reset(new Menu(*this));
|
||||||
|
|
||||||
// Add action links in the applications section.
|
// Add action links in the applications section.
|
||||||
auto appIdx = menu->sectionNamed("applications");
|
auto appIdx = menu->sectionNamed("applications");
|
||||||
@ -628,16 +628,6 @@ void GMenu2X::mainLoop() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle touchscreen events.
|
|
||||||
if (ts.available()) {
|
|
||||||
ts.poll();
|
|
||||||
for (auto it = layers.rbegin(); it != layers.rend(); ++it) {
|
|
||||||
if ((*it)->handleTouchscreen(ts)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle other input events.
|
// Handle other input events.
|
||||||
InputManager::Button button;
|
InputManager::Button button;
|
||||||
bool gotEvent;
|
bool gotEvent;
|
||||||
@ -656,7 +646,7 @@ void GMenu2X::mainLoop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::explorer() {
|
void GMenu2X::explorer() {
|
||||||
FileDialog fd(*this, ts, tr["Select an application"], "sh,bin,py,elf,");
|
FileDialog fd(*this, tr["Select an application"], "sh,bin,py,elf,");
|
||||||
if (fd.exec()) {
|
if (fd.exec()) {
|
||||||
if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex()))
|
if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex()))
|
||||||
writeConfig();
|
writeConfig();
|
||||||
@ -701,35 +691,35 @@ void GMenu2X::showSettings() {
|
|||||||
encodings.push_back("NTSC");
|
encodings.push_back("NTSC");
|
||||||
encodings.push_back("PAL");
|
encodings.push_back("PAL");
|
||||||
|
|
||||||
SettingsDialog sd(*this, input, ts, tr["Settings"]);
|
SettingsDialog sd(*this, input, tr["Settings"]);
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
||||||
*this, ts, tr["Language"],
|
*this, tr["Language"],
|
||||||
tr["Set the language used by GMenu2X"],
|
tr["Set the language used by GMenu2X"],
|
||||||
&lang, &translations)));
|
&lang, &translations)));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
||||||
*this, ts, tr["Save last selection"],
|
*this, tr["Save last selection"],
|
||||||
tr["Save the last selected link and section on exit"],
|
tr["Save the last selected link and section on exit"],
|
||||||
&confInt["saveSelection"])));
|
&confInt["saveSelection"])));
|
||||||
#ifdef ENABLE_CPUFREQ
|
#ifdef ENABLE_CPUFREQ
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||||
*this, ts, tr["Clock for GMenu2X"],
|
*this, tr["Clock for GMenu2X"],
|
||||||
tr["Set the cpu working frequency when running GMenu2X"],
|
tr["Set the cpu working frequency when running GMenu2X"],
|
||||||
&confInt["menuClock"], cpuFreqMin, cpuFreqSafeMax, cpuFreqMultiple)));
|
&confInt["menuClock"], cpuFreqMin, cpuFreqSafeMax, cpuFreqMultiple)));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||||
*this, ts, tr["Maximum overclock"],
|
*this, tr["Maximum overclock"],
|
||||||
tr["Set the maximum overclock for launching links"],
|
tr["Set the maximum overclock for launching links"],
|
||||||
&confInt["maxClock"], cpuFreqMin, cpuFreqMax, cpuFreqMultiple)));
|
&confInt["maxClock"], cpuFreqMin, cpuFreqMax, cpuFreqMultiple)));
|
||||||
#endif
|
#endif
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
||||||
*this, ts, tr["Output logs"],
|
*this, tr["Output logs"],
|
||||||
tr["Logs the output of the links. Use the Log Viewer to read them."],
|
tr["Logs the output of the links. Use the Log Viewer to read them."],
|
||||||
&confInt["outputLogs"])));
|
&confInt["outputLogs"])));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||||
*this, ts, tr["Screen Timeout"],
|
*this, tr["Screen Timeout"],
|
||||||
tr["Set screen's backlight timeout in seconds"],
|
tr["Set screen's backlight timeout in seconds"],
|
||||||
&confInt["backlightTimeout"], 0, 120)));
|
&confInt["backlightTimeout"], 0, 120)));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||||
*this, ts, tr["Button repeat rate"],
|
*this, tr["Button repeat rate"],
|
||||||
tr["Set button repetitions per second"],
|
tr["Set button repetitions per second"],
|
||||||
&confInt["buttonRepeatRate"], 0, 20)));
|
&confInt["buttonRepeatRate"], 0, 20)));
|
||||||
|
|
||||||
@ -761,33 +751,33 @@ void GMenu2X::skinMenu() {
|
|||||||
|
|
||||||
string curSkin = confStr["skin"];
|
string curSkin = confStr["skin"];
|
||||||
|
|
||||||
SettingsDialog sd(*this, input, ts, tr["Skin"]);
|
SettingsDialog sd(*this, input, tr["Skin"]);
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
||||||
*this, ts, tr["Skin"],
|
*this, tr["Skin"],
|
||||||
tr["Set the skin used by GMenu2X"],
|
tr["Set the skin used by GMenu2X"],
|
||||||
&confStr["skin"], &fl_sk.getDirectories())));
|
&confStr["skin"], &fl_sk.getDirectories())));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||||
*this, ts, tr["Top Bar"],
|
*this, tr["Top Bar"],
|
||||||
tr["Color of the top bar"],
|
tr["Color of the top bar"],
|
||||||
&skinConfColors[COLOR_TOP_BAR_BG])));
|
&skinConfColors[COLOR_TOP_BAR_BG])));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||||
*this, ts, tr["Bottom Bar"],
|
*this, tr["Bottom Bar"],
|
||||||
tr["Color of the bottom bar"],
|
tr["Color of the bottom bar"],
|
||||||
&skinConfColors[COLOR_BOTTOM_BAR_BG])));
|
&skinConfColors[COLOR_BOTTOM_BAR_BG])));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||||
*this, ts, tr["Selection"],
|
*this, tr["Selection"],
|
||||||
tr["Color of the selection and other interface details"],
|
tr["Color of the selection and other interface details"],
|
||||||
&skinConfColors[COLOR_SELECTION_BG])));
|
&skinConfColors[COLOR_SELECTION_BG])));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||||
*this, ts, tr["Message Box"],
|
*this, tr["Message Box"],
|
||||||
tr["Background color of the message box"],
|
tr["Background color of the message box"],
|
||||||
&skinConfColors[COLOR_MESSAGE_BOX_BG])));
|
&skinConfColors[COLOR_MESSAGE_BOX_BG])));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||||
*this, ts, tr["Message Box Border"],
|
*this, tr["Message Box Border"],
|
||||||
tr["Border color of the message box"],
|
tr["Border color of the message box"],
|
||||||
&skinConfColors[COLOR_MESSAGE_BOX_BORDER])));
|
&skinConfColors[COLOR_MESSAGE_BOX_BORDER])));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||||
*this, ts, tr["Message Box Selection"],
|
*this, tr["Message Box Selection"],
|
||||||
tr["Color of the selection of the message box"],
|
tr["Color of the selection of the message box"],
|
||||||
&skinConfColors[COLOR_MESSAGE_BOX_SELECTION])));
|
&skinConfColors[COLOR_MESSAGE_BOX_SELECTION])));
|
||||||
|
|
||||||
@ -888,7 +878,7 @@ void GMenu2X::showContextMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::changeWallpaper() {
|
void GMenu2X::changeWallpaper() {
|
||||||
WallpaperDialog wp(*this, ts);
|
WallpaperDialog wp(*this);
|
||||||
if (wp.exec() && confStr["wallpaper"] != wp.wallpaper) {
|
if (wp.exec() && confStr["wallpaper"] != wp.wallpaper) {
|
||||||
confStr["wallpaper"] = wp.wallpaper;
|
confStr["wallpaper"] = wp.wallpaper;
|
||||||
initBG();
|
initBG();
|
||||||
@ -897,7 +887,7 @@ void GMenu2X::changeWallpaper() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::addLink() {
|
void GMenu2X::addLink() {
|
||||||
FileDialog fd(*this, ts, tr["Select an application"], "sh,bin,py,elf,");
|
FileDialog fd(*this, tr["Select an application"], "sh,bin,py,elf,");
|
||||||
if (fd.exec())
|
if (fd.exec())
|
||||||
menu->addLink(fd.getPath(), fd.getFile());
|
menu->addLink(fd.getPath(), fd.getFile());
|
||||||
}
|
}
|
||||||
@ -925,52 +915,52 @@ void GMenu2X::editLink() {
|
|||||||
string diagTitle = tr.translate("Edit $1",linkTitle.c_str(),NULL);
|
string diagTitle = tr.translate("Edit $1",linkTitle.c_str(),NULL);
|
||||||
string diagIcon = linkApp->getIconPath();
|
string diagIcon = linkApp->getIconPath();
|
||||||
|
|
||||||
SettingsDialog sd(*this, input, ts, diagTitle, diagIcon);
|
SettingsDialog sd(*this, input, diagTitle, diagIcon);
|
||||||
if (!linkApp->isOpk()) {
|
if (!linkApp->isOpk()) {
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
||||||
*this, ts, tr["Title"],
|
*this, tr["Title"],
|
||||||
tr["Link title"],
|
tr["Link title"],
|
||||||
&linkTitle, diagTitle, diagIcon)));
|
&linkTitle, diagTitle, diagIcon)));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
||||||
*this, ts, tr["Description"],
|
*this, tr["Description"],
|
||||||
tr["Link description"],
|
tr["Link description"],
|
||||||
&linkDescription, diagTitle, diagIcon)));
|
&linkDescription, diagTitle, diagIcon)));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
||||||
*this, ts, tr["Section"],
|
*this, tr["Section"],
|
||||||
tr["The section this link belongs to"],
|
tr["The section this link belongs to"],
|
||||||
&newSection, &menu->getSections())));
|
&newSection, &menu->getSections())));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingImage(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingImage(
|
||||||
*this, ts, tr["Icon"],
|
*this, tr["Icon"],
|
||||||
tr.translate("Select an icon for this link", linkTitle.c_str(), NULL),
|
tr.translate("Select an icon for this link", linkTitle.c_str(), NULL),
|
||||||
&linkIcon, "png")));
|
&linkIcon, "png")));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingFile(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingFile(
|
||||||
*this, ts, tr["Manual"],
|
*this, tr["Manual"],
|
||||||
tr["Select a manual or README file"],
|
tr["Select a manual or README file"],
|
||||||
&linkManual, "man.png,txt")));
|
&linkManual, "man.png,txt")));
|
||||||
}
|
}
|
||||||
if (!linkApp->isOpk() || !linkApp->getSelectorDir().empty()) {
|
if (!linkApp->isOpk() || !linkApp->getSelectorDir().empty()) {
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingDir(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingDir(
|
||||||
*this, ts, tr["Selector Directory"],
|
*this, tr["Selector Directory"],
|
||||||
tr["Directory to scan for the selector"],
|
tr["Directory to scan for the selector"],
|
||||||
&linkSelDir)));
|
&linkSelDir)));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
||||||
*this, ts, tr["Selector Browser"],
|
*this, tr["Selector Browser"],
|
||||||
tr["Allow the selector to change directory"],
|
tr["Allow the selector to change directory"],
|
||||||
&linkSelBrowser)));
|
&linkSelBrowser)));
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_CPUFREQ
|
#ifdef ENABLE_CPUFREQ
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||||
*this, ts, tr["Clock frequency"],
|
*this, tr["Clock frequency"],
|
||||||
tr["CPU clock frequency for this link"],
|
tr["CPU clock frequency for this link"],
|
||||||
&linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple)));
|
&linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple)));
|
||||||
#endif
|
#endif
|
||||||
if (!linkApp->isOpk()) {
|
if (!linkApp->isOpk()) {
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
||||||
*this, ts, tr["Selector Filter"],
|
*this, tr["Selector Filter"],
|
||||||
tr["Selector filter (Separate values with a comma)"],
|
tr["Selector filter (Separate values with a comma)"],
|
||||||
&linkSelFilter, diagTitle, diagIcon)));
|
&linkSelFilter, diagTitle, diagIcon)));
|
||||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
||||||
*this, ts, tr["Display Console"],
|
*this, tr["Display Console"],
|
||||||
tr["Must be enabled for console-based applications"],
|
tr["Must be enabled for console-based applications"],
|
||||||
&linkApp->consoleApp)));
|
&linkApp->consoleApp)));
|
||||||
}
|
}
|
||||||
@ -1021,7 +1011,7 @@ void GMenu2X::deleteLink() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::addSection() {
|
void GMenu2X::addSection() {
|
||||||
InputDialog id(*this, input, ts, tr["Insert a name for the new section"]);
|
InputDialog id(*this, input, tr["Insert a name for the new section"]);
|
||||||
if (id.exec()) {
|
if (id.exec()) {
|
||||||
// Look up section; create if it doesn't exist yet.
|
// Look up section; create if it doesn't exist yet.
|
||||||
auto idx = menu->sectionNamed(id.getInput());
|
auto idx = menu->sectionNamed(id.getInput());
|
||||||
@ -1031,7 +1021,7 @@ void GMenu2X::addSection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::renameSection() {
|
void GMenu2X::renameSection() {
|
||||||
InputDialog id(*this, input, ts, tr["Insert a new name for this section"],menu->selSection());
|
InputDialog id(*this, input, tr["Insert a new name for this section"],menu->selSection());
|
||||||
if (id.exec()) {
|
if (id.exec()) {
|
||||||
//only if a section with the same name does not exist & !samename
|
//only if a section with the same name does not exist & !samename
|
||||||
if (menu->selSection() != id.getInput()
|
if (menu->selSection() != id.getInput()
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "contextmenu.h"
|
#include "contextmenu.h"
|
||||||
#include "surfacecollection.h"
|
#include "surfacecollection.h"
|
||||||
#include "translator.h"
|
#include "translator.h"
|
||||||
#include "touchscreen.h"
|
|
||||||
#include "inputmanager.h"
|
#include "inputmanager.h"
|
||||||
#include "powersaver.h"
|
#include "powersaver.h"
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
@ -70,7 +69,6 @@ enum color {
|
|||||||
|
|
||||||
class GMenu2X {
|
class GMenu2X {
|
||||||
private:
|
private:
|
||||||
Touchscreen ts;
|
|
||||||
std::shared_ptr<Menu> menu;
|
std::shared_ptr<Menu> menu;
|
||||||
#ifdef ENABLE_INOTIFY
|
#ifdef ENABLE_INOTIFY
|
||||||
MediaMonitor *monitor;
|
MediaMonitor *monitor;
|
||||||
@ -210,8 +208,6 @@ public:
|
|||||||
|
|
||||||
void drawTopBar(Surface& s);
|
void drawTopBar(Surface& s);
|
||||||
void drawBottomBar(Surface& s);
|
void drawBottomBar(Surface& s);
|
||||||
|
|
||||||
Touchscreen &getTouchscreen() { return ts; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GMENU2X_H
|
#endif // GMENU2X_H
|
||||||
|
@ -36,11 +36,3 @@ bool HelpPopup::handleButtonPress(InputManager::Button button) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HelpPopup::handleTouchscreen(Touchscreen& ts) {
|
|
||||||
if (ts.pressed()) {
|
|
||||||
dismiss();
|
|
||||||
ts.setHandled();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -19,7 +19,6 @@ public:
|
|||||||
// Layer implementation:
|
// Layer implementation:
|
||||||
virtual void paint(Surface& s);
|
virtual void paint(Surface& s);
|
||||||
virtual bool handleButtonPress(InputManager::Button button);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual bool handleTouchscreen(Touchscreen& ts);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GMenu2X& gmenu2x;
|
GMenu2X& gmenu2x;
|
||||||
|
@ -8,10 +8,9 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
IconButton::IconButton(
|
IconButton::IconButton(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x, const string &icon, const string &label,
|
||||||
const string &icon, const string &label, Action action)
|
Action action)
|
||||||
: gmenu2x(gmenu2x)
|
: gmenu2x(gmenu2x)
|
||||||
, ts(ts)
|
|
||||||
, icon(icon)
|
, icon(icon)
|
||||||
, label(label)
|
, label(label)
|
||||||
, action(action)
|
, action(action)
|
||||||
@ -52,15 +51,6 @@ void IconButton::recalcRects() {
|
|||||||
rect.h = h;
|
rect.h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IconButton::handleTS() {
|
|
||||||
if (action && ts.released() && ts.inRect(rect)) {
|
|
||||||
ts.setHandled();
|
|
||||||
action();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconButton::paint(Surface& s) {
|
void IconButton::paint(Surface& s) {
|
||||||
if (iconSurface) {
|
if (iconSurface) {
|
||||||
iconSurface->blit(s, iconRect);
|
iconSurface->blit(s, iconRect);
|
||||||
|
@ -10,29 +10,25 @@
|
|||||||
|
|
||||||
class OffscreenSurface;
|
class OffscreenSurface;
|
||||||
class Surface;
|
class Surface;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
|
|
||||||
class IconButton {
|
class IconButton {
|
||||||
public:
|
public:
|
||||||
typedef std::function<void(void)> Action;
|
typedef std::function<void(void)> Action;
|
||||||
|
|
||||||
IconButton(GMenu2X& gmenu2x, Touchscreen &ts,
|
IconButton(GMenu2X& gmenu2x,
|
||||||
const std::string &icon, const std::string &label = "",
|
const std::string &icon, const std::string &label = "",
|
||||||
Action action = nullptr);
|
Action action = nullptr);
|
||||||
|
|
||||||
SDL_Rect getRect() { return rect; }
|
SDL_Rect getRect() { return rect; }
|
||||||
void setPosition(int x, int y);
|
void setPosition(int x, int y);
|
||||||
|
|
||||||
bool handleTS();
|
|
||||||
|
|
||||||
void paint(Surface& s);
|
void paint(Surface& s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recalcRects();
|
void recalcRects();
|
||||||
|
|
||||||
GMenu2X& gmenu2x;
|
GMenu2X& gmenu2x;
|
||||||
Touchscreen &ts;
|
|
||||||
std::string icon, label;
|
std::string icon, label;
|
||||||
Action action;
|
Action action;
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ImageDialog::ImageDialog(
|
ImageDialog::ImageDialog(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts, const string &text,
|
GMenu2X& gmenu2x, const string &text,
|
||||||
const string &filter, const string &file)
|
const string &filter, const string &file)
|
||||||
: FileDialog(gmenu2x, ts, text, filter, file, "Image Browser")
|
: FileDialog(gmenu2x, text, filter, file, "Image Browser")
|
||||||
{
|
{
|
||||||
|
|
||||||
string path;
|
string path;
|
||||||
|
@ -31,7 +31,7 @@ protected:
|
|||||||
SurfaceCollection previews;
|
SurfaceCollection previews;
|
||||||
public:
|
public:
|
||||||
ImageDialog(
|
ImageDialog(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts, const std::string &text,
|
GMenu2X& gmenu2x, const std::string &text,
|
||||||
const std::string &filter = "", const std::string &file = "");
|
const std::string &filter = "", const std::string &file = "");
|
||||||
virtual ~ImageDialog();
|
virtual ~ImageDialog();
|
||||||
|
|
||||||
|
@ -38,11 +38,10 @@ static bool utf8Code(unsigned char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
InputDialog::InputDialog(GMenu2X& gmenu2x, InputManager &inputMgr_,
|
InputDialog::InputDialog(GMenu2X& gmenu2x, InputManager &inputMgr_,
|
||||||
Touchscreen &ts_, const string &text,
|
const string &text,
|
||||||
const string &startvalue, const string &title, const string &icon)
|
const string &startvalue, const string &title, const string &icon)
|
||||||
: Dialog(gmenu2x)
|
: Dialog(gmenu2x)
|
||||||
, inputMgr(inputMgr_)
|
, inputMgr(inputMgr_)
|
||||||
, ts(ts_)
|
|
||||||
{
|
{
|
||||||
if (title.empty()) {
|
if (title.empty()) {
|
||||||
this->title = text;
|
this->title = text;
|
||||||
@ -97,22 +96,22 @@ InputDialog::InputDialog(GMenu2X& gmenu2x, InputManager &inputMgr_,
|
|||||||
setKeyboard(0);
|
setKeyboard(0);
|
||||||
|
|
||||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/l.png",
|
gmenu2x, "skin:imgs/buttons/l.png",
|
||||||
gmenu2x.tr["Backspace"],
|
gmenu2x.tr["Backspace"],
|
||||||
bind(&InputDialog::backspace, this))));
|
bind(&InputDialog::backspace, this))));
|
||||||
|
|
||||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/r.png",
|
gmenu2x, "skin:imgs/buttons/r.png",
|
||||||
gmenu2x.tr["Space"],
|
gmenu2x.tr["Space"],
|
||||||
bind(&InputDialog::space, this))));
|
bind(&InputDialog::space, this))));
|
||||||
|
|
||||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
gmenu2x, "skin:imgs/buttons/accept.png",
|
||||||
gmenu2x.tr["Confirm"],
|
gmenu2x.tr["Confirm"],
|
||||||
bind(&InputDialog::confirm, this))));
|
bind(&InputDialog::confirm, this))));
|
||||||
|
|
||||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
gmenu2x, "skin:imgs/buttons/cancel.png",
|
||||||
gmenu2x.tr["Change keys"],
|
gmenu2x.tr["Change keys"],
|
||||||
bind(&InputDialog::changeKeys, this))));
|
bind(&InputDialog::changeKeys, this))));
|
||||||
}
|
}
|
||||||
@ -182,7 +181,6 @@ bool InputDialog::exec() {
|
|||||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ts.available()) ts.poll();
|
|
||||||
drawVirtualKeyboard();
|
drawVirtualKeyboard();
|
||||||
s.flip();
|
s.flip();
|
||||||
|
|
||||||
@ -306,12 +304,6 @@ void InputDialog::drawVirtualKeyboard() {
|
|||||||
KEY_HEIGHT - 2
|
KEY_HEIGHT - 2
|
||||||
};
|
};
|
||||||
|
|
||||||
//if ts on rect, change selection
|
|
||||||
if (ts.available() && ts.pressed() && ts.inRect(re)) {
|
|
||||||
selCol = xc;
|
|
||||||
selRow = l;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.rectangle(re,
|
s.rectangle(re,
|
||||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||||
gmenu2x.font->write(s, charX,
|
gmenu2x.font->write(s, charX,
|
||||||
@ -330,10 +322,6 @@ void InputDialog::drawVirtualKeyboard() {
|
|||||||
KEY_HEIGHT - 1
|
KEY_HEIGHT - 1
|
||||||
};
|
};
|
||||||
s.rectangle(re, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
s.rectangle(re, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||||
if (ts.available() && ts.pressed() && ts.inRect(re)) {
|
|
||||||
selCol = 0;
|
|
||||||
selRow = kb->size();
|
|
||||||
}
|
|
||||||
gmenu2x.font->write(s, gmenu2x.tr["Cancel"],
|
gmenu2x.font->write(s, gmenu2x.tr["Cancel"],
|
||||||
(int)(160 - kbLength * KEY_WIDTH / 4),
|
(int)(160 - kbLength * KEY_WIDTH / 4),
|
||||||
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
|
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
|
||||||
@ -341,10 +329,6 @@ void InputDialog::drawVirtualKeyboard() {
|
|||||||
|
|
||||||
re.x = kbLeft + kbLength * KEY_WIDTH / 2 - 1;
|
re.x = kbLeft + kbLength * KEY_WIDTH / 2 - 1;
|
||||||
s.rectangle(re, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
s.rectangle(re, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||||
if (ts.available() && ts.pressed() && ts.inRect(re)) {
|
|
||||||
selCol = 1;
|
|
||||||
selRow = kb->size();
|
|
||||||
}
|
|
||||||
gmenu2x.font->write(s, gmenu2x.tr["OK"],
|
gmenu2x.font->write(s, gmenu2x.tr["OK"],
|
||||||
(int)(160 + kbLength * KEY_WIDTH / 4),
|
(int)(160 + kbLength * KEY_WIDTH / 4),
|
||||||
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
|
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
|
||||||
|
@ -29,11 +29,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class InputManager;
|
class InputManager;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class InputDialog : protected Dialog {
|
class InputDialog : protected Dialog {
|
||||||
public:
|
public:
|
||||||
InputDialog(GMenu2X& gmenu2x, InputManager &inputMgr, Touchscreen &ts,
|
InputDialog(GMenu2X& gmenu2x, InputManager &inputMgr,
|
||||||
const std::string &text, const std::string &startvalue="",
|
const std::string &text, const std::string &startvalue="",
|
||||||
const std::string &title="", const std::string &icon="");
|
const std::string &title="", const std::string &icon="");
|
||||||
|
|
||||||
@ -50,7 +49,6 @@ private:
|
|||||||
void setKeyboard(int);
|
void setKeyboard(int);
|
||||||
|
|
||||||
InputManager &inputMgr;
|
InputManager &inputMgr;
|
||||||
Touchscreen &ts;
|
|
||||||
int selRow, selCol;
|
int selRow, selCol;
|
||||||
bool close, ok;
|
bool close, ok;
|
||||||
std::string title, text, icon;
|
std::string title, text, icon;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "inputmanager.h"
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class Surface;
|
class Surface;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,13 +36,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool handleButtonPress(InputManager::Button button) = 0;
|
virtual bool handleButtonPress(InputManager::Button button) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the touch screen.
|
|
||||||
* Only called if there is a touch screen available.
|
|
||||||
* Returns true iff the touch screen was fully handled by this layer.
|
|
||||||
*/
|
|
||||||
virtual bool handleTouchscreen(Touchscreen &ts) = 0;
|
|
||||||
|
|
||||||
Status getStatus() { return status; }
|
Status getStatus() { return status; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
19
src/link.cpp
19
src/link.cpp
@ -34,11 +34,9 @@ using namespace std;
|
|||||||
|
|
||||||
Link::Link(GMenu2X& gmenu2x, Action action)
|
Link::Link(GMenu2X& gmenu2x, Action action)
|
||||||
: gmenu2x(gmenu2x)
|
: gmenu2x(gmenu2x)
|
||||||
, ts(gmenu2x.getTouchscreen())
|
|
||||||
, action(action)
|
, action(action)
|
||||||
, lastTick(0)
|
, lastTick(0)
|
||||||
{
|
{
|
||||||
// ts = gmenu2x.getTouchscreen();
|
|
||||||
rect.w = gmenu2x.skinConfInt["linkWidth"];
|
rect.w = gmenu2x.skinConfInt["linkWidth"];
|
||||||
rect.h = gmenu2x.skinConfInt["linkHeight"];
|
rect.h = gmenu2x.skinConfInt["linkHeight"];
|
||||||
edited = false;
|
edited = false;
|
||||||
@ -49,23 +47,6 @@ Link::Link(GMenu2X& gmenu2x, Action action)
|
|||||||
updateSurfaces();
|
updateSurfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Link::isPressed() {
|
|
||||||
return ts.pressed() && ts.inRect(rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Link::handleTS() {
|
|
||||||
if (ts.released() && ts.inRect(rect)) {
|
|
||||||
int tickNow = SDL_GetTicks();
|
|
||||||
if (tickNow - lastTick < 400) {
|
|
||||||
ts.setHandled();
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
lastTick = tickNow;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Link::paint() {
|
void Link::paint() {
|
||||||
Surface& s = *gmenu2x.s;
|
Surface& s = *gmenu2x.s;
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
class GMenu2X;
|
class GMenu2X;
|
||||||
class OffscreenSurface;
|
class OffscreenSurface;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,9 +42,6 @@ public:
|
|||||||
Link(GMenu2X& gmenu2x, Action action);
|
Link(GMenu2X& gmenu2x, Action action);
|
||||||
virtual ~Link() {};
|
virtual ~Link() {};
|
||||||
|
|
||||||
bool isPressed();
|
|
||||||
bool handleTS();
|
|
||||||
|
|
||||||
virtual void paint();
|
virtual void paint();
|
||||||
void paintHover();
|
void paintHover();
|
||||||
|
|
||||||
@ -79,7 +75,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void recalcCoordinates();
|
void recalcCoordinates();
|
||||||
|
|
||||||
Touchscreen &ts;
|
|
||||||
Action action;
|
Action action;
|
||||||
|
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
|
@ -72,10 +72,6 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleTouchscreen(Touchscreen&) override {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LinkApp& app;
|
LinkApp& app;
|
||||||
};
|
};
|
||||||
|
46
src/menu.cpp
46
src/menu.cpp
@ -68,10 +68,9 @@ void Menu::Animation::step()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::Menu(GMenu2X& gmenu2x, Touchscreen &ts)
|
Menu::Menu(GMenu2X& gmenu2x)
|
||||||
: gmenu2x(gmenu2x)
|
: gmenu2x(gmenu2x)
|
||||||
, ts(ts)
|
, btnContextMenu(gmenu2x, "skin:imgs/menu.png", "",
|
||||||
, btnContextMenu(gmenu2x, ts, "skin:imgs/menu.png", "",
|
|
||||||
std::bind(&GMenu2X::showContextMenu, &gmenu2x))
|
std::bind(&GMenu2X::showContextMenu, &gmenu2x))
|
||||||
{
|
{
|
||||||
readSections(GMENU2X_SYSTEM_DIR "/sections");
|
readSections(GMENU2X_SYSTEM_DIR "/sections");
|
||||||
@ -275,10 +274,6 @@ void Menu::paint(Surface &s) {
|
|||||||
sc.skinRes("imgs/manual.png")->blit(
|
sc.skinRes("imgs/manual.png")->blit(
|
||||||
s, gmenu2x.manualX, gmenu2x.bottomBarIconY);
|
s, gmenu2x.manualX, gmenu2x.bottomBarIconY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ts.available()) {
|
|
||||||
btnContextMenu.paint(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Menu::handleButtonPress(InputManager::Button button) {
|
bool Menu::handleButtonPress(InputManager::Button button) {
|
||||||
@ -312,43 +307,6 @@ bool Menu::handleButtonPress(InputManager::Button button) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Menu::handleTouchscreen(Touchscreen &ts) {
|
|
||||||
btnContextMenu.handleTS();
|
|
||||||
|
|
||||||
ConfIntHash &skinConfInt = gmenu2x.skinConfInt;
|
|
||||||
const int topBarHeight = skinConfInt["topBarHeight"];
|
|
||||||
const int screenWidth = gmenu2x.resX;
|
|
||||||
|
|
||||||
if (ts.pressed() && ts.getY() < topBarHeight) {
|
|
||||||
int leftSection, rightSection;
|
|
||||||
calcSectionRange(leftSection, rightSection);
|
|
||||||
|
|
||||||
const int linkWidth = skinConfInt["linkWidth"];
|
|
||||||
const int leftSectionX = screenWidth / 2 + leftSection * linkWidth;
|
|
||||||
const int i = min(
|
|
||||||
leftSection + max((ts.getX() - leftSectionX) / linkWidth, 0),
|
|
||||||
rightSection);
|
|
||||||
const uint numSections = sections.size();
|
|
||||||
setSectionIndex((iSection + numSections + i) % numSections);
|
|
||||||
|
|
||||||
ts.setHandled();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint linksPerPage = linkColumns * linkRows;
|
|
||||||
uint i = iFirstDispRow * linkColumns;
|
|
||||||
while (i < (iFirstDispRow * linkColumns) + linksPerPage && i < sectionLinks()->size()) {
|
|
||||||
if (sectionLinks()->at(i)->isPressed()) {
|
|
||||||
setLinkIndex(i);
|
|
||||||
}
|
|
||||||
if (sectionLinks()->at(i)->handleTS()) {
|
|
||||||
i = sectionLinks()->size();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return ts.handled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*====================================
|
/*====================================
|
||||||
SECTION MANAGEMENT
|
SECTION MANAGEMENT
|
||||||
====================================*/
|
====================================*/
|
||||||
|
@ -55,7 +55,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
GMenu2X& gmenu2x;
|
GMenu2X& gmenu2x;
|
||||||
Touchscreen &ts;
|
|
||||||
IconButton btnContextMenu;
|
IconButton btnContextMenu;
|
||||||
int iSection, iLink;
|
int iSection, iLink;
|
||||||
uint iFirstDispRow;
|
uint iFirstDispRow;
|
||||||
@ -109,7 +108,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
typedef std::function<void(void)> Action;
|
typedef std::function<void(void)> Action;
|
||||||
|
|
||||||
Menu(GMenu2X& gmenu2x, Touchscreen &ts);
|
Menu(GMenu2X& gmenu2x);
|
||||||
virtual ~Menu();
|
virtual ~Menu();
|
||||||
|
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
@ -152,7 +151,6 @@ public:
|
|||||||
virtual bool runAnimations();
|
virtual bool runAnimations();
|
||||||
virtual void paint(Surface &s);
|
virtual void paint(Surface &s);
|
||||||
virtual bool handleButtonPress(InputManager::Button button);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual bool handleTouchscreen(Touchscreen &ts);
|
|
||||||
|
|
||||||
bool linkChangeSection(uint linkIndex, uint oldSectionIndex, uint newSectionIndex);
|
bool linkChangeSection(uint linkIndex, uint oldSectionIndex, uint newSectionIndex);
|
||||||
|
|
||||||
|
@ -44,11 +44,6 @@ void MenuSetting::draw(int /*valueX*/, int y, int /*h*/)
|
|||||||
gmenu2x.font->write(s, name, 5, y, Font::HAlignLeft, Font::VAlignTop);
|
gmenu2x.font->write(s, name, 5, y, Font::HAlignLeft, Font::VAlignTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSetting::handleTS(int /*valueX*/, int /*y*/, int /*h*/)
|
|
||||||
{
|
|
||||||
buttonBox.handleTS();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuSetting::drawSelected(int valueX, int y, int h)
|
void MenuSetting::drawSelected(int valueX, int y, int h)
|
||||||
{
|
{
|
||||||
Surface& s = *gmenu2x.s;
|
Surface& s = *gmenu2x.s;
|
||||||
|
@ -45,7 +45,6 @@ public:
|
|||||||
virtual ~MenuSetting();
|
virtual ~MenuSetting();
|
||||||
|
|
||||||
virtual void draw(int valueX, int y, int h);
|
virtual void draw(int valueX, int y, int h);
|
||||||
virtual void handleTS(int valueX, int y, int h);
|
|
||||||
|
|
||||||
virtual bool handleButtonPress(InputManager::Button button) = 0;
|
virtual bool handleButtonPress(InputManager::Button button) = 0;
|
||||||
virtual void drawSelected(int valueX, int y, int h);
|
virtual void drawSelected(int valueX, int y, int h);
|
||||||
|
@ -32,10 +32,9 @@ using std::string;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
MenuSettingBool::MenuSettingBool(
|
MenuSettingBool::MenuSettingBool(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description, int *value)
|
const string &name, const string &description, int *value)
|
||||||
: MenuSetting(gmenu2x, name, description)
|
: MenuSetting(gmenu2x, name, description)
|
||||||
, ts(ts)
|
|
||||||
{
|
{
|
||||||
_ivalue = value;
|
_ivalue = value;
|
||||||
_value = NULL;
|
_value = NULL;
|
||||||
@ -45,10 +44,9 @@ MenuSettingBool::MenuSettingBool(
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuSettingBool::MenuSettingBool(
|
MenuSettingBool::MenuSettingBool(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description, bool *value)
|
const string &name, const string &description, bool *value)
|
||||||
: MenuSetting(gmenu2x, name, description)
|
: MenuSetting(gmenu2x, name, description)
|
||||||
, ts(ts)
|
|
||||||
{
|
{
|
||||||
_value = value;
|
_value = value;
|
||||||
_ivalue = NULL;
|
_ivalue = NULL;
|
||||||
@ -60,7 +58,7 @@ MenuSettingBool::MenuSettingBool(
|
|||||||
void MenuSettingBool::initButton()
|
void MenuSettingBool::initButton()
|
||||||
{
|
{
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
gmenu2x, "skin:imgs/buttons/accept.png",
|
||||||
gmenu2x.tr["Switch"],
|
gmenu2x.tr["Switch"],
|
||||||
bind(&MenuSettingBool::toggle, this))));
|
bind(&MenuSettingBool::toggle, this))));
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,12 @@
|
|||||||
#include "inputmanager.h"
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class GMenu2X;
|
class GMenu2X;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class MenuSettingBool : public MenuSetting {
|
class MenuSettingBool : public MenuSetting {
|
||||||
private:
|
private:
|
||||||
void initButton();
|
void initButton();
|
||||||
void toggle();
|
void toggle();
|
||||||
|
|
||||||
Touchscreen &ts;
|
|
||||||
bool originalValue;
|
bool originalValue;
|
||||||
bool *_value;
|
bool *_value;
|
||||||
int *_ivalue;
|
int *_ivalue;
|
||||||
@ -39,11 +37,11 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingBool(
|
MenuSettingBool(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const std::string &name, const std::string &description,
|
const std::string &name, const std::string &description,
|
||||||
bool *value);
|
bool *value);
|
||||||
MenuSettingBool(
|
MenuSettingBool(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const std::string &name, const std::string &description,
|
const std::string &name, const std::string &description,
|
||||||
int *value);
|
int *value);
|
||||||
virtual ~MenuSettingBool() {}
|
virtual ~MenuSettingBool() {}
|
||||||
|
@ -29,24 +29,23 @@ using std::string;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
MenuSettingDir::MenuSettingDir(
|
MenuSettingDir::MenuSettingDir(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description, string *value)
|
const string &name, const string &description, string *value)
|
||||||
: MenuSettingStringBase(gmenu2x, name, description, value)
|
: MenuSettingStringBase(gmenu2x, name, description, value)
|
||||||
, ts(ts_)
|
|
||||||
{
|
{
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
gmenu2x, "skin:imgs/buttons/cancel.png",
|
||||||
gmenu2x.tr["Clear"],
|
gmenu2x.tr["Clear"],
|
||||||
bind(&MenuSettingDir::clear, this))));
|
bind(&MenuSettingDir::clear, this))));
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
gmenu2x, "skin:imgs/buttons/accept.png",
|
||||||
gmenu2x.tr["Select"],
|
gmenu2x.tr["Select"],
|
||||||
bind(&MenuSettingDir::edit, this))));
|
bind(&MenuSettingDir::edit, this))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingDir::edit()
|
void MenuSettingDir::edit()
|
||||||
{
|
{
|
||||||
DirDialog dd(gmenu2x, ts, description, value());
|
DirDialog dd(gmenu2x, description, value());
|
||||||
if (dd.exec()) setValue(dd.getPath());
|
if (dd.exec()) setValue(dd.getPath());
|
||||||
}
|
}
|
||||||
|
@ -22,18 +22,13 @@
|
|||||||
|
|
||||||
#include "menusettingstringbase.h"
|
#include "menusettingstringbase.h"
|
||||||
|
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class MenuSettingDir : public MenuSettingStringBase {
|
class MenuSettingDir : public MenuSettingStringBase {
|
||||||
private:
|
|
||||||
Touchscreen &ts;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void edit();
|
virtual void edit();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingDir(
|
MenuSettingDir(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const std::string &name, const std::string &description,
|
const std::string &name, const std::string &description,
|
||||||
std::string *value);
|
std::string *value);
|
||||||
virtual ~MenuSettingDir() {}
|
virtual ~MenuSettingDir() {}
|
||||||
|
@ -29,27 +29,26 @@ using std::string;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
MenuSettingFile::MenuSettingFile(
|
MenuSettingFile::MenuSettingFile(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description,
|
const string &name, const string &description,
|
||||||
string *value, const string &filter_)
|
string *value, const string &filter_)
|
||||||
: MenuSettingStringBase(gmenu2x, name, description, value)
|
: MenuSettingStringBase(gmenu2x, name, description, value)
|
||||||
, ts(ts_)
|
|
||||||
, filter(filter_)
|
, filter(filter_)
|
||||||
{
|
{
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
gmenu2x, "skin:imgs/buttons/cancel.png",
|
||||||
gmenu2x.tr["Clear"],
|
gmenu2x.tr["Clear"],
|
||||||
bind(&MenuSettingFile::clear, this))));
|
bind(&MenuSettingFile::clear, this))));
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
gmenu2x, "skin:imgs/buttons/accept.png",
|
||||||
gmenu2x.tr["Select"],
|
gmenu2x.tr["Select"],
|
||||||
bind(&MenuSettingFile::edit, this))));
|
bind(&MenuSettingFile::edit, this))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingFile::edit()
|
void MenuSettingFile::edit()
|
||||||
{
|
{
|
||||||
FileDialog fd(gmenu2x, ts, description, filter, value());
|
FileDialog fd(gmenu2x, description, filter, value());
|
||||||
if (fd.exec()) {
|
if (fd.exec()) {
|
||||||
setValue(fd.getPath() + "/" + fd.getFile());
|
setValue(fd.getPath() + "/" + fd.getFile());
|
||||||
}
|
}
|
||||||
|
@ -22,18 +22,15 @@
|
|||||||
|
|
||||||
#include "menusettingstringbase.h"
|
#include "menusettingstringbase.h"
|
||||||
|
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class MenuSettingFile : public MenuSettingStringBase {
|
class MenuSettingFile : public MenuSettingStringBase {
|
||||||
protected:
|
protected:
|
||||||
virtual void edit();
|
virtual void edit();
|
||||||
|
|
||||||
Touchscreen &ts;
|
|
||||||
std::string filter;
|
std::string filter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingFile(
|
MenuSettingFile(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const std::string &name, const std::string &description,
|
const std::string &name, const std::string &description,
|
||||||
std::string *value, const std::string &filter = "");
|
std::string *value, const std::string &filter = "");
|
||||||
virtual ~MenuSettingFile() {}
|
virtual ~MenuSettingFile() {}
|
||||||
|
@ -27,15 +27,15 @@
|
|||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
MenuSettingImage::MenuSettingImage(
|
MenuSettingImage::MenuSettingImage(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description,
|
const string &name, const string &description,
|
||||||
string *value, const string &filter)
|
string *value, const string &filter)
|
||||||
: MenuSettingFile(gmenu2x, ts, name, description, value, filter)
|
: MenuSettingFile(gmenu2x, name, description, value, filter)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingImage::edit() {
|
void MenuSettingImage::edit() {
|
||||||
ImageDialog id(gmenu2x, ts, description, filter, value());
|
ImageDialog id(gmenu2x, description, filter, value());
|
||||||
if (id.exec()) setValue(id.getPath() + "/" + id.getFile());
|
if (id.exec()) setValue(id.getPath() + "/" + id.getFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ protected:
|
|||||||
virtual void edit();
|
virtual void edit();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingImage(GMenu2X& gmenu2x, Touchscreen &ts,
|
MenuSettingImage(GMenu2X& gmenu2x,
|
||||||
const std::string &name, const std::string &description,
|
const std::string &name, const std::string &description,
|
||||||
std::string *value, const std::string &filter = "");
|
std::string *value, const std::string &filter = "");
|
||||||
virtual ~MenuSettingImage() {}
|
virtual ~MenuSettingImage() {}
|
||||||
|
@ -33,7 +33,7 @@ using std::stringstream;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
MenuSettingInt::MenuSettingInt(
|
MenuSettingInt::MenuSettingInt(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description,
|
const string &name, const string &description,
|
||||||
int *value, int min, int max, int increment)
|
int *value, int min, int max, int increment)
|
||||||
: MenuSetting(gmenu2x, name, description)
|
: MenuSetting(gmenu2x, name, description)
|
||||||
@ -50,17 +50,17 @@ MenuSettingInt::MenuSettingInt(
|
|||||||
IconButton::Action actionDec = bind(&MenuSettingInt::dec, this);
|
IconButton::Action actionDec = bind(&MenuSettingInt::dec, this);
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/l.png",
|
gmenu2x, "skin:imgs/buttons/l.png",
|
||||||
"", actionDec)));
|
"", actionDec)));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/left.png",
|
gmenu2x, "skin:imgs/buttons/left.png",
|
||||||
gmenu2x.tr["Decrease"], actionDec)));
|
gmenu2x.tr["Decrease"], actionDec)));
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/r.png",
|
gmenu2x, "skin:imgs/buttons/r.png",
|
||||||
"", actionInc)));
|
"", actionInc)));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/right.png",
|
gmenu2x, "skin:imgs/buttons/right.png",
|
||||||
gmenu2x.tr["Increase"], actionInc)));
|
gmenu2x.tr["Increase"], actionInc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
#include "menusetting.h"
|
#include "menusetting.h"
|
||||||
#include "inputmanager.h"
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class MenuSettingInt : public MenuSetting {
|
class MenuSettingInt : public MenuSetting {
|
||||||
private:
|
private:
|
||||||
int originalValue;
|
int originalValue;
|
||||||
@ -38,7 +36,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingInt(
|
MenuSettingInt(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const std::string &name, const std::string &description,
|
const std::string &name, const std::string &description,
|
||||||
int *value, int min, int max, int increment = 1);
|
int *value, int min, int max, int increment = 1);
|
||||||
virtual ~MenuSettingInt() {}
|
virtual ~MenuSettingInt() {}
|
||||||
|
@ -31,7 +31,7 @@ using std::vector;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
MenuSettingMultiString::MenuSettingMultiString(
|
MenuSettingMultiString::MenuSettingMultiString(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description,
|
const string &name, const string &description,
|
||||||
string *value, const vector<string> *choices_)
|
string *value, const vector<string> *choices_)
|
||||||
: MenuSettingStringBase(gmenu2x, name, description, value)
|
: MenuSettingStringBase(gmenu2x, name, description, value)
|
||||||
@ -40,10 +40,10 @@ MenuSettingMultiString::MenuSettingMultiString(
|
|||||||
setSel(find(choices->begin(), choices->end(), *value) - choices->begin());
|
setSel(find(choices->begin(), choices->end(), *value) - choices->begin());
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/left.png", "",
|
gmenu2x, "skin:imgs/buttons/left.png", "",
|
||||||
bind(&MenuSettingMultiString::decSel, this))));
|
bind(&MenuSettingMultiString::decSel, this))));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/right.png",
|
gmenu2x, "skin:imgs/buttons/right.png",
|
||||||
gmenu2x.tr["Change value"],
|
gmenu2x.tr["Change value"],
|
||||||
bind(&MenuSettingMultiString::incSel, this))));
|
bind(&MenuSettingMultiString::incSel, this))));
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class MenuSettingMultiString : public MenuSettingStringBase {
|
class MenuSettingMultiString : public MenuSettingStringBase {
|
||||||
private:
|
private:
|
||||||
virtual void edit() {
|
virtual void edit() {
|
||||||
@ -42,7 +40,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingMultiString(
|
MenuSettingMultiString(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const std::string &name, const std::string &description,
|
const std::string &name, const std::string &description,
|
||||||
std::string *value, const std::vector<std::string> *choices);
|
std::string *value, const std::vector<std::string> *choices);
|
||||||
virtual ~MenuSettingMultiString() {};
|
virtual ~MenuSettingMultiString() {};
|
||||||
|
@ -34,10 +34,9 @@ using std::unique_ptr;
|
|||||||
constexpr unsigned int COMPONENT_WIDTH = 28;
|
constexpr unsigned int COMPONENT_WIDTH = 28;
|
||||||
|
|
||||||
MenuSettingRGBA::MenuSettingRGBA(
|
MenuSettingRGBA::MenuSettingRGBA(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description, RGBAColor *value)
|
const string &name, const string &description, RGBAColor *value)
|
||||||
: MenuSetting(gmenu2x, name, description)
|
: MenuSetting(gmenu2x, name, description)
|
||||||
, ts(ts_)
|
|
||||||
{
|
{
|
||||||
edit = false;
|
edit = false;
|
||||||
|
|
||||||
@ -66,19 +65,6 @@ void MenuSettingRGBA::draw(int valueX, int y, int h) {
|
|||||||
font->write(s, strA, valueX + h + COMPONENT_WIDTH * 4 - 2, y, Font::HAlignRight, Font::VAlignTop);
|
font->write(s, strA, valueX + h + COMPONENT_WIDTH * 4 - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingRGBA::handleTS(int valueX, int y, int h) {
|
|
||||||
if (ts.pressed()) {
|
|
||||||
for (int i=0; i<4; i++) {
|
|
||||||
if (i!=selPart && ts.inRect(valueX + h + i * COMPONENT_WIDTH,y,COMPONENT_WIDTH,h)) {
|
|
||||||
selPart = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuSetting::handleTS(valueX, y, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MenuSettingRGBA::handleButtonPress(InputManager::Button button)
|
bool MenuSettingRGBA::handleButtonPress(InputManager::Button button)
|
||||||
{
|
{
|
||||||
if (edit) {
|
if (edit) {
|
||||||
@ -230,14 +216,14 @@ void MenuSettingRGBA::updateButtonBox()
|
|||||||
{
|
{
|
||||||
buttonBox.clear();
|
buttonBox.clear();
|
||||||
if (edit) {
|
if (edit) {
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/l.png")));
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/l.png")));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png", gmenu2x.tr["Decrease"])));
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/left.png", gmenu2x.tr["Decrease"])));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/r.png")));
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/r.png")));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x.tr["Increase"])));
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x.tr["Increase"])));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x.tr["Confirm"])));
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x.tr["Confirm"])));
|
||||||
} else {
|
} else {
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png")));
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/left.png")));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x.tr["Change color component"])));
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x.tr["Change color component"])));
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x.tr["Edit"])));
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x.tr["Edit"])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,9 @@
|
|||||||
#include "inputmanager.h"
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class GMenu2X;
|
class GMenu2X;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class MenuSettingRGBA : public MenuSetting {
|
class MenuSettingRGBA : public MenuSetting {
|
||||||
private:
|
private:
|
||||||
Touchscreen &ts;
|
|
||||||
unsigned short selPart;
|
unsigned short selPart;
|
||||||
std::string strR, strG, strB, strA;
|
std::string strR, strG, strB, strA;
|
||||||
RGBAColor originalValue;
|
RGBAColor originalValue;
|
||||||
@ -47,13 +45,12 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingRGBA(
|
MenuSettingRGBA(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
GMenu2X& gmenu2x,
|
||||||
const std::string &name, const std::string &description,
|
const std::string &name, const std::string &description,
|
||||||
RGBAColor *value);
|
RGBAColor *value);
|
||||||
virtual ~MenuSettingRGBA() {};
|
virtual ~MenuSettingRGBA() {};
|
||||||
|
|
||||||
virtual void draw(int valueX, int y, int h);
|
virtual void draw(int valueX, int y, int h);
|
||||||
virtual void handleTS(int valueX, int y, int h);
|
|
||||||
virtual bool handleButtonPress(InputManager::Button button);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual void drawSelected(int valueX, int y, int h);
|
virtual void drawSelected(int valueX, int y, int h);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
@ -29,21 +29,20 @@ using std::string;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
MenuSettingString::MenuSettingString(
|
MenuSettingString::MenuSettingString(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
GMenu2X& gmenu2x,
|
||||||
const string &name, const string &description, string *value,
|
const string &name, const string &description, string *value,
|
||||||
const string &diagTitle_, const string &diagIcon_)
|
const string &diagTitle_, const string &diagIcon_)
|
||||||
: MenuSettingStringBase(gmenu2x, name, description, value)
|
: MenuSettingStringBase(gmenu2x, name, description, value)
|
||||||
, ts(ts_)
|
|
||||||
, diagTitle(diagTitle_)
|
, diagTitle(diagTitle_)
|
||||||
, diagIcon(diagIcon_)
|
, diagIcon(diagIcon_)
|
||||||
{
|
{
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
gmenu2x, "skin:imgs/buttons/cancel.png",
|
||||||
gmenu2x.tr["Clear"],
|
gmenu2x.tr["Clear"],
|
||||||
bind(&MenuSettingString::clear, this))));
|
bind(&MenuSettingString::clear, this))));
|
||||||
|
|
||||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
gmenu2x, "skin:imgs/buttons/accept.png",
|
||||||
gmenu2x.tr["Edit"],
|
gmenu2x.tr["Edit"],
|
||||||
bind(&MenuSettingString::edit, this))));
|
bind(&MenuSettingString::edit, this))));
|
||||||
}
|
}
|
||||||
@ -51,7 +50,6 @@ MenuSettingString::MenuSettingString(
|
|||||||
void MenuSettingString::edit()
|
void MenuSettingString::edit()
|
||||||
{
|
{
|
||||||
InputDialog id(
|
InputDialog id(
|
||||||
gmenu2x, gmenu2x.input, ts,
|
gmenu2x, gmenu2x.input, description, value(), diagTitle, diagIcon);
|
||||||
description, value(), diagTitle, diagIcon);
|
|
||||||
if (id.exec()) setValue(id.getInput());
|
if (id.exec()) setValue(id.getInput());
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,7 @@
|
|||||||
|
|
||||||
#include "menusettingstringbase.h"
|
#include "menusettingstringbase.h"
|
||||||
|
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class MenuSettingString : public MenuSettingStringBase {
|
class MenuSettingString : public MenuSettingStringBase {
|
||||||
private:
|
|
||||||
Touchscreen &ts;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void edit();
|
virtual void edit();
|
||||||
|
|
||||||
@ -35,7 +30,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingString(
|
MenuSettingString(
|
||||||
GMenu2X& gmenu2x, Touchscreen &ts, const std::string &name,
|
GMenu2X& gmenu2x, const std::string &name,
|
||||||
const std::string &description, std::string *value,
|
const std::string &description, std::string *value,
|
||||||
const std::string &diagTitle = "",
|
const std::string &diagTitle = "",
|
||||||
const std::string &diagIcon = "");
|
const std::string &diagIcon = "");
|
||||||
|
@ -28,11 +28,10 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(
|
SettingsDialog::SettingsDialog(
|
||||||
GMenu2X& gmenu2x, InputManager &inputMgr_, Touchscreen &ts_,
|
GMenu2X& gmenu2x, InputManager &inputMgr_,
|
||||||
const string &text_, const string &icon)
|
const string &text_, const string &icon)
|
||||||
: Dialog(gmenu2x)
|
: Dialog(gmenu2x)
|
||||||
, inputMgr(inputMgr_)
|
, inputMgr(inputMgr_)
|
||||||
, ts(ts_)
|
|
||||||
, text(text_)
|
, text(text_)
|
||||||
{
|
{
|
||||||
if (!icon.empty() && gmenu2x.sc[icon] != NULL) {
|
if (!icon.empty() && gmenu2x.sc[icon] != NULL) {
|
||||||
@ -46,22 +45,10 @@ bool SettingsDialog::exec() {
|
|||||||
OffscreenSurface bg(*gmenu2x.bg);
|
OffscreenSurface bg(*gmenu2x.bg);
|
||||||
bg.convertToDisplayFormat();
|
bg.convertToDisplayFormat();
|
||||||
|
|
||||||
bool close = false, ts_pressed = false;
|
bool close = false;
|
||||||
uint i, sel = 0, firstElement = 0;
|
uint i, sel = 0, firstElement = 0;
|
||||||
|
|
||||||
const int topBarHeight = gmenu2x.skinConfInt["topBarHeight"];
|
const int topBarHeight = gmenu2x.skinConfInt["topBarHeight"];
|
||||||
SDL_Rect clipRect = {
|
|
||||||
0,
|
|
||||||
static_cast<Sint16>(topBarHeight + 1),
|
|
||||||
static_cast<Uint16>(gmenu2x.resX - 9),
|
|
||||||
static_cast<Uint16>(gmenu2x.resY - topBarHeight - 25)
|
|
||||||
};
|
|
||||||
SDL_Rect touchRect = {
|
|
||||||
2,
|
|
||||||
static_cast<Sint16>(topBarHeight + 4),
|
|
||||||
static_cast<Uint16>(gmenu2x.resX - 12),
|
|
||||||
static_cast<Uint16>(clipRect.h)
|
|
||||||
};
|
|
||||||
uint rowHeight = gmenu2x.font->getLineSpacing() + 1; // gp2x=15+1 / pandora=19+1
|
uint rowHeight = gmenu2x.font->getLineSpacing() + 1; // gp2x=15+1 / pandora=19+1
|
||||||
uint numRows = (gmenu2x.resY - topBarHeight - 20) / rowHeight;
|
uint numRows = (gmenu2x.resY - topBarHeight - 20) / rowHeight;
|
||||||
|
|
||||||
@ -73,8 +60,6 @@ bool SettingsDialog::exec() {
|
|||||||
while (!close) {
|
while (!close) {
|
||||||
OutputSurface& s = *gmenu2x.s;
|
OutputSurface& s = *gmenu2x.s;
|
||||||
|
|
||||||
if (ts.available()) ts.poll();
|
|
||||||
|
|
||||||
bg.blit(s, 0, 0);
|
bg.blit(s, 0, 0);
|
||||||
|
|
||||||
gmenu2x.drawTopBar(s);
|
gmenu2x.drawTopBar(s);
|
||||||
@ -93,22 +78,9 @@ bool SettingsDialog::exec() {
|
|||||||
//selected option
|
//selected option
|
||||||
settings[sel]->drawSelected(maxNameWidth + 15, iY, rowHeight);
|
settings[sel]->drawSelected(maxNameWidth + 15, iY, rowHeight);
|
||||||
|
|
||||||
if (ts_pressed && !ts.pressed()) {
|
|
||||||
ts_pressed = false;
|
|
||||||
}
|
|
||||||
if (ts.available() && ts.pressed() && !ts.inRect(touchRect)) {
|
|
||||||
ts_pressed = false;
|
|
||||||
}
|
|
||||||
for (i=firstElement; i<settings.size() && i<firstElement+numRows; i++) {
|
for (i=firstElement; i<settings.size() && i<firstElement+numRows; i++) {
|
||||||
iY = i-firstElement;
|
iY = i-firstElement;
|
||||||
settings[i]->draw(maxNameWidth + 15, iY * rowHeight + topBarHeight + 2, rowHeight);
|
settings[i]->draw(maxNameWidth + 15, iY * rowHeight + topBarHeight + 2, rowHeight);
|
||||||
if (ts.available() && ts.pressed() && ts.inRect(
|
|
||||||
touchRect.x, touchRect.y + (iY * rowHeight),
|
|
||||||
touchRect.w, rowHeight
|
|
||||||
)) {
|
|
||||||
ts_pressed = true;
|
|
||||||
sel = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gmenu2x.drawScrollBar(numRows, settings.size(), firstElement);
|
gmenu2x.drawScrollBar(numRows, settings.size(), firstElement);
|
||||||
@ -117,7 +89,6 @@ bool SettingsDialog::exec() {
|
|||||||
writeSubTitle(s, settings[sel]->getDescription());
|
writeSubTitle(s, settings[sel]->getDescription());
|
||||||
|
|
||||||
s.flip();
|
s.flip();
|
||||||
settings[sel]->handleTS(maxNameWidth + 15, iY, rowHeight);
|
|
||||||
|
|
||||||
InputManager::Button button = inputMgr.waitForPressedButton();
|
InputManager::Button button = inputMgr.waitForPressedButton();
|
||||||
if (!settings[sel]->handleButtonPress(button)) {
|
if (!settings[sel]->handleButtonPress(button)) {
|
||||||
|
@ -30,17 +30,15 @@
|
|||||||
|
|
||||||
class InputManager;
|
class InputManager;
|
||||||
class MenuSetting;
|
class MenuSetting;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class SettingsDialog : protected Dialog {
|
class SettingsDialog : protected Dialog {
|
||||||
private:
|
private:
|
||||||
InputManager &inputMgr;
|
InputManager &inputMgr;
|
||||||
Touchscreen &ts;
|
|
||||||
std::vector<std::unique_ptr<MenuSetting>> settings;
|
std::vector<std::unique_ptr<MenuSetting>> settings;
|
||||||
std::string text, icon;
|
std::string text, icon;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SettingsDialog(GMenu2X& gmenu2x, InputManager &inputMgr, Touchscreen &ts,
|
SettingsDialog(GMenu2X& gmenu2x, InputManager &inputMgr,
|
||||||
const std::string &text,
|
const std::string &text,
|
||||||
const std::string &icon = "skin:sections/settings.png");
|
const std::string &icon = "skin:sections/settings.png");
|
||||||
|
|
||||||
|
@ -1,110 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* Copyright (C) 2006 by Massimiliano Torromeo *
|
|
||||||
* massimiliano.torromeo@gmail.com *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
* GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program; if not, write to the *
|
|
||||||
* Free Software Foundation, Inc., *
|
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#include "touchscreen.h"
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
|
|
||||||
Touchscreen::Touchscreen() {
|
|
||||||
calibrated = false;
|
|
||||||
wasPressed = false;
|
|
||||||
_handled = false;
|
|
||||||
x = 0;
|
|
||||||
y = 0;
|
|
||||||
startX = 0;
|
|
||||||
startY = 0;
|
|
||||||
event.x = 0;
|
|
||||||
event.y = 0;
|
|
||||||
event.pressure = 0;
|
|
||||||
ts_fd = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Touchscreen::~Touchscreen() {
|
|
||||||
if (ts_fd > 0) {
|
|
||||||
close(ts_fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Touchscreen::calibrate() {
|
|
||||||
if (event.pressure == 0) {
|
|
||||||
calibX = ((event.x - 200) * 320 / 3750) / 4;
|
|
||||||
calibY = (((event.y - 200) * 240 / 3750)) / 4;
|
|
||||||
calibrated = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Touchscreen::poll() {
|
|
||||||
wasPressed = pressed();
|
|
||||||
SDL_PumpEvents();
|
|
||||||
int mx, my;
|
|
||||||
if (SDL_GetMouseState(&mx,&my) && SDL_BUTTON(1)) {
|
|
||||||
x = mx;
|
|
||||||
y = my;
|
|
||||||
event.pressure = 1;
|
|
||||||
} else {
|
|
||||||
event.pressure = 0;
|
|
||||||
}
|
|
||||||
_handled = false;
|
|
||||||
|
|
||||||
if (!wasPressed && pressed()) {
|
|
||||||
startX = x;
|
|
||||||
startY = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Touchscreen::handled() {
|
|
||||||
return _handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Touchscreen::setHandled() {
|
|
||||||
wasPressed = false;
|
|
||||||
_handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Touchscreen::pressed() {
|
|
||||||
return !_handled && event.pressure > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Touchscreen::released() {
|
|
||||||
return !pressed() && wasPressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Touchscreen::inRect(int ix, int iy, int iw, int ih) {
|
|
||||||
return !_handled &&
|
|
||||||
(y >= iy) && (y <= iy + ih) && (x >= ix) && (x <= ix + iw);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Touchscreen::inRect(SDL_Rect r) {
|
|
||||||
return inRect(r.x, r.y, r.w, r.h);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Touchscreen::startedInRect(int ix, int iy, int iw, int ih) {
|
|
||||||
return !_handled &&
|
|
||||||
(startY >= iy) && (startY <= iy + ih) &&
|
|
||||||
(startX >= ix) && (startX <= ix + iw);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Touchscreen::startedInRect(SDL_Rect r) {
|
|
||||||
return startedInRect(r.x, r.y, r.w, r.h);
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* Copyright (C) 2006 by Massimiliano Torromeo *
|
|
||||||
* massimiliano.torromeo@gmail.com *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
* GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program; if not, write to the *
|
|
||||||
* Free Software Foundation, Inc., *
|
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef TOUCHSCREEN_H
|
|
||||||
#define TOUCHSCREEN_H
|
|
||||||
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t pressure;
|
|
||||||
uint16_t x;
|
|
||||||
uint16_t y;
|
|
||||||
uint16_t pad;
|
|
||||||
struct timeval stamp;
|
|
||||||
} TS_EVENT;
|
|
||||||
|
|
||||||
class Touchscreen {
|
|
||||||
public:
|
|
||||||
Touchscreen();
|
|
||||||
~Touchscreen();
|
|
||||||
|
|
||||||
bool available() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool poll();
|
|
||||||
bool pressed();
|
|
||||||
bool released();
|
|
||||||
|
|
||||||
bool handled();
|
|
||||||
void setHandled();
|
|
||||||
|
|
||||||
bool inRect(int x, int y, int w, int h);
|
|
||||||
bool inRect(SDL_Rect r);
|
|
||||||
bool startedInRect(int x, int y, int w, int h);
|
|
||||||
bool startedInRect(SDL_Rect r);
|
|
||||||
|
|
||||||
int getX() { return x; }
|
|
||||||
int getY() { return y; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int ts_fd;
|
|
||||||
bool calibrated, _handled;
|
|
||||||
TS_EVENT event;
|
|
||||||
int calibX, calibY;
|
|
||||||
int x, y, startX, startY;
|
|
||||||
bool wasPressed;
|
|
||||||
|
|
||||||
void calibrate(/*TS_EVENT event*/);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -32,9 +32,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
WallpaperDialog::WallpaperDialog(GMenu2X& gmenu2x, Touchscreen &ts_)
|
WallpaperDialog::WallpaperDialog(GMenu2X& gmenu2x)
|
||||||
: Dialog(gmenu2x)
|
: Dialog(gmenu2x)
|
||||||
, ts(ts_)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,8 +62,8 @@ bool WallpaperDialog::exec()
|
|||||||
uint i, selected = 0, firstElement = 0, iY;
|
uint i, selected = 0, firstElement = 0, iY;
|
||||||
|
|
||||||
ButtonBox buttonbox;
|
ButtonBox buttonbox;
|
||||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x.tr["Select"])));
|
buttonbox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x.tr["Select"])));
|
||||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x.tr["Exit"])));
|
buttonbox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, "skin:imgs/buttons/cancel.png", gmenu2x.tr["Exit"])));
|
||||||
|
|
||||||
unsigned int top, height;
|
unsigned int top, height;
|
||||||
tie(top, height) = gmenu2x.getContentArea();
|
tie(top, height) = gmenu2x.getContentArea();
|
||||||
|
@ -25,14 +25,9 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
class WallpaperDialog : protected Dialog {
|
class WallpaperDialog : protected Dialog {
|
||||||
private:
|
|
||||||
Touchscreen &ts;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WallpaperDialog(GMenu2X& gmenu2x, Touchscreen &ts);
|
WallpaperDialog(GMenu2X& gmenu2x);
|
||||||
std::string wallpaper;
|
std::string wallpaper;
|
||||||
|
|
||||||
bool exec();
|
bool exec();
|
||||||
|
Loading…
Reference in New Issue
Block a user