mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 16:17:10 +02:00
Add ButtonBox widget to simplify managing buttons in the bottombar. Also fixes some memleaks where buttons were left unfreed.
This commit is contained in:
parent
2a6a1f0041
commit
3b2538cfaf
@ -1,8 +1,29 @@
|
||||
bin_PROGRAMS = gmenu2x
|
||||
#
|
||||
gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp filelister.cpp gmenu2x.cpp iconbutton.cpp imagedialog.cpp inputdialog.cpp inputmanager.cpp linkaction.cpp linkapp.cpp link.cpp listviewitem.cpp menu.cpp menusettingbool.cpp menusetting.cpp menusettingdir.cpp menusettingfile.cpp menusettingimage.cpp menusettingint.cpp menusettingmultistring.cpp menusettingrgba.cpp menusettingstring.cpp messagebox.cpp pxml.cpp selector.cpp selectordetector.cpp settingsdialog.cpp sfontplus.cpp surfacecollection.cpp surface.cpp textdialog.cpp textmanualdialog.cpp touchscreen.cpp translator.cpp utilities.cpp wallpaperdialog.cpp listview.cpp tinyxml/tinystr.cpp tinyxml/tinyxml.cpp tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlparser.cpp browsedialog.cpp
|
||||
gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \
|
||||
filelister.cpp gmenu2x.cpp iconbutton.cpp imagedialog.cpp inputdialog.cpp \
|
||||
inputmanager.cpp linkaction.cpp linkapp.cpp link.cpp listviewitem.cpp \
|
||||
menu.cpp menusettingbool.cpp menusetting.cpp menusettingdir.cpp \
|
||||
menusettingfile.cpp menusettingimage.cpp menusettingint.cpp \
|
||||
menusettingmultistring.cpp menusettingrgba.cpp menusettingstring.cpp \
|
||||
messagebox.cpp pxml.cpp selector.cpp selectordetector.cpp \
|
||||
settingsdialog.cpp sfontplus.cpp surfacecollection.cpp surface.cpp \
|
||||
textdialog.cpp textmanualdialog.cpp touchscreen.cpp translator.cpp \
|
||||
utilities.cpp wallpaperdialog.cpp listview.cpp tinyxml/tinystr.cpp \
|
||||
tinyxml/tinyxml.cpp tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlparser.cpp \
|
||||
browsedialog.cpp buttonbox.cpp
|
||||
|
||||
noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h FastDelegate.h \
|
||||
filedialog.h filelister.h gmenu2x.h gp2x.h iconbutton.h imagedialog.h \
|
||||
inputdialog.h inputmanager.h jz4740.h linkaction.h linkapp.h link.h \
|
||||
listview.h listviewitem.h menu.h menusettingbool.h menusettingdir.h \
|
||||
menusettingfile.h menusetting.h menusettingimage.h menusettingint.h \
|
||||
menusettingmultistring.h menusettingrgba.h menusettingstring.h \
|
||||
messagebox.h pxml.h selectordetector.h selector.h settingsdialog.h \
|
||||
sfontplus.h surfacecollection.h surface.h textdialog.h textmanualdialog.h \
|
||||
touchscreen.h translator.h utilities.h wallpaperdialog.h \
|
||||
tinyxml/tinystr.h tinyxml/tinyxml.h browsedialog.h buttonbox.h
|
||||
|
||||
noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h FastDelegate.h filedialog.h filelister.h gmenu2x.h gp2x.h iconbutton.h imagedialog.h inputdialog.h inputmanager.h jz4740.h linkaction.h linkapp.h link.h listview.h listviewitem.h menu.h menusettingbool.h menusettingdir.h menusettingfile.h menusetting.h menusettingimage.h menusettingint.h menusettingmultistring.h menusettingrgba.h menusettingstring.h messagebox.h pxml.h selectordetector.h selector.h settingsdialog.h sfontplus.h surfacecollection.h surface.h textdialog.h textmanualdialog.h touchscreen.h translator.h utilities.h wallpaperdialog.h tinyxml/tinystr.h tinyxml/tinyxml.h browsedialog.h
|
||||
AM_CFLAGS= @CFLAGS@ @SDL_CFLAGS@
|
||||
|
||||
AM_CXXFLAGS = @CXXFLAGS@ @SDL_CFLAGS@
|
||||
|
@ -9,20 +9,21 @@ using namespace fastdelegate;
|
||||
|
||||
BrowseDialog::BrowseDialog(GMenu2X *gmenu2x, const string &title,
|
||||
const string &subtitle) :
|
||||
gmenu2x(gmenu2x), title(title), subtitle(subtitle)
|
||||
gmenu2x(gmenu2x), title(title), subtitle(subtitle), buttonBox(gmenu2x)
|
||||
{
|
||||
ButtonAction actionUp = MakeDelegate(this, &BrowseDialog::directoryUp);
|
||||
ButtonAction actionEnter = MakeDelegate(this, &BrowseDialog::directoryEnter);
|
||||
ButtonAction actionConfirm = MakeDelegate(this, &BrowseDialog::confirm);
|
||||
IconButton *btn;
|
||||
|
||||
btnUp = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Up one folder"]);
|
||||
btnUp->setAction(actionUp);
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Up one folder"]);
|
||||
btn->setAction(MakeDelegate(this, &BrowseDialog::directoryUp));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnEnter = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Enter folder"]);
|
||||
btnEnter->setAction(actionEnter);
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Enter folder"]);
|
||||
btn->setAction(MakeDelegate(this, &BrowseDialog::directoryEnter));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnConfirm = new IconButton(gmenu2x, "skin:imgs/buttons/start.png", gmenu2x->tr["Confirm"]);
|
||||
btnConfirm->setAction(actionConfirm);
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/start.png", gmenu2x->tr["Confirm"]);
|
||||
btn->setAction(MakeDelegate(this, &BrowseDialog::confirm));
|
||||
buttonBox.add(btn);
|
||||
|
||||
iconGoUp = gmenu2x->sc.skinRes("imgs/go-up.png");
|
||||
iconFolder = gmenu2x->sc.skinRes("imgs/folder.png");
|
||||
@ -143,9 +144,7 @@ bool BrowseDialog::handleInput()
|
||||
break;
|
||||
}
|
||||
|
||||
btnUp->handleTS();
|
||||
btnEnter->handleTS();
|
||||
btnConfirm->handleTS();
|
||||
buttonBox.handleTS();
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
@ -195,9 +194,7 @@ void BrowseDialog::paint()
|
||||
gmenu2x->writeTitle(title);
|
||||
gmenu2x->writeSubTitle(subtitle);
|
||||
|
||||
gmenu2x->drawButton(btnConfirm,
|
||||
gmenu2x->drawButton(btnUp,
|
||||
gmenu2x->drawButton(btnEnter, 5)));
|
||||
buttonBox.paint(5);
|
||||
|
||||
if (selected>firstElement+numRows-1)
|
||||
firstElement = selected-numRows+1;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <string>
|
||||
#include "filelister.h"
|
||||
#include "gmenu2x.h"
|
||||
#include "buttonbox.h"
|
||||
|
||||
class FileLister;
|
||||
|
||||
@ -73,13 +74,14 @@ private:
|
||||
unsigned int numRows;
|
||||
unsigned int rowHeight;
|
||||
|
||||
|
||||
bool ts_pressed;
|
||||
|
||||
Surface *iconGoUp;
|
||||
Surface *iconFolder;
|
||||
Surface *iconFile;
|
||||
|
||||
ButtonBox buttonBox;
|
||||
|
||||
Action getAction();
|
||||
bool handleInput();
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
|
||||
SDL_Rect getRect();
|
||||
void setSize(int w, int h);
|
||||
void setPosition(int x, int y);
|
||||
virtual void setPosition(int x, int y);
|
||||
|
||||
virtual void paint();
|
||||
virtual bool paintHover();
|
||||
@ -54,6 +54,7 @@ public:
|
||||
bool isPressed();
|
||||
bool isReleased();
|
||||
bool handleTS();
|
||||
|
||||
void exec();
|
||||
void voidAction() {};
|
||||
void setAction(ButtonAction action);
|
||||
|
32
src/buttonbox.cpp
Normal file
32
src/buttonbox.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
#include "button.h"
|
||||
#include "gmenu2x.h"
|
||||
|
||||
#include "buttonbox.h"
|
||||
|
||||
ButtonBox::ButtonBox(GMenu2X *gmenu2x) : gmenu2x(gmenu2x)
|
||||
{
|
||||
}
|
||||
|
||||
ButtonBox::~ButtonBox()
|
||||
{
|
||||
for (ButtonList::const_iterator it = buttons.begin(); it != buttons.end(); ++it)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
void ButtonBox::add(Button *button)
|
||||
{
|
||||
buttons.push_back(button);
|
||||
}
|
||||
|
||||
void ButtonBox::paint(unsigned int posX)
|
||||
{
|
||||
for (ButtonList::const_iterator it = buttons.begin(); it != buttons.end(); ++it)
|
||||
posX = gmenu2x->drawButton(*it, posX);
|
||||
}
|
||||
|
||||
void ButtonBox::handleTS()
|
||||
{
|
||||
for (ButtonList::iterator it = buttons.begin(); it != buttons.end(); ++it)
|
||||
(*it)->handleTS();
|
||||
}
|
26
src/buttonbox.h
Normal file
26
src/buttonbox.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef __BUTTONBOX_H__
|
||||
#define __BUTTONBOX_H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
class GMenu2X;
|
||||
class Button;
|
||||
|
||||
class ButtonBox
|
||||
{
|
||||
public:
|
||||
ButtonBox(GMenu2X *gmenu2x);
|
||||
~ButtonBox();
|
||||
|
||||
void add(Button *button);
|
||||
|
||||
void paint(unsigned int posX);
|
||||
void handleTS();
|
||||
private:
|
||||
typedef std::vector<Button*> ButtonList;
|
||||
|
||||
ButtonList buttons;
|
||||
GMenu2X *gmenu2x;
|
||||
};
|
||||
|
||||
#endif
|
@ -1914,7 +1914,7 @@ string GMenu2X::getDiskFree() {
|
||||
return df;
|
||||
}
|
||||
|
||||
int GMenu2X::drawButton(IconButton *btn, int x, int y) {
|
||||
int GMenu2X::drawButton(Button *btn, int x, int y) {
|
||||
if (y<0) y = resY+y;
|
||||
btn->setPosition(x, y-7);
|
||||
btn->paint();
|
||||
|
@ -238,7 +238,7 @@ public:
|
||||
void deleteSection();
|
||||
|
||||
void initBG();
|
||||
int drawButton(IconButton *btn, int x=5, int y=-10);
|
||||
int drawButton(Button *btn, int x=5, int y=-10);
|
||||
int drawButton(Surface *s, const string &btn, const string &text, int x=5, int y=-10);
|
||||
int drawButtonRight(Surface *s, const string &btn, const string &text, int x=5, int y=-10);
|
||||
void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height);
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
virtual void paint();
|
||||
virtual bool paintHover();
|
||||
|
||||
void setPosition(int x, int y);
|
||||
virtual void setPosition(int x, int y);
|
||||
|
||||
const string &getLabel();
|
||||
void setLabel(const string &label);
|
||||
|
@ -19,18 +19,23 @@
|
||||
***************************************************************************/
|
||||
#include "menusetting.h"
|
||||
|
||||
MenuSetting::MenuSetting(GMenu2X *gmenu2x, const string &name, const string &description) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
this->name = name;
|
||||
this->description = description;
|
||||
MenuSetting::MenuSetting(GMenu2X *gmenu2x, const string &name,
|
||||
const string &description) : gmenu2x(gmenu2x), name(name),
|
||||
description(description), buttonBox(gmenu2x)
|
||||
{
|
||||
}
|
||||
|
||||
void MenuSetting::draw(int y) {
|
||||
void MenuSetting::draw(int y)
|
||||
{
|
||||
gmenu2x->s->write( gmenu2x->font, name, 5, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
}
|
||||
|
||||
void MenuSetting::handleTS() {}
|
||||
void MenuSetting::manageInput() {}
|
||||
void MenuSetting::adjustInput() {}
|
||||
void MenuSetting::drawSelected(int) {}
|
||||
bool MenuSetting::edited() { return true; }
|
||||
void MenuSetting::handleTS()
|
||||
{
|
||||
buttonBox.handleTS();
|
||||
}
|
||||
|
||||
void MenuSetting::drawSelected(int)
|
||||
{
|
||||
buttonBox.paint(5);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include "gmenu2x.h"
|
||||
#include "buttonbox.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
@ -37,16 +38,19 @@ class MenuSetting {
|
||||
protected:
|
||||
GMenu2X *gmenu2x;
|
||||
|
||||
ButtonBox buttonBox;
|
||||
|
||||
public:
|
||||
MenuSetting(GMenu2X *gmenu2x, const string &name, const string &description);
|
||||
virtual ~MenuSetting() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
virtual void manageInput();
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
||||
virtual void manageInput() {};
|
||||
virtual void adjustInput() {};
|
||||
virtual void drawSelected(int);
|
||||
virtual bool edited() { return true; };
|
||||
|
||||
string name, description;
|
||||
};
|
||||
|
@ -25,49 +25,59 @@ using namespace std;
|
||||
using namespace fastdelegate;
|
||||
|
||||
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value)
|
||||
: MenuSetting(gmenu2x,name,description) {
|
||||
: MenuSetting(gmenu2x,name,description)
|
||||
{
|
||||
IconButton *btn;
|
||||
|
||||
_ivalue = value;
|
||||
_value = NULL;
|
||||
originalValue = *value != 0;
|
||||
setValue(this->value());
|
||||
|
||||
btnToggle = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Switch"]);
|
||||
btnToggle->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Switch"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value)
|
||||
: MenuSetting(gmenu2x,name,description) {
|
||||
: MenuSetting(gmenu2x,name,description)
|
||||
{
|
||||
IconButton *btn;
|
||||
|
||||
_value = value;
|
||||
_ivalue = NULL;
|
||||
originalValue = *value;
|
||||
setValue(this->value());
|
||||
|
||||
btnToggle = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Switch"]);
|
||||
btnToggle->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Switch"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
void MenuSettingBool::draw(int y) {
|
||||
void MenuSettingBool::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
}
|
||||
|
||||
void MenuSettingBool::handleTS() {
|
||||
btnToggle->handleTS();
|
||||
void MenuSettingBool::manageInput()
|
||||
{
|
||||
if (gmenu2x->input[ACTION_B])
|
||||
toggle();
|
||||
}
|
||||
|
||||
void MenuSettingBool::manageInput() {
|
||||
if ( gmenu2x->input[ACTION_B] ) toggle();
|
||||
}
|
||||
|
||||
void MenuSettingBool::toggle() {
|
||||
void MenuSettingBool::toggle()
|
||||
{
|
||||
setValue(!value());
|
||||
}
|
||||
|
||||
void MenuSettingBool::setValue(int value) {
|
||||
void MenuSettingBool::setValue(int value)
|
||||
{
|
||||
setValue(value != 0);
|
||||
}
|
||||
|
||||
void MenuSettingBool::setValue(bool value) {
|
||||
void MenuSettingBool::setValue(bool value)
|
||||
{
|
||||
if (_value == NULL)
|
||||
*_ivalue = value;
|
||||
else
|
||||
@ -75,7 +85,8 @@ void MenuSettingBool::setValue(bool value) {
|
||||
strvalue = value ? "ON" : "OFF";
|
||||
}
|
||||
|
||||
bool MenuSettingBool::value() {
|
||||
bool MenuSettingBool::value()
|
||||
{
|
||||
if (_value == NULL)
|
||||
return *_ivalue != 0;
|
||||
else
|
||||
@ -84,10 +95,7 @@ bool MenuSettingBool::value() {
|
||||
|
||||
void MenuSettingBool::adjustInput() {}
|
||||
|
||||
void MenuSettingBool::drawSelected(int) {
|
||||
gmenu2x->drawButton(btnToggle);
|
||||
}
|
||||
|
||||
bool MenuSettingBool::edited() {
|
||||
bool MenuSettingBool::edited()
|
||||
{
|
||||
return originalValue != value();
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ private:
|
||||
bool *_value;
|
||||
int *_ivalue;
|
||||
string strvalue;
|
||||
IconButton *btnToggle;
|
||||
|
||||
void toggle();
|
||||
|
||||
@ -42,10 +41,8 @@ public:
|
||||
virtual ~MenuSettingBool() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
virtual void manageInput();
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
||||
void setValue(int value);
|
||||
|
@ -26,55 +26,55 @@ using namespace fastdelegate;
|
||||
|
||||
MenuSettingDir::MenuSettingDir(GMenu2X *gmenu2x, const string &name, const string &description, string *value)
|
||||
: MenuSetting(gmenu2x,name,description) {
|
||||
IconButton *btn;
|
||||
|
||||
_value = value;
|
||||
originalValue = *value;
|
||||
|
||||
btnClear = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
|
||||
btnClear->setAction(MakeDelegate(this, &MenuSettingDir::clear));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingDir::clear));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnSelect = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Select a directory"]);
|
||||
btnSelect->setAction(MakeDelegate(this, &MenuSettingDir::select));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Select a directory"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingDir::select));
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
void MenuSettingDir::draw(int y) {
|
||||
void MenuSettingDir::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write( gmenu2x->font, value(), 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
}
|
||||
|
||||
void MenuSettingDir::handleTS() {
|
||||
btnSelect->handleTS();
|
||||
btnClear->handleTS();
|
||||
void MenuSettingDir::manageInput()
|
||||
{
|
||||
if (gmenu2x->input[ACTION_X]) setValue("");
|
||||
if (gmenu2x->input[ACTION_B]) select();
|
||||
}
|
||||
|
||||
void MenuSettingDir::manageInput() {
|
||||
if ( gmenu2x->input[ACTION_X] ) setValue("");
|
||||
if ( gmenu2x->input[ACTION_B] ) select();
|
||||
}
|
||||
|
||||
void MenuSettingDir::clear() {
|
||||
void MenuSettingDir::clear()
|
||||
{
|
||||
setValue("");
|
||||
}
|
||||
|
||||
void MenuSettingDir::select() {
|
||||
void MenuSettingDir::select()
|
||||
{
|
||||
DirDialog dd(gmenu2x, description, value());
|
||||
if (dd.exec()) setValue( dd.getPath() );
|
||||
}
|
||||
|
||||
void MenuSettingDir::setValue(const string &value) {
|
||||
void MenuSettingDir::setValue(const string &value)
|
||||
{
|
||||
*_value = value;
|
||||
}
|
||||
|
||||
const string &MenuSettingDir::value() {
|
||||
const string &MenuSettingDir::value()
|
||||
{
|
||||
return *_value;
|
||||
}
|
||||
|
||||
void MenuSettingDir::adjustInput() {}
|
||||
|
||||
void MenuSettingDir::drawSelected(int) {
|
||||
gmenu2x->drawButton(btnClear,
|
||||
gmenu2x->drawButton(btnSelect));
|
||||
}
|
||||
|
||||
bool MenuSettingDir::edited() {
|
||||
return originalValue != value();
|
||||
}
|
||||
|
@ -29,20 +29,16 @@ class MenuSettingDir : public MenuSetting {
|
||||
private:
|
||||
string originalValue;
|
||||
string *_value;
|
||||
IconButton *btnClear, *btnSelect;
|
||||
|
||||
void select();
|
||||
void clear();
|
||||
|
||||
public:
|
||||
MenuSettingDir(GMenu2X *gmenu2x, const string &name, const string &description, string *value);
|
||||
virtual ~MenuSettingDir() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
virtual void manageInput();
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
||||
void setValue(const string &value);
|
||||
|
@ -25,57 +25,61 @@ using namespace std;
|
||||
using namespace fastdelegate;
|
||||
|
||||
MenuSettingFile::MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter)
|
||||
: MenuSetting(gmenu2x,name,description) {
|
||||
: MenuSetting(gmenu2x,name,description)
|
||||
{
|
||||
IconButton *btn;
|
||||
|
||||
this->filter = filter;
|
||||
_value = value;
|
||||
originalValue = *value;
|
||||
|
||||
btnClear = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
|
||||
btnClear->setAction(MakeDelegate(this, &MenuSettingFile::clear));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingFile::clear));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnSelect = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Select a file"]);
|
||||
btnSelect->setAction(MakeDelegate(this, &MenuSettingFile::select));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Select a file"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingFile::select));
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
void MenuSettingFile::draw(int y) {
|
||||
void MenuSettingFile::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write( gmenu2x->font, value(), 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
}
|
||||
|
||||
void MenuSettingFile::handleTS() {
|
||||
btnSelect->handleTS();
|
||||
btnClear->handleTS();
|
||||
void MenuSettingFile::manageInput()
|
||||
{
|
||||
if (gmenu2x->input[ACTION_X])
|
||||
setValue("");
|
||||
if (gmenu2x->input[ACTION_B])
|
||||
select();
|
||||
}
|
||||
|
||||
void MenuSettingFile::manageInput() {
|
||||
if ( gmenu2x->input[ACTION_X] ) setValue("");
|
||||
if ( gmenu2x->input[ACTION_B] ) select();
|
||||
}
|
||||
|
||||
void MenuSettingFile::clear() {
|
||||
void MenuSettingFile::clear()
|
||||
{
|
||||
setValue("");
|
||||
}
|
||||
|
||||
void MenuSettingFile::select() {
|
||||
void MenuSettingFile::select()
|
||||
{
|
||||
FileDialog fd(gmenu2x, description, filter, value());
|
||||
if (fd.exec()) setValue( fd.getPath()+"/"+fd.getFile() );
|
||||
if (fd.exec())
|
||||
setValue(fd.getPath()+"/"+fd.getFile());
|
||||
}
|
||||
|
||||
void MenuSettingFile::setValue(const string &value) {
|
||||
void MenuSettingFile::setValue(const string &value)
|
||||
{
|
||||
*_value = value;
|
||||
}
|
||||
|
||||
const string &MenuSettingFile::value() {
|
||||
const string &MenuSettingFile::value()
|
||||
{
|
||||
return *_value;
|
||||
}
|
||||
|
||||
void MenuSettingFile::adjustInput() {}
|
||||
|
||||
void MenuSettingFile::drawSelected(int) {
|
||||
gmenu2x->drawButton(btnClear,
|
||||
gmenu2x->drawButton(btnSelect));
|
||||
}
|
||||
|
||||
bool MenuSettingFile::edited() {
|
||||
return originalValue != value();
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ protected:
|
||||
string originalValue;
|
||||
string *_value;
|
||||
string filter;
|
||||
IconButton *btnClear, *btnSelect;
|
||||
|
||||
void select();
|
||||
void clear();
|
||||
@ -40,10 +39,8 @@ public:
|
||||
virtual ~MenuSettingFile() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
virtual void manageInput();
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
||||
virtual void setValue(const string &value);
|
||||
|
@ -25,7 +25,10 @@ using namespace std;
|
||||
using namespace fastdelegate;
|
||||
|
||||
MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max)
|
||||
: MenuSetting(gmenu2x,name,description) {
|
||||
: MenuSetting(gmenu2x,name,description)
|
||||
{
|
||||
IconButton *btn;
|
||||
|
||||
_value = value;
|
||||
originalValue = *value;
|
||||
this->min = min;
|
||||
@ -36,45 +39,49 @@ MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const strin
|
||||
ButtonAction actionInc = MakeDelegate(this, &MenuSettingInt::inc);
|
||||
ButtonAction actionDec = MakeDelegate(this, &MenuSettingInt::dec);
|
||||
|
||||
btnInc = new IconButton(gmenu2x, "skin:imgs/buttons/y.png", gmenu2x->tr["Increase value"]);
|
||||
btnInc->setAction(actionInc);
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/left.png");
|
||||
btn->setAction(actionDec);
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnDec = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Decrease value"]);
|
||||
btnDec->setAction(actionDec);
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/y.png", gmenu2x->tr["Increase value"]);
|
||||
btn->setAction(actionInc);
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnInc2 = new IconButton(gmenu2x, "skin:imgs/buttons/right.png");
|
||||
btnInc2->setAction(actionInc);
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/right.png");
|
||||
btn->setAction(actionInc);
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnDec2 = new IconButton(gmenu2x, "skin:imgs/buttons/left.png");
|
||||
btnDec2->setAction(actionDec);
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Decrease value"]);
|
||||
btn->setAction(actionDec);
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
void MenuSettingInt::draw(int y) {
|
||||
void MenuSettingInt::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
}
|
||||
|
||||
void MenuSettingInt::handleTS() {
|
||||
btnInc->handleTS();
|
||||
btnDec->handleTS();
|
||||
btnInc2->handleTS();
|
||||
btnDec2->handleTS();
|
||||
void MenuSettingInt::manageInput()
|
||||
{
|
||||
if (gmenu2x->input[ACTION_LEFT ] || gmenu2x->input[ACTION_X])
|
||||
dec();
|
||||
if (gmenu2x->input[ACTION_RIGHT] || gmenu2x->input[ACTION_Y])
|
||||
inc();
|
||||
}
|
||||
|
||||
void MenuSettingInt::manageInput() {
|
||||
if ( gmenu2x->input[ACTION_LEFT ] || gmenu2x->input[ACTION_X] ) dec();
|
||||
if ( gmenu2x->input[ACTION_RIGHT] || gmenu2x->input[ACTION_Y] ) inc();
|
||||
void MenuSettingInt::inc()
|
||||
{
|
||||
setValue(value() + 1);
|
||||
}
|
||||
|
||||
void MenuSettingInt::inc() {
|
||||
setValue(value()+1);
|
||||
void MenuSettingInt::dec()
|
||||
{
|
||||
setValue(value() - 1);
|
||||
}
|
||||
|
||||
void MenuSettingInt::dec() {
|
||||
setValue(value()-1);
|
||||
}
|
||||
|
||||
void MenuSettingInt::setValue(int value) {
|
||||
void MenuSettingInt::setValue(int value)
|
||||
{
|
||||
*_value = constrain(value,min,max);
|
||||
stringstream ss;
|
||||
ss << *_value;
|
||||
@ -82,24 +89,20 @@ void MenuSettingInt::setValue(int value) {
|
||||
ss >> strvalue;
|
||||
}
|
||||
|
||||
int MenuSettingInt::value() {
|
||||
int MenuSettingInt::value()
|
||||
{
|
||||
return *_value;
|
||||
}
|
||||
|
||||
void MenuSettingInt::adjustInput() {
|
||||
void MenuSettingInt::adjustInput()
|
||||
{
|
||||
#ifdef TARGET_GP2X
|
||||
gmenu2x->input.setInterval(30, ACTION_LEFT );
|
||||
gmenu2x->input.setInterval(30, ACTION_RIGHT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MenuSettingInt::drawSelected(int) {
|
||||
gmenu2x->drawButton(btnInc,
|
||||
gmenu2x->drawButton(btnInc2,
|
||||
gmenu2x->drawButton(btnDec,
|
||||
gmenu2x->drawButton(btnDec2)-10))-10);
|
||||
}
|
||||
|
||||
bool MenuSettingInt::edited() {
|
||||
bool MenuSettingInt::edited()
|
||||
{
|
||||
return originalValue != value();
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ private:
|
||||
int originalValue;
|
||||
int *_value;
|
||||
string strvalue;
|
||||
IconButton *btnInc, *btnDec, *btnInc2, *btnDec2;
|
||||
|
||||
void inc();
|
||||
void dec();
|
||||
@ -41,11 +40,9 @@ public:
|
||||
MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max);
|
||||
virtual ~MenuSettingInt() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
virtual void manageInput();
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual void draw(int);
|
||||
virtual bool edited();
|
||||
|
||||
int min, max;
|
||||
|
@ -24,56 +24,61 @@ using namespace std;
|
||||
using namespace fastdelegate;
|
||||
|
||||
MenuSettingMultiString::MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, vector<string> *choices)
|
||||
: MenuSetting(gmenu2x,name,description) {
|
||||
: MenuSetting(gmenu2x,name,description)
|
||||
{
|
||||
IconButton *btn;
|
||||
|
||||
this->choices = choices;
|
||||
this->value = value;
|
||||
originalValue = *value;
|
||||
setSel( find(choices->begin(),choices->end(),*value)-choices->begin() );
|
||||
|
||||
btnDec = new IconButton(gmenu2x, "skin:imgs/buttons/left.png");
|
||||
btnDec->setAction(MakeDelegate(this, &MenuSettingMultiString::decSel));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/left.png");
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingMultiString::decSel));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnInc = new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change value"]);
|
||||
btnInc->setAction(MakeDelegate(this, &MenuSettingMultiString::incSel));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change value"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingMultiString::incSel));
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
void MenuSettingMultiString::draw(int y) {
|
||||
void MenuSettingMultiString::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write( gmenu2x->font, *value, 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
}
|
||||
|
||||
void MenuSettingMultiString::handleTS() {
|
||||
btnDec->handleTS();
|
||||
btnInc->handleTS();
|
||||
void MenuSettingMultiString::manageInput()
|
||||
{
|
||||
if (gmenu2x->input[ACTION_LEFT ])
|
||||
decSel();
|
||||
if (gmenu2x->input[ACTION_RIGHT])
|
||||
incSel();
|
||||
}
|
||||
|
||||
void MenuSettingMultiString::manageInput() {
|
||||
if ( gmenu2x->input[ACTION_LEFT ] ) decSel();
|
||||
if ( gmenu2x->input[ACTION_RIGHT] ) incSel();
|
||||
}
|
||||
|
||||
void MenuSettingMultiString::incSel() {
|
||||
void MenuSettingMultiString::incSel()
|
||||
{
|
||||
setSel(selected+1);
|
||||
}
|
||||
|
||||
void MenuSettingMultiString::decSel() {
|
||||
void MenuSettingMultiString::decSel()
|
||||
{
|
||||
setSel(selected-1);
|
||||
}
|
||||
|
||||
void MenuSettingMultiString::setSel(int sel) {
|
||||
if (sel<0) sel = choices->size()-1;
|
||||
else if (sel>=(int)choices->size()) sel = 0;
|
||||
void MenuSettingMultiString::setSel(int sel)
|
||||
{
|
||||
if (sel < 0)
|
||||
sel = choices->size()-1;
|
||||
else if (sel >= (int)choices->size())
|
||||
sel = 0;
|
||||
selected = sel;
|
||||
*value = (*choices)[sel];
|
||||
}
|
||||
|
||||
void MenuSettingMultiString::adjustInput() {}
|
||||
|
||||
void MenuSettingMultiString::drawSelected(int) {
|
||||
gmenu2x->drawButton(btnInc,
|
||||
gmenu2x->drawButton(btnDec)-6);
|
||||
}
|
||||
|
||||
bool MenuSettingMultiString::edited() {
|
||||
bool MenuSettingMultiString::edited()
|
||||
{
|
||||
return originalValue != *value;
|
||||
}
|
||||
|
@ -42,10 +42,8 @@ public:
|
||||
virtual ~MenuSettingMultiString() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
virtual void manageInput();
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
};
|
||||
|
||||
|
@ -25,6 +25,8 @@ using namespace fastdelegate;
|
||||
|
||||
MenuSettingRGBA::MenuSettingRGBA(GMenu2X *gmenu2x, const string &name, const string &description, RGBAColor *value)
|
||||
: MenuSetting(gmenu2x,name,description) {
|
||||
IconButton *btn;
|
||||
|
||||
selPart = 0;
|
||||
_value = value;
|
||||
originalValue = *value;
|
||||
@ -33,17 +35,21 @@ MenuSettingRGBA::MenuSettingRGBA(GMenu2X *gmenu2x, const string &name, const str
|
||||
this->setB(this->value().b);
|
||||
this->setA(this->value().a);
|
||||
|
||||
btnDec = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Decrease"]);
|
||||
btnDec->setAction(MakeDelegate(this, &MenuSettingRGBA::dec));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Decrease"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingRGBA::dec));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnInc = new IconButton(gmenu2x, "skin:imgs/buttons/y.png", gmenu2x->tr["Increase"]);
|
||||
btnInc->setAction(MakeDelegate(this, &MenuSettingRGBA::inc));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/y.png", gmenu2x->tr["Increase"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingRGBA::inc));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnLeftComponent = new IconButton(gmenu2x, "skin:imgs/buttons/left.png");
|
||||
btnLeftComponent->setAction(MakeDelegate(this, &MenuSettingRGBA::leftComponent));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/left.png");
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingRGBA::leftComponent));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnRightComponent = new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"]);
|
||||
btnRightComponent->setAction(MakeDelegate(this, &MenuSettingRGBA::rightComponent));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingRGBA::rightComponent));
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::draw(int y) {
|
||||
@ -58,71 +64,83 @@ void MenuSettingRGBA::draw(int y) {
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::handleTS() {
|
||||
if (gmenu2x->ts.pressed())
|
||||
for (int i=0; i<4; i++)
|
||||
if (gmenu2x->ts.pressed()) {
|
||||
for (int i=0; i<4; i++) {
|
||||
if (i!=selPart && gmenu2x->ts.inRect(166+i*36,y,36,14)) {
|
||||
selPart = i;
|
||||
i = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
btnDec->handleTS();
|
||||
btnInc->handleTS();
|
||||
btnLeftComponent->handleTS();
|
||||
btnRightComponent->handleTS();
|
||||
MenuSetting::handleTS();
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::manageInput() {
|
||||
if ( gmenu2x->input[ACTION_Y ]) inc();
|
||||
if ( gmenu2x->input[ACTION_X ]) dec();
|
||||
if ( gmenu2x->input[ACTION_LEFT ]) leftComponent();
|
||||
if ( gmenu2x->input[ACTION_RIGHT]) rightComponent();
|
||||
if (gmenu2x->input[ACTION_Y])
|
||||
inc();
|
||||
if (gmenu2x->input[ACTION_X])
|
||||
dec();
|
||||
if (gmenu2x->input[ACTION_LEFT])
|
||||
leftComponent();
|
||||
if (gmenu2x->input[ACTION_RIGHT])
|
||||
rightComponent();
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::dec() {
|
||||
setSelPart( constrain(getSelPart()-1,0,255) );
|
||||
void MenuSettingRGBA::dec()
|
||||
{
|
||||
setSelPart(constrain(getSelPart()-1,0,255));
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::inc() {
|
||||
setSelPart( constrain(getSelPart()+1,0,255) );
|
||||
void MenuSettingRGBA::inc()
|
||||
{
|
||||
setSelPart(constrain(getSelPart()+1,0,255));
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::leftComponent() {
|
||||
void MenuSettingRGBA::leftComponent()
|
||||
{
|
||||
selPart = constrain(selPart-1,0,3);
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::rightComponent() {
|
||||
void MenuSettingRGBA::rightComponent()
|
||||
{
|
||||
selPart = constrain(selPart+1,0,3);
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::setR(unsigned short r) {
|
||||
void MenuSettingRGBA::setR(unsigned short r)
|
||||
{
|
||||
_value->r = r;
|
||||
stringstream ss;
|
||||
ss << r;
|
||||
ss >> strR;
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::setG(unsigned short g) {
|
||||
void MenuSettingRGBA::setG(unsigned short g)
|
||||
{
|
||||
_value->g = g;
|
||||
stringstream ss;
|
||||
ss << g;
|
||||
ss >> strG;
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::setB(unsigned short b) {
|
||||
void MenuSettingRGBA::setB(unsigned short b)
|
||||
{
|
||||
_value->b = b;
|
||||
stringstream ss;
|
||||
ss << b;
|
||||
ss >> strB;
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::setA(unsigned short a) {
|
||||
void MenuSettingRGBA::setA(unsigned short a)
|
||||
{
|
||||
_value->a = a;
|
||||
stringstream ss;
|
||||
ss << a;
|
||||
ss >> strA;
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::setSelPart(unsigned short value) {
|
||||
void MenuSettingRGBA::setSelPart(unsigned short value)
|
||||
{
|
||||
switch (selPart) {
|
||||
default: case 0: setR(value); break;
|
||||
case 1: setG(value); break;
|
||||
@ -131,11 +149,13 @@ void MenuSettingRGBA::setSelPart(unsigned short value) {
|
||||
}
|
||||
}
|
||||
|
||||
RGBAColor MenuSettingRGBA::value() {
|
||||
RGBAColor MenuSettingRGBA::value()
|
||||
{
|
||||
return *_value;
|
||||
}
|
||||
|
||||
unsigned short MenuSettingRGBA::getSelPart() {
|
||||
unsigned short MenuSettingRGBA::getSelPart()
|
||||
{
|
||||
switch (selPart) {
|
||||
default: case 0: return value().r;
|
||||
case 1: return value().g;
|
||||
@ -144,7 +164,8 @@ unsigned short MenuSettingRGBA::getSelPart() {
|
||||
}
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::adjustInput() {
|
||||
void MenuSettingRGBA::adjustInput()
|
||||
{
|
||||
#ifdef TARGET_GP2X
|
||||
gmenu2x->input.setInterval(30, ACTION_Y );
|
||||
gmenu2x->input.setInterval(30, ACTION_X );
|
||||
@ -152,16 +173,15 @@ void MenuSettingRGBA::adjustInput() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::drawSelected(int y) {
|
||||
void MenuSettingRGBA::drawSelected(int y)
|
||||
{
|
||||
int x = 166+selPart*36;
|
||||
gmenu2x->s->box( x, y, 36, 14, gmenu2x->skinConfColors[COLOR_SELECTION_BG] );
|
||||
|
||||
gmenu2x->drawButton(btnDec,
|
||||
gmenu2x->drawButton(btnInc,
|
||||
gmenu2x->drawButton(btnRightComponent,
|
||||
gmenu2x->drawButton(btnLeftComponent)-6)));
|
||||
MenuSetting::drawSelected(y);
|
||||
}
|
||||
|
||||
bool MenuSettingRGBA::edited() {
|
||||
bool MenuSettingRGBA::edited()
|
||||
{
|
||||
return originalValue.r != value().r || originalValue.g != value().g || originalValue.b != value().b || originalValue.a != value().a;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ private:
|
||||
string strR, strG, strB, strA;
|
||||
RGBAColor originalValue;
|
||||
RGBAColor *_value;
|
||||
IconButton *btnDec, *btnInc, *btnLeftComponent, *btnRightComponent;
|
||||
|
||||
void dec();
|
||||
void inc();
|
||||
|
@ -25,57 +25,61 @@ using namespace std;
|
||||
using namespace fastdelegate;
|
||||
|
||||
MenuSettingString::MenuSettingString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &diagTitle, const string &diagIcon)
|
||||
: MenuSetting(gmenu2x,name,description) {
|
||||
: MenuSetting(gmenu2x, name, description)
|
||||
{
|
||||
IconButton *btn;
|
||||
|
||||
_value = value;
|
||||
originalValue = *value;
|
||||
this->diagTitle = diagTitle;
|
||||
this->diagIcon = diagIcon;
|
||||
|
||||
btnClear = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
|
||||
btnClear->setAction(MakeDelegate(this, &MenuSettingString::clear));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingString::clear));
|
||||
buttonBox.add(btn);
|
||||
|
||||
btnEdit = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Edit"]);
|
||||
btnEdit->setAction(MakeDelegate(this, &MenuSettingString::edit));
|
||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Edit"]);
|
||||
btn->setAction(MakeDelegate(this, &MenuSettingString::edit));
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
void MenuSettingString::draw(int y) {
|
||||
void MenuSettingString::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write( gmenu2x->font, value(), 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
gmenu2x->s->write(gmenu2x->font, value(), 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle);
|
||||
}
|
||||
|
||||
void MenuSettingString::handleTS() {
|
||||
btnEdit->handleTS();
|
||||
void MenuSettingString::manageInput()
|
||||
{
|
||||
if (gmenu2x->input[ACTION_X])
|
||||
clear();
|
||||
if (gmenu2x->input[ACTION_B])
|
||||
edit();
|
||||
}
|
||||
|
||||
void MenuSettingString::manageInput() {
|
||||
if ( gmenu2x->input[ACTION_X] ) clear();
|
||||
if ( gmenu2x->input[ACTION_B] ) edit();
|
||||
}
|
||||
|
||||
void MenuSettingString::setValue(const string &value) {
|
||||
void MenuSettingString::setValue(const string &value)
|
||||
{
|
||||
*_value = value;
|
||||
}
|
||||
|
||||
const string &MenuSettingString::value() {
|
||||
const string &MenuSettingString::value()
|
||||
{
|
||||
return *_value;
|
||||
}
|
||||
|
||||
void MenuSettingString::adjustInput() {}
|
||||
|
||||
void MenuSettingString::clear() {
|
||||
void MenuSettingString::clear()
|
||||
{
|
||||
setValue("");
|
||||
}
|
||||
|
||||
void MenuSettingString::edit() {
|
||||
void MenuSettingString::edit()
|
||||
{
|
||||
InputDialog id(gmenu2x,description,value(), diagTitle,diagIcon);
|
||||
if (id.exec()) setValue(id.input);
|
||||
}
|
||||
|
||||
void MenuSettingString::drawSelected(int) {
|
||||
gmenu2x->drawButton(btnClear,
|
||||
gmenu2x->drawButton(btnEdit));
|
||||
}
|
||||
|
||||
bool MenuSettingString::edited() {
|
||||
return originalValue != value();
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ class MenuSettingString : public MenuSetting {
|
||||
private:
|
||||
string originalValue, diagTitle, diagIcon;
|
||||
string *_value;
|
||||
IconButton *btnClear, *btnEdit;
|
||||
|
||||
void edit();
|
||||
void clear();
|
||||
@ -39,10 +38,8 @@ public:
|
||||
virtual ~MenuSettingString() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
virtual void manageInput();
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
||||
void setValue(const string &value);
|
||||
|
Loading…
Reference in New Issue
Block a user