diff --git a/CONTRIBUTORS b/CONTRIBUTORS index da8756a7..87104638 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2593,6 +2593,7 @@ Markus Ehrnsperger for implementing cStatus::OsdItem2() with the information whether the item is selectable for reporting an improper call of cStatus::OsdCurrentItem() before cStatus::OsdItem2() for fixing unnecessary calls to DisplayCurrent() for editable menu items + for implementing cStatus::OsdCurrentItem2() with the index of the current item Werner Färber for reporting a bug in handling the cPluginManager::Active() result when pressing diff --git a/HISTORY b/HISTORY index 0e8af1a9..77f83790 100644 --- a/HISTORY +++ b/HISTORY @@ -10068,3 +10068,7 @@ Video Disk Recorder Revision History - Fixed an unnecessary redisplay of the menu when pressing a hotkey. - Fixed unnecessary calls to DisplayCurrent() for editable menu items (thanks to Markus Ehrnsperger). +- The new virtual function cStatus::OsdCurrentItem2() can be used to get the index of the + current menu item (thanks to Markus Ehrnsperger). Plugins that implemented + cStatus::OsdCurrentItem() will still work as before, because the default implementation + of cStatus::OsdCurrentItem2() calls cStatus::OsdCurrentItem(). diff --git a/osdbase.c b/osdbase.c index 3584d35a..a5f91369 100644 --- a/osdbase.c +++ b/osdbase.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osdbase.c 5.4 2025/01/29 10:35:25 kls Exp $ + * $Id: osdbase.c 5.5 2025/01/29 11:15:26 kls Exp $ */ #include "osdbase.h" @@ -268,7 +268,7 @@ void cOsdMenu::Display(void) bool CurrentSelectable = (i == current) && item->Selectable(); item->SetMenuItem(displayMenu, i - first, CurrentSelectable, item->Selectable()); if (CurrentSelectable) - cStatus::MsgOsdCurrentItem(item->Text()); + cStatus::MsgOsdCurrentItem(item->Text(), i); if (++n == displayMenuItems) break; i++; @@ -300,7 +300,7 @@ void cOsdMenu::DisplayCurrent(bool Current) if (item) { item->SetMenuItem(displayMenu, current - first, Current && item->Selectable(), item->Selectable()); if (Current && item->Selectable()) - cStatus::MsgOsdCurrentItem(item->Text()); + cStatus::MsgOsdCurrentItem(item->Text(), current); if (!Current) item->SetFresh(true); // leaving the current item resets 'fresh' if (cMenuEditItem *MenuEditItem = dynamic_cast(item)) { @@ -321,7 +321,7 @@ void cOsdMenu::DisplayItem(cOsdItem *Item) bool Current = Index == current; Item->SetMenuItem(displayMenu, Offset, Current && Item->Selectable(), Item->Selectable()); if (Current && Item->Selectable()) - cStatus::MsgOsdCurrentItem(Item->Text()); + cStatus::MsgOsdCurrentItem(Item->Text(), Index); } } } diff --git a/status.c b/status.c index afef0b12..922c35ab 100644 --- a/status.c +++ b/status.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: status.c 5.1 2025/01/16 09:42:11 kls Exp $ + * $Id: status.c 5.2 2025/01/29 11:15:26 kls Exp $ */ #include "status.h" @@ -113,10 +113,10 @@ void cStatus::MsgOsdItem(const char *Text, int Index, bool Selectable) sm->OsdItem2(Text, Index, Selectable); } -void cStatus::MsgOsdCurrentItem(const char *Text) +void cStatus::MsgOsdCurrentItem(const char *Text, int Index) { for (cStatus *sm = statusMonitors.First(); sm; sm = statusMonitors.Next(sm)) - sm->OsdCurrentItem(Text); + sm->OsdCurrentItem2(Text, Index); } void cStatus::MsgOsdTextItem(const char *Text, bool Scroll) diff --git a/status.h b/status.h index 1c40dfd8..7f95b267 100644 --- a/status.h +++ b/status.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: status.h 5.1 2025/01/16 09:42:11 kls Exp $ + * $Id: status.h 5.2 2025/01/29 11:15:26 kls Exp $ */ #ifndef __STATUS_H @@ -92,6 +92,9 @@ protected: // Selectable is true if this item can be selected. virtual void OsdCurrentItem(const char *Text) {} // The OSD displays the given single line Text as the current menu item. + virtual void OsdCurrentItem2(const char *Text, int Index) { OsdCurrentItem(Text); } + // The OSD displays the given single line Text as the current menu item. + // Index is the one that was given in OsdItem[2]() for this item. virtual void OsdTextItem(const char *Text, bool Scroll) {} // The OSD displays the given multi line text. If Text points to an // actual string, that text shall be displayed and Scroll has no @@ -121,7 +124,7 @@ public: static void MsgOsdStatusMessage(const char *Message); static void MsgOsdHelpKeys(const char *Red, const char *Green, const char *Yellow, const char *Blue); static void MsgOsdItem(const char *Text, int Index, bool Selectable = true); - static void MsgOsdCurrentItem(const char *Text); + static void MsgOsdCurrentItem(const char *Text, int Index = -1); static void MsgOsdTextItem(const char *Text, bool Scroll = false); static void MsgOsdChannel(const char *Text); static void MsgOsdProgramme(time_t PresentTime, const char *PresentTitle, const char *PresentSubtitle, time_t FollowingTime, const char *FollowingTitle, const char *FollowingSubtitle);