From 1ff17d83c9c6f178e9bcb8f8c5792121a5545365 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Thu, 5 Sep 2013 19:19:16 -0400 Subject: [PATCH] Add function GMenu2X::getTouchscreen(), to simplify Link and LinkApp prototypes --- src/gmenu2x.h | 2 ++ src/link.cpp | 8 +++++--- src/link.h | 2 +- src/linkapp.cpp | 6 +++--- src/linkapp.h | 5 ++--- src/menu.cpp | 8 ++++---- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/gmenu2x.h b/src/gmenu2x.h index dcb7157..8aec704 100644 --- a/src/gmenu2x.h +++ b/src/gmenu2x.h @@ -213,6 +213,8 @@ public: void drawTopBar(Surface *s); void drawBottomBar(Surface *s); + + Touchscreen &getTouchscreen() { return ts; } }; #endif // GMENU2X_H diff --git a/src/link.cpp b/src/link.cpp index b3af34f..eba4710 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -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; diff --git a/src/link.h b/src/link.h index 47ff8a5..9eda73d 100644 --- a/src/link.h +++ b/src/link.h @@ -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(); diff --git a/src/linkapp.cpp b/src/linkapp.cpp index f6c6481..24808b5 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -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 = ""; diff --git a/src/linkapp.h b/src/linkapp.h index b0849b4..fa0fdbc 100644 --- a/src/linkapp.h +++ b/src/linkapp.h @@ -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 diff --git a/src/menu.cpp b/src/menu.cpp index 3711bdc..07cbdf7 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -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; xinput, 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);