pictureviewer: using CComponentsHeader to paint header

* rework footer handling (get height from paintButtons methode)


Origin commit data
------------------
Branch: ni/coolstream
Commit: b335a50ef3
Author: vanhofen <vanhofen@gmx.de>
Date: 2013-05-27 (Mon, 27 May 2013)

Origin message was:
------------------
- pictureviewer: using CComponentsHeader to paint header

* rework footer handling (get height from paintButtons methode)


------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2013-05-27 22:25:30 +02:00
parent e52b01ab39
commit e1c59e3472
2 changed files with 50 additions and 59 deletions

View File

@@ -47,6 +47,7 @@
#include <gui/audiomute.h> #include <gui/audiomute.h>
#include <gui/nfs.h> #include <gui/nfs.h>
#include <gui/components/cc_frm.h>
#include <gui/widget/buttons.h> #include <gui/widget/buttons.h>
#include <gui/widget/icons.h> #include <gui/widget/icons.h>
#include <gui/widget/menue.h> #include <gui/widget/menue.h>
@@ -122,6 +123,26 @@ CPictureViewerGui::~CPictureViewerGui()
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
#define PictureViewerButtons1Count 4
const struct button_label PictureViewerButtons1[PictureViewerButtons1Count] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD },
{ NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_AUDIOPLAYER_DELETEALL },
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_PICTUREVIEWER_SLIDESHOW }
};
#define PictureViewerButtons2Count 3
struct button_label PictureViewerButtons2[PictureViewerButtons2Count] =
{
{ NEUTRINO_ICON_BUTTON_5 , LOCALE_PICTUREVIEWER_SORTORDER_DATE },
{ NEUTRINO_ICON_BUTTON_OKAY , LOCALE_PICTUREVIEWER_SHOW },
{ NEUTRINO_ICON_BUTTON_MUTE_SMALL, LOCALE_FILEBROWSER_DELETE }
};
//------------------------------------------------------------------------
int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey) int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey)
{ {
audioplayer = false; audioplayer = false;
@@ -133,27 +154,17 @@ int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey)
width = frameBuffer->getScreenWidthRel(); width = frameBuffer->getScreenWidthRel();
height = frameBuffer->getScreenHeightRel(); height = frameBuffer->getScreenHeightRel();
sheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight(); sheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
int icol_w, icol_h; //get footerHeight from paintButtons
buttons1Height = ::paintButtons(0, 0, 0, PictureViewerButtons1Count, PictureViewerButtons1, 0, 0, "", false, COL_INFOBAR_SHADOW, NULL, 0, false);
buttons2Height = ::paintButtons(0, 0, 0, PictureViewerButtons2Count, PictureViewerButtons2, 0, 0, "", false, COL_INFOBAR_SHADOW, NULL, 0, false);
footerHeight = buttons1Height + buttons2Height;
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); listmaxshow = (height-theight-footerHeight)/(fheight);
height = theight+listmaxshow*fheight+footerHeight; // recalc height
frameBuffer->getIconSize(NEUTRINO_ICON_MP3, &icol_w, &icol_h);
theight = std::max(theight, icol_h);
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_HELP, &icol_w, &icol_h);
theight = std::max(theight, icol_h);
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MENU, &icol_w, &icol_h);
theight = std::max(theight, icol_h);
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icol_w, &icol_h);
buttonHeight = 8 + std::max(icol_h+2, sheight); //TODO get value from buttonbar
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
listmaxshow = (height-theight-2*buttonHeight)/(fheight);
height = theight+2*buttonHeight+listmaxshow*fheight; // recalc height
x=getScreenStartX( width ); x=getScreenStartX( width );
y=getScreenStartY( height ); y=getScreenStartY( height );
@@ -686,63 +697,41 @@ void CPictureViewerGui::paintItem(int pos)
void CPictureViewerGui::paintHead() void CPictureViewerGui::paintHead()
{ {
// printf("paintHead{\n"); CComponentsHeader header(x, y, width, theight, LOCALE_PICTUREVIEWER_HEAD, NEUTRINO_ICON_MP3, CComponentsHeader::CC_BTN_HELP);
std::string strCaption = g_Locale->getText(LOCALE_PICTUREVIEWER_HEAD);
int iw1, iw2, iw3, ih; #ifdef ENABLE_GUI_MOUNT
frameBuffer->getIconSize(NEUTRINO_ICON_MP3, &iw1, &ih); header.addButtonIcon(NEUTRINO_ICON_BUTTON_MENU);
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_HELP, &iw2, &ih); #endif
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MENU, &iw3, &ih);
frameBuffer->paintBoxRel(x, y, width, theight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); header.paint();
frameBuffer->paintIcon(NEUTRINO_ICON_MP3, x+5, y, theight);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+iw1+10, y+theight+0, width- iw1 - iw2 - iw3 - 5*5, strCaption, COL_MENUHEAD, 0, true); // UTF-8
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_HELP, x+ width- iw2 - 5, y, theight);
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_MENU, x+ width- iw2 - iw3 - 10, y, theight );
// printf("paintHead}\n");
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
const struct button_label PictureViewerButtons[5] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD },
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_DELETEALL },
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_PICTUREVIEWER_SLIDESHOW },
{ NEUTRINO_ICON_BUTTON_MUTE_SMALL , LOCALE_FILEBROWSER_DELETE }
};
const struct button_label PictureViewerButtons2[][2] =
{
{
{ NEUTRINO_ICON_BUTTON_5 , LOCALE_PICTUREVIEWER_SORTORDER_DATE },
{ NEUTRINO_ICON_BUTTON_OKAY , LOCALE_PICTUREVIEWER_SHOW }
},
{
{ NEUTRINO_ICON_BUTTON_5 , LOCALE_PICTUREVIEWER_SORTORDER_FILENAME },
{ NEUTRINO_ICON_BUTTON_OKAY , LOCALE_PICTUREVIEWER_SHOW }
}
};
void CPictureViewerGui::paintFoot() void CPictureViewerGui::paintFoot()
{ {
// printf("paintFoot{\n"); if (m_sort == FILENAME)
PictureViewerButtons2[0].locale = LOCALE_PICTUREVIEWER_SORTORDER_FILENAME;
else
PictureViewerButtons2[0].locale = LOCALE_PICTUREVIEWER_SORTORDER_DATE;
frameBuffer->paintBoxRel(x, y+(height-2*buttonHeight), width, 2*buttonHeight, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_LARGE, CORNER_BOTTOM); frameBuffer->paintBoxRel(x, y + (height - footerHeight), width, footerHeight, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_LARGE, CORNER_BOTTOM);
if (!playlist.empty()) if (!playlist.empty())
{ {
::paintButtons(x, y + (height - 2 * buttonHeight), 0, 5, PictureViewerButtons, width); ::paintButtons(x, y + (height - footerHeight), 0, PictureViewerButtons1Count, PictureViewerButtons1, width);
::paintButtons(x, y + (height - buttonHeight), 0, 2, (m_sort==FILENAME)?PictureViewerButtons2[0]:PictureViewerButtons2[1], width); ::paintButtons(x, y + (height - buttons2Height), 0, PictureViewerButtons2Count, PictureViewerButtons2, width);
} }
else else
::paintButtons(x , y + (height - 2 * buttonHeight), 0, 1, &(PictureViewerButtons[1]), width); ::paintButtons(x, y + (height - footerHeight), 0, 1, &(PictureViewerButtons1[1]), width);
// printf("paintFoot}\n");
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void CPictureViewerGui::paintInfo() void CPictureViewerGui::paintInfo()
{ {
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void CPictureViewerGui::paint() void CPictureViewerGui::paint()

View File

@@ -77,7 +77,9 @@ class CPictureViewerGui : public CMenuTarget
int fheight; // Fonthoehe Playlist-Inhalt int fheight; // Fonthoehe Playlist-Inhalt
int theight; // Fonthoehe Playlist-Titel int theight; // Fonthoehe Playlist-Titel
int sheight; // Fonthoehe MP Info int sheight; // Fonthoehe MP Info
int buttonHeight; int footerHeight;
int buttons1Height;
int buttons2Height;
bool visible; bool visible;
State m_state; State m_state;
SortOrder m_sort; SortOrder m_sort;