2 Copyright 2004-2008 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 "vrecording.h"
25 #include "vquestion.h"
35 #include "vrecordinglist.h"
36 #include "recording.h"
39 #include "wmovieview.h"
40 #include "wseriesview.h"
41 #include "wpictureview.h"
43 VRecording::VRecording(RecMan* trecman, Recording* trec)
50 Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
52 Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
55 if (Video::getInstance()->getFormat() == Video::PAL)
69 if (rec->recInfo && strlen(rec->recInfo->title))
70 setTitleText(rec->recInfo->title);
72 setTitleText(rec->getProgName());
73 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
75 tabbar.setPosition(10+130+10, 30 + 5);
76 tabbar.setSize(area.w - 20-10-130, area.h - 30 - 10);
82 WTextbox * summary=new WTextbox();
83 summary->setParaMode(true);
85 if (rec->recInfo && strlen(rec->recInfo->summary))
86 summary->setText(rec->recInfo->summary);
88 summary->setText(tr("Summary unavailable"));
90 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
92 tabbar.addTab(tr("EPG"), summary);
94 WMovieView *movieview = new WMovieView(rec->movieInfo);
95 movieview->setParaMode(true);
96 tabbar.addTab(tr("TheTVDB Info"), movieview);
98 if (rec->movieInfo->actors.size() > 0 && osdv)
100 WActorGallery *gallery= new WActorGallery(rec->movieInfo->actors);
101 tabbar.addTab(tr("Cast"),gallery);
103 WArtworkGallery *artgallery= new WArtworkGallery(*rec->movieInfo);
104 tabbar.addTab(tr("Gallery"),artgallery);
106 } else if (rec->seriesInfo) {
107 WSeriesView *seriesview = new WSeriesView(rec->seriesInfo);
108 seriesview->setParaMode(true);
109 tabbar.addTab(tr("TheTVDB Info"), seriesview);
111 if (rec->seriesInfo->actors.size() > 0 && osdv)
113 WActorGallery *gallery= new WActorGallery(rec->seriesInfo->actors);
114 tabbar.addTab(tr("Cast"),gallery);
116 WArtworkGallery *artgallery= new WArtworkGallery(*rec->seriesInfo);
117 tabbar.addTab(tr("Gallery"),artgallery);
124 int sfh = getFontHeight();
126 buttonRegion.y = 10+30;
127 buttonRegion.w = 130;
128 buttonRegion.h = sfh*2*last;
130 button[PLAY].setText(tr("Play"));
131 button[RESUME].setText(tr("Resume"));
132 button[MOVE].setText(tr("Move"));
133 button[A_DELETE].setText(tr("Delete"));
135 for (int i=PLAY, ver=10+30; i<last; i++, ver+= sfh*2)
137 button[i].setPosition(10, ver);
138 button[i].setSize(130, sfh);
143 button[selected].setActive(1);
144 tabbar.activateFocus(false);
147 VRecording::~VRecording()
151 void VRecording::setParent(VRecordingList* tvRecList)
153 vRecList = tvRecList;
156 void VRecording::draw()
159 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
162 if (rec->movieInfo) {
163 poster=rec->movieInfo->poster;
165 if (rec->seriesInfo) {
166 if (rec->seriesInfo->seasonposter.height) {
167 poster=rec->seriesInfo->seasonposter;
170 if (rec->seriesInfo->posters.size()) {
171 poster=rec->seriesInfo->posters[0];
175 // float aspect=((float)poster.height)/((float)poster.width)/Osd::getInstance()->getPixelAspect();
176 drawTVMedia(poster.info,buttonRegion.x,
178 buttonRegion.w,/*buttonRegion.w*aspect*/0.f,BottomLeft);
184 int VRecording::handleCommand(int command)
186 if (command==Remote::BACK) {
195 tabbar.activateFocus(false);
200 case Remote::DF_DOWN:
203 tabbar.activateFocus(false);
208 case Remote::DF_LEFT:
210 case Remote::DF_RIGHT:
213 button[selected].setActive(0);
214 tabbar.activateFocus(true);
215 button[selected].draw();
217 BoxStack::getInstance()->update(this);
223 if (selected == PLAY)
225 Message* m = new Message(); // Must be done after this view deleted
228 m->message = Message::PLAY_SELECTED_RECORDING;
229 Command::getInstance()->postMessageNoLock(m);
233 if (selected == RESUME)
235 Message* m = new Message(); // Must be done after this view deleted
238 m->message = Message::RESUME_SELECTED_RECORDING;
239 Command::getInstance()->postMessageNoLock(m);
243 if (selected == MOVE)
245 VRecMove* vrm = new VRecMove(recman);
246 vrm->setParent(this);
248 BoxStack::getInstance()->add(vrm);
249 BoxStack::getInstance()->update(vrm);
253 if (selected == A_DELETE)
255 VQuestion* v = new VQuestion(this);
256 v->setSize(260, 180);
258 v->setTitleBarColour(DrawStyle::DANGER);
261 v->setTitleText(tr("Delete recording"));
262 v->setMainText(tr("Are you sure you want to delete this recording?"));
263 v->setDefault(VQuestion::NO);
264 if (Video::getInstance()->getFormat() == Video::PAL)
266 v->setPosition(230, 160);
270 v->setPosition(220, 140);
274 BoxStack::getInstance()->add(v);
275 BoxStack::getInstance()->update(v);
282 int retval = tabbar.handleCommand(command);
285 BoxStack::getInstance()->update(this);
288 else if (retval == 2)
290 // command was taken and actively ignored
291 if (command==Remote::LEFT || command==Remote::DF_LEFT
292 || command==Remote::RIGHT || command==Remote::DF_RIGHT)
295 button[selected].setActive(1);
296 tabbar.activateFocus(false);
297 button[selected].draw();
299 BoxStack::getInstance()->update(this);
306 // stop command getting to any more views
310 void VRecording::moveCursor(Direction direction)
312 button[selected].setActive(0);
313 button[selected].draw();
314 if (direction == RIGHT)
316 if (++selected == last) selected = PLAY;
320 if (--selected < 0) selected = last - 1;
322 button[selected].setActive(1);
323 button[selected].draw();
324 BoxStack::getInstance()->update(this, &buttonRegion);
327 void VRecording::processMessage(Message* m)
329 if (m->message == Message::MOUSE_MOVE)
331 for (int i = PLAY; i < last; i++)
333 if (button[i].mouseMove((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
335 for (int j = PLAY; j < last; j++)
336 button[j].setActive(0);
337 button[i].setActive(1);
338 tabbar.activateFocus(false);
342 BoxStack::getInstance()->update(this);
346 if (tabbar.mouseMove((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
348 BoxStack::getInstance()->update(this);
352 else if (m->message == Message::MOUSE_SCROLL)
354 if (tabbar.mouseAndroidScroll((m->tag >> 16) - getScreenX(), (m->tag & 0xFFFF) - getScreenY(),
355 (short)(m->parameter.num >> 16), (short) (m->parameter.num & 0xFFFF)))
357 BoxStack::getInstance()->update(this);
361 else if (m->message == Message::MOUSE_LBDOWN)
364 for (int i = PLAY; i < last; i++)
366 if (button[i].mouseLBDOWN((m->parameter.num>>16)-getScreenX(),(m->parameter.num&0xFFFF)-getScreenY()))
368 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
374 if (cancel && tabbar.mouseLBDOWN((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
377 button[selected].setActive(0);
379 BoxStack::getInstance()->update(this);
384 //check if press is outside this view! then simulate cancel
385 int x=(m->parameter.num>>16)-getScreenX();
386 int y=(m->parameter.num&0xFFFF)-getScreenY();
387 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
389 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
393 else if (m->message == Message::QUESTION_YES)
395 if (selected == A_DELETE)
397 Message* m2 = new Message(); // Delete self
399 m2->to = BoxStack::getInstance();
400 m2->message = Message::CLOSE_ME;
401 Command::getInstance()->postMessageNoLock(m2);
403 m2 = new Message(); // OK. Want this to delete before this message does its job
406 m2->message = Message::DELETE_SELECTED_RECORDING;
407 Command::getInstance()->postMessageNoLock(m2);
410 else if (m->message == Message::MOVE_RECORDING)
412 Message* m2 = new Message(); // Delete self
414 m2->to = BoxStack::getInstance();
415 m2->message = Message::CLOSE_ME;
416 Command::getInstance()->postMessageNoLock(m2);
421 m2->message = Message::MOVE_RECORDING;
422 m2->parameter.num = m->parameter.num;
423 Command::getInstance()->postMessageNoLock(m2);