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 #include "imageloader.h"
37 static const char* TAG = "VChannelList";
39 VChannelList::VChannelList(u4 ttype)
41 boxstack = BoxStack::getInstance();
44 if (Video::getInstance()->getFormat() == Video::PAL)
55 imageLoader = ImageLoader::getInstance();
58 if (type == VDR::VIDEO)
60 setTitleText(tr("Channels"));
61 Image icon = imageLoader->createStatic(sa_tv);
62 setTitleBarIcon(icon);
64 else if (type == VDR::RADIO)
66 setTitleText(tr("Radio Stations"));
67 Image icon = imageLoader->createStatic(sa_radio);
68 setTitleBarIcon(icon);
71 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
73 sl.setPosition(10, 30 + 5);
74 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
76 MessageQueue::getInstance()->addReceiver(this);
79 VChannelList::~VChannelList()
81 MessageQueue::getInstance()->removeReceiver(this);
84 void VChannelList::setList(std::shared_ptr<ChannelList> tlist)
86 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
89 if (osdv) sl.addColumn(20);
99 for (u4 i = 0; i < chanList->size(); i++)
101 chan = (*chanList)[i];
102 std::ostringstream os;
103 os << chan->number << '\t' << chan->name;
107 if (type == VDR::VIDEO) sa_id = sa_tv;
108 else if (type == VDR::RADIO) sa_id = sa_radio;
109 Image icon = imageLoader->createChannelLogo((*chanList)[i]->number, sa_id);
111 chan->index = sl.addOption(os.str(), chan, first, icon);
114 chan->index = sl.addOption(os.str(), chan, first);
121 void VChannelList::highlightChannel(Channel* chan)
123 sl.hintSetCurrent(chan->index);
126 boxstack->update(this);
129 void VChannelList::draw()
133 // Put the status stuff at the bottom
138 w.nextSymbol = WSymbol::UP;
139 w.setPosition(20, 385);
142 w.nextSymbol = WSymbol::DOWN;
143 w.setPosition(50, 385);
146 w.nextSymbol = WSymbol::SKIPBACK;
147 w.setPosition(85, 385);
150 w.nextSymbol = WSymbol::SKIPFORWARD;
151 w.setPosition(115, 385);
154 w.nextSymbol = WSymbol::PLAY;
155 w.setPosition(150, 385);
161 void VChannelList::doShowingBar()
163 int topOption = sl.getTopOption() + 1;
164 if (sl.getNumOptions() == 0) topOption = 0;
166 rectangle(220, 385, 160, 25, DrawStyle::VIEWBACKGROUND);
169 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
170 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
173 * The following would work but the translation files need changing to {} instead of %i
174 * This is server side and so requires a server version bump breaking compatibility with older clients
175 * Maybe this will happen for v0.6 ?
178 * fmt::format(tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()).c_str(),
179 * 220, 385, DrawStyle::LIGHTTEXT);
184 void VChannelList::quickUpdate() { //only quick for plattform that need it!
185 #ifdef GRADIENT_DRAWING
193 int VChannelList::handleCommand(int command)
202 boxstack->update(this);
203 return BoxStack::COMMAND_HANDLED;
210 boxstack->update(this);
211 return BoxStack::COMMAND_HANDLED;
213 case Input::SKIPBACK:
218 boxstack->update(this);
219 return BoxStack::COMMAND_HANDLED;
221 case Input::SKIPFORWARD:
226 boxstack->update(this);
227 return BoxStack::COMMAND_HANDLED;
240 VChannelSelect* v = new VChannelSelect(this);
244 v->handleCommand(command);
245 return BoxStack::COMMAND_HANDLED;
250 Channel* chan = NULL;
251 if (chanList) chan = reinterpret_cast<Channel*>(sl.getCurrentOptionData());
252 if (chan == NULL) return 2;
254 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
258 return BoxStack::COMMAND_HANDLED;
262 return BoxStack::DELETE_ME;
265 // stop command getting to any more views
266 return BoxStack::ABANDON_COMMAND;
269 void VChannelList::processMessage(Message* m)
271 /* if (m->message == Message::MOUSE_MOVE) {
272 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
273 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
276 boxstack->update(this);
279 else */if (m->message == Message::MOUSE_MOVE)
281 if (sl.mouseMove(m->parameter - getScreenX(), m->tag - getScreenY()))
284 boxstack->update(this);
287 else if (m->message == Message::MOUSE_LBDOWN)
289 if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY()))
291 Input::sendInputKey(Input::OK);
293 else if (coordsOutsideBox(m))
295 Input::sendInputKey(Input::BACK);
298 else if (m->message == Message::CHANNEL_CHANGE)
300 LogNT::getInstance()->debug(TAG, "Channel change {}", m->parameter);
301 Channel* chan = NULL;
302 for (u4 i = 0; i < chanList->size(); i++)
304 if ((*chanList)[i]->number == m->parameter)
306 chan = (*chanList)[i];
312 /* if (chan->type == VDR::VIDEO)
314 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
321 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
325 v->channelChange(VVideoLive::NUMBER, chan->number);