mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 00:41:17 +02:00
CNeutrinoEventList: rework paint of header
Reduce code with chain form and use text and logo items as embedded items.
This commit is contained in:
@@ -850,71 +850,42 @@ void CNeutrinoEventList::paintDescription(int index)
|
|||||||
|
|
||||||
void CNeutrinoEventList::paintHead(t_channel_id _channel_id, std::string _channelname, std::string _channelname_prev, std::string _channelname_next)
|
void CNeutrinoEventList::paintHead(t_channel_id _channel_id, std::string _channelname, std::string _channelname_prev, std::string _channelname_next)
|
||||||
{
|
{
|
||||||
CComponentsHeader* header = NULL;
|
|
||||||
CComponentsChannelLogo* midLogo = NULL;
|
|
||||||
CComponentsText* midText = NULL;
|
|
||||||
CComponentsText* lText = NULL;
|
|
||||||
CComponentsText* rText = NULL;
|
|
||||||
|
|
||||||
int font_mid = SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE;
|
int font_mid = SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE;
|
||||||
int font_lr = SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE;
|
int font_lr = SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE;
|
||||||
|
|
||||||
header = new CComponentsHeader(x, y, full_width, theight);
|
CComponentsFrmChain header(x, y, full_width, theight);
|
||||||
header->paint(CC_SAVE_SCREEN_NO);
|
header.enableColBodyGradient(g_settings.gradiant);
|
||||||
|
header.setCorner(RADIUS_LARGE, CORNER_TOP);
|
||||||
|
|
||||||
int logo_w_max = full_width / 4;
|
|
||||||
int name_w = 0;
|
|
||||||
int x_off = 10;
|
int x_off = 10;
|
||||||
int y_off = std::max((theight - g_Font[font_lr]->getHeight()) / 2, 0);
|
int mid_width = header.getWidth() * 40 / 100; // 40%
|
||||||
int x_pos = x;
|
int side_width = ((header.getWidth() - mid_width) / 2) - (2 * x_off);
|
||||||
int y_pos = y;
|
|
||||||
int mid_width = full_width * 40 / 100; // 40%
|
|
||||||
int side_width = ((full_width - mid_width) / 2) - (2 * x_off);
|
|
||||||
|
|
||||||
midLogo = new CComponentsChannelLogo(0, 0, logo_w_max, theight, _channelname, _channel_id);
|
CComponentsChannelLogo* midLogo = new CComponentsChannelLogo(CC_CENTERED, CC_CENTERED, _channelname, _channel_id);
|
||||||
if (midLogo->hasLogo()) {
|
if (midLogo->hasLogo()) {
|
||||||
int logo_w = midLogo->getWidth();
|
header.addCCItem(midLogo);
|
||||||
midLogo->setXPos(x + (full_width - logo_w) / 2);
|
|
||||||
midLogo->setYPos(y + (theight - midLogo->getHeight()) / 2);
|
|
||||||
midLogo->paint();
|
|
||||||
// recalc widths
|
// recalc widths
|
||||||
mid_width = logo_w;
|
side_width = ((full_width - midLogo->getWidth()) / 2) - (4 * x_off);
|
||||||
side_width = ((full_width - mid_width) / 2) - (4 * x_off);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
name_w = g_Font[font_mid]->getRenderWidth(_channelname);
|
delete midLogo;
|
||||||
x_pos = x + (full_width - std::min(name_w, mid_width))/2;
|
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);
|
||||||
y_pos = y;
|
|
||||||
midText = new CComponentsText(x_pos, y_pos, mid_width, theight, _channelname, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_mid]);
|
|
||||||
midText->doPaintBg(false);
|
midText->doPaintBg(false);
|
||||||
midText->setTextColor(COL_MENUHEAD_TEXT);
|
|
||||||
midText->paint(CC_SAVE_SCREEN_NO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_channelname_prev.empty()) {
|
if (!_channelname_prev.empty()) {
|
||||||
x_pos = x + x_off;
|
CComponentsText *lText = new CComponentsText(x_off, CC_CENTERED, side_width, theight, _channelname_prev, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr], &header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT);
|
||||||
y_pos = y + y_off;
|
|
||||||
lText = new CComponentsText(x_pos, y_pos, side_width, theight, _channelname_prev, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr]);
|
|
||||||
lText->doPaintBg(false);
|
lText->doPaintBg(false);
|
||||||
lText->setTextColor(COL_MENUHEAD_TEXT);
|
|
||||||
lText->paint(CC_SAVE_SCREEN_NO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_channelname_next.empty()) {
|
if (!_channelname_next.empty()) {
|
||||||
name_w = g_Font[font_lr]->getRenderWidth(_channelname_next);
|
int name_w = std::min(g_Font[font_lr]->getRenderWidth(_channelname_next), side_width);
|
||||||
x_pos = x + full_width - std::min(name_w, side_width) - x_off;
|
int x_pos = header.getWidth() - name_w - x_off;
|
||||||
y_pos = y + y_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 = new CComponentsText(x_pos, y_pos, std::min(name_w, side_width), theight, _channelname_next, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr]);
|
|
||||||
rText->doPaintBg(false);
|
rText->doPaintBg(false);
|
||||||
rText->setTextColor(COL_MENUHEAD_TEXT);
|
|
||||||
rText->paint(CC_SAVE_SCREEN_NO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rText) delete rText;
|
header.paint(CC_SAVE_SCREEN_NO);
|
||||||
if (lText) delete lText;
|
|
||||||
if (midText) delete midText;
|
|
||||||
if (midLogo) delete midLogo;
|
|
||||||
if (header) delete header;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNeutrinoEventList::paint(t_channel_id channel_id)
|
void CNeutrinoEventList::paint(t_channel_id channel_id)
|
||||||
|
Reference in New Issue
Block a user