From 1cb885dfe97fb3190fc11d34e4005d27ddb0d4ae Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 14 Jan 2015 19:33:38 +0100 Subject: [PATCH] CChannelList/CNeutrinoEventList/CMovieBrowser: fix logo scale Downscale was broken. --- src/gui/channellist.cpp | 20 +++++++++++++------- src/gui/eventlist.cpp | 27 ++++++++++++++++++++------- src/gui/moviebrowser.cpp | 13 ++++++++++--- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 0add17c11..52b64c72c 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -1663,13 +1663,19 @@ void CChannelList::showChannelLogo() CChannelLogo->hide(); delete CChannelLogo; } - CChannelLogo = new CComponentsChannelLogo(0, 0, logo_w_max, theight, - (*chanlist)[selected]->getName(), (*chanlist)[selected]->channel_id); - if (CChannelLogo->hasLogo()) { - CChannelLogo->doScale(theight < CChannelLogo->getHeight()); - CChannelLogo->setXPos(x + full_width - logo_off - CChannelLogo->getWidth()); - CChannelLogo->setYPos(y + (theight - CChannelLogo->getHeight()) / 2); - CChannelLogo->paint(); + CChannelLogo = new CComponentsChannelLogo(0, 0, (*chanlist)[selected]->getName(), (*chanlist)[selected]->channel_id); + + if (CChannelLogo->hasLogo()){ + int h_logo = CChannelLogo->getHeight(); + if (h_logo > theight){ //scale image if required, TODO: move into an own handler, eg. header, so channel logo should be paint in header object + uint8_t h_ratio = uint8_t(theight*100/h_logo); + CChannelLogo->setHeight(theight); + int w_logo = h_ratio*CChannelLogo->getWidth()/100; + CChannelLogo->setWidth(min(w_logo, logo_w_max)); + CChannelLogo->setXPos(x + full_width - logo_off - CChannelLogo->getWidth()); + CChannelLogo->setYPos(y + (theight - CChannelLogo->getHeight()) / 2); + CChannelLogo->paint(); + } } else { delete CChannelLogo; CChannelLogo = NULL; diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 35f4cde60..2845b1de5 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -858,17 +858,30 @@ void CNeutrinoEventList::paintHead(t_channel_id _channel_id, std::string _channe header.setCorner(RADIUS_LARGE, CORNER_TOP); int x_off = 10; - int mid_width = header.getWidth() * 40 / 100; // 40% - int side_width = ((header.getWidth() - mid_width) / 2) - (2 * x_off); + int mid_width = full_width * 40 / 100; // 40% + int side_width = ((full_width - mid_width) / 2) - (2 * x_off); - CComponentsChannelLogo* midLogo = new CComponentsChannelLogo(CC_CENTERED, CC_CENTERED, _channelname, _channel_id); + //create an logo object + CComponentsChannelLogo* midLogo = new CComponentsChannelLogo(0, 0, _channelname, _channel_id, &header); if (midLogo->hasLogo()) { - header.addCCItem(midLogo); + //if logo object has found a logo and was ititialized, the hand it's size + int w_logo = midLogo->getWidth(); + + //scale image if required, TODO: move into an own handler, eg. header, so channel logo should be paint in header object + int h_logo = midLogo->getHeight(); + if (h_logo > theight){ + uint8_t h_ratio = uint8_t(theight*100/h_logo); + midLogo->setHeight(theight); + w_logo = h_ratio*w_logo/100; + midLogo->setWidth(w_logo); + } + midLogo->setPos(CC_CENTERED, CC_CENTERED); + // recalc widths - side_width = ((full_width - midLogo->getWidth()) / 2) - (4 * x_off); + side_width = ((full_width - w_logo) / 2) - (4 * x_off); } else { - delete midLogo; + header.removeCCItem(midLogo); //remove/destroy logo object, if it is not available CComponentsText *midText = new CComponentsText(CC_CENTERED, CC_CENTERED, mid_width, theight, _channelname, CTextBox::CENTER, g_Font[font_mid], &header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); midText->doPaintBg(false); } @@ -880,7 +893,7 @@ void CNeutrinoEventList::paintHead(t_channel_id _channel_id, std::string _channe if (!_channelname_next.empty()) { int name_w = std::min(g_Font[font_lr]->getRenderWidth(_channelname_next), side_width); - int x_pos = header.getWidth() - name_w - x_off; + int x_pos = full_width - name_w - x_off; CComponentsText *rText = new CComponentsText(x_pos, CC_CENTERED, name_w, theight, _channelname_next, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr], &header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); rText->doPaintBg(false); } diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 2d8f6fd33..ff185cd17 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1259,15 +1259,22 @@ void CMovieBrowser::refreshMovieInfo(void) CChannelLogo = NULL; } if (old_EpgId != m_movieSelectionHandler->epgEpgId >>16) { - CChannelLogo = new CComponentsChannelLogo(0, 0, logo_w_max, m_cBoxFrameTitleRel.iHeight, - m_movieSelectionHandler->epgChannel, m_movieSelectionHandler->epgEpgId >>16); + CChannelLogo = new CComponentsChannelLogo(0, 0, m_movieSelectionHandler->epgChannel, m_movieSelectionHandler->epgEpgId >>16); old_EpgId = m_movieSelectionHandler->epgEpgId >>16; } if (CChannelLogo && CChannelLogo->hasLogo()) { + //scale image if required, TODO: move into an own handler, eg. header, so channel logo should be paint in header object + int h_logo = CChannelLogo->getHeight(); + if (h_logo > m_cBoxFrameTitleRel.iHeight){ + uint8_t ratio = m_cBoxFrameTitleRel.iHeight*100/h_logo; + CChannelLogo->setHeight(m_cBoxFrameTitleRel.iHeight); + int w_logo = ratio*CChannelLogo->getWidth()/100; + CChannelLogo->setWidth(min(w_logo, logo_w_max)); + } + lx = m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+m_cBoxFrameTitleRel.iWidth-CChannelLogo->getWidth()-10; ly = m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY+ (m_cBoxFrameTitleRel.iHeight-CChannelLogo->getHeight())/2; - CChannelLogo->doScale(m_cBoxFrameTitleRel.iHeight < CChannelLogo->getHeight()); CChannelLogo->setXPos(lx - pb_hdd_offset); CChannelLogo->setYPos(ly); CChannelLogo->paint();