summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c201
1 files changed, 160 insertions, 41 deletions
diff --git a/menu.c b/menu.c
index 30532a7..e25b230 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 1.88 2001/07/28 16:17:28 kls Exp $
+ * $Id: menu.c 1.95 2001/08/05 16:09:41 kls Exp $
*/
#include "menu.h"
@@ -590,7 +590,7 @@ cMenuChannelItem::cMenuChannelItem(int Index, cChannel *Channel)
index = Index;
channel = Channel;
if (channel->groupSep)
- SetColor(clrWhite, clrCyan);
+ SetColor(clrCyan, clrBackground);
Set();
}
@@ -600,7 +600,7 @@ void cMenuChannelItem::Set(void)
if (!channel->groupSep)
asprintf(&buffer, "%d\t%s", channel->number, channel->name );
else
- asprintf(&buffer, "\t%s", channel->name);
+ asprintf(&buffer, "---\t%s ----------------------------------------------------------------", channel->name);
SetText(buffer, false);
}
@@ -1590,6 +1590,80 @@ eOSState cMenuRecordings::ProcessKey(eKeys Key)
return state;
}
+#ifdef DVDSUPPORT
+// --- cMenuDVDItem ----------------------------------------------------------
+
+class cMenuDVDItem : public cOsdItem {
+ private:
+ int title;
+ int chapters;
+ virtual void Set(void);
+public:
+ cMenuDVDItem(int Title, int Chapters);
+ int Title(void) { return title; }
+ };
+
+cMenuDVDItem::cMenuDVDItem(int Title, int Chapters)
+{
+ title = Title;
+ chapters = Chapters;
+ Set();
+}
+
+void cMenuDVDItem::Set(void)
+{
+ char *buffer = NULL;
+ asprintf(&buffer, " %2d.\tTitle - \t%2d\tChapters", title + 1, chapters);
+ SetText(buffer, false);
+}
+
+// --- cMenuDVD --------------------------------------------------------------
+
+cMenuDVD::cMenuDVD(void)
+:cOsdMenu(tr("DVD"), 5, 8, 3)
+{
+ if ((dvd = cDVD::getDVD())) {
+ dvd->Open();
+ ifo_handle_t *vmg = dvd->openVMG();
+ if (vmg) {
+ dsyslog(LOG_INFO, "DVD: vmg: %p", vmg);//XXX
+ tt_srpt_t *tt_srpt = vmg->tt_srpt;
+ dsyslog(LOG_INFO, "DVD: tt_srpt: %p", tt_srpt);//XXX
+ for (int i = 0; i < tt_srpt->nr_of_srpts; i++)
+ Add(new cMenuDVDItem(i, tt_srpt->title[i].nr_of_ptts));
+ }
+ }
+ SetHelp(tr("Play"), NULL, NULL, NULL);
+ Display();
+}
+
+eOSState cMenuDVD::Play(void)
+{
+ cMenuDVDItem *ri = (cMenuDVDItem *)Get(Current());
+ if (ri) {
+ cReplayControl::SetDVD(dvd, ri->Title());
+ isyslog(LOG_INFO, "DVD: playing title %d", ri->Title());
+ return osReplay;
+ }
+ return osContinue;
+}
+
+eOSState cMenuDVD::ProcessKey(eKeys Key)
+{
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
+ case kRed: return Play();
+ case kMenu: return osEnd;
+ default: break;
+ }
+ }
+ return state;
+}
+#endif //DVDSUPPORT
+
// --- cMenuSetup ------------------------------------------------------------
class cMenuSetup : public cOsdMenu {
@@ -1714,23 +1788,21 @@ eOSState cMenuCommands::ProcessKey(eKeys Key)
#define STOP_RECORDING tr(" Stop recording ")
-static const char *hk(int n, const char *s)
-{
- static char buffer[32];
- snprintf(buffer, sizeof(buffer), " %d %s", n, s);
- return buffer;
-}
-
cMenuMain::cMenuMain(bool Replaying)
:cOsdMenu(tr("Main"))
{
- Add(new cOsdItem(hk(1, tr("Schedule")), osSchedule));
- Add(new cOsdItem(hk(2, tr("Channels")), osChannels));
- Add(new cOsdItem(hk(3, tr("Timers")), osTimers));
- Add(new cOsdItem(hk(4, tr("Recordings")), osRecordings));
- Add(new cOsdItem(hk(5, tr("Setup")), osSetup));
+ digit = 0;
+ Add(new cOsdItem(hk(tr("Schedule")), osSchedule));
+ Add(new cOsdItem(hk(tr("Channels")), osChannels));
+ Add(new cOsdItem(hk(tr("Timers")), osTimers));
+ Add(new cOsdItem(hk(tr("Recordings")), osRecordings));
+#ifdef DVDSUPPORT
+ if (cDVD::DriveExists())
+ Add(new cOsdItem(hk(tr("DVD")), osDVD));
+#endif //DVDSUPPORT
+ Add(new cOsdItem(hk(tr("Setup")), osSetup));
if (Commands.Count())
- Add(new cOsdItem(hk(6, tr("Commands")), osCommands));
+ Add(new cOsdItem(hk(tr("Commands")), osCommands));
if (Replaying)
Add(new cOsdItem(tr(" Stop replaying"), osStopReplay));
const char *s = NULL;
@@ -1741,13 +1813,30 @@ cMenuMain::cMenuMain(bool Replaying)
delete buffer;
}
if (cVideoCutter::Active())
- Add(new cOsdItem(tr(" Cancel editing"), osCancelEdit));
- SetHelp(tr("Record"), cDvbApi::PrimaryDvbApi->CanToggleAudioTrack() ? tr("Language") : NULL, NULL, cReplayControl::LastReplayed() ? tr("Resume") : NULL);
+ Add(new cOsdItem(hk(tr(" Cancel editing")), osCancelEdit));
+ const char *DVDbutton =
+#ifdef DVDSUPPORT
+ cDVD::DiscOk() ? tr("Eject DVD") : NULL;
+#else
+ NULL;
+#endif //DVDSUPPORT
+ SetHelp(tr("Record"), cDvbApi::PrimaryDvbApi->CanToggleAudioTrack() ? tr("Language") : NULL, DVDbutton, cReplayControl::LastReplayed() ? tr("Resume") : NULL);
Display();
lastActivity = time(NULL);
SetHasHotkeys();
}
+const char *cMenuMain::hk(const char *s)
+{
+ static char buffer[32];
+ if (digit < 9) {
+ snprintf(buffer, sizeof(buffer), " %d %s", ++digit, s);
+ return buffer;
+ }
+ else
+ return s;
+}
+
eOSState cMenuMain::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
@@ -1757,6 +1846,9 @@ eOSState cMenuMain::ProcessKey(eKeys Key)
case osChannels: return AddSubMenu(new cMenuChannels);
case osTimers: return AddSubMenu(new cMenuTimers);
case osRecordings: return AddSubMenu(new cMenuRecordings);
+#ifdef DVDSUPPORT
+ case osDVD: return AddSubMenu(new cMenuDVD);
+#endif //DVDSUPPORT
case osSetup: return AddSubMenu(new cMenuSetup);
case osCommands: return AddSubMenu(new cMenuCommands);
case osStopRecord: if (Interface->Confirm(tr("Stop recording?"))) {
@@ -1773,22 +1865,31 @@ eOSState cMenuMain::ProcessKey(eKeys Key)
}
break;
default: switch (Key) {
- case kMenu: state = osEnd; break;
- case kRed: if (!HasSubMenu())
- state = osRecord;
- break;
- case kGreen: if (!HasSubMenu()) {
- if (cDvbApi::PrimaryDvbApi->CanToggleAudioTrack()) {
- Interface->Clear();
- cDvbApi::PrimaryDvbApi->ToggleAudioTrack();
- state = osEnd;
- }
- }
- break;
- case kBlue: if (!HasSubMenu())
- state = osReplay;
- break;
- default: break;
+ case kMenu: state = osEnd; break;
+ case kRed: if (!HasSubMenu())
+ state = osRecord;
+ break;
+ case kGreen: if (!HasSubMenu()) {
+ if (cDvbApi::PrimaryDvbApi->CanToggleAudioTrack()) {
+ Interface->Clear();
+ cDvbApi::PrimaryDvbApi->ToggleAudioTrack();
+ state = osEnd;
+ }
+ }
+ break;
+#ifdef DVDSUPPORT
+ case kYellow: if (!HasSubMenu()) {
+ if (cDVD::DiscOk()) {
+ cDVD::Eject();
+ state = osEnd;
+ }
+ }
+ break;
+#endif //DVDSUPPORT
+ case kBlue: if (!HasSubMenu())
+ state = osReplay;
+ break;
+ default: break;
}
}
if (Key != kNone)
@@ -2144,6 +2245,10 @@ void cProgressBar::Mark(int x, bool Start, bool Current)
char *cReplayControl::fileName = NULL;
char *cReplayControl::title = NULL;
+#ifdef DVDSUPPORT
+cDVD *cReplayControl::dvd = NULL;//XXX
+int cReplayControl::titleid = 0;//XXX
+#endif //DVDSUPPORT
cReplayControl::cReplayControl(void)
{
@@ -2155,6 +2260,10 @@ cReplayControl::cReplayControl(void)
marks.Load(fileName);
dvbApi->StartReplay(fileName);
}
+#ifdef DVDSUPPORT
+ else if (dvd)
+ dvbApi->StartDVDplay(dvd, titleid);//XXX
+#endif //DVDSUPPORT
}
cReplayControl::~cReplayControl()
@@ -2171,6 +2280,15 @@ void cReplayControl::SetRecording(const char *FileName, const char *Title)
title = Title ? strdup(Title) : NULL;
}
+#ifdef DVDSUPPORT
+void cReplayControl::SetDVD(cDVD *DVD, int Title)//XXX
+{
+ SetRecording(NULL, NULL);
+ dvd = DVD;
+ titleid = Title;
+}
+#endif //DVDSUPPORT
+
const char *cReplayControl::LastReplayed(void)
{
return fileName;
@@ -2216,10 +2334,10 @@ bool cReplayControl::ShowProgress(bool Initial)
}
if (Total != lastTotal) {
Interface->Write(-7, 2, IndexToHMSF(Total));
- Interface->Flush();
- lastTotal = Total;
+ if (!Initial)
+ Interface->Flush();
}
- if (Current != lastCurrent) {
+ if (Current != lastCurrent || Total != lastTotal) {
#ifdef DEBUG_OSD
int p = Width() * Current / Total;
Interface->Fill(0, 1, p, 1, clrGreen);
@@ -2227,12 +2345,14 @@ bool cReplayControl::ShowProgress(bool Initial)
#else
cProgressBar ProgressBar(Width() * dvbApi->CellWidth(), dvbApi->LineHeight(), Current, Total, marks);
Interface->SetBitmap(0, dvbApi->LineHeight(), ProgressBar);
- Interface->Flush();
+ if (!Initial)
+ Interface->Flush();
#endif
Interface->Write(0, 2, IndexToHMSF(Current, displayFrames));
Interface->Flush();
lastCurrent = Current;
}
+ lastTotal = Total;
return true;
}
return false;
@@ -2338,11 +2458,10 @@ eOSState cReplayControl::ProcessKey(eKeys Key)
// Positioning:
case kUp: dvbApi->Play(); break;
case kDown: dvbApi->Pause(); break;
- case kLeft: dvbApi->Backward(); break;
- case kRight: dvbApi->Forward(); break;
case kLeft|k_Release:
+ case kLeft: dvbApi->Backward(); break;
case kRight|k_Release:
- dvbApi->Play(); break;
+ case kRight: dvbApi->Forward(); break;
case kGreen|k_Repeat:
case kGreen: dvbApi->SkipSeconds(-60); break;
case kYellow|k_Repeat: