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()
138 // Put the status stuff at the bottom
143 w.nextSymbol = WSymbol::UP;
144 w.setPosition(20, 385);
147 w.nextSymbol = WSymbol::DOWN;
148 w.setPosition(50, 385);
151 w.nextSymbol = WSymbol::SKIPBACK;
152 w.setPosition(85, 385);
155 w.nextSymbol = WSymbol::SKIPFORWARD;
156 w.setPosition(115, 385);
159 w.nextSymbol = WSymbol::PLAY;
160 w.setPosition(150, 385);
166 void VChannelList::doShowingBar()
168 int topOption = sl.getTopOption() + 1;
169 if (sl.getNumOptions() == 0) topOption = 0;
171 rectangle(220, 385, 160, 25, DrawStyle::VIEWBACKGROUND);
174 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
175 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
178 * The following would work but the translation files need changing to {} instead of %i
179 * This is server side and so requires a server version bump breaking compatibility with older clients
180 * Maybe this will happen for v0.6 ?
183 * fmt::format(tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()).c_str(),
184 * 220, 385, DrawStyle::LIGHTTEXT);
189 void VChannelList::quickUpdate() { //only quick for plattform that need it!
190 #ifdef GRADIENT_DRAWING
198 int VChannelList::handleCommand(int command)
207 boxstack->update(this);
208 return BoxStack::COMMAND_HANDLED;
215 boxstack->update(this);
216 return BoxStack::COMMAND_HANDLED;
218 case Input::SKIPBACK:
223 boxstack->update(this);
224 return BoxStack::COMMAND_HANDLED;
226 case Input::SKIPFORWARD:
231 boxstack->update(this);
232 return BoxStack::COMMAND_HANDLED;
245 VChannelSelect* v = new VChannelSelect(this);
249 v->handleCommand(command);
250 return BoxStack::COMMAND_HANDLED;
255 Channel* chan = NULL;
256 if (chanList) chan = reinterpret_cast<Channel*>(sl.getCurrentOptionData());
257 if (chan == NULL) return 2;
259 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
263 return BoxStack::COMMAND_HANDLED;
267 return BoxStack::DELETE_ME;
270 // stop command getting to any more views
271 return BoxStack::ABANDON_COMMAND;
274 void VChannelList::processMessage(Message* m)
276 /* if (m->message == Message::MOUSE_MOVE) {
277 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
278 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
281 boxstack->update(this);
284 else */if (m->message == Message::MOUSE_MOVE)
286 if (sl.mouseMove(m->parameter - getScreenX(), m->tag - getScreenY()))
289 boxstack->update(this);
292 else if (m->message == Message::MOUSE_LBDOWN)
294 if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY()))
296 Input::sendInputKey(Input::OK);
298 else if (coordsOutsideBox(m))
300 Input::sendInputKey(Input::BACK);
303 else if (m->message == Message::CHANNEL_CHANGE)
305 LogNT::getInstance()->debug(TAG, "Channel change {}", m->parameter);
306 Channel* chan = NULL;
307 for (UINT i = 0; i < chanList->size(); i++)
309 if ((*chanList)[i]->number == m->parameter)
311 chan = (*chanList)[i];
317 /* if (chan->type == VDR::VIDEO)
319 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
326 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
330 v->channelChange(VVideoLive::NUMBER, chan->number);