From 79e4763bf2b758e5e9e499e06ccda3222fdae07f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 12 Jan 2009 22:13:15 +0000 Subject: [PATCH] New recordings menu --- command.cc | 4 +- objects.mk | 2 +- vrecording.cc | 334 ++++++++++++++++++++++++++++++++++++++++++++++ vrecording.h | 67 ++++++++++ vrecordinglist.cc | 9 ++ 5 files changed, 413 insertions(+), 3 deletions(-) create mode 100644 vrecording.cc create mode 100644 vrecording.h diff --git a/command.cc b/command.cc index ccf1fb4..34f56e0 100644 --- a/command.cc +++ b/command.cc @@ -899,7 +899,7 @@ void Command::doJustConnected(VConnect* vconnect) // Enter pre-keys here // handleCommand(Remote::OK); -// handleCommand(Remote::ONE); +// handleCommand(Remote::THREE); // handleCommand(Remote::SIX); // handleCommand(Remote::OK); // handleCommand(Remote::UP); @@ -907,7 +907,7 @@ void Command::doJustConnected(VConnect* vconnect) // handleCommand(Remote::DOWN); // handleCommand(Remote::DOWN); // handleCommand(Remote::DOWN); -// handleCommand(Remote::OK); + // handleCommand(Remote::OK); // handleCommand(Remote::RED); } } diff --git a/objects.mk b/objects.mk index 62a8fe5..ad2727e 100644 --- a/objects.mk +++ b/objects.mk @@ -5,7 +5,7 @@ OBJECTS1 = command.o log.o tcp.o dsock.o thread.o timers.o i18n.o mutex.o player.o playerradio.o vfeed.o afeed.o \ demuxer.o demuxervdr.o demuxerts.o stream.o draintarget.o \ region.o colour.o boxstack.o boxx.o tbboxx.o \ - vinfo.o vquestion.o vrecordinglist.o \ + vinfo.o vquestion.o vrecordinglist.o vrecording.o \ vmute.o vvolume.o vtimerlist.o vtimeredit.o vrecordingmenu.o \ vchannellist.o vwelcome.o vvideorec.o vepgsettimer.o \ vchannelselect.o vserverselect.o vconnect.o vepg.o vrecmove.o \ diff --git a/vrecording.cc b/vrecording.cc new file mode 100644 index 0000000..516e0d9 --- /dev/null +++ b/vrecording.cc @@ -0,0 +1,334 @@ +/* + Copyright 2004-2008 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "vrecording.h" + +#include "remote.h" +#include "recinfo.h" +#include "vquestion.h" +#include "vinfo.h" +#include "vdr.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "command.h" +#include "vrecmove.h" +#include "boxstack.h" +#include "recman.h" +#include "vrecordinglist.h" +#include "recording.h" +#include "message.h" +#include "log.h" + +VRecording::VRecording(RecMan* trecman, Recording* trec) +{ + rec = trec; + recman = trecman; + + Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName()); + rec->loadRecInfo(); + Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName()); + + setSize(570, 420); + createBuffer(); + if (Video::getInstance()->getFormat() == Video::PAL) + { + setPosition(80, 70); + } + else + { + setPosition(70, 35); + } + + setTitleBarOn(1); + setBorderOn(1); + setTitleText(rec->getProgName()); + setTitleBarColour(Colour::TITLEBARBACKGROUND); + + summary.setPosition(10, 30 + 5); + summary.setSize(area.w - 20, area.h - 30 - 15 - 50); + summary.setParaMode(true); + + if (strlen(rec->recInfo->summary)) + summary.setText(rec->recInfo->summary); + else + summary.setText(tr("Summary unavailable")); + + add(&summary); + + + buttonPlay.setPosition(70, area.h - 40); + buttonResume.setPosition(180, area.h - 40); + buttonMove.setPosition(290, area.h - 40); + buttonDelete.setPosition(400, area.h - 40); + + buttonRegion.x = 70; + buttonRegion.y = area.h - 40; + buttonRegion.w = 460; + buttonRegion.h = Surface::getFontHeight(); + + buttonPlay.setText(tr("Play")); + buttonResume.setText(tr("Resume")); + buttonMove.setText(tr("Move")); + buttonDelete.setText(tr("Delete")); + + add(&buttonPlay); + add(&buttonResume); + add(&buttonMove); + add(&buttonDelete); + + buttonPlay.setActive(1); + selected = 1; +} + +VRecording::~VRecording() +{ +} + +void VRecording::setParent(VRecordingList* tvRecList) +{ + vRecList = tvRecList; +} + +void VRecording::draw() +{ + TBBoxx::draw(); +} + +int VRecording::handleCommand(int command) +{ + switch(command) + { + case Remote::LEFT: + case Remote::DF_UP: + case Remote::UP: + { + doLeft(); + return 2; + } + case Remote::RIGHT: + case Remote::DF_DOWN: + case Remote::DOWN: + { + doRight(); + return 2; + } + case Remote::OK: + { + + if (selected == 1) + { + Message* m = new Message(); // Must be done after this view deleted + m->from = this; + m->to = vRecList; + m->message = Message::PLAY_SELECTED_RECORDING; + Command::getInstance()->postMessageNoLock(m); + return 4; + } + + if (selected == 2) + { + Message* m = new Message(); // Must be done after this view deleted + m->from = this; + m->to = vRecList; + m->message = Message::RESUME_SELECTED_RECORDING; + Command::getInstance()->postMessageNoLock(m); + return 4; + } + + if (selected == 3) + { + VRecMove* vrm = new VRecMove(recman); + vrm->setParent(this); + vrm->draw(); + BoxStack::getInstance()->add(vrm); + BoxStack::getInstance()->update(vrm); + return 2; + } + + if (selected == 4) + { + VQuestion* v = new VQuestion(this); + v->setSize(260, 180); + v->createBuffer(); + v->setTitleBarColour(Colour::DANGER); + v->setTitleBarOn(1); + v->setBorderOn(1); + v->setTitleText(tr("Delete recording")); + v->setMainText(tr("Are you sure you want to delete this recording?")); + v->setDefault(VQuestion::NO); + if (Video::getInstance()->getFormat() == Video::PAL) + { + v->setPosition(230, 160); + } + else + { + v->setPosition(220, 140); + } + + v->draw(); + BoxStack::getInstance()->add(v); + BoxStack::getInstance()->update(v); + return 2; + } + } + + case Remote::BACK: + { + return 4; + } + } + // stop command getting to any more views + return 1; +} + +void VRecording::doRight() +{ + switch(selected) + { + case 1: + buttonPlay.setActive(0); + buttonResume.setActive(1); + buttonPlay.draw(); + buttonResume.draw(); + break; + case 2: + buttonResume.setActive(0); + buttonMove.setActive(1); + buttonResume.draw(); + buttonMove.draw(); + break; + case 3: + buttonMove.setActive(0); + buttonDelete.setActive(1); + buttonMove.draw(); + buttonDelete.draw(); + break; + case 4: + buttonDelete.setActive(0); + buttonPlay.setActive(1); + buttonDelete.draw(); + buttonPlay.draw(); + break; + } + + if (++selected == 5) selected = 1; + + BoxStack::getInstance()->update(this, &buttonRegion); +} + +void VRecording::doLeft() +{ + switch(selected) + { + case 1: + buttonPlay.setActive(0); + buttonDelete.setActive(1); + buttonPlay.draw(); + buttonDelete.draw(); + break; + case 2: + buttonResume.setActive(0); + buttonPlay.setActive(1); + buttonResume.draw(); + buttonPlay.draw(); + break; + case 3: + buttonMove.setActive(0); + buttonResume.setActive(1); + buttonMove.draw(); + buttonResume.draw(); + break; + case 4: + buttonDelete.setActive(0); + buttonMove.setActive(1); + buttonDelete.draw(); + buttonMove.draw(); + break; + } + + if (--selected == 0) selected = 4; + + BoxStack::getInstance()->update(this, &buttonRegion); +} + +void VRecording::processMessage(Message* m) +{ +/* + if (m->message == Message::MOUSE_MOVE) + { + if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + { + sl.draw(); + BoxStack::getInstance()->update(this); + } + } + else if (m->message == Message::MOUSE_LBDOWN) + { + if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + { + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press + } + else + { + //check if press is outside this view! then simulate cancel + int x=(m->parameter>>16)-getScreenX(); + int y=(m->parameter&0xFFFF)-getScreenY(); + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) + { + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + } + } + } + */ + if (m->message == Message::QUESTION_YES) + { + if (selected == 4) + { + Message* m2 = new Message(); // Delete self + m2->from = this; + m2->to = BoxStack::getInstance(); + m2->message = Message::CLOSE_ME; + Command::getInstance()->postMessageNoLock(m2); + + m2 = new Message(); // OK. Want this to delete before this message does its job + m2->from = this; + m2->to = vRecList; + m2->message = Message::DELETE_SELECTED_RECORDING; + Command::getInstance()->postMessageNoLock(m2); + } + } + else if (m->message == Message::MOVE_RECORDING) + { + Message* m2 = new Message(); // Delete self + m2->from = this; + m2->to = BoxStack::getInstance(); + m2->message = Message::CLOSE_ME; + Command::getInstance()->postMessageNoLock(m2); + + m2 = new Message(); + m2->from = this; + m2->to = vRecList; + m2->message = Message::MOVE_RECORDING; + m2->parameter = m->parameter; + Command::getInstance()->postMessageNoLock(m2); + } +} + diff --git a/vrecording.h b/vrecording.h new file mode 100644 index 0000000..9d3e043 --- /dev/null +++ b/vrecording.h @@ -0,0 +1,67 @@ +/* + Copyright 2004-2008 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef VRECORDING_H +#define VRECORDING_H + +#include +#include + +#include "tbboxx.h" +#include "wbutton.h" +#include "wtextbox.h" + +class VRecordingList; +class RecMan; +class Recording; +class Message; + +class VRecording : public TBBoxx +{ + public: + VRecording(RecMan* recman, Recording* rec); + ~VRecording(); + void setParent(VRecordingList* tvRecList); + + void draw(); + + int handleCommand(int command); + void processMessage(Message* m); + + private: + RecMan* recman; + VRecordingList* vRecList; + Recording* rec; + + WTextbox summary; + + WButton buttonPlay; // 1 + WButton buttonResume; // 2 + WButton buttonMove; // 3 + WButton buttonDelete; // 4 + + int selected; + Region buttonRegion; + + void doLeft(); + void doRight(); +}; + +#endif diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 430ad30..2e96a36 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -27,6 +27,7 @@ #include "wsymbol.h" #include "boxstack.h" #include "vrecordingmenu.h" +#include "vrecording.h" #include "vdr.h" #include "vvideorec.h" #include "vradiorec.h" @@ -448,12 +449,20 @@ int VRecordingList::handleCommand(int command) { Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->getFileName()); +/* VRecordingMenu* v = new VRecordingMenu(recman); v->setParent(this); v->setRecording(current); v->draw(); boxstack->add(v); boxstack->update(v); +*/ + VRecording* vr = new VRecording(recman, current); + vr->setParent(this); + vr->draw(); + boxstack->add(vr); + boxstack->update(vr); + return 2; } // should not get to here -- 2.39.5