left alignment of folders menu

This commit is contained in:
louis 2013-07-20 11:48:00 +02:00
parent 98a301eff5
commit 9f351151ed
3 changed files with 13 additions and 7 deletions

View File

@ -46,13 +46,14 @@ void cRecMenuItem::setBackground(void) {
// --- cRecMenuItemButton ------------------------------------------------------- // --- cRecMenuItemButton -------------------------------------------------------
cRecMenuItemButton::cRecMenuItemButton(const char *text, eRecMenuState action, bool active, bool halfWidth) { cRecMenuItemButton::cRecMenuItemButton(const char *text, eRecMenuState action, bool active, bool halfWidth, bool alignLeft) {
selectable = true; selectable = true;
this->text = text; this->text = text;
this->action = action; this->action = action;
this->active = active; this->active = active;
height = 3 * font->Height() / 2; height = 3 * font->Height() / 2;
this->halfWidth = halfWidth; this->halfWidth = halfWidth;
this->alignLeft = alignLeft;
} }
cRecMenuItemButton::~cRecMenuItemButton(void) { cRecMenuItemButton::~cRecMenuItemButton(void) {
@ -75,7 +76,11 @@ void cRecMenuItemButton::SetPixmaps(void) {
void cRecMenuItemButton::Draw(void) { void cRecMenuItemButton::Draw(void) {
int y = (height - font->Height()) / 2; int y = (height - font->Height()) / 2;
int x = (width - font->Width(*text)) / 2;; int x;
if (!alignLeft)
x = (width - font->Width(*text)) / 2;
else
x = 10;
pixmap->DrawText(cPoint(x, y), *text, colorText, colorTextBack, font); pixmap->DrawText(cPoint(x, y), *text, colorText, colorTextBack, font);
} }

View File

@ -97,8 +97,9 @@ class cRecMenuItemButton : public cRecMenuItem {
private: private:
cString text; cString text;
bool halfWidth; bool halfWidth;
bool alignLeft;
public: public:
cRecMenuItemButton(const char *text, eRecMenuState action, bool active, bool halfWidth = false); cRecMenuItemButton(const char *text, eRecMenuState action, bool active, bool halfWidth = false, bool alignLeft = false);
virtual ~cRecMenuItemButton(void); virtual ~cRecMenuItemButton(void);
int GetWidth(void); int GetWidth(void);
void SetPixmaps(void); void SetPixmaps(void);

View File

@ -76,12 +76,12 @@ public:
infoItem->CalculateHeight(width - 2 * border); infoItem->CalculateHeight(width - 2 * border);
SetHeader(infoItem); SetHeader(infoItem);
AddMenuItemScroll(new cRecMenuItemButton(tr("root video folder"), nextAction, true, false)); AddMenuItemScroll(new cRecMenuItemButton(tr("root video folder"), nextAction, true, false, true));
readFolders(NULL, ""); readFolders(NULL, "");
int numFolders = folders.size(); int numFolders = folders.size();
for (int i=0; i < numFolders; i++) { for (int i=0; i < numFolders; i++) {
AddMenuItemScroll(new cRecMenuItemButton(*folders[i], nextAction, false, false)); AddMenuItemScroll(new cRecMenuItemButton(*folders[i], nextAction, false, false, true));
if (!CheckHeight()) if (!CheckHeight())
break; break;
} }
@ -92,10 +92,10 @@ public:
}; };
cRecMenuItem *GetMenuItem(int number) { cRecMenuItem *GetMenuItem(int number) {
if (number == 0) { if (number == 0) {
cRecMenuItem *result = new cRecMenuItemButton(tr("root video folder"), rmsInstantRecord, false, false); cRecMenuItem *result = new cRecMenuItemButton(tr("root video folder"), rmsInstantRecord, false, false, true);
return result; return result;
} else if ((number > 0) && (number < folders.size()+1)) { } else if ((number > 0) && (number < folders.size()+1)) {
cRecMenuItem *result = new cRecMenuItemButton(*folders[number-1], rmsInstantRecord, false, false); cRecMenuItem *result = new cRecMenuItemButton(*folders[number-1], rmsInstantRecord, false, false, true);
return result; return result;
} }
return NULL; return NULL;