1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 17:41:52 +02:00

Add function GMenu2X::getTouchscreen(), to simplify Link and LinkApp prototypes

This commit is contained in:
Paul Cercueil 2013-09-05 19:19:16 -04:00
parent 20339c8849
commit 1ff17d83c9
6 changed files with 17 additions and 14 deletions

View File

@ -213,6 +213,8 @@ public:
void drawTopBar(Surface *s);
void drawBottomBar(Surface *s);
Touchscreen &getTouchscreen() { return ts; }
};
#endif // GMENU2X_H

View File

@ -32,13 +32,15 @@
using namespace std;
Link::Link(GMenu2X *gmenu2x, Touchscreen &ts, function_t action)
Link::Link(GMenu2X *gmenu2x, function_t action)
: gmenu2x(gmenu2x)
, ts(ts)
, ts(gmenu2x->getTouchscreen())
, action(action)
, rect((SDL_Rect) { 0, 0, 0, 0 })
, lastTick(0)
{
// ts = gmenu2x->getTouchscreen();
rect.w = gmenu2x->skinConfInt["linkWidth"];
rect.h = gmenu2x->skinConfInt["linkHeight"];
edited = false;
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
iconX = 0;

View File

@ -38,7 +38,7 @@ Base class that represents a link on screen.
*/
class Link {
public:
Link(GMenu2X *gmenu2x, Touchscreen &ts, function_t action);
Link(GMenu2X *gmenu2x, function_t action);
virtual ~Link() {};
bool isPressed();

View File

@ -57,13 +57,13 @@ using namespace std;
static const char *tokens[] = { "%f", "%F", "%u", "%U", };
#ifdef HAVE_LIBOPK
LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
LinkApp::LinkApp(GMenu2X *gmenu2x_, InputManager &inputMgr_,
const char* linkfile, struct OPK *opk)
#else
LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
LinkApp::LinkApp(GMenu2X *gmenu2x_, InputManager &inputMgr_,
const char* linkfile)
#endif
: Link(gmenu2x_, ts, BIND(&LinkApp::start))
: Link(gmenu2x_, BIND(&LinkApp::start))
, inputMgr(inputMgr_)
{
manual = "";

View File

@ -27,7 +27,6 @@
class GMenu2X;
class InputManager;
class Touchscreen;
/**
Parses links files.
@ -62,10 +61,10 @@ public:
bool isOpk() { return isOPK; }
const std::string &getOpkFile() { return opkFile; }
LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr,
LinkApp(GMenu2X *gmenu2x, InputManager &inputMgr,
const char* linkfile, struct OPK *opk = NULL);
#else
LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr,
LinkApp(GMenu2X *gmenu2x, InputManager &inputMgr,
const char* linkfile);
bool isOpk() { return false; }
#endif

View File

@ -399,7 +399,7 @@ void Menu::setSectionIndex(int i) {
bool Menu::addActionLink(uint section, const string &title, function_t action, const string &description, const string &icon) {
if (section>=sections.size()) return false;
Link *link = new Link(gmenu2x, ts, action);
Link *link = new Link(gmenu2x, action);
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
link->setTitle(title);
link->setDescription(description);
@ -500,7 +500,7 @@ bool Menu::addLink(string path, string file, string section) {
INFO("Section: '%s(%i)'\n", sections[isection].c_str(), isection);
LinkApp* link = new LinkApp(gmenu2x, ts, gmenu2x->input, linkpath.c_str());
LinkApp* link = new LinkApp(gmenu2x, gmenu2x->input, linkpath.c_str());
link->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]);
links[isection].push_back( link );
}
@ -703,7 +703,7 @@ void Menu::openPackage(std::string path, bool order)
if (!has_metadata)
break;
link = new LinkApp(gmenu2x, ts, gmenu2x->input, path.c_str(), opk);
link = new LinkApp(gmenu2x, gmenu2x->input, path.c_str(), opk);
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
addSection(link->getCategory());
@ -845,7 +845,7 @@ void Menu::readLinks() {
sort(linkfiles.begin(), linkfiles.end(),case_less());
for (uint x=0; x<linkfiles.size(); x++) {
LinkApp *link = new LinkApp(gmenu2x, ts, gmenu2x->input, linkfiles[x].c_str());
LinkApp *link = new LinkApp(gmenu2x, gmenu2x->input, linkfiles[x].c_str());
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
if (link->targetExists())
links[i].push_back(link);