diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2012-03-02 15:49:57 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2012-03-02 15:49:57 +0100 |
commit | c5eb60f07a560d9baed751edbb5b5c0246c8e903 (patch) | |
tree | 419f655ba1aa9dd9ccb20cd91a9f6658d4bfde40 | |
parent | e7b0f909ff42983c9f22b9db0e4ad6686942ea8b (diff) | |
download | vdr-c5eb60f07a560d9baed751edbb5b5c0246c8e903.tar.gz vdr-c5eb60f07a560d9baed751edbb5b5c0246c8e903.tar.bz2 |
Fixed handling OSD color button texts in case a menu item has texts of its own
-rw-r--r-- | CONTRIBUTORS | 2 | ||||
-rw-r--r-- | HISTORY | 5 | ||||
-rw-r--r-- | menuitems.c | 28 | ||||
-rw-r--r-- | menuitems.h | 7 | ||||
-rw-r--r-- | osdbase.c | 25 | ||||
-rw-r--r-- | osdbase.h | 4 |
6 files changed, 61 insertions, 10 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 32c23dcf..d2ef1f3f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1135,6 +1135,8 @@ Rolf Ahrenberg <rahrenbe@cc.hut.fi> "word by word" for reporting a problem with color palettes in subtitles for adding some typecasts to silence gcc compiler warnings + for reporting a bug in handling OSD color button texts in case a menu item has + texts of its own Ralf Klueber <ralf.klueber@vodafone.com> for reporting a bug in cutting a recording if there is only a single editing mark @@ -6947,3 +6947,8 @@ Video Disk Recorder Revision History - Added a Query parameter to cDevice::GetDevice(), so that devices can be queried without side effects when zapping. - Replaced min(max()) calls with the new function constrain(). +- Fixed handling OSD color button texts in case a menu item has texts of its own + (reported by Rolf Ahrenberg). If a plugin creates derived cMenuEditItems that set + color button texts, these should not set the texts directly by calling + cSkinDisplay::Current()->SetButtons(), but rather call the new member function + cMenuEditItem::SetHelp(). diff --git a/menuitems.c b/menuitems.c index e7797d6e..dc3ea715 100644 --- a/menuitems.c +++ b/menuitems.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menuitems.c 2.10 2011/08/12 13:19:40 kls Exp $ + * $Id: menuitems.c 2.11 2012/03/02 15:49:57 kls Exp $ */ #include "menuitems.h" @@ -26,6 +26,7 @@ const char *FileNameChars = trNOOP("FileNameChars$ abcdefghijklmnopqrstuvwxyz012 cMenuEditItem::cMenuEditItem(const char *Name) { name = strdup(Name ? Name : "???"); + SetHelp(NULL); } cMenuEditItem::~cMenuEditItem() @@ -40,6 +41,27 @@ void cMenuEditItem::SetValue(const char *Value) cStatus::MsgOsdCurrentItem(buffer); } +void cMenuEditItem::SetHelp(const char *Red, const char *Green, const char *Yellow, const char *Blue) +{ + // strings are NOT copied - must be constants!!! + helpRed = Red; + helpGreen = Green; + helpYellow = Yellow; + helpBlue = Blue; + helpDisplayed = false; +} + +bool cMenuEditItem::DisplayHelp(void) +{ + bool HasHelp = helpRed || helpGreen || helpYellow || helpBlue; + if (HasHelp && !helpDisplayed) { + cSkinDisplay::Current()->SetButtons(helpRed, helpGreen, helpYellow, helpBlue); + cStatus::MsgOsdHelpKeys(helpRed, helpGreen, helpYellow, helpBlue); + helpDisplayed = true; + } + return HasHelp; +} + // --- cMenuEditIntItem ------------------------------------------------------ cMenuEditIntItem::cMenuEditIntItem(const char *Name, int *Value, int Min, int Max, const char *MinString, const char *MaxString) @@ -382,9 +404,9 @@ void cMenuEditStrItem::LeaveEditMode(bool SaveValue) void cMenuEditStrItem::SetHelpKeys(void) { if (InEditMode()) - cSkinDisplay::Current()->SetButtons(tr("Button$ABC/abc"), insert ? tr("Button$Overwrite") : tr("Button$Insert"), tr("Button$Delete")); + SetHelp(tr("Button$ABC/abc"), insert ? tr("Button$Overwrite") : tr("Button$Insert"), tr("Button$Delete")); else - cSkinDisplay::Current()->SetButtons(NULL); + SetHelp(NULL); } uint *cMenuEditStrItem::IsAllowed(uint c) diff --git a/menuitems.h b/menuitems.h index a6f27438..db31bda4 100644 --- a/menuitems.h +++ b/menuitems.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menuitems.h 2.5 2011/06/13 13:46:03 kls Exp $ + * $Id: menuitems.h 2.6 2012/03/02 15:49:57 kls Exp $ */ #ifndef __MENUITEMS_H @@ -19,10 +19,15 @@ extern const char *FileNameChars; class cMenuEditItem : public cOsdItem { private: char *name; + const char *helpRed, *helpGreen, *helpYellow, *helpBlue; + bool helpDisplayed; +protected: + void SetHelp(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL); public: cMenuEditItem(const char *Name); ~cMenuEditItem(); void SetValue(const char *Value); + bool DisplayHelp(void); }; class cMenuEditIntItem : public cMenuEditItem { @@ -4,13 +4,14 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osdbase.c 2.3 2010/12/12 13:41:28 kls Exp $ + * $Id: osdbase.c 2.4 2012/03/02 15:49:57 kls Exp $ */ #include "osdbase.h" #include <string.h> #include "device.h" #include "i18n.h" +#include "menuitems.h" #include "remote.h" #include "status.h" @@ -85,6 +86,7 @@ cOsdMenu::cOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) current = marked = -1; subMenu = NULL; helpRed = helpGreen = helpYellow = helpBlue = NULL; + helpDisplayed = false; status = NULL; if (!displayMenuCount++) SetDisplayMenu(); @@ -154,6 +156,15 @@ void cOsdMenu::SetTitle(const char *Title) title = strdup(Title); } +void cOsdMenu::DisplayHelp(bool Force) +{ + if (!helpDisplayed || Force) { + displayMenu->SetButtons(helpRed, helpGreen, helpYellow, helpBlue); + cStatus::MsgOsdHelpKeys(helpRed, helpGreen, helpYellow, helpBlue); + helpDisplayed = true; + } +} + void cOsdMenu::SetHelp(const char *Red, const char *Green, const char *Yellow, const char *Blue) { // strings are NOT copied - must be constants!!! @@ -161,8 +172,7 @@ void cOsdMenu::SetHelp(const char *Red, const char *Green, const char *Yellow, c helpGreen = Green; helpYellow = Yellow; helpBlue = Blue; - displayMenu->SetButtons(helpRed, helpGreen, helpYellow, helpBlue); - cStatus::MsgOsdHelpKeys(helpRed, helpGreen, helpYellow, helpBlue); + DisplayHelp(true); } void cOsdMenu::Del(int Index) @@ -205,8 +215,7 @@ void cOsdMenu::Display(void) displayMenu->SetTabs(cols[0], cols[1], cols[2], cols[3], cols[4]);//XXX displayMenu->SetTitle(title); cStatus::MsgOsdTitle(title); - displayMenu->SetButtons(helpRed, helpGreen, helpYellow, helpBlue); - cStatus::MsgOsdHelpKeys(helpRed, helpGreen, helpYellow, helpBlue); + DisplayHelp(true); int count = Count(); if (count > 0) { int ni = 0; @@ -263,6 +272,12 @@ void cOsdMenu::DisplayCurrent(bool Current) cStatus::MsgOsdCurrentItem(item->Text()); if (!Current) item->SetFresh(true); // leaving the current item resets 'fresh' + if (cMenuEditItem *MenuEditItem = dynamic_cast<cMenuEditItem *>(item)) { + if (!MenuEditItem->DisplayHelp()) + DisplayHelp(); + else + helpDisplayed = false; + } } } @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osdbase.h 2.1 2010/01/16 14:25:31 kls Exp $ + * $Id: osdbase.h 2.2 2012/03/02 15:49:57 kls Exp $ */ #ifndef __OSDBASE_H @@ -92,9 +92,11 @@ private: int first, current, marked; cOsdMenu *subMenu; const char *helpRed, *helpGreen, *helpYellow, *helpBlue; + bool helpDisplayed; char *status; int digit; bool hasHotkeys; + void DisplayHelp(bool Force = false); protected: void SetDisplayMenu(void); cSkinDisplayMenu *DisplayMenu(void) { return displayMenu; } |