2010-02-04 13:33:47 +02:00
|
|
|
/***************************************************************************
|
2011-10-23 17:43:56 +03:00
|
|
|
* Copyright (C) 2006 by Massimiliano Torromeo *
|
|
|
|
* massimiliano.torromeo@gmail.com *
|
2010-02-04 13:33:47 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
***************************************************************************/
|
2011-10-23 17:43:56 +03:00
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
#ifndef MENU_H
|
|
|
|
#define MENU_H
|
|
|
|
|
2013-07-29 19:58:25 +03:00
|
|
|
#include "delegate.h"
|
2013-08-05 17:43:22 +03:00
|
|
|
#include "inputmanager.h"
|
|
|
|
#include "link.h"
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
class LinkApp;
|
|
|
|
class GMenu2X;
|
2013-07-16 20:36:18 +03:00
|
|
|
class Monitor;
|
2013-08-04 22:14:29 +03:00
|
|
|
class Surface;
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Handles the menu structure
|
|
|
|
|
|
|
|
@author Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
|
|
|
|
*/
|
|
|
|
class Menu {
|
|
|
|
private:
|
|
|
|
GMenu2X *gmenu2x;
|
2011-12-23 15:03:05 +02:00
|
|
|
Touchscreen &ts;
|
2010-02-04 13:33:47 +02:00
|
|
|
int iSection, iLink;
|
2013-08-05 15:54:42 +03:00
|
|
|
uint iFirstDispRow;
|
2011-10-23 17:43:56 +03:00
|
|
|
std::vector<std::string> sections;
|
|
|
|
std::vector< std::vector<Link*> > links;
|
2010-07-27 22:12:15 +03:00
|
|
|
|
2013-08-05 01:51:36 +03:00
|
|
|
uint linkColumns, linkRows;
|
|
|
|
|
2013-08-05 15:54:42 +03:00
|
|
|
/**
|
|
|
|
* Determine which section headers are visible.
|
|
|
|
* The output values are relative to the middle section at 0.
|
|
|
|
*/
|
|
|
|
void calcSectionRange(int &leftSection, int &rightSection);
|
|
|
|
|
2013-08-04 23:07:34 +03:00
|
|
|
std::vector<Link*> *sectionLinks(int i = -1);
|
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
void readLinks();
|
|
|
|
void freeLinks();
|
2013-07-19 00:38:09 +03:00
|
|
|
void orderLinks();
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2011-07-11 03:49:44 +03:00
|
|
|
// Load all the sections of the given "sections" directory.
|
|
|
|
void readSections(std::string parentDir);
|
|
|
|
|
2012-10-07 22:51:25 +03:00
|
|
|
#ifdef HAVE_LIBOPK
|
|
|
|
// Load all the .opk packages of the given directory
|
|
|
|
void readPackages(std::string parentDir);
|
2013-07-16 20:36:18 +03:00
|
|
|
#ifdef ENABLE_INOTIFY
|
|
|
|
std::vector<Monitor *> monitors;
|
|
|
|
#endif
|
2012-10-07 22:51:25 +03:00
|
|
|
#endif
|
|
|
|
|
2011-07-11 03:49:44 +03:00
|
|
|
// Load all the links on the given section directory.
|
|
|
|
void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles);
|
|
|
|
|
2013-08-05 17:43:22 +03:00
|
|
|
void decSectionIndex();
|
|
|
|
void incSectionIndex();
|
|
|
|
void linkLeft();
|
|
|
|
void linkRight();
|
|
|
|
void linkUp();
|
|
|
|
void linkDown();
|
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
public:
|
2011-12-23 15:03:05 +02:00
|
|
|
Menu(GMenu2X *gmenu2x, Touchscreen &ts);
|
2010-02-04 13:33:47 +02:00
|
|
|
~Menu();
|
|
|
|
|
2013-07-16 20:36:18 +03:00
|
|
|
#ifdef HAVE_LIBOPK
|
2013-07-19 19:50:20 +03:00
|
|
|
void openPackage(std::string path, bool order = true);
|
2013-07-19 19:01:25 +03:00
|
|
|
void openPackagesFromDir(std::string path);
|
2013-07-16 20:36:18 +03:00
|
|
|
#ifdef ENABLE_INOTIFY
|
|
|
|
void removePackageLink(std::string path);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
int selSectionIndex();
|
2011-10-23 17:43:56 +03:00
|
|
|
const std::string &selSection();
|
2010-02-04 13:33:47 +02:00
|
|
|
void setSectionIndex(int i);
|
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
bool addActionLink(uint section, const std::string &title,
|
2013-07-29 19:58:25 +03:00
|
|
|
function_t action, const std::string &description="",
|
2011-10-23 17:43:56 +03:00
|
|
|
const std::string &icon="");
|
|
|
|
bool addLink(std::string path, std::string file, std::string section="");
|
|
|
|
bool addSection(const std::string §ionName);
|
2010-02-04 13:33:47 +02:00
|
|
|
void deleteSelectedLink();
|
|
|
|
void deleteSelectedSection();
|
|
|
|
|
2013-08-05 01:51:36 +03:00
|
|
|
void skinUpdated();
|
2013-08-04 22:14:29 +03:00
|
|
|
void paint(Surface &s);
|
2013-08-05 17:43:22 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the pressing of the give button.
|
|
|
|
* Returns true iff the event was consumed.
|
|
|
|
*/
|
|
|
|
bool handleButtonPress(InputManager::Button button);
|
|
|
|
|
2013-08-04 23:07:34 +03:00
|
|
|
void handleTS();
|
2010-02-04 13:33:47 +02:00
|
|
|
bool linkChangeSection(uint linkIndex, uint oldSectionIndex, uint newSectionIndex);
|
|
|
|
|
|
|
|
int selLinkIndex();
|
|
|
|
Link *selLink();
|
|
|
|
LinkApp *selLinkApp();
|
|
|
|
void setLinkIndex(int i);
|
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
const std::vector<std::string> &getSections() { return sections; }
|
|
|
|
void renameSection(int index, const std::string &name);
|
2010-02-04 13:33:47 +02:00
|
|
|
};
|
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
#endif // MENU_H
|