- bouqueteditor: massively rework gui; ...

* add CBEGlobals to globalize some basic calculations
  (maybe there's something more to globalize)
* add header-icons
* change header-captions
* add info-texts for webtv-channels
* change arrangement of status-icons
* small code re-formattings

bouqueteditor_bouquets:
* RC_yellow now starts and stops moving of bouquets
* RC_tv now switches to tv-channels
* RC_radio now switches to radio-channels

bouqueteditor_chanselect:
* RC_green now add channels too
* don't use listbox-widget anymore (listbox is unused now)
This commit is contained in:
svenhoefer
2017-09-24 22:03:04 +02:00
committed by Jacek Jendrzej
parent 940fdf36fd
commit 4f50b2009a
9 changed files with 990 additions and 789 deletions

View File

@@ -19,5 +19,5 @@ noinst_LIBRARIES = libneutrino_gui_bedit.a
libneutrino_gui_bedit_a_SOURCES = \
bouqueteditor_bouquets.cpp \
bouqueteditor_channels.cpp \
bouqueteditor_chanselect.cpp
bouqueteditor_chanselect.cpp \
bouqueteditor_globals.cpp

View File

@@ -1,24 +1,24 @@
/*
Neutrino-GUI - DBoxII-Project
neutrino bouquet editor - bouquets editor
Copyright (C) 2001 Steffen Hehn 'McClean'
Copyright (C) 2009,2011,2013,2016 Stefan Seyfried
Copyright (C) 2017 Sven Hoefer
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 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.
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -27,46 +27,49 @@
#include <global.h>
#include <neutrino.h>
#include "bouqueteditor_channels.h"
#include "bouqueteditor_bouquets.h"
#include <driver/fontrenderer.h>
#include <driver/screen_max.h>
#include <gui/components/cc.h>
#include <gui/widget/hintbox.h>
#include <gui/widget/keyboard_input.h>
#include <gui/widget/msgbox.h>
#include <gui/widget/stringinput.h>
#include <gui/widget/keyboard_input.h>
#include <zapit/client/zapittools.h>
#include "bouqueteditor_bouquets.h"
#include "bouqueteditor_channels.h"
extern CBouquetManager *g_bouquetManager;
CBEBouquetWidget::CBEBouquetWidget()
{
frameBuffer = CFrameBuffer::getInstance();
iconoffset = 0;
origPosition = 0;
newPosition = 0;
listmaxshow = 0;
bouquetsChanged = 0;
width = 0;
height = 0;
x = 0;
y = 0;
selected = 0;
liststart = 0;
state = beDefault;
Bouquets = NULL;
iheight = 0;
ButtonHeight = footer.getHeight();
fheight = 0;
theight = 0;
int iw, ih;
action_icon_width = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_DUMMY_SMALL, &action_icon_width, &ih);
status_icon_width = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_HIDDEN, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
frameBuffer->getIconSize(NEUTRINO_ICON_LOCK, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
frameBuffer->getIconSize(NEUTRINO_ICON_AUDIO, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
frameBuffer->getIconSize(NEUTRINO_ICON_VIDEO, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
}
void CBEBouquetWidget::paintItem(int pos)
{
int ypos = y + theight + pos*iheight;
int ypos = y + header_height + pos*item_height;
unsigned int current = liststart + pos;
bool i_selected = current == selected;
@@ -84,79 +87,91 @@ void CBEBouquetWidget::paintItem(int pos)
else
{
bool has_channels = true;
if(current < Bouquets->size())
has_channels = (!(*Bouquets)[current]->tvChannels.empty() ) || (!(*Bouquets)[current]->radioChannels.empty());
if (current < Bouquets->size())
has_channels = (!(*Bouquets)[current]->tvChannels.empty()) || (!(*Bouquets)[current]->radioChannels.empty());
if (!has_channels)
color = COL_MENUCONTENTINACTIVE_TEXT;
}
if (i_radius)
frameBuffer->paintBoxRel(x,ypos, width - SCROLLBAR_WIDTH, iheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x,ypos, width - SCROLLBAR_WIDTH, iheight, bgcolor, i_radius);
frameBuffer->paintBoxRel(x,ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x,ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius);
if (current < Bouquets->size()) {
if (current < Bouquets->size())
{
if ((i_selected) && (state == beMoving))
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + OFFSET_INNER_MID, ypos, iheight);
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + OFFSET_INNER_MID, ypos, item_height);
else
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_DUMMY_SMALL, x + OFFSET_INNER_MID, ypos, item_height);
int text_offset = 2*OFFSET_INNER_MID + action_icon_width;
item_font->RenderString(x + text_offset, ypos + item_height, width - text_offset - SCROLLBAR_WIDTH - 5*OFFSET_INNER_MID - 4*status_icon_width, (*Bouquets)[current]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[current]->Name, color);
if ((*Bouquets)[current]->bHidden)
frameBuffer->paintIcon(NEUTRINO_ICON_HIDDEN, x + OFFSET_INNER_MID + iconoffset, ypos, iheight);
frameBuffer->paintIcon(NEUTRINO_ICON_HIDDEN, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - status_icon_width, ypos, item_height);
if ((*Bouquets)[current]->bLocked != g_settings.parentallock_defaultlocked)
frameBuffer->paintIcon(NEUTRINO_ICON_LOCK, x + OFFSET_INNER_MID + 2*iconoffset, ypos, iheight);
frameBuffer->paintIcon(NEUTRINO_ICON_LOCK, x + width - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - 2*status_icon_width, ypos, item_height);
if (!(*Bouquets)[current]->tvChannels.empty() ) {
frameBuffer->paintIcon(NEUTRINO_ICON_VIDEO, x + OFFSET_INNER_MID + 3*iconoffset, ypos, iheight);
}
if (!(*Bouquets)[current]->radioChannels.empty())
frameBuffer->paintIcon(NEUTRINO_ICON_AUDIO, x + width - SCROLLBAR_WIDTH - 3*OFFSET_INNER_MID - 3*status_icon_width, ypos, item_height);
if (!(*Bouquets)[current]->radioChannels.empty()) {
frameBuffer->paintIcon(NEUTRINO_ICON_AUDIO, x + OFFSET_INNER_MID + 4*iconoffset, ypos, iheight);
}
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 2*OFFSET_INNER_MID + 5*iconoffset, ypos + iheight - (iheight-fheight)/2, width - 3*OFFSET_INNER_MID - 5*iconoffset, (*Bouquets)[current]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[current]->Name, color);
if (!(*Bouquets)[current]->tvChannels.empty())
frameBuffer->paintIcon(NEUTRINO_ICON_VIDEO, x + width - SCROLLBAR_WIDTH - 4*OFFSET_INNER_MID - 4*status_icon_width, ypos, item_height);
}
}
void CBEBouquetWidget::paint()
void CBEBouquetWidget::paintItems()
{
liststart = (selected/listmaxshow)*listmaxshow;
liststart = (selected/items_count)*items_count;
for(unsigned int count=0;count<listmaxshow;count++)
{
for(unsigned int count = 0; count < items_count; count++)
paintItem(count);
}
int total_pages;
int current_page;
getScrollBarData(&total_pages, &current_page, Bouquets->size(), listmaxshow, selected);
paintScrollBar(x + width - SCROLLBAR_WIDTH, y + theight, SCROLLBAR_WIDTH, iheight*listmaxshow, total_pages, current_page);
getScrollBarData(&total_pages, &current_page, Bouquets->size(), items_count, selected);
paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, body_height, total_pages, current_page);
}
void CBEBouquetWidget::paintBody()
{
PaintBoxRel(x, y + header_height, width, body_height, COL_MENUCONTENT_PLUS_0, RADIUS_NONE, CORNER_NONE, CC_SHADOW_ON);
}
void CBEBouquetWidget::paintHead()
{
CComponentsHeader header(x, y, width, theight, LOCALE_BOUQUETLIST_HEAD, "" /*no header icon*/, CComponentsHeader::CC_BTN_EXIT);
header.setCaption(LOCALE_BOUQUETLIST_HEAD);
header.setIcon(NEUTRINO_ICON_SETTINGS);
header.setDimensionsAll(x, y, width, header_height);
header.setCorner(RADIUS_LARGE, CORNER_TOP);
header.enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true);
header.paint(CC_SAVE_SCREEN_NO);
}
const struct button_label CBEBouquetWidgetButtons[6] =
const struct button_label CBEBouquetWidgetButtons[] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_BOUQUETEDITOR_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_BOUQUETEDITOR_ADD },
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_BOUQUETEDITOR_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_BOUQUETEDITOR_ADD },
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOUQUETEDITOR_MOVE },
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_BOUQUETEDITOR_RENAME},
{ NEUTRINO_ICON_BUTTON_PAUSE , LOCALE_BOUQUETEDITOR_HIDE },
{ NEUTRINO_ICON_BUTTON_STOP , LOCALE_BOUQUETEDITOR_LOCK }
{ NEUTRINO_ICON_BUTTON_BLUE, LOCALE_BOUQUETEDITOR_RENAME },
{ NEUTRINO_ICON_BUTTON_PAUSE, LOCALE_BOUQUETEDITOR_HIDE },
{ NEUTRINO_ICON_BUTTON_STOP, LOCALE_BOUQUETEDITOR_LOCK }
};
void CBEBouquetWidget::paintFoot()
{
size_t numbuttons = sizeof(CBEBouquetWidgetButtons)/sizeof(CBEBouquetWidgetButtons[0]);
footer.paintButtons(x, y+height, width, ButtonHeight, numbuttons, CBEBouquetWidgetButtons, width/numbuttons-2*OFFSET_INNER_MID);
footer.setCorner(RADIUS_LARGE, CORNER_BOTTOM);
footer.enableShadow(CC_SHADOW_ON, -1, true);
footer.paintButtons(x, y + header_height + body_height, width, footer_height, numbuttons, CBEBouquetWidgetButtons);
}
void CBEBouquetWidget::hide()
{
frameBuffer->paintBackgroundBoxRel(x,y, width,height);
footer.kill();
frameBuffer->paintBackgroundBoxRel(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW);
}
void CBEBouquetWidget::updateSelection(unsigned int newpos)
@@ -167,16 +182,22 @@ void CBEBouquetWidget::updateSelection(unsigned int newpos)
unsigned int prev_selected = selected;
selected = newpos;
if (state == beDefault) {
if (state == beDefault)
{
unsigned int oldliststart = liststart;
liststart = (selected/listmaxshow)*listmaxshow;
if(oldliststart!=liststart) {
paint();
} else {
liststart = (selected/items_count)*items_count;
if (oldliststart != liststart)
{
paintItems();
}
else
{
paintItem(prev_selected - liststart);
paintItem(selected - liststart);
}
} else {
}
else
{
internalMoveBouquet(prev_selected, selected);
}
}
@@ -191,58 +212,26 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
if (parent)
parent->hide();
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
int icol_w, icol_h;
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_YELLOW, &icol_w, &icol_h);
iheight = std::max(fheight, icol_h + OFFSET_INNER_MIN);
iconoffset = std::max(iconoffset, icol_w);
frameBuffer->getIconSize(NEUTRINO_ICON_LOCK, &icol_w, &icol_h);
iheight = std::max(fheight, icol_h + OFFSET_INNER_MIN);
iconoffset = std::max(iconoffset, icol_w);
frameBuffer->getIconSize(NEUTRINO_ICON_HIDDEN, &icol_w, &icol_h);
iheight = std::max(fheight, icol_h + OFFSET_INNER_MIN);
iconoffset = std::max(iconoffset, icol_w);
frameBuffer->getIconSize(NEUTRINO_ICON_VIDEO, &icol_w, &icol_h);
iheight = std::max(fheight, icol_h + OFFSET_INNER_MIN);
iconoffset = std::max(iconoffset, icol_w);
frameBuffer->getIconSize(NEUTRINO_ICON_AUDIO, &icol_w, &icol_h);
iheight = std::max(fheight, icol_h + OFFSET_INNER_MIN);
iconoffset = std::max(iconoffset, icol_w);
width = frameBuffer->getScreenWidthRel();
height = frameBuffer->getScreenHeightRel() - ButtonHeight;
listmaxshow = (height-theight)/iheight;
height = theight+listmaxshow*iheight; // recalc height
x = getScreenStartX(width);
y = getScreenStartY(height + ButtonHeight);
Bouquets = &g_bouquetManager->Bouquets;
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
bouquetsChanged = false;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]);
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
bool loop=true;
bool loop = true;
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);
if ( msg <= CRCInput::RC_MaxRC )
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]);
if (msg <= CRCInput::RC_MaxRC)
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
if ((msg == CRCInput::RC_timeout) ||
(msg == (neutrino_msg_t)g_settings.key_channelList_cancel))
if ((msg == CRCInput::RC_timeout) || (msg == (neutrino_msg_t)g_settings.key_channelList_cancel))
{
if (state == beDefault)
{
@@ -250,23 +239,30 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
{
int result = ShowMsg(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMsgBox::mbrYes, CMsgBox::mbYesNoCancel, NULL, 600);
switch( result )
switch(result)
{
case CMsgBox::mbrYes:
{
case CMsgBox::mbrYes :
loop=false;
saveChanges();
break;
case CMsgBox::mbrNo :
}
case CMsgBox::mbrNo:
{
loop=false;
discardChanges();
break;
case CMsgBox::mbrCancel :
}
case CMsgBox::mbrCancel:
{
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
break;
}
}
}
else
{
loop = false;
@@ -280,36 +276,38 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
else if (msg == CRCInput::RC_up || msg == (neutrino_msg_t)g_settings.key_pageup ||
msg == CRCInput::RC_down || msg == (neutrino_msg_t)g_settings.key_pagedown)
{
int new_selected = UpDownKey(*Bouquets, msg, listmaxshow, selected);
int new_selected = UpDownKey(*Bouquets, msg, items_count, selected);
updateSelection(new_selected);
}
else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end) {
if (!(Bouquets->empty())) {
else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end)
{
if (!(Bouquets->empty()))
{
int new_selected = msg == (neutrino_msg_t) g_settings.key_list_start ? 0 : Bouquets->size() - 1;
updateSelection(new_selected);
}
}
else if(msg==CRCInput::RC_red)
else if (msg == CRCInput::RC_red)
{
if (state == beDefault)
deleteBouquet();
}
else if(msg==CRCInput::RC_green)
else if (msg == CRCInput::RC_green)
{
if (state == beDefault)
addBouquet();
}
else if(msg==CRCInput::RC_yellow)
else if (msg == CRCInput::RC_yellow)
{
if (selected < Bouquets->size()) /* Bouquets->size() might be 0 */
{
liststart = (selected/listmaxshow)*listmaxshow;
liststart = (selected/items_count)*items_count;
if (state == beDefault)
beginMoveBouquet();
paintItem(selected - liststart);
}
}
else if(msg==CRCInput::RC_blue)
else if (msg == CRCInput::RC_blue)
{
if (selected < Bouquets->size()) /* Bouquets->size() might be 0 */
{
@@ -317,8 +315,7 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
renameBouquet();
}
}
else if(msg==CRCInput::RC_pause)
else if (msg == CRCInput::RC_pause)
{
if (selected < Bouquets->size()) /* Bouquets->size() might be 0 */
{
@@ -326,7 +323,7 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
switchHideBouquet();
}
}
else if(msg==CRCInput::RC_stop)
else if (msg == CRCInput::RC_stop)
{
if (selected < Bouquets->size()) /* Bouquets->size() might be 0 */
{
@@ -334,30 +331,35 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
switchLockBouquet();
}
}
else if(msg==CRCInput::RC_ok)
else if (msg == CRCInput::RC_ok)
{
if (state == beDefault)
{
if (selected < Bouquets->size()) /* Bouquets->size() might be 0 */
{
std::string ChannelWidgetCaption=(*Bouquets)[selected]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[selected]->Name;
if (!(*Bouquets)[selected]->tvChannels.empty() ) {
ChannelWidgetCaption = ChannelWidgetCaption+ " => TV";
#if 0
if (!(*Bouquets)[selected]->tvChannels.empty())
{
ChannelWidgetCaption = ChannelWidgetCaption + " => TV";
if (!(*Bouquets)[selected]->radioChannels.empty())
ChannelWidgetCaption = ChannelWidgetCaption+ "/Radio";
ChannelWidgetCaption = ChannelWidgetCaption + " / Radio";
}
else if (!(*Bouquets)[selected]->radioChannels.empty()) {
ChannelWidgetCaption = ChannelWidgetCaption+ " => Radio";
else if (!(*Bouquets)[selected]->radioChannels.empty())
{
ChannelWidgetCaption = ChannelWidgetCaption + " => Radio";
}
#endif
CBEChannelWidget* channelWidget = new CBEChannelWidget(ChannelWidgetCaption, selected);
channelWidget->exec( this, "");
channelWidget->exec(this, "");
if (channelWidget->hasChanged())
bouquetsChanged = true;
delete channelWidget;
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
}
}
else if (state == beMoving)
@@ -365,13 +367,13 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
finishMoveBouquet();
}
}
else if( CRCInput::isNumeric(msg) )
else if (CRCInput::isNumeric(msg))
{
if (state == beDefault)
{
//kein pushback - wenn man versehentlich wo draufkommt is die edit-arbeit umsonst
//selected = oldselected;
//g_RCInput->postMsg( msg, data );
//g_RCInput->postMsg(msg, data);
//loop=false;
}
else if (state == beMoving)
@@ -385,7 +387,7 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
}
else
{
CNeutrinoApp::getInstance()->handleMsg( msg, data );
CNeutrinoApp::getInstance()->handleMsg(msg, data);
}
}
hide();
@@ -405,13 +407,13 @@ void CBEBouquetWidget::deleteBouquet()
if (selected >= Bouquets->size())
selected = Bouquets->empty() ? 0 : (Bouquets->size() - 1);
bouquetsChanged = true;
paint();
paintItems();
}
void CBEBouquetWidget::addBouquet()
{
std::string newName = inputName("", LOCALE_BOUQUETEDITOR_BOUQUETNAME);
if (!(newName.empty()))
if (!newName.empty())
{
g_bouquetManager->addBouquet(newName, true);
Bouquets = &g_bouquetManager->Bouquets;
@@ -419,8 +421,9 @@ void CBEBouquetWidget::addBouquet()
bouquetsChanged = true;
}
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
}
void CBEBouquetWidget::beginMoveBouquet()
@@ -438,27 +441,29 @@ void CBEBouquetWidget::finishMoveBouquet()
Bouquets = &g_bouquetManager->Bouquets;
bouquetsChanged = bouquetsChanged | true;
}
paint();
paintItems();
}
void CBEBouquetWidget::cancelMoveBouquet()
{
state = beDefault;
internalMoveBouquet( newPosition, origPosition);
internalMoveBouquet(newPosition, origPosition);
bouquetsChanged = bouquetsChanged | false;
}
void CBEBouquetWidget::internalMoveBouquet( unsigned int fromPosition, unsigned int toPosition)
void CBEBouquetWidget::internalMoveBouquet(unsigned int fromPosition, unsigned int toPosition)
{
if ( (int) toPosition == -1 ) return;
if ( toPosition == Bouquets->size()) return;
if ((int) toPosition == -1)
return;
if (toPosition == Bouquets->size())
return;
g_bouquetManager->moveBouquet(fromPosition, toPosition);
Bouquets = &g_bouquetManager->Bouquets;
//bouquetsChanged = true;
selected = toPosition;
newPosition = toPosition;
paint();
paintItems();
}
void CBEBouquetWidget::renameBouquet()
@@ -474,22 +479,23 @@ void CBEBouquetWidget::renameBouquet()
bouquetsChanged = true;
}
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
}
void CBEBouquetWidget::switchHideBouquet()
{
bouquetsChanged = true;
(*Bouquets)[selected]->bHidden = !(*Bouquets)[selected]->bHidden;
paint();
paintItems();
}
void CBEBouquetWidget::switchLockBouquet()
{
bouquetsChanged = true;
g_bouquetManager->setBouquetLock((*Bouquets)[selected], !(*Bouquets)[selected]->bLocked);
paint();
paintItems();
}
std::string CBEBouquetWidget::inputName(const char * const defaultName, const neutrino_locale_t caption)

View File

@@ -1,47 +1,39 @@
/*
Neutrino-GUI - DBoxII-Project
neutrino bouquet editor - bouquets editor
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
Copyright (C) 2017 Sven Hoefer
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 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.
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __bouqueteditor_bouquets__
#define __bouqueteditor_bouquets__
#include <gui/widget/menue.h>
#include <zapit/client/zapitclient.h>
#include <zapit/channel.h>
#include <zapit/bouquets.h>
#include <gui/components/cc.h>
#include <gui/widget/listhelpers.h>
#include <string>
class CFrameBuffer;
#include <gui/components/cc.h>
#include <gui/widget/listhelpers.h>
#include <gui/widget/menue.h>
#include <zapit/bouquets.h>
#include <zapit/channel.h>
#include <zapit/client/zapitclient.h>
#include "bouqueteditor_globals.h"
/* class for handling when bouquets changed. */
/* This class should be a temporarily work around */
/* and should be replaced by standard neutrino event handlers */
@@ -52,13 +44,9 @@ public:
virtual void onBouquetsChanged() {};
};
class CBEBouquetWidget : public CMenuTarget, public CListHelpers
class CBEBouquetWidget : public CBEGlobals, public CMenuTarget, public CListHelpers
{
private:
CFrameBuffer *frameBuffer;
CComponentsFooter footer;
enum
{
beDefault,
@@ -70,23 +58,15 @@ class CBEBouquetWidget : public CMenuTarget, public CListHelpers
unsigned int newPosition;
unsigned int liststart;
unsigned int listmaxshow;
int fheight; // Fonthoehe Bouquetlist-Inhalt
int theight; // Fonthoehe Bouquetlist-Titel
int ButtonHeight;
int iconoffset;
int iheight; // item height
//std::string name;
bool bouquetsChanged;
int width;
int height;
int x;
int y;
void paintItem(int pos);
void paint();
bool bouquetsChanged;
void paintHead();
void paintBody();
void paintItem(int pos);
void paintItems();
void paintFoot();
void hide();
void updateSelection(unsigned int newpos);
@@ -96,7 +76,7 @@ class CBEBouquetWidget : public CMenuTarget, public CListHelpers
void beginMoveBouquet();
void finishMoveBouquet();
void cancelMoveBouquet();
void internalMoveBouquet( unsigned int fromPosition, unsigned int toPosition);
void internalMoveBouquet(unsigned int fromPosition, unsigned int toPosition);
void renameBouquet();
void switchHideBouquet();
void switchLockBouquet();
@@ -104,7 +84,7 @@ class CBEBouquetWidget : public CMenuTarget, public CListHelpers
void saveChanges();
void discardChanges();
std::string inputName(const char * const defaultName, const neutrino_locale_t caption);
std::string inputName(const char* const defaultName, const neutrino_locale_t caption);
public:
CBEBouquetWidget();
@@ -114,5 +94,4 @@ class CBEBouquetWidget : public CMenuTarget, public CListHelpers
int exec(CMenuTarget* parent, const std::string & actionKey);
};
#endif

View File

@@ -1,81 +1,55 @@
/*
Neutrino-GUI - DBoxII-Project
neutrino bouquet editor - channels editor
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Copyright (C) 2011 CoolStream International Ltd
Copyright (C) 2009,2011,2013,2016 Stefan Seyfried
Copyright (C) 2017 Sven Hoefer
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 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.
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gui/widget/msgbox.h>
#include "bouqueteditor_channels.h"
#include <global.h>
#include <neutrino.h>
#include <driver/fontrenderer.h>
#include <driver/screen_max.h>
#include "bouqueteditor_chanselect.h"
#include <gui/components/cc.h>
#include <gui/widget/icons.h>
#include <gui/widget/stringinput.h>
#include <gui/widget/keyboard_input.h>
#include <zapit/getservices.h>
#include <gui/widget/msgbox.h>
#include <gui/widget/stringinput.h>
#include <zapit/femanager.h>
#include <zapit/getservices.h>
#include "bouqueteditor_channels.h"
#include "bouqueteditor_chanselect.h"
extern CBouquetManager *g_bouquetManager;
CBEChannelWidget::CBEChannelWidget(const std::string & Caption, unsigned int Bouquet)
{
int icol_w, icol_h;
frameBuffer = CFrameBuffer::getInstance();
selected = 0;
iconoffset = 0;
origPosition = 0;
newPosition = 0;
listmaxshow = 0;
numwidth = 0;
info_height = 0;
channelsChanged = false;
width = 0;
height = 0;
x = 0;
y = 0;
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
footerHeight= footer.getHeight();
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_YELLOW, &icol_w, &icol_h);
iheight = std::max(fheight, icol_h+2);
iconoffset = std::max(iconoffset, icol_w);
frameBuffer->getIconSize(NEUTRINO_ICON_LOCK, &icol_w, &icol_h);
iheight = std::max(fheight, icol_h+2);
iconoffset = std::max(iconoffset, icol_w);
liststart = 0;
state = beDefault;
caption = Caption;
@@ -84,6 +58,18 @@ CBEChannelWidget::CBEChannelWidget(const std::string & Caption, unsigned int Bou
dline = NULL;
ibox = NULL;
Channels = NULL;
int iw, ih;
action_icon_width = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_DUMMY_SMALL, &action_icon_width, &ih);
status_icon_width = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
frameBuffer->getIconSize(NEUTRINO_ICON_STREAMING, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
frameBuffer->getIconSize(NEUTRINO_ICON_LOCK, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
}
CBEChannelWidget::~CBEChannelWidget()
@@ -94,7 +80,7 @@ CBEChannelWidget::~CBEChannelWidget()
void CBEChannelWidget::paintItem(int pos)
{
int ypos = y+ theight+0 + pos*iheight;
int ypos = y + header_height + pos*item_height;
unsigned int current = liststart + pos;
bool i_selected = current == selected;
@@ -108,10 +94,8 @@ void CBEChannelWidget::paintItem(int pos)
if (i_selected)
{
if (current < Channels->size())
{
initItem2DetailsLine(pos, current);
paintDetails(current);
}
paintDetails(pos, current);
i_radius = RADIUS_LARGE;
}
else
@@ -121,70 +105,133 @@ void CBEChannelWidget::paintItem(int pos)
}
if (i_radius)
frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, bgcolor, i_radius);
frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius);
if ((current == selected) && (state == beMoving)) {
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + OFFSET_INNER_MID, ypos, iheight);
}
if (current < Channels->size()) {
if ((*Channels)[current]->bLocked) {
frameBuffer->paintIcon(NEUTRINO_ICON_LOCK, x + OFFSET_INNER_MID + iconoffset, ypos, iheight);
}
//FIXME numwidth ? we not show chan numbers
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 2*OFFSET_INNER_MID + 2*iconoffset, ypos + iheight - (iheight-fheight)/2, width - 3*OFFSET_INNER_MID - 2*iconoffset, (*Channels)[current]->getName(), color);
if((*Channels)[current]->scrambled)
frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iconoffset, ypos, fheight);
if (current < Channels->size())
{
if ((i_selected) && (state == beMoving))
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + OFFSET_INNER_MID, ypos, item_height);
else
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_DUMMY_SMALL, x + OFFSET_INNER_MID, ypos, item_height);
int text_offset = 2*OFFSET_INNER_MID + action_icon_width;
item_font->RenderString(x + text_offset, ypos + item_height, width - text_offset - SCROLLBAR_WIDTH - 3*OFFSET_INNER_MID - 2*status_icon_width, (*Channels)[current]->getName(), color);
if ((*Channels)[current]->scrambled)
frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - status_icon_width, ypos, item_height);
else if (!(*Channels)[current]->getUrl().empty())
frameBuffer->paintIcon(NEUTRINO_ICON_STREAMING, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iconoffset, ypos, fheight);
frameBuffer->paintIcon(NEUTRINO_ICON_STREAMING, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - status_icon_width, ypos, item_height);
if ((*Channels)[current]->bLocked)
frameBuffer->paintIcon(NEUTRINO_ICON_LOCK, x + width - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - 2*status_icon_width, ypos, item_height);
}
}
void CBEChannelWidget::paint()
void CBEChannelWidget::paintItems()
{
liststart = (selected/listmaxshow)*listmaxshow;
int lastnum = liststart + listmaxshow;
liststart = (selected/items_count)*items_count;
numwidth = 0;
int maxDigitWidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getMaxDigitWidth();
int _lastnum = lastnum;
while (_lastnum) {
numwidth += maxDigitWidth;
_lastnum /= 10;
}
for(unsigned int count=0;count<listmaxshow;count++)
{
for(unsigned int count = 0; count < items_count; count++)
paintItem(count);
}
int total_pages;
int current_page;
getScrollBarData(&total_pages, &current_page, Channels->size(), listmaxshow, selected);
paintScrollBar(x + width - SCROLLBAR_WIDTH, y + theight, SCROLLBAR_WIDTH, iheight*listmaxshow, total_pages, current_page);
getScrollBarData(&total_pages, &current_page, Channels->size(), items_count, selected);
paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, body_height, total_pages, current_page);
}
void CBEChannelWidget::paintBody()
{
PaintBoxRel(x, y + header_height, width, body_height, COL_MENUCONTENT_PLUS_0, RADIUS_NONE, CORNER_NONE, CC_SHADOW_ON);
}
void CBEChannelWidget::paintHead()
{
CComponentsHeader header(x, y, width, theight, caption, "" /*no header icon*/, CComponentsHeader::CC_BTN_EXIT);
header.setCaption(caption + (mode == CZapitClient::MODE_TV ? " - TV" : " - Radio"));
header.setIcon(NULL); // trick the cc-header
header.setIcon(mode == CZapitClient::MODE_TV ? NEUTRINO_ICON_VIDEO : NEUTRINO_ICON_AUDIO);
header.setDimensionsAll(x, y, width, header_height);
header.setCorner(RADIUS_LARGE, CORNER_TOP);
header.enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true);
header.paint(CC_SAVE_SCREEN_NO);
}
const struct button_label CBEChannelWidgetButtons[6] =
const struct button_label CBEChannelWidgetButtons[] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_BOUQUETEDITOR_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_BOUQUETEDITOR_ADD },
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_BOUQUETEDITOR_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_BOUQUETEDITOR_ADD },
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOUQUETEDITOR_MOVE },
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_BOUQUETEDITOR_RENAME },
{ NEUTRINO_ICON_BUTTON_BLUE, LOCALE_BOUQUETEDITOR_RENAME },
{ NEUTRINO_ICON_BUTTON_DUMMY_SMALL, LOCALE_BOUQUETEDITOR_SWITCHMODE },
//{ NEUTRINO_ICON_BUTTON_FORWARD , LOCALE_BOUQUETEDITOR_MOVE_TO }, // TODO upgrade
{ NEUTRINO_ICON_BUTTON_STOP , LOCALE_BOUQUETEDITOR_LOCK }
// { NEUTRINO_ICON_BUTTON_FORWARD, LOCALE_BOUQUETEDITOR_MOVE_TO }, // TODO upgrade
{ NEUTRINO_ICON_BUTTON_STOP, LOCALE_BOUQUETEDITOR_LOCK }
};
void CBEChannelWidget::paintFoot()
{
size_t numbuttons = sizeof(CBEChannelWidgetButtons)/sizeof(CBEChannelWidgetButtons[0]);
footer.paintButtons(x, y + (height-footerHeight), width, footerHeight, numbuttons, CBEChannelWidgetButtons, width/numbuttons-2*OFFSET_INNER_MID);
footer.enableShadow(CC_SHADOW_ON, -1, true);
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);
if (dline)
dline->kill();
if (ibox)
ibox->kill();
}
std::string CBEChannelWidget::getInfoText(int index)
@@ -192,83 +239,26 @@ std::string CBEChannelWidget::getInfoText(int index)
std::string res = "";
std::string satname = CServiceManager::getInstance()->GetSatelliteName((*Channels)[index]->getSatellitePosition());
if (IS_WEBTV((*Channels)[index]->getChannelID()))
satname = "WebTV";
transponder t;
CServiceManager::getInstance()->GetTransponder((*Channels)[index]->getTransponderId(), t);
std::string desc = t.description();
if((*Channels)[index]->pname)
desc = desc + " (" + std::string((*Channels)[index]->pname) + ")";
if ((*Channels)[index]->pname)
{
if (desc.empty())
desc = std::string((*Channels)[index]->pname);
else
desc = desc + " (" + satname + ")";
desc += " (" + std::string((*Channels)[index]->pname) + ")";
}
if (!(*Channels)[index]->getDesc().empty())
desc += "\n" + (*Channels)[index]->getDesc();
res = satname + " " + desc;
res = satname + " - " + desc;
return res;
}
void CBEChannelWidget::paintDetails(int index)
{
//details line
dline->paint(CC_SAVE_SCREEN_NO);
std::string str = getInfoText(index);
//info box
ibox->setText(str, CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]);
ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0);
ibox->setTextColor(COL_MENUCONTENTDARK_TEXT);
ibox->paint(CC_SAVE_SCREEN_NO);
}
void CBEChannelWidget::initItem2DetailsLine (int pos, int /*ch_index*/)
{
int xpos = x - DETAILSLINE_WIDTH;
int ypos1 = y + theight+0 + pos*iheight;
int ypos2 = y + height + OFFSET_INTER;
int ypos1a = ypos1 + (fheight/2);
int ypos2a = ypos2 + (info_height/2);
if (dline)
dline->kill(); //kill details line
// init Line if detail info (and not valid list pos)
if (pos >= 0)
{
if (dline == NULL)
dline = new CComponentsDetailsLine(xpos, ypos1a, ypos2a, fheight/2, info_height-RADIUS_LARGE*2);
dline->setYPos(ypos1a);
//infobox
if (ibox == NULL){
ibox = new CComponentsInfoBox();
}
if (ibox->isPainted())
ibox->hide();
ibox->setDimensionsAll(x, ypos2, width, info_height);
ibox->setFrameThickness(FRAME_WIDTH_MIN);
#if 0
ibox->paint(false,true);
#endif
ibox->setCorner(RADIUS_LARGE);
ibox->disableShadow();
}
}
void CBEChannelWidget::clearItem2DetailsLine()
{
if (dline)
dline->kill(); //kill details line
if (ibox)
ibox->kill(); //kill info box
}
void CBEChannelWidget::hide()
{
frameBuffer->paintBackgroundBoxRel(x,y, width,height+footerHeight);
clearItem2DetailsLine ();
}
void CBEChannelWidget::updateSelection(unsigned int newpos)
{
if (newpos == selected || newpos == (unsigned int)-1)
@@ -277,16 +267,22 @@ void CBEChannelWidget::updateSelection(unsigned int newpos)
unsigned int prev_selected = selected;
selected = newpos;
if (state == beDefault) {
if (state == beDefault)
{
unsigned int oldliststart = liststart;
liststart = (selected/listmaxshow)*listmaxshow;
if(oldliststart!=liststart) {
paint();
} else {
liststart = (selected/items_count)*items_count;
if (oldliststart != liststart)
{
paintItems();
}
else
{
paintItem(prev_selected - liststart);
paintItem(selected - liststart);
}
} else {
}
else
{
internalMoveChannel(prev_selected, selected);
}
}
@@ -301,43 +297,32 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
if (parent)
parent->hide();
width = frameBuffer->getScreenWidthRel();
info_height = 2*iheight + 4;
height = frameBuffer->getScreenHeightRel() - info_height;
listmaxshow = (height-theight-footerHeight-0)/iheight;
height = theight+footerHeight+listmaxshow*iheight; // recalc height
x = getScreenStartX(width);
if (x < DETAILSLINE_WIDTH)
x = DETAILSLINE_WIDTH;
y = getScreenStartY(height + info_height);
mode = CZapitClient::MODE_TV;
if (g_bouquetManager->Bouquets[bouquet]->tvChannels.empty())
mode = CZapitClient::MODE_RADIO;
else if (g_bouquetManager->Bouquets[bouquet]->radioChannels.empty())
mode = CZapitClient::MODE_TV;
Channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
channelsChanged = false;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]);
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
bool loop=true;
bool loop = true;
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);
if ( msg <= CRCInput::RC_MaxRC )
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]);
if (msg <= CRCInput::RC_MaxRC)
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
if ((msg == CRCInput::RC_timeout) ||
(msg == (neutrino_msg_t)g_settings.key_channelList_cancel))
if ((msg == CRCInput::RC_timeout) || (msg == (neutrino_msg_t)g_settings.key_channelList_cancel))
{
if (state == beDefault)
{
@@ -351,33 +336,37 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
else if (msg == CRCInput::RC_up || msg == (neutrino_msg_t)g_settings.key_pageup ||
msg == CRCInput::RC_down || msg == (neutrino_msg_t)g_settings.key_pagedown)
{
int new_selected = UpDownKey(*Channels, msg, listmaxshow, selected);
int new_selected = UpDownKey(*Channels, msg, items_count, selected);
updateSelection(new_selected);
}
else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end) {
if (!(Channels->empty())) {
else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end)
{
if (!(Channels->empty()))
{
int new_selected = msg == (neutrino_msg_t) g_settings.key_list_start ? 0 : Channels->size() - 1;
updateSelection(new_selected);
}
}
else if(msg==CRCInput::RC_red)
else if (msg == CRCInput::RC_red)
{
if (state == beDefault)
deleteChannel();
}
else if(msg==CRCInput::RC_green)
else if (msg == CRCInput::RC_green)
{
if (state == beDefault)
addChannel();
}
else if(msg==CRCInput::RC_yellow)
else if (msg == CRCInput::RC_yellow)
{
liststart = (selected/listmaxshow)*listmaxshow;
liststart = (selected/items_count)*items_count;
if (state == beDefault)
beginMoveChannel();
else if (state == beMoving)
finishMoveChannel();
paintItem(selected - liststart);
}
else if(msg==CRCInput::RC_blue)
else if (msg == CRCInput::RC_blue)
{
if (selected < Channels->size()) /* Channels->size() might be 0 */
{
@@ -385,7 +374,7 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
renameChannel();
}
}
else if(msg==CRCInput::RC_stop)
else if (msg == CRCInput::RC_stop)
{
if (selected < Channels->size()) /* Channels->size() might be 0 */
{
@@ -394,7 +383,7 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
}
}
/* TODO upgrade
else if (msg == CRCInput::RC_forward )
else if (msg == CRCInput::RC_forward)
{
if (selected < Channels->size())
{
@@ -403,38 +392,48 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
}
}
*/
else if( msg == (neutrino_msg_t) g_settings.key_tvradio_mode || msg==CRCInput::RC_tv ) {
else if (msg == (neutrino_msg_t) g_settings.key_tvradio_mode || msg == CRCInput::RC_tv || msg == CRCInput::RC_radio)
{
if (msg == CRCInput::RC_radio)
mode = CZapitClient::MODE_RADIO;
else if (msg == CRCInput::RC_tv)
mode = CZapitClient::MODE_TV;
else // g_settings.key_tvradio_mode
{
if (mode == CZapitClient::MODE_TV)
mode = CZapitClient::MODE_RADIO;
else
mode = CZapitClient::MODE_TV;
}
Channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
selected = 0;
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
}
else if(msg==CRCInput::RC_ok)
else if (msg == CRCInput::RC_ok)
{
if (state == beDefault)
{
if (selected < Channels->size()) /* Channels.size() might be 0 */
g_Zapit->zapTo_serviceID((*Channels)[selected]->getChannelID());
} else if (state == beMoving) {
}
else if (state == beMoving)
{
finishMoveChannel();
}
}
else if( CRCInput::isNumeric(msg) )
else if (CRCInput::isNumeric(msg))
{
if (state == beDefault)
{
//kein pushback - wenn man versehentlich wo draufkommt is die edit-arbeit umsonst
//selected = oldselected;
//g_RCInput->postMsg( msg, data );
//g_RCInput->postMsg(msg, data);
//loop=false;
}
else if (state == beMoving)
@@ -448,7 +447,7 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
}
else
{
CNeutrinoApp::getInstance()->handleMsg( msg, data );
CNeutrinoApp::getInstance()->handleMsg(msg, data);
}
}
hide();
@@ -470,7 +469,7 @@ void CBEChannelWidget::deleteChannel()
if (selected >= Channels->size())
selected = Channels->empty() ? 0 : (Channels->size() - 1);
channelsChanged = true;
paint();
paintItems();
}
void CBEChannelWidget::renameChannel()
@@ -479,7 +478,7 @@ void CBEChannelWidget::renameChannel()
if (newName != (*Channels)[selected]->getName())
{
if(newName.empty())
if (newName.empty())
(*Channels)[selected]->setUserName("");
else
(*Channels)[selected]->setUserName(newName);
@@ -487,8 +486,9 @@ void CBEChannelWidget::renameChannel()
channelsChanged = true;
}
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
}
void CBEChannelWidget::switchLockChannel()
@@ -513,8 +513,9 @@ void CBEChannelWidget::addChannel()
}
delete channelSelectWidget;
paintHead();
paint();
paintBody();
paintFoot();
paintItems();
}
void CBEChannelWidget::beginMoveChannel()
@@ -528,13 +529,13 @@ void CBEChannelWidget::finishMoveChannel()
{
state = beDefault;
channelsChanged = channelsChanged | true;
paint();
paintItems();
}
void CBEChannelWidget::cancelMoveChannel()
{
state = beDefault;
internalMoveChannel( newPosition, origPosition);
internalMoveChannel(newPosition, origPosition);
channelsChanged = channelsChanged | false;
}
/* TODO upgrade (taken from channellist.cpp)
@@ -543,25 +544,26 @@ void CBEChannelWidget::moveChannelToBouquet()
if (addChannelToBouquet())
deleteChannel(false);
else
paint();
paintItems();
paintHead();
}
*/
void CBEChannelWidget::internalMoveChannel( unsigned int fromPosition, unsigned int toPosition)
void CBEChannelWidget::internalMoveChannel(unsigned int fromPosition, unsigned int toPosition)
{
if ( (int) toPosition == -1 ) return;
if ( toPosition == Channels->size()) return;
if ((int) toPosition == -1)
return;
if (toPosition == Channels->size())
return;
g_bouquetManager->Bouquets[bouquet]->moveService(fromPosition, toPosition,
mode == CZapitClient::MODE_TV ? 1 : 2);
g_bouquetManager->Bouquets[bouquet]->moveService(fromPosition, toPosition, mode == CZapitClient::MODE_TV ? 1 : 2);
//channelsChanged = true;
Channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
selected = toPosition;
newPosition = toPosition;
paint();
paintItems();
}
std::string CBEChannelWidget::inputName(const char * const defaultName, const neutrino_locale_t _caption)
@@ -578,5 +580,5 @@ std::string CBEChannelWidget::inputName(const char * const defaultName, const ne
bool CBEChannelWidget::hasChanged()
{
return (channelsChanged);
return channelsChanged;
}

View File

@@ -1,56 +1,46 @@
/*
Neutrino-GUI - DBoxII-Project
neutrino bouquet editor - channels editor
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
Copyright (C) 2017 Sven Hoefer
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 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.
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __bouqueteditor_channels__
#define __bouqueteditor_channels__
#include <gui/widget/menue.h>
#include <gui/widget/listhelpers.h>
#include <string>
#include <gui/components/cc.h>
#include <gui/widget/listhelpers.h>
#include <gui/widget/menue.h>
#include <zapit/bouquets.h>
#include <zapit/channel.h>
#include <zapit/client/zapitclient.h>
#include <string>
#include <zapit/channel.h>
#include <zapit/bouquets.h>
#include "bouqueteditor_globals.h"
class CFrameBuffer;
class CBEChannelWidget : public CMenuTarget, public CListHelpers
class CBEChannelWidget : public CBEGlobals, public CMenuTarget, public CListHelpers
{
private:
CFrameBuffer *frameBuffer;
CComponentsDetailsLine *dline;
CComponentsInfoBox *ibox;
CComponentsFooter footer;
enum state_
{
beDefault,
@@ -60,36 +50,21 @@ class CBEChannelWidget : public CMenuTarget, public CListHelpers
unsigned int selected;
unsigned int origPosition;
unsigned int newPosition;
unsigned int liststart;
unsigned int listmaxshow;
unsigned int numwidth;
int fheight;
int theight;
int iconoffset;
int iheight; // item height
int footerHeight;
int info_height;
std::string caption;
bool channelsChanged;
std::string caption;
CZapitClient::channelsMode mode;
unsigned int bouquet;
int width;
int height;
int x;
int y;
void paintItem(int pos);
void paintDetails(int index);
void initItem2DetailsLine (int pos, int ch_index);
void clearItem2DetailsLine ();
void paint();
void paintHead();
void paintBody();
void paintItem(int pos);
void paintItems();
void paintFoot();
void paintDetails(int pos, int current);
void hide();
void updateSelection(unsigned int newpos);
@@ -101,10 +76,10 @@ class CBEChannelWidget : public CMenuTarget, public CListHelpers
void finishMoveChannel();
void cancelMoveChannel();
void moveChannelToBouquet();
void internalMoveChannel( unsigned int fromPosition, unsigned int toPosition);
void internalMoveChannel(unsigned int fromPosition, unsigned int toPosition);
std::string getInfoText(int index);
std::string inputName(const char * const defaultName, const neutrino_locale_t caption);
std::string inputName(const char* const defaultName, const neutrino_locale_t caption);
public:
CBEChannelWidget( const std::string & Caption, unsigned int Bouquet);

View File

@@ -1,32 +1,23 @@
/*
Neutrino-GUI - DBoxII-Project
neutrino bouquet editor - channel selection
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
Copyright (C) 2017 Sven Hoefer
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 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.
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -34,47 +25,41 @@
#endif
#include <unistd.h>
#include <global.h>
#include <neutrino.h>
#include "bouqueteditor_chanselect.h"
#include <driver/fontrenderer.h>
#include <driver/screen_max.h>
#include <gui/widget/icons.h>
#include <zapit/zapit.h>
#include <zapit/getservices.h>
#include <zapit/zapit.h>
#include "bouqueteditor_chanselect.h"
extern CBouquetManager *g_bouquetManager;
CBEChannelSelectWidget::CBEChannelSelectWidget(const std::string & Caption, CZapitBouquet* Bouquet, CZapitClient::channelsMode Mode)
:CListBox(Caption.c_str())
{
int icol_w, icol_h;
caption = Caption;
bouquet = Bouquet;
mode = Mode;
iconoffset = 0;
info_height = 0;
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
footerHeight= footer.getHeight();
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_GREEN, &icol_w, &icol_h);
iheight = std::max(fheight, icol_h+2);
iconoffset = std::max(iconoffset, icol_w);
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_OKAY, &icol_w, &icol_h);
ButtonHeight = std::max(footerHeight, icol_h+4);
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_HOME, &icol_w, &icol_h);
ButtonHeight = std::max(footerHeight, icol_h+4);
selected = 0;
liststart = 0;
channellist_sort_mode = SORT_ALPHA;
bouquetChannels = NULL;
dline = NULL;
ibox = new CComponentsInfoBox();
ibox = NULL;
int iw, ih;
action_icon_width = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_DUMMY_SMALL, &action_icon_width, &ih);
status_icon_width = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
frameBuffer->getIconSize(NEUTRINO_ICON_STREAMING, &iw, &ih);
status_icon_width = std::max(status_icon_width, iw);
}
CBEChannelSelectWidget::~CBEChannelSelectWidget()
@@ -83,12 +68,355 @@ CBEChannelSelectWidget::~CBEChannelSelectWidget()
delete ibox;
}
uint CBEChannelSelectWidget::getItemCount()
void CBEChannelSelectWidget::paintItem(int pos)
{
return Channels.size();
int ypos = y + header_height + pos*item_height;
unsigned int current = liststart + pos;
bool i_selected = current == selected;
int i_radius = RADIUS_NONE;
fb_pixel_t color;
fb_pixel_t bgcolor;
getItemColors(color, bgcolor, i_selected);
if (i_selected)
{
if (current < Channels.size())
paintDetails(pos, current);
i_radius = RADIUS_LARGE;
}
else
{
if (current < Channels.size() && (Channels[current]->flags & CZapitChannel::NOT_PRESENT))
color = COL_MENUCONTENTINACTIVE_TEXT;
}
if (i_radius)
frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius);
if (current < Channels.size())
{
if (isChannelInBouquet(current))
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_GREEN, x + OFFSET_INNER_MID, ypos, item_height);
else
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_DUMMY_SMALL, x + OFFSET_INNER_MID, ypos, item_height);
int text_offset = 2*OFFSET_INNER_MID + action_icon_width;
item_font->RenderString(x + text_offset, ypos + item_height, width - text_offset - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - status_icon_width, Channels[current]->getName(), color);
if (Channels[current]->scrambled)
frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - status_icon_width, ypos, item_height);
else if (!Channels[current]->getUrl().empty())
frameBuffer->paintIcon(NEUTRINO_ICON_STREAMING, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - status_icon_width, ypos, item_height);
}
}
bool CBEChannelSelectWidget::isChannelInBouquet( int index)
void CBEChannelSelectWidget::paintItems()
{
liststart = (selected/items_count)*items_count;
for(unsigned int count = 0; count < items_count; count++)
paintItem(count);
int total_pages;
int current_page;
getScrollBarData(&total_pages, &current_page, Channels.size(), items_count, selected);
paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, body_height, total_pages, current_page);
}
void CBEChannelSelectWidget::paintBody()
{
PaintBoxRel(x, y + header_height, width, body_height, COL_MENUCONTENT_PLUS_0, RADIUS_NONE, CORNER_NONE, CC_SHADOW_ON);
}
void CBEChannelSelectWidget::paintHead()
{
header.setCaption(caption + (mode == CZapitClient::MODE_TV ? " - TV" : " - Radio"));
header.setIcon(NULL); // trick the cc-header
header.setIcon(mode == CZapitClient::MODE_TV ? NEUTRINO_ICON_VIDEO : NEUTRINO_ICON_AUDIO);
header.setDimensionsAll(x, y, width, header_height);
header.setCorner(RADIUS_LARGE, CORNER_TOP);
header.enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true);
header.paint(CC_SAVE_SCREEN_NO);
}
struct button_label CBEChannelSelectButtons[] =
{
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_CHANNELLIST_FOOT_SORT_ALPHA },
{ NEUTRINO_ICON_BUTTON_OKAY, LOCALE_BOUQUETEDITOR_SWITCH },
{ NEUTRINO_ICON_BUTTON_HOME, LOCALE_BOUQUETEDITOR_RETURN }
};
void CBEChannelSelectWidget::paintFoot()
{
switch (channellist_sort_mode)
{
case SORT_FREQ:
{
CBEChannelSelectButtons[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_FREQ;
break;
}
case SORT_SAT:
{
CBEChannelSelectButtons[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_SAT;
break;
}
case SORT_CH_NUMBER:
{
CBEChannelSelectButtons[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_CHNUM;
break;
}
case SORT_ALPHA:
default:
{
CBEChannelSelectButtons[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_ALPHA;
break;
}
}
const short numbuttons = sizeof(CBEChannelSelectButtons)/sizeof(CBEChannelSelectButtons[0]);
footer.enableShadow(CC_SHADOW_ON, -1, true);
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);
if (dline)
dline->kill();
if (ibox)
ibox->kill();
}
std::string CBEChannelSelectWidget::getInfoText(int index)
{
std::string res = "";
std::string satname = CServiceManager::getInstance()->GetSatelliteName(Channels[index]->getSatellitePosition());
if (IS_WEBTV(Channels[index]->getChannelID()))
satname = "WebTV";
transponder t;
CServiceManager::getInstance()->GetTransponder(Channels[index]->getTransponderId(), t);
std::string desc = t.description();
if (Channels[index]->pname)
{
if (desc.empty())
desc = std::string(Channels[index]->pname);
else
desc += " (" + std::string(Channels[index]->pname) + ")";
}
if (!Channels[index]->getDesc().empty())
desc += "\n" + Channels[index]->getDesc();
res = satname + " - " + desc;
return res;
}
void CBEChannelSelectWidget::updateSelection(unsigned int newpos)
{
if (newpos == selected || newpos == (unsigned int)-1)
return;
unsigned int prev_selected = selected;
selected = newpos;
unsigned int oldliststart = liststart;
liststart = (selected/items_count)*items_count;
if (oldliststart != liststart)
{
paintItems();
}
else
{
paintItem(prev_selected - liststart);
paintItem(selected - liststart);
}
}
int CBEChannelSelectWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*/)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = menu_return::RETURN_REPAINT;
selected = 0;
if (parent)
parent->hide();
bouquetChannels = mode == CZapitClient::MODE_TV ? &(bouquet->tvChannels) : &(bouquet->radioChannels);
Channels.clear();
if (mode == CZapitClient::MODE_RADIO)
CServiceManager::getInstance()->GetAllRadioChannels(Channels);
else
CServiceManager::getInstance()->GetAllTvChannels(Channels);
sort(Channels.begin(), Channels.end(), CmpChannelByChName());
paintHead();
paintBody();
paintFoot();
paintItems();
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
channelChanged = false;
bool loop = true;
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);
if (msg <= CRCInput::RC_MaxRC)
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
if ((msg == (neutrino_msg_t)g_settings.key_channelList_cancel) || (msg == CRCInput::RC_home))
{
loop = false;
}
else if (msg == CRCInput::RC_up || msg == (neutrino_msg_t)g_settings.key_pageup ||
msg == CRCInput::RC_down || msg == (neutrino_msg_t)g_settings.key_pagedown)
{
int new_selected = UpDownKey(Channels, msg, items_count, selected);
updateSelection(new_selected);
}
else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end)
{
if (!Channels.empty())
{
int new_selected = msg == (neutrino_msg_t) g_settings.key_list_start ? 0 : Channels.size() - 1;
updateSelection(new_selected);
}
}
else if (msg == CRCInput::RC_ok || msg == CRCInput::RC_green)
{
if (selected < Channels.size())
selectChannel();
}
else if (msg == CRCInput::RC_red)
{
if (selected < Channels.size())
sortChannels();
}
else if (CNeutrinoApp::getInstance()->listModeKey(msg))
{
// do nothing
}
else
{
CNeutrinoApp::getInstance()->handleMsg(msg, data);
}
}
hide();
return res;
}
void CBEChannelSelectWidget::sortChannels()
{
channellist_sort_mode++;
if (channellist_sort_mode >= SORT_END)
channellist_sort_mode = SORT_ALPHA;
switch (channellist_sort_mode)
{
case SORT_FREQ:
{
sort(Channels.begin(), Channels.end(), CmpChannelByFreq());
break;
}
case SORT_SAT:
{
sort(Channels.begin(), Channels.end(), CmpChannelBySat());
break;
}
case SORT_CH_NUMBER:
{
sort(Channels.begin(), Channels.end(), CmpChannelByChNum());
break;
}
case SORT_ALPHA:
default:
{
sort(Channels.begin(), Channels.end(), CmpChannelByChName());
break;
}
}
paintFoot();
paintItems();
}
void CBEChannelSelectWidget::selectChannel()
{
channelChanged = true;
if (isChannelInBouquet(selected))
bouquet->removeService(Channels[selected]);
else
bouquet->addService(Channels[selected]);
bouquetChannels = mode == CZapitClient::MODE_TV ? &(bouquet->tvChannels) : &(bouquet->radioChannels);
paintItem(selected - liststart);
g_RCInput->postMsg(CRCInput::RC_down, 0);
}
bool CBEChannelSelectWidget::isChannelInBouquet(int index)
{
for (unsigned int i=0; i< bouquetChannels->size(); i++)
{
@@ -100,223 +428,5 @@ bool CBEChannelSelectWidget::isChannelInBouquet( int index)
bool CBEChannelSelectWidget::hasChanged()
{
return modified;
}
void CBEChannelSelectWidget::paintItem(uint32_t itemNr, int paintNr, bool pselected)
{
int ypos = y+ theight + paintNr*iheight;
int i_radius = RADIUS_NONE;
fb_pixel_t color;
fb_pixel_t bgcolor;
getItemColors(color, bgcolor, pselected);
if (pselected)
{
if (itemNr < getItemCount())
{
initItem2DetailsLine (paintNr, itemNr);
paintDetails(itemNr);
}
i_radius = RADIUS_LARGE;
}
else
{
if (itemNr < getItemCount() && (Channels[itemNr]->flags & CZapitChannel::NOT_PRESENT))
color = COL_MENUCONTENTINACTIVE_TEXT;
}
if (i_radius)
frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, bgcolor, i_radius);
if(itemNr < getItemCount())
{
if( isChannelInBouquet(itemNr))
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_GREEN, x + OFFSET_INNER_MID, ypos, iheight);
else
frameBuffer->paintBoxRel(x + OFFSET_INNER_MID, ypos, iconoffset, iheight, bgcolor);
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 2*OFFSET_INNER_MID + 2*iconoffset, ypos + iheight - (iheight-fheight)/2, width - 3*OFFSET_INNER_MID - 2*iconoffset, Channels[itemNr]->getName(), color);
if(Channels[itemNr]->scrambled)
frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iconoffset, ypos, fheight);
else if (!Channels[itemNr]->getUrl().empty())
frameBuffer->paintIcon(NEUTRINO_ICON_STREAMING, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iconoffset, ypos, fheight);
}
}
void CBEChannelSelectWidget::onOkKeyPressed()
{
if (selected >= Channels.size())
return;
setModified();
if (isChannelInBouquet(selected))
bouquet->removeService(Channels[selected]);
else
bouquet->addService(Channels[selected]);
bouquetChannels = mode == CZapitClient::MODE_TV ? &(bouquet->tvChannels) : &(bouquet->radioChannels);
paintItem( selected, selected - liststart, false);
g_RCInput->postMsg( CRCInput::RC_down, 0 );
}
void CBEChannelSelectWidget::onRedKeyPressed()
{
if (selected >= Channels.size())
return;
channellist_sort_mode++;
if(channellist_sort_mode > SORT_END)
channellist_sort_mode = 0;
switch(channellist_sort_mode)
{
case SORT_ALPHA:
sort(Channels.begin(), Channels.end(), CmpChannelByChName());
break;
case SORT_FREQ:
sort(Channels.begin(), Channels.end(), CmpChannelByFreq());
break;
case SORT_SAT:
sort(Channels.begin(), Channels.end(), CmpChannelBySat());
break;
case SORT_CH_NUMBER:
sort(Channels.begin(), Channels.end(), CmpChannelByChNum());
break;
default:
sort(Channels.begin(), Channels.end(), CmpChannelByChName());
break;
}
paintFoot();
paint();
}
int CBEChannelSelectWidget::exec(CMenuTarget* parent, const std::string & actionKey)
{
width = frameBuffer->getScreenWidthRel();
info_height = 2*iheight + 4;
height = frameBuffer->getScreenHeightRel() - info_height;
listmaxshow = (height-theight-footerHeight-0)/iheight;
height = theight+footerHeight+listmaxshow*iheight; // recalc height
x = getScreenStartX(width);
if (x < DETAILSLINE_WIDTH)
x = DETAILSLINE_WIDTH;
y = getScreenStartY(height + info_height);
bouquetChannels = mode == CZapitClient::MODE_TV ? &(bouquet->tvChannels) : &(bouquet->radioChannels);
Channels.clear();
if (mode == CZapitClient::MODE_RADIO)
CServiceManager::getInstance()->GetAllRadioChannels(Channels);
else
CServiceManager::getInstance()->GetAllTvChannels(Channels);
sort(Channels.begin(), Channels.end(), CmpChannelByChName());
return CListBox::exec(parent, actionKey);
}
const struct button_label CBEChannelSelectButtons[] =
{
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_CHANNELLIST_FOOT_SORT_ALPHA},
{ NEUTRINO_ICON_BUTTON_OKAY, LOCALE_BOUQUETEDITOR_SWITCH },
{ NEUTRINO_ICON_BUTTON_HOME, LOCALE_BOUQUETEDITOR_RETURN }
};
void CBEChannelSelectWidget::paintFoot()
{
const short numbuttons = sizeof(CBEChannelSelectButtons)/sizeof(CBEChannelSelectButtons[0]);
struct button_label Button[numbuttons];
for (int i = 0; i < numbuttons; i++)
Button[i] = CBEChannelSelectButtons[i];
switch (channellist_sort_mode) {
case SORT_ALPHA:
Button[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_ALPHA;
break;
case SORT_FREQ:
Button[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_FREQ;
break;
case SORT_SAT:
Button[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_SAT;
break;
case SORT_CH_NUMBER:
Button[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_CHNUM;
break;
default:
Button[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_ALPHA;
break;
}
footer.paintButtons(x, y + (height-footerHeight), width, footerHeight, numbuttons, Button, width/numbuttons-2*OFFSET_INNER_MID);
}
std::string CBEChannelSelectWidget::getInfoText(int index)
{
std::string res = "";
std::string satname = CServiceManager::getInstance()->GetSatelliteName(Channels[index]->getSatellitePosition());
transponder t;
CServiceManager::getInstance()->GetTransponder(Channels[index]->getTransponderId(), t);
std::string desc = t.description();
if(Channels[index]->pname)
desc = desc + " (" + std::string(Channels[index]->pname) + ")";
else
desc = desc + " (" + satname + ")";
res = satname + " " + desc;
return res;
}
void CBEChannelSelectWidget::paintDetails(int index)
{
//details line
dline->paint(CC_SAVE_SCREEN_NO);
std::string str = getInfoText(index);
//info box
ibox->setText(str, CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]);
ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0);
ibox->setTextColor(COL_MENUCONTENTDARK_TEXT);
ibox->paint(false);
}
void CBEChannelSelectWidget::initItem2DetailsLine (int pos, int /*ch_index*/)
{
int xpos = x - DETAILSLINE_WIDTH;
int ypos1 = y + theight+0 + pos*iheight;
int ypos2 = y + height + OFFSET_INTER;
int ypos1a = ypos1 + (fheight/2);
int ypos2a = ypos2 + (info_height/2);
if (dline)
dline->kill(); //kill details line
// init Line if detail info (and not valid list pos)
if (pos >= 0)
{
if (dline == NULL)
dline = new CComponentsDetailsLine(xpos, ypos1a, ypos2a, fheight/2, info_height-RADIUS_LARGE*2);
dline->setYPos(ypos1a);
//infobox
if (ibox){
ibox->setDimensionsAll(x, ypos2, width, info_height);
ibox->setFrameThickness(FRAME_WIDTH_MIN);
ibox->setCorner(RADIUS_LARGE);
ibox->disableShadow();
}
}
}
void CBEChannelSelectWidget::hide()
{
dline->kill(); //kill details line
ibox->kill();
CListBox::hide();
return channelChanged;
}

View File

@@ -1,76 +1,84 @@
/*
Neutrino-GUI - DBoxII-Project
neutrino bouquet editor - channel selection
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
Copyright (C) 2017 Sven Hoefer
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 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.
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __bouqueteditor_chanselect__
#define __bouqueteditor_chanselect__
#include <gui/widget/listbox.h>
#include <string>
#include <gui/components/cc.h>
#include <gui/widget/listhelpers.h>
#include <gui/widget/menue.h>
#include <zapit/bouquets.h>
#include <zapit/channel.h>
#include <zapit/client/zapitclient.h>
#include <string>
#include <zapit/channel.h>
#include <zapit/bouquets.h>
#include "bouqueteditor_globals.h"
class CBEChannelSelectWidget : public CListBox
class CBEChannelSelectWidget : public CBEGlobals, public CMenuTarget, public CListHelpers
{
private:
CZapitBouquet * bouquet;
short int channellist_sort_mode;
enum{SORT_ALPHA,SORT_FREQ,SORT_SAT,SORT_CH_NUMBER, SORT_END};
CZapitClient::channelsMode mode;
bool isChannelInBouquet( int index);
CComponentsDetailsLine *dline;
CComponentsInfoBox *ibox;
CComponentsFooter footer;
uint getItemCount();
void paintItem(uint32_t itemNr, int paintNr, bool selected);
void paintDetails(int index);
void initItem2DetailsLine (int pos, int ch_index);
void paintFoot();
void onOkKeyPressed();
void onRedKeyPressed();
void hide();
int footerHeight;
int info_height;
enum {
SORT_ALPHA,
SORT_FREQ,
SORT_SAT,
SORT_CH_NUMBER,
SORT_END
};
unsigned int selected;
unsigned int liststart;
CZapitClient::channelsMode mode;
CZapitBouquet * bouquet;
short int channellist_sort_mode;
bool isChannelInBouquet(int index);
bool channelChanged;
std::string caption;
void paintHead();
void paintBody();
void paintItem(int pos);
void paintItems();
void paintFoot();
void paintDetails(int pos, int current);
void hide();
void updateSelection(unsigned int newpos);
void sortChannels();
void selectChannel();
std::string getInfoText(int index);
public:
ZapitChannelList Channels;
ZapitChannelList * bouquetChannels;
public:
CBEChannelSelectWidget(const std::string & Caption, CZapitBouquet* Bouquet, CZapitClient::channelsMode Mode);
~CBEChannelSelectWidget();
ZapitChannelList Channels;
ZapitChannelList * bouquetChannels;
int exec(CMenuTarget* parent, const std::string & actionKey);
bool hasChanged();
};

View File

@@ -0,0 +1,60 @@
/*
neutrino bouquet editor - globals
Copyright (C) 2017 Sven Hoefer
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 <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <global.h>
#include <neutrino.h>
#include <driver/screen_max.h>
#include "bouqueteditor_globals.h"
class CFrameBuffer;
CBEGlobals::CBEGlobals()
{
frameBuffer = CFrameBuffer::getInstance();
item_font = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST];
info_font = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR];
width = frameBuffer->getScreenWidthRel();
height = frameBuffer->getScreenHeightRel();
header_height = header.getHeight();
item_height = item_font->getHeight();
footer_height = footer.getHeight();
info_height = 2*info_font->getHeight() + 2*OFFSET_INNER_SMALL;
items_count = (height - header_height - footer_height - OFFSET_INTER - info_height - 2*OFFSET_SHADOW) / item_height;
body_height = items_count*item_height;
height = header_height + body_height + footer_height + OFFSET_INTER + info_height + 2*OFFSET_SHADOW; // recalc height
x = getScreenStartX(width);
y = getScreenStartY(height);
}
CBEGlobals::~CBEGlobals()
{
}

View File

@@ -0,0 +1,61 @@
/*
neutrino bouquet editor - globals
Copyright (C) 2017 Sven Hoefer
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 <http://www.gnu.org/licenses/>.
*/
#ifndef __bouqueteditor_globals__
#define __bouqueteditor_globals__
#include <driver/fontrenderer.h>
#include <gui/components/cc.h>
class CFrameBuffer;
class CBEGlobals
{
public:
CBEGlobals();
~CBEGlobals();
CFrameBuffer *frameBuffer;
int x;
int y;
int width;
int height;
int header_height;
int body_height;
int item_height;
int footer_height;
int info_height;
CComponentsHeader header;
CComponentsFooter footer;
unsigned int items_count;
Font *item_font;
Font *info_font;
int action_icon_width;
int status_icon_width;
};
#endif