diff --git a/src/driver/fb_window.cpp b/src/driver/fb_window.cpp index d0d47afd5..840550435 100644 --- a/src/driver/fb_window.cpp +++ b/src/driver/fb_window.cpp @@ -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); } -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; } diff --git a/src/driver/fb_window.h b/src/driver/fb_window.h index 63181177f..10d806b6b 100644 --- a/src/driver/fb_window.h +++ b/src/driver/fb_window.h @@ -45,7 +45,7 @@ class 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); - 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); }; diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index 0e16d6ffb..ca8c5415a 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -934,12 +934,17 @@ bool CFrameBuffer::paintIcon8(const std::string & filename, const int x, const i 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()) return false; //printf("%s(file, %d, %d, %d)\n", __FUNCTION__, x, y, offset); + int yy = y; char * ptr = rindex(filename.c_str(), '.'); 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"; *ptr = '.'; 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; 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; height = (header.height_hi << 8) | header.height_lo; + if (h != 0) + yy += (h - height) / 2; + 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; for (int count=0; count> 1 ); @@ -998,10 +1010,11 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in 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); - 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) diff --git a/src/driver/framebuffer.h b/src/driver/framebuffer.h index 116b10c36..f5fdfe105 100644 --- a/src/driver/framebuffer.h +++ b/src/driver/framebuffer.h @@ -167,8 +167,11 @@ class CFrameBuffer void setIconBasePath(const std::string & iconPath); - bool paintIcon (const char * const filename, const int x, const int y, const unsigned char offset = 1); - bool paintIcon (const std::string & 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 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); void loadPal (const std::string & filename, const unsigned char offset = 0, const unsigned char endidx = 255); diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index 52aa48622..3f6239622 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -683,7 +683,7 @@ void CStringInputSMS::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->paintHLine(x, x+width, y+height-25, COL_INFOBAR_SHADOW_PLUS_0); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 19be4224b..c6f0d8564 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -3618,7 +3618,7 @@ void CNeutrinoApp::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool if(pixbuf!= NULL) 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); g_volscale->reset(); g_volscale->paint(x + 41, y + 12, g_settings.current_volume);