mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
framebuffer: add infrastructure to center icons vertically
add an additional height parameter to paintIcon() that allows to center the icons vertically between y and y+h defaults to 0 == unchanged behaviour git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@92 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -70,9 +70,9 @@ void CFBWindow::paintBoxRel(const int _x, const int _y, const int _dx, const int
|
|||||||
((CPrivateData *)private_data)->frameBuffer->paintBoxRel(x + _x, y + _y, _dx, _dy, _col, radius, type);
|
((CPrivateData *)private_data)->frameBuffer->paintBoxRel(x + _x, y + _y, _dx, _dy, _col, radius, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFBWindow::paintIcon(const char * const _filename, const int _x, const int _y, const color_t _offset)
|
bool CFBWindow::paintIcon(const char * const _filename, const int _x, const int _y, const int _h, const color_t _offset)
|
||||||
{
|
{
|
||||||
((CPrivateData *)private_data)->frameBuffer->paintIcon(_filename, x + _x, y + _y, _offset);
|
((CPrivateData *)private_data)->frameBuffer->paintIcon(_filename, x + _x, y + _y, _h, _offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ class CFBWindow
|
|||||||
~CFBWindow();
|
~CFBWindow();
|
||||||
|
|
||||||
void paintBoxRel(const int _x, const int _y, const int _dx, const int _dy, const color_t _col, int radius = 0, int type = 0xF);
|
void paintBoxRel(const int _x, const int _y, const int _dx, const int _dy, const color_t _col, int radius = 0, int type = 0xF);
|
||||||
bool paintIcon(const char * const _filename, const int _x, const int _y, const color_t _offset = 1);
|
bool paintIcon(const char * const _filename, const int _x, const int _y, const int _h = 0, const color_t _offset = 1);
|
||||||
void RenderString(const font_t _font, const int _x, const int _y, const int _width, const char * const _text, const color_t _color, const int _boxheight = 0, const bool _utf8_encoded = false);
|
void RenderString(const font_t _font, const int _x, const int _y, const int _width, const char * const _text, const color_t _color, const int _boxheight = 0, const bool _utf8_encoded = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -934,12 +934,17 @@ bool CFrameBuffer::paintIcon8(const std::string & filename, const int x, const i
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const int y, const unsigned char offset)
|
/* paint icon at position x/y,
|
||||||
|
if height h is given, center vertically between y and y+h
|
||||||
|
offset is a color offset (probably only useful with palette) */
|
||||||
|
bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const int y,
|
||||||
|
const int h, const unsigned char offset)
|
||||||
{
|
{
|
||||||
if (!getActive())
|
if (!getActive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//printf("%s(file, %d, %d, %d)\n", __FUNCTION__, x, y, offset);
|
//printf("%s(file, %d, %d, %d)\n", __FUNCTION__, x, y, offset);
|
||||||
|
int yy = y;
|
||||||
|
|
||||||
char * ptr = rindex(filename.c_str(), '.');
|
char * ptr = rindex(filename.c_str(), '.');
|
||||||
if(ptr) {
|
if(ptr) {
|
||||||
@@ -947,7 +952,11 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in
|
|||||||
std::string newname = iconBasePath + filename.c_str() + ".gif";
|
std::string newname = iconBasePath + filename.c_str() + ".gif";
|
||||||
*ptr = '.';
|
*ptr = '.';
|
||||||
if(!access(newname.c_str(), F_OK))
|
if(!access(newname.c_str(), F_OK))
|
||||||
return g_PicViewer->DisplayImage(newname, x, y, 0, 0);
|
{
|
||||||
|
if (h != 0)
|
||||||
|
yy += (h - g_PicViewer->getHeight(newname.c_str())) / 2;
|
||||||
|
return g_PicViewer->DisplayImage(newname, x, yy, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
struct rawHeader header;
|
struct rawHeader header;
|
||||||
uint16_t width, height;
|
uint16_t width, height;
|
||||||
@@ -970,8 +979,11 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in
|
|||||||
width = (header.width_hi << 8) | header.width_lo;
|
width = (header.width_hi << 8) | header.width_lo;
|
||||||
height = (header.height_hi << 8) | header.height_lo;
|
height = (header.height_hi << 8) | header.height_lo;
|
||||||
|
|
||||||
|
if (h != 0)
|
||||||
|
yy += (h - height) / 2;
|
||||||
|
|
||||||
unsigned char pixbuf[768];
|
unsigned char pixbuf[768];
|
||||||
uint8_t * d = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y;
|
uint8_t * d = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * yy;
|
||||||
fb_pixel_t * d2;
|
fb_pixel_t * d2;
|
||||||
for (int count=0; count<height; count ++ ) {
|
for (int count=0; count<height; count ++ ) {
|
||||||
read(fd, &pixbuf[0], width >> 1 );
|
read(fd, &pixbuf[0], width >> 1 );
|
||||||
@@ -998,10 +1010,11 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFrameBuffer::paintIcon(const char * const filename, const int x, const int y, const unsigned char offset)
|
bool CFrameBuffer::paintIcon(const char * const filename, const int x, const int y,
|
||||||
|
const int h, const unsigned char offset)
|
||||||
{
|
{
|
||||||
//printf("%s(%s, %d, %d, %d)\n", __FUNCTION__, filename, x, y, offset);
|
//printf("%s(%s, %d, %d, %d)\n", __FUNCTION__, filename, x, y, offset);
|
||||||
return paintIcon(std::string(filename), x, y, offset);
|
return paintIcon(std::string(filename), x, y, h, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFrameBuffer::loadPal(const std::string & filename, const unsigned char offset, const unsigned char endidx)
|
void CFrameBuffer::loadPal(const std::string & filename, const unsigned char offset, const unsigned char endidx)
|
||||||
|
@@ -167,8 +167,11 @@ class CFrameBuffer
|
|||||||
|
|
||||||
void setIconBasePath(const std::string & iconPath);
|
void setIconBasePath(const std::string & iconPath);
|
||||||
|
|
||||||
bool paintIcon (const char * const filename, const int x, const int y, const unsigned char offset = 1);
|
/* h is the height of the target "window", if != 0 the icon gets centered in that window */
|
||||||
bool paintIcon (const std::string & filename, const int x, const int y, const unsigned char offset = 1);
|
bool paintIcon (const char * const filename, const int x, const int y,
|
||||||
|
const int h = 0, const unsigned char offset = 1);
|
||||||
|
bool paintIcon (const std::string & filename, const int x, const int y,
|
||||||
|
const int h = 0, const unsigned char offset = 1);
|
||||||
bool paintIcon8(const std::string & filename, const int x, const int y, const unsigned char offset = 0);
|
bool paintIcon8(const std::string & filename, const int x, const int y, const unsigned char offset = 0);
|
||||||
void loadPal (const std::string & filename, const unsigned char offset = 0, const unsigned char endidx = 255);
|
void loadPal (const std::string & filename, const unsigned char offset = 0, const unsigned char endidx = 255);
|
||||||
|
|
||||||
|
@@ -683,7 +683,7 @@ void CStringInputSMS::paint()
|
|||||||
{
|
{
|
||||||
CStringInput::paint();
|
CStringInput::paint();
|
||||||
|
|
||||||
frameBuffer->paintIcon("numericpad.raw", x+20+140, y+ hheight+ mheight+ iheight* 3+ 30, COL_MENUCONTENT);
|
frameBuffer->paintIcon("numericpad.raw", x+20+140, y+ hheight+ mheight+ iheight* 3+ 30, 0, COL_MENUCONTENT);
|
||||||
|
|
||||||
frameBuffer->paintBoxRel(x,y+height-25, width,25, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, CORNER_BOTTOM);
|
frameBuffer->paintBoxRel(x,y+height-25, width,25, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, CORNER_BOTTOM);
|
||||||
frameBuffer->paintHLine(x, x+width, y+height-25, COL_INFOBAR_SHADOW_PLUS_0);
|
frameBuffer->paintHLine(x, x+width, y+height-25, COL_INFOBAR_SHADOW_PLUS_0);
|
||||||
|
@@ -3618,7 +3618,7 @@ void CNeutrinoApp::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool
|
|||||||
if(pixbuf!= NULL)
|
if(pixbuf!= NULL)
|
||||||
frameBuffer->SaveScreen(x, y, dx, dy, pixbuf);
|
frameBuffer->SaveScreen(x, y, dx, dy, pixbuf);
|
||||||
|
|
||||||
frameBuffer->paintIcon("volume.raw",x,y, COL_INFOBAR);
|
frameBuffer->paintIcon("volume.raw",x,y, 0, COL_INFOBAR);
|
||||||
frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0);
|
frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0);
|
||||||
g_volscale->reset();
|
g_volscale->reset();
|
||||||
g_volscale->paint(x + 41, y + 12, g_settings.current_volume);
|
g_volscale->paint(x + 41, y + 12, g_settings.current_volume);
|
||||||
|
Reference in New Issue
Block a user