diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index cb90186bf..4ecad5660 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -882,66 +882,18 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start showText(showPos, sy + toph); // small bottom box with left/right navigation - if (!Bottombox){ - Bottombox = new CComponentsFrmChain(sx, sy+oy-botboxheight, ox, botboxheight); - Bottombox->setColorBody(COL_MENUFOOT_PLUS_0); - Bottombox->setCornerType(CORNER_NONE); - Bottombox->enableColBodyGradient(g_settings.theme.infobar_gradient_bottom,COL_MENUFOOT_PLUS_0,g_settings.theme.infobar_gradient_bottom_direction); - Bottombox->set2ndColor(COL_MENUCONTENT_PLUS_0); - } + if (!Bottombox) + Bottombox = new CNaviBar(sx, sy+oy-botboxheight, ox, botboxheight); if (!mp_info){ std::string fromto = epg_start + " - " + epg_end; - int x_off = OFFSET_INNER_MID; - int mid_width = ox * 40 / 100; // 40% - int side_width = ((ox - mid_width) / 2) - (2 * x_off); GetPrevNextEPGData(epgData.eventID, &epgData.epg_times.startzeit); - // init left arrow - if (!lpic){ - lpic = new CComponentsPictureScalable(x_off,CC_CENTERED,NEUTRINO_ICON_BUTTON_LEFT); - lpic->doPaintBg(false); - Bottombox->addCCItem(lpic); - lpic->enableSaveBg(); - } - lpic->allowPaint(prev_id && !call_fromfollowlist); - - // init right arrow - if (!rpic){ - rpic = new CComponentsPictureScalable(0,CC_CENTERED,NEUTRINO_ICON_BUTTON_RIGHT); - - rpic->doPaintBg(false); - Bottombox->addCCItem(rpic); - rpic->enableSaveBg(); - int x_pos = ox - rpic->getWidth() - x_off; - rpic->setXPos(x_pos); - } - rpic->allowPaint(next_id && !call_fromfollowlist); - - // init text left "from to" - if (!lText){ - lText = new CComponentsText(x_off + lpic->getWidth() + x_off, CC_CENTERED, side_width, toph, "", CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, NULL, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); - lText->doPaintBg(false); - Bottombox->addCCItem(lText); - lText->enableSaveBg(); - } - lText->setText(fromto, CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], COL_MENUHEAD_TEXT, CComponentsText::FONT_STYLE_REGULAR); - - // init text right "follow" - if (!rText){ - rText = new CComponentsText(0, CC_CENTERED, side_width, toph, "", CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, Bottombox, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); - rText->doPaintBg(false); - rText->enableSaveBg(); - } - rText->setText(epg_date, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]); - rText->setXPos(rpic->getXPos() - x_off - rText->getWidth()); + Bottombox->enableArrows(prev_id && !call_fromfollowlist, next_id && !call_fromfollowlist); + Bottombox->setText(fromto, epg_date); } - //ensure clean background - if(Bottombox->isPainted()) - Bottombox->hideCCItems(); - //paint bottombox contents Bottombox->paint(false); showProgressBar(); diff --git a/src/gui/epgview.h b/src/gui/epgview.h index 44de63c05..d873b82de 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -38,7 +38,7 @@ #include #include "widget/menue.h" - +#include "widget/navibar.h" #include #include @@ -51,7 +51,7 @@ class CEpgData CChannelEventList followlist; CEPGData epgData; CComponentsHeader *header; - CComponentsFrmChain *Bottombox; + CNaviBar *Bottombox; CComponentsPictureScalable *lpic, *rpic; CComponentsText *lText, *rText; CProgressBar *pb; diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index ebb8d5e8f..3d7c56e01 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -889,44 +889,14 @@ void CEventList::paintHead(t_channel_id _channel_id, std::string _channelname, s void CEventList::paintBottomBox(std::string _channelname_prev, std::string _channelname_next) { int by = y + height - iheight - botboxheight; - int font_lr = SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE; - int x_off = OFFSET_INNER_MID; - int mid_width = full_width * 40 / 100; // 40% - int side_width = ((full_width - mid_width) / 2) - (2 * x_off); if (!Bottombox){ - Bottombox = new CComponentsFrmChain(x, by, full_width, botboxheight); - Bottombox->setColorBody(COL_MENUFOOT_PLUS_0); - Bottombox->enableColBodyGradient(g_settings.theme.infobar_gradient_bottom,COL_MENUFOOT_PLUS_0,g_settings.theme.infobar_gradient_bottom_direction); - Bottombox->set2ndColor(COL_MENUCONTENT_PLUS_0); - }else{ - if (Bottombox->isPainted()) - Bottombox->hideCCItems(); - Bottombox->clear(); + Bottombox = new CNaviBar(x, by, full_width, botboxheight); + Bottombox->setFont(g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]); } - if (!_channelname_prev.empty()) { - CComponentsPictureScalable *lpic = new CComponentsPictureScalable(x_off,CC_CENTERED,NEUTRINO_ICON_BUTTON_LEFT,Bottombox); - lpic->doPaintBg(false); - lpic->enableSaveBg(); - - CComponentsText *lText = new CComponentsText(x_off + lpic->getWidth() + OFFSET_INNER_MID, CC_CENTERED, side_width, theight, _channelname_prev, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr], CComponentsText::FONT_STYLE_REGULAR, Bottombox, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); - lText->doPaintBg(false); - lText->enableSaveBg(); - } - - if (!_channelname_next.empty()) { - CComponentsPictureScalable *rpic = new CComponentsPictureScalable(0,CC_CENTERED,NEUTRINO_ICON_BUTTON_RIGHT,Bottombox); - int x_pos = full_width - rpic->getWidth() - OFFSET_INNER_MID; - rpic->doPaintBg(false); - rpic->setXPos(x_pos); - rpic->enableSaveBg(); - - CComponentsText *rText = new CComponentsText(0, CC_CENTERED, side_width, theight, _channelname_next, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[font_lr], CComponentsText::FONT_STYLE_REGULAR, Bottombox, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); - rText->setXPos(x_pos - OFFSET_INNER_MID - rText->getWidth()); - rText->doPaintBg(false); - rText->enableSaveBg(); - } + Bottombox->enableArrows(!_channelname_prev.empty(), !_channelname_next.empty()); + Bottombox->setText(_channelname_prev, _channelname_next); Bottombox->paint(false); } diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index 8b81aefb5..69cf7442c 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -32,7 +32,7 @@ #include #include #include - +#include #include "infoviewer.h" #include "widget/menue.h" @@ -104,8 +104,8 @@ class CEventList : public CListHelpers event_id_t item_event_ID; CComponentsText *cc_infozone; CComponentsHeader *header; - CProgressBar *pb; - CComponentsFrmChain *Bottombox; + CProgressBar *pb; + CNaviBar *Bottombox; const char * unit_short_minute; void paintItem(unsigned pos, t_channel_id channel_id = 0); diff --git a/src/gui/widget/Makefile.am b/src/gui/widget/Makefile.am index 5da8d7ebe..838ba162f 100644 --- a/src/gui/widget/Makefile.am +++ b/src/gui/widget/Makefile.am @@ -27,6 +27,7 @@ libneutrino_gui_widget_a_SOURCES = \ menue.cpp \ mountchooser.cpp \ msgbox.cpp \ + navibar.cpp \ shellwindow.cpp \ stringinput.cpp \ stringinput_ext.cpp \ diff --git a/src/gui/widget/navibar.cpp b/src/gui/widget/navibar.cpp new file mode 100644 index 000000000..74e1db74e --- /dev/null +++ b/src/gui/widget/navibar.cpp @@ -0,0 +1,116 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Class for epg window navigation bar. + Copyright (C) 2017, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "navibar.h" + + +using namespace std; + + +CNaviBar::CNaviBar( const int& x, + const int& y, + const int& dx, + const int& dy, + CComponentsForm* parent, + int shadow_mode, + fb_pixel_t& color_frame, + fb_pixel_t& color_body, + fb_pixel_t& color_shadow) + : CComponentsFrmChain( x, y, dx, dy, + NULL, + CC_DIR_X, + parent, + shadow_mode, + color_frame, + color_body, + color_shadow) +{ + setCornerType(CORNER_NONE); + enableColBodyGradient(g_settings.theme.infobar_gradient_bottom,COL_MENUFOOT_PLUS_0,g_settings.theme.infobar_gradient_bottom_direction); + set2ndColor(COL_MENUCONTENT_PLUS_0); + + nb_lpic = nb_rpic = NULL; + nb_lText = nb_rText = NULL; + nb_font = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE];; + nb_lpic_enable = nb_rpic_enable = false; + nb_l_text = nb_r_text = string(); + + initCCItems(); +} + +void CNaviBar::initCCItems() +{ + int x_off = OFFSET_INNER_MID; + int mid_width = width * 40 / 100; // 40% + int side_width = ((width - mid_width) / 2) - (2 * x_off); + int h_text = height; + + // init left arrow + if (!nb_lpic){ + nb_lpic = new CComponentsPictureScalable(x_off,CC_CENTERED,NEUTRINO_ICON_BUTTON_LEFT); + nb_lpic->doPaintBg(false); + this->addCCItem(nb_lpic); + nb_lpic->enableSaveBg(); + } + nb_lpic->allowPaint(nb_lpic_enable); + + // init right arrow + if (!nb_rpic){ + nb_rpic = new CComponentsPictureScalable(0,CC_CENTERED,NEUTRINO_ICON_BUTTON_RIGHT); + + nb_rpic->doPaintBg(false); + this->addCCItem(nb_rpic); + nb_rpic->enableSaveBg(); + int x_pos = width - nb_rpic->getWidth() - x_off; + nb_rpic->setXPos(x_pos); + } + nb_rpic->allowPaint(nb_rpic_enable); + + // init text left + if (!nb_lText){ + nb_lText = new CComponentsText(x_off + nb_lpic->getWidth() + x_off, CC_CENTERED, side_width, h_text, "", CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, this, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); + nb_lText->doPaintBg(false); + nb_lText->enableSaveBg(); + } + nb_lText->setText(nb_l_text, CTextBox::NO_AUTO_LINEBREAK, nb_font, COL_MENUHEAD_TEXT, CComponentsText::FONT_STYLE_REGULAR); + + // init text right + if (!nb_rText){ + nb_rText = new CComponentsText(0, CC_CENTERED, side_width, h_text, "", CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, this, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); + nb_rText->doPaintBg(false); + nb_rText->enableSaveBg(); + } + nb_rText->setText(nb_r_text, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, nb_font); + nb_rText->setXPos(nb_rpic->getXPos() - x_off - nb_rText->getWidth()); +} + + +void CNaviBar::paint(bool do_save_bg) +{ + hideCCItems(); + CComponentsFrmChain::paint(do_save_bg); +} diff --git a/src/gui/widget/navibar.h b/src/gui/widget/navibar.h new file mode 100644 index 000000000..1bc71b6fe --- /dev/null +++ b/src/gui/widget/navibar.h @@ -0,0 +1,169 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Class for epg window navigation bar. + Copyright (C) 2017, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + + +#ifndef __C_NAVIBAR__ +#define __C_NAVIBAR__ + +#include +#include + + +/** + CNaviBar is sub class of CComponentsFrmChain. + Shows a navigation bar with text and navigation icons. + You can enable/disable predefined icons and texts + on the left and/or right side of bar. +*/ +class CNaviBar : public CComponentsFrmChain +{ + private: + CComponentsPictureScalable *nb_lpic, *nb_rpic; + CComponentsText *nb_lText, *nb_rText; + + Font *nb_font; + + bool nb_lpic_enable; + bool nb_rpic_enable; + + std::string nb_l_text; + std::string nb_r_text; + + void initCCItems(); + + public: + /**CNaviBar Constructor + * @param[in] x + * @li expects type int, x position + * @param[in] y + * @li expects type int, y position + * @param[in] dx + * @li expects type int, width + * @param[in] dy + * @li expects type int, height + * @param[in] parent + * @li optional: expects type CComponentsForm or derivates, allows usage as item inside CComponentsForm container, default = NULL + * @param[in] shadow_mode + * @li optional: expects type fb_pixel_t, defines shadow mode, default CC_SHADOW_OFF + * @param[in] color_frame + * @li optional: expects type fb_pixel_t, defines frame color, default value = COL_FRAME_PLUS_0 + * @param[in] color_body + * @li optional: expects type fb_pixel_t, defines body color, default value = COL_MENUFOOT_PLUS_0 + * @param[in] color_shadow + * @li optional: expects type fb_pixel_t, defines shadow color, default value = COL_SHADOW_PLUS_0 + * + * @see class CComponentsFrmChain() + */ + CNaviBar( const int& x, + const int& y, + const int& dx, + const int& dy, + CComponentsForm* parent = NULL, + int shadow_mode = CC_SHADOW_OFF, + fb_pixel_t& color_frame = COL_FRAME_PLUS_0, + fb_pixel_t& color_body = COL_MENUFOOT_PLUS_0, + fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0); + + //~CNaviBar(); //is inherited + + /** + * Enable or disable left icon + * @param[in] enable + * @li exepts type bool, default = true + */ + void enableLeftArrow(bool enable = true){nb_lpic_enable = enable; initCCItems();} + + /** + * Enable or disable right icon + * @param[in] enable + * @li exepts type bool, default = true + */ + void enableRightArrow(bool enable = true){nb_rpic_enable = enable; initCCItems();} + + /** + * disable left icon + * no parameter + */ + void disableLeftArrow(){enableLeftArrow(false);} + + /** + * disable right icon + * no parameter + */ + void disableRightArrow(){enableRightArrow(false);} + + /** + * Enable or disable both icons at once. + * @param[in] enable_left + * @li exepts type bool, default = true + * @param[in] enable_right + * @li exepts type bool, default = true + */ + void enableArrows(bool enable_left = true, bool enable_right = true){enableLeftArrow(enable_left); enableRightArrow(enable_right);} + + /** + * Disable all icons. + * no parameter + */ + void disableArrows(){disableLeftArrow(); disableRightArrow();} + + /** + * Sets font type for texts. + * @param[in] font + * @li exepts type Font* + */ + void setFont(Font *font) {nb_font = font; initCCItems();} + + /** + * Sets left text. + * @param[in] text + * @li exepts type std::string + */ + void setLeftText(const std::string& text) {nb_l_text = text; initCCItems();} + + /** + * Sets right text + * @param[in] text + * @li exepts type std::string + */ + void setRightText(const std::string& text) {nb_r_text = text; initCCItems();} + + /** + * Sets left and right text at once. + * @param[in] left + * @li exepts type std::string + * @param[in] right + * @li exepts type std::string + */ + void setText(const std::string& left, const std::string& right) {setLeftText(left); setRightText(right);} + + /** + * Paint bar on screen. + * @param[in] do_save_bg + * @li optional: exepts type bool, default = CC_SAVE_SCREEN_YES. + */ + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + +#endif +