mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-02 10:21:04 +02:00
neutrino buttonbars: reworked painting of buttonbar in
channellist,
stringinput (also cleared some char format problems),
audioplayer,
bouqueteditor_bouqets,
bouqueteditor_channels,
bouqueteditor_chanselect,
bookmarkmanager,,
bouquetlist,
filebrowser,
epgplus,
epgview,
pictureviewer,
timerlist,
upnpbrowser
TODO:
This is still not a final solution. I would like to see buttonhandling in
own class for better integration and handling of window structure.
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1179 e54a6e83-5905-42d5-8d5c-058d10e6a962
Origin commit data
------------------
Commit: e1f887af72
Author: Thilo Graf <dbt@novatux.de>
Date: 2011-02-21 (Mon, 21 Feb 2011)
Origin message was:
------------------
*neutrino buttonbars: reworked painting of buttonbar in
channellist,
stringinput (also cleared some char format problems),
audioplayer,
bouqueteditor_bouqets,
bouqueteditor_channels,
bouqueteditor_chanselect,
bookmarkmanager,,
bouquetlist,
filebrowser,
epgplus,
epgview,
pictureviewer,
timerlist,
upnpbrowser
TODO:
This is still not a final solution. I would like to see buttonhandling in
own class for better integration and handling of window structure.
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1179 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/widget/buttons.cpp,v 1.2 2004/03/14 22:20:05 thegoodguy Exp $
|
||||
* $Id: buttons.cpp,v 1.10 2010/07/12 08:24:55 dbt Exp $
|
||||
*
|
||||
* (C) 2003 by thegoodguy <thegoodguy@berlios.de>
|
||||
*
|
||||
@@ -23,31 +23,160 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
|
||||
#include <gui/widget/buttons.h>
|
||||
#include <gui/customcolor.h>
|
||||
#include <system/settings.h>
|
||||
|
||||
#include <gui/color.h>
|
||||
#if 1
|
||||
void paintButtons(CFrameBuffer * const frameBuffer, Font * const font, const CLocaleManager * const localemanager, const int x, const int y, const unsigned int buttonwidth, const unsigned int count, const struct button_label * const content)
|
||||
{
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
int iw = 0, ih = 0;
|
||||
int fh = font->getHeight();
|
||||
|
||||
frameBuffer->getIconSize(content[i].button, &iw, &ih);
|
||||
frameBuffer->paintIcon(content[i].button, x + i * buttonwidth, y);
|
||||
font->RenderString(x + i * buttonwidth + iw + 5, y + fh-(fh-ih)/2, buttonwidth - iw - 5, localemanager->getText(content[i].locale), COL_INFOBAR, 0, true); // UTF-8
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void paintButtons(CFrameBuffer * const frameBuffer, Font * const font, const CLocaleManager * const localemanager, const int x, const int y, const unsigned int buttonwidth, const unsigned int height, const unsigned int count, const struct button_label * const content)
|
||||
|
||||
/* paintButtons usage,
|
||||
use this fucntion for painting icons with captions in horizontal or vertical direction.
|
||||
|
||||
* x set horizontal startposition
|
||||
* y set vertical startposition
|
||||
* footerwidth set width of buttonbar as similar to footer, value 0 (default) means: do nothing, then paint it extra
|
||||
* count set count of buttons
|
||||
* content set struct buttonlabel with iconfile and locales, for an empty text let locale constant empty, so you can paint icons without captions,
|
||||
* width width of footer, contains the buttons
|
||||
* footerheigth set height of buttonbar as similar to footer, value 0 (default) means: value calculates automaticly depends of maximal height of icon and caption
|
||||
* buttonwidth set width of buttonlabel include icon, caption and offsets, value 0 (default), calculates automaticly the buttonwidth, buttons will be paint like a chain
|
||||
* vertical_paint optional, default value is false (horizontal) sets direction of painted buttons
|
||||
* fcolor optional, default value is COL_INFOBAR_SHADOW, use it to render font with other color
|
||||
* alt_buttontext optional, default NULL, overwrites button caption at definied buttonlabel id (see parameter alt_buttontext_id) with this text
|
||||
* alt_buttontext_id optional, default 0, means id from buttonlable struct which text you will change
|
||||
*/
|
||||
|
||||
// y-------+ +-----------+
|
||||
// | ID0 ID1 |
|
||||
// | +-----buttonwidth------+---------+-----buttonwidth------+ |
|
||||
// | [icon][w_space][caption][w_space][icon][w_space][caption] | footerheight
|
||||
// | |
|
||||
// rounded +----------------------------------footerwidth----------------------------------+rounded----+ |
|
||||
// |
|
||||
// x
|
||||
//
|
||||
int paintButtons( const int &x,
|
||||
const int &y,
|
||||
const int &footerwidth,
|
||||
const uint &count,
|
||||
const struct button_label * const content,
|
||||
const int &footerheight,
|
||||
const int &buttonwidth,
|
||||
bool vertical_paint,
|
||||
const unsigned char fcolor,
|
||||
const char * alt_buttontext,
|
||||
const uint &buttontext_id)
|
||||
{
|
||||
int iw, ih;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
CFrameBuffer *frameBuffer = CFrameBuffer::getInstance();
|
||||
Font * font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL];
|
||||
uint cnt = count;
|
||||
int x_footer = x;
|
||||
int y_footer = y;
|
||||
int w_footer = footerwidth;
|
||||
int h_footer = 0;
|
||||
|
||||
int w_space = 4; //minimal space between caption to icon and between buttons and between border to caption
|
||||
int x_icon = x_footer+20;
|
||||
int x_caption = 0;
|
||||
|
||||
int x_button = x_icon;
|
||||
int w_button = 0;
|
||||
int h_button = 0;
|
||||
|
||||
//calculate max of h + w
|
||||
//icon
|
||||
int h_max_icon = 0;
|
||||
int w_max_icon = 0;
|
||||
|
||||
//text
|
||||
int w_max_text = 0;
|
||||
int h_max_text = font->getHeight();
|
||||
|
||||
for (uint i = 0; i < cnt; i++)
|
||||
{
|
||||
int fh = font->getHeight();
|
||||
frameBuffer->getIconSize(content[i].button, &iw, &ih);
|
||||
frameBuffer->paintIcon(content[i].button, x + i * buttonwidth, y, height);
|
||||
font->RenderString(x + i * buttonwidth + iw + 5, y + (height-fh)/2 + fh, buttonwidth - iw - 5, localemanager->getText(content[i].locale), COL_INFOBAR, 0, true); // UTF-8
|
||||
//icon
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
frameBuffer->getIconSize(content[i].button, &w, &h);
|
||||
h_max_icon = std::max(h_max_icon, h);
|
||||
w_max_icon = std::max(w_max_icon, w);
|
||||
|
||||
//text
|
||||
const char * buttontext = content[i].locale ? g_Locale->getText(content[i].locale) : "";
|
||||
|
||||
//text width
|
||||
int fwidth = font->getRenderWidth(buttontext, true);
|
||||
w_max_text = std::max(w_max_text, fwidth);
|
||||
}
|
||||
|
||||
//calculate button width
|
||||
w_button = buttonwidth == 0 ? (w_max_icon + w_space + w_max_text) : buttonwidth;
|
||||
|
||||
//calculate button heigth
|
||||
h_button = std::max(h_max_icon, h_max_text); //calculate optimal button height
|
||||
|
||||
//calculate footer heigth
|
||||
h_footer = footerheight == 0 ? (h_button + 2*w_space) : footerheight;
|
||||
|
||||
//paint footer
|
||||
if (w_footer > 0)
|
||||
frameBuffer->paintBoxRel(x_footer, y_footer, w_footer, h_footer, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_LARGE, CORNER_BOTTOM); //round
|
||||
|
||||
|
||||
//baseline
|
||||
int y_base = y_footer + h_footer/2;
|
||||
|
||||
|
||||
for (uint j = 0; j < cnt; j++)
|
||||
{
|
||||
const char * caption = NULL;
|
||||
//set caption...
|
||||
if (alt_buttontext != NULL && j == buttontext_id)
|
||||
caption = alt_buttontext; //...with an alternate buttontext
|
||||
else
|
||||
caption = content[j].locale ? g_Locale->getText(content[j].locale) : "";
|
||||
|
||||
const char * icon = content[j].button ? content[j].button : "";
|
||||
|
||||
//get height/width of icon
|
||||
int iconw, iconh;
|
||||
frameBuffer->getIconSize(content[j].button, &iconw, &iconh);
|
||||
|
||||
// calculate baseline startposition of icon and text in y
|
||||
int y_caption = y_base + h_max_text/2+1;
|
||||
|
||||
// paint icon and text
|
||||
frameBuffer->paintIcon(icon, x_button , y_base-iconh/2);
|
||||
x_caption = x_button + iconw + w_space;
|
||||
font->RenderString(x_caption, y_caption, w_max_text, caption, fcolor, 0, true); // UTF-8
|
||||
|
||||
/* set next startposition x, if text is length=0 then offset is =renderwidth of icon,
|
||||
* for generating buttons without captions,
|
||||
*/
|
||||
|
||||
int lentext = strlen(caption);
|
||||
if (vertical_paint)
|
||||
// set x_icon for painting buttons with vertical arrangement
|
||||
{
|
||||
if (lentext !=0)
|
||||
{
|
||||
x_button = x;
|
||||
y_base += h_footer;
|
||||
}
|
||||
else
|
||||
{
|
||||
x_button = x_caption;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//set x_icon for painting buttons with horizontal arrangement as default
|
||||
x_button = lentext !=0 ? (x_button + w_button + 2*w_space) : x_button;
|
||||
}
|
||||
}
|
||||
|
||||
return h_footer;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#define __gui_widget_buttons_h__
|
||||
|
||||
/*
|
||||
* $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/widget/buttons.h,v 1.2 2004/05/25 07:44:16 thegoodguy Exp $
|
||||
* $Id: buttons.h,v 1.6 2010/07/12 08:24:55 dbt Exp $
|
||||
*
|
||||
* (C) 2003 by thegoodguy <thegoodguy@berlios.de>
|
||||
*
|
||||
@@ -21,10 +21,11 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <driver/fontrenderer.h>
|
||||
#include <driver/framebuffer.h>
|
||||
#include <system/localize.h>
|
||||
#include <gui/color.h>
|
||||
|
||||
typedef struct button_label
|
||||
{
|
||||
@@ -32,7 +33,17 @@ typedef struct button_label
|
||||
neutrino_locale_t locale;
|
||||
} button_label_struct;
|
||||
|
||||
void paintButtons(CFrameBuffer * const frameBuffer, Font * const font, const CLocaleManager * const localemanager, const int x, const int y, const unsigned int buttonwidth, const unsigned int count, const struct button_label * const content);
|
||||
void paintButtons(CFrameBuffer * const frameBuffer, Font * const font, const CLocaleManager * const localemanager, const int x, const int y, const unsigned int buttonwidth, const unsigned int height, const unsigned int count, const struct button_label * const content);
|
||||
|
||||
int paintButtons( const int &x,
|
||||
const int &y,
|
||||
const int &footerwidth,
|
||||
const uint &count,
|
||||
const struct button_label * const content,
|
||||
const int &footerheight = 0,
|
||||
const int &buttonwidth = 0,
|
||||
bool vertical_paint = false,
|
||||
const unsigned char fcolor = COL_INFOBAR_SHADOW,
|
||||
const char * alt_buttontext = NULL,
|
||||
const uint &buttontext_id = 0);
|
||||
|
||||
|
||||
#endif /* __gui_widget_buttons_h__ */
|
||||
|
@@ -142,15 +142,16 @@ void CStringInput::init()
|
||||
}
|
||||
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
iheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getHeight();
|
||||
|
||||
height = hheight+ mheight+ 50;
|
||||
footerHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+8; //initial height value for buttonbar
|
||||
height = hheight+ mheight + 50;
|
||||
if (hint_1 != NONEXISTANT_LOCALE)
|
||||
{
|
||||
height += iheight;
|
||||
if (hint_2 != NONEXISTANT_LOCALE)
|
||||
height += iheight;
|
||||
}
|
||||
|
||||
height += g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+6; //buttonbar;
|
||||
|
||||
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width)>>1);
|
||||
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height)>>1);
|
||||
selected = 0;
|
||||
@@ -470,7 +471,7 @@ int CStringInput::handleOthers(const neutrino_msg_t /*msg*/, const neutrino_msg_
|
||||
|
||||
void CStringInput::hide()
|
||||
{
|
||||
frameBuffer->paintBackgroundBoxRel(x, y, width, height);
|
||||
frameBuffer->paintBackgroundBoxRel(x, y, width, height + footerHeight);
|
||||
}
|
||||
|
||||
const char * CStringInput::getHint1(void)
|
||||
@@ -484,7 +485,7 @@ void CStringInput::paint()
|
||||
int icol_w, icol_h;
|
||||
|
||||
frameBuffer->paintBoxRel(x, y, width, hheight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); //round
|
||||
frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);//round
|
||||
frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0);
|
||||
|
||||
if (!(iconfile.empty()))
|
||||
{
|
||||
@@ -561,15 +562,15 @@ CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, char* Value, int
|
||||
void CStringInputSMS::initSMS(const char * const Valid_Chars)
|
||||
{
|
||||
last_digit = -1; // no key pressed yet
|
||||
const char CharList[10][11] = { "0 -_/()<>=", // 9 characters
|
||||
const char CharList[10][11] = { "0 -_/()<>=", // 10 characters
|
||||
"1+.,:!?\\",
|
||||
"abc2<EFBFBD>",
|
||||
"abc2ä",
|
||||
"def3",
|
||||
"ghi4",
|
||||
"jkl5",
|
||||
"mno6<EFBFBD>",
|
||||
"pqrs7<EFBFBD>",
|
||||
"tuv8<EFBFBD>",
|
||||
"mno6ö",
|
||||
"pqrs7ß",
|
||||
"tuv8ü",
|
||||
"wxyz9" };
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
@@ -686,30 +687,17 @@ void CStringInputSMS::keyRightPressed()
|
||||
const struct button_label CStringInputSMSButtons[2] =
|
||||
{
|
||||
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_STRINGINPUT_CAPS },
|
||||
// { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_XXX },
|
||||
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_STRINGINPUT_CLEAR }
|
||||
// { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_XXX }
|
||||
};
|
||||
|
||||
void CStringInputSMS::paint()
|
||||
{
|
||||
int icol_w, icol_h;
|
||||
int bh, bw, fh;
|
||||
|
||||
CStringInput::paint();
|
||||
|
||||
fh = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icol_w, &icol_h);
|
||||
bh = std::max(fh, icol_h+4);
|
||||
bw = (width - 20) / 2;
|
||||
|
||||
frameBuffer->paintIcon(NEUTRINO_ICON_NUMERIC_PAD, x+20+140, y+ hheight+ mheight+ iheight* 3+ 30, 0, COL_MENUCONTENT);
|
||||
|
||||
frameBuffer->paintBoxRel(x, y+height-bh, width, bh, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
|
||||
//frameBuffer->paintHLine(x, x+width, y+height-25, COL_INFOBAR_SHADOW_PLUS_0);
|
||||
|
||||
//::paintButtons(frameBuffer, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL], g_Locale, x + 8, y+height-25+1, 230, 2, CStringInputSMSButtons);
|
||||
::paintButtons(frameBuffer, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL], g_Locale, x + 10, y+height-bh, bw, bh, 2, CStringInputSMSButtons);
|
||||
//buttonbar
|
||||
::paintButtons(x, y + height, width, 2, CStringInputSMSButtons);
|
||||
}
|
||||
|
||||
void CPINInput::paintChar(int pos)
|
||||
|
@@ -52,6 +52,7 @@ class CStringInput : public CMenuTarget
|
||||
int hheight; // head font height
|
||||
int mheight; // menu font height
|
||||
int iheight;
|
||||
int footerHeight;
|
||||
|
||||
char * head;
|
||||
neutrino_locale_t name;
|
||||
|
Reference in New Issue
Block a user