mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 17:51:34 +02:00
Add function GMenu2X::getTouchscreen(), to simplify Link and LinkApp prototypes
This commit is contained in:
parent
20339c8849
commit
1ff17d83c9
@ -213,6 +213,8 @@ public:
|
|||||||
|
|
||||||
void drawTopBar(Surface *s);
|
void drawTopBar(Surface *s);
|
||||||
void drawBottomBar(Surface *s);
|
void drawBottomBar(Surface *s);
|
||||||
|
|
||||||
|
Touchscreen &getTouchscreen() { return ts; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GMENU2X_H
|
#endif // GMENU2X_H
|
||||||
|
@ -32,13 +32,15 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
Link::Link(GMenu2X *gmenu2x, Touchscreen &ts, function_t action)
|
Link::Link(GMenu2X *gmenu2x, function_t action)
|
||||||
: gmenu2x(gmenu2x)
|
: gmenu2x(gmenu2x)
|
||||||
, ts(ts)
|
, ts(gmenu2x->getTouchscreen())
|
||||||
, action(action)
|
, action(action)
|
||||||
, rect((SDL_Rect) { 0, 0, 0, 0 })
|
|
||||||
, lastTick(0)
|
, lastTick(0)
|
||||||
{
|
{
|
||||||
|
// ts = gmenu2x->getTouchscreen();
|
||||||
|
rect.w = gmenu2x->skinConfInt["linkWidth"];
|
||||||
|
rect.h = gmenu2x->skinConfInt["linkHeight"];
|
||||||
edited = false;
|
edited = false;
|
||||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
||||||
iconX = 0;
|
iconX = 0;
|
||||||
|
@ -38,7 +38,7 @@ Base class that represents a link on screen.
|
|||||||
*/
|
*/
|
||||||
class Link {
|
class Link {
|
||||||
public:
|
public:
|
||||||
Link(GMenu2X *gmenu2x, Touchscreen &ts, function_t action);
|
Link(GMenu2X *gmenu2x, function_t action);
|
||||||
virtual ~Link() {};
|
virtual ~Link() {};
|
||||||
|
|
||||||
bool isPressed();
|
bool isPressed();
|
||||||
|
@ -57,13 +57,13 @@ using namespace std;
|
|||||||
static const char *tokens[] = { "%f", "%F", "%u", "%U", };
|
static const char *tokens[] = { "%f", "%F", "%u", "%U", };
|
||||||
|
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
LinkApp::LinkApp(GMenu2X *gmenu2x_, InputManager &inputMgr_,
|
||||||
const char* linkfile, struct OPK *opk)
|
const char* linkfile, struct OPK *opk)
|
||||||
#else
|
#else
|
||||||
LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
LinkApp::LinkApp(GMenu2X *gmenu2x_, InputManager &inputMgr_,
|
||||||
const char* linkfile)
|
const char* linkfile)
|
||||||
#endif
|
#endif
|
||||||
: Link(gmenu2x_, ts, BIND(&LinkApp::start))
|
: Link(gmenu2x_, BIND(&LinkApp::start))
|
||||||
, inputMgr(inputMgr_)
|
, inputMgr(inputMgr_)
|
||||||
{
|
{
|
||||||
manual = "";
|
manual = "";
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
class GMenu2X;
|
class GMenu2X;
|
||||||
class InputManager;
|
class InputManager;
|
||||||
class Touchscreen;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Parses links files.
|
Parses links files.
|
||||||
@ -62,10 +61,10 @@ public:
|
|||||||
bool isOpk() { return isOPK; }
|
bool isOpk() { return isOPK; }
|
||||||
const std::string &getOpkFile() { return opkFile; }
|
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);
|
const char* linkfile, struct OPK *opk = NULL);
|
||||||
#else
|
#else
|
||||||
LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr,
|
LinkApp(GMenu2X *gmenu2x, InputManager &inputMgr,
|
||||||
const char* linkfile);
|
const char* linkfile);
|
||||||
bool isOpk() { return false; }
|
bool isOpk() { return false; }
|
||||||
#endif
|
#endif
|
||||||
|
@ -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) {
|
bool Menu::addActionLink(uint section, const string &title, function_t action, const string &description, const string &icon) {
|
||||||
if (section>=sections.size()) return false;
|
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->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
|
||||||
link->setTitle(title);
|
link->setTitle(title);
|
||||||
link->setDescription(description);
|
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);
|
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"]);
|
link->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]);
|
||||||
links[isection].push_back( link );
|
links[isection].push_back( link );
|
||||||
}
|
}
|
||||||
@ -703,7 +703,7 @@ void Menu::openPackage(std::string path, bool order)
|
|||||||
if (!has_metadata)
|
if (!has_metadata)
|
||||||
break;
|
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"]);
|
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
|
||||||
|
|
||||||
addSection(link->getCategory());
|
addSection(link->getCategory());
|
||||||
@ -845,7 +845,7 @@ void Menu::readLinks() {
|
|||||||
|
|
||||||
sort(linkfiles.begin(), linkfiles.end(),case_less());
|
sort(linkfiles.begin(), linkfiles.end(),case_less());
|
||||||
for (uint x=0; x<linkfiles.size(); x++) {
|
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"]);
|
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
|
||||||
if (link->targetExists())
|
if (link->targetExists())
|
||||||
links[i].push_back(link);
|
links[i].push_back(link);
|
||||||
|
Loading…
Reference in New Issue
Block a user