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"
40 VRecording::VRecording(RecMan* trecman, Recording* trec)
45 Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
47 Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
51 if (Video::getInstance()->getFormat() == Video::PAL)
62 setTitleText(rec->getProgName());
63 setTitleBarColour(Colour::TITLEBARBACKGROUND);
65 summary.setPosition(10, 30 + 5);
66 summary.setSize(area.w - 20, area.h - 30 - 15 - 50);
67 summary.setParaMode(true);
69 if (strlen(rec->recInfo->summary))
70 summary.setText(rec->recInfo->summary);
72 summary.setText(tr("Summary unavailable"));
77 buttonPlay.setPosition(10, area.h - 40);
78 buttonResume.setPosition(150, area.h - 40);
79 buttonMove.setPosition(290, area.h - 40);
80 buttonDelete.setPosition(430, area.h - 40);
82 int sfh = Surface::getFontHeight();
84 buttonPlay.setSize(130, sfh);
85 buttonResume.setSize(130, sfh);
86 buttonMove.setSize(130, sfh);
87 buttonDelete.setSize(130, sfh);
90 buttonRegion.y = area.h - 40;
94 buttonPlay.setText(tr("Play"));
95 buttonResume.setText(tr("Resume"));
96 buttonMove.setText(tr("Move"));
97 buttonDelete.setText(tr("Delete"));
104 buttonPlay.setActive(1);
108 VRecording::~VRecording()
112 void VRecording::setParent(VRecordingList* tvRecList)
114 vRecList = tvRecList;
117 void VRecording::draw()
122 int VRecording::handleCommand(int command)
134 case Remote::DF_DOWN:
145 Message* m = new Message(); // Must be done after this view deleted
148 m->message = Message::PLAY_SELECTED_RECORDING;
149 Command::getInstance()->postMessageNoLock(m);
155 Message* m = new Message(); // Must be done after this view deleted
158 m->message = Message::RESUME_SELECTED_RECORDING;
159 Command::getInstance()->postMessageNoLock(m);
165 VRecMove* vrm = new VRecMove(recman);
166 vrm->setParent(this);
168 BoxStack::getInstance()->add(vrm);
169 BoxStack::getInstance()->update(vrm);
175 VQuestion* v = new VQuestion(this);
176 v->setSize(260, 180);
178 v->setTitleBarColour(Colour::DANGER);
181 v->setTitleText(tr("Delete recording"));
182 v->setMainText(tr("Are you sure you want to delete this recording?"));
183 v->setDefault(VQuestion::NO);
184 if (Video::getInstance()->getFormat() == Video::PAL)
186 v->setPosition(230, 160);
190 v->setPosition(220, 140);
194 BoxStack::getInstance()->add(v);
195 BoxStack::getInstance()->update(v);
205 // stop command getting to any more views
209 void VRecording::doRight()
214 buttonPlay.setActive(0);
215 buttonResume.setActive(1);
220 buttonResume.setActive(0);
221 buttonMove.setActive(1);
226 buttonMove.setActive(0);
227 buttonDelete.setActive(1);
232 buttonDelete.setActive(0);
233 buttonPlay.setActive(1);
239 if (++selected == 5) selected = 1;
241 BoxStack::getInstance()->update(this, &buttonRegion);
244 void VRecording::doLeft()
249 buttonPlay.setActive(0);
250 buttonDelete.setActive(1);
255 buttonResume.setActive(0);
256 buttonPlay.setActive(1);
261 buttonMove.setActive(0);
262 buttonResume.setActive(1);
267 buttonDelete.setActive(0);
268 buttonMove.setActive(1);
274 if (--selected == 0) selected = 4;
276 BoxStack::getInstance()->update(this, &buttonRegion);
279 void VRecording::processMessage(Message* m)
281 if (m->message == Message::MOUSE_MOVE)
283 if (buttonPlay.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
285 buttonPlay.setActive(1);
286 buttonResume.setActive(0);
287 buttonMove.setActive(0);
288 buttonDelete.setActive(0);
291 BoxStack::getInstance()->update(this);
293 else if (buttonResume.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
295 buttonPlay.setActive(0);
296 buttonResume.setActive(1);
297 buttonMove.setActive(0);
298 buttonDelete.setActive(0);
301 BoxStack::getInstance()->update(this);
303 else if (buttonMove.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
305 buttonPlay.setActive(0);
306 buttonResume.setActive(0);
307 buttonMove.setActive(1);
308 buttonDelete.setActive(0);
311 BoxStack::getInstance()->update(this);
313 else if (buttonDelete.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
315 buttonPlay.setActive(0);
316 buttonResume.setActive(0);
317 buttonMove.setActive(0);
318 buttonDelete.setActive(1);
321 BoxStack::getInstance()->update(this);
324 else if (m->message == Message::MOUSE_LBDOWN)
326 if (buttonPlay.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
328 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
330 else if (buttonResume.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
332 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
334 else if (buttonMove.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
336 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
338 else if (buttonDelete.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
340 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
344 //check if press is outside this view! then simulate cancel
345 int x=(m->parameter>>16)-getScreenX();
346 int y=(m->parameter&0xFFFF)-getScreenY();
347 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
349 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
353 else if (m->message == Message::QUESTION_YES)
357 Message* m2 = new Message(); // Delete self
359 m2->to = BoxStack::getInstance();
360 m2->message = Message::CLOSE_ME;
361 Command::getInstance()->postMessageNoLock(m2);
363 m2 = new Message(); // OK. Want this to delete before this message does its job
366 m2->message = Message::DELETE_SELECTED_RECORDING;
367 Command::getInstance()->postMessageNoLock(m2);
370 else if (m->message == Message::MOVE_RECORDING)
372 Message* m2 = new Message(); // Delete self
374 m2->to = BoxStack::getInstance();
375 m2->message = Message::CLOSE_ME;
376 Command::getInstance()->postMessageNoLock(m2);
381 m2->message = Message::MOVE_RECORDING;
382 m2->parameter = m->parameter;
383 Command::getInstance()->postMessageNoLock(m2);