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);
83 for (UINT i = 0; i < chanList->size(); i++)
85 delete (*chanList)[i];
93 void VChannelList::setList(ChannelList* tlist)
96 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
99 if (osdv) sl.addColumn(20);
109 for (UINT i = 0; i < chanList->size(); i++)
111 chan = (*chanList)[i];
112 sprintf(str, "%lu\t%s", chan->number, chan->name);
113 TVMediaInfo *info=NULL;
115 info= new TVMediaInfo();
116 info->setChannelLogo((*chanList)[i]->number);
117 if (type == VDR::VIDEO) info->setStaticFallback(sa_tv);
118 else info->setStaticFallback(sa_radio);
120 chan->index = sl.addOption(str, chan, first, info);
126 void VChannelList::highlightChannel(Channel* chan)
128 sl.hintSetCurrent(chan->index);
131 boxstack->update(this);
134 void VChannelList::draw()
139 // Put the status stuff at the bottom
144 w.nextSymbol = WSymbol::UP;
145 w.setPosition(20, 385);
148 w.nextSymbol = WSymbol::DOWN;
149 w.setPosition(50, 385);
152 w.nextSymbol = WSymbol::SKIPBACK;
153 w.setPosition(85, 385);
156 w.nextSymbol = WSymbol::SKIPFORWARD;
157 w.setPosition(115, 385);
160 w.nextSymbol = WSymbol::PLAY;
161 w.setPosition(150, 385);
167 void VChannelList::doShowingBar()
169 int topOption = sl.getTopOption() + 1;
170 if (sl.getNumOptions() == 0) topOption = 0;
172 rectangle(220, 385, 160, 25, DrawStyle::VIEWBACKGROUND);
175 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
176 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
179 * The following would work but the translation files need changing to {} instead of %i
180 * This is server side and so requires a server version bump breaking compatibility with older clients
181 * Maybe this will happen for v0.6 ?
184 * fmt::format(tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()).c_str(),
185 * 220, 385, DrawStyle::LIGHTTEXT);
190 void VChannelList::quickUpdate() { //only quick for plattform that need it!
191 #ifdef GRADIENT_DRAWING
199 int VChannelList::handleCommand(int command)
208 boxstack->update(this);
209 return BoxStack::COMMAND_HANDLED;
216 boxstack->update(this);
217 return BoxStack::COMMAND_HANDLED;
219 case Input::SKIPBACK:
224 boxstack->update(this);
225 return BoxStack::COMMAND_HANDLED;
227 case Input::SKIPFORWARD:
232 boxstack->update(this);
233 return BoxStack::COMMAND_HANDLED;
246 VChannelSelect* v = new VChannelSelect(this);
250 v->handleCommand(command);
251 return BoxStack::COMMAND_HANDLED;
256 Channel* chan = NULL;
257 if (chanList) chan = reinterpret_cast<Channel*>(sl.getCurrentOptionData());
258 if (chan == NULL) return 2;
260 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
264 return BoxStack::COMMAND_HANDLED;
268 return BoxStack::DELETE_ME;
271 // stop command getting to any more views
272 return BoxStack::ABANDON_COMMAND;
275 void VChannelList::processMessage(Message* m)
277 /* if (m->message == Message::MOUSE_MOVE) {
278 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
279 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
282 boxstack->update(this);
285 else */if (m->message == Message::MOUSE_MOVE)
287 if (sl.mouseMove(m->parameter - getScreenX(), m->tag - getScreenY()))
290 boxstack->update(this);
293 else if (m->message == Message::MOUSE_LBDOWN)
295 if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY()))
297 Input::sendInputKey(Input::OK);
299 else if (coordsOutsideBox(m))
301 Input::sendInputKey(Input::BACK);
304 else if (m->message == Message::CHANNEL_CHANGE)
306 LogNT::getInstance()->debug(TAG, "Channel change {}", m->parameter);
307 Channel* chan = NULL;
308 for (UINT i = 0; i < chanList->size(); i++)
310 if ((*chanList)[i]->number == m->parameter)
312 chan = (*chanList)[i];
318 /* if (chan->type == VDR::VIDEO)
320 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
327 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
331 v->channelChange(VVideoLive::NUMBER, chan->number);