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)
127 case Remote::DF_LEFT:
135 case Remote::DF_RIGHT:
136 case Remote::DF_DOWN:
147 Message* m = new Message(); // Must be done after this view deleted
150 m->message = Message::PLAY_SELECTED_RECORDING;
151 Command::getInstance()->postMessageNoLock(m);
157 Message* m = new Message(); // Must be done after this view deleted
160 m->message = Message::RESUME_SELECTED_RECORDING;
161 Command::getInstance()->postMessageNoLock(m);
167 VRecMove* vrm = new VRecMove(recman);
168 vrm->setParent(this);
170 BoxStack::getInstance()->add(vrm);
171 BoxStack::getInstance()->update(vrm);
177 VQuestion* v = new VQuestion(this);
178 v->setSize(260, 180);
180 v->setTitleBarColour(Colour::DANGER);
183 v->setTitleText(tr("Delete recording"));
184 v->setMainText(tr("Are you sure you want to delete this recording?"));
185 v->setDefault(VQuestion::NO);
186 if (Video::getInstance()->getFormat() == Video::PAL)
188 v->setPosition(230, 160);
192 v->setPosition(220, 140);
196 BoxStack::getInstance()->add(v);
197 BoxStack::getInstance()->update(v);
207 // stop command getting to any more views
211 void VRecording::doRight()
216 buttonPlay.setActive(0);
217 buttonResume.setActive(1);
222 buttonResume.setActive(0);
223 buttonMove.setActive(1);
228 buttonMove.setActive(0);
229 buttonDelete.setActive(1);
234 buttonDelete.setActive(0);
235 buttonPlay.setActive(1);
241 if (++selected == 5) selected = 1;
243 BoxStack::getInstance()->update(this, &buttonRegion);
246 void VRecording::doLeft()
251 buttonPlay.setActive(0);
252 buttonDelete.setActive(1);
257 buttonResume.setActive(0);
258 buttonPlay.setActive(1);
263 buttonMove.setActive(0);
264 buttonResume.setActive(1);
269 buttonDelete.setActive(0);
270 buttonMove.setActive(1);
276 if (--selected == 0) selected = 4;
278 BoxStack::getInstance()->update(this, &buttonRegion);
281 void VRecording::processMessage(Message* m)
283 if (m->message == Message::MOUSE_MOVE)
285 if (buttonPlay.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
287 buttonPlay.setActive(1);
288 buttonResume.setActive(0);
289 buttonMove.setActive(0);
290 buttonDelete.setActive(0);
293 BoxStack::getInstance()->update(this);
295 else if (buttonResume.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
297 buttonPlay.setActive(0);
298 buttonResume.setActive(1);
299 buttonMove.setActive(0);
300 buttonDelete.setActive(0);
303 BoxStack::getInstance()->update(this);
305 else if (buttonMove.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
307 buttonPlay.setActive(0);
308 buttonResume.setActive(0);
309 buttonMove.setActive(1);
310 buttonDelete.setActive(0);
313 BoxStack::getInstance()->update(this);
315 else if (buttonDelete.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
317 buttonPlay.setActive(0);
318 buttonResume.setActive(0);
319 buttonMove.setActive(0);
320 buttonDelete.setActive(1);
323 BoxStack::getInstance()->update(this);
326 else if (m->message == Message::MOUSE_LBDOWN)
328 if (buttonPlay.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
330 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
332 else if (buttonResume.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
334 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
336 else if (buttonMove.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
338 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
340 else if (buttonDelete.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
342 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
346 //check if press is outside this view! then simulate cancel
347 int x=(m->parameter>>16)-getScreenX();
348 int y=(m->parameter&0xFFFF)-getScreenY();
349 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
351 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
355 else if (m->message == Message::QUESTION_YES)
359 Message* m2 = new Message(); // Delete self
361 m2->to = BoxStack::getInstance();
362 m2->message = Message::CLOSE_ME;
363 Command::getInstance()->postMessageNoLock(m2);
365 m2 = new Message(); // OK. Want this to delete before this message does its job
368 m2->message = Message::DELETE_SELECTED_RECORDING;
369 Command::getInstance()->postMessageNoLock(m2);
372 else if (m->message == Message::MOVE_RECORDING)
374 Message* m2 = new Message(); // Delete self
376 m2->to = BoxStack::getInstance();
377 m2->message = Message::CLOSE_ME;
378 Command::getInstance()->postMessageNoLock(m2);
383 m2->message = Message::MOVE_RECORDING;
384 m2->parameter = m->parameter;
385 Command::getInstance()->postMessageNoLock(m2);