mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-12-25 07:59:53 +02:00
Pass GMenu2X instance by reference instead of pointer
This makes it explicit that null is not accepted.
This commit is contained in:
parent
05a58e869c
commit
11ca8308b1
@ -11,7 +11,7 @@ using std::string;
|
||||
using std::unique_ptr;
|
||||
|
||||
BrowseDialog::BrowseDialog(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts_,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
||||
const string &title, const string &subtitle)
|
||||
: Dialog(gmenu2x)
|
||||
, ts(ts_)
|
||||
@ -23,27 +23,27 @@ BrowseDialog::BrowseDialog(
|
||||
gmenu2x, ts, "skin:imgs/buttons/left.png")));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
||||
gmenu2x->tr["Up one folder"],
|
||||
gmenu2x.tr["Up one folder"],
|
||||
bind(&BrowseDialog::directoryUp, this))));
|
||||
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
||||
gmenu2x->tr["Select"],
|
||||
gmenu2x.tr["Select"],
|
||||
bind(&BrowseDialog::directoryEnter, this))));
|
||||
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/start.png",
|
||||
gmenu2x->tr["Confirm"],
|
||||
gmenu2x.tr["Confirm"],
|
||||
bind(&BrowseDialog::confirm, this))));
|
||||
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/select.png",
|
||||
gmenu2x->tr["Exit"],
|
||||
gmenu2x.tr["Exit"],
|
||||
bind(&BrowseDialog::quit, this))));
|
||||
|
||||
iconGoUp = gmenu2x->sc.skinRes("imgs/go-up.png");
|
||||
iconFolder = gmenu2x->sc.skinRes("imgs/folder.png");
|
||||
iconFile = gmenu2x->sc.skinRes("imgs/file.png");
|
||||
iconGoUp = gmenu2x.sc.skinRes("imgs/go-up.png");
|
||||
iconFolder = gmenu2x.sc.skinRes("imgs/folder.png");
|
||||
iconFile = gmenu2x.sc.skinRes("imgs/file.png");
|
||||
}
|
||||
|
||||
BrowseDialog::~BrowseDialog()
|
||||
@ -57,20 +57,20 @@ bool BrowseDialog::exec()
|
||||
|| path.compare(0, strlen(CARD_ROOT), CARD_ROOT) != 0)
|
||||
setPath(CARD_ROOT);
|
||||
|
||||
const int topBarHeight = gmenu2x->skinConfInt["topBarHeight"];
|
||||
rowHeight = gmenu2x->font->getLineSpacing() + 1; // gp2x=15+1 / pandora=19+1
|
||||
const int topBarHeight = gmenu2x.skinConfInt["topBarHeight"];
|
||||
rowHeight = gmenu2x.font->getLineSpacing() + 1; // gp2x=15+1 / pandora=19+1
|
||||
rowHeight = constrain(rowHeight, 20, 40);
|
||||
numRows = (gmenu2x->resY - topBarHeight - 20) / rowHeight;
|
||||
numRows = (gmenu2x.resY - topBarHeight - 20) / rowHeight;
|
||||
clipRect = (SDL_Rect) {
|
||||
0,
|
||||
static_cast<Sint16>(topBarHeight + 1),
|
||||
static_cast<Uint16>(gmenu2x->resX - 9),
|
||||
static_cast<Uint16>(gmenu2x->resY - topBarHeight - 25)
|
||||
static_cast<Uint16>(gmenu2x.resX - 9),
|
||||
static_cast<Uint16>(gmenu2x.resY - topBarHeight - 25)
|
||||
};
|
||||
touchRect = (SDL_Rect) {
|
||||
2,
|
||||
static_cast<Sint16>(topBarHeight + 4),
|
||||
static_cast<Uint16>(gmenu2x->resX - 12),
|
||||
static_cast<Uint16>(gmenu2x.resX - 12),
|
||||
clipRect.h
|
||||
};
|
||||
|
||||
@ -114,7 +114,7 @@ BrowseDialog::Action BrowseDialog::getAction(InputManager::Button button)
|
||||
|
||||
void BrowseDialog::handleInput()
|
||||
{
|
||||
InputManager::Button button = gmenu2x->input.waitForPressedButton();
|
||||
InputManager::Button button = gmenu2x.input.waitForPressedButton();
|
||||
|
||||
BrowseDialog::Action action;
|
||||
if (ts_pressed && !ts.pressed()) {
|
||||
@ -221,17 +221,17 @@ void BrowseDialog::quit()
|
||||
|
||||
void BrowseDialog::paint()
|
||||
{
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
|
||||
unsigned int i, iY;
|
||||
unsigned int firstElement, lastElement;
|
||||
unsigned int offsetY;
|
||||
|
||||
OffscreenSurface bg(*gmenu2x->bg);
|
||||
OffscreenSurface bg(*gmenu2x.bg);
|
||||
drawTitleIcon(bg, "icons/explorer.png", true);
|
||||
writeTitle(bg, title);
|
||||
writeSubTitle(bg, subtitle);
|
||||
buttonBox.paint(bg, 5, gmenu2x->resY - 1);
|
||||
buttonBox.paint(bg, 5, gmenu2x.resY - 1);
|
||||
|
||||
bg.convertToDisplayFormat();
|
||||
bg.blit(s, 0, 0);
|
||||
@ -246,10 +246,10 @@ void BrowseDialog::paint()
|
||||
}
|
||||
|
||||
//Selection
|
||||
const int topBarHeight = gmenu2x->skinConfInt["topBarHeight"];
|
||||
const int topBarHeight = gmenu2x.skinConfInt["topBarHeight"];
|
||||
iY = topBarHeight + 1 + (selected - firstElement) * rowHeight;
|
||||
s.box(2, iY, gmenu2x->resX - 12, rowHeight - 1,
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
s.box(2, iY, gmenu2x.resX - 12, rowHeight - 1,
|
||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
|
||||
lastElement = firstElement + numRows;
|
||||
if (lastElement > fl.size())
|
||||
@ -271,7 +271,7 @@ void BrowseDialog::paint()
|
||||
icon = iconFile;
|
||||
}
|
||||
icon->blit(s, 5, offsetY);
|
||||
gmenu2x->font->write(s, fl[i], 24, offsetY + rowHeight / 2,
|
||||
gmenu2x.font->write(s, fl[i], 24, offsetY + rowHeight / 2,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
|
||||
if (ts.available() && ts.pressed()
|
||||
@ -284,6 +284,6 @@ void BrowseDialog::paint()
|
||||
}
|
||||
s.clearClipRect();
|
||||
|
||||
gmenu2x->drawScrollBar(numRows,fl.size(), firstElement);
|
||||
gmenu2x.drawScrollBar(numRows,fl.size(), firstElement);
|
||||
s.flip();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class Touchscreen;
|
||||
class BrowseDialog : protected Dialog {
|
||||
protected:
|
||||
BrowseDialog(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &title, const std::string &subtitle);
|
||||
virtual ~BrowseDialog();
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "gmenu2x.h"
|
||||
#include "font.h"
|
||||
|
||||
Dialog::Dialog(GMenu2X *gmenu2x) : gmenu2x(gmenu2x)
|
||||
Dialog::Dialog(GMenu2X& gmenu2x) : gmenu2x(gmenu2x)
|
||||
{
|
||||
}
|
||||
|
||||
@ -13,27 +13,27 @@ void Dialog::drawTitleIcon(Surface& s, const std::string &icon, bool skinRes)
|
||||
Surface *i = NULL;
|
||||
if (!icon.empty()) {
|
||||
if (skinRes)
|
||||
i = gmenu2x->sc.skinRes(icon);
|
||||
i = gmenu2x.sc.skinRes(icon);
|
||||
else
|
||||
i = gmenu2x->sc[icon];
|
||||
i = gmenu2x.sc[icon];
|
||||
}
|
||||
|
||||
if (i==NULL)
|
||||
i = gmenu2x->sc.skinRes("icons/generic.png");
|
||||
i = gmenu2x.sc.skinRes("icons/generic.png");
|
||||
|
||||
i->blit(s, 4, (gmenu2x->skinConfInt["topBarHeight"] - 32) / 2);
|
||||
i->blit(s, 4, (gmenu2x.skinConfInt["topBarHeight"] - 32) / 2);
|
||||
}
|
||||
|
||||
void Dialog::writeTitle(Surface& s, const std::string &title)
|
||||
{
|
||||
gmenu2x->font->write(s, title, 40, 0, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x.font->write(s, title, 40, 0, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
void Dialog::writeSubTitle(Surface& s, const std::string &subtitle)
|
||||
{
|
||||
std::string wrapped = gmenu2x->font->wordWrap(subtitle, gmenu2x->resX - 48);
|
||||
gmenu2x->font->write(s, wrapped, 40,
|
||||
gmenu2x->skinConfInt["topBarHeight"]
|
||||
- gmenu2x->font->getTextHeight(wrapped),
|
||||
std::string wrapped = gmenu2x.font->wordWrap(subtitle, gmenu2x.resX - 48);
|
||||
gmenu2x.font->write(s, wrapped, 40,
|
||||
gmenu2x.skinConfInt["topBarHeight"]
|
||||
- gmenu2x.font->getTextHeight(wrapped),
|
||||
Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
@ -9,14 +9,14 @@ class Surface;
|
||||
class Dialog
|
||||
{
|
||||
public:
|
||||
Dialog(GMenu2X *gmenu2x);
|
||||
Dialog(GMenu2X& gmenu2x);
|
||||
|
||||
protected:
|
||||
void drawTitleIcon(Surface& s, const std::string &icon, bool skinRes = false);
|
||||
void writeTitle(Surface& s, const std::string &title);
|
||||
void writeSubTitle(Surface& s, const std::string &subtitle);
|
||||
|
||||
GMenu2X *gmenu2x;
|
||||
GMenu2X& gmenu2x;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -25,7 +25,7 @@
|
||||
using namespace std;
|
||||
|
||||
DirDialog::DirDialog(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const string &text, const string &dir)
|
||||
: BrowseDialog(gmenu2x, ts, "Directory Browser", text)
|
||||
{
|
||||
|
@ -26,7 +26,7 @@
|
||||
class DirDialog : public BrowseDialog {
|
||||
public:
|
||||
DirDialog(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &text, const std::string &dir = "");
|
||||
};
|
||||
|
||||
|
@ -21,12 +21,11 @@
|
||||
#include "filedialog.h"
|
||||
|
||||
#include "filelister.h"
|
||||
#include "gmenu2x.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FileDialog::FileDialog(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts, const string &text,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts, const string &text,
|
||||
const string &filter, const string &file, const string &title)
|
||||
: BrowseDialog(gmenu2x, ts, title, text)
|
||||
{
|
||||
|
@ -26,7 +26,7 @@
|
||||
class FileDialog : public BrowseDialog {
|
||||
public:
|
||||
FileDialog(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts, const std::string &text,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts, const std::string &text,
|
||||
const std::string &filter="*", const std::string &file="",
|
||||
const std::string &title = "File Dialog");
|
||||
bool exec();
|
||||
|
@ -214,7 +214,7 @@ void GMenu2X::initCPULimits() {
|
||||
#endif
|
||||
|
||||
GMenu2X::GMenu2X()
|
||||
: input(powerSaver)
|
||||
: input(*this, powerSaver)
|
||||
{
|
||||
usbnet = samba = inet = web = false;
|
||||
useSelectionPng = false;
|
||||
@ -279,7 +279,7 @@ GMenu2X::GMenu2X()
|
||||
monitor = new MediaMonitor(CARD_ROOT);
|
||||
#endif
|
||||
|
||||
if (!input.init(this, menu.get())) {
|
||||
if (!input.init(menu.get())) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ void GMenu2X::initFont() {
|
||||
|
||||
void GMenu2X::initMenu() {
|
||||
//Menu structure handler
|
||||
menu.reset(new Menu(this, ts));
|
||||
menu.reset(new Menu(*this, ts));
|
||||
for (uint i=0; i<menu->getSections().size(); i++) {
|
||||
//Add virtual links in the applications section
|
||||
if (menu->getSections()[i]=="applications") {
|
||||
@ -425,19 +425,19 @@ void GMenu2X::initMenu() {
|
||||
void GMenu2X::about() {
|
||||
string text(readFileAsString(GMENU2X_SYSTEM_DIR "/about.txt"));
|
||||
string build_date("Build date: " __DATE__);
|
||||
TextDialog td(this, "GMenu2X", build_date, "icons/about.png", text);
|
||||
TextDialog td(*this, "GMenu2X", build_date, "icons/about.png", text);
|
||||
td.exec();
|
||||
}
|
||||
|
||||
void GMenu2X::viewLog() {
|
||||
string text(readFileAsString(LOG_FILE));
|
||||
|
||||
TextDialog td(this, tr["Log Viewer"],
|
||||
TextDialog td(*this, tr["Log Viewer"],
|
||||
tr["Displays last launched program's output"],
|
||||
"icons/ebook.png", text);
|
||||
td.exec();
|
||||
|
||||
MessageBox mb(this, tr["Do you want to delete the log file?"],
|
||||
MessageBox mb(*this, tr["Do you want to delete the log file?"],
|
||||
"icons/ebook.png");
|
||||
mb.setButton(InputManager::ACCEPT, tr["Yes"]);
|
||||
mb.setButton(InputManager::CANCEL, tr["No"]);
|
||||
@ -659,7 +659,7 @@ void GMenu2X::mainLoop() {
|
||||
}
|
||||
|
||||
void GMenu2X::explorer() {
|
||||
FileDialog fd(this, ts, tr["Select an application"], "sh,bin,py,elf,");
|
||||
FileDialog fd(*this, ts, tr["Select an application"], "sh,bin,py,elf,");
|
||||
if (fd.exec()) {
|
||||
if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex()))
|
||||
writeConfig();
|
||||
@ -704,35 +704,35 @@ void GMenu2X::showSettings() {
|
||||
encodings.push_back("NTSC");
|
||||
encodings.push_back("PAL");
|
||||
|
||||
SettingsDialog sd(this, input, ts, tr["Settings"]);
|
||||
SettingsDialog sd(*this, input, ts, tr["Settings"]);
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
||||
this, ts, tr["Language"],
|
||||
*this, ts, tr["Language"],
|
||||
tr["Set the language used by GMenu2X"],
|
||||
&lang, &translations)));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
||||
this, ts, tr["Save last selection"],
|
||||
*this, ts, tr["Save last selection"],
|
||||
tr["Save the last selected link and section on exit"],
|
||||
&confInt["saveSelection"])));
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||
this, ts, tr["Clock for GMenu2X"],
|
||||
*this, ts, tr["Clock for GMenu2X"],
|
||||
tr["Set the cpu working frequency when running GMenu2X"],
|
||||
&confInt["menuClock"], cpuFreqMin, cpuFreqSafeMax, cpuFreqMultiple)));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||
this, ts, tr["Maximum overclock"],
|
||||
*this, ts, tr["Maximum overclock"],
|
||||
tr["Set the maximum overclock for launching links"],
|
||||
&confInt["maxClock"], cpuFreqMin, cpuFreqMax, cpuFreqMultiple)));
|
||||
#endif
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
||||
this, ts, tr["Output logs"],
|
||||
*this, ts, tr["Output logs"],
|
||||
tr["Logs the output of the links. Use the Log Viewer to read them."],
|
||||
&confInt["outputLogs"])));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||
this, ts, tr["Screen Timeout"],
|
||||
*this, ts, tr["Screen Timeout"],
|
||||
tr["Set screen's backlight timeout in seconds"],
|
||||
&confInt["backlightTimeout"], 0, 120)));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||
this, ts, tr["Button repeat rate"],
|
||||
*this, ts, tr["Button repeat rate"],
|
||||
tr["Set button repetitions per second"],
|
||||
&confInt["buttonRepeatRate"], 0, 20)));
|
||||
|
||||
@ -764,33 +764,33 @@ void GMenu2X::skinMenu() {
|
||||
|
||||
string curSkin = confStr["skin"];
|
||||
|
||||
SettingsDialog sd(this, input, ts, tr["Skin"]);
|
||||
SettingsDialog sd(*this, input, ts, tr["Skin"]);
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
||||
this, ts, tr["Skin"],
|
||||
*this, ts, tr["Skin"],
|
||||
tr["Set the skin used by GMenu2X"],
|
||||
&confStr["skin"], &fl_sk.getDirectories())));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||
this, ts, tr["Top Bar"],
|
||||
*this, ts, tr["Top Bar"],
|
||||
tr["Color of the top bar"],
|
||||
&skinConfColors[COLOR_TOP_BAR_BG])));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||
this, ts, tr["Bottom Bar"],
|
||||
*this, ts, tr["Bottom Bar"],
|
||||
tr["Color of the bottom bar"],
|
||||
&skinConfColors[COLOR_BOTTOM_BAR_BG])));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||
this, ts, tr["Selection"],
|
||||
*this, ts, tr["Selection"],
|
||||
tr["Color of the selection and other interface details"],
|
||||
&skinConfColors[COLOR_SELECTION_BG])));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||
this, ts, tr["Message Box"],
|
||||
*this, ts, tr["Message Box"],
|
||||
tr["Background color of the message box"],
|
||||
&skinConfColors[COLOR_MESSAGE_BOX_BG])));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||
this, ts, tr["Message Box Border"],
|
||||
*this, ts, tr["Message Box Border"],
|
||||
tr["Border color of the message box"],
|
||||
&skinConfColors[COLOR_MESSAGE_BOX_BORDER])));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingRGBA(
|
||||
this, ts, tr["Message Box Selection"],
|
||||
*this, ts, tr["Message Box Selection"],
|
||||
tr["Color of the selection of the message box"],
|
||||
&skinConfColors[COLOR_MESSAGE_BOX_SELECTION])));
|
||||
|
||||
@ -891,7 +891,7 @@ void GMenu2X::showContextMenu() {
|
||||
}
|
||||
|
||||
void GMenu2X::changeWallpaper() {
|
||||
WallpaperDialog wp(this, ts);
|
||||
WallpaperDialog wp(*this, ts);
|
||||
if (wp.exec() && confStr["wallpaper"] != wp.wallpaper) {
|
||||
confStr["wallpaper"] = wp.wallpaper;
|
||||
initBG();
|
||||
@ -900,7 +900,7 @@ void GMenu2X::changeWallpaper() {
|
||||
}
|
||||
|
||||
void GMenu2X::addLink() {
|
||||
FileDialog fd(this, ts, tr["Select an application"], "sh,bin,py,elf,");
|
||||
FileDialog fd(*this, ts, tr["Select an application"], "sh,bin,py,elf,");
|
||||
if (fd.exec())
|
||||
menu->addLink(fd.getPath(), fd.getFile());
|
||||
}
|
||||
@ -928,52 +928,52 @@ void GMenu2X::editLink() {
|
||||
string diagTitle = tr.translate("Edit $1",linkTitle.c_str(),NULL);
|
||||
string diagIcon = linkApp->getIconPath();
|
||||
|
||||
SettingsDialog sd(this, input, ts, diagTitle, diagIcon);
|
||||
SettingsDialog sd(*this, input, ts, diagTitle, diagIcon);
|
||||
if (!linkApp->isOpk()) {
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
||||
this, ts, tr["Title"],
|
||||
*this, ts, tr["Title"],
|
||||
tr["Link title"],
|
||||
&linkTitle, diagTitle, diagIcon)));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
||||
this, ts, tr["Description"],
|
||||
*this, ts, tr["Description"],
|
||||
tr["Link description"],
|
||||
&linkDescription, diagTitle, diagIcon)));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingMultiString(
|
||||
this, ts, tr["Section"],
|
||||
*this, ts, tr["Section"],
|
||||
tr["The section this link belongs to"],
|
||||
&newSection, &menu->getSections())));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingImage(
|
||||
this, ts, tr["Icon"],
|
||||
*this, ts, tr["Icon"],
|
||||
tr.translate("Select an icon for this link", linkTitle.c_str(), NULL),
|
||||
&linkIcon, "png")));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingFile(
|
||||
this, ts, tr["Manual"],
|
||||
*this, ts, tr["Manual"],
|
||||
tr["Select a manual or README file"],
|
||||
&linkManual, "man.png,txt")));
|
||||
}
|
||||
if (!linkApp->isOpk() || !linkApp->getSelectorDir().empty()) {
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingDir(
|
||||
this, ts, tr["Selector Directory"],
|
||||
*this, ts, tr["Selector Directory"],
|
||||
tr["Directory to scan for the selector"],
|
||||
&linkSelDir)));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
||||
this, ts, tr["Selector Browser"],
|
||||
*this, ts, tr["Selector Browser"],
|
||||
tr["Allow the selector to change directory"],
|
||||
&linkSelBrowser)));
|
||||
}
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingInt(
|
||||
this, ts, tr["Clock frequency"],
|
||||
*this, ts, tr["Clock frequency"],
|
||||
tr["CPU clock frequency for this link"],
|
||||
&linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple)));
|
||||
#endif
|
||||
if (!linkApp->isOpk()) {
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingString(
|
||||
this, ts, tr["Selector Filter"],
|
||||
*this, ts, tr["Selector Filter"],
|
||||
tr["Selector filter (Separate values with a comma)"],
|
||||
&linkSelFilter, diagTitle, diagIcon)));
|
||||
sd.addSetting(unique_ptr<MenuSetting>(new MenuSettingBool(
|
||||
this, ts, tr["Display Console"],
|
||||
*this, ts, tr["Display Console"],
|
||||
tr["Must be enabled for console-based applications"],
|
||||
&linkApp->consoleApp)));
|
||||
}
|
||||
@ -1015,7 +1015,7 @@ void GMenu2X::editLink() {
|
||||
|
||||
void GMenu2X::deleteLink() {
|
||||
if (menu->selLinkApp()!=NULL) {
|
||||
MessageBox mb(this, tr.translate("Deleting $1",menu->selLink()->getTitle().c_str(),NULL)+"\n"+tr["Are you sure?"], menu->selLink()->getIconPath());
|
||||
MessageBox mb(*this, tr.translate("Deleting $1",menu->selLink()->getTitle().c_str(),NULL)+"\n"+tr["Are you sure?"], menu->selLink()->getIconPath());
|
||||
mb.setButton(InputManager::ACCEPT, tr["Yes"]);
|
||||
mb.setButton(InputManager::CANCEL, tr["No"]);
|
||||
if (mb.exec() == InputManager::ACCEPT)
|
||||
@ -1024,7 +1024,7 @@ void GMenu2X::deleteLink() {
|
||||
}
|
||||
|
||||
void GMenu2X::addSection() {
|
||||
InputDialog id(this, input, ts, tr["Insert a name for the new section"]);
|
||||
InputDialog id(*this, input, ts, tr["Insert a name for the new section"]);
|
||||
if (id.exec()) {
|
||||
//only if a section with the same name does not exist
|
||||
if (find(menu->getSections().begin(), menu->getSections().end(), id.getInput())
|
||||
@ -1037,7 +1037,7 @@ void GMenu2X::addSection() {
|
||||
}
|
||||
|
||||
void GMenu2X::renameSection() {
|
||||
InputDialog id(this, input, ts, tr["Insert a new name for this section"],menu->selSection());
|
||||
InputDialog id(*this, input, ts, tr["Insert a new name for this section"],menu->selSection());
|
||||
if (id.exec()) {
|
||||
//only if a section with the same name does not exist & !samename
|
||||
if (menu->selSection() != id.getInput()
|
||||
@ -1069,7 +1069,7 @@ void GMenu2X::renameSection() {
|
||||
}
|
||||
|
||||
void GMenu2X::deleteSection() {
|
||||
MessageBox mb(this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]);
|
||||
MessageBox mb(*this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]);
|
||||
mb.setButton(InputManager::ACCEPT, tr["Yes"]);
|
||||
mb.setButton(InputManager::CANCEL, tr["No"]);
|
||||
if (mb.exec() == InputManager::ACCEPT) {
|
||||
|
@ -8,7 +8,7 @@ using namespace std;
|
||||
|
||||
|
||||
IconButton::IconButton(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const string &icon, const string &label, Action action)
|
||||
: gmenu2x(gmenu2x)
|
||||
, ts(ts)
|
||||
@ -17,7 +17,7 @@ IconButton::IconButton(
|
||||
, action(action)
|
||||
, rect({ 0, 0, 0, 0 })
|
||||
{
|
||||
iconSurface = gmenu2x->sc[icon];
|
||||
iconSurface = gmenu2x.sc[icon];
|
||||
recalcRects();
|
||||
}
|
||||
|
||||
@ -42,8 +42,8 @@ void IconButton::recalcRects() {
|
||||
labelRect = {
|
||||
static_cast<Sint16>(iconRect.x + iconRect.w + margin),
|
||||
static_cast<Sint16>(rect.y + h / 2),
|
||||
static_cast<Uint16>(gmenu2x->font->getTextWidth(label)),
|
||||
static_cast<Uint16>(gmenu2x->font->getLineSpacing())
|
||||
static_cast<Uint16>(gmenu2x.font->getTextWidth(label)),
|
||||
static_cast<Uint16>(gmenu2x.font->getLineSpacing())
|
||||
};
|
||||
w += margin + labelRect.w;
|
||||
}
|
||||
@ -66,7 +66,7 @@ void IconButton::paint(Surface& s) {
|
||||
iconSurface->blit(s, iconRect);
|
||||
}
|
||||
if (!label.empty()) {
|
||||
gmenu2x->font->write(s, label, labelRect.x, labelRect.y,
|
||||
gmenu2x.font->write(s, label, labelRect.x, labelRect.y,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class IconButton {
|
||||
public:
|
||||
typedef std::function<void(void)> Action;
|
||||
|
||||
IconButton(GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
IconButton(GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &icon, const std::string &label = "",
|
||||
Action action = nullptr);
|
||||
|
||||
@ -31,7 +31,7 @@ public:
|
||||
private:
|
||||
void recalcRects();
|
||||
|
||||
GMenu2X *gmenu2x;
|
||||
GMenu2X& gmenu2x;
|
||||
Touchscreen &ts;
|
||||
std::string icon, label;
|
||||
Action action;
|
||||
|
@ -34,7 +34,7 @@
|
||||
using namespace std;
|
||||
|
||||
ImageDialog::ImageDialog(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts, const string &text,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts, const string &text,
|
||||
const string &filter, const string &file)
|
||||
: FileDialog(gmenu2x, ts, text, filter, file, "Image Browser")
|
||||
{
|
||||
@ -42,7 +42,7 @@ ImageDialog::ImageDialog(
|
||||
string path;
|
||||
|
||||
if (!file.empty()) {
|
||||
path = strreplace(file, "skin:", gmenu2x->sc.getSkinPath(gmenu2x->confStr["skin"]));
|
||||
path = strreplace(file, "skin:", gmenu2x.sc.getSkinPath(gmenu2x.confStr["skin"]));
|
||||
string::size_type pos = path.rfind("/");
|
||||
if (pos != string::npos)
|
||||
setPath(path.substr(0, pos));
|
||||
@ -55,7 +55,7 @@ ImageDialog::~ImageDialog() {
|
||||
|
||||
void ImageDialog::beforeFileList() {
|
||||
if (fl.isFile(selected) && fileExists(getPath()+"/"+fl[selected]))
|
||||
previews[getPath()+"/"+fl[selected]]->blitRight(*gmenu2x->s, 310, 43);
|
||||
previews[getPath()+"/"+fl[selected]]->blitRight(*gmenu2x.s, 310, 43);
|
||||
}
|
||||
|
||||
void ImageDialog::onChangeDir() {
|
||||
|
@ -31,7 +31,7 @@ protected:
|
||||
SurfaceCollection previews;
|
||||
public:
|
||||
ImageDialog(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts, const std::string &text,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts, const std::string &text,
|
||||
const std::string &filter = "", const std::string &file = "");
|
||||
virtual ~ImageDialog();
|
||||
|
||||
|
@ -37,7 +37,7 @@ static bool utf8Code(unsigned char c)
|
||||
return (c>=194 && c<=198) || c==208 || c==209;
|
||||
}
|
||||
|
||||
InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_,
|
||||
InputDialog::InputDialog(GMenu2X& gmenu2x, InputManager &inputMgr_,
|
||||
Touchscreen &ts_, const string &text,
|
||||
const string &startvalue, const string &title, const string &icon)
|
||||
: Dialog(gmenu2x)
|
||||
@ -52,7 +52,7 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_,
|
||||
this->text = text;
|
||||
}
|
||||
this->icon = "";
|
||||
if (!icon.empty() && gmenu2x->sc[icon] != NULL) {
|
||||
if (!icon.empty() && gmenu2x.sc[icon] != NULL) {
|
||||
this->icon = icon;
|
||||
}
|
||||
|
||||
@ -98,22 +98,22 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_,
|
||||
|
||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/l.png",
|
||||
gmenu2x->tr["Backspace"],
|
||||
gmenu2x.tr["Backspace"],
|
||||
bind(&InputDialog::backspace, this))));
|
||||
|
||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/r.png",
|
||||
gmenu2x->tr["Space"],
|
||||
gmenu2x.tr["Space"],
|
||||
bind(&InputDialog::space, this))));
|
||||
|
||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
||||
gmenu2x->tr["Confirm"],
|
||||
gmenu2x.tr["Confirm"],
|
||||
bind(&InputDialog::confirm, this))));
|
||||
|
||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
||||
gmenu2x->tr["Change keys"],
|
||||
gmenu2x.tr["Change keys"],
|
||||
bind(&InputDialog::changeKeys, this))));
|
||||
}
|
||||
|
||||
@ -141,34 +141,34 @@ void InputDialog::setKeyboard(int kb) {
|
||||
|
||||
bool InputDialog::exec() {
|
||||
SDL_Rect box = {
|
||||
0, 60, 0, static_cast<Uint16>(gmenu2x->font->getLineSpacing() + 4)
|
||||
0, 60, 0, static_cast<Uint16>(gmenu2x.font->getLineSpacing() + 4)
|
||||
};
|
||||
|
||||
Uint32 caretTick = 0, curTick;
|
||||
bool caretOn = true;
|
||||
|
||||
OffscreenSurface bg(*gmenu2x->bg);
|
||||
OffscreenSurface bg(*gmenu2x.bg);
|
||||
drawTitleIcon(bg, icon, false);
|
||||
writeTitle(bg, title);
|
||||
writeSubTitle(bg, text);
|
||||
buttonbox.paint(bg, 5, gmenu2x->resY - 1);
|
||||
buttonbox.paint(bg, 5, gmenu2x.resY - 1);
|
||||
bg.convertToDisplayFormat();
|
||||
|
||||
close = false;
|
||||
ok = true;
|
||||
while (!close) {
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
|
||||
bg.blit(s, 0, 0);
|
||||
|
||||
box.w = gmenu2x->font->getTextWidth(input) + 18;
|
||||
box.w = gmenu2x.font->getTextWidth(input) + 18;
|
||||
box.x = 160 - box.w / 2;
|
||||
s.box(box.x, box.y, box.w, box.h,
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
s.rectangle(box.x, box.y, box.w, box.h,
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
|
||||
gmenu2x->font->write(s, input, box.x + 5, box.y + box.h - 2,
|
||||
gmenu2x.font->write(s, input, box.x + 5, box.y + box.h - 2,
|
||||
Font::HAlignLeft, Font::VAlignBottom);
|
||||
|
||||
curTick = SDL_GetTicks();
|
||||
@ -179,7 +179,7 @@ bool InputDialog::exec() {
|
||||
|
||||
if (caretOn) {
|
||||
s.box(box.x + box.w - 12, box.y + 3, 8, box.h - 6,
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
}
|
||||
|
||||
if (ts.available()) ts.poll();
|
||||
@ -264,10 +264,10 @@ void InputDialog::changeKeys() {
|
||||
}
|
||||
|
||||
void InputDialog::drawVirtualKeyboard() {
|
||||
Surface& s = *gmenu2x->s;
|
||||
Surface& s = *gmenu2x.s;
|
||||
|
||||
//keyboard border
|
||||
s.rectangle(kbRect, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
s.rectangle(kbRect, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
|
||||
if (selCol<0) selCol = selRow==(int)kb->size() ? 1 : kbLength-1;
|
||||
if (selCol>=(int)kbLength) selCol = 0;
|
||||
@ -278,13 +278,13 @@ void InputDialog::drawVirtualKeyboard() {
|
||||
if (selRow<(int)kb->size())
|
||||
s.box(kbLeft + selCol * KEY_WIDTH - 1,
|
||||
KB_TOP + selRow * KEY_HEIGHT, KEY_WIDTH - 1, KEY_HEIGHT - 2,
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
else {
|
||||
if (selCol > 1) selCol = 0;
|
||||
if (selCol < 0) selCol = 1;
|
||||
s.box(kbLeft + selCol * kbLength * KEY_WIDTH / 2 - 1,
|
||||
KB_TOP + kb->size() * KEY_HEIGHT, kbLength * KEY_WIDTH / 2 - 1,
|
||||
KEY_HEIGHT - 1, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
KEY_HEIGHT - 1, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
}
|
||||
|
||||
//keys
|
||||
@ -313,8 +313,8 @@ void InputDialog::drawVirtualKeyboard() {
|
||||
}
|
||||
|
||||
s.rectangle(re,
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x->font->write(s, charX,
|
||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x.font->write(s, charX,
|
||||
kbLeft + xc * KEY_WIDTH + KEY_WIDTH / 2 - 1,
|
||||
KB_TOP + l * KEY_HEIGHT + KEY_HEIGHT / 2,
|
||||
Font::HAlignCenter, Font::VAlignMiddle);
|
||||
@ -329,23 +329,23 @@ void InputDialog::drawVirtualKeyboard() {
|
||||
static_cast<Uint16>(kbLength * KEY_WIDTH / 2 - 1),
|
||||
KEY_HEIGHT - 1
|
||||
};
|
||||
s.rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
s.rectangle(re, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
if (ts.available() && ts.pressed() && ts.inRect(re)) {
|
||||
selCol = 0;
|
||||
selRow = kb->size();
|
||||
}
|
||||
gmenu2x->font->write(s, gmenu2x->tr["Cancel"],
|
||||
gmenu2x.font->write(s, gmenu2x.tr["Cancel"],
|
||||
(int)(160 - kbLength * KEY_WIDTH / 4),
|
||||
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
|
||||
Font::HAlignCenter, Font::VAlignMiddle);
|
||||
|
||||
re.x = kbLeft + kbLength * KEY_WIDTH / 2 - 1;
|
||||
s.rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
s.rectangle(re, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
if (ts.available() && ts.pressed() && ts.inRect(re)) {
|
||||
selCol = 1;
|
||||
selRow = kb->size();
|
||||
}
|
||||
gmenu2x->font->write(s, gmenu2x->tr["OK"],
|
||||
gmenu2x.font->write(s, gmenu2x.tr["OK"],
|
||||
(int)(160 + kbLength * KEY_WIDTH / 4),
|
||||
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
|
||||
Font::HAlignCenter, Font::VAlignMiddle);
|
||||
|
@ -33,7 +33,7 @@ class Touchscreen;
|
||||
|
||||
class InputDialog : protected Dialog {
|
||||
public:
|
||||
InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr, Touchscreen &ts,
|
||||
InputDialog(GMenu2X& gmenu2x, InputManager &inputMgr, Touchscreen &ts,
|
||||
const std::string &text, const std::string &startvalue="",
|
||||
const std::string &title="", const std::string &icon="");
|
||||
|
||||
|
@ -30,8 +30,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool InputManager::init(GMenu2X *gmenu2x, Menu *menu) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
bool InputManager::init(Menu *menu)
|
||||
{
|
||||
this->menu = menu;
|
||||
|
||||
repeatRateChanged();
|
||||
@ -43,7 +43,7 @@ bool InputManager::init(GMenu2X *gmenu2x, Menu *menu) {
|
||||
|
||||
/* If a user-specified input.conf file exists, we load it;
|
||||
* otherwise, we load the default one. */
|
||||
string input_file = gmenu2x->getHome() + "/input.conf";
|
||||
string input_file = gmenu2x.getHome() + "/input.conf";
|
||||
DEBUG("Loading user-specific input.conf file: %s.\n", input_file.c_str());
|
||||
if (!readConfFile(input_file)) {
|
||||
input_file = GMENU2X_SYSTEM_DIR "/input.conf";
|
||||
@ -57,8 +57,9 @@ bool InputManager::init(GMenu2X *gmenu2x, Menu *menu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
InputManager::InputManager(PowerSaver& powerSaver)
|
||||
: powerSaver(powerSaver)
|
||||
InputManager::InputManager(GMenu2X& gmenu2x, PowerSaver& powerSaver)
|
||||
: gmenu2x(gmenu2x)
|
||||
, powerSaver(powerSaver)
|
||||
{
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
int i;
|
||||
@ -152,7 +153,7 @@ static int repeatRateMs(int repeatRate)
|
||||
}
|
||||
|
||||
void InputManager::repeatRateChanged() {
|
||||
int ms = repeatRateMs(gmenu2x->confInt["buttonRepeatRate"]);
|
||||
int ms = repeatRateMs(gmenu2x.confInt["buttonRepeatRate"]);
|
||||
if (ms == 0) {
|
||||
SDL_EnableKeyRepeat(0, 0);
|
||||
} else {
|
||||
@ -347,7 +348,7 @@ Uint32 InputManager::joystickRepeatCallback(Uint32 timeout __attribute__((unused
|
||||
};
|
||||
SDL_PushEvent((SDL_Event *) &e);
|
||||
|
||||
return repeatRateMs(gmenu2x->confInt["buttonRepeatRate"]);
|
||||
return repeatRateMs(gmenu2x.confInt["buttonRepeatRate"]);
|
||||
}
|
||||
|
||||
void InputManager::stopTimer(Joystick *joystick)
|
||||
|
@ -62,10 +62,10 @@ public:
|
||||
};
|
||||
#define BUTTON_TYPE_SIZE 10
|
||||
|
||||
InputManager(PowerSaver& powerSaver);
|
||||
InputManager(GMenu2X& gmenu2x, PowerSaver& powerSaver);
|
||||
~InputManager();
|
||||
|
||||
bool init(GMenu2X *gmenu2x, Menu *menu);
|
||||
bool init(Menu *menu);
|
||||
Button waitForPressedButton();
|
||||
void repeatRateChanged();
|
||||
Uint32 joystickRepeatCallback(Uint32 timeout, struct Joystick *joystick);
|
||||
@ -80,7 +80,7 @@ private:
|
||||
unsigned int kb_code, js_code;
|
||||
};
|
||||
|
||||
GMenu2X *gmenu2x;
|
||||
GMenu2X& gmenu2x;
|
||||
Menu *menu;
|
||||
PowerSaver& powerSaver;
|
||||
|
||||
|
36
src/link.cpp
36
src/link.cpp
@ -32,17 +32,17 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
Link::Link(GMenu2X *gmenu2x, Action action)
|
||||
Link::Link(GMenu2X& gmenu2x, Action action)
|
||||
: gmenu2x(gmenu2x)
|
||||
, ts(gmenu2x->getTouchscreen())
|
||||
, ts(gmenu2x.getTouchscreen())
|
||||
, action(action)
|
||||
, lastTick(0)
|
||||
{
|
||||
// ts = gmenu2x->getTouchscreen();
|
||||
rect.w = gmenu2x->skinConfInt["linkWidth"];
|
||||
rect.h = gmenu2x->skinConfInt["linkHeight"];
|
||||
// ts = gmenu2x.getTouchscreen();
|
||||
rect.w = gmenu2x.skinConfInt["linkWidth"];
|
||||
rect.h = gmenu2x.skinConfInt["linkHeight"];
|
||||
edited = false;
|
||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
||||
iconPath = gmenu2x.sc.getSkinFilePath("icons/generic.png");
|
||||
iconX = 0;
|
||||
padding = 0;
|
||||
|
||||
@ -67,26 +67,26 @@ bool Link::handleTS() {
|
||||
}
|
||||
|
||||
void Link::paint() {
|
||||
Surface& s = *gmenu2x->s;
|
||||
Surface& s = *gmenu2x.s;
|
||||
|
||||
if (iconSurface) {
|
||||
iconSurface->blit(s, iconX, rect.y+padding, 32,32);
|
||||
}
|
||||
gmenu2x->font->write(s, getTitle(), iconX+16, rect.y + gmenu2x->skinConfInt["linkHeight"]-padding, Font::HAlignCenter, Font::VAlignBottom);
|
||||
gmenu2x.font->write(s, getTitle(), iconX+16, rect.y + gmenu2x.skinConfInt["linkHeight"]-padding, Font::HAlignCenter, Font::VAlignBottom);
|
||||
}
|
||||
|
||||
void Link::paintHover() {
|
||||
Surface& s = *gmenu2x->s;
|
||||
Surface& s = *gmenu2x.s;
|
||||
|
||||
if (gmenu2x->useSelectionPng)
|
||||
gmenu2x->sc["imgs/selection.png"]->blit(s, rect, Font::HAlignCenter, Font::VAlignMiddle);
|
||||
if (gmenu2x.useSelectionPng)
|
||||
gmenu2x.sc["imgs/selection.png"]->blit(s, rect, Font::HAlignCenter, Font::VAlignMiddle);
|
||||
else
|
||||
s.box(rect.x, rect.y, rect.w, rect.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
s.box(rect.x, rect.y, rect.w, rect.h, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
}
|
||||
|
||||
void Link::updateSurfaces()
|
||||
{
|
||||
iconSurface = gmenu2x->sc[getIconPath()];
|
||||
iconSurface = gmenu2x.sc[getIconPath()];
|
||||
}
|
||||
|
||||
const string &Link::getTitle() {
|
||||
@ -117,7 +117,7 @@ const string &Link::getIcon() {
|
||||
|
||||
void Link::loadIcon() {
|
||||
if (icon.compare(0, 5, "skin:") == 0) {
|
||||
setIconPath(gmenu2x->sc.getSkinFilePath(icon.substr(5, string::npos)));
|
||||
setIconPath(gmenu2x.sc.getSkinFilePath(icon.substr(5, string::npos)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ void Link::setIcon(const string &icon) {
|
||||
this->icon = icon;
|
||||
|
||||
if (icon.compare(0, 5, "skin:") == 0)
|
||||
this->iconPath = gmenu2x->sc.getSkinFilePath(
|
||||
this->iconPath = gmenu2x.sc.getSkinFilePath(
|
||||
icon.substr(5, string::npos));
|
||||
else
|
||||
this->iconPath = icon;
|
||||
@ -135,7 +135,7 @@ void Link::setIcon(const string &icon) {
|
||||
}
|
||||
|
||||
const string &Link::searchIcon() {
|
||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
||||
iconPath = gmenu2x.sc.getSkinFilePath("icons/generic.png");
|
||||
return iconPath;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ void Link::setIconPath(const string &icon) {
|
||||
if (fileExists(icon))
|
||||
iconPath = icon;
|
||||
else
|
||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
||||
iconPath = gmenu2x.sc.getSkinFilePath("icons/generic.png");
|
||||
updateSurfaces();
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ void Link::setPosition(int x, int y) {
|
||||
|
||||
void Link::recalcCoordinates() {
|
||||
iconX = rect.x+(rect.w-32)/2;
|
||||
padding = (gmenu2x->skinConfInt["linkHeight"] - 32 - gmenu2x->font->getLineSpacing()) / 3;
|
||||
padding = (gmenu2x.skinConfInt["linkHeight"] - 32 - gmenu2x.font->getLineSpacing()) / 3;
|
||||
}
|
||||
|
||||
void Link::run() {
|
||||
|
@ -40,7 +40,7 @@ class Link {
|
||||
public:
|
||||
typedef std::function<void(void)> Action;
|
||||
|
||||
Link(GMenu2X *gmenu2x, Action action);
|
||||
Link(GMenu2X& gmenu2x, Action action);
|
||||
virtual ~Link() {};
|
||||
|
||||
bool isPressed();
|
||||
@ -66,7 +66,7 @@ public:
|
||||
void run();
|
||||
|
||||
protected:
|
||||
GMenu2X *gmenu2x;
|
||||
GMenu2X& gmenu2x;
|
||||
bool edited;
|
||||
std::string title, description, launchMsg, icon, iconPath;
|
||||
|
||||
|
@ -82,18 +82,18 @@ private:
|
||||
|
||||
|
||||
#ifdef HAVE_LIBOPK
|
||||
LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable,
|
||||
LinkApp::LinkApp(GMenu2X& gmenu2x, string const& linkfile, bool deletable,
|
||||
struct OPK *opk, const char *metadata_)
|
||||
#else
|
||||
LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable)
|
||||
LinkApp::LinkApp(GMenu2X& gmenu2x, string const& linkfile, bool deletable)
|
||||
#endif
|
||||
: Link(gmenu2x_, bind(&LinkApp::start, this))
|
||||
: Link(gmenu2x, bind(&LinkApp::start, this))
|
||||
, deletable(deletable)
|
||||
{
|
||||
manual = "";
|
||||
file = linkfile;
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
setClock(gmenu2x->getDefaultAppClock());
|
||||
setClock(gmenu2x.getDefaultAppClock());
|
||||
#else
|
||||
setClock(0);
|
||||
#endif
|
||||
@ -141,13 +141,13 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable)
|
||||
category = category.substr(0, pos);
|
||||
|
||||
} else if ((!strncmp(key, "Name", lkey) && title.empty())
|
||||
|| !strncmp(key, ("Name[" + gmenu2x->tr["Lng"] +
|
||||
|| !strncmp(key, ("Name[" + gmenu2x.tr["Lng"] +
|
||||
"]").c_str(), lkey)) {
|
||||
title = buf;
|
||||
|
||||
} else if ((!strncmp(key, "Comment", lkey) && description.empty())
|
||||
|| !strncmp(key, ("Comment[" +
|
||||
gmenu2x->tr["Lng"] + "]").c_str(), lkey)) {
|
||||
gmenu2x.tr["Lng"] + "]").c_str(), lkey)) {
|
||||
description = buf;
|
||||
|
||||
} else if (!strncmp(key, "Terminal", lkey)) {
|
||||
@ -159,7 +159,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable)
|
||||
} else if (!strncmp(key, "Icon", lkey)) {
|
||||
/* Read the icon from the OPK only
|
||||
* if it doesn't exist on the skin */
|
||||
this->icon = gmenu2x->sc.getSkinFilePath("icons/" + (string) buf + ".png");
|
||||
this->icon = gmenu2x.sc.getSkinFilePath("icons/" + (string) buf + ".png");
|
||||
if (this->icon.empty()) {
|
||||
this->icon = linkfile + '#' + buf + ".png";
|
||||
}
|
||||
@ -211,7 +211,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable)
|
||||
#endif /* HAVE_LIBXDGMIME */
|
||||
}
|
||||
|
||||
file = gmenu2x->getHome() + "/sections/" + category + '/' + opkMount;
|
||||
file = gmenu2x.getHome() + "/sections/" + category + '/' + opkMount;
|
||||
opkMount = (string) "/mnt/" + opkMount + '/';
|
||||
edited = true;
|
||||
} else
|
||||
@ -274,7 +274,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable)
|
||||
|
||||
void LinkApp::loadIcon() {
|
||||
if (icon.compare(0, 5, "skin:") == 0) {
|
||||
string linkIcon = gmenu2x->sc.getSkinFilePath(
|
||||
string linkIcon = gmenu2x.sc.getSkinFilePath(
|
||||
icon.substr(5, string::npos));
|
||||
if (!fileExists(linkIcon))
|
||||
searchIcon();
|
||||
@ -299,12 +299,12 @@ const string &LinkApp::searchIcon() {
|
||||
if (pos != string::npos)
|
||||
string exectitle = execicon.substr(pos+1,execicon.length());
|
||||
|
||||
if (!gmenu2x->sc.getSkinFilePath("icons/"+exectitle).empty())
|
||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/"+exectitle);
|
||||
if (!gmenu2x.sc.getSkinFilePath("icons/"+exectitle).empty())
|
||||
iconPath = gmenu2x.sc.getSkinFilePath("icons/"+exectitle);
|
||||
else if (fileExists(execicon))
|
||||
iconPath = execicon;
|
||||
else
|
||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
||||
iconPath = gmenu2x.sc.getSkinFilePath("icons/generic.png");
|
||||
|
||||
return iconPath;
|
||||
}
|
||||
@ -378,35 +378,35 @@ bool LinkApp::save() {
|
||||
|
||||
void LinkApp::drawLaunch(Surface& s) {
|
||||
//Darkened background
|
||||
s.box(0, 0, gmenu2x->resX, gmenu2x->resY, 0,0,0,150);
|
||||
s.box(0, 0, gmenu2x.resX, gmenu2x.resY, 0,0,0,150);
|
||||
|
||||
string text = getLaunchMsg().empty()
|
||||
? gmenu2x->tr.translate("Launching $1", getTitle().c_str(), nullptr)
|
||||
: gmenu2x->tr.translate(getLaunchMsg().c_str(), nullptr);
|
||||
? gmenu2x.tr.translate("Launching $1", getTitle().c_str(), nullptr)
|
||||
: gmenu2x.tr.translate(getLaunchMsg().c_str(), nullptr);
|
||||
|
||||
int textW = gmenu2x->font->getTextWidth(text);
|
||||
int textW = gmenu2x.font->getTextWidth(text);
|
||||
int boxW = 62+textW;
|
||||
int halfBoxW = boxW/2;
|
||||
|
||||
//outer box
|
||||
s.box(gmenu2x->halfX-2-halfBoxW, gmenu2x->halfY-23, halfBoxW*2+5, 47, gmenu2x->skinConfColors[COLOR_MESSAGE_BOX_BG]);
|
||||
s.box(gmenu2x.halfX-2-halfBoxW, gmenu2x.halfY-23, halfBoxW*2+5, 47, gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BG]);
|
||||
//inner rectangle
|
||||
s.rectangle(gmenu2x->halfX-halfBoxW, gmenu2x->halfY-21, boxW, 42, gmenu2x->skinConfColors[COLOR_MESSAGE_BOX_BORDER]);
|
||||
s.rectangle(gmenu2x.halfX-halfBoxW, gmenu2x.halfY-21, boxW, 42, gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BORDER]);
|
||||
|
||||
int x = gmenu2x->halfX+10-halfBoxW;
|
||||
int x = gmenu2x.halfX + 10 - halfBoxW;
|
||||
/*if (!getIcon().empty())
|
||||
gmenu2x->sc[getIcon()]->blit(gmenu2x->s,x,104);
|
||||
gmenu2x.sc[getIcon()]->blit(gmenu2x.s,x,104);
|
||||
else
|
||||
gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/
|
||||
gmenu2x.sc["icons/generic.png"]->blit(gmenu2x.s,x,104);*/
|
||||
if (iconSurface) {
|
||||
iconSurface->blit(s, x, gmenu2x->halfY - 16);
|
||||
iconSurface->blit(s, x, gmenu2x.halfY - 16);
|
||||
}
|
||||
gmenu2x->font->write(s, text, x + 42, gmenu2x->halfY + 1, Font::HAlignLeft, Font::VAlignMiddle);
|
||||
gmenu2x.font->write(s, text, x + 42, gmenu2x.halfY + 1, Font::HAlignLeft, Font::VAlignMiddle);
|
||||
}
|
||||
|
||||
void LinkApp::start() {
|
||||
if (selectordir.empty()) {
|
||||
gmenu2x->queueLaunch(prepareLaunch(""), make_shared<LaunchLayer>(*this));
|
||||
gmenu2x.queueLaunch(prepareLaunch(""), make_shared<LaunchLayer>(*this));
|
||||
} else {
|
||||
selector();
|
||||
}
|
||||
@ -459,16 +459,16 @@ void LinkApp::showManual() {
|
||||
if (manual.substr(manual.size()-8,8)==".man.png") {
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
//Raise the clock to speed-up the loading of the manual
|
||||
gmenu2x->setSafeMaxClock();
|
||||
gmenu2x.setSafeMaxClock();
|
||||
#endif
|
||||
|
||||
auto pngman = OffscreenSurface::loadImage(manual);
|
||||
if (!pngman) {
|
||||
return;
|
||||
}
|
||||
auto bg = OffscreenSurface::loadImage(gmenu2x->confStr["wallpaper"]);
|
||||
auto bg = OffscreenSurface::loadImage(gmenu2x.confStr["wallpaper"]);
|
||||
if (!bg) {
|
||||
bg = OffscreenSurface::emptySurface(gmenu2x->s->width(), gmenu2x->s->height());
|
||||
bg = OffscreenSurface::emptySurface(gmenu2x.s->width(), gmenu2x.s->height());
|
||||
}
|
||||
bg->convertToDisplayFormat();
|
||||
|
||||
@ -484,34 +484,34 @@ void LinkApp::showManual() {
|
||||
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
//Lower the clock
|
||||
gmenu2x->setMenuClock();
|
||||
gmenu2x.setMenuClock();
|
||||
#endif
|
||||
|
||||
while (!close) {
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
|
||||
if (repaint) {
|
||||
bg->blit(s, 0, 0);
|
||||
pngman->blit(s, -page*320, 0);
|
||||
|
||||
gmenu2x->drawBottomBar(s);
|
||||
gmenu2x.drawBottomBar(s);
|
||||
int x = 5;
|
||||
x = gmenu2x->drawButton(s, "left", "", x);
|
||||
x = gmenu2x->drawButton(s, "right", gmenu2x->tr["Change page"], x);
|
||||
x = gmenu2x->drawButton(s, "cancel", "", x);
|
||||
x = gmenu2x->drawButton(s, "start", gmenu2x->tr["Exit"], x);
|
||||
x = gmenu2x.drawButton(s, "left", "", x);
|
||||
x = gmenu2x.drawButton(s, "right", gmenu2x.tr["Change page"], x);
|
||||
x = gmenu2x.drawButton(s, "cancel", "", x);
|
||||
x = gmenu2x.drawButton(s, "start", gmenu2x.tr["Exit"], x);
|
||||
|
||||
ss.clear();
|
||||
ss << page+1;
|
||||
ss >> pageStatus;
|
||||
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
|
||||
gmenu2x->font->write(s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
|
||||
pageStatus = gmenu2x.tr["Page"]+": "+pageStatus+"/"+spagecount;
|
||||
gmenu2x.font->write(s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
|
||||
|
||||
s.flip();
|
||||
repaint = false;
|
||||
}
|
||||
|
||||
switch(gmenu2x->input.waitForPressedButton()) {
|
||||
switch(gmenu2x.input.waitForPressedButton()) {
|
||||
case InputManager::SETTINGS:
|
||||
case InputManager::CANCEL:
|
||||
close = true;
|
||||
@ -566,8 +566,8 @@ void LinkApp::selector(int startSelection, const string &selectorDir) {
|
||||
if (!selectedDir.empty()) {
|
||||
selectordir = selectedDir;
|
||||
}
|
||||
gmenu2x->writeTmp(selection, selectedDir);
|
||||
gmenu2x->queueLaunch(
|
||||
gmenu2x.writeTmp(selection, selectedDir);
|
||||
gmenu2x.queueLaunch(
|
||||
prepareLaunch(selectedDir + sel.getFile()),
|
||||
make_shared<LaunchLayer>(*this));
|
||||
}
|
||||
@ -607,7 +607,7 @@ unique_ptr<Launcher> LinkApp::prepareLaunch(const string &selectedFile) {
|
||||
}
|
||||
}
|
||||
|
||||
if (gmenu2x->confInt["outputLogs"] && !consoleApp) {
|
||||
if (gmenu2x.confInt["outputLogs"] && !consoleApp) {
|
||||
int fd = open(LOG_FILE, O_WRONLY | O_TRUNC | O_CREAT, 0644);
|
||||
if (fd < 0) {
|
||||
ERROR("Unable to open log file for write: %s\n", LOG_FILE);
|
||||
@ -619,14 +619,14 @@ unique_ptr<Launcher> LinkApp::prepareLaunch(const string &selectedFile) {
|
||||
}
|
||||
}
|
||||
|
||||
gmenu2x->saveSelection();
|
||||
gmenu2x.saveSelection();
|
||||
|
||||
if (selectedFile.empty()) {
|
||||
gmenu2x->writeTmp();
|
||||
gmenu2x.writeTmp();
|
||||
}
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
if (clock() != gmenu2x->confInt["menuClock"]) {
|
||||
gmenu2x->setClock(clock());
|
||||
if (clock() != gmenu2x.confInt["menuClock"]) {
|
||||
gmenu2x.setClock(clock());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -61,10 +61,10 @@ public:
|
||||
bool isOpk() { return isOPK; }
|
||||
const std::string &getOpkFile() { return opkFile; }
|
||||
|
||||
LinkApp(GMenu2X *gmenu2x, std::string const& linkfile, bool deletable,
|
||||
LinkApp(GMenu2X& gmenu2x, std::string const& linkfile, bool deletable,
|
||||
struct OPK *opk = NULL, const char *metadata = NULL);
|
||||
#else
|
||||
LinkApp(GMenu2X *gmenu2x, std::string const& linkfile, bool deletable);
|
||||
LinkApp(GMenu2X& gmenu2x, std::string const& linkfile, bool deletable);
|
||||
bool isOpk() { return false; }
|
||||
#endif
|
||||
|
||||
|
62
src/menu.cpp
62
src/menu.cpp
@ -67,11 +67,11 @@ void Menu::Animation::step()
|
||||
}
|
||||
}
|
||||
|
||||
Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
|
||||
Menu::Menu(GMenu2X& gmenu2x, Touchscreen &ts)
|
||||
: gmenu2x(gmenu2x)
|
||||
, ts(ts)
|
||||
, btnContextMenu(gmenu2x, ts, "skin:imgs/menu.png", "",
|
||||
std::bind(&GMenu2X::showContextMenu, gmenu2x))
|
||||
std::bind(&GMenu2X::showContextMenu, &gmenu2x))
|
||||
{
|
||||
readSections(GMENU2X_SYSTEM_DIR "/sections");
|
||||
readSections(GMenu2X::getHome() + "/sections");
|
||||
@ -100,7 +100,7 @@ Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
|
||||
}
|
||||
#endif
|
||||
|
||||
btnContextMenu.setPosition(gmenu2x->resX - 38, gmenu2x->bottomBarIconY);
|
||||
btnContextMenu.setPosition(gmenu2x.resX - 38, gmenu2x.bottomBarIconY);
|
||||
}
|
||||
|
||||
Menu::~Menu() {
|
||||
@ -130,16 +130,16 @@ void Menu::readSections(std::string parentDir)
|
||||
}
|
||||
|
||||
void Menu::skinUpdated() {
|
||||
ConfIntHash &skinConfInt = gmenu2x->skinConfInt;
|
||||
ConfIntHash &skinConfInt = gmenu2x.skinConfInt;
|
||||
|
||||
//recalculate some coordinates based on the new element sizes
|
||||
linkColumns = (gmenu2x->resX - 10) / skinConfInt["linkWidth"];
|
||||
linkRows = (gmenu2x->resY - 35 - skinConfInt["topBarHeight"]) / skinConfInt["linkHeight"];
|
||||
linkColumns = (gmenu2x.resX - 10) / skinConfInt["linkWidth"];
|
||||
linkRows = (gmenu2x.resY - 35 - skinConfInt["topBarHeight"]) / skinConfInt["linkHeight"];
|
||||
|
||||
//reload section icons
|
||||
vector<string>::size_type i = 0;
|
||||
for (string sectionName : sections) {
|
||||
gmenu2x->sc["skin:sections/" + sectionName + ".png"];
|
||||
gmenu2x.sc["skin:sections/" + sectionName + ".png"];
|
||||
|
||||
for (Link *&link : links[i]) {
|
||||
link->loadIcon();
|
||||
@ -150,9 +150,9 @@ void Menu::skinUpdated() {
|
||||
}
|
||||
|
||||
void Menu::calcSectionRange(int &leftSection, int &rightSection) {
|
||||
ConfIntHash &skinConfInt = gmenu2x->skinConfInt;
|
||||
ConfIntHash &skinConfInt = gmenu2x.skinConfInt;
|
||||
const int linkWidth = skinConfInt["linkWidth"];
|
||||
const int screenWidth = gmenu2x->resX;
|
||||
const int screenWidth = gmenu2x.resX;
|
||||
const int numSections = sections.size();
|
||||
rightSection = min(
|
||||
max(1, (screenWidth - 20 - linkWidth) / (2 * linkWidth)),
|
||||
@ -171,15 +171,15 @@ bool Menu::runAnimations() {
|
||||
|
||||
void Menu::paint(Surface &s) {
|
||||
const uint width = s.width(), height = s.height();
|
||||
Font &font = *gmenu2x->font;
|
||||
SurfaceCollection &sc = gmenu2x->sc;
|
||||
Font &font = *gmenu2x.font;
|
||||
SurfaceCollection &sc = gmenu2x.sc;
|
||||
|
||||
ConfIntHash &skinConfInt = gmenu2x->skinConfInt;
|
||||
ConfIntHash &skinConfInt = gmenu2x.skinConfInt;
|
||||
const int topBarHeight = skinConfInt["topBarHeight"];
|
||||
const int bottomBarHeight = skinConfInt["bottomBarHeight"];
|
||||
const int linkWidth = skinConfInt["linkWidth"];
|
||||
const int linkHeight = skinConfInt["linkHeight"];
|
||||
RGBAColor &selectionBgColor = gmenu2x->skinConfColors[COLOR_SELECTION_BG];
|
||||
RGBAColor &selectionBgColor = gmenu2x.skinConfColors[COLOR_SELECTION_BG];
|
||||
|
||||
// Apply section header animation.
|
||||
int leftSection, rightSection;
|
||||
@ -221,7 +221,7 @@ void Menu::paint(Surface &s) {
|
||||
|
||||
vector<Link*> §ionLinks = links[iSection];
|
||||
const uint numLinks = sectionLinks.size();
|
||||
gmenu2x->drawScrollBar(
|
||||
gmenu2x.drawScrollBar(
|
||||
linkRows, (numLinks + linkColumns - 1) / linkColumns, iFirstDispRow);
|
||||
|
||||
//Links
|
||||
@ -253,14 +253,14 @@ void Menu::paint(Surface &s) {
|
||||
LinkApp *linkApp = selLinkApp();
|
||||
if (linkApp) {
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
font.write(s, linkApp->clockStr(gmenu2x->confInt["maxClock"]),
|
||||
gmenu2x->cpuX, gmenu2x->bottomBarTextY,
|
||||
font.write(s, linkApp->clockStr(gmenu2x.confInt["maxClock"]),
|
||||
gmenu2x.cpuX, gmenu2x.bottomBarTextY,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
#endif
|
||||
//Manual indicator
|
||||
if (!linkApp->getManual().empty())
|
||||
sc.skinRes("imgs/manual.png")->blit(
|
||||
s, gmenu2x->manualX, gmenu2x->bottomBarIconY);
|
||||
s, gmenu2x.manualX, gmenu2x.bottomBarIconY);
|
||||
}
|
||||
|
||||
if (ts.available()) {
|
||||
@ -292,7 +292,7 @@ bool Menu::handleButtonPress(InputManager::Button button) {
|
||||
incSectionIndex();
|
||||
return true;
|
||||
case InputManager::MENU:
|
||||
gmenu2x->showContextMenu();
|
||||
gmenu2x.showContextMenu();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -302,9 +302,9 @@ bool Menu::handleButtonPress(InputManager::Button button) {
|
||||
bool Menu::handleTouchscreen(Touchscreen &ts) {
|
||||
btnContextMenu.handleTS();
|
||||
|
||||
ConfIntHash &skinConfInt = gmenu2x->skinConfInt;
|
||||
ConfIntHash &skinConfInt = gmenu2x.skinConfInt;
|
||||
const int topBarHeight = skinConfInt["topBarHeight"];
|
||||
const int screenWidth = gmenu2x->resX;
|
||||
const int screenWidth = gmenu2x.resX;
|
||||
|
||||
if (ts.pressed() && ts.getY() < topBarHeight) {
|
||||
int leftSection, rightSection;
|
||||
@ -391,12 +391,12 @@ void Menu::addActionLink(uint section, const string &title, Action action, const
|
||||
assert(section < sections.size());
|
||||
|
||||
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->setDescription(description);
|
||||
if (gmenu2x->sc.exists(icon)
|
||||
if (gmenu2x.sc.exists(icon)
|
||||
|| (icon.substr(0,5)=="skin:"
|
||||
&& !gmenu2x->sc.getSkinFilePath(icon.substr(5,icon.length())).empty())
|
||||
&& !gmenu2x.sc.getSkinFilePath(icon.substr(5,icon.length())).empty())
|
||||
|| fileExists(icon)) {
|
||||
link->setIcon(icon);
|
||||
}
|
||||
@ -475,8 +475,8 @@ bool Menu::addLink(string path, string file, string section) {
|
||||
if (fileExists(exename+".png")) icon = exename+".png";
|
||||
|
||||
//Reduce title lenght to fit the link width
|
||||
if (gmenu2x->font->getTextWidth(shorttitle)>gmenu2x->skinConfInt["linkWidth"]) {
|
||||
while (gmenu2x->font->getTextWidth(shorttitle+"..")>gmenu2x->skinConfInt["linkWidth"])
|
||||
if (gmenu2x.font->getTextWidth(shorttitle)>gmenu2x.skinConfInt["linkWidth"]) {
|
||||
while (gmenu2x.font->getTextWidth(shorttitle+"..")>gmenu2x.skinConfInt["linkWidth"])
|
||||
shorttitle = shorttitle.substr(0,shorttitle.length()-1);
|
||||
shorttitle += "..";
|
||||
}
|
||||
@ -496,7 +496,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, linkpath, true);
|
||||
link->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]);
|
||||
link->setSize(gmenu2x.skinConfInt["linkWidth"], gmenu2x.skinConfInt["linkHeight"]);
|
||||
links[isection].push_back( link );
|
||||
}
|
||||
} else {
|
||||
@ -543,13 +543,13 @@ void Menu::deleteSelectedLink()
|
||||
icon_used = iconpath == (*link)->getIconPath();
|
||||
|
||||
if (!icon_used)
|
||||
gmenu2x->sc.del(iconpath);
|
||||
gmenu2x.sc.del(iconpath);
|
||||
}
|
||||
|
||||
void Menu::deleteSelectedSection() {
|
||||
INFO("Deleting section '%s'\n", selSection().c_str());
|
||||
|
||||
gmenu2x->sc.del("sections/"+selSection()+".png");
|
||||
gmenu2x.sc.del("sections/"+selSection()+".png");
|
||||
links.erase( links.begin()+selSectionIndex() );
|
||||
sections.erase( sections.begin()+selSectionIndex() );
|
||||
setSectionIndex(0); //reload sections
|
||||
@ -700,7 +700,7 @@ void Menu::openPackage(std::string path, bool order)
|
||||
// but that is not something we want to do in the menu,
|
||||
// so consider this link undeletable.
|
||||
link = new LinkApp(gmenu2x, path, false, opk, name);
|
||||
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
|
||||
link->setSize(gmenu2x.skinConfInt["linkWidth"], gmenu2x.skinConfInt["linkHeight"]);
|
||||
|
||||
addSection(link->getCategory());
|
||||
for (i = 0; i < sections.size(); i++) {
|
||||
@ -840,8 +840,8 @@ void Menu::readLinksOfSection(
|
||||
LinkApp *link = new LinkApp(gmenu2x, linkfile, deletable);
|
||||
if (link->targetExists()) {
|
||||
link->setSize(
|
||||
gmenu2x->skinConfInt["linkWidth"],
|
||||
gmenu2x->skinConfInt["linkHeight"]);
|
||||
gmenu2x.skinConfInt["linkWidth"],
|
||||
gmenu2x.skinConfInt["linkHeight"]);
|
||||
links.push_back(link);
|
||||
} else {
|
||||
delete link;
|
||||
|
@ -54,7 +54,7 @@ private:
|
||||
int curr;
|
||||
};
|
||||
|
||||
GMenu2X *gmenu2x;
|
||||
GMenu2X& gmenu2x;
|
||||
Touchscreen &ts;
|
||||
IconButton btnContextMenu;
|
||||
int iSection, iLink;
|
||||
@ -102,7 +102,7 @@ private:
|
||||
public:
|
||||
typedef std::function<void(void)> Action;
|
||||
|
||||
Menu(GMenu2X *gmenu2x, Touchscreen &ts);
|
||||
Menu(GMenu2X& gmenu2x, Touchscreen &ts);
|
||||
virtual ~Menu();
|
||||
|
||||
#ifdef HAVE_LIBOPK
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
using std::string;
|
||||
|
||||
MenuSetting::MenuSetting(GMenu2X *gmenu2x, const string &name,
|
||||
MenuSetting::MenuSetting(GMenu2X& gmenu2x, const string &name,
|
||||
const string &description)
|
||||
: gmenu2x(gmenu2x)
|
||||
, name(name)
|
||||
@ -40,8 +40,8 @@ MenuSetting::~MenuSetting()
|
||||
|
||||
void MenuSetting::draw(int /*valueX*/, int y, int /*h*/)
|
||||
{
|
||||
Surface& s = *gmenu2x->s;
|
||||
gmenu2x->font->write(s, name, 5, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
Surface& s = *gmenu2x.s;
|
||||
gmenu2x.font->write(s, name, 5, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
void MenuSetting::handleTS(int /*valueX*/, int /*y*/, int /*h*/)
|
||||
@ -51,11 +51,11 @@ void MenuSetting::handleTS(int /*valueX*/, int /*y*/, int /*h*/)
|
||||
|
||||
void MenuSetting::drawSelected(int valueX, int y, int h)
|
||||
{
|
||||
Surface& s = *gmenu2x->s;
|
||||
Surface& s = *gmenu2x.s;
|
||||
|
||||
// The selection rectangle
|
||||
s.box(0, y, valueX - 5, h,
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
|
||||
buttonBox.paint(s, 5, gmenu2x->resY - 1);
|
||||
buttonBox.paint(s, 5, gmenu2x.resY - 1);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ Base class for different kind of option
|
||||
*/
|
||||
class MenuSetting {
|
||||
protected:
|
||||
GMenu2X *gmenu2x;
|
||||
GMenu2X& gmenu2x;
|
||||
|
||||
ButtonBox buttonBox;
|
||||
|
||||
@ -40,7 +40,7 @@ protected:
|
||||
|
||||
public:
|
||||
MenuSetting(
|
||||
GMenu2X *gmenu2x, const std::string &name,
|
||||
GMenu2X& gmenu2x, const std::string &name,
|
||||
const std::string &description);
|
||||
virtual ~MenuSetting();
|
||||
|
||||
|
@ -32,7 +32,7 @@ using std::string;
|
||||
using std::unique_ptr;
|
||||
|
||||
MenuSettingBool::MenuSettingBool(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const string &name, const string &description, int *value)
|
||||
: MenuSetting(gmenu2x, name, description)
|
||||
, ts(ts)
|
||||
@ -45,7 +45,7 @@ MenuSettingBool::MenuSettingBool(
|
||||
}
|
||||
|
||||
MenuSettingBool::MenuSettingBool(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const string &name, const string &description, bool *value)
|
||||
: MenuSetting(gmenu2x, name, description)
|
||||
, ts(ts)
|
||||
@ -61,15 +61,15 @@ void MenuSettingBool::initButton()
|
||||
{
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
||||
gmenu2x->tr["Switch"],
|
||||
gmenu2x.tr["Switch"],
|
||||
bind(&MenuSettingBool::toggle, this))));
|
||||
}
|
||||
|
||||
void MenuSettingBool::draw(int valueX, int y, int h)
|
||||
{
|
||||
Surface& s = *gmenu2x->s;
|
||||
Surface& s = *gmenu2x.s;
|
||||
MenuSetting::draw(valueX, y, h);
|
||||
gmenu2x->font->write(s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x.font->write(s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
bool MenuSettingBool::handleButtonPress(InputManager::Button button)
|
||||
|
@ -39,11 +39,11 @@ private:
|
||||
|
||||
public:
|
||||
MenuSettingBool(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &name, const std::string &description,
|
||||
bool *value);
|
||||
MenuSettingBool(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &name, const std::string &description,
|
||||
int *value);
|
||||
virtual ~MenuSettingBool() {}
|
||||
|
@ -29,19 +29,19 @@ using std::string;
|
||||
using std::unique_ptr;
|
||||
|
||||
MenuSettingDir::MenuSettingDir(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts_,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
||||
const string &name, const string &description, string *value)
|
||||
: MenuSettingStringBase(gmenu2x, name, description, value)
|
||||
, ts(ts_)
|
||||
{
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
||||
gmenu2x->tr["Clear"],
|
||||
gmenu2x.tr["Clear"],
|
||||
bind(&MenuSettingDir::clear, this))));
|
||||
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
||||
gmenu2x->tr["Select"],
|
||||
gmenu2x.tr["Select"],
|
||||
bind(&MenuSettingDir::edit, this))));
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ protected:
|
||||
|
||||
public:
|
||||
MenuSettingDir(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &name, const std::string &description,
|
||||
std::string *value);
|
||||
virtual ~MenuSettingDir() {}
|
||||
|
@ -29,7 +29,7 @@ using std::string;
|
||||
using std::unique_ptr;
|
||||
|
||||
MenuSettingFile::MenuSettingFile(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts_,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
||||
const string &name, const string &description,
|
||||
string *value, const string &filter_)
|
||||
: MenuSettingStringBase(gmenu2x, name, description, value)
|
||||
@ -38,12 +38,12 @@ MenuSettingFile::MenuSettingFile(
|
||||
{
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
||||
gmenu2x->tr["Clear"],
|
||||
gmenu2x.tr["Clear"],
|
||||
bind(&MenuSettingFile::clear, this))));
|
||||
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
||||
gmenu2x->tr["Select"],
|
||||
gmenu2x.tr["Select"],
|
||||
bind(&MenuSettingFile::edit, this))));
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ protected:
|
||||
|
||||
public:
|
||||
MenuSettingFile(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &name, const std::string &description,
|
||||
std::string *value, const std::string &filter = "");
|
||||
virtual ~MenuSettingFile() {}
|
||||
|
@ -27,7 +27,7 @@
|
||||
using std::string;
|
||||
|
||||
MenuSettingImage::MenuSettingImage(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const string &name, const string &description,
|
||||
string *value, const string &filter)
|
||||
: MenuSettingFile(gmenu2x, ts, name, description, value, filter)
|
||||
@ -40,10 +40,10 @@ void MenuSettingImage::edit() {
|
||||
}
|
||||
|
||||
void MenuSettingImage::setValue(const string &value) {
|
||||
string skinpath(gmenu2x->sc.getSkinPath(gmenu2x->confStr["skin"]));
|
||||
string skinpath(gmenu2x.sc.getSkinPath(gmenu2x.confStr["skin"]));
|
||||
bool inSkinDir = value.substr(0, skinpath.length()) == skinpath;
|
||||
if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") {
|
||||
skinpath = gmenu2x->sc.getSkinPath("Default");
|
||||
if (!inSkinDir && gmenu2x.confStr["skin"] != "Default") {
|
||||
skinpath = gmenu2x.sc.getSkinPath("Default");
|
||||
inSkinDir = value.substr(0, skinpath.length()) == skinpath;
|
||||
}
|
||||
if (inSkinDir) {
|
||||
|
@ -27,7 +27,7 @@ protected:
|
||||
virtual void edit();
|
||||
|
||||
public:
|
||||
MenuSettingImage(GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
MenuSettingImage(GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &name, const std::string &description,
|
||||
std::string *value, const std::string &filter = "");
|
||||
virtual ~MenuSettingImage() {}
|
||||
|
@ -33,10 +33,10 @@ using std::stringstream;
|
||||
using std::unique_ptr;
|
||||
|
||||
MenuSettingInt::MenuSettingInt(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const string &name, const string &description,
|
||||
int *value, int min, int max, int increment)
|
||||
: MenuSetting(gmenu2x,name,description)
|
||||
: MenuSetting(gmenu2x, name, description)
|
||||
{
|
||||
_value = value;
|
||||
originalValue = *value;
|
||||
@ -54,21 +54,21 @@ MenuSettingInt::MenuSettingInt(
|
||||
"", actionDec)));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/left.png",
|
||||
gmenu2x->tr["Decrease"], actionDec)));
|
||||
gmenu2x.tr["Decrease"], actionDec)));
|
||||
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/r.png",
|
||||
"", actionInc)));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/right.png",
|
||||
gmenu2x->tr["Increase"], actionInc)));
|
||||
gmenu2x.tr["Increase"], actionInc)));
|
||||
}
|
||||
|
||||
void MenuSettingInt::draw(int valueX, int y, int h)
|
||||
{
|
||||
Surface& s = *gmenu2x->s;
|
||||
Surface& s = *gmenu2x.s;
|
||||
MenuSetting::draw(valueX, y, h);
|
||||
gmenu2x->font->write(s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x.font->write(s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
bool MenuSettingInt::handleButtonPress(InputManager::Button button)
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
|
||||
public:
|
||||
MenuSettingInt(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &name, const std::string &description,
|
||||
int *value, int min, int max, int increment = 1);
|
||||
virtual ~MenuSettingInt() {}
|
||||
|
@ -31,7 +31,7 @@ using std::vector;
|
||||
using std::unique_ptr;
|
||||
|
||||
MenuSettingMultiString::MenuSettingMultiString(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const string &name, const string &description,
|
||||
string *value, const vector<string> *choices_)
|
||||
: MenuSettingStringBase(gmenu2x, name, description, value)
|
||||
@ -44,7 +44,7 @@ MenuSettingMultiString::MenuSettingMultiString(
|
||||
bind(&MenuSettingMultiString::decSel, this))));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/right.png",
|
||||
gmenu2x->tr["Change value"],
|
||||
gmenu2x.tr["Change value"],
|
||||
bind(&MenuSettingMultiString::incSel, this))));
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ private:
|
||||
|
||||
public:
|
||||
MenuSettingMultiString(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &name, const std::string &description,
|
||||
std::string *value, const std::vector<std::string> *choices);
|
||||
virtual ~MenuSettingMultiString() {};
|
||||
|
@ -34,7 +34,7 @@ using std::unique_ptr;
|
||||
constexpr unsigned int COMPONENT_WIDTH = 28;
|
||||
|
||||
MenuSettingRGBA::MenuSettingRGBA(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts_,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
||||
const string &name, const string &description, RGBAColor *value)
|
||||
: MenuSetting(gmenu2x, name, description)
|
||||
, ts(ts_)
|
||||
@ -53,16 +53,17 @@ MenuSettingRGBA::MenuSettingRGBA(
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::draw(int valueX, int y, int h) {
|
||||
Surface& s = *gmenu2x->s;
|
||||
Surface& s = *gmenu2x.s;
|
||||
|
||||
MenuSetting::draw(valueX, y, h);
|
||||
s.rectangle(valueX, y + 1, h - 2, h - 2, 0,0,0,255);
|
||||
s.rectangle(valueX + 1, y + 2, h - 4, h - 4, 255,255,255,255);
|
||||
s.box(valueX + 2, y + 3, h - 6, h - 6, value());
|
||||
gmenu2x->font->write(s, strR, valueX + h + COMPONENT_WIDTH - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||
gmenu2x->font->write(s, strG, valueX + h + COMPONENT_WIDTH * 2 - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||
gmenu2x->font->write(s, strB, valueX + h + COMPONENT_WIDTH * 3 - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||
gmenu2x->font->write(s, strA, valueX + h + COMPONENT_WIDTH * 4 - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||
auto& font = gmenu2x.font;
|
||||
font->write(s, strR, valueX + h + COMPONENT_WIDTH - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||
font->write(s, strG, valueX + h + COMPONENT_WIDTH * 2 - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||
font->write(s, strB, valueX + h + COMPONENT_WIDTH * 3 - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||
font->write(s, strA, valueX + h + COMPONENT_WIDTH * 4 - 2, y, Font::HAlignRight, Font::VAlignTop);
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::handleTS(int valueX, int y, int h) {
|
||||
@ -215,7 +216,7 @@ void MenuSettingRGBA::drawSelected(int valueX, int y, int h)
|
||||
case 2: color = RGBAColor( 0, 0, 255, 255); break;
|
||||
case 3: color = RGBAColor(128, 128, 128, 255); break;
|
||||
}
|
||||
gmenu2x->s->box( x + h, y, COMPONENT_WIDTH, h, color );
|
||||
gmenu2x.s->box( x + h, y, COMPONENT_WIDTH, h, color );
|
||||
|
||||
MenuSetting::drawSelected(valueX, y, h);
|
||||
}
|
||||
@ -230,13 +231,13 @@ void MenuSettingRGBA::updateButtonBox()
|
||||
buttonBox.clear();
|
||||
if (edit) {
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/l.png")));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png", gmenu2x.tr["Decrease"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/r.png")));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Confirm"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x.tr["Increase"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x.tr["Confirm"])));
|
||||
} else {
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png")));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Edit"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x.tr["Change color component"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x.tr["Edit"])));
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ private:
|
||||
|
||||
public:
|
||||
MenuSettingRGBA(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts,
|
||||
const std::string &name, const std::string &description,
|
||||
RGBAColor *value);
|
||||
virtual ~MenuSettingRGBA() {};
|
||||
|
@ -29,7 +29,7 @@ using std::string;
|
||||
using std::unique_ptr;
|
||||
|
||||
MenuSettingString::MenuSettingString(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts_,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts_,
|
||||
const string &name, const string &description, string *value,
|
||||
const string &diagTitle_, const string &diagIcon_)
|
||||
: MenuSettingStringBase(gmenu2x, name, description, value)
|
||||
@ -39,19 +39,19 @@ MenuSettingString::MenuSettingString(
|
||||
{
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/cancel.png",
|
||||
gmenu2x->tr["Clear"],
|
||||
gmenu2x.tr["Clear"],
|
||||
bind(&MenuSettingString::clear, this))));
|
||||
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(
|
||||
gmenu2x, ts, "skin:imgs/buttons/accept.png",
|
||||
gmenu2x->tr["Edit"],
|
||||
gmenu2x.tr["Edit"],
|
||||
bind(&MenuSettingString::edit, this))));
|
||||
}
|
||||
|
||||
void MenuSettingString::edit()
|
||||
{
|
||||
InputDialog id(
|
||||
gmenu2x, gmenu2x->input, ts,
|
||||
gmenu2x, gmenu2x.input, ts,
|
||||
description, value(), diagTitle, diagIcon);
|
||||
if (id.exec()) setValue(id.getInput());
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ protected:
|
||||
|
||||
public:
|
||||
MenuSettingString(
|
||||
GMenu2X *gmenu2x, Touchscreen &ts, const std::string &name,
|
||||
GMenu2X& gmenu2x, Touchscreen &ts, const std::string &name,
|
||||
const std::string &description, std::string *value,
|
||||
const std::string &diagTitle = "",
|
||||
const std::string &diagIcon = "");
|
||||
|
@ -25,7 +25,7 @@
|
||||
using std::string;
|
||||
|
||||
MenuSettingStringBase::MenuSettingStringBase(
|
||||
GMenu2X *gmenu2x, const string &name,
|
||||
GMenu2X& gmenu2x, const string &name,
|
||||
const string &description, string *value)
|
||||
: MenuSetting(gmenu2x, name, description)
|
||||
, originalValue(*value)
|
||||
@ -39,9 +39,9 @@ MenuSettingStringBase::~MenuSettingStringBase()
|
||||
|
||||
void MenuSettingStringBase::draw(int valueX, int y, int h)
|
||||
{
|
||||
Surface& s = *gmenu2x->s;
|
||||
Surface& s = *gmenu2x.s;
|
||||
MenuSetting::draw(valueX, y, h);
|
||||
gmenu2x->font->write(s, value(), valueX, y,
|
||||
gmenu2x.font->write(s, value(), valueX, y,
|
||||
Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ protected:
|
||||
|
||||
public:
|
||||
MenuSettingStringBase(
|
||||
GMenu2X *gmenu2x, const std::string &name,
|
||||
GMenu2X& gmenu2x, const std::string &name,
|
||||
const std::string &description, std::string *value);
|
||||
virtual ~MenuSettingStringBase();
|
||||
|
||||
|
@ -30,15 +30,15 @@ constexpr unsigned int ICON_PADDING = 6;
|
||||
constexpr unsigned int TEXT_PADDING = 8;
|
||||
constexpr unsigned int ICON_DIMENSION = 32;
|
||||
|
||||
MessageBox::MessageBox(GMenu2X *gmenu2x, const string &text, const string &icon) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
this->text = text;
|
||||
this->icon = icon;
|
||||
|
||||
MessageBox::MessageBox(GMenu2X& gmenu2x, const string &text, const string &icon)
|
||||
: gmenu2x(gmenu2x)
|
||||
, text(text)
|
||||
, icon(icon)
|
||||
{
|
||||
for (uint i = 0; i < BUTTON_TYPE_SIZE; i++) {
|
||||
buttons[i] = "";
|
||||
buttonLabels[i] = "";
|
||||
buttonPositions[i].h = gmenu2x->font->getLineSpacing();
|
||||
buttonPositions[i].h = gmenu2x.font->getLineSpacing();
|
||||
}
|
||||
|
||||
//Default enabled button
|
||||
@ -62,39 +62,39 @@ void MessageBox::setButton(InputManager::Button button, const string &label) {
|
||||
}
|
||||
|
||||
int MessageBox::exec() {
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
OffscreenSurface bg(s);
|
||||
//Darken background
|
||||
bg.box(0, 0, gmenu2x->resX, gmenu2x->resY, 0,0,0,200);
|
||||
bg.box(0, 0, gmenu2x.resX, gmenu2x.resY, 0,0,0,200);
|
||||
|
||||
SDL_Rect box;
|
||||
int textHeight = gmenu2x->font->getTextHeight(text);
|
||||
int textHeight = gmenu2x.font->getTextHeight(text);
|
||||
box.h = textHeight + 2 * TEXT_PADDING;
|
||||
box.w = gmenu2x->font->getTextWidth(text) + 2 * TEXT_PADDING;
|
||||
if (gmenu2x->sc[icon]) {
|
||||
box.w = gmenu2x.font->getTextWidth(text) + 2 * TEXT_PADDING;
|
||||
if (gmenu2x.sc[icon]) {
|
||||
box.h = max(box.h, (Uint16) (ICON_DIMENSION + 2 * ICON_PADDING));
|
||||
box.w += ICON_DIMENSION + ICON_PADDING;
|
||||
}
|
||||
box.x = gmenu2x->halfX - box.w/2;
|
||||
box.y = gmenu2x->halfY - box.h/2;
|
||||
box.x = gmenu2x.halfX - box.w / 2;
|
||||
box.y = gmenu2x.halfY - box.h / 2;
|
||||
|
||||
//outer box
|
||||
bg.box(box.x - 2, box.y - 2, box.w + 4, box.h + 4, gmenu2x->skinConfColors[COLOR_MESSAGE_BOX_BG]);
|
||||
bg.box(box.x - 2, box.y - 2, box.w + 4, box.h + 4, gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BG]);
|
||||
//draw inner rectangle
|
||||
bg.rectangle(box, gmenu2x->skinConfColors[COLOR_MESSAGE_BOX_BORDER]);
|
||||
bg.rectangle(box, gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BORDER]);
|
||||
//icon+text
|
||||
if (gmenu2x->sc[icon]) {
|
||||
gmenu2x->sc[icon]->blitCenter(bg, box.x + ICON_PADDING + ICON_DIMENSION / 2, box.y + ICON_PADDING + ICON_DIMENSION / 2);
|
||||
if (gmenu2x.sc[icon]) {
|
||||
gmenu2x.sc[icon]->blitCenter(bg, box.x + ICON_PADDING + ICON_DIMENSION / 2, box.y + ICON_PADDING + ICON_DIMENSION / 2);
|
||||
}
|
||||
gmenu2x->font->write(bg, text, box.x + TEXT_PADDING + (gmenu2x->sc[icon] ? ICON_PADDING + ICON_DIMENSION : 0), box.y + (box.h - textHeight) / 2, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x.font->write(bg, text, box.x + TEXT_PADDING + (gmenu2x.sc[icon] ? ICON_PADDING + ICON_DIMENSION : 0), box.y + (box.h - textHeight) / 2, Font::HAlignLeft, Font::VAlignTop);
|
||||
|
||||
int btnX = gmenu2x->halfX+box.w/2-6;
|
||||
int btnX = gmenu2x.halfX + box.w / 2 - 6;
|
||||
for (uint i = 0; i < BUTTON_TYPE_SIZE; i++) {
|
||||
if (!buttons[i].empty()) {
|
||||
buttonPositions[i].y = box.y+box.h+8;
|
||||
buttonPositions[i].w = btnX;
|
||||
|
||||
btnX = gmenu2x->drawButtonRight(bg, buttonLabels[i], buttons[i], btnX, buttonPositions[i].y);
|
||||
btnX = gmenu2x.drawButtonRight(bg, buttonLabels[i], buttons[i], btnX, buttonPositions[i].y);
|
||||
|
||||
buttonPositions[i].x = btnX;
|
||||
buttonPositions[i].w = buttonPositions[i].x-btnX-6;
|
||||
@ -108,7 +108,7 @@ int MessageBox::exec() {
|
||||
int result = -1;
|
||||
while (result < 0) {
|
||||
InputManager::Button button;
|
||||
if (gmenu2x->input.pollButton(&button)
|
||||
if (gmenu2x.input.pollButton(&button)
|
||||
&& !buttons[button].empty()) {
|
||||
result = button;
|
||||
}
|
||||
|
@ -30,13 +30,13 @@ class GMenu2X;
|
||||
|
||||
class MessageBox {
|
||||
public:
|
||||
MessageBox(GMenu2X *gmenu2x, const std::string &text,
|
||||
MessageBox(GMenu2X& gmenu2x, const std::string &text,
|
||||
const std::string &icon="");
|
||||
void setButton(InputManager::Button button, const std::string &label);
|
||||
int exec();
|
||||
|
||||
private:
|
||||
GMenu2X *gmenu2x;
|
||||
GMenu2X& gmenu2x;
|
||||
std::string text, icon;
|
||||
std::string buttons[BUTTON_TYPE_SIZE];
|
||||
std::string buttonLabels[BUTTON_TYPE_SIZE];
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
Selector::Selector(GMenu2X *gmenu2x, LinkApp& link, const string &selectorDir)
|
||||
Selector::Selector(GMenu2X& gmenu2x, LinkApp& link, const string &selectorDir)
|
||||
: Dialog(gmenu2x)
|
||||
, link(link)
|
||||
{
|
||||
@ -58,30 +58,30 @@ int Selector::exec(int startSelection) {
|
||||
dir = parentDir(dir);
|
||||
}
|
||||
|
||||
OffscreenSurface bg(*gmenu2x->bg);
|
||||
OffscreenSurface bg(*gmenu2x.bg);
|
||||
drawTitleIcon(bg, link.getIconPath(), true);
|
||||
writeTitle(bg, link.getTitle());
|
||||
writeSubTitle(bg, link.getDescription());
|
||||
|
||||
int x = 5;
|
||||
if (fl.size() != 0) {
|
||||
x = gmenu2x->drawButton(bg, "accept", gmenu2x->tr["Select"], x);
|
||||
x = gmenu2x.drawButton(bg, "accept", gmenu2x.tr["Select"], x);
|
||||
}
|
||||
if (showDirectories) {
|
||||
x = gmenu2x->drawButton(bg, "left", "", x);
|
||||
x = gmenu2x->drawButton(bg, "cancel", gmenu2x->tr["Up one folder"], x);
|
||||
x = gmenu2x.drawButton(bg, "left", "", x);
|
||||
x = gmenu2x.drawButton(bg, "cancel", gmenu2x.tr["Up one folder"], x);
|
||||
} else {
|
||||
x = gmenu2x->drawButton(bg, "cancel", "", x);
|
||||
x = gmenu2x.drawButton(bg, "cancel", "", x);
|
||||
}
|
||||
x = gmenu2x->drawButton(bg, "start", gmenu2x->tr["Exit"], x);
|
||||
x = gmenu2x.drawButton(bg, "start", gmenu2x.tr["Exit"], x);
|
||||
|
||||
unsigned int top, height;
|
||||
tie(top, height) = gmenu2x->getContentArea();
|
||||
tie(top, height) = gmenu2x.getContentArea();
|
||||
|
||||
auto folderIcon = gmenu2x->sc.skinRes("imgs/folder.png");
|
||||
auto folderIcon = gmenu2x.sc.skinRes("imgs/folder.png");
|
||||
|
||||
// Figure out how many items we can fit in the content area.
|
||||
int lineHeight = gmenu2x->font->getLineSpacing();
|
||||
int lineHeight = gmenu2x.font->getLineSpacing();
|
||||
if (showDirectories && folderIcon) {
|
||||
lineHeight = max(lineHeight, folderIcon->height() + 2);
|
||||
}
|
||||
@ -97,12 +97,12 @@ int Selector::exec(int startSelection) {
|
||||
|
||||
bool close = false, result = true;
|
||||
while (!close) {
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
|
||||
bg.blit(s, 0, 0);
|
||||
|
||||
if (fl.size() == 0) {
|
||||
gmenu2x->font->write(s, "(" + gmenu2x->tr["no items"] + ")",
|
||||
gmenu2x.font->write(s, "(" + gmenu2x.tr["no items"] + ")",
|
||||
4, top + lineHeight / 2,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
} else {
|
||||
@ -123,7 +123,7 @@ int Selector::exec(int startSelection) {
|
||||
//Selection
|
||||
int iY = top + (selected - firstElement) * lineHeight;
|
||||
if (selected<fl.size())
|
||||
s.box(1, iY, 309, lineHeight, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
s.box(1, iY, 309, lineHeight, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
|
||||
//Files & Dirs
|
||||
s.setClipRect(0, top, 311, height);
|
||||
@ -137,11 +137,11 @@ int Selector::exec(int startSelection) {
|
||||
x, iY + (lineHeight - folderIcon->height()) / 2);
|
||||
x += folderIcon->width() + 2;
|
||||
}
|
||||
gmenu2x->font->write(s, fl[i],
|
||||
gmenu2x.font->write(s, fl[i],
|
||||
x, iY + lineHeight / 2,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
} else {
|
||||
gmenu2x->font->write(s, trimExtension(fl[i]),
|
||||
gmenu2x.font->write(s, trimExtension(fl[i]),
|
||||
x, iY + lineHeight / 2,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
}
|
||||
@ -149,10 +149,10 @@ int Selector::exec(int startSelection) {
|
||||
s.clearClipRect();
|
||||
}
|
||||
|
||||
gmenu2x->drawScrollBar(nb_elements, fl.size(), firstElement);
|
||||
gmenu2x.drawScrollBar(nb_elements, fl.size(), firstElement);
|
||||
s.flip();
|
||||
|
||||
switch (gmenu2x->input.waitForPressedButton()) {
|
||||
switch (gmenu2x.input.waitForPressedButton()) {
|
||||
case InputManager::SETTINGS:
|
||||
close = true;
|
||||
result = false;
|
||||
|
@ -44,7 +44,7 @@ private:
|
||||
int goToParentDir(FileLister& fl);
|
||||
|
||||
public:
|
||||
Selector(GMenu2X *gmenu2x, LinkApp& link,
|
||||
Selector(GMenu2X& gmenu2x, LinkApp& link,
|
||||
const std::string &selectorDir = "");
|
||||
|
||||
int exec(int startSelection = 0);
|
||||
|
@ -28,14 +28,14 @@
|
||||
using namespace std;
|
||||
|
||||
SettingsDialog::SettingsDialog(
|
||||
GMenu2X *gmenu2x_, InputManager &inputMgr_, Touchscreen &ts_,
|
||||
GMenu2X& gmenu2x, InputManager &inputMgr_, Touchscreen &ts_,
|
||||
const string &text_, const string &icon)
|
||||
: Dialog(gmenu2x_)
|
||||
: Dialog(gmenu2x)
|
||||
, inputMgr(inputMgr_)
|
||||
, ts(ts_)
|
||||
, text(text_)
|
||||
{
|
||||
if (!icon.empty() && gmenu2x->sc[icon] != NULL) {
|
||||
if (!icon.empty() && gmenu2x.sc[icon] != NULL) {
|
||||
this->icon = icon;
|
||||
} else {
|
||||
this->icon = "icons/generic.png";
|
||||
@ -43,46 +43,46 @@ SettingsDialog::SettingsDialog(
|
||||
}
|
||||
|
||||
bool SettingsDialog::exec() {
|
||||
OffscreenSurface bg(*gmenu2x->bg);
|
||||
OffscreenSurface bg(*gmenu2x.bg);
|
||||
bg.convertToDisplayFormat();
|
||||
|
||||
bool close = false, ts_pressed = false;
|
||||
uint i, sel = 0, firstElement = 0;
|
||||
|
||||
const int topBarHeight = gmenu2x->skinConfInt["topBarHeight"];
|
||||
const int topBarHeight = gmenu2x.skinConfInt["topBarHeight"];
|
||||
SDL_Rect clipRect = {
|
||||
0,
|
||||
static_cast<Sint16>(topBarHeight + 1),
|
||||
static_cast<Uint16>(gmenu2x->resX - 9),
|
||||
static_cast<Uint16>(gmenu2x->resY - topBarHeight - 25)
|
||||
static_cast<Uint16>(gmenu2x.resX - 9),
|
||||
static_cast<Uint16>(gmenu2x.resY - topBarHeight - 25)
|
||||
};
|
||||
SDL_Rect touchRect = {
|
||||
2,
|
||||
static_cast<Sint16>(topBarHeight + 4),
|
||||
static_cast<Uint16>(gmenu2x->resX - 12),
|
||||
static_cast<Uint16>(gmenu2x.resX - 12),
|
||||
static_cast<Uint16>(clipRect.h)
|
||||
};
|
||||
uint rowHeight = gmenu2x->font->getLineSpacing() + 1; // gp2x=15+1 / pandora=19+1
|
||||
uint numRows = (gmenu2x->resY - topBarHeight - 20) / rowHeight;
|
||||
uint rowHeight = gmenu2x.font->getLineSpacing() + 1; // gp2x=15+1 / pandora=19+1
|
||||
uint numRows = (gmenu2x.resY - topBarHeight - 20) / rowHeight;
|
||||
|
||||
uint maxNameWidth = 0;
|
||||
for (auto it = settings.begin(); it != settings.end(); it++) {
|
||||
maxNameWidth = max(maxNameWidth, (uint) gmenu2x->font->getTextWidth((*it)->getName()));
|
||||
maxNameWidth = max(maxNameWidth, (uint) gmenu2x.font->getTextWidth((*it)->getName()));
|
||||
}
|
||||
|
||||
while (!close) {
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
|
||||
if (ts.available()) ts.poll();
|
||||
|
||||
bg.blit(s, 0, 0);
|
||||
|
||||
gmenu2x->drawTopBar(s);
|
||||
gmenu2x.drawTopBar(s);
|
||||
//link icon
|
||||
drawTitleIcon(s, icon);
|
||||
writeTitle(s, text);
|
||||
|
||||
gmenu2x->drawBottomBar(s);
|
||||
gmenu2x.drawBottomBar(s);
|
||||
|
||||
if (sel>firstElement+numRows-1) firstElement=sel-numRows+1;
|
||||
if (sel<firstElement) firstElement=sel;
|
||||
@ -111,7 +111,7 @@ bool SettingsDialog::exec() {
|
||||
}
|
||||
}
|
||||
|
||||
gmenu2x->drawScrollBar(numRows, settings.size(), firstElement);
|
||||
gmenu2x.drawScrollBar(numRows, settings.size(), firstElement);
|
||||
|
||||
//description
|
||||
writeSubTitle(s, settings[sel]->getDescription());
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
std::string text, icon;
|
||||
|
||||
public:
|
||||
SettingsDialog(GMenu2X *gmenu2x, InputManager &inputMgr, Touchscreen &ts,
|
||||
SettingsDialog(GMenu2X& gmenu2x, InputManager &inputMgr, Touchscreen &ts,
|
||||
const std::string &text,
|
||||
const std::string &icon = "skin:sections/settings.png");
|
||||
|
||||
|
@ -27,10 +27,10 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
TextDialog::TextDialog(GMenu2X *gmenu2x, const string &title, const string &description, const string &icon, const string &text)
|
||||
TextDialog::TextDialog(GMenu2X& gmenu2x, const string &title, const string &description, const string &icon, const string &text)
|
||||
: Dialog(gmenu2x)
|
||||
{
|
||||
split(this->text, gmenu2x->font->wordWrap(text, (int) gmenu2x->resX - 15), "\n");
|
||||
split(this->text, gmenu2x.font->wordWrap(text, (int) gmenu2x.resX - 15), "\n");
|
||||
this->title = title;
|
||||
this->description = description;
|
||||
this->icon = icon;
|
||||
@ -39,28 +39,28 @@ TextDialog::TextDialog(GMenu2X *gmenu2x, const string &title, const string &desc
|
||||
void TextDialog::drawText(const vector<string> &text, unsigned int y,
|
||||
unsigned int firstRow, unsigned int rowsPerPage)
|
||||
{
|
||||
Surface& s = *gmenu2x->s;
|
||||
const int fontHeight = gmenu2x->font->getLineSpacing();
|
||||
Surface& s = *gmenu2x.s;
|
||||
const int fontHeight = gmenu2x.font->getLineSpacing();
|
||||
|
||||
for (unsigned i = firstRow; i < firstRow + rowsPerPage && i < text.size(); i++) {
|
||||
const string &line = text.at(i);
|
||||
int rowY = y + (i - firstRow) * fontHeight;
|
||||
if (line == "----") { // horizontal ruler
|
||||
rowY += fontHeight / 2;
|
||||
s.box(5, rowY, gmenu2x->resX - 16, 1, 255, 255, 255, 130);
|
||||
s.box(5, rowY+1, gmenu2x->resX - 16, 1, 0, 0, 0, 130);
|
||||
s.box(5, rowY, gmenu2x.resX - 16, 1, 255, 255, 255, 130);
|
||||
s.box(5, rowY+1, gmenu2x.resX - 16, 1, 0, 0, 0, 130);
|
||||
} else {
|
||||
gmenu2x->font->write(s, line, 5, rowY);
|
||||
gmenu2x.font->write(s, line, 5, rowY);
|
||||
}
|
||||
}
|
||||
|
||||
gmenu2x->drawScrollBar(rowsPerPage, text.size(), firstRow);
|
||||
gmenu2x.drawScrollBar(rowsPerPage, text.size(), firstRow);
|
||||
}
|
||||
|
||||
void TextDialog::exec() {
|
||||
bool close = false;
|
||||
|
||||
OffscreenSurface bg(*gmenu2x->bg);
|
||||
OffscreenSurface bg(*gmenu2x.bg);
|
||||
|
||||
//link icon
|
||||
if (!fileExists(icon))
|
||||
@ -71,16 +71,16 @@ void TextDialog::exec() {
|
||||
writeSubTitle(bg, description);
|
||||
|
||||
int x = 5;
|
||||
x = gmenu2x->drawButton(bg, "up", "", x);
|
||||
x = gmenu2x->drawButton(bg, "down", gmenu2x->tr["Scroll"], x);
|
||||
x = gmenu2x->drawButton(bg, "cancel", "", x);
|
||||
x = gmenu2x->drawButton(bg, "start", gmenu2x->tr["Exit"], x);
|
||||
x = gmenu2x.drawButton(bg, "up", "", x);
|
||||
x = gmenu2x.drawButton(bg, "down", gmenu2x.tr["Scroll"], x);
|
||||
x = gmenu2x.drawButton(bg, "cancel", "", x);
|
||||
x = gmenu2x.drawButton(bg, "start", gmenu2x.tr["Exit"], x);
|
||||
|
||||
bg.convertToDisplayFormat();
|
||||
|
||||
const int fontHeight = gmenu2x->font->getLineSpacing();
|
||||
const int fontHeight = gmenu2x.font->getLineSpacing();
|
||||
unsigned int contentY, contentHeight;
|
||||
tie(contentY, contentHeight) = gmenu2x->getContentArea();
|
||||
tie(contentY, contentHeight) = gmenu2x.getContentArea();
|
||||
const unsigned rowsPerPage = max(contentHeight / fontHeight, 1u);
|
||||
const unsigned maxFirstRow =
|
||||
text.size() < rowsPerPage ? 0 : text.size() - rowsPerPage;
|
||||
@ -88,13 +88,13 @@ void TextDialog::exec() {
|
||||
|
||||
unsigned firstRow = 0;
|
||||
while (!close) {
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
|
||||
bg.blit(s, 0, 0);
|
||||
drawText(text, contentY, firstRow, rowsPerPage);
|
||||
s.flip();
|
||||
|
||||
switch(gmenu2x->input.waitForPressedButton()) {
|
||||
switch(gmenu2x.input.waitForPressedButton()) {
|
||||
case InputManager::UP:
|
||||
if (firstRow > 0) firstRow--;
|
||||
break;
|
||||
|
@ -35,7 +35,7 @@ protected:
|
||||
unsigned int firstRow, unsigned int rowsPerPage);
|
||||
|
||||
public:
|
||||
TextDialog(GMenu2X *gmenu2x, const std::string &title,
|
||||
TextDialog(GMenu2X& gmenu2x, const std::string &title,
|
||||
const std::string &description, const std::string &icon,
|
||||
const std::string &text);
|
||||
void exec();
|
||||
|
@ -29,9 +29,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, const string &title, const string &icon, const string &text)
|
||||
: TextDialog(gmenu2x,title,"",icon,text) {
|
||||
|
||||
TextManualDialog::TextManualDialog(GMenu2X& gmenu2x, const string &title, const string &icon, const string &text)
|
||||
: TextDialog(gmenu2x, title, "", icon, text)
|
||||
{
|
||||
//split the text in multiple pages
|
||||
for (uint i=0; i<this->text.size(); i++) {
|
||||
string line = trim(this->text.at(i));
|
||||
@ -42,7 +42,7 @@ TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, const string &title, const
|
||||
} else {
|
||||
if (pages.size()==0) {
|
||||
ManualPage mp;
|
||||
mp.title = gmenu2x->tr["Untitled"];
|
||||
mp.title = gmenu2x.tr["Untitled"];
|
||||
pages.push_back(mp);
|
||||
}
|
||||
pages[pages.size()-1].text.push_back(this->text.at(i));
|
||||
@ -50,7 +50,7 @@ TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, const string &title, const
|
||||
}
|
||||
if (pages.size()==0) {
|
||||
ManualPage mp;
|
||||
mp.title = gmenu2x->tr["Untitled"];
|
||||
mp.title = gmenu2x.tr["Untitled"];
|
||||
pages.push_back(mp);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, const string &title, const
|
||||
}
|
||||
|
||||
void TextManualDialog::exec() {
|
||||
OffscreenSurface bg(*gmenu2x->bg);
|
||||
OffscreenSurface bg(*gmenu2x.bg);
|
||||
|
||||
//link icon
|
||||
if (!fileExists(icon))
|
||||
@ -80,12 +80,12 @@ void TextManualDialog::exec() {
|
||||
writeTitle(bg, title+(description.empty() ? "" : ": "+description));
|
||||
|
||||
int x = 5;
|
||||
x = gmenu2x->drawButton(bg, "up", "", x);
|
||||
x = gmenu2x->drawButton(bg, "down", gmenu2x->tr["Scroll"], x);
|
||||
x = gmenu2x->drawButton(bg, "left", "", x);
|
||||
x = gmenu2x->drawButton(bg, "right", gmenu2x->tr["Change page"], x);
|
||||
x = gmenu2x->drawButton(bg, "cancel", "", x);
|
||||
x = gmenu2x->drawButton(bg, "start", gmenu2x->tr["Exit"], x);
|
||||
x = gmenu2x.drawButton(bg, "up", "", x);
|
||||
x = gmenu2x.drawButton(bg, "down", gmenu2x.tr["Scroll"], x);
|
||||
x = gmenu2x.drawButton(bg, "left", "", x);
|
||||
x = gmenu2x.drawButton(bg, "right", gmenu2x.tr["Change page"], x);
|
||||
x = gmenu2x.drawButton(bg, "cancel", "", x);
|
||||
x = gmenu2x.drawButton(bg, "start", gmenu2x.tr["Exit"], x);
|
||||
|
||||
bg.convertToDisplayFormat();
|
||||
|
||||
@ -95,9 +95,9 @@ void TextManualDialog::exec() {
|
||||
ss >> spagecount;
|
||||
string pageStatus;
|
||||
|
||||
const int fontHeight = gmenu2x->font->getLineSpacing();
|
||||
const int fontHeight = gmenu2x.font->getLineSpacing();
|
||||
unsigned int contentY, contentHeight;
|
||||
tie(contentY, contentHeight) = gmenu2x->getContentArea();
|
||||
tie(contentY, contentHeight) = gmenu2x.getContentArea();
|
||||
const unsigned rowsPerPage = max(contentHeight / fontHeight, 1u);
|
||||
contentY += (contentHeight % fontHeight) / 2;
|
||||
|
||||
@ -105,7 +105,7 @@ void TextManualDialog::exec() {
|
||||
bool close = false;
|
||||
|
||||
while (!close) {
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
|
||||
bg.blit(s,0,0);
|
||||
writeSubTitle(s, pages[page].title);
|
||||
@ -114,15 +114,15 @@ void TextManualDialog::exec() {
|
||||
ss.clear();
|
||||
ss << page+1;
|
||||
ss >> pageStatus;
|
||||
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
|
||||
gmenu2x->font->write(s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
|
||||
pageStatus = gmenu2x.tr["Page"]+": "+pageStatus+"/"+spagecount;
|
||||
gmenu2x.font->write(s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
|
||||
|
||||
s.flip();
|
||||
|
||||
const unsigned maxFirstRow = pages[page].text.size() < rowsPerPage
|
||||
? 0 : pages[page].text.size() - rowsPerPage;
|
||||
|
||||
switch(gmenu2x->input.waitForPressedButton()) {
|
||||
switch(gmenu2x.input.waitForPressedButton()) {
|
||||
case InputManager::UP:
|
||||
if (firstRow > 0) firstRow--;
|
||||
break;
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
std::vector<ManualPage> pages;
|
||||
|
||||
public:
|
||||
TextManualDialog(GMenu2X *gmenu2x, const std::string &title,
|
||||
TextManualDialog(GMenu2X& gmenu2x, const std::string &title,
|
||||
const std::string &icon, const std::string &text);
|
||||
void exec();
|
||||
};
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
WallpaperDialog::WallpaperDialog(GMenu2X *gmenu2x, Touchscreen &ts_)
|
||||
WallpaperDialog::WallpaperDialog(GMenu2X& gmenu2x, Touchscreen &ts_)
|
||||
: Dialog(gmenu2x)
|
||||
, ts(ts_)
|
||||
{
|
||||
@ -47,11 +47,11 @@ bool WallpaperDialog::exec()
|
||||
fl.setFilter("png");
|
||||
|
||||
fl.browse(GMenu2X::getHome() + "/skins/"
|
||||
+ gmenu2x->confStr["skin"] + "/wallpapers", true);
|
||||
+ gmenu2x.confStr["skin"] + "/wallpapers", true);
|
||||
fl.browse(GMENU2X_SYSTEM_DIR "/skins/"
|
||||
+ gmenu2x->confStr["skin"] + "/wallpapers", false);
|
||||
+ gmenu2x.confStr["skin"] + "/wallpapers", false);
|
||||
|
||||
if (gmenu2x->confStr["skin"] != "Default") {
|
||||
if (gmenu2x.confStr["skin"] != "Default") {
|
||||
fl.browse(GMenu2X::getHome() + "/skins/Default/wallpapers", false);
|
||||
fl.browse(GMENU2X_SYSTEM_DIR "/skins/Default/wallpapers", false);
|
||||
}
|
||||
@ -63,17 +63,17 @@ bool WallpaperDialog::exec()
|
||||
uint i, selected = 0, firstElement = 0, iY;
|
||||
|
||||
ButtonBox buttonbox;
|
||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Select"])));
|
||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Exit"])));
|
||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x.tr["Select"])));
|
||||
buttonbox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x.tr["Exit"])));
|
||||
|
||||
unsigned int top, height;
|
||||
tie(top, height) = gmenu2x->getContentArea();
|
||||
tie(top, height) = gmenu2x.getContentArea();
|
||||
|
||||
int fontheight = gmenu2x->font->getLineSpacing();
|
||||
int fontheight = gmenu2x.font->getLineSpacing();
|
||||
unsigned int nb_elements = height / fontheight;
|
||||
|
||||
while (!close) {
|
||||
OutputSurface& s = *gmenu2x->s;
|
||||
OutputSurface& s = *gmenu2x.s;
|
||||
|
||||
if (selected > firstElement + nb_elements - 1)
|
||||
firstElement = selected - nb_elements + 1;
|
||||
@ -81,37 +81,37 @@ bool WallpaperDialog::exec()
|
||||
firstElement = selected;
|
||||
|
||||
//Wallpaper
|
||||
gmenu2x->sc[((string)"skin:wallpapers/" + wallpapers[selected]).c_str()]->blit(s, 0, 0);
|
||||
gmenu2x.sc[((string)"skin:wallpapers/" + wallpapers[selected]).c_str()]->blit(s, 0, 0);
|
||||
|
||||
gmenu2x->drawTopBar(s);
|
||||
gmenu2x->drawBottomBar(s);
|
||||
gmenu2x.drawTopBar(s);
|
||||
gmenu2x.drawBottomBar(s);
|
||||
|
||||
drawTitleIcon(s, "icons/wallpaper.png", true);
|
||||
writeTitle(s, gmenu2x->tr["Wallpaper selection"]);
|
||||
writeSubTitle(s, gmenu2x->tr["Select a wallpaper from the list"]);
|
||||
writeTitle(s, gmenu2x.tr["Wallpaper selection"]);
|
||||
writeSubTitle(s, gmenu2x.tr["Select a wallpaper from the list"]);
|
||||
|
||||
buttonbox.paint(s, 5, gmenu2x->resY - 1);
|
||||
buttonbox.paint(s, 5, gmenu2x.resY - 1);
|
||||
|
||||
//Selection
|
||||
iY = selected - firstElement;
|
||||
iY = top + (iY * fontheight);
|
||||
s.box(2, iY, 308, fontheight, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
s.box(2, iY, 308, fontheight, gmenu2x.skinConfColors[COLOR_SELECTION_BG]);
|
||||
|
||||
//Files & Directories
|
||||
s.setClipRect(0, top, 311, height);
|
||||
for (i = firstElement; i < wallpapers.size()
|
||||
&& i < firstElement + nb_elements; i++) {
|
||||
iY = i-firstElement;
|
||||
gmenu2x->font->write(s, wallpapers[i], 5,
|
||||
gmenu2x.font->write(s, wallpapers[i], 5,
|
||||
top + (iY * fontheight),
|
||||
Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
s.clearClipRect();
|
||||
|
||||
gmenu2x->drawScrollBar(nb_elements, wallpapers.size(), firstElement);
|
||||
gmenu2x.drawScrollBar(nb_elements, wallpapers.size(), firstElement);
|
||||
s.flip();
|
||||
|
||||
switch(gmenu2x->input.waitForPressedButton()) {
|
||||
switch(gmenu2x.input.waitForPressedButton()) {
|
||||
case InputManager::CANCEL:
|
||||
close = true;
|
||||
result = false;
|
||||
@ -139,15 +139,16 @@ bool WallpaperDialog::exec()
|
||||
case InputManager::ACCEPT:
|
||||
close = true;
|
||||
if (wallpapers.size() > 0)
|
||||
wallpaper = gmenu2x->sc.getSkinFilePath("wallpapers/" + wallpapers[selected]);
|
||||
wallpaper = gmenu2x.sc.getSkinFilePath("wallpapers/" + wallpapers[selected]);
|
||||
else result = false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint i=0; i<wallpapers.size(); i++)
|
||||
gmenu2x->sc.del("skin:wallpapers/" + wallpapers[i]);
|
||||
for (uint i=0; i<wallpapers.size(); i++) {
|
||||
gmenu2x.sc.del("skin:wallpapers/" + wallpapers[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ private:
|
||||
Touchscreen &ts;
|
||||
|
||||
public:
|
||||
WallpaperDialog(GMenu2X *gmenu2x, Touchscreen &ts);
|
||||
WallpaperDialog(GMenu2X& gmenu2x, Touchscreen &ts);
|
||||
std::string wallpaper;
|
||||
|
||||
bool exec();
|
||||
|
Loading…
Reference in New Issue
Block a user