1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-26 09:49:40 +02:00

Made GMenu2X::ts private.

Pass Touchscreen reference to constructors instead of pulling it from
the GMenu2X class.
This commit is contained in:
Maarten ter Huurne 2011-12-23 14:03:05 +01:00
parent 944ab86f9c
commit 1ad6b2f25a
40 changed files with 243 additions and 182 deletions

View File

@ -9,9 +9,11 @@
using namespace fastdelegate; using namespace fastdelegate;
using std::string; using std::string;
BrowseDialog::BrowseDialog(GMenu2X *gmenu2x, const string &title, BrowseDialog::BrowseDialog(
const string &subtitle) GMenu2X *gmenu2x, Touchscreen &ts_,
const string &title, const string &subtitle)
: Dialog(gmenu2x) : Dialog(gmenu2x)
, ts(ts_)
, title(title) , title(title)
, subtitle(subtitle) , subtitle(subtitle)
, ts_pressed(false) , ts_pressed(false)
@ -19,20 +21,20 @@ BrowseDialog::BrowseDialog(GMenu2X *gmenu2x, const string &title,
{ {
IconButton *btn; IconButton *btn;
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/left.png")); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png"));
btn = new IconButton(gmenu2x, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Up one folder"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Up one folder"]);
btn->setAction(MakeDelegate(this, &BrowseDialog::directoryUp)); btn->setAction(MakeDelegate(this, &BrowseDialog::directoryUp));
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x->tr["Enter folder"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Enter folder"]);
btn->setAction(MakeDelegate(this, &BrowseDialog::directoryEnter)); btn->setAction(MakeDelegate(this, &BrowseDialog::directoryEnter));
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/start.png", gmenu2x->tr["Confirm"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/start.png", gmenu2x->tr["Confirm"]);
btn->setAction(MakeDelegate(this, &BrowseDialog::confirm)); btn->setAction(MakeDelegate(this, &BrowseDialog::confirm));
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/select.png", gmenu2x->tr["Exit"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/select.png", gmenu2x->tr["Exit"]);
btn->setAction(MakeDelegate(this, &BrowseDialog::quit)); btn->setAction(MakeDelegate(this, &BrowseDialog::quit));
buttonBox.add(btn); buttonBox.add(btn);
@ -64,7 +66,7 @@ bool BrowseDialog::exec()
selected = 0; selected = 0;
close = false; close = false;
while (!close) { while (!close) {
if (gmenu2x->ts.available()) gmenu2x->ts.poll(); if (ts.available()) ts.poll();
paint(); paint();
@ -104,14 +106,14 @@ void BrowseDialog::handleInput()
InputManager::Button button = gmenu2x->input.waitForPressedButton(); InputManager::Button button = gmenu2x->input.waitForPressedButton();
BrowseDialog::Action action; BrowseDialog::Action action;
if (ts_pressed && !gmenu2x->ts.pressed()) { if (ts_pressed && !ts.pressed()) {
action = BrowseDialog::ACT_SELECT; action = BrowseDialog::ACT_SELECT;
ts_pressed = false; ts_pressed = false;
} else { } else {
action = getAction(button); action = getAction(button);
} }
if (gmenu2x->ts.available() && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false; 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;
@ -250,7 +252,7 @@ void BrowseDialog::paint()
icon->blit(gmenu2x->s, 5, offsetY); icon->blit(gmenu2x->s, 5, offsetY);
gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, ASFont::HAlignLeft, ASFont::VAlignMiddle); gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, ASFont::HAlignLeft, ASFont::VAlignMiddle);
if (gmenu2x->ts.available() && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) { if (ts.available() && ts.pressed() && ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) {
ts_pressed = true; ts_pressed = true;
selected = i; selected = i;
} }

View File

@ -29,10 +29,13 @@
#include <SDL.h> #include <SDL.h>
#include <string> #include <string>
class Touchscreen;
class BrowseDialog : protected Dialog { class BrowseDialog : protected Dialog {
protected: protected:
BrowseDialog(GMenu2X *gmenu2x, const std::string &title, BrowseDialog(
const std::string &subtitle); GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &title, const std::string &subtitle);
virtual ~BrowseDialog(); virtual ~BrowseDialog();
void setPath(const std::string &path) { void setPath(const std::string &path) {
@ -55,6 +58,7 @@ private:
ACT_CONFIRM, ACT_CONFIRM,
}; };
Touchscreen &ts;
bool close, result; bool close, result;
std::string title; std::string title;

View File

@ -29,10 +29,8 @@ typedef fastdelegate::FastDelegate0<> ButtonAction;
class Touchscreen; class Touchscreen;
class Button { class Button {
private:
Touchscreen &ts;
protected: protected:
Touchscreen &ts;
ButtonAction action; ButtonAction action;
SDL_Rect rect; SDL_Rect rect;
bool doubleClick; bool doubleClick;

View File

@ -24,8 +24,10 @@
using namespace std; using namespace std;
DirDialog::DirDialog(GMenu2X *gmenu2x, const string &text, const string &dir) DirDialog::DirDialog(
: BrowseDialog(gmenu2x, "Directory Browser", text) GMenu2X *gmenu2x, Touchscreen &ts,
const string &text, const string &dir)
: BrowseDialog(gmenu2x, ts, "Directory Browser", text)
{ {
fl = new FileLister(dir, true, false); fl = new FileLister(dir, true, false);
} }

View File

@ -23,12 +23,11 @@
#include "browsedialog.h" #include "browsedialog.h"
#include <string>
class DirDialog : public BrowseDialog { class DirDialog : public BrowseDialog {
public: public:
DirDialog(GMenu2X *gmenu2x, const std::string &text, DirDialog(
const std::string &dir=""); GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &text, const std::string &dir = "");
~DirDialog(); ~DirDialog();
}; };

View File

@ -25,9 +25,10 @@
using namespace std; using namespace std;
FileDialog::FileDialog(GMenu2X *gmenu2x, const string &text, FileDialog::FileDialog(
const string &filter, const string &file, const string &title) : GMenu2X *gmenu2x, Touchscreen &ts, const string &text,
BrowseDialog(gmenu2x, title, text) const string &filter, const string &file, const string &title)
: BrowseDialog(gmenu2x, ts, title, text)
{ {
string path(CARD_ROOT); string path(CARD_ROOT);
if (!file.empty()) { if (!file.empty()) {

View File

@ -23,11 +23,10 @@
#include "browsedialog.h" #include "browsedialog.h"
#include <string>
class FileDialog : public BrowseDialog { class FileDialog : public BrowseDialog {
public: public:
FileDialog(GMenu2X *gmenu2x, const std::string &text, FileDialog(
GMenu2X *gmenu2x, Touchscreen &ts, 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");
virtual ~FileDialog(); virtual ~FileDialog();

View File

@ -558,7 +558,7 @@ void GMenu2X::initFont() {
void GMenu2X::initMenu() { void GMenu2X::initMenu() {
//Menu structure handler //Menu structure handler
menu = new Menu(this); menu = new Menu(this, ts);
for (uint i=0; i<menu->getSections().size(); i++) { for (uint i=0; i<menu->getSections().size(); i++) {
//Add virtual links in the applications section //Add virtual links in the applications section
if (menu->getSections()[i]=="applications") { if (menu->getSections()[i]=="applications") {
@ -983,7 +983,7 @@ void GMenu2X::main() {
string fps = ""; string fps = "";
#endif #endif
IconButton btnContextMenu(this,"skin:imgs/menu.png"); IconButton btnContextMenu(this, ts, "skin:imgs/menu.png");
btnContextMenu.setPosition(resX-38, bottomBarIconY); btnContextMenu.setPosition(resX-38, bottomBarIconY);
btnContextMenu.setAction(MakeDelegate(this, &GMenu2X::contextMenu)); btnContextMenu.setAction(MakeDelegate(this, &GMenu2X::contextMenu));
@ -1243,7 +1243,7 @@ void GMenu2X::main() {
} }
void GMenu2X::explorer() { void GMenu2X::explorer() {
FileDialog fd(this,tr["Select an application"],".gpu,.dge,.sh,"); FileDialog fd(this, ts, tr["Select an application"], ".gpu,.dge,.sh,");
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();
@ -1287,21 +1287,21 @@ void GMenu2X::options() {
encodings.push_back("PAL"); encodings.push_back("PAL");
SettingsDialog sd(this, input, ts, tr["Settings"]); SettingsDialog sd(this, input, ts, tr["Settings"]);
sd.addSetting(new MenuSettingMultiString(this,tr["Language"],tr["Set the language used by GMenu2X"],&lang,&fl_tr.getFiles())); sd.addSetting(new MenuSettingMultiString(this, ts, tr["Language"], tr["Set the language used by GMenu2X"], &lang, &fl_tr.getFiles()));
sd.addSetting(new MenuSettingBool(this,tr["Save last selection"],tr["Save the last selected link and section on exit"],&confInt["saveSelection"])); sd.addSetting(new MenuSettingBool(this, ts, tr["Save last selection"], tr["Save the last selected link and section on exit"], &confInt["saveSelection"]));
sd.addSetting(new MenuSettingInt(this,tr["Clock for GMenu2X"],tr["Set the cpu working frequency when running GMenu2X"],&confInt["menuClock"],cpuFreqMin,cpuFreqSafeMax,cpuFreqMultiple)); sd.addSetting(new MenuSettingInt(this, ts, tr["Clock for GMenu2X"], tr["Set the cpu working frequency when running GMenu2X"], &confInt["menuClock"], cpuFreqMin, cpuFreqSafeMax, cpuFreqMultiple));
sd.addSetting(new MenuSettingInt(this,tr["Maximum overclock"],tr["Set the maximum overclock for launching links"],&confInt["maxClock"],cpuFreqMin,cpuFreqMax,cpuFreqMultiple)); sd.addSetting(new MenuSettingInt(this, ts, tr["Maximum overclock"], tr["Set the maximum overclock for launching links"], &confInt["maxClock"], cpuFreqMin, cpuFreqMax, cpuFreqMultiple));
sd.addSetting(new MenuSettingBool(this,tr["Output logs"],tr["Logs the output of the links. Use the Log Viewer to read them."],&confInt["outputLogs"])); sd.addSetting(new MenuSettingBool(this, ts, tr["Output logs"], tr["Logs the output of the links. Use the Log Viewer to read them."], &confInt["outputLogs"]));
//G //G
sd.addSetting(new MenuSettingInt(this,tr["Lcd Backlight"],tr["Set Lcd Backlight value (default: 100)"],&newBacklight,5,100)); sd.addSetting(new MenuSettingInt(this, ts, tr["Lcd Backlight"], tr["Set Lcd Backlight value (default: 100)"], &newBacklight, 5, 100));
sd.addSetting(new MenuSettingInt(this,tr["Screen Timeout"],tr["Set screen's backlight timeout in seconds"],&confInt["backlightTimeout"],0,120)); sd.addSetting(new MenuSettingInt(this, ts, tr["Screen Timeout"], tr["Set screen's backlight timeout in seconds"], &confInt["backlightTimeout"], 0, 120));
// sd.addSetting(new MenuSettingMultiString(this,tr["Tv-Out encoding"],tr["Encoding of the tv-out signal"],&confStr["tvoutEncoding"],&encodings)); // sd.addSetting(new MenuSettingMultiString(this, ts, tr["Tv-Out encoding"], tr["Encoding of the tv-out signal"], &confStr["tvoutEncoding"], &encodings));
sd.addSetting(new MenuSettingBool(this,tr["Show root"],tr["Show root folder in the file selection dialogs"],&showRootFolder)); sd.addSetting(new MenuSettingBool(this, ts, tr["Show root"], tr["Show root folder in the file selection dialogs"], &showRootFolder));
if (sd.exec() && sd.edited()) { if (sd.exec() && sd.edited()) {
//G //G
if (newBacklight != oldBacklight) setBacklight(newBacklight); if (newBacklight != oldBacklight) setBacklight(newBacklight);
if (curMenuClock!=confInt["menuClock"]) setClock(confInt["menuClock"]); if (curMenuClock != confInt["menuClock"]) setClock(confInt["menuClock"]);
if (confInt["backlightTimeout"] == 0) { if (confInt["backlightTimeout"] == 0) {
if (PowerSaver::isRunning()) if (PowerSaver::isRunning())
@ -1327,17 +1327,17 @@ void GMenu2X::options() {
#ifdef PLATFORM_GP2X #ifdef PLATFORM_GP2X
void GMenu2X::settingsOpen2x() { void GMenu2X::settingsOpen2x() {
SettingsDialog sd(this, input, ts, tr["Open2x Settings"]); SettingsDialog sd(this, input, ts, tr["Open2x Settings"]);
sd.addSetting(new MenuSettingBool(this,tr["USB net on boot"],tr["Allow USB networking to be started at boot time"],&o2x_usb_net_on_boot)); sd.addSetting(new MenuSettingBool(this, ts, tr["USB net on boot"], tr["Allow USB networking to be started at boot time"], &o2x_usb_net_on_boot));
sd.addSetting(new MenuSettingString(this,tr["USB net IP"],tr["IP address to be used for USB networking"],&o2x_usb_net_ip)); sd.addSetting(new MenuSettingString(this, ts, tr["USB net IP"], tr["IP address to be used for USB networking"], &o2x_usb_net_ip));
sd.addSetting(new MenuSettingBool(this,tr["Telnet on boot"],tr["Allow telnet to be started at boot time"],&o2x_telnet_on_boot)); sd.addSetting(new MenuSettingBool(this, ts, tr["Telnet on boot"], tr["Allow telnet to be started at boot time"], &o2x_telnet_on_boot));
sd.addSetting(new MenuSettingBool(this,tr["FTP on boot"],tr["Allow FTP to be started at boot time"],&o2x_ftp_on_boot)); sd.addSetting(new MenuSettingBool(this, ts, tr["FTP on boot"], tr["Allow FTP to be started at boot time"], &o2x_ftp_on_boot));
sd.addSetting(new MenuSettingBool(this,tr["GP2XJOY on boot"],tr["Create a js0 device for GP2X controls"],&o2x_gp2xjoy_on_boot)); sd.addSetting(new MenuSettingBool(this, ts, tr["GP2XJOY on boot"], tr["Create a js0 device for GP2X controls"], &o2x_gp2xjoy_on_boot));
sd.addSetting(new MenuSettingBool(this,tr["USB host on boot"],tr["Allow USB host to be started at boot time"],&o2x_usb_host_on_boot)); sd.addSetting(new MenuSettingBool(this, ts, tr["USB host on boot"], tr["Allow USB host to be started at boot time"], &o2x_usb_host_on_boot));
sd.addSetting(new MenuSettingBool(this,tr["USB HID on boot"],tr["Allow USB HID to be started at boot time"],&o2x_usb_hid_on_boot)); sd.addSetting(new MenuSettingBool(this,ts, tr["USB HID on boot"], tr["Allow USB HID to be started at boot time"], &o2x_usb_hid_on_boot));
sd.addSetting(new MenuSettingBool(this,tr["USB storage on boot"],tr["Allow USB storage to be started at boot time"],&o2x_usb_storage_on_boot)); sd.addSetting(new MenuSettingBool(this, ts, tr["USB storage on boot"], tr["Allow USB storage to be started at boot time"], &o2x_usb_storage_on_boot));
//sd.addSetting(new MenuSettingInt(this,tr["Speaker Mode on boot"],tr["Set Speaker mode. 0 = Mute, 1 = Phones, 2 = Speaker"],&volumeMode,0,2)); //sd.addSetting(new MenuSettingInt(this, ts, tr["Speaker Mode on boot"], tr["Set Speaker mode. 0 = Mute, 1 = Phones, 2 = Speaker"], &volumeMode, 0, 2));
sd.addSetting(new MenuSettingInt(this,tr["Speaker Scaler"],tr["Set the Speaker Mode scaling 0-150\% (default is 100\%)"],&volumeScalerNormal,0,150)); sd.addSetting(new MenuSettingInt(this, ts, tr["Speaker Scaler"], tr["Set the Speaker Mode scaling 0-150\% (default is 100\%)"], &volumeScalerNormal, 0, 150));
sd.addSetting(new MenuSettingInt(this,tr["Headphones Scaler"],tr["Set the Headphones Mode scaling 0-100\% (default is 65\%)"],&volumeScalerPhones,0,100)); sd.addSetting(new MenuSettingInt(this, ts, tr["Headphones Scaler"], tr["Set the Headphones Mode scaling 0-100\% (default is 65\%)"], &volumeScalerPhones, 0, 100));
if (sd.exec() && sd.edited()) { if (sd.exec() && sd.edited()) {
writeConfigOpen2x(); writeConfigOpen2x();
@ -1360,13 +1360,13 @@ void GMenu2X::skinMenu() {
string curSkin = confStr["skin"]; string curSkin = confStr["skin"];
SettingsDialog sd(this, input, ts, tr["Skin"]); SettingsDialog sd(this, input, ts, tr["Skin"]);
sd.addSetting(new MenuSettingMultiString(this,tr["Skin"],tr["Set the skin used by GMenu2X"],&confStr["skin"],&fl_sk.getDirectories())); sd.addSetting(new MenuSettingMultiString(this, ts, tr["Skin"], tr["Set the skin used by GMenu2X"], &confStr["skin"], &fl_sk.getDirectories()));
sd.addSetting(new MenuSettingRGBA(this,tr["Top Bar Color"],tr["Color of the top bar"],&skinConfColors[COLOR_TOP_BAR_BG])); sd.addSetting(new MenuSettingRGBA(this, ts, tr["Top Bar Color"], tr["Color of the top bar"], &skinConfColors[COLOR_TOP_BAR_BG]));
sd.addSetting(new MenuSettingRGBA(this,tr["Bottom Bar Color"],tr["Color of the bottom bar"],&skinConfColors[COLOR_BOTTOM_BAR_BG])); sd.addSetting(new MenuSettingRGBA(this, ts, tr["Bottom Bar Color"], tr["Color of the bottom bar"], &skinConfColors[COLOR_BOTTOM_BAR_BG]));
sd.addSetting(new MenuSettingRGBA(this,tr["Selection Color"],tr["Color of the selection and other interface details"],&skinConfColors[COLOR_SELECTION_BG])); sd.addSetting(new MenuSettingRGBA(this, ts, tr["Selection Color"], tr["Color of the selection and other interface details"], &skinConfColors[COLOR_SELECTION_BG]));
sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Color"],tr["Background color of the message box"],&skinConfColors[COLOR_MESSAGE_BOX_BG])); sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box Color"], tr["Background color of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_BG]));
sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Border Color"],tr["Border color of the message box"],&skinConfColors[COLOR_MESSAGE_BOX_BORDER])); sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box Border Color"], tr["Border color of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_BORDER]));
sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Selection Color"],tr["Color of the selection of the message box"],&skinConfColors[COLOR_MESSAGE_BOX_SELECTION])); sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box Selection Color"], tr["Color of the selection of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_SELECTION]));
if (sd.exec() && sd.edited()) { if (sd.exec() && sd.edited()) {
if (curSkin != confStr["skin"]) { if (curSkin != confStr["skin"]) {
@ -1645,7 +1645,7 @@ void GMenu2X::contextMenu() {
} }
void GMenu2X::changeWallpaper() { void GMenu2X::changeWallpaper() {
WallpaperDialog wp(this); WallpaperDialog wp(this, ts);
if (wp.exec() && confStr["wallpaper"] != wp.wallpaper) { if (wp.exec() && confStr["wallpaper"] != wp.wallpaper) {
confStr["wallpaper"] = wp.wallpaper; confStr["wallpaper"] = wp.wallpaper;
initBG(); initBG();
@ -1654,7 +1654,7 @@ void GMenu2X::changeWallpaper() {
} }
void GMenu2X::addLink() { void GMenu2X::addLink() {
FileDialog fd(this,tr["Select an application"]); FileDialog fd(this, ts, tr["Select an application"]);
if (fd.exec()) { if (fd.exec()) {
ledOn(); ledOn();
menu->addLink(fd.getPath(), fd.getFile()); menu->addLink(fd.getPath(), fd.getFile());
@ -1692,22 +1692,22 @@ void GMenu2X::editLink() {
string diagIcon = menu->selLinkApp()->getIconPath(); string diagIcon = menu->selLinkApp()->getIconPath();
SettingsDialog sd(this, input, ts, diagTitle, diagIcon); SettingsDialog sd(this, input, ts, diagTitle, diagIcon);
sd.addSetting(new MenuSettingString(this,tr["Title"],tr["Link title"],&linkTitle, diagTitle,diagIcon)); sd.addSetting(new MenuSettingString(this, ts, tr["Title"], tr["Link title"], &linkTitle, diagTitle, diagIcon));
sd.addSetting(new MenuSettingString(this,tr["Description"],tr["Link description"],&linkDescription, diagTitle,diagIcon)); sd.addSetting(new MenuSettingString(this, ts, tr["Description"], tr["Link description"], &linkDescription, diagTitle, diagIcon));
sd.addSetting(new MenuSettingMultiString(this,tr["Section"],tr["The section this link belongs to"],&newSection,&menu->getSections())); sd.addSetting(new MenuSettingMultiString(this, ts, tr["Section"], tr["The section this link belongs to"], &newSection, &menu->getSections()));
sd.addSetting(new MenuSettingImage(this,tr["Icon"],tr.translate("Select an icon for the link: $1",linkTitle.c_str(),NULL),&linkIcon,".png,.bmp,.jpg,.jpeg")); sd.addSetting(new MenuSettingImage(this, ts, tr["Icon"], tr.translate("Select an icon for the link: $1", linkTitle.c_str(), NULL), &linkIcon, ".png,.bmp,.jpg,.jpeg"));
sd.addSetting(new MenuSettingFile(this,tr["Manual"],tr["Select a graphic/textual manual or a readme"],&linkManual,".man.png,.txt")); sd.addSetting(new MenuSettingFile(this, ts, tr["Manual"], tr["Select a graphic/textual manual or a readme"], &linkManual, ".man.png,.txt"));
sd.addSetting(new MenuSettingInt(this,tr["Clock (default: 336)"],tr["Cpu clock frequency to set when launching this link"],&linkClock,cpuFreqMin,confInt["maxClock"],cpuFreqMultiple)); sd.addSetting(new MenuSettingInt(this, ts, tr["Clock (default: 336)"], tr["Cpu clock frequency to set when launching this link"], &linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple));
// sd.addSetting(new MenuSettingBool(this,tr["Tweak RAM Timings"],tr["This usually speeds up the application at the cost of stability"],&linkUseRamTimings)); // sd.addSetting(new MenuSettingBool(this, ts, tr["Tweak RAM Timings"], tr["This usually speeds up the application at the cost of stability"], &linkUseRamTimings));
sd.addSetting(new MenuSettingString(this,tr["Parameters"],tr["Parameters to pass to the application"],&linkParams, diagTitle,diagIcon)); sd.addSetting(new MenuSettingString(this, ts, tr["Parameters"], tr["Parameters to pass to the application"], &linkParams, diagTitle, diagIcon));
sd.addSetting(new MenuSettingDir(this,tr["Selector Directory"],tr["Directory to scan for the selector"],&linkSelDir)); sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir));
sd.addSetting(new MenuSettingBool(this,tr["Selector Browser"],tr["Allow the selector to change directory"],&linkSelBrowser)); sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser));
sd.addSetting(new MenuSettingString(this,tr["Selector Filter"],tr["Selector filter (Separate values with a comma)"],&linkSelFilter, diagTitle,diagIcon)); sd.addSetting(new MenuSettingString(this, ts, tr["Selector Filter"], tr["Selector filter (Separate values with a comma)"], &linkSelFilter, diagTitle, diagIcon));
sd.addSetting(new MenuSettingDir(this,tr["Selector Screenshots"],tr["Directory of the screenshots for the selector"],&linkSelScreens)); sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Screenshots"], tr["Directory of the screenshots for the selector"], &linkSelScreens));
sd.addSetting(new MenuSettingFile(this,tr["Selector Aliases"],tr["File containing a list of aliases for the selector"],&linkSelAliases)); sd.addSetting(new MenuSettingFile(this, ts, tr["Selector Aliases"], tr["File containing a list of aliases for the selector"], &linkSelAliases));
//G //G
sd.addSetting(new MenuSettingBool(this,tr["Wrapper"],tr["Explicitly relaunch GMenu2X after execution"],&menu->selLinkApp()->needsWrapperRef())); sd.addSetting(new MenuSettingBool(this, ts, tr["Wrapper"], tr["Explicitly relaunch GMenu2X after execution"], &menu->selLinkApp()->needsWrapperRef()));
sd.addSetting(new MenuSettingBool(this,tr["Don't Leave"],tr["Don't quit GMenu2X when launching this link"],&menu->selLinkApp()->runsInBackgroundRef())); sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &menu->selLinkApp()->runsInBackgroundRef()));
if (sd.exec() && sd.edited()) { if (sd.exec() && sd.edited()) {
ledOn(); ledOn();

View File

@ -64,7 +64,9 @@ typedef std::tr1::unordered_map<std::string, int, std::tr1::hash<std::string> >
class GMenu2X { class GMenu2X {
private: private:
Touchscreen ts;
std::string path; //!< Contains the working directory of GMenu2X std::string path; //!< Contains the working directory of GMenu2X
/*! /*!
Retrieves the free disk space on the sd Retrieves the free disk space on the sd
@return String containing a human readable representation of the free disk space @return String containing a human readable representation of the free disk space
@ -159,7 +161,6 @@ public:
const std::string &getExePath(); const std::string &getExePath();
InputManager input; InputManager input;
Touchscreen ts;
//Configuration hashes //Configuration hashes
ConfStrHash confStr, skinConfStr; ConfStrHash confStr, skinConfStr;

View File

@ -7,9 +7,10 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
IconButton::IconButton(GMenu2X *gmenu2x_, const string &icon, IconButton::IconButton(
const string &label) GMenu2X *gmenu2x_, Touchscreen &ts_,
: Button(gmenu2x_->ts) const string &icon, const string &label)
: Button(ts_)
, gmenu2x(gmenu2x_) , gmenu2x(gmenu2x_)
{ {
this->icon = icon; this->icon = icon;

View File

@ -10,8 +10,8 @@ class Surface;
class IconButton : public Button { class IconButton : public Button {
public: public:
IconButton(GMenu2X *gmenu2x, const std::string &icon, IconButton(GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &label=""); const std::string &icon, const std::string &label = "");
virtual ~IconButton() {}; virtual ~IconButton() {};
virtual void paint(); virtual void paint();

View File

@ -34,9 +34,11 @@
using namespace std; using namespace std;
ImageDialog::ImageDialog(GMenu2X *gmenu2x, const string &text, ImageDialog::ImageDialog(
const string &filter, const string &file) : GMenu2X *gmenu2x, Touchscreen &ts, const string &text,
FileDialog(gmenu2x, text, filter, file, "Image Browser") { const string &filter, const string &file)
: FileDialog(gmenu2x, ts, text, filter, file, "Image Browser")
{
string path; string path;

View File

@ -30,8 +30,9 @@ class ImageDialog : public FileDialog {
protected: protected:
SurfaceCollection previews; SurfaceCollection previews;
public: public:
ImageDialog(GMenu2X *gmenu2x, const std::string &text, ImageDialog(
const std::string &filter="", const std::string &file=""); GMenu2X *gmenu2x, Touchscreen &ts, const std::string &text,
const std::string &filter = "", const std::string &file = "");
virtual ~ImageDialog(); virtual ~ImageDialog();
virtual void beforeFileList(); virtual void beforeFileList();

View File

@ -94,22 +94,22 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_,
setKeyboard(0); setKeyboard(0);
buttonbox = new ButtonBox(gmenu2x); buttonbox = new ButtonBox(gmenu2x);
IconButton *btnBackspace = new IconButton(gmenu2x, IconButton *btnBackspace = new IconButton(gmenu2x, ts,
"skin:imgs/buttons/l.png", gmenu2x->tr["Backspace"]); "skin:imgs/buttons/l.png", gmenu2x->tr["Backspace"]);
btnBackspace->setAction(MakeDelegate(this, &InputDialog::backspace)); btnBackspace->setAction(MakeDelegate(this, &InputDialog::backspace));
buttonbox->add(btnBackspace); buttonbox->add(btnBackspace);
IconButton *btnSpace = new IconButton(gmenu2x, IconButton *btnSpace = new IconButton(gmenu2x, ts,
"skin:imgs/buttons/r.png", gmenu2x->tr["Space"]); "skin:imgs/buttons/r.png", gmenu2x->tr["Space"]);
btnSpace->setAction(MakeDelegate(this, &InputDialog::space)); btnSpace->setAction(MakeDelegate(this, &InputDialog::space));
buttonbox->add(btnSpace); buttonbox->add(btnSpace);
IconButton *btnConfirm = new IconButton(gmenu2x, IconButton *btnConfirm = new IconButton(gmenu2x, ts,
"skin:imgs/buttons/accept.png", gmenu2x->tr["Confirm"]); "skin:imgs/buttons/accept.png", gmenu2x->tr["Confirm"]);
btnConfirm->setAction(MakeDelegate(this, &InputDialog::confirm)); btnConfirm->setAction(MakeDelegate(this, &InputDialog::confirm));
buttonbox->add(btnConfirm); buttonbox->add(btnConfirm);
IconButton *btnChangeKeys = new IconButton(gmenu2x, IconButton *btnChangeKeys = new IconButton(gmenu2x, ts,
"skin:imgs/buttons/cancel.png", gmenu2x->tr["Change keys"]); "skin:imgs/buttons/cancel.png", gmenu2x->tr["Change keys"]);
btnChangeKeys->setAction(MakeDelegate(this, &InputDialog::changeKeys)); btnChangeKeys->setAction(MakeDelegate(this, &InputDialog::changeKeys));
buttonbox->add(btnChangeKeys); buttonbox->add(btnChangeKeys);

View File

@ -31,8 +31,8 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
Link::Link(GMenu2X *gmenu2x_) Link::Link(GMenu2X *gmenu2x_, Touchscreen &ts)
: Button(gmenu2x_->ts, true) : Button(ts, true)
, gmenu2x(gmenu2x_) , gmenu2x(gmenu2x_)
{ {
action = MakeDelegate(this, &Link::run); action = MakeDelegate(this, &Link::run);

View File

@ -50,7 +50,7 @@ protected:
void updateSurfaces(); void updateSurfaces();
public: public:
Link(GMenu2X *gmenu2x); Link(GMenu2X *gmenu2x, Touchscreen &ts);
virtual ~Link() {}; virtual ~Link() {};
virtual void paint(); virtual void paint();

View File

@ -20,8 +20,8 @@
#include "linkaction.h" #include "linkaction.h"
LinkAction::LinkAction(GMenu2X *gmenu2x, LinkRunAction act) LinkAction::LinkAction(GMenu2X *gmenu2x, Touchscreen &ts, LinkRunAction act)
: Link(gmenu2x) { : Link(gmenu2x, ts) {
this->action = act; this->action = act;
} }

View File

@ -37,7 +37,7 @@ class LinkAction : public Link {
private: private:
LinkRunAction action; LinkRunAction action;
public: public:
LinkAction(GMenu2X *gmenu2x, LinkRunAction act); LinkAction(GMenu2X *gmenu2x, Touchscreen &ts, LinkRunAction act);
virtual ~LinkAction() {}; virtual ~LinkAction() {};
virtual void run(); virtual void run();
}; };

View File

@ -38,9 +38,9 @@
using namespace std; using namespace std;
LinkApp::LinkApp(GMenu2X *gmenu2x_, InputManager &inputMgr_, LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
const char* linkfile) const char* linkfile)
: Link(gmenu2x_) : Link(gmenu2x_, ts)
, inputMgr(inputMgr_) , inputMgr(inputMgr_)
{ {
manual = ""; manual = "";

View File

@ -27,6 +27,7 @@
class GMenu2X; class GMenu2X;
class InputManager; class InputManager;
class Touchscreen;
/** /**
Parses links files. Parses links files.
@ -53,7 +54,8 @@ private:
bool dontleave; bool dontleave;
public: public:
LinkApp(GMenu2X *gmenu2x, InputManager &inputMgr, const char* linkfile); LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr,
const char* linkfile);
virtual const std::string &searchIcon(); virtual const std::string &searchIcon();
const std::string &getExec(); const std::string &getExec();

View File

@ -35,8 +35,10 @@
using namespace std; using namespace std;
Menu::Menu(GMenu2X *gmenu2x) { Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
this->gmenu2x = gmenu2x; : gmenu2x(gmenu2x)
, ts(ts)
{
iFirstDispSection = 0; iFirstDispSection = 0;
readSections(GMENU2X_SYSTEM_DIR "/sections"); readSections(GMENU2X_SYSTEM_DIR "/sections");
@ -171,7 +173,7 @@ void Menu::setSectionIndex(int i) {
bool Menu::addActionLink(uint section, const string &title, LinkRunAction action, const string &description, const string &icon) { bool Menu::addActionLink(uint section, const string &title, LinkRunAction action, const string &description, const string &icon) {
if (section>=sections.size()) return false; if (section>=sections.size()) return false;
LinkAction *linkact = new LinkAction(gmenu2x,action); LinkAction *linkact = new LinkAction(gmenu2x, ts, action);
linkact->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]); linkact->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]);
linkact->setTitle(title); linkact->setTitle(title);
linkact->setDescription(description); linkact->setDescription(description);
@ -283,7 +285,7 @@ bool Menu::addLink(string path, string file, string section) {
INFO("Section: '%s(%i)'\n", sections[isection].c_str(), isection); INFO("Section: '%s(%i)'\n", sections[isection].c_str(), isection);
LinkApp* link = new LinkApp(gmenu2x, gmenu2x->input, linkpath.c_str()); LinkApp* link = new LinkApp(gmenu2x, ts, gmenu2x->input, linkpath.c_str());
link->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]); link->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]);
links[isection].push_back( link ); links[isection].push_back( link );
} }
@ -465,10 +467,10 @@ void Menu::readLinks() {
sort(linkfiles.begin(), linkfiles.end(),case_less()); sort(linkfiles.begin(), linkfiles.end(),case_less());
for (uint x=0; x<linkfiles.size(); x++) { for (uint x=0; x<linkfiles.size(); x++) {
LinkApp *link = new LinkApp(gmenu2x, gmenu2x->input, linkfiles[x].c_str()); LinkApp *link = new LinkApp(gmenu2x, ts, gmenu2x->input, linkfiles[x].c_str());
link->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]); link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
if (link->targetExists()) if (link->targetExists())
links[i].push_back( link ); links[i].push_back(link);
else else
delete link; delete link;
} }

View File

@ -37,6 +37,7 @@ Handles the menu structure
class Menu { class Menu {
private: private:
GMenu2X *gmenu2x; GMenu2X *gmenu2x;
Touchscreen &ts;
int iSection, iLink; int iSection, iLink;
uint iFirstDispSection, iFirstDispRow; uint iFirstDispSection, iFirstDispRow;
std::vector<std::string> sections; std::vector<std::string> sections;
@ -52,7 +53,7 @@ private:
void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles); void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles);
public: public:
Menu(GMenu2X *gmenu2x); Menu(GMenu2X *gmenu2x, Touchscreen &ts);
~Menu(); ~Menu();
std::vector<Link*> *sectionLinks(int i = -1); std::vector<Link*> *sectionLinks(int i = -1);

View File

@ -30,9 +30,10 @@ using std::string;
using fastdelegate::MakeDelegate; using fastdelegate::MakeDelegate;
MenuSettingBool::MenuSettingBool( MenuSettingBool::MenuSettingBool(
GMenu2X *gmenu2x, const string &name, GMenu2X *gmenu2x, Touchscreen &ts,
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;
@ -42,9 +43,10 @@ MenuSettingBool::MenuSettingBool(
} }
MenuSettingBool::MenuSettingBool( MenuSettingBool::MenuSettingBool(
GMenu2X *gmenu2x, const string &name, GMenu2X *gmenu2x, Touchscreen &ts,
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;
@ -55,7 +57,8 @@ MenuSettingBool::MenuSettingBool(
void MenuSettingBool::initButton() void MenuSettingBool::initButton()
{ {
IconButton *btn = new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", IconButton *btn = new IconButton(gmenu2x, ts,
"skin:imgs/buttons/accept.png",
gmenu2x->tr["Switch"]); gmenu2x->tr["Switch"]);
btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle)); btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
buttonBox.add(btn); buttonBox.add(btn);

View File

@ -24,12 +24,14 @@
#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;
@ -37,11 +39,13 @@ private:
public: public:
MenuSettingBool( MenuSettingBool(
GMenu2X *gmenu2x, const std::string &name, GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &description, bool *value); const std::string &name, const std::string &description,
bool *value);
MenuSettingBool( MenuSettingBool(
GMenu2X *gmenu2x, const std::string &name, GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &description, int *value); const std::string &name, const std::string &description,
int *value);
virtual ~MenuSettingBool() {} virtual ~MenuSettingBool() {}
virtual void draw(int y); virtual void draw(int y);

View File

@ -28,18 +28,19 @@ using std::string;
using fastdelegate::MakeDelegate; using fastdelegate::MakeDelegate;
MenuSettingDir::MenuSettingDir( MenuSettingDir::MenuSettingDir(
GMenu2X *gmenu2x, const string &name, GMenu2X *gmenu2x, Touchscreen &ts_,
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_)
{ {
IconButton *btn; IconButton *btn;
btn = new IconButton(gmenu2x, "skin:imgs/buttons/cancel.png", btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png",
gmenu2x->tr["Clear"]); gmenu2x->tr["Clear"]);
btn->setAction(MakeDelegate(this, &MenuSettingDir::clear)); btn->setAction(MakeDelegate(this, &MenuSettingDir::clear));
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png",
gmenu2x->tr["Select a directory"]); gmenu2x->tr["Select a directory"]);
btn->setAction(MakeDelegate(this, &MenuSettingDir::edit)); btn->setAction(MakeDelegate(this, &MenuSettingDir::edit));
buttonBox.add(btn); buttonBox.add(btn);
@ -47,6 +48,6 @@ MenuSettingDir::MenuSettingDir(
void MenuSettingDir::edit() void MenuSettingDir::edit()
{ {
DirDialog dd(gmenu2x, description, value()); DirDialog dd(gmenu2x, ts, description, value());
if (dd.exec()) setValue(dd.getPath()); if (dd.exec()) setValue(dd.getPath());
} }

View File

@ -22,14 +22,20 @@
#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, const std::string &name, GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &description, std::string *value); const std::string &name, const std::string &description,
std::string *value);
virtual ~MenuSettingDir() {} virtual ~MenuSettingDir() {}
}; };

View File

@ -28,25 +28,27 @@ using std::string;
using fastdelegate::MakeDelegate; using fastdelegate::MakeDelegate;
MenuSettingFile::MenuSettingFile( MenuSettingFile::MenuSettingFile(
GMenu2X *gmenu2x, const string &name, GMenu2X *gmenu2x, Touchscreen &ts_,
const string &description, string *value, const string &filter_) const string &name, const string &description,
string *value, const string &filter_)
: MenuSettingStringBase(gmenu2x, name, description, value) : MenuSettingStringBase(gmenu2x, name, description, value)
, ts(ts_)
, filter(filter_) , filter(filter_)
{ {
IconButton *btn; IconButton *btn;
btn = new IconButton(gmenu2x, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Clear"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Clear"]);
btn->setAction(MakeDelegate(this, &MenuSettingFile::clear)); btn->setAction(MakeDelegate(this, &MenuSettingFile::clear));
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x->tr["Select a file"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Select a file"]);
btn->setAction(MakeDelegate(this, &MenuSettingFile::edit)); btn->setAction(MakeDelegate(this, &MenuSettingFile::edit));
buttonBox.add(btn); buttonBox.add(btn);
} }
void MenuSettingFile::edit() void MenuSettingFile::edit()
{ {
FileDialog fd(gmenu2x, description, filter, value()); FileDialog fd(gmenu2x, ts, description, filter, value());
if (fd.exec()) { if (fd.exec()) {
setValue(fd.getPath() + "/" + fd.getFile()); setValue(fd.getPath() + "/" + fd.getFile());
} }

View File

@ -22,17 +22,20 @@
#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, const std::string &name, GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &description, std::string *value, const std::string &name, const std::string &description,
const std::string &filter = ""); std::string *value, const std::string &filter = "");
virtual ~MenuSettingFile() {} virtual ~MenuSettingFile() {}
}; };

View File

@ -26,13 +26,16 @@
using std::string; using std::string;
MenuSettingImage::MenuSettingImage(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter) MenuSettingImage::MenuSettingImage(
: MenuSettingFile(gmenu2x, name, description, value, filter) GMenu2X *gmenu2x, Touchscreen &ts,
const string &name, const string &description,
string *value, const string &filter)
: MenuSettingFile(gmenu2x, ts, name, description, value, filter)
{ {
} }
void MenuSettingImage::edit() { void MenuSettingImage::edit() {
ImageDialog id(gmenu2x, description, filter, value()); ImageDialog id(gmenu2x, ts, description, filter, value());
if (id.exec()) setValue(id.getPath() + "/" + id.getFile()); if (id.exec()) setValue(id.getPath() + "/" + id.getFile());
} }

View File

@ -27,9 +27,9 @@ protected:
virtual void edit(); virtual void edit();
public: public:
MenuSettingImage(GMenu2X *gmenu2x, const std::string &name, MenuSettingImage(GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &description, std::string *value, const std::string &name, const std::string &description,
const std::string &filter = ""); std::string *value, const std::string &filter = "");
virtual ~MenuSettingImage() {} virtual ~MenuSettingImage() {}
virtual void setValue(const std::string &value); virtual void setValue(const std::string &value);

View File

@ -30,7 +30,10 @@ using std::string;
using std::stringstream; using std::stringstream;
using fastdelegate::MakeDelegate; using fastdelegate::MakeDelegate;
MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max, int increment) MenuSettingInt::MenuSettingInt(
GMenu2X *gmenu2x, Touchscreen &ts,
const string &name, const string &description,
int *value, int min, int max, int increment)
: MenuSetting(gmenu2x,name,description) : MenuSetting(gmenu2x,name,description)
{ {
IconButton *btn; IconButton *btn;
@ -46,19 +49,19 @@ MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const strin
ButtonAction actionInc = MakeDelegate(this, &MenuSettingInt::inc); ButtonAction actionInc = MakeDelegate(this, &MenuSettingInt::inc);
ButtonAction actionDec = MakeDelegate(this, &MenuSettingInt::dec); ButtonAction actionDec = MakeDelegate(this, &MenuSettingInt::dec);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/l.png"); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/l.png");
btn->setAction(actionDec); btn->setAction(actionDec);
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"]);
btn->setAction(actionDec); btn->setAction(actionDec);
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/r.png"); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/r.png");
btn->setAction(actionInc); btn->setAction(actionInc);
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"]);
btn->setAction(actionInc); btn->setAction(actionInc);
buttonBox.add(btn); buttonBox.add(btn);
} }

View File

@ -23,6 +23,8 @@
#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;
@ -36,9 +38,9 @@ private:
public: public:
MenuSettingInt( MenuSettingInt(
GMenu2X *gmenu2x, const std::string &name, GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &description, int *value, int min, int max, const std::string &name, const std::string &description,
int increment = 1); int *value, int min, int max, int increment = 1);
virtual ~MenuSettingInt() {} virtual ~MenuSettingInt() {}
virtual bool handleButtonPress(InputManager::Button button); virtual bool handleButtonPress(InputManager::Button button);

View File

@ -30,9 +30,9 @@ using std::vector;
using fastdelegate::MakeDelegate; using fastdelegate::MakeDelegate;
MenuSettingMultiString::MenuSettingMultiString( MenuSettingMultiString::MenuSettingMultiString(
GMenu2X *gmenu2x, const string &name, GMenu2X *gmenu2x, Touchscreen &ts,
const string &description, string *value, const string &name, const string &description,
const vector<string> *choices_) string *value, const vector<string> *choices_)
: MenuSettingStringBase(gmenu2x, name, description, value) : MenuSettingStringBase(gmenu2x, name, description, value)
, choices(choices_) , choices(choices_)
{ {
@ -40,11 +40,11 @@ MenuSettingMultiString::MenuSettingMultiString(
IconButton *btn; IconButton *btn;
btn = new IconButton(gmenu2x, "skin:imgs/buttons/left.png"); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png");
btn->setAction(MakeDelegate(this, &MenuSettingMultiString::decSel)); btn->setAction(MakeDelegate(this, &MenuSettingMultiString::decSel));
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change value"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Change value"]);
btn->setAction(MakeDelegate(this, &MenuSettingMultiString::incSel)); btn->setAction(MakeDelegate(this, &MenuSettingMultiString::incSel));
buttonBox.add(btn); buttonBox.add(btn);
} }

View File

@ -25,6 +25,8 @@
#include <vector> #include <vector>
class Touchscreen;
class MenuSettingMultiString : public MenuSettingStringBase { class MenuSettingMultiString : public MenuSettingStringBase {
private: private:
virtual void edit() { virtual void edit() {
@ -40,9 +42,9 @@ private:
public: public:
MenuSettingMultiString( MenuSettingMultiString(
GMenu2X *gmenu2x, const std::string &name, GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &description, std::string *value, const std::string &name, const std::string &description,
const std::vector<std::string> *choices); std::string *value, const std::vector<std::string> *choices);
virtual ~MenuSettingMultiString() {}; virtual ~MenuSettingMultiString() {};
virtual bool handleButtonPress(InputManager::Button button); virtual bool handleButtonPress(InputManager::Button button);

View File

@ -31,9 +31,10 @@ using std::stringstream;
using fastdelegate::MakeDelegate; using fastdelegate::MakeDelegate;
MenuSettingRGBA::MenuSettingRGBA( MenuSettingRGBA::MenuSettingRGBA(
GMenu2X *gmenu2x, const string &name, GMenu2X *gmenu2x, Touchscreen &ts_,
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;
@ -60,9 +61,9 @@ void MenuSettingRGBA::draw(int y) {
} }
void MenuSettingRGBA::handleTS() { void MenuSettingRGBA::handleTS() {
if (gmenu2x->ts.pressed()) { if (ts.pressed()) {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
if (i!=selPart && gmenu2x->ts.inRect(166+i*36,y,36,14)) { if (i!=selPart && ts.inRect(166+i*36,y,36,14)) {
selPart = i; selPart = i;
i = 4; i = 4;
} }
@ -226,14 +227,14 @@ void MenuSettingRGBA::updateButtonBox()
{ {
buttonBox.clear(); buttonBox.clear();
if (edit) { if (edit) {
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/l.png")); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/l.png"));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"])); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"]));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/r.png")); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/r.png"));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"])); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"]));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x->tr["Confirm"])); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Confirm"]));
} else { } else {
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/left.png")); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png"));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"])); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"]));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x->tr["Edit"])); buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Edit"]));
} }
} }

View File

@ -26,9 +26,11 @@
#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;
int y; int y;
std::string strR, strG, strB, strA; std::string strR, strG, strB, strA;
@ -46,8 +48,9 @@ private:
public: public:
MenuSettingRGBA( MenuSettingRGBA(
GMenu2X *gmenu2x, const std::string &name, GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &description, RGBAColor *value); const std::string &name, const std::string &description,
RGBAColor *value);
virtual ~MenuSettingRGBA() {}; virtual ~MenuSettingRGBA() {};
virtual void draw(int y); virtual void draw(int y);

View File

@ -28,20 +28,21 @@ using std::string;
using fastdelegate::MakeDelegate; using fastdelegate::MakeDelegate;
MenuSettingString::MenuSettingString( MenuSettingString::MenuSettingString(
GMenu2X *gmenu2x, const string &name, GMenu2X *gmenu2x, Touchscreen &ts_,
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_)
{ {
IconButton *btn; IconButton *btn;
btn = new IconButton(gmenu2x, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Clear"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Clear"]);
btn->setAction(MakeDelegate(this, &MenuSettingString::clear)); btn->setAction(MakeDelegate(this, &MenuSettingString::clear));
buttonBox.add(btn); buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x->tr["Edit"]); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Edit"]);
btn->setAction(MakeDelegate(this, &MenuSettingString::edit)); btn->setAction(MakeDelegate(this, &MenuSettingString::edit));
buttonBox.add(btn); buttonBox.add(btn);
} }
@ -49,7 +50,7 @@ MenuSettingString::MenuSettingString(
void MenuSettingString::edit() void MenuSettingString::edit()
{ {
InputDialog id( InputDialog id(
gmenu2x, gmenu2x->input, gmenu2x->ts, gmenu2x, gmenu2x->input, ts,
description, value(), diagTitle, diagIcon); description, value(), diagTitle, diagIcon);
if (id.exec()) setValue(id.getInput()); if (id.exec()) setValue(id.getInput());
} }

View File

@ -22,14 +22,20 @@
#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();
std::string diagTitle, diagIcon; std::string diagTitle, diagIcon;
public: public:
MenuSettingString(GMenu2X *gmenu2x, const std::string &name, MenuSettingString(
GMenu2X *gmenu2x, Touchscreen &ts, 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 = "");

View File

@ -31,8 +31,9 @@
using namespace std; using namespace std;
WallpaperDialog::WallpaperDialog(GMenu2X *gmenu2x) WallpaperDialog::WallpaperDialog(GMenu2X *gmenu2x, Touchscreen &ts_)
: Dialog(gmenu2x) : Dialog(gmenu2x)
, ts(ts_)
{ {
} }
@ -76,8 +77,8 @@ bool WallpaperDialog::exec()
uint i, selected = 0, firstElement = 0, iY; uint i, selected = 0, firstElement = 0, iY;
ButtonBox buttonbox(gmenu2x); ButtonBox buttonbox(gmenu2x);
buttonbox.add(new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x->tr["Select wallpaper"])); buttonbox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Select wallpaper"]));
buttonbox.add(new IconButton(gmenu2x, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Exit"])); buttonbox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Exit"]));
while (!close) { while (!close) {
if (selected>firstElement+9) firstElement=selected-9; if (selected>firstElement+9) firstElement=selected-9;

View File

@ -25,9 +25,14 @@
#include <string> #include <string>
class Touchscreen;
class WallpaperDialog : protected Dialog { class WallpaperDialog : protected Dialog {
private:
Touchscreen &ts;
public: public:
WallpaperDialog(GMenu2X *gmenu2x); WallpaperDialog(GMenu2X *gmenu2x, Touchscreen &ts);
std::string wallpaper; std::string wallpaper;
bool exec(); bool exec();