From 3045baea1300a17cca594ddd1ba157cc652a3c74 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 12 Oct 2017 12:26:02 +0200 Subject: [PATCH] bedit: use inherited version of paintDetails() and dline/ibox objects This moves full identicaly code into base class. TODO: There are more similar parts. --- src/gui/bedit/bouqueteditor_bouquets.h | 1 + src/gui/bedit/bouqueteditor_channels.cpp | 53 +--------------------- src/gui/bedit/bouqueteditor_channels.h | 5 +- src/gui/bedit/bouqueteditor_chanselect.cpp | 52 --------------------- src/gui/bedit/bouqueteditor_chanselect.h | 5 +- src/gui/bedit/bouqueteditor_globals.cpp | 51 +++++++++++++++++++++ src/gui/bedit/bouqueteditor_globals.h | 9 +++- 7 files changed, 63 insertions(+), 113 deletions(-) diff --git a/src/gui/bedit/bouqueteditor_bouquets.h b/src/gui/bedit/bouqueteditor_bouquets.h index 9aa27dc2c..439ae1d7b 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.h +++ b/src/gui/bedit/bouqueteditor_bouquets.h @@ -85,6 +85,7 @@ class CBEBouquetWidget : public CBEGlobals, public CMenuTarget, public CListHelp void discardChanges(); std::string inputName(const char* const defaultName, const neutrino_locale_t caption); + std::string getInfoText(int /*index*/){}; public: CBEBouquetWidget(); diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index ac5a260cd..3bbb3c706 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -55,8 +55,7 @@ CBEChannelWidget::CBEChannelWidget(const std::string & Caption, unsigned int Bou caption = Caption; bouquet = Bouquet; mode = CZapitClient::MODE_TV; - dline = NULL; - ibox = NULL; + Channels = NULL; int iw, ih; @@ -76,8 +75,6 @@ CBEChannelWidget::CBEChannelWidget(const std::string & Caption, unsigned int Bou CBEChannelWidget::~CBEChannelWidget() { - delete dline; - delete ibox; } void CBEChannelWidget::paintItem(int pos) @@ -178,54 +175,6 @@ void CBEChannelWidget::paintFoot() footer.paintButtons(x, y + header_height + body_height, width, footer_height, numbuttons, CBEChannelWidgetButtons); } -void CBEChannelWidget::paintDetails(int pos, int current) -{ - int xpos = x - DETAILSLINE_WIDTH; - int ypos1 = y + header_height + pos*item_height; - int ypos2 = y + height - info_height - OFFSET_SHADOW; - int ypos1a = ypos1 + (item_height/2); - int ypos2a = ypos2 + (info_height/2); - - if (dline) - dline->kill(); - - if (pos >= 0) - { - if (dline == NULL) - dline = new CComponentsDetailsLine(); - - if (dline) - { - dline->setDimensionsAll(xpos, ypos1a, ypos2a, item_height/2, info_height - RADIUS_LARGE*2); - dline->paint(CC_SAVE_SCREEN_NO); - } - - if (ibox == NULL) - { - ibox = new CComponentsInfoBox(); - - if (ibox) - { - ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); - ibox->setTextColor(COL_MENUCONTENTDARK_TEXT); - ibox->setFrameThickness(FRAME_WIDTH_MIN); - ibox->setCorner(RADIUS_LARGE); - ibox->enableShadow(CC_SHADOW_ON); - } - } - - if (ibox) - { - if (ibox->isPainted()) - ibox->hide(); - - ibox->setDimensionsAll(x, ypos2, width, info_height); - ibox->setText(getInfoText(current), CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, info_font); - ibox->paint(CC_SAVE_SCREEN_NO); - } - } -} - void CBEChannelWidget::hide() { frameBuffer->paintBackgroundBoxRel(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW); diff --git a/src/gui/bedit/bouqueteditor_channels.h b/src/gui/bedit/bouqueteditor_channels.h index e8a9b521c..73f5512aa 100644 --- a/src/gui/bedit/bouqueteditor_channels.h +++ b/src/gui/bedit/bouqueteditor_channels.h @@ -38,9 +38,6 @@ class CBEChannelWidget : public CBEGlobals, public CMenuTarget, public CListHelpers { private: - CComponentsDetailsLine *dline; - CComponentsInfoBox *ibox; - enum state_ { beDefault, @@ -64,7 +61,7 @@ class CBEChannelWidget : public CBEGlobals, public CMenuTarget, public CListHelp void paintItem(int pos); void paintItems(); void paintFoot(); - void paintDetails(int pos, int current); + void hide(); void updateSelection(unsigned int newpos); diff --git a/src/gui/bedit/bouqueteditor_chanselect.cpp b/src/gui/bedit/bouqueteditor_chanselect.cpp index 09766df53..008997664 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.cpp +++ b/src/gui/bedit/bouqueteditor_chanselect.cpp @@ -48,8 +48,6 @@ CBEChannelSelectWidget::CBEChannelSelectWidget(const std::string & Caption, CZap liststart = 0; channellist_sort_mode = SORT_ALPHA; bouquetChannels = NULL; - dline = NULL; - ibox = NULL; int iw, ih; action_icon_width = 0; @@ -64,8 +62,6 @@ CBEChannelSelectWidget::CBEChannelSelectWidget(const std::string & Caption, CZap CBEChannelSelectWidget::~CBEChannelSelectWidget() { - delete dline; - delete ibox; } void CBEChannelSelectWidget::paintItem(int pos) @@ -184,54 +180,6 @@ void CBEChannelSelectWidget::paintFoot() footer.paintButtons(x, y + header_height + body_height, width, footer_height, numbuttons, CBEChannelSelectButtons); } -void CBEChannelSelectWidget::paintDetails(int pos, int current) -{ - int xpos = x - DETAILSLINE_WIDTH; - int ypos1 = y + header_height + pos*item_height; - int ypos2 = y + height - info_height - OFFSET_SHADOW; - int ypos1a = ypos1 + (item_height/2); - int ypos2a = ypos2 + (info_height/2); - - if (dline) - dline->kill(); - - if (pos >= 0) - { - if (dline == NULL) - dline = new CComponentsDetailsLine(); - - if (dline) - { - dline->setDimensionsAll(xpos, ypos1a, ypos2a, item_height/2, info_height - RADIUS_LARGE*2); - dline->paint(CC_SAVE_SCREEN_NO); - } - - if (ibox == NULL) - { - ibox = new CComponentsInfoBox(); - - if (ibox) - { - ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); - ibox->setTextColor(COL_MENUCONTENTDARK_TEXT); - ibox->setFrameThickness(FRAME_WIDTH_MIN); - ibox->setCorner(RADIUS_LARGE); - ibox->enableShadow(CC_SHADOW_ON); - } - } - - if (ibox) - { - if (ibox->isPainted()) - ibox->hide(); - - ibox->setDimensionsAll(x, ypos2, width, info_height); - ibox->setText(getInfoText(current), CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, info_font); - ibox->paint(CC_SAVE_SCREEN_NO); - } - } -} - void CBEChannelSelectWidget::hide() { frameBuffer->paintBackgroundBoxRel(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW); diff --git a/src/gui/bedit/bouqueteditor_chanselect.h b/src/gui/bedit/bouqueteditor_chanselect.h index bf7b9e6f6..c54436fae 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.h +++ b/src/gui/bedit/bouqueteditor_chanselect.h @@ -37,9 +37,6 @@ class CBEChannelSelectWidget : public CBEGlobals, public CMenuTarget, public CListHelpers { private: - CComponentsDetailsLine *dline; - CComponentsInfoBox *ibox; - enum { SORT_ALPHA, SORT_FREQ, @@ -64,7 +61,7 @@ class CBEChannelSelectWidget : public CBEGlobals, public CMenuTarget, public CLi void paintItem(int pos); void paintItems(); void paintFoot(); - void paintDetails(int pos, int current); + void hide(); void updateSelection(unsigned int newpos); diff --git a/src/gui/bedit/bouqueteditor_globals.cpp b/src/gui/bedit/bouqueteditor_globals.cpp index 3e8a9c14c..4d624724c 100644 --- a/src/gui/bedit/bouqueteditor_globals.cpp +++ b/src/gui/bedit/bouqueteditor_globals.cpp @@ -54,8 +54,59 @@ CBEGlobals::CBEGlobals() y = getScreenStartY(height); timeout = g_settings.timing[SNeutrinoSettings::TIMING_MENU]; + + dline = NULL; + ibox = NULL; } CBEGlobals::~CBEGlobals() { + delete dline; + delete ibox; } + +void CBEGlobals::paintDetails(int pos, int current) +{ + int xpos = x - DETAILSLINE_WIDTH; + int ypos1 = y + header_height + pos*item_height; + int ypos2 = y + height - info_height - OFFSET_SHADOW; + int ypos1a = ypos1 + (item_height/2); + int ypos2a = ypos2 + (info_height/2); + + if (pos >= 0) + { + if (dline == NULL) + dline = new CComponentsDetailsLine(); + dline->setDimensionsAll(xpos, ypos1a, ypos2a, item_height/2, info_height - RADIUS_LARGE*2); + + dline->paint(); + + if (ibox == NULL) + ibox = new CComponentsInfoBox(); + ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); + ibox->setTextColor(COL_MENUCONTENTDARK_TEXT); + ibox->setFrameThickness(FRAME_WIDTH_MIN); + ibox->setCorner(RADIUS_LARGE); + ibox->enableShadow(); + ibox->enableColBodyGradient(g_settings.theme.menu_Hint_gradient, COL_MENUFOOT_PLUS_0, g_settings.theme.menu_Hint_gradient_direction);// COL_MENUFOOT_PLUS_0 is default footer color + ibox->setDimensionsAll(x, ypos2, width, info_height); + ibox->setText(getInfoText(current), CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, info_font); + + ibox->paint(); + } + else + { + if (dline) + { + if (dline->isPainted()) + dline->hide(); + } + if (ibox) + { + if (ibox->isPainted()) + ibox->hide(); + } + } +} + + diff --git a/src/gui/bedit/bouqueteditor_globals.h b/src/gui/bedit/bouqueteditor_globals.h index 3e5b665e8..af04c4e16 100644 --- a/src/gui/bedit/bouqueteditor_globals.h +++ b/src/gui/bedit/bouqueteditor_globals.h @@ -28,9 +28,16 @@ class CBEGlobals { + protected: + CComponentsDetailsLine *dline; + CComponentsInfoBox *ibox; + + virtual std::string getInfoText(int index) = 0; + void paintDetails(int pos, int current); + public: CBEGlobals(); - ~CBEGlobals(); + virtual ~CBEGlobals(); CFrameBuffer *frameBuffer;