mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 21:36:15 +02:00
Give InputDialog a direct reference to the Touchscreen and InputManager objects instead of fetching them from the GMenu2X object.
This commit is contained in:
parent
4468464505
commit
d03dbea9bd
@ -1513,7 +1513,7 @@ void GMenu2X::deleteLink() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::addSection() {
|
void GMenu2X::addSection() {
|
||||||
InputDialog id(this,tr["Insert a name for the new section"]);
|
InputDialog id(this, input, ts, tr["Insert a name for the new section"]);
|
||||||
if (id.exec()) {
|
if (id.exec()) {
|
||||||
//only if a section with the same name does not exist
|
//only if a section with the same name does not exist
|
||||||
if (find(menu->getSections().begin(), menu->getSections().end(), id.getInput())
|
if (find(menu->getSections().begin(), menu->getSections().end(), id.getInput())
|
||||||
@ -1530,7 +1530,7 @@ void GMenu2X::addSection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::renameSection() {
|
void GMenu2X::renameSection() {
|
||||||
InputDialog id(this,tr["Insert a new name for this section"],menu->selSection());
|
InputDialog id(this, input, ts, 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()
|
||||||
|
@ -26,9 +26,12 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fastdelegate;
|
using namespace fastdelegate;
|
||||||
|
|
||||||
InputDialog::InputDialog(GMenu2X *gmenu2x, const string &text,
|
InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_,
|
||||||
const string &startvalue, const string &title, const string &icon) :
|
Touchscreen &ts_, const string &text,
|
||||||
Dialog(gmenu2x)
|
const string &startvalue, const string &title, const string &icon)
|
||||||
|
: Dialog(gmenu2x)
|
||||||
|
, inputMgr(inputMgr_)
|
||||||
|
, ts(ts_)
|
||||||
{
|
{
|
||||||
if (title=="") {
|
if (title=="") {
|
||||||
this->title = text;
|
this->title = text;
|
||||||
@ -157,20 +160,20 @@ bool InputDialog::exec() {
|
|||||||
|
|
||||||
if (caretOn) gmenu2x->s->box(box.x+box.w-12, box.y+3, 8, box.h-6, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
if (caretOn) gmenu2x->s->box(box.x+box.w-12, box.y+3, 8, box.h-6, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||||
|
|
||||||
if (gmenu2x->f200) gmenu2x->ts.poll();
|
if (gmenu2x->f200) ts.poll();
|
||||||
action = drawVirtualKeyboard();
|
action = drawVirtualKeyboard();
|
||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
|
|
||||||
gmenu2x->input.update();
|
inputMgr.update();
|
||||||
if ( gmenu2x->input[ACTION_START] ) action = ID_ACTION_CLOSE;
|
if ( inputMgr[ACTION_START] ) action = ID_ACTION_CLOSE;
|
||||||
if ( gmenu2x->input[ACTION_UP ] ) action = ID_ACTION_UP;
|
if ( inputMgr[ACTION_UP ] ) action = ID_ACTION_UP;
|
||||||
if ( gmenu2x->input[ACTION_DOWN ] ) action = ID_ACTION_DOWN;
|
if ( inputMgr[ACTION_DOWN ] ) action = ID_ACTION_DOWN;
|
||||||
if ( gmenu2x->input[ACTION_LEFT ] ) action = ID_ACTION_LEFT;
|
if ( inputMgr[ACTION_LEFT ] ) action = ID_ACTION_LEFT;
|
||||||
if ( gmenu2x->input[ACTION_RIGHT] ) action = ID_ACTION_RIGHT;
|
if ( inputMgr[ACTION_RIGHT] ) action = ID_ACTION_RIGHT;
|
||||||
if ( gmenu2x->input[ACTION_B] ) action = ID_ACTION_SELECT;
|
if ( inputMgr[ACTION_B] ) action = ID_ACTION_SELECT;
|
||||||
if ( gmenu2x->input[ACTION_Y] ) action = ID_ACTION_KB_CHANGE;
|
if ( inputMgr[ACTION_Y] ) action = ID_ACTION_KB_CHANGE;
|
||||||
if ( gmenu2x->input[ACTION_X] || gmenu2x->input[ACTION_L] ) action = ID_ACTION_BACKSPACE;
|
if ( inputMgr[ACTION_X] || inputMgr[ACTION_L] ) action = ID_ACTION_BACKSPACE;
|
||||||
if ( gmenu2x->input[ACTION_R ] ) action = ID_ACTION_SPACE;
|
if ( inputMgr[ACTION_R ] ) action = ID_ACTION_SPACE;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ID_ACTION_CLOSE: {
|
case ID_ACTION_CLOSE: {
|
||||||
@ -270,7 +273,7 @@ int InputDialog::drawVirtualKeyboard() {
|
|||||||
SDL_Rect re = {kbLeft+xc*KEY_WIDTH-1, KB_TOP+l*KEY_HEIGHT, KEY_WIDTH-1, KEY_HEIGHT-2};
|
SDL_Rect re = {kbLeft+xc*KEY_WIDTH-1, KB_TOP+l*KEY_HEIGHT, KEY_WIDTH-1, KEY_HEIGHT-2};
|
||||||
|
|
||||||
//if ts on rect, change selection
|
//if ts on rect, change selection
|
||||||
if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(re)) {
|
if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) {
|
||||||
selCol = xc;
|
selCol = xc;
|
||||||
selRow = l;
|
selRow = l;
|
||||||
}
|
}
|
||||||
@ -284,7 +287,7 @@ int InputDialog::drawVirtualKeyboard() {
|
|||||||
//Ok/Cancel
|
//Ok/Cancel
|
||||||
SDL_Rect re = {kbLeft-1, KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1};
|
SDL_Rect re = {kbLeft-1, KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1};
|
||||||
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||||
if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(re)) {
|
if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) {
|
||||||
selCol = 0;
|
selCol = 0;
|
||||||
selRow = kb->size();
|
selRow = kb->size();
|
||||||
}
|
}
|
||||||
@ -292,14 +295,14 @@ int InputDialog::drawVirtualKeyboard() {
|
|||||||
|
|
||||||
re.x = kbLeft+kbLength*KEY_WIDTH/2-1;
|
re.x = kbLeft+kbLength*KEY_WIDTH/2-1;
|
||||||
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||||
if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(re)) {
|
if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) {
|
||||||
selCol = 1;
|
selCol = 1;
|
||||||
selRow = kb->size();
|
selRow = kb->size();
|
||||||
}
|
}
|
||||||
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"], (int)(160+kbLength*KEY_WIDTH/4), KB_TOP+kb->size()*KEY_HEIGHT+KEY_HEIGHT/2, SFontHAlignCenter, SFontVAlignMiddle);
|
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"], (int)(160+kbLength*KEY_WIDTH/4), KB_TOP+kb->size()*KEY_HEIGHT+KEY_HEIGHT/2, SFontHAlignCenter, SFontVAlignMiddle);
|
||||||
|
|
||||||
//if ts released
|
//if ts released
|
||||||
if (gmenu2x->f200 && gmenu2x->ts.released() && gmenu2x->ts.inRect(kbRect)) {
|
if (gmenu2x->f200 && ts.released() && ts.inRect(kbRect)) {
|
||||||
action = ID_ACTION_SELECT;
|
action = ID_ACTION_SELECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,13 @@ using std::vector;
|
|||||||
|
|
||||||
typedef vector<string> stringlist;
|
typedef vector<string> stringlist;
|
||||||
|
|
||||||
|
class InputManager;
|
||||||
|
class Touchscreen;
|
||||||
|
|
||||||
class InputDialog : protected Dialog {
|
class InputDialog : protected Dialog {
|
||||||
private:
|
private:
|
||||||
|
InputManager &inputMgr;
|
||||||
|
Touchscreen &ts;
|
||||||
int selRow, selCol;
|
int selRow, selCol;
|
||||||
bool close, ok;
|
bool close, ok;
|
||||||
string title, text, icon;
|
string title, text, icon;
|
||||||
@ -68,7 +73,7 @@ private:
|
|||||||
void setKeyboard(int);
|
void setKeyboard(int);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InputDialog(GMenu2X *gmenu2x, const string &text, const string &startvalue="", const string &title="", const string &icon="");
|
InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr, Touchscreen &ts, const string &text, const string &startvalue="", const string &title="", const string &icon="");
|
||||||
|
|
||||||
bool exec();
|
bool exec();
|
||||||
const string &getInput() { return input; }
|
const string &getInput() { return input; }
|
||||||
|
@ -76,7 +76,8 @@ void MenuSettingString::clear()
|
|||||||
|
|
||||||
void MenuSettingString::edit()
|
void MenuSettingString::edit()
|
||||||
{
|
{
|
||||||
InputDialog id(gmenu2x,description,value(), diagTitle,diagIcon);
|
InputDialog id(gmenu2x, gmenu2x->input, gmenu2x->ts,
|
||||||
|
description, value(), diagTitle, diagIcon);
|
||||||
if (id.exec()) setValue(id.getInput());
|
if (id.exec()) setValue(id.getInput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user