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)
84 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
87 if (osdv) sl.addColumn(20);
97 for (UINT i = 0; i < chanList->size(); i++)
99 chan = (*chanList)[i];
100 //sprintf(str, "%lu\t%s", chan->number, chan->name);
101 std::ostringstream os;
102 os << chan->number << '\t' << chan->name;
103 TVMediaInfo *info=NULL;
105 info= new TVMediaInfo();
106 info->setChannelLogo((*chanList)[i]->number);
107 if (type == VDR::VIDEO) info->setStaticFallback(sa_tv);
108 else info->setStaticFallback(sa_radio);
110 chan->index = sl.addOption(os.str(), chan, first, info);
116 void VChannelList::highlightChannel(Channel* chan)
118 sl.hintSetCurrent(chan->index);
121 boxstack->update(this);
124 void VChannelList::draw()
128 // Put the status stuff at the bottom
133 w.nextSymbol = WSymbol::UP;
134 w.setPosition(20, 385);
137 w.nextSymbol = WSymbol::DOWN;
138 w.setPosition(50, 385);
141 w.nextSymbol = WSymbol::SKIPBACK;
142 w.setPosition(85, 385);
145 w.nextSymbol = WSymbol::SKIPFORWARD;
146 w.setPosition(115, 385);
149 w.nextSymbol = WSymbol::PLAY;
150 w.setPosition(150, 385);
156 void VChannelList::doShowingBar()
158 int topOption = sl.getTopOption() + 1;
159 if (sl.getNumOptions() == 0) topOption = 0;
161 rectangle(220, 385, 160, 25, DrawStyle::VIEWBACKGROUND);
164 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
165 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
168 * The following would work but the translation files need changing to {} instead of %i
169 * This is server side and so requires a server version bump breaking compatibility with older clients
170 * Maybe this will happen for v0.6 ?
173 * fmt::format(tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()).c_str(),
174 * 220, 385, DrawStyle::LIGHTTEXT);
179 void VChannelList::quickUpdate() { //only quick for plattform that need it!
180 #ifdef GRADIENT_DRAWING
188 int VChannelList::handleCommand(int command)
197 boxstack->update(this);
198 return BoxStack::COMMAND_HANDLED;
205 boxstack->update(this);
206 return BoxStack::COMMAND_HANDLED;
208 case Input::SKIPBACK:
213 boxstack->update(this);
214 return BoxStack::COMMAND_HANDLED;
216 case Input::SKIPFORWARD:
221 boxstack->update(this);
222 return BoxStack::COMMAND_HANDLED;
235 VChannelSelect* v = new VChannelSelect(this);
239 v->handleCommand(command);
240 return BoxStack::COMMAND_HANDLED;
245 Channel* chan = NULL;
246 if (chanList) chan = reinterpret_cast<Channel*>(sl.getCurrentOptionData());
247 if (chan == NULL) return 2;
249 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
253 return BoxStack::COMMAND_HANDLED;
257 return BoxStack::DELETE_ME;
260 // stop command getting to any more views
261 return BoxStack::ABANDON_COMMAND;
264 void VChannelList::processMessage(Message* m)
266 /* if (m->message == Message::MOUSE_MOVE) {
267 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
268 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
271 boxstack->update(this);
274 else */if (m->message == Message::MOUSE_MOVE)
276 if (sl.mouseMove(m->parameter - getScreenX(), m->tag - getScreenY()))
279 boxstack->update(this);
282 else if (m->message == Message::MOUSE_LBDOWN)
284 if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY()))
286 Input::sendInputKey(Input::OK);
288 else if (coordsOutsideBox(m))
290 Input::sendInputKey(Input::BACK);
293 else if (m->message == Message::CHANNEL_CHANGE)
295 LogNT::getInstance()->debug(TAG, "Channel change {}", m->parameter);
296 Channel* chan = NULL;
297 for (UINT i = 0; i < chanList->size(); i++)
299 if ((*chanList)[i]->number == m->parameter)
301 chan = (*chanList)[i];
307 /* if (chan->type == VDR::VIDEO)
309 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
316 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
320 v->channelChange(VVideoLive::NUMBER, chan->number);