From d81ad3a3f53e9ac08b00bc951ceb39658d528e01 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 3 Mar 2020 21:22:34 +0100 Subject: [PATCH] epg_banner: outsource class for rate banners For global use. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7e7ddaa0f30e4572204e46ed8d18b3e8ba93e6d5 Author: Thilo Graf Date: 2020-03-03 (Tue, 03 Mar 2020) ------------------ This commit was generated by Migit --- src/gui/Makefile.am | 1 + src/gui/epgview.cpp | 10 +++-- src/gui/epgview.h | 43 ++------------------- src/gui/rate_banner.cpp | 86 +++++++++++++++++++++++++++++++++++++++++ src/gui/rate_banner.h | 65 +++++++++++++++++++++++++++++++ 5 files changed, 161 insertions(+), 44 deletions(-) create mode 100644 src/gui/rate_banner.cpp create mode 100644 src/gui/rate_banner.h diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 9e281ea91..ba754b3e2 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -91,6 +91,7 @@ libneutrino_gui_a_SOURCES = \ plugins_hide.cpp \ proxyserver_setup.cpp \ radiotext_window.cpp \ + rate_banner.cpp \ rc_lock.cpp \ record_setup.cpp \ scan.cpp \ diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 84a47ae6c..0049ea8b1 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -26,9 +26,11 @@ #endif #include -#include -#include -#include +#include +#include "adzap.h" +#include "epgview.h" +#include "eventlist.h" +#include "rate_banner.h" #include #include @@ -36,7 +38,7 @@ #include #include -#include +#include "timerlist.h" #include #include diff --git a/src/gui/epgview.h b/src/gui/epgview.h index 99a27d52e..80645cf11 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -40,12 +40,12 @@ #include #include "widget/menue.h" #include "widget/navibar.h" -#include "gui/components/cc.h" + #include #include class CFrameBuffer; -//class CEPGRateBanner; + class CEpgData { private: @@ -128,41 +128,4 @@ class CEPGDataHandler : public CMenuTarget }; -#if 0 -class CEPGRateBanner : public CComponentsIconForm -{ - private: - void init(const std::string& quote_icon, const std::string& quote_icon_bg, const size_t& quote, const size_t& quote_max, const std::string& provider_logo) - { - cc_item_type.name = "epg_rate_banner"; - append_x_offset = 5; - paint_bg = false; - addIcons(provider_logo); - addIcons(quote_icon, quote); - addIcons(quote_icon_bg, quote_max - quote); - } - - public: - - CEPGRateBanner( const int &x_pos, - const int &y_pos, - const size_t& quote, - const size_t& quote_max = 10, - const std::string& provider_logo = "", - const std::string& quote_icon = NEUTRINO_ICON_STAR_ON, - const std::string& quote_icon_bg = NEUTRINO_ICON_STAR_OFF, - int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_FRAME_PLUS_0, - fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, - fb_pixel_t color_shadow = COL_SHADOW_PLUS_0, - CComponentsForm *parent = NULL) - :CComponentsIconForm(x_pos, y_pos, 0, 0, std::vector(), parent, shadow_mode, color_frame, color_body, color_shadow) - { - init(quote_icon, quote_icon_bg, quote, quote_max, provider_logo); - }; -}; -#endif - - -#endif - +#endif //__epgview__ diff --git a/src/gui/rate_banner.cpp b/src/gui/rate_banner.cpp new file mode 100644 index 000000000..b7461ef62 --- /dev/null +++ b/src/gui/rate_banner.cpp @@ -0,0 +1,86 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Class for rate banner. + Copyright (C) 2020, 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 "rate_banner.h" +#include + +CRateBanner::CRateBanner( const int &x_pos, + const int &y_pos, + const float& quote, + const float& quote_max, + const std::string& provider_logo, + const std::string& quote_icon, + const std::string& quote_icon_bg, + int shadow_mode, + fb_pixel_t color_frame, + fb_pixel_t color_body, + fb_pixel_t color_shadow, + CComponentsForm *parent) + :CComponentsIconForm(x_pos, y_pos, 0, 0, std::vector(), parent, shadow_mode, color_frame, color_body, color_shadow) +{ + init(quote_icon, quote_icon_bg, quote, quote_max, provider_logo); +} + +CRateBanner::~CRateBanner() +{ + +} + +void CRateBanner::init(const std::string& quote_icon, const std::string& quote_icon_bg, const float& quote, const float& quote_max, const std::string& provider_logo) +{ + cc_item_type.name = "rate_banner"; + append_x_offset = OFFSET_INNER_SMALL; + paint_bg = false; + rat_prov_logo = provider_logo; + rat_icon = quote_icon; + rat_icon_bg = quote_icon_bg; + rate = quote; + rat_max = quote_max; +} + +void CRateBanner::paint(const bool &do_save_bg) +{ + clear(); + addIcon(rat_prov_logo); + addIcons(rat_icon, rat_max); + paintForm(do_save_bg); + + int x_base = getCCItem(rat_icon)->getRealXPos(); + float w_rate_space = static_cast(width - (getCCItem(rat_prov_logo) ? getCCItem(rat_prov_logo)->getWidth() - append_x_offset : 0)); + float w_rate_size = w_rate_space / rat_max * rate; + int w_tmp = static_cast(round(w_rate_size)) - append_x_offset; + fb_pixel_t* pixbuf = getScreen(x_base, y, w_tmp, height); + + removeAllIcons(); + addIcon(rat_prov_logo); + addIcons(rat_icon_bg, rat_max); + + paintCCItems(); + frameBuffer->RestoreScreen(x_base, y, w_tmp, height, pixbuf); + delete[] pixbuf; + pixbuf = NULL; +} diff --git a/src/gui/rate_banner.h b/src/gui/rate_banner.h new file mode 100644 index 000000000..8cccf82e8 --- /dev/null +++ b/src/gui/rate_banner.h @@ -0,0 +1,65 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Class for rate banner. + Copyright (C) 2020, 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 __RATE_BANNER_H__ +#define __RATE_BANNER_H__ + + +#include "components/cc.h" + +#include + + +class CRateBanner : public CComponentsIconForm +{ + private: + std::string rat_icon, rat_icon_bg, rat_prov_logo; + float rate, rat_max; + + void init( const std::string& quote_icon, + const std::string& quote_icon_bg, + const float& quote, + const float& quote_max, + const std::string& provider_logo); + + public: + CRateBanner( const int &x_pos, + const int &y_pos, + const float& quote, + const float& quote_max = 10, + const std::string& provider_logo = "", + const std::string& quote_icon = NEUTRINO_ICON_STAR_ON, + const std::string& quote_icon_bg = NEUTRINO_ICON_STAR_OFF, + int shadow_mode = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_FRAME_PLUS_0, + fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, + fb_pixel_t color_shadow = COL_SHADOW_PLUS_0, + CComponentsForm *parent = NULL); + + virtual ~CRateBanner(); + + void paint(const bool &do_save_bg = CC_SAVE_SCREEN_YES); +}; + +#endif //__RATE_BANNER_H__