CComponentsPicture: structure of class highly simplified

It should  be now easier to use images as objects. An initialized
picture object should provide all relevant properties and some
functionalities of picture viewer.
This commit is contained in:
2014-06-20 17:20:15 +02:00
committed by svenhoefer
parent 8bbd7024d9
commit 5eb63b9515
12 changed files with 190 additions and 196 deletions

View File

@@ -34,7 +34,7 @@
#include <gui/volumebar.h>
#include <gui/audiomute.h>
CAudioMute::CAudioMute():CComponentsPicture(0, 0, 0, 0, NEUTRINO_ICON_BUTTON_MUTE)
CAudioMute::CAudioMute():CComponentsPicture(0, 0, NEUTRINO_ICON_BUTTON_MUTE)
{
y_old = -1;
paint_bg = false;

View File

@@ -108,7 +108,7 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const
cc_item_selected = selected;
fr_thickness = 3;
append_x_offset = 6;
append_y_offset = append_x_offset;
append_y_offset = 0;
corner_rad = RADIUS_MID;
cc_btn_capt_col = COL_MENUCONTENT_TEXT;
@@ -139,15 +139,16 @@ void CComponentsButton::initIcon()
int h_icon = 0;
frameBuffer->getIconSize(cc_btn_icon.c_str(), &w_icon, &h_icon);
int h_max = height-2*fr_thickness;
if (h_icon > h_max){
int ratio = h_icon/h_max;
cc_btn_icon = frameBuffer->getIconBasePath() + cc_btn_icon;
cc_btn_icon += ".png";
w_icon = w_icon*ratio;
}
h_icon = min(height-2*fr_thickness, h_icon);
// if (h_icon != h_max){
// int ratio = h_icon/h_max;
// cc_btn_icon = frameBuffer->getIconBasePath() + cc_btn_icon;
// cc_btn_icon += ".png";
// w_icon = w_icon*ratio;
// }
cc_btn_icon_obj = new CComponentsPicture(fr_thickness, CC_CENTERED, w_icon, h_max, cc_btn_icon, CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, this);
int y_icon = height/2 - h_icon/2;
cc_btn_icon_obj = new CComponentsPicture(fr_thickness, y_icon, w_icon, h_icon, cc_btn_icon, this);
cc_btn_icon_obj->doPaintBg(false);
}
}
@@ -183,7 +184,7 @@ void CComponentsButton::initCaption()
but text render isn't wrong here, because capitalized chars or long chars like e. 'q', 'y' are considered!
Therefore we here need other icons or a hack, that considers some different height values.
*/
int y_cap = 0;
int y_cap = height/2 - h_cap/2 - fr_thickness;
cc_btn_capt_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap);

View File

@@ -109,7 +109,7 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
cch_btn_obj = NULL;
cch_col_text = COL_MENUHEAD_TEXT;
cch_caption_align = CTextBox::NO_AUTO_LINEBREAK;
cch_items_y = 0;
cch_items_y = CC_CENTERED;
cch_offset = 8;
cch_icon_x = cch_offset;
cch_icon_w = 0;
@@ -195,7 +195,7 @@ void CComponentsHeader::initIcon()
//create instance for cch_icon_obj and add to container at once
if (cch_icon_obj == NULL){
dprintf(DEBUG_DEBUG, "[CComponentsHeader]\n [%s - %d] init header icon: %s\n", __func__, __LINE__, cch_icon_name.c_str());
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name, CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, this);
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name, this);
}
//set properties for icon object
@@ -203,7 +203,8 @@ void CComponentsHeader::initIcon()
//get dimensions of header icon
int iw = 0;
int ih = 0;
cch_icon_obj->getPictureSize(&iw, &ih);
cch_icon_obj->getImageSize(&iw, &ih);
dprintf(DEBUG_INFO, "[CComponentsHeader]\n [%s - %d] init icon size: iw = %d, ih = %d\n", __func__, __LINE__, iw, ih);
cch_icon_obj->setWidth(iw);
cch_icon_obj->setHeight(ih);
cch_icon_obj->doPaintBg(false);
@@ -222,8 +223,8 @@ void CComponentsHeader::initIcon()
//global adapt height
height = max(height, cch_icon_obj->getHeight());
//re-align height of icon object
cch_icon_obj->setHeight(height);
// //re-align height of icon object
// cch_icon_obj->setHeight(height);
}
}

View File

@@ -80,7 +80,6 @@ void CComponentsIconForm::addIcon(const std::string& icon_name)
chn_direction == CC_DIR_Y ? CC_APPEND : CC_CENTERED,
0, 0,
icon_name,
CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER,
this);
ccp->doPaintBg(false);
@@ -99,8 +98,7 @@ void CComponentsIconForm::insertIcon(const uint& icon_id, const std::string& ico
CComponentsPicture *ccp = new CComponentsPicture(chn_direction == CC_DIR_X ? CC_APPEND : CC_CENTERED,
chn_direction == CC_DIR_Y ? CC_APPEND : CC_CENTERED,
0, 0,
icon_name,
CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
icon_name);
ccp->doPaintBg(false);
insertCCItem(icon_id, ccp);

View File

@@ -110,7 +110,6 @@ void CComponentsSlider::initCCSlBody()
if (csl_body_obj){
csl_body_obj->setDimensionsAll(icon_x, icon_y, icon_w, icon_h);
csl_body_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
}
}

View File

@@ -98,7 +98,7 @@ void CComponentsInfoBox::paintPicture()
return;
//init pic object and set icon paint position
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, 0, 0, "");
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, "");
//define icon
pic->setPicture(pic_name);

View File

@@ -33,7 +33,7 @@
#include "cc_item_picture.h"
#include <unistd.h>
#include <system/debug.h>
extern CPictureViewer * g_PicViewer;
using namespace std;
@@ -41,18 +41,25 @@ using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsPicture from CComponentsItem
CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& image_name,
const int &alignment,
const std::string& image_path,
CComponentsForm *parent,
bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
{
init(x_pos, y_pos, w, h, image_name, alignment, parent, has_shadow, color_frame, color_background, color_shadow);
init(x_pos, y_pos, w, h, image_path, parent, has_shadow, color_frame, color_background, color_shadow);
}
CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos,
const std::string& image_name,
CComponentsForm *parent,
bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
{
init(x_pos, y_pos, 0, 0, image_name, parent, has_shadow, color_frame, color_background, color_shadow);
}
void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w, const int &h,
const string& image_name,
const int &alignment,
CComponentsForm *parent,
bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
@@ -61,8 +68,8 @@ void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w,
cc_item_type = CC_ITEMTYPE_PICTURE;
//CComponents
x = pic_x = x_pos;
y = pic_y = y_pos;
x = x_pos;
y = y_pos;
height = h;
width = w;
shadow = has_shadow;
@@ -72,19 +79,14 @@ void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w,
col_shadow = color_shadow;
//CComponentsPicture
pic_paint_mode = CC_PIC_IMAGE_MODE_AUTO,
pic_name = image_name;
pic_align = alignment;
pic_offset = 1;
pic_paint = true;
pic_paintBg = false;
pic_painted = false;
do_paint = false;
pic_max_w = 0;
pic_max_h = 0;
if (pic_name.empty())
pic_width = pic_height = 0;
is_icon = false;
is_image_painted= false;
do_paint = true;
getSupportedImageFormats(v_ext);
v_ext.resize(unique(v_ext.begin(), v_ext.end()) - v_ext.begin());
initCCItem();
initParent(parent);
}
@@ -103,111 +105,87 @@ void CComponentsPicture::setPicture(const char* picture_name)
setPicture(s_tmp);
}
void CComponentsPicture::setPictureAlign(const int alignment)
{
pic_align = alignment;
initCCItem();
}
void CComponentsPicture::initCCItem()
{
pic_width = pic_height = 0;
pic_painted = false;
do_paint = false;
//handle size
int w_pic = width;
int h_pic = height;
if (pic_name == "")
if (pic_name.empty())
return;
if (pic_max_w == 0)
pic_max_w = width-2*fr_thickness;
//check for path or name, set icon or image with full path
string::size_type pos = pic_name.find("/", 0);
is_icon = (pos == string::npos);
if (pic_max_h == 0)
pic_max_h = height-2*fr_thickness;
dprintf(DEBUG_INFO, "[CComponentsPicture] %s: detected image file: is_icon: %d (pos= %d), pic_name=%s\n", __func__, is_icon, pos, pic_name.c_str());
//set the image mode depends of name syntax, icon names contains no path,
//so we can detect the required image mode
if (pic_paint_mode == CC_PIC_IMAGE_MODE_AUTO){
if (!access(pic_name.c_str(), F_OK ))
pic_paint_mode = CC_PIC_IMAGE_MODE_ON;
else
pic_paint_mode = CC_PIC_IMAGE_MODE_OFF;
//get current image size
getImageSize(&w_pic, &h_pic);
//for icons (names without explicit path) set dimensions of "this" to current image...//TODO: centering image/icon
if (is_icon){
width = w_pic;
height = max(h_pic, height);
}
else{ //defined values in constructor or defined via setters defined, have priority, value 0 is not allowed
if (width == 0)
width = w_pic;
if (height == 0)
height = h_pic;
}
if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF){
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
#if 0
pic_width = max(pic_width, pic_max_w);
pic_height = max(pic_height, pic_max_h);
#endif
//resize/scale image if required, if no icon mode detected, use real image size
if (!is_icon){
if (width != w_pic || height != h_pic)
rescaleImageDimensions(&w_pic, &h_pic, width, height);
}
}
if (pic_paint_mode == CC_PIC_IMAGE_MODE_ON) {
g_PicViewer->getSize(pic_name.c_str(), &pic_width, &pic_height);
if((pic_width > pic_max_w) || (pic_height > pic_max_h))
g_PicViewer->rescaleImageDimensions(&pic_width, &pic_height, pic_max_w, pic_max_h);
}
if (pic_width == 0 || pic_height == 0)
dprintf(DEBUG_DEBUG, "[CComponentsPicture] %s file: %s, no icon dimensions found! width = %d, height = %d\n", __func__, pic_name.c_str(), pic_width, pic_height);
initPosition();
int sw = (shadow ? shadow_w :0);
width = max(max(pic_width, pic_max_w), width) + sw ;
height = max(max(pic_height, pic_max_h), height) + sw ;
dprintf(DEBUG_DEBUG, "[CComponentsPicture] %s initialized Image: ====>> %s\n\titem x = %d\n\tdx = %d (image dx = %d)\n\titem y = %d\n\titem dy = %d (image dy = %d)\n",
__func__, pic_name.c_str(), x, width, pic_width, y, height, pic_height);
}
void CComponentsPicture::initPosition()
void CComponentsPicture::initPosition(int *x_position, int *y_position)
{
//using of real x/y values to paint images if this picture object is bound in a parent form
int px = pic_x = x, py = pic_y = y;
*x_position = x;
*y_position = y;
if (cc_parent){
px = cc_xr;
py = cc_yr;
*x_position = cc_xr;
*y_position = cc_yr;
}
}
if (pic_height>0 && pic_width>0){
if (pic_align & CC_ALIGN_LEFT)
pic_x = px+fr_thickness;
if (pic_align & CC_ALIGN_RIGHT)
pic_x = px+width-pic_width-fr_thickness;
if (pic_align & CC_ALIGN_TOP)
pic_y = py+fr_thickness;
if (pic_align & CC_ALIGN_BOTTOM)
pic_y = py+height-pic_height-fr_thickness;
if (pic_align & CC_ALIGN_HOR_CENTER)
pic_x = px+width/2-pic_width/2;
if (pic_align & CC_ALIGN_VER_CENTER)
pic_y = py+height/2-pic_height/2;
do_paint = true;
}
void CComponentsPicture::getImageSize(int* width_image, int *height_image)
{
if (!is_icon)
CPictureViewer::getSize(pic_name.c_str(), width_image, height_image);
else
frameBuffer->getIconSize(pic_name.c_str(), width_image, height_image);
}
void CComponentsPicture::paintPicture()
{
pic_painted = false;
is_image_painted = false;
//initialize image position
int x_pic = x;
int y_pic = y;
initPosition(&x_pic, &y_pic);
if (do_paint && cc_allow_paint){
dprintf(DEBUG_DEBUG, "[CComponentsPicture] %s: paint image: %s (do_paint=%d) with mode %d\n", __func__, pic_name.c_str(), do_paint, pic_paint_mode);
if (pic_name.empty())
return;
if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF)
pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0 /*pic_max_h*/, pic_offset, pic_paint, pic_paintBg, col_body);
else if (pic_paint_mode == CC_PIC_IMAGE_MODE_ON)
pic_painted = g_PicViewer->DisplayImage(pic_name, pic_x, pic_y, pic_width, pic_height);
dprintf(DEBUG_INFO, "[CComponentsPicture] %s: paint image file: pic_name=%s\n", __func__, pic_name.c_str());
if (cc_allow_paint){
if (!is_icon)
is_image_painted = DisplayImage(pic_name, x_pic, y_pic, width, height);
else
is_image_painted = frameBuffer->paintIcon(pic_name, x_pic, y_pic, height, 1, do_paint, paint_bg, col_body);
}
if (pic_painted)
do_paint = false;
}
void CComponentsPicture::paint(bool do_save_bg)
{
initCCItem();
paintInit(do_save_bg);
paintPicture();
}
@@ -215,69 +193,65 @@ void CComponentsPicture::paint(bool do_save_bg)
void CComponentsPicture::hide(bool no_restore)
{
hideCCItem(no_restore);
pic_painted = false;
is_image_painted = false;
}
CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_pos, const int &w, const int &h,
const uint64_t& channelId,
const std::string& channelName,
const int &alignment,
const uint64_t& channelId,
CComponentsForm *parent,
bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
:CComponentsPicture(x_pos, y_pos, w, h,
"", alignment, parent, has_shadow,
"", parent, has_shadow,
color_frame, color_background, color_shadow)
{
channel_id = channelId;
channel_name = channelName;
initVarPictureChannellLogo();
setChannel(channelId, channelName);
alt_pic_name = "";
}
void CComponentsChannelLogo::setPicture(const std::string& picture_name)
CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_pos,
const std::string& channelName,
const uint64_t& channelId,
CComponentsForm *parent,
bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
:CComponentsPicture(x_pos, y_pos, 0, 0,
"", parent, has_shadow,
color_frame, color_background, color_shadow)
{
pic_name = picture_name;
setChannel(channelId, channelName);
alt_pic_name = "";
}
void CComponentsChannelLogo::setAltLogo(const std::string& picture_name)
{
alt_pic_name = picture_name;
channel_id = 0;
channel_name = "";
initVarPictureChannellLogo();
has_logo = true;
initCCItem();
}
void CComponentsChannelLogo::setPicture(const char* picture_name)
void CComponentsChannelLogo::setAltLogo(const char* picture_name)
{
string s_tmp = "";
if (picture_name)
s_tmp = string(picture_name);
this->setPicture(s_tmp);
this->setAltLogo(s_tmp);
}
void CComponentsChannelLogo::setChannel(const uint64_t& channelId, const std::string& channelName)
{
channel_id = channelId;
channel_name = channelName;
initVarPictureChannellLogo();
}
void CComponentsChannelLogo::initVarPictureChannellLogo()
{
string tmp_logo = pic_name;
has_logo = false;
if (!(channel_id == 0 && channel_name.empty() && pic_name.empty()))
has_logo = GetLogoName(channel_id, channel_name, pic_name, &pic_width, &pic_height);
has_logo = GetLogoName(channel_id, channel_name, pic_name, &width, &height);
if (!has_logo)
pic_name = tmp_logo;
dprintf(DEBUG_DEBUG, "\t[CComponentsChannelLogo] %s: init image: %s (has_logo=%d, channel_id=%" PRIu64 ")\n", __func__, pic_name.c_str(), has_logo, channel_id);
pic_name = alt_pic_name;
initCCItem();
}
void CComponentsChannelLogo::paint(bool do_save_bg)
{
initVarPictureChannellLogo();
paintInit(do_save_bg);
paintPicture();
has_logo = false; //reset
}

View File

@@ -37,32 +37,27 @@
//! Sub class of CComponentsItem. Shows box with image with assigned attributes.
/*!
Picture is usable like each other CCItems.
Picture is usable as an object like each other CCItems.
*/
class CComponentsPicture : public CComponentsItem
class CComponentsPicture : public CComponentsItem, public CPictureViewer
{
protected:
///some internal modes for icon and image handling
enum
{
CC_PIC_IMAGE_MODE_OFF = 0, //paint pictures in icon mode, mainly not scaled
CC_PIC_IMAGE_MODE_ON = 1, //paint pictures in image mode, paint scaled if required
CC_PIC_IMAGE_MODE_AUTO = 2
};
///possible image formats
std::vector<std::string> v_ext;
///property: path or name of image, icon names to find in /widget/icons.h, icons will paint never scaled
///property: name of image (without extensionn) full path to image (with extension), icon names to find in /widget/icons.h, icons will paint never scaled
std::string pic_name;
///property: interface to CFrameBuffer::paintIcon() arg 5
unsigned char pic_offset;
bool pic_paint, pic_paintBg, pic_painted, do_paint;
int pic_align, pic_x, pic_y, pic_width, pic_height;
int pic_max_w, pic_max_h, pic_paint_mode;
///indicate that image was sucessful painted
bool is_image_painted;
///image is defined only by name without full path, handling as icon, not as scalable image, default = false
bool is_icon;
///sets that image may be painted, default = false
bool do_paint;
void init( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& image_name,
const int &alignment,
CComponentsForm *parent,
bool has_shadow,
fb_pixel_t color_frame,
@@ -72,63 +67,88 @@ class CComponentsPicture : public CComponentsItem
///initialize all required attributes
void initCCItem();
///initialize position of picture object dependendly from settings
void initPosition();
void initPosition(int *x_position, int *y_position);
///paint image
void paintPicture();
public:
CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& image_name,
const int &alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER,
CComponentsForm *parent = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_background = 0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
virtual inline void setPictureOffset(const unsigned char offset){pic_offset = offset;};
virtual inline void setPicturePaint(bool paint_p){pic_paint = paint_p;};
virtual inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;};
CComponentsPicture( const int &x_pos, const int &y_pos,
const std::string& image_name,
CComponentsForm *parent = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_background = 0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///sets an image name (unscaled icons only), full image path or url to an iamge file (scalable)
virtual void setPicture(const std::string& picture_name);
///sets an image name (unscaled icons only), full image path or url to an iamge file (scalable)
virtual void setPicture(const char* picture_name);
virtual void setPictureAlign(const int alignment);
///return paint mode of internal image, true=image was painted, please do not to confuse with isPainted()! isPainted() is related to item itself.
virtual inline bool isPicPainted(){return pic_painted;};
virtual inline bool isPicPainted(){return is_image_painted;};
///handle image size
void getImageSize(int* width_image, int *height_image);
///paint item
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///hide item
virtual void hide(bool no_restore = false);
virtual inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;};
virtual void setMaxWidth(const int w_max){pic_max_w = w_max;};
virtual void setMaxHeight(const int h_max){pic_max_h = h_max;};
};
class CComponentsChannelLogo : public CComponentsPicture, CPictureViewer
class CComponentsChannelLogo : public CComponentsPicture
{
protected:
///initialize all required attributes
void initVarPictureChannellLogo();
private:
///channel id
uint64_t channel_id;
///channel name
std::string channel_name;
///alternate image file, if no channel logo is available
std::string alt_pic_name;
///indicates that logo is available, after paint or new instance, value = false
bool has_logo;
public:
CComponentsChannelLogo( const int &x_pos, const int &y_pos, const int &w, const int &h,
const uint64_t& channelId =0,
const std::string& channelName = "",
const int &alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER,
const uint64_t& channelId =0,
CComponentsForm *parent = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_background = 0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
CComponentsChannelLogo( const int &x_pos, const int &y_pos,
const std::string& channelName = "",
const uint64_t& channelId =0,
CComponentsForm *parent = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_background = 0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///set channel id and/or channel name, NOTE: channel name is prefered
void setChannel(const uint64_t& channelId, const std::string& channelName);
void setPicture(const std::string& picture_name);
void setPicture(const char* picture_name);
///set an alternate logo if no logo is available NOTE: value of has_logo will set to true
void setAltLogo(const std::string& picture_name);
///set an alternate logo if no logo is available, NOTE: value of has_logo will set to true
void setAltLogo(const char* picture_name);
///returns true, if any logo is available, also if an alternate logo was setted
bool hasLogo(){return has_logo;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
#endif

View File

@@ -99,7 +99,7 @@ void CComponentsPIP::paint(bool do_save_bg)
videoDecoder->Pig(pig_x, pig_y, pig_w, pig_h, screen_w, screen_h);
}
else{ //paint an alternate image if no tv mode available
CComponentsPicture pic = CComponentsPicture (pig_x, pig_y, pig_w, pig_h, pic_name, CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, NULL, false, col_frame, col_frame);
CComponentsPicture pic = CComponentsPicture (pig_x, pig_y, pig_w, pig_h, pic_name, NULL, false, col_frame, col_frame);
pic.setCorner(corner_rad, corner_type);
pic.paint(CC_SAVE_SCREEN_NO);
}

View File

@@ -32,7 +32,7 @@
#include <gui/movieplayer.h>
#include <driver/pictureviewer/pictureviewer.h>
#include <neutrino.h>
#include <system/debug.h>
#include "luainstance.h"
/* the magic color that tells us we are using one of the palette colors */
@@ -1886,8 +1886,7 @@ int CLuaInstance::CPictureNew(lua_State *L)
CLuaCWindow* parent = NULL;
lua_Integer x=10, y=10, dx=100, dy=100;
std::string image_name = "";
lua_Integer alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER;
lua_Integer alignment = 0;
std::string tmp1 = "false"; // has_shadow
lua_Integer color_frame = (lua_Integer)COL_MENUCONTENT_PLUS_6;
lua_Integer color_background = (lua_Integer)COL_MENUCONTENT_PLUS_0;
@@ -1899,7 +1898,11 @@ int CLuaInstance::CPictureNew(lua_State *L)
tableLookup(L, "dx" , dx);
tableLookup(L, "dy" , dy);
tableLookup(L, "image" , image_name);
tableLookup(L, "alignment" , alignment);
tableLookup(L, "alignment" , alignment); //invalid argumet, for compatibility
if (alignment)
dprintf(DEBUG_NORMAL, "[CLuaInstance][%s - %d] invalid argument: 'alignment' has no effect!\n", __func__, __LINE__);
tableLookup(L, "has_shadow" , tmp1);
bool has_shadow = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
tableLookup(L, "color_frame" , color_frame);
@@ -1910,7 +1913,7 @@ int CLuaInstance::CPictureNew(lua_State *L)
CLuaPicture **udata = (CLuaPicture **) lua_newuserdata(L, sizeof(CLuaPicture *));
*udata = new CLuaPicture();
(*udata)->cp = new CComponentsPicture(x, y, dx, dy, image_name, alignment, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow);
(*udata)->cp = new CComponentsPicture(x, y, dx, dy, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow);
(*udata)->parent = pw;
luaL_getmetatable(L, "cpicture");
lua_setmetatable(L, -2);

View File

@@ -404,7 +404,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
}
else if (actionKey == "picture"){
if (pic == NULL)
pic = new CComponentsPicture (100, 100, 200, 200, DATADIR "/neutrino/icons/mp3-5.jpg");
pic = new CComponentsPicture (100, 100, 200, 100, DATADIR "/neutrino/icons/mp3-5.jpg");
if (!pic->isPainted() && !pic->isPicPainted())
pic->paint();
@@ -414,7 +414,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
}
else if (actionKey == "channellogo"){
if (chnl_pic == NULL)
chnl_pic = new CComponentsChannelLogo(100, 100, 200, 200, 0, "ProSieben");
chnl_pic = new CComponentsChannelLogo(100, 100, "ProSieben", 0);
if (!chnl_pic->isPainted() && !chnl_pic->isPicPainted())
chnl_pic->paint();
@@ -430,10 +430,9 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
form->setFrameThickness(2);
form->setColorFrame(COL_WHITE);
CComponentsPicture *ptmp = new CComponentsPicture(0, 0, 0, 0, NEUTRINO_ICON_BUTTON_YELLOW);
CComponentsPicture *ptmp = new CComponentsPicture(0, 0, NEUTRINO_ICON_BUTTON_YELLOW);
ptmp->setWidth(28);
ptmp->setHeight(28);
ptmp->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
ptmp->setColorBody(COL_BLUE);
ptmp->setCorner(RADIUS_MID, CORNER_TOP_LEFT);
form->addCCItem(ptmp);

View File

@@ -175,7 +175,6 @@ void CVolumeBar::initVolumeBarIcon()
{
vb_icon = new CComponentsPicture(vb_icon_x, 0, vb_icon_w, height, NEUTRINO_ICON_VOLUME);
vb_icon->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
vb_icon->setColorBody(col_body);
vb_icon->setCorner(cornerRad(), CORNER_LEFT);