2 Copyright 2004-2007 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "vchannellist.h"
25 #include "vvideolivetv.h"
32 #include "vchannelselect.h"
33 #include "staticartwork.h"
35 static const char* TAG = "VChannelList";
37 VChannelList::VChannelList(ULONG ttype)
39 boxstack = BoxStack::getInstance();
42 if (Video::getInstance()->getFormat() == Video::PAL)
54 if (type == VDR::VIDEO)
56 setTitleText(tr("Channels"));
57 TVMediaInfo *info= new TVMediaInfo();
58 info->setStaticArtwork(sa_tv);
59 setTitleBarIcon(info);
61 else if (type == VDR::RADIO)
63 setTitleText(tr("Radio Stations"));
64 TVMediaInfo *info= new TVMediaInfo();
65 info->setStaticArtwork(sa_radio);
66 setTitleBarIcon(info);
69 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
71 sl.setPosition(10, 30 + 5);
72 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
74 MessageQueue::getInstance()->addReceiver(this);
77 VChannelList::~VChannelList()
79 MessageQueue::getInstance()->removeReceiver(this);
82 void VChannelList::setList(std::shared_ptr<ChannelList> tlist)
85 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
88 if (osdv) sl.addColumn(20);
98 for (UINT i = 0; i < chanList->size(); i++)
100 chan = (*chanList)[i];
101 sprintf(str, "%lu\t%s", chan->number, chan->name);
102 TVMediaInfo *info=NULL;
104 info= new TVMediaInfo();
105 info->setChannelLogo((*chanList)[i]->number);
106 if (type == VDR::VIDEO) info->setStaticFallback(sa_tv);
107 else info->setStaticFallback(sa_radio);
109 chan->index = sl.addOption(str, chan, first, info);
115 void VChannelList::highlightChannel(Channel* chan)
117 sl.hintSetCurrent(chan->index);
120 boxstack->update(this);
123 void VChannelList::draw()
127 // Put the status stuff at the bottom
132 w.nextSymbol = WSymbol::UP;
133 w.setPosition(20, 385);
136 w.nextSymbol = WSymbol::DOWN;
137 w.setPosition(50, 385);
140 w.nextSymbol = WSymbol::SKIPBACK;
141 w.setPosition(85, 385);
144 w.nextSymbol = WSymbol::SKIPFORWARD;
145 w.setPosition(115, 385);
148 w.nextSymbol = WSymbol::PLAY;
149 w.setPosition(150, 385);
155 void VChannelList::doShowingBar()
157 int topOption = sl.getTopOption() + 1;
158 if (sl.getNumOptions() == 0) topOption = 0;
160 rectangle(220, 385, 160, 25, DrawStyle::VIEWBACKGROUND);
163 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
164 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
167 * The following would work but the translation files need changing to {} instead of %i
168 * This is server side and so requires a server version bump breaking compatibility with older clients
169 * Maybe this will happen for v0.6 ?
172 * fmt::format(tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()).c_str(),
173 * 220, 385, DrawStyle::LIGHTTEXT);
178 void VChannelList::quickUpdate() { //only quick for plattform that need it!
179 #ifdef GRADIENT_DRAWING
187 int VChannelList::handleCommand(int command)
196 boxstack->update(this);
197 return BoxStack::COMMAND_HANDLED;
204 boxstack->update(this);
205 return BoxStack::COMMAND_HANDLED;
207 case Input::SKIPBACK:
212 boxstack->update(this);
213 return BoxStack::COMMAND_HANDLED;
215 case Input::SKIPFORWARD:
220 boxstack->update(this);
221 return BoxStack::COMMAND_HANDLED;
234 VChannelSelect* v = new VChannelSelect(this);
238 v->handleCommand(command);
239 return BoxStack::COMMAND_HANDLED;
244 Channel* chan = NULL;
245 if (chanList) chan = reinterpret_cast<Channel*>(sl.getCurrentOptionData());
246 if (chan == NULL) return 2;
248 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
252 return BoxStack::COMMAND_HANDLED;
256 return BoxStack::DELETE_ME;
259 // stop command getting to any more views
260 return BoxStack::ABANDON_COMMAND;
263 void VChannelList::processMessage(Message* m)
265 /* if (m->message == Message::MOUSE_MOVE) {
266 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
267 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
270 boxstack->update(this);
273 else */if (m->message == Message::MOUSE_MOVE)
275 if (sl.mouseMove(m->parameter - getScreenX(), m->tag - getScreenY()))
278 boxstack->update(this);
281 else if (m->message == Message::MOUSE_LBDOWN)
283 if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY()))
285 Input::sendInputKey(Input::OK);
287 else if (coordsOutsideBox(m))
289 Input::sendInputKey(Input::BACK);
292 else if (m->message == Message::CHANNEL_CHANGE)
294 LogNT::getInstance()->debug(TAG, "Channel change {}", m->parameter);
295 Channel* chan = NULL;
296 for (UINT i = 0; i < chanList->size(); i++)
298 if ((*chanList)[i]->number == m->parameter)
300 chan = (*chanList)[i];
306 /* if (chan->type == VDR::VIDEO)
308 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
315 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
319 v->channelChange(VVideoLive::NUMBER, chan->number);