diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2000-04-29 15:57:42 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2000-04-29 15:57:42 +0200 |
commit | f13ded672b7fe1836299ca6d7fc2910c0c9c1109 (patch) | |
tree | 2a353d944b8dca194065a4e69601ba46b6c7d8f5 /menu.c | |
parent | 20ad6d5a050fc0ad386a55ac62f26995fa4b1aca (diff) | |
download | vdr-f13ded672b7fe1836299ca6d7fc2910c0c9c1109.tar.gz vdr-f13ded672b7fe1836299ca6d7fc2910c0c9c1109.tar.bz2 |
Better encapsulation of user interaction
Diffstat (limited to 'menu.c')
-rw-r--r-- | menu.c | 83 |
1 files changed, 58 insertions, 25 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.9 2000/04/29 08:52:54 kls Exp $ + * $Id: menu.c 1.10 2000/04/29 14:53:27 kls Exp $ */ #include "menu.h" @@ -947,9 +947,8 @@ eOSState cMenuRecordings::Play(void) { cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current()); if (ri) { -//XXX what if this recording's file is currently in use??? - if (DvbApi.StartReplay(ri->recording->FileName(), ri->recording->Title())) - return osEnd; + cReplayControl::SetRecording(ri->recording->FileName(), ri->recording->Title()); + return osReplay; } return osContinue; } @@ -1008,41 +1007,75 @@ eOSState cMenuMain::ProcessKey(eKeys Key) case osChannels: return AddSubMenu(new cMenuChannels); case osTimer: return AddSubMenu(new cMenuTimers); case osRecordings: return AddSubMenu(new cMenuRecordings); - default: break; + default: if (Key == kMenu) + state = osEnd; } return state; } -// --- cReplayDisplay -------------------------------------------------------- +// --- cReplayControl -------------------------------------------------------- + +char *cReplayControl::fileName = NULL; +char *cReplayControl::title = NULL; + +cReplayControl::cReplayControl(void) +{ + visible = shown = false; + if (fileName) + DvbApi.StartReplay(fileName, title); +} + +cReplayControl::~cReplayControl() +{ + Hide(); + DvbApi.StopReplay(); +} + +void cReplayControl::SetRecording(const char *FileName, const char *Title) +{ + delete fileName; + delete title; + fileName = FileName ? strdup(FileName) : NULL; + title = Title ? strdup(Title) : NULL; +} -cReplayDisplay::cReplayDisplay(void) +void cReplayControl::Show(void) { - Interface.Open(MenuColumns, -3); - shown = DvbApi.ShowProgress(true); + if (!visible) { + Interface.Open(MenuColumns, -3); + visible = true; + shown = DvbApi.ShowProgress(true); + } } -cReplayDisplay::~cReplayDisplay() +void cReplayControl::Hide(void) { - Interface.Close(); + if (visible) { + Interface.Close(); + visible = false; + } } -eKeys cReplayDisplay::ProcessKey(eKeys Key) +eOSState cReplayControl::ProcessKey(eKeys Key) { if (!DvbApi.Replaying()) - return kOk; // will turn off replay display - shown = DvbApi.ShowProgress(!shown) || shown; + return osEnd; + if (visible) + shown = DvbApi.ShowProgress(!shown) || shown; switch (Key) { - case kBegin: - case kPause: - case kStop: - case kSearchBack: - case kSearchForward: - case kSkipBack: - case kSkipForward: break; // will be done in main loop - case kMenu: break; // allow direct switching to menu - case kOk: break; // switches off replay display - default: Key = kNone; // ignore anything not explicitly known here + case kBegin: DvbApi.Skip(-INT_MAX); break; + case kPause: DvbApi.PauseReplay(); break; + case kStop: Hide(); + DvbApi.StopReplay(); + return osEnd; + case kSearchBack: DvbApi.FastRewind(); break; + case kSearchForward: DvbApi.FastForward(); break; + case kSkipBack: DvbApi.Skip(-60); break; + case kSkipForward: DvbApi.Skip(60); break; + case kMenu: Hide(); return osMenu; // allow direct switching to menu + case kOk: visible ? Hide() : Show(); break; + default: return osUnknown; } - return Key; + return osContinue; } |