1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-23 03:24:38 +02:00

Give SettingsDialog a direct reference to the Touchscreen and InputManager objects instead of fetching them from the GMenu2X object.

This commit is contained in:
Maarten ter Huurne 2010-07-27 23:09:16 +02:00
parent d03dbea9bd
commit 0ce743426a
3 changed files with 25 additions and 17 deletions

View File

@ -1027,7 +1027,7 @@ void GMenu2X::options() {
encodings.push_back("NTSC"); encodings.push_back("NTSC");
encodings.push_back("PAL"); encodings.push_back("PAL");
SettingsDialog sd(this,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,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,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"],200,430)); sd.addSetting(new MenuSettingInt(this,tr["Clock for GMenu2X"],tr["Set the cpu working frequency when running GMenu2X"],&confInt["menuClock"],200,430));
@ -1055,7 +1055,7 @@ void GMenu2X::options() {
} }
void GMenu2X::settingsOpen2x() { void GMenu2X::settingsOpen2x() {
SettingsDialog sd(this,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,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,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,tr["Telnet on boot"],tr["Allow telnet to be started at boot time"],&o2x_telnet_on_boot));
@ -1085,7 +1085,7 @@ void GMenu2X::skinMenu() {
fl_sk.browse(); fl_sk.browse();
string curSkin = confStr["skin"]; string curSkin = confStr["skin"];
SettingsDialog sd(this,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,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,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,tr["Bottom Bar Color"],tr["Color of the bottom bar"],&skinConfColors[COLOR_BOTTOM_BAR_BG]));
@ -1430,7 +1430,7 @@ void GMenu2X::editLink() {
string diagTitle = tr.translate("Edit link: $1",linkTitle.c_str(),NULL); string diagTitle = tr.translate("Edit link: $1",linkTitle.c_str(),NULL);
string diagIcon = menu->selLinkApp()->getIconPath(); string diagIcon = menu->selLinkApp()->getIconPath();
SettingsDialog sd(this,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,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,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,tr["Section"],tr["The section this link belongs to"],&newSection,&menu->getSections()));

View File

@ -25,11 +25,14 @@
using namespace std; using namespace std;
SettingsDialog::SettingsDialog(GMenu2X *gmenu2x, const string &text, const string &icon) SettingsDialog::SettingsDialog(
: Dialog(gmenu2x) GMenu2X *gmenu2x_, InputManager &inputMgr_, Touchscreen &ts_,
const string &text_, const string &icon)
: Dialog(gmenu2x_)
, inputMgr(inputMgr_)
, ts(ts_)
, text(text_)
{ {
this->text = text;
if (icon!="" && gmenu2x->sc[icon] != NULL) if (icon!="" && gmenu2x->sc[icon] != NULL)
this->icon = icon; this->icon = icon;
else else
@ -56,7 +59,7 @@ bool SettingsDialog::exec() {
while (!close) { while (!close) {
action = SD_NO_ACTION; action = SD_NO_ACTION;
if (gmenu2x->f200) gmenu2x->ts.poll(); if (gmenu2x->f200) ts.poll();
bg.blit(gmenu2x->s,0,0); bg.blit(gmenu2x->s,0,0);
@ -82,12 +85,12 @@ bool SettingsDialog::exec() {
voices[sel]->drawSelected(iY); voices[sel]->drawSelected(iY);
gmenu2x->s->setClipRect(clipRect); gmenu2x->s->setClipRect(clipRect);
if (ts_pressed && !gmenu2x->ts.pressed()) ts_pressed = false; if (ts_pressed && !ts.pressed()) ts_pressed = false;
if (gmenu2x->f200 && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false; if (gmenu2x->f200 && ts.pressed() && !ts.inRect(touchRect)) ts_pressed = false;
for (i=firstElement; i<voices.size() && i<firstElement+numRows; i++) { for (i=firstElement; i<voices.size() && i<firstElement+numRows; i++) {
iY = i-firstElement; iY = i-firstElement;
voices[i]->draw(iY*rowHeight+gmenu2x->skinConfInt["topBarHeight"]+2); voices[i]->draw(iY*rowHeight+gmenu2x->skinConfInt["topBarHeight"]+2);
if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(touchRect.x, touchRect.y+(iY*rowHeight), touchRect.w, rowHeight)) { if (gmenu2x->f200 && ts.pressed() && ts.inRect(touchRect.x, touchRect.y+(iY*rowHeight), touchRect.w, rowHeight)) {
ts_pressed = true; ts_pressed = true;
sel = i; sel = i;
} }
@ -102,10 +105,10 @@ bool SettingsDialog::exec() {
gmenu2x->s->flip(); gmenu2x->s->flip();
voices[sel]->handleTS(); voices[sel]->handleTS();
gmenu2x->input.update(); inputMgr.update();
if ( gmenu2x->input[ACTION_START] ) action = SD_ACTION_CLOSE; if ( inputMgr[ACTION_START] ) action = SD_ACTION_CLOSE;
if ( gmenu2x->input[ACTION_UP ] ) action = SD_ACTION_UP; if ( inputMgr[ACTION_UP ] ) action = SD_ACTION_UP;
if ( gmenu2x->input[ACTION_DOWN ] ) action = SD_ACTION_DOWN; if ( inputMgr[ACTION_DOWN ] ) action = SD_ACTION_DOWN;
voices[sel]->manageInput(); voices[sel]->manageInput();
switch (action) { switch (action) {

View File

@ -34,13 +34,18 @@
using std::string; using std::string;
using std::vector; using std::vector;
class InputManager;
class Touchscreen;
class SettingsDialog : protected Dialog { class SettingsDialog : protected Dialog {
private: private:
InputManager &inputMgr;
Touchscreen &ts;
vector<MenuSetting *> voices; vector<MenuSetting *> voices;
string text, icon; string text, icon;
public: public:
SettingsDialog(GMenu2X *gmenu2x, const string &text, const string &icon="skin:sections/settings.png"); SettingsDialog(GMenu2X *gmenu2x, InputManager &inputMgr, Touchscreen &ts, const string &text, const string &icon="skin:sections/settings.png");
~SettingsDialog(); ~SettingsDialog();
bool edited(); bool edited();