Merge branch 'check/pu-cc' into master

...needs some build- and logical fixing...

Conflicts:
	data/locale/deutsch.locale
	data/locale/english.locale
	src/driver/volume.cpp
	src/gui/eventlist.cpp
	src/gui/moviebrowser.cpp
	src/gui/scan.cpp
	src/gui/timeosd.cpp
	src/gui/widget/progressbar.cpp
	src/gui/widget/progressbar.h
This commit is contained in:
Stefan Seyfried
2013-04-06 14:28:16 +02:00
42 changed files with 861 additions and 738 deletions

View File

@@ -32,6 +32,7 @@ libneutrino_gui_components_a_SOURCES = \
cc_item_box.cpp \
cc_item_infobox.cpp \
cc_item_picture.cpp \
cc_item_progressbar.cpp \
cc_item_shapes.cpp \
cc_item_text.cpp \
cc_item_tvpig.cpp
cc_item_tvpic.cpp

View File

@@ -45,8 +45,9 @@ class CComponents
bool firstPaint, shadow, is_painted, paint_bg;
void initVarBasic();
bool allowPaint(int i);
void paintFbItems(bool do_save_bg = true);
fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
virtual fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
comp_screen_data_t saved_screen;
void clearSavedScreen();
@@ -103,23 +104,6 @@ class CComponentsItem : public CComponents
void initVarItem();
public:
enum
{
CC_ITEMTYPE_BASE,
CC_ITEMTYPE_PICTURE,
CC_ITEMTYPE_TEXT,
CC_ITEMTYPE_TEXT_INFOBOX,
CC_ITEMTYPE_SHAPE_SQUARE,
CC_ITEMTYPE_SHAPE_CIRCLE,
CC_ITEMTYPE_PIP,
CC_ITEMTYPE_FRM,
CC_ITEMTYPE_FRM_HEADER,
CC_ITEMTYPE_FRM_ICONFORM,
CC_ITEMTYPE_FRM_WINDOW,
CC_ITEMTYPE_LABEL,
CC_ITEMTYPES
};
CComponentsItem();
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
@@ -178,7 +162,7 @@ class CComponentsText : public CComponentsItem
fb_pixel_t ct_col_text;
int ct_text_mode; //see textbox.h for possible modes
const char* ct_text;
bool ct_text_sent;
bool ct_text_sent, ct_paint_textbg;
void initVarText();
void clearCCText();
@@ -198,6 +182,7 @@ class CComponentsText : public CComponentsItem
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};//see textbox.h for possible modes
virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;};
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);

View File

@@ -42,7 +42,7 @@ CComponents::CComponents()
CComponents::~CComponents()
{
hide();
hide();
clearSavedScreen();
clear();
}
@@ -78,6 +78,24 @@ void CComponents::initVarBasic()
saved_screen.pixbuf = NULL;
}
bool CComponents::allowPaint(int i)
{
if(v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BOX)
return true;
if (v_fbdata[CC_FBDATA_TYPE_BOX].x != v_fbdata[i].x)
return true;
else if (v_fbdata[CC_FBDATA_TYPE_BOX].y != v_fbdata[i].y)
return true;
else if (v_fbdata[CC_FBDATA_TYPE_BOX].dx != v_fbdata[i].dx)
return true;
else if (v_fbdata[CC_FBDATA_TYPE_BOX].dy != v_fbdata[i].dy)
return true;
return false;
}
//paint framebuffer stuff and fill buffer
void CComponents::paintFbItems(bool do_save_bg)
{
@@ -120,7 +138,7 @@ void CComponents::paintFbItems(bool do_save_bg)
frameBuffer->paintBoxFrame(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].frame_thickness, v_fbdata[i].color, v_fbdata[i].r);
else if (fbtype == CC_FBDATA_TYPE_BACKGROUND)
frameBuffer->paintBackgroundBoxRel(x, y, v_fbdata[i].dx, v_fbdata[i].dy);
else
else if( allowPaint(i) )
frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].color, v_fbdata[i].r, corner_type);
}
}

View File

@@ -285,7 +285,7 @@ void CComponentsForm::hide(bool no_restore)
// because the handling of minitv items are different to other item types
// and need an explizit call of hide()
for(size_t i=0; i<v_cc_items.size(); i++) {
if (v_cc_items[i]->getItemType() == CComponentsItem::CC_ITEMTYPE_PIP){
if (v_cc_items[i]->getItemType() == CC_ITEMTYPE_PIP){
v_cc_items[i]->hide();
break;
}

View File

@@ -91,9 +91,16 @@ void CComponentsInfoBox::initVarInfobox()
void CComponentsInfoBox::paintPicture()
{
//init and set icon paint position
//ensure empty pic object
if (pic)
delete pic;
pic = NULL;
//exit if no image definied
if (pic_name == "")
return;
//init pic object and set icon paint position
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness/*+y_offset*/, 0, 0, "");
//define icon
@@ -115,7 +122,7 @@ void CComponentsInfoBox::paint(bool do_save_bg)
x_text = x+fr_thickness+x_offset;
//set text to the left border if picture is not painted
if (pic->isPicPainted()){
if ((pic) && (pic->isPicPainted())){
int pic_w = pic->getWidth();
x_text += pic_w+x_offset;
}
@@ -127,6 +134,7 @@ void CComponentsInfoBox::paint(bool do_save_bg)
cctext = new CComponentsText();
cctext->setText(ct_text, ct_text_mode, ct_font);
cctext->doPaintTextBoxBg(false);
cctext->setDimensionsAll(x_text, y+fr_thickness, width-(x_text-x+x_offset+fr_thickness), height-2*fr_thickness);
cctext->paint(CC_SAVE_SCREEN_NO);
}

View File

@@ -105,6 +105,9 @@ void CComponentsPicture::initVarPicture()
pic_painted = false;
do_paint = false;
if (pic_name == "")
return;
if (pic_max_w == 0)
pic_max_w = width-2*fr_thickness;

View File

@@ -0,0 +1,272 @@
/*
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
(C) 2008, 2013 by Thilo Graf
(C) 2009,2010,2013 Stefan Seyfried
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <global.h>
#include <neutrino.h>
#include "cc_item_progressbar.h"
#define ITEMW 4
#define POINT 2
#define RED 0xFF0000
#define GREEN 0x00FF00
#define YELLOW 0xFFFF00
CProgressBar::CProgressBar()
{
initVarProgressbar();
}
CProgressBar::CProgressBar( const int x_pos, const int y_pos, const int w, const int h,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow,
const fb_pixel_t active_col, const fb_pixel_t passive_col,
const bool blinkenlights,
const int r, const int g, const int b,
const bool inv)
{
initVarProgressbar();
//CComponents
x = x_pos;
y = y_pos;
width = w;
height = h;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
pb_blink = blinkenlights;
pb_invert = inv;
pb_red = r;
pb_green = g;
pb_yellow = b;
pb_active_col = active_col;
pb_passive_col = passive_col;
}
void CProgressBar::initVarProgressbar()
{
//CComponentsItem
initVarItem();
cc_item_type = CC_ITEMTYPE_PROGRESSBAR;
//CProgressBar
pb_blink = false;
pb_invert = false;
pb_bl_changed = g_settings.progressbar_color;
pb_last_width = -1;
pb_red = 40;
pb_green = 100;
pb_yellow = 70;
pb_active_col = COL_INFOBAR_PLUS_7;
pb_passive_col = COL_INFOBAR_PLUS_3;
pb_value = 0;
pb_max_value = 0;
pb_paint_zero = false;
// init start positions x/y active bar
pb_x = x + fr_thickness;
pb_y = y + fr_thickness;
pb_active_width = 0;
pb_max_width = width - 2*fr_thickness;
pb_height = 0;
pb_start_x_passive = 0;
pb_passive_width = width;
}
//calculate bar dimensions
void CProgressBar::initDimensions()
{
//prevent stupid callers, can give invalid values like "-1"...
if (pb_value < 0)
pb_value = 0;
if (pb_value > pb_max_value)
pb_max_value = pb_value;
// start positions x/y active bar
pb_x = x + fr_thickness;
pb_y = y + fr_thickness;
// width for active bar with current value
pb_active_width = max(0, pb_last_width);
if (pb_max_value)
pb_active_width = (width - 2*fr_thickness) * pb_value / pb_max_value;
// max width active/passive bar
pb_max_width = width - 2*fr_thickness;
// max height of active/passive bar
pb_height = height - 2*fr_thickness;
pb_start_x_passive = pb_x + pb_active_width;
pb_passive_width = pb_max_width - pb_active_width;
// background = frame
if ( col_frame == 0 )
col_frame = pb_active_col;
}
void CProgressBar::paintSimple()
{
// progress value
if (pb_active_width != pb_last_width){
frameBuffer->paintBoxRel(pb_x, pb_y, pb_active_width, pb_height, pb_active_col); // active bar
frameBuffer->paintBoxRel(pb_start_x_passive, pb_y, pb_passive_width, pb_height, pb_passive_col); // passive bar
}
if (pb_paint_zero && pb_value == 0)
frameBuffer->paintLine(x+fr_thickness , y+fr_thickness, x+width-3, y+height-3, pb_active_col); // zero line
}
void CProgressBar::paintAdvanced()
{
int itemw = ITEMW, itemh = ITEMW, pointx = POINT, pointy = POINT;
if(g_settings.progressbar_color){
switch ((pb_color_t)g_settings.progressbar_design){
default:
case PB_MATRIX: // ::::: matrix
break;
case PB_LINES_V: // ||||| vert. lines
itemh = pb_height;
pointy = pb_height;
break;
case PB_LINES_H: // ===== horiz. lines
itemw = POINT;
break;
case PB_COLOR: // filled color
itemw = POINT;
itemh = pb_height;
pointy = pb_height;
break;
}
}
const int spc = itemh - pointy; /* space between horizontal lines / points */
int hcnt = (pb_height + spc) / itemh; /* how many POINTs is the bar high */
int yoff = (pb_height + spc - itemh * hcnt) / 2;
//printf("height: %d itemh: %d hcnt: %d yoff: %d spc: %d\n", height, itemh, hcnt, yoff, spc);
/* red, yellow, green are given in percent */
int rd = pb_red * pb_max_width / (100 * itemw); /* how many POINTs red */
int yw = pb_yellow * pb_max_width / (100 * itemw); /* how many POINTs yellow */
int gn = pb_green * pb_max_width / (100 * itemw); /* how many POINTs green */
int maxi = pb_active_width / itemw; /* how many POINTs is the active bar */
int total = pb_max_width / itemw; /* total number of POINTs */
uint32_t rgb;
fb_pixel_t color;
if (pb_active_width != pb_last_width) {
int i, j;
const int py = pb_y + yoff;
if (pb_active_width > pb_last_width) {
int step, off;
int b = 0;
uint8_t diff = 0;
for (i = 0; (i < rd) && (i < maxi); i++) {
diff = i * 255 / rd;
if (pb_invert)
rgb = GREEN + (diff << 16); // adding red
else
rgb = RED + (diff << 8); // adding green
color = make16color(rgb);
for (j = 0; j < hcnt; j++)
frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color);
}
step = yw - rd - 1;
if (step < 1)
step = 1;
for (; (i < yw) && (i < maxi); i++) {
diff = b++ * 255 / step / 2;
if (pb_invert)
rgb = YELLOW - (diff << 8); // removing green
else
rgb = YELLOW - (diff << 16); // removing red
color = make16color(rgb);
for (j = 0; j < hcnt; j++)
frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color);
}
off = diff;
b = 0;
step = gn - yw - 1;
if (step < 1)
step = 1;
for (; (i < gn) && (i < maxi); i++) {
diff = b++ * 255 / step / 2 + off;
if (pb_invert)
rgb = YELLOW - (diff << 8); // removing green
else
rgb = YELLOW - (diff << 16); // removing red
color = make16color(rgb);
for (j = 0; j < hcnt; j++)
frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color);
}
}
for(i = maxi; i < total; i++) {
for (j = 0; j < hcnt; j++)
frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, pb_passive_col); //fill passive
}
}
}
void CProgressBar::paintProgress(bool do_save_bg)
{
if(pb_bl_changed != g_settings.progressbar_color) {
pb_bl_changed = g_settings.progressbar_color;
reset();
}
initDimensions();
//body
if (pb_last_width == -1 && col_body != 0) /* first paint */
paintInit(do_save_bg);
//progress
if (!pb_blink || !g_settings.progressbar_color)
paintSimple();
else
paintAdvanced();
if (is_painted)
pb_last_width = pb_active_width;
}
void CProgressBar::paint(bool do_save_bg)
{
paintProgress(do_save_bg);
}

View File

@@ -0,0 +1,162 @@
/*
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
(C) 2008, 2013 by Thilo Graf
(C) 2009,2010,2013 Stefan Seyfried
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
///
/*!
description of parameters:
position of progressbar:
x_pos > start position on screen x
y_pos > start position on screen y
pb_width > with of progressbar
pb_height > height of progressbar
definitions of values:
value > value, you will display
max_value > maximal value that you will display
appearance:
activebar_col > color of inner bar that shows the current value
passivebar_col > color of passive bar
frame_col > general frame color of progressbar, set 0 for no frame
shadowbar_col color > shadow behind progressbar, set 0 for no shadow
paintZero > optional, if set to true and value = 0, then paints a diagonal line instead of active bar as symbolic for a zero value
*/
#ifndef __CC_PROGRESSBAR_H__
#define __CC_PROGRESSBAR_H__
#include "config.h"
#include <gui/components/cc.h>
#include <string>
class CProgressBar : public CComponentsItem
{
protected:
void initVarProgressbar();
private:
///colors of active and passive bar area, active means the displayed value, passive the neutral area
fb_pixel_t pb_active_col, pb_passive_col;
int pb_last_width;
///width of progress
int pb_active_width, pb_passive_width;
///maximal width,heigth of progress
int pb_max_width, pb_height;
///start position of bars
int pb_start_x_passive;
///color values
int pb_red, pb_green, pb_yellow;
///start position of activ/passiv area
int pb_x, pb_y;
bool pb_blink, pb_invert, pb_bl_changed;
///causes a diagonal line as a sign for 0 value instead of an empty bar
bool pb_paint_zero;
///to evaluate values, these will be convert to the graph
int pb_value, pb_max_value;
///paint simple version of progressbar with simple color modifications
void paintSimple();
///paint version of progressbar with color and advanced display modifications
void paintAdvanced();
void initDimensions();
///paints graph
void paintProgress(bool do_save_bg = CC_SAVE_SCREEN_NO);
static inline unsigned int make16color(__u32 rgb){return 0xFF000000 | rgb;};
public:
///parameters:
///x_pos, y_pos, w, h: position and dimension in pixel
///blinkenlights: true if you want code to follow progressbar_color. needed, no default.
///w, h: width / height of bar. Can later be set with paintProgressbar.
///r, g, b: percentage of the bar where red/green/yellow is used, only used if blinkenlights (colored) == true.
///inv: false => red on the left side, true: red on right side.
///active_col, passive_col: sets colors for displayed values, activ_col means the the displayed progress
///color_frame, color_body, color_shadow: colores of progressbar for frame, body and shadow, Note: color of frame is ineffective on fr_thickness = 0
CProgressBar();
CProgressBar( const int x_pos, const int y_pos,
const int w = -1, const int h = -1,
fb_pixel_t color_frame = 0, fb_pixel_t color_body = COL_INFOBAR_PLUS_3, fb_pixel_t color_shadow = COL_INFOBAR_PLUS_7,
const fb_pixel_t active_col = COL_INFOBAR_PLUS_7, const fb_pixel_t passive_col = COL_INFOBAR_PLUS_3,
const bool blinkenlights = false,
const int r = 40, const int g = 100, const int b =70,
const bool inv = false );
///set up to display available values
void setValue(const int val){ pb_value = val;};
void setMaxValue(const int max_val){pb_max_value = max_val;};
///set up booth values to display at once
void setValues(const int val, const int max_val){pb_value = val; pb_max_value = max_val;};
///causes painting a diagonal line if value = 0, Note: ineffective in colored mode
void setZeroLine(bool paint_zero_line = true){pb_paint_zero = paint_zero_line;};
///setters for status colors
void setActiveColor(fb_pixel_t active_color) {pb_active_col = active_color;};
void setPassiveColor(fb_pixel_t passive_color) {pb_passive_col = passive_color;};
///set up booth status colors at once
void setStatusColors(fb_pixel_t active_color, fb_pixel_t passive_color) {pb_passive_col = passive_color; pb_active_col = active_color;};
///invert: false => red on the left side, true: red on right side.
void setInvert(bool inverted = true){pb_invert = inverted;};
///blinkenlights: true (default) if you want code to follow progressbar_color.
void setBlink(bool blinkenlights = true){pb_blink = blinkenlights;};
///r, g, b: percentage of the bar where red/green/yellow is used, only used if blinkenlights (colored) == true.
void setRgb(const int r, const int g, const int b){pb_red = r; pb_green = g; pb_yellow = b;};
///x, y, width, height, value, max_value: set most wanted parameters at once
void setProgress(const int x_pos, const int y_pos,
const int w, const int h,
const int val, const int max_val){x=x_pos; y=y_pos; width=w; height=h; pb_value=val; pb_max_value=max_val;};
///force update on next paint
void reset() { pb_last_width = -1; }
void paint(bool do_save_bg = CC_SAVE_SCREEN_NO);
enum pb_color_t {
PB_MATRIX = 0, /* 0 */
PB_LINES_V, /* 1 */
PB_LINES_H, /* 2 */
PB_COLOR /* 3 */
};
};
#endif /* __CC_PROGRESSBAR_H__ */

View File

@@ -91,6 +91,7 @@ void CComponentsText::initVarText()
ct_text_mode = CTextBox::AUTO_WIDTH;
ct_col_text = COL_MENUCONTENT;
ct_text_sent = false;
ct_paint_textbg = true;
}
@@ -124,7 +125,7 @@ void CComponentsText::initCCText()
ct_textbox->setTextMode(ct_text_mode);
ct_textbox->setWindowPos(ct_box);
ct_textbox->setTextBorderWidth(0);
ct_textbox->enableBackgroundPaint(false);
ct_textbox->enableBackgroundPaint(ct_paint_textbg);
ct_textbox->setBackGroundColor(col_body);
ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type);
ct_textbox->setTextColor(ct_col_text);

View File

@@ -29,6 +29,26 @@
#include <driver/framebuffer.h>
#include <system/localize.h>
///cc item types
typedef enum
{
CC_ITEMTYPE_BASE,
CC_ITEMTYPE_PICTURE,
CC_ITEMTYPE_TEXT,
CC_ITEMTYPE_TEXT_INFOBOX,
CC_ITEMTYPE_SHAPE_SQUARE,
CC_ITEMTYPE_SHAPE_CIRCLE,
CC_ITEMTYPE_PIP,
CC_ITEMTYPE_FRM,
CC_ITEMTYPE_FRM_HEADER,
CC_ITEMTYPE_FRM_ICONFORM,
CC_ITEMTYPE_FRM_WINDOW,
CC_ITEMTYPE_LABEL,
CC_ITEMTYPE_PROGRESSBAR,
CC_ITEMTYPES
}CC_ITEMTYPES_T;
//required typedefs
typedef struct comp_fbdata_t
{