diff options
author | lordjaxom <lordjaxom> | 2004-05-31 19:56:56 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2004-05-31 19:56:56 +0000 |
commit | b968a310699595ff139278440ae278aebf112c1f (patch) | |
tree | 1944e18832ee3f7420634db6a607aec6c35b76e8 | |
parent | 377ef2b18a6499a1ef0e540a74c4e54317efee85 (diff) | |
download | vdr-plugin-text2skin-b968a310699595ff139278440ae278aebf112c1f.tar.gz vdr-plugin-text2skin-b968a310699595ff139278440ae278aebf112c1f.tar.bz2 |
- "Background" may be initialized with a color nowv0.0.1-rc1
- fixed channel name/number display
- added parameter type (to store logo's filetype)
- "Timebar", "Progressbar" and "Volumebar": Background is only drawn if bg is
specified
- fixed timebar (was running backwards)
- renamed "Progressbar" to "Replaybar" for more consistency
- renamed "Logo" to "ChannelLogo"
- introduced items "Language" (for audio language texts or symbols) and "Image"
(foreground images)
- adopted SKINS document (SKINS.de is not up-to-date yet)
- introduced item "MenuTitle"
- introduced items "MenuRed", "MenuGreen", "MenuYellow" and "MenuBlue"
- activated message items for display in menu
- introcuded parameter "arc" and item "Slope"
- fixed possible segfault in Item=Message
- implemented items "SymbolReplaying" and "SymbolRadio"
- added "text" parameter for all text like Items (explanation follows)
- added "SymbolPlay", "SymbolPause", "SymbolFastFwd", "SymbolFastRew",
"SymbolSlowFwd", "SymbolSlowRew" items.
-rw-r--r-- | HISTORY | 25 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | SKINS | 103 | ||||
-rw-r--r-- | bitmap.c | 11 | ||||
-rw-r--r-- | bitmap.h | 6 | ||||
-rw-r--r-- | common.c | 49 | ||||
-rw-r--r-- | common.h | 10 | ||||
-rw-r--r-- | data.c | 175 | ||||
-rw-r--r-- | data.h | 88 | ||||
-rw-r--r-- | display.c | 88 | ||||
-rw-r--r-- | display.h | 7 | ||||
-rw-r--r-- | font.c | 127 | ||||
-rw-r--r-- | font.h | 41 | ||||
-rw-r--r-- | loader.c | 7 | ||||
-rw-r--r-- | loader.h | 13 | ||||
-rw-r--r-- | render.c | 479 | ||||
-rw-r--r-- | render.h | 67 | ||||
-rw-r--r-- | text2skin.c | 6 |
18 files changed, 940 insertions, 370 deletions
@@ -1,9 +1,32 @@ VDR Plugin 'text2skin' Revision History --------------------------------------- +2004-05-31: Version 0.0.1-rc1 + +- "Background" may be initialized with a color now +- fixed channel name/number display +- added parameter type (to store logo's filetype) +- "Timebar", "Progressbar" and "Volumebar": Background is only drawn if bg is + specified +- fixed timebar (was running backwards) +- renamed "Progressbar" to "Replaybar" for more consistency +- renamed "Logo" to "ChannelLogo" +- introduced items "Language" (for audio language texts or symbols) and "Image" + (foreground images) +- adopted SKINS document (SKINS.de is not up-to-date yet) +- introduced item "MenuTitle" +- introduced items "MenuRed", "MenuGreen", "MenuYellow" and "MenuBlue" +- activated message items for display in menu +- introcuded parameter "arc" and item "Slope" +- fixed possible segfault in Item=Message +- implemented items "SymbolReplaying" and "SymbolRadio" +- added "text" parameter for all text like Items (explanation follows) +- added "SymbolPlay", "SymbolPause", "SymbolFastFwd", "SymbolFastRew", + "SymbolSlowFwd", "SymbolSlowRew" items. + 2004-05-23: Version 0.0.1-pre2 -- added "ChannelSmall" section +- added "ChannelSmall" section (apparently VDR doesn't use it) - added replay and message items - added a german translation of the SKINS document (incomplete) @@ -1,11 +1,11 @@ # # Makefile for a Video Disk Recorder plugin # -# $Id: Makefile,v 1.1.1.1 2004/05/23 00:08:03 lordjaxom Exp $ +# $Id: Makefile,v 1.2 2004/05/26 21:27:11 lordjaxom Exp $ # disable in case you don't want to install imlib # in that case, you will not be able to load other files than simple xpms -HAVE_IMLIB=1 +HAVE_IMLIB2=1 # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. @@ -44,8 +44,8 @@ PACKAGE = vdr-$(ARCHIVE) ### Includes and Defines (add further entries here): -ifdef HAVE_IMLIB - DEFINES += -DHAVE_IMLIB +ifdef HAVE_IMLIB2 + DEFINES += -DHAVE_IMLIB2 endif INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include @@ -123,9 +123,10 @@ Description: This adds a background area for the specific display. This area background for everything that will be drawn later on. You can define a background image for that area here, too. That picture has to be the same width and height as the area. If you don't use - a background image, the area will not be initialized with any - content. The background color will replace the color 0 in the - images palette, and the foreground color will replace color 1. + a background image, the area will be initialized with the bg color + (default 0). If an image is present, the background color will + replace the color 0 in the images palette, and the foreground + color will replace color 1. Parameters: x, y, width, height, bpp, path, bg, fg Item: Item=Text @@ -135,34 +136,47 @@ Description: Draws plain text into the given area, using the given foreground limits are the background areas. Parameters: x, y, text, width, height, fg, font, align +Item: Item=Image +Description: Draws a plain image into the given area, using background and + foreground color (if given) to replace the palette indices 0 + and 1. +Parameters: x, y, width, height, fg, bg, path Item: Item=DateTime Description: Draws a date and time string into the given area. Otherwise, see Item=Text -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=Date Description: Draws a date string into the given area. Otherwise, see Item=Text -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=Time Description: Draws a time string into the given area. Otherwise, see Item=Text -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text + +Item: Item=ChannelLogo +Description: Draws a logo for the current channel (if present). The logo's + filename will be the channel name, and the parameter type + gives the file extension. The parameter path can give an + additional subdirectory to the skin's directory. +Example: Item=ChannelLogo,path=logos/,type=png,...; +Parameters: x, y, width, height, fg, bg, path, type Item: Item=ChannelNumberName Description: Draws the channel number and name into the given area. Otherwise, see Item=Text -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=ChannelNumber Description: Draws the channel number into the given area. Otherwise, see Item=Text -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=ChannelName Description: Draws the channel name into the given area. Otherwise, see Item=Text -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=Rectangle Description: Draws a filled rectangle into the defined area. @@ -175,34 +189,35 @@ Parameters: x, y, width, height, fg Item: Item=Timebar Description: Draws a timebar displaying the progress of the current programme. - The area will be filled with the background color and the bar will - be drawn using the foreground color. If width is greater than - height, the bar will be drawn vertically, otherwise horizontally. + The area will be filled with the background color (if given) and + the bar will be drawn using the foreground color. If width is + greater than height, the bar will be drawn horizontally, otherwise + vertically. Parameters: x, y, width, height, fg, bg Item: Item=PresentTime Description: Draws the start time of the present programme. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=PresentTitle Description: Draws the title of the present programme. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=PresentShortText Description: Draws the short text (or episode name) of the present programme. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=FollowingTime Description: Draws the start time of the following programme. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=FollowingTitle Description: Draws the title of the following programme. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=FollowingShortText Description: Draws the short text (or episode name) of the following programme. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=SymbolTeletext Description: Draws the specified image into the specified location if the @@ -232,6 +247,28 @@ Description: Draws the specified image into the specified location if the image handling, see Item=Background. Parameters: x, y, width, height, path, altpath, fg, bg +Item: Item=SymbolRecording +Description: Draws the specified image into the specified location if VDR is + currently recording. If that is not the case, the alternative + image (if given) will be displayed. For details on the image + handling, see Item=Background. +Parameters: x, y, width, height, path, altpath, fg, bg + +Item: Item=SymbolRadio +Description: Draws the specified image into the specified location if the + current channel is a radio channel. If that is not the case, the + alternative image (if given) will be displayed. For details on the + image handling, see Item=Background. +Parameters: x, y, width, height, path, altpath, fg, bg + +Item: Item=Language +Description: Draws a logo for the current language (currently the only + languages VDR knows are "Audio 1" and possibly "Audio 2", + regardless of the real language). For more information on how + the logo is found, see Item=ChannelLogo. The logo's filename will + be the language's name. +Parameters: x, y, width, height, path, type, fg, bg + Item: Item=Volumebar Description: Draws a volumebar into the specified area. For more details, see Item=Timebar. @@ -243,42 +280,42 @@ Description: Draws a mute symbol and/or text (if given) into the specified area. handling. Parameters: x, y, width, height, fg, bg, text, font, align, path -Item: Item=Progressbar +Item: Item=Replaybar Description: Draws a progressbar displaying the replay progress into the specified area. For more details, see Item=Timebar. Parameters: x, y, width, height, fg, bg Item: Item=ReplayTitle Description: Draws the title of the current replay. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=ReplayCurrent Description: Draws the current time in the current replay. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=ReplayTotal Description: Draws the total length of the current replay. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=ReplayJump Description: Draws the "Jump:" prompt (if present) of the current replay. -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=MessageStatus Description: Draws the current status message (if present). -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=MessageInfo Description: Draws the current info message (if present). -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=MessageWarning Description: Draws the current warning message (if present). -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Item: Item=MessageError Description: Draws the current error message (if present). -Parameters: x, y, width, height, fg, font, align +Parameters: x, y, width, height, fg, font, align, text Known Parameters @@ -337,7 +374,17 @@ Description: A string representing a path- and filename relative to the skin Default: not given Parameter: text -Description: The string that will be displayed. +Description: For non-text-items (and for the item "Text" itself), this is the + plain text to be displayed. For items that have it's own texts + (such as "Date", "PresentTitle" etc.), this is a template that + defines how the text is to be displayed. A dollar symbol '$' will + be replaced by the original text. +Default: not given +Example: Item=ReplayCurrent,text=Current: $; would display for example + "Current: 0:00:21" instead of only "0:00:21". + +Parameter: type +Description: The string giving the file extensions for logos. Default: not given Parameter: align @@ -1,8 +1,10 @@ /* - * $Id: bitmap.c,v 1.1.1.1 2004/05/23 00:08:03 lordjaxom Exp $ + * $Id: bitmap.c,v 1.3 2004/05/31 19:54:12 lordjaxom Exp $ */ +#define __STL_CONFIG_H #include <vdr/tools.h> +#undef __STL_CONFIG_H #include "bitmap.h" #define X_DISPLAY_MISSING #include <Imlib2.h> @@ -24,7 +26,7 @@ bool cText2SkinBitmap::Load(const char *Filename) { if (len > 4) { if (strcmp(Filename + len - 4, ".xpm") == 0) return LoadXpm(Filename); -#ifdef HAVE_IMLIB +#ifdef HAVE_IMLIB2 else if (strcmp(Filename + len - 4, ".png") == 0) return LoadPng(Filename); #endif @@ -35,7 +37,7 @@ bool cText2SkinBitmap::Load(const char *Filename) { return false; } -#ifdef HAVE_IMLIB +#ifdef HAVE_IMLIB2 bool cText2SkinBitmap::LoadPng(const char *Filename) { Imlib_Image image; image = imlib_load_image(Filename); @@ -48,8 +50,9 @@ bool cText2SkinBitmap::LoadPng(const char *Filename) { int pal = 0, pos = 0; for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) { - tColor col = (data[pos + 0] << 24) | (data[pos + 1] << 16) | (data[pos + 2] << 8) | data[pos + 3]; + tColor col = (data[pos + 3] << 24) | (data[pos + 2] << 16) | (data[pos + 1] << 8) | data[pos + 0]; int res = Index(col); + //printf("color: r=%d,g=%d,b=%d,a=%d\n", data[pos], data[pos+1], data[pos+2], data[pos+3]); if (pal > 0 && res == 0) ;//esyslog("ERROR: text2skin: Too many colors used in palette"); else @@ -1,11 +1,13 @@ /* - * $Id: bitmap.h,v 1.1.1.1 2004/05/23 00:08:03 lordjaxom Exp $ + * $Id: bitmap.h,v 1.3 2004/05/31 19:54:12 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_BITMAP_H #define VDR_TEXT2SKIN_BITMAP_H +#define __STL_CONFIG_H #include <vdr/osd.h> +#undef __STL_CONFIG_H class cText2SkinBitmap: public cBitmap { public: @@ -14,7 +16,7 @@ public: virtual ~cText2SkinBitmap(); bool Load(const char *Filename); -#ifdef HAVE_IMLIB +#ifdef HAVE_IMLIB2 bool LoadPng(const char *Filename); #endif }; @@ -1,8 +1,10 @@ /* - * $Id: common.c,v 1.1.1.1 2004/05/23 00:08:03 lordjaxom Exp $ + * $Id: common.c,v 1.4 2004/05/31 19:54:12 lordjaxom Exp $ */ +#define __STL_CONFIG_H #include <vdr/plugin.h> +#undef __STL_CONFIG_H #include "data.h" #include "common.h" @@ -10,16 +12,6 @@ const char *SkinPath(void) { return cPlugin::ConfigDirectory(PLUGIN_NAME_I18N); } -const cFont *SkinFont(cText2SkinItem *Item) { - const cFont *font; - font = cFont::GetFont(fontOsd); - if (Item->Font()) { - if (strcmp(Item->Font(), "Sml") == 0) font = cFont::GetFont(fontSml); - else if (strcmp(Item->Font(), "Fix") == 0) font = cFont::GetFont(fontFix); - } - return font; -} - void DrawTextTransparent(cOsd *Osd, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment) { int w = Font->Width(s); int h = Font->Height(); @@ -69,3 +61,38 @@ void DrawTextTransparent(cOsd *Osd, int x, int y, const char *s, tColor ColorFg, x += CharData->width; } } + +const char *ChannelNumber(const cChannel *Channel, int Number) { + static char buffer[256]; + buffer[0] = '\0'; + if (Channel) { + if (!Channel->GroupSep()) + snprintf(buffer, sizeof(buffer), "%d%s", Channel->Number(), Number ? "-" : ""); + } + else if (Number) + snprintf(buffer, sizeof(buffer), "%d-", Number); + return buffer; +} + +const char *ChannelName(const cChannel *Channel, int Number) { + static char buffer[256]; + buffer[0] = '\0'; + if (Channel) + snprintf(buffer, sizeof(buffer), "%s", Channel->Name()); + else if (!Number) + snprintf(buffer, sizeof(buffer), "%s", tr("*** Invalid Channel ***")); + return buffer; +} + +string ItemText(cText2SkinItem *Item, const string &Content) { + string s; + if (Item->Text() != "") { + s = Item->Text(); + int pos; + while ((pos = s.find('$')) != -1) + s.replace(pos, 1, Content); + } else + s = Content; + return s; +} + @@ -1,14 +1,20 @@ /* - * $Id: common.h,v 1.1.1.1 2004/05/23 00:08:03 lordjaxom Exp $ + * $Id: common.h,v 1.4 2004/05/31 19:54:12 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_COMMON_H #define VDR_TEXT2SKIN_COMMON_H +#include <string> + class cText2SkinItem; +#define precond(x) if ((x)) { esyslog("ERROR: text2skin: "#x " not given"); return; } + const char *SkinPath(void); -const cFont *SkinFont(cText2SkinItem *Item); void DrawTextTransparent(cOsd *Osd, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment); +const char *ChannelNumber(const cChannel *Channel, int Number); +const char *ChannelName(const cChannel *Channel, int Number); +string ItemText(cText2SkinItem *Item, const string &Content); #endif // VDR_TEXT2SKIN_COMMON_H @@ -1,5 +1,5 @@ /* - * $Id: data.c,v 1.2 2004/05/23 19:20:26 lordjaxom Exp $ + * $Id: data.c,v 1.10 2004/05/31 19:54:12 lordjaxom Exp $ */ #include "data.h" @@ -9,29 +9,19 @@ eSkinSection cText2SkinItem::mParseSection = sectionUnknown; cText2SkinItem::cText2SkinItem(void) { mSection = sectionUnknown; mItem = itemUnknown; - mX = -1; - mY = -1; - mWidth = 0; - mHeight = 0; + mPos.x = -1; + mPos.y = -1; + mSize.w = 0; + mSize.h = 0; mBpp = 4; + mArc = 0; mFg = NULL; mBg = NULL; - mName = NULL; - mVersion = NULL; - mFont = NULL; - mPath = NULL; - mAltPath = NULL; - mText = NULL; + mFont = cFont::GetFont(fontOsd); mAlign = taDefault; } cText2SkinItem::~cText2SkinItem() { - free(mText); - free(mPath); - free(mAltPath); - free(mFont); - free(mVersion); - free(mName); delete mBg; delete mFg; } @@ -60,55 +50,69 @@ bool cText2SkinItem::Parse(const char *Text) { } // check if this is an item - char *item; - if (ParseVar(ptr, "Item", &item)) { + string item; + if (ParseVar(ptr, "Item", item)) { mSection = mParseSection; - if (strcmp(item, "Skin") == 0) { // the Skin item - if (ParseVar(ptr, "name", &mName) && ParseVar(ptr, "version", &mVersion)) + if (item == "Skin") { // the Skin item + if (ParseVar(ptr, "name", mName) && ParseVar(ptr, "version", mVersion)) mItem = itemSkin; else esyslog("ERROR: text2skin: Skin doesn't contain Item=Skin keyphrase"); } - else if (strcmp(item, "Background") == 0) mItem = itemBackground; - else if (strcmp(item, "Logo") == 0) mItem = itemLogo; - else if (strcmp(item, "Text") == 0) mItem = itemText; - else if (strcmp(item, "DateTime") == 0) mItem = itemDateTime; - else if (strcmp(item, "Date") == 0) mItem = itemDate; - else if (strcmp(item, "Time") == 0) mItem = itemTime; - else if (strcmp(item, "ChannelNumberName") == 0) mItem = itemChannelNumberName; - else if (strcmp(item, "ChannelNumber") == 0) mItem = itemChannelNumber; - else if (strcmp(item, "ChannelName") == 0) mItem = itemChannelName; - else if (strcmp(item, "Rectangle") == 0) mItem = itemRectangle; - else if (strcmp(item, "Ellipse") == 0) mItem = itemEllipse; - else if (strcmp(item, "Timebar") == 0) mItem = itemTimebar; - else if (strcmp(item, "PresentTime") == 0) mItem = itemPresentTime; - else if (strcmp(item, "PresentTitle") == 0) mItem = itemPresentTitle; - else if (strcmp(item, "PresentShortText") == 0) mItem = itemPresentShortText; - else if (strcmp(item, "FollowingTime") == 0) mItem = itemFollowingTime; - else if (strcmp(item, "FollowingTitle") == 0) mItem = itemFollowingTitle; - else if (strcmp(item, "FollowingShortText") == 0) mItem = itemFollowingShortText; - else if (strcmp(item, "SymbolTeletext") == 0) mItem = itemSymbolTeletext; - else if (strcmp(item, "SymbolAudio") == 0) mItem = itemSymbolAudio; - else if (strcmp(item, "SymbolDolby") == 0) mItem = itemSymbolDolby; - else if (strcmp(item, "SymbolEncrypted") == 0) mItem = itemSymbolEncrypted; - else if (strcmp(item, "Volumebar") == 0) mItem = itemVolumebar; - else if (strcmp(item, "Mute") == 0) mItem = itemMute; - else if (strcmp(item, "Progressbar") == 0) mItem = itemProgressbar; - else if (strcmp(item, "ReplayTitle") == 0) mItem = itemReplayTitle; - else if (strcmp(item, "ReplayCurrent") == 0) mItem = itemReplayCurrent; - else if (strcmp(item, "ReplayTotal") == 0) mItem = itemReplayTotal; - else if (strcmp(item, "ReplayJump") == 0) mItem = itemReplayJump; - else if (strcmp(item, "MessageStatus") == 0) mItem = itemMessageStatus; - else if (strcmp(item, "MessageInfo") == 0) mItem = itemMessageInfo; - else if (strcmp(item, "MessageWarning") == 0) mItem = itemMessageWarning; - else if (strcmp(item, "MessageError") == 0) mItem = itemMessageError; - else if (strcmp(item, "MenuArea") == 0) mItem = itemMenuArea; - else if (strcmp(item, "MenuItem") == 0) mItem = itemMenuItem; - else if (strcmp(item, "MenuCurrent") == 0) mItem = itemMenuCurrent; + else if (item == "Background") mItem = itemBackground; + else if (item == "ChannelLogo") mItem = itemChannelLogo; + else if (item == "Language") mItem = itemLanguage; + else if (item == "Text") mItem = itemText; + else if (item == "Image") mItem = itemImage; + else if (item == "DateTime") mItem = itemDateTime; + else if (item == "Date") mItem = itemDate; + else if (item == "Time") mItem = itemTime; + else if (item == "ChannelNumberName") mItem = itemChannelNumberName; + else if (item == "ChannelNumber") mItem = itemChannelNumber; + else if (item == "ChannelName") mItem = itemChannelName; + else if (item == "Rectangle") mItem = itemRectangle; + else if (item == "Ellipse") mItem = itemEllipse; + else if (item == "Slope") mItem = itemSlope; + else if (item == "Timebar") mItem = itemTimebar; + else if (item == "PresentTime") mItem = itemPresentTime; + else if (item == "PresentTitle") mItem = itemPresentTitle; + else if (item == "PresentShortText") mItem = itemPresentShortText; + else if (item == "FollowingTime") mItem = itemFollowingTime; + else if (item == "FollowingTitle") mItem = itemFollowingTitle; + else if (item == "FollowingShortText") mItem = itemFollowingShortText; + else if (item == "SymbolTeletext") mItem = itemSymbolTeletext; + else if (item == "SymbolAudio") mItem = itemSymbolAudio; + else if (item == "SymbolDolby") mItem = itemSymbolDolby; + else if (item == "SymbolEncrypted") mItem = itemSymbolEncrypted; + else if (item == "SymbolRecording") mItem = itemSymbolRecording; + else if (item == "SymbolRadio") mItem = itemSymbolRadio; + else if (item == "Volumebar") mItem = itemVolumebar; + else if (item == "Mute") mItem = itemMute; + else if (item == "Replaybar") mItem = itemReplaybar; + else if (item == "ReplayTitle") mItem = itemReplayTitle; + else if (item == "ReplayCurrent") mItem = itemReplayCurrent; + else if (item == "ReplayTotal") mItem = itemReplayTotal; + else if (item == "ReplayJump") mItem = itemReplayJump; + else if (item == "SymbolPlay") mItem = itemSymbolPlay; + else if (item == "SymbolPause") mItem = itemSymbolPause; + else if (item == "SymbolFastFwd") mItem = itemSymbolFastFwd; + else if (item == "SymbolFastRew") mItem = itemSymbolFastRew; + else if (item == "SymbolSlowFwd") mItem = itemSymbolSlowFwd; + else if (item == "SymbolFastFwd") mItem = itemSymbolFastFwd; + else if (item == "MessageStatus") mItem = itemMessageStatus; + else if (item == "MessageInfo") mItem = itemMessageInfo; + else if (item == "MessageWarning") mItem = itemMessageWarning; + else if (item == "MessageError") mItem = itemMessageError; + else if (item == "MenuArea") mItem = itemMenuArea; + else if (item == "MenuItem") mItem = itemMenuItem; + else if (item == "MenuCurrent") mItem = itemMenuCurrent; + else if (item == "MenuTitle") mItem = itemMenuTitle; + else if (item == "MenuRed") mItem = itemMenuRed; + else if (item == "MenuGreen") mItem = itemMenuGreen; + else if (item == "MenuYellow") mItem = itemMenuYellow; + else if (item == "MenuBlue") mItem = itemMenuBlue; else - esyslog("ERROR: text2skin: %s is not a valid theme item\n", item); - - free(item); + esyslog("ERROR: text2skin: %s is not a valid theme item\n", item.c_str()); if (mItem != itemUnknown) { if (mItem != itemSkin) @@ -123,39 +127,41 @@ bool cText2SkinItem::Parse(const char *Text) { } bool cText2SkinItem::ParseItem(const char *Text) { - ParseVar(Text, "x", &mX); - ParseVar(Text, "y", &mY); - ParseVar(Text, "width", &mWidth); - ParseVar(Text, "height", &mHeight); + ParseVar(Text, "x", &mPos.x); + ParseVar(Text, "y", &mPos.y); + ParseVar(Text, "width", &mSize.w); + ParseVar(Text, "height", &mSize.h); ParseVar(Text, "bpp", &mBpp); + ParseVar(Text, "arc", &mArc); ParseVar(Text, "fg", &mFg); ParseVar(Text, "bg", &mBg); ParseVar(Text, "font", &mFont); - ParseVar(Text, "path", &mPath); - ParseVar(Text, "altpath", &mAltPath); - ParseVar(Text, "text", &mText); + ParseVar(Text, "path", mPath); + ParseVar(Text, "altpath", mAltPath); + ParseVar(Text, "text", mText); + ParseVar(Text, "type", mType); ParseVar(Text, "align", &mAlign); return true; } bool cText2SkinItem::ParseVar(const char *Text, const char *Name, int *Value) { - char *value; - if (ParseVar(Text, Name, &value)) { - *Value = atoi(value); + string value; + if (ParseVar(Text, Name, value)) { + *Value = atoi(value.c_str()); return true; } return false; } -bool cText2SkinItem::ParseVar(const char *Text, const char *Name, char **Value){ +bool cText2SkinItem::ParseVar(const char *Text, const char *Name, string &Value){ char *ptr1, *ptr2; char *str; asprintf(&str, "%s=", Name); if ((ptr1 = strstr(Text, str))) { ptr1 += strlen(str); if ((ptr2 = strchr(ptr1, ',')) || (ptr2 = strchr(ptr1, ';'))) { - asprintf(Value, "%.*s", ptr2 - ptr1, ptr1); - free(str); + Value = ptr1; + Value.erase(ptr2 - ptr1); return true; } } @@ -164,19 +170,18 @@ bool cText2SkinItem::ParseVar(const char *Text, const char *Name, char **Value){ } bool cText2SkinItem::ParseVar(const char *Text, const char *Name, tColor **Value) { - char *value; - if (ParseVar(Text, Name, &value) && *value == '#') { - *Value = new tColor(strtoul(value + 1, NULL, 16)); + string value; + if (ParseVar(Text, Name, value) && value[0] == '#') { + *Value = new tColor(strtoul(value.c_str() + 1, NULL, 16)); return true; } return false; } bool cText2SkinItem::ParseVar(const char *Text, const char *Name, eTextAlignment *Value) { - char *value; - if (ParseVar(Text, Name, &value)) { - int v = atoi(value); - free(value); + string value; + if (ParseVar(Text, Name, value)) { + int v = atoi(value.c_str()); if (v == 0) *Value = (eTextAlignment)(taTop|taLeft); else if (v == 1) @@ -187,6 +192,16 @@ bool cText2SkinItem::ParseVar(const char *Text, const char *Name, eTextAlignment } return false; } + +bool cText2SkinItem::ParseVar(const char *Text, const char *Name, const cFont **Value) { + string value; + if (ParseVar(Text, Name, value)) { + if (value == "Sml") *Value = cFont::GetFont(fontSml); + else if (value == "Fix") *Value = cFont::GetFont(fontFix); + return true; + } + return false; +} cText2SkinData::cText2SkinData(const char *Skin) { mSkin = strdup(Skin); @@ -1,13 +1,18 @@ /* - * $Id: data.h,v 1.2 2004/05/23 19:20:26 lordjaxom Exp $ + * $Id: data.h,v 1.9 2004/05/31 19:54:12 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_DATA_H #define VDR_TEXT2SKIN_DATA_H +#define __STL_CONFIG_H #include <vdr/tools.h> #include <vdr/osd.h> #include <vdr/config.h> +#undef __STL_CONFIG_H +#include <string> + +using std::string; // sections and items known by skin files @@ -26,16 +31,19 @@ enum eSkinItem { itemUnknown, itemSkin, // item identifying the Skin itself itemBackground, - itemLogo, itemText, + itemImage, + itemRectangle, + itemEllipse, + itemSlope, itemDateTime, itemDate, itemTime, + itemChannelLogo, itemChannelNumberName, itemChannelNumber, itemChannelName, - itemRectangle, - itemEllipse, + itemLanguage, itemTimebar, itemPresentTime, itemPresentTitle, @@ -47,20 +55,41 @@ enum eSkinItem { itemSymbolAudio, itemSymbolDolby, itemSymbolEncrypted, + itemSymbolRecording, + itemSymbolRadio, itemVolumebar, itemMute, - itemProgressbar, + itemReplaybar, itemReplayTitle, itemReplayCurrent, itemReplayTotal, itemReplayJump, + itemSymbolPlay, + itemSymbolPause, + itemSymbolFastFwd, + itemSymbolFastRew, + itemSymbolSlowFwd, + itemSymbolSlowRew, itemMessageStatus, itemMessageInfo, itemMessageWarning, itemMessageError, itemMenuArea, itemMenuItem, - itemMenuCurrent + itemMenuCurrent, + itemMenuTitle, + itemMenuRed, + itemMenuGreen, + itemMenuYellow, + itemMenuBlue, +}; + +struct POINT { + int x, y; +}; + +struct SIZE { + int w, h; }; class cText2SkinItem: public cListObject { @@ -71,23 +100,26 @@ private: eSkinSection mSection; eSkinItem mItem; - int mX, mY; - int mWidth, mHeight; + POINT mPos; + SIZE mSize; int mBpp; + int mArc; tColor *mFg; tColor *mBg; - char *mName; - char *mVersion; - char *mFont; - char *mPath; - char *mAltPath; - char *mText; + const cFont *mFont; + string mName; + string mVersion; + string mPath; + string mAltPath; + string mText; + string mType; eTextAlignment mAlign; protected: bool ParseItem(const char *Text); bool ParseVar(const char *Text, const char *Name, int *Value); - bool ParseVar(const char *Text, const char *Name, char **Value); + bool ParseVar(const char *Text, const char *Name, const cFont **Value); + bool ParseVar(const char *Text, const char *Name, string &Value); bool ParseVar(const char *Text, const char *Name, tColor **Value); bool ParseVar(const char *Text, const char *Name, eTextAlignment *Value); @@ -99,21 +131,19 @@ public: eSkinSection Section(void) const { return mSection; } eSkinItem Item(void) const { return mItem; } - int X(void) const { return mX; } - int Y(void) const { return mY; } - int Width(void) const { return mWidth; } - int Height(void) const { return mHeight; } + const POINT &Pos(void) const { return mPos; } + const SIZE &Size(void) const { return mSize; } int Bpp(void) const { return mBpp; } - bool HasFg(void) const { return mFg != NULL; } - tColor Fg(void) const { return mFg ? *mFg : 0xFFFFFFFF; } - bool HasBg(void) const { return mBg != NULL; } - tColor Bg(void) const { return mBg ? *mBg : 0xFF000000; } - const char *Name(void) const { return mName; } - const char *Version(void) const { return mVersion; } - const char *Font(void) const { return mFont; } - const char *Path(void) const { return mPath; } - const char *AltPath(void) const { return mAltPath; } - const char *Text(void) const { return mText; } + int Arc(void) const { return mArc; } + const tColor *Fg(void) const { return mFg; } + const tColor *Bg(void) const { return mBg; } + const cFont *Font(void) const { return mFont; } + const string &Name(void) const { return mName; } + const string &Version(void) const { return mVersion; } + const string &Path(void) const { return mPath; } + const string &AltPath(void) const { return mAltPath; } + const string &Text(void) const { return mText; } + const string &Type(void) const { return mType; } eTextAlignment Align(void) const { return mAlign; } }; @@ -1,10 +1,10 @@ /* - * $Id: display.c,v 1.2 2004/05/23 19:20:26 lordjaxom Exp $ + * $Id: display.c,v 1.6 2004/05/31 19:54:12 lordjaxom Exp $ */ -#include "display.h" -#include "data.h" #include "render.h" +#include "data.h" +#include "display.h" // --- cText2SkinDisplayChannel ----------------------------------------------- @@ -22,17 +22,26 @@ cText2SkinDisplayChannel::~cText2SkinDisplayChannel() { void cText2SkinDisplayChannel::SetChannel(const cChannel *Channel, int Number) { printf("SetChannel\n"); - if (mRender->mChannel != Channel || mRender->mNumber != Number) { + if (mRender->mChannel != Channel || mRender->mChannelNumber != Number) { mRender->mChannel = Channel; - mRender->mNumber = Number; + mRender->mChannelNumber = Number; mDirty = true; } } void cText2SkinDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following) { - if (mRender->mPresent != Present || mRender->mFollowing != Following) { - mRender->mPresent = Present; - mRender->mFollowing = Following; + if (mRender->mChannelPresent != Present || mRender->mChannelFollowing != Following) { + mRender->mChannelPresent = Present; + mRender->mChannelFollowing = Following; + mDirty = true; + } +} + +void cText2SkinDisplayChannel::SetMessage(eMessageType Type, const char *Text) { + if (Text == NULL) Text = ""; + if (mRender->mMessageType != Type || mRender->mMessageText != Text) { + mRender->mMessageType = Type; + mRender->mMessageText = Text; mDirty = true; } } @@ -78,7 +87,7 @@ void cText2SkinDisplayVolume::Flush(void) { // --- cText2SkinDisplayReplay ------------------------------------------------ cText2SkinDisplayReplay::cText2SkinDisplayReplay(cText2SkinData *Data, bool ModeOnly) { - printf("cText2SkinDisplayVolume\n"); + printf("cText2SkinDisplayReplay\n"); mData = Data; mRender = new cText2SkinRender(mData, ModeOnly ? sectionReplayMode : sectionReplay); mDirty = false; @@ -112,6 +121,14 @@ void cText2SkinDisplayReplay::SetProgress(int Current, int Total) { } } +void cText2SkinDisplayReplay::SetMarks(const cMarks *Marks) { + printf("SetMarks: %p\n", Marks); + if (mRender->mReplayMarks != Marks) { + mRender->mReplayMarks = Marks; + mDirty = true; + } +} + void cText2SkinDisplayReplay::SetCurrent(const char *Current) { if (mRender->mReplayCurrentText != Current) { mRender->mReplayCurrentText = Current; @@ -127,8 +144,18 @@ void cText2SkinDisplayReplay::SetTotal(const char *Total) { } void cText2SkinDisplayReplay::SetJump(const char *Jump) { + if (Jump == NULL) Jump = ""; if (mRender->mReplayJump != Jump) { - mRender->mReplayJump = NULL; + mRender->mReplayJump = Jump; + mDirty = true; + } +} + +void cText2SkinDisplayReplay::SetMessage(eMessageType Type, const char *Text) { + if (Text == NULL) Text = ""; + if (mRender->mMessageType != Type || mRender->mMessageText != Text) { + mRender->mMessageType = Type; + mRender->mMessageText = Text; mDirty = true; } } @@ -155,6 +182,7 @@ cText2SkinDisplayMessage::~cText2SkinDisplayMessage() { } void cText2SkinDisplayMessage::SetMessage(eMessageType Type, const char *Text) { + if (Text == NULL) Text = ""; if (mRender->mMessageType != Type || mRender->mMessageText != Text) { mRender->mMessageType = Type; mRender->mMessageText = Text; @@ -182,7 +210,7 @@ cText2SkinDisplayMenu::cText2SkinDisplayMenu(cText2SkinData *Data) { cText2SkinItem *area = mData->Get(itemMenuArea); cText2SkinItem *item = mData->Get(itemMenuItem); if (area && item) - mMaxItems = area->Height() / item->Height(); + mMaxItems = area->Size().h / item->Size().h; else esyslog("ERROR: text2skin: Skin is missing the items MenuArea and/or MenuItem"); } @@ -192,35 +220,53 @@ cText2SkinDisplayMenu::~cText2SkinDisplayMenu() { } void cText2SkinDisplayMenu::Clear(void) { - mRender->mItems.clear(); - mRender->mCurrent = -1; + mRender->mMenuItems.clear(); + mRender->mMenuCurrent = -1; mDirty = true; } void cText2SkinDisplayMenu::SetTitle(const char *Title) { - if (mRender->mTitle != Title) { - mRender->mTitle = Title; + if (mRender->mMenuTitle != Title) { + mRender->mMenuTitle = Title; mDirty = true; } } void cText2SkinDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue) { + if (Red == NULL) Red = ""; + if (Green == NULL) Green = ""; + if (Yellow == NULL) Yellow = ""; + if (Blue == NULL) Blue = ""; + if (mRender->mMenuRed != Red || mRender->mMenuGreen != Green || mRender->mMenuYellow != Yellow || mRender->mMenuBlue != Blue) { + mRender->mMenuRed = Red; + mRender->mMenuGreen = Green; + mRender->mMenuYellow = Yellow; + mRender->mMenuBlue = Blue; + mDirty = true; + } } void cText2SkinDisplayMenu::SetMessage(eMessageType Type, const char *Text) { + printf("SetMessage: %d, %s\n", Type, Text); + if (Text == NULL) Text = ""; + if (mRender->mMessageType != Type || mRender->mMessageText != Text) { + mRender->mMessageType = Type; + mRender->mMessageText = Text; + mDirty = true; + } } void cText2SkinDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) { cText2SkinRender::MenuItem item = { Text, Selectable }; - if ((int)mRender->mItems.size() <= Index) { - mRender->mItems.push_back(item); + if ((int)mRender->mMenuItems.size() <= Index) { + mRender->mMenuItems.push_back(item); mDirty = true; - } else if (mRender->mItems[Index] != item) { - mRender->mItems[Index] = item; + } else if (mRender->mMenuItems[Index] != item) { + mRender->mMenuItems[Index] = item; mDirty = true; } - if (Current && mRender->mCurrent != Index) { - mRender->mCurrent = Index; + if (Current && mRender->mMenuCurrent != Index) { + mRender->mMenuCurrent = Index; mDirty = true; } } @@ -1,11 +1,13 @@ /* - * $Id: display.h,v 1.1.1.1 2004/05/23 00:08:03 lordjaxom Exp $ + * $Id: display.h,v 1.2 2004/05/31 19:54:12 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_SKIN_H #define VDR_TEXT2SKIN_SKIN_H +#define __STL_CONFIG_H #include <vdr/skins.h> +#undef __STL_CONFIG_H class cText2SkinData; class cText2SkinRender; @@ -23,6 +25,7 @@ public: virtual void SetChannel(const cChannel *Channel, int Number); virtual void SetEvents(const cEvent *Present, const cEvent *Following); + virtual void SetMessage(eMessageType Type, const char *Text); virtual void Flush(void); }; @@ -50,9 +53,11 @@ public: virtual void SetTitle(const char *Title); virtual void SetMode(bool Play, bool Forward, int Speed); virtual void SetProgress(int Current, int Total); + virtual void SetMarks(const cMarks *Marks); virtual void SetCurrent(const char *Current); virtual void SetTotal(const char *Total); virtual void SetJump(const char *Jump); + virtual void SetMessage(eMessageType Type, const char *Text); virtual void Flush(void); }; @@ -0,0 +1,127 @@ +/* + * $Id: font.c,v 1.5 2004/05/30 21:48:21 austriancoder Exp $ + */ + +#include "font.h" + +// ================================== +// constr. +cText2SkinFont::cText2SkinFont() +{ + m_library = 0; + m_face = 0; + + // init freetype2 lib + int error = FT_Init_FreeType(&m_library); + if (error) + { + esyslog("ERROR: Could not init freetype library\n"); + } +} + +// ================================== +// deconstr. +cText2SkinFont::~cText2SkinFont() +{ + if (m_face) + { + FT_Done_Face(m_face); + } + + if (m_library) + { + FT_Done_FreeType(m_library); + } +} + +// ================================== +// try to load a font +bool cText2SkinFont::LoadFontFile(string Filename) +{ + int error = FT_New_Face(m_library, Filename.c_str(), 0, &m_face); + + // every thing ok? + if (error == FT_Err_Unknown_File_Format) + { + esyslog("ERROR: Font file (%s) could be opened and read, but it appears that its font format is unsupported\n", Filename.c_str()); + return false; + } + else if (error) + { + esyslog("ERROR: Font file (%s) could be opened or read, or simply it is broken\n", Filename.c_str()); + return false; + } + + // set slot + m_slot = m_face->glyph; + + return true; +} + +// ================================== +// sets size of font +void cText2SkinFont::SetFontSize(int size) +{ + FT_Set_Char_Size + ( + m_face, // handle to face object + 0, // char_width in 1/64th of points + size*64, // char_height in 1/64th of points + 300, // horizontal device resolution (dpi) + 300 // vertical device resolution (dpi) + ); +} + +// ================================== +// write some text :) +void cText2SkinFont::DrawTextTransparent(cOsd *Osd, int x, int y, const char *s, tColor ColorFg, int Width, int Height, int Alignment) +{ + // where to get this infos? +// int w = Font->Width(s); +// int h = Font->Height(); + + int limit = 0; + if (Width || Height) + { + int cw = Width ? Width : w; + limit = x + cw; + if (Width) + { + if ((Alignment & taLeft) != 0) + ; + else if ((Alignment & taRight) != 0) + { + if (w < Width) + x += Width - w; + } + else + { + // taCentered + if (w < Width) + x += (Width - w) / 2; + } + } + + if (Height) + { + if ((Alignment & taTop) != 0) + ; + else if ((Alignment & taBottom) != 0) + { + if (h < Height) + y += Height - h; + } + else + { + // taCentered + if (h < Height) + y += (Height - h) / 2; + } + } + } + + // write text + while (s && *s) + { + } +} @@ -0,0 +1,41 @@ +/* + * $Id: font.h,v 1.3 2004/05/29 00:27:22 lordjaxom Exp $ + */ + +#ifndef VDR_TEXT2SKIN_FREETYPE_H +#define VDR_TEXT2SKIN_FREETYPE_H + +#include <ft2build.h> +#include FT_FREETYPE_H + +#include <string> +using std::string; + +#include "data.h" + +// kannst noch einbauen, dass er die fonts "fontOsd" "fontSml" und "fontFix" aus VDR statt aus freetype nimmt + +// ================================== +/* cText2SkinFont + + Adds interface to FreeTpye font lib. +*/ +class cText2SkinFont +{ +public: + cText2SkinFont(); + ~cText2SkinFont(); + + // font handling + bool LoadFontFile(string Filename); + void SetFontSize(int size); + void DrawTextTransparent(cOsd *Osd, int x, int y, const char *s, tColor ColorFg, int Width, int Height, int Alignment); + +private: + FT_Library m_library; + FT_Face m_face; + FT_GlyphSlot m_slot; + +}; + +#endif /*VDR_TEXT2SKIN_FREETYPE_H*/ @@ -1,8 +1,10 @@ /* - * $Id: loader.c,v 1.1.1.1 2004/05/23 00:08:03 lordjaxom Exp $ + * $Id: loader.c,v 1.4 2004/05/31 19:54:12 lordjaxom Exp $ */ +#define __STL_CONFIG_H #include <vdr/plugin.h> +#undef __STL_CONFIG_H #include "loader.h" #include "data.h" #include "display.h" @@ -49,7 +51,7 @@ void cText2SkinLoader::Load(const char *Skin) { esyslog("ERROR: text2skin: %s/%s is not a valid skin directory\n", SkinPath(), Skin); } -cText2SkinLoader::cText2SkinLoader(cText2SkinData *Data, const char *Skin, const char *Description): cSkin(Skin, &::Theme) { +cText2SkinLoader::cText2SkinLoader(cText2SkinData *Data, const string &Skin, const string &Description): cSkin(Skin.c_str(), &::Theme) { mData = Data; mDescription = Description; } @@ -60,6 +62,7 @@ cText2SkinLoader::~cText2SkinLoader() { } cSkinDisplayChannel *cText2SkinLoader::DisplayChannel(bool WithInfo) { + printf("WithInfo: %d\n", WithInfo); return new cText2SkinDisplayChannel(mData, WithInfo); } @@ -1,27 +1,32 @@ /* - * $Id: loader.h,v 1.1.1.1 2004/05/23 00:08:03 lordjaxom Exp $ + * $Id: loader.h,v 1.3 2004/05/31 19:54:12 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_LOADER_H #define VDR_TEXT2SKIN_LOADER_H +#define __STL_CONFIG_H #include <vdr/skins.h> +#undef __STL_CONFIG_H +#include <string> + +using std::string; class cText2SkinData; class cText2SkinLoader: public cSkin { private: cText2SkinData *mData; - const char *mDescription; + string mDescription; public: static void Start(void); static void Load(const char *Skin); - cText2SkinLoader(cText2SkinData *Data, const char *Skin, const char *Description); + cText2SkinLoader(cText2SkinData *Data, const string &Skin, const string &Description); ~cText2SkinLoader(); - virtual const char *Description(void) { return mDescription; }; + virtual const char *Description(void) { return mDescription.c_str(); } virtual cSkinDisplayChannel *DisplayChannel(bool WithInfo); virtual cSkinDisplayMenu *DisplayMenu(void); virtual cSkinDisplayReplay *DisplayReplay(bool ModeOnly); @@ -1,10 +1,13 @@ /* - * $Id: render.c,v 1.3 2004/05/23 19:20:26 lordjaxom Exp $ + * $Id: render.c,v 1.10 2004/05/31 19:54:12 lordjaxom Exp $ */ +#include "render.h" +#define __STL_CONFIG_H #include <vdr/channels.h> #include <vdr/epg.h> -#include "render.h" +#include <vdr/menu.h> +#undef __STL_CONFIG_H #include "data.h" #include "bitmap.h" #include "common.h" @@ -13,39 +16,36 @@ cText2SkinRender::cText2SkinRender(cText2SkinData *Data, eSkinSection Section) { tArea areas[MAXOSDAREAS]; int numAreas = 0; + printf("Section: %d\n",Section); + mData = Data; mSection = Section; mOsd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop); mChannel = NULL; - mNumber = 0; + mChannelNumber = 0; mVolumeCurrent = 0; mVolumeTotal = 0; mVolumeMute = false; - mReplayTitle = NULL; mReplayPlay = false; mReplayForward = false; mReplaySpeed = 0; mReplayCurrent = 0; mReplayTotal = 0; - mReplayCurrentText = NULL; - mReplayTotalText = NULL; - mReplayJump = NULL; + mReplayMarks = NULL; mMessageType = (eMessageType)-1; - mMessageText = NULL; - mPresent = NULL; - mFollowing = NULL; - mTitle = NULL; - mCurrent = 0; + mChannelPresent = NULL; + mChannelFollowing = NULL; + mMenuCurrent = 0; cText2SkinItem *item; for (item = Data->First(); item; item = Data->Next(item)) { if (item->Section() == Section && item->Item() == itemBackground) { if (numAreas < MAXOSDAREAS) { - printf("area item: %d:%d:%d:%d:%d\n", item->X(), item->Y(), item->X() + item->Width() - 1, item->Y() + item->Height() - 1, item->Bpp()); - areas[numAreas].x1 = item->X(); - areas[numAreas].y1 = item->Y(); - areas[numAreas].x2 = item->X() + item->Width() - 1; - areas[numAreas].y2 = item->Y() + item->Height() - 1; + printf("area item: %d:%d:%d:%d:%d\n", item->Pos().x, item->Pos().y, item->Pos().x + item->Size().w - 1, item->Pos().y + item->Size().h - 1, item->Bpp()); + areas[numAreas].x1 = item->Pos().x; + areas[numAreas].y1 = item->Pos().y; + areas[numAreas].x2 = item->Pos().x + item->Size().w - 1; + areas[numAreas].y2 = item->Pos().y + item->Size().h - 1; areas[numAreas].bpp = item->Bpp(); ++numAreas; } else @@ -91,10 +91,14 @@ void cText2SkinRender::Flush(void) { switch (item->Item()) { case itemBackground: DisplayBackground(item); break; - case itemLogo: - DisplayLogo(item); break; + case itemChannelLogo: + DisplayChannelLogo(item); break; + case itemLanguage: + DisplayLanguage(item); break; case itemText: DisplayText(item); break; + case itemImage: + DisplayImage(item); break; case itemDateTime: DisplayDateTime(item); break; case itemDate: @@ -111,6 +115,8 @@ void cText2SkinRender::Flush(void) { DisplayRectangle(item); break; case itemEllipse: DisplayEllipse(item); break; + case itemSlope: + DisplaySlope(item); break; case itemTimebar: DisplayTimebar(item); break; case itemPresentTime: @@ -129,13 +135,21 @@ void cText2SkinRender::Flush(void) { case itemSymbolAudio: case itemSymbolDolby: case itemSymbolEncrypted: + case itemSymbolRecording: + case itemSymbolRadio: + case itemSymbolPlay: + case itemSymbolPause: + case itemSymbolFastFwd: + case itemSymbolFastRew: + case itemSymbolSlowFwd: + case itemSymbolSlowRew: DisplaySymbol(item); break; case itemVolumebar: DisplayVolumebar(item); break; case itemMute: DisplayMute(item); break; - case itemProgressbar: - DisplayProgressbar(item); break; + case itemReplaybar: + DisplayReplaybar(item); break; case itemReplayTitle: DisplayReplayTitle(item); break; case itemReplayCurrent: @@ -145,15 +159,19 @@ void cText2SkinRender::Flush(void) { case itemReplayJump: DisplayReplayJump(item); break; case itemMessageInfo: - DisplayMessageInfo(item); break; case itemMessageStatus: - DisplayMessageStatus(item); break; case itemMessageWarning: - DisplayMessageWarning(item); break; case itemMessageError: - DisplayMessageError(item); break; + DisplayMessage(item); break; case itemMenuItem: DisplayMenuItems(item); break; + case itemMenuTitle: + DisplayMenuTitle(item); break; + case itemMenuRed: + case itemMenuGreen: + case itemMenuYellow: + case itemMenuBlue: + DisplayMenuColorbutton(item); break; default: break; } @@ -163,127 +181,255 @@ void cText2SkinRender::Flush(void) { mOsd->Flush(); } -void cText2SkinRender::DisplayBackground(cText2SkinItem *Item) { - printf("DisplayBackground\n"); - if (Item->Path()) { +void cText2SkinRender::DrawBackground(const POINT &Pos, const SIZE &Size, const tColor *Bg, const tColor *Fg, const string &Path) { + bool image = false; + cText2SkinBitmap bm; + if (Path != "") { char *p; - asprintf(&p, "%s/%s/%s", SkinPath(), mData->Skin(), Item->Path()); - cText2SkinBitmap bm(p); + asprintf(&p, "%s/%s/%s", SkinPath(), mData->Skin(), Path.c_str()); + if (bm.Load(p)) { + if (Bg) bm.SetColor(0, *Bg); + if (Fg) bm.SetColor(1, *Fg); + image = true; + } free(p); - if (Item->HasBg()) bm.SetColor(0, Item->Bg()); - if (Item->HasFg()) bm.SetColor(1, Item->Fg()); - mOsd->DrawBitmap(Item->X(), Item->Y(), bm); + } + + if (image) + mOsd->DrawBitmap(Pos.x, Pos.y, bm); + else + mOsd->DrawRectangle(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, Bg ? *Bg : 0); +} + +void cText2SkinRender::DrawImage(const POINT &Pos, const SIZE &Size, const tColor *Bg, const tColor *Fg, const string &Path) { + cText2SkinBitmap bm; + char *p; + asprintf(&p, "%s/%s/%s", SkinPath(), mData->Skin(), Path.c_str()); + printf("Trying to load image: %s\n", p); + if (bm.Load(p)) { + if (Bg) bm.SetColor(0, *Bg); + if (Fg) bm.SetColor(1, *Fg); + mOsd->DrawRectangle(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, bm.Color(0)); + mOsd->DrawBitmap(Pos.x, Pos.y, bm); + } + free(p); +} + +void cText2SkinRender::DrawText(const POINT &Pos, const SIZE &Size, const tColor *Fg, const string &Text, const cFont *Font, int Align) { + DrawTextTransparent(mOsd, Pos.x, Pos.y, Text.c_str(), Fg ? *Fg : 0, 0, Font, Size.w, Size.h, Align); +} + +void cText2SkinRender::DrawRectangle(const POINT &Pos, const SIZE &Size, const tColor *Fg) { + mOsd->DrawRectangle(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, Fg ? *Fg : 0); +} + +void cText2SkinRender::DrawEllipse(const POINT &Pos, const SIZE &Size, const tColor *Fg, int Arc) { + mOsd->DrawEllipse(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, Fg ? *Fg : 0, Arc); +} + +void cText2SkinRender::DrawSlope(const POINT &Pos, const SIZE &Size, const tColor *Fg, int Arc) { + mOsd->DrawSlope(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, Fg ? *Fg : 0, Arc); +} + +void cText2SkinRender::DrawProgressbar(const POINT &Pos, const SIZE &Size, int Current, int Total, const tColor *Bg, const tColor *Fg, const cMarks *Marks) { + if (Bg) + DrawRectangle(Pos, Size, Bg); + if (Size.w > Size.h) { + SIZE size = { Size.w * Current / Total, Size.h }; + DrawRectangle(Pos, size, Fg); + + if (Marks) { + bool Start = true; + for (const cMark *m = Marks->First(); m; m = Marks->Next(m)) { + POINT p1 = { Pos.x + m->position * Size.w / Total, Pos.y }; + if (Start) { + const cMark *m2 = Marks->Next(m); + tColor col = clrRed; + POINT p2 = { p1.x, Pos.y + Size.h / 3 }; + SIZE s = { ((m2 ? m2->position : Total) - m->position) * Size.w / Total, Size.h / 3 }; + DrawRectangle(p2, s, &col); + } + DrawMark(p1, Size, Start, m->position == Current, false); + Start = !Start; + } + } } else { - printf("drawing plain background\n"); + SIZE size = { Size.w, Size.h * Current / Total }; + DrawRectangle(Pos, size, Fg); + + if (Marks) { + bool Start = true; + for (const cMark *m = Marks->First(); m; m = Marks->Next(m)) { + POINT p1 = { Pos.x, Pos.y + m->position * Size.h / Total }; + if (Start) { + const cMark *m2 = Marks->Next(m); + tColor col = clrRed; + POINT p2 = { Pos.x + Size.w / 3, p1.y }; + SIZE s = { Size.w / 3, ((m2 ? m2->position : Total) - m->position) * Size.h / Total }; + DrawRectangle(p2, s, &col); + } + DrawMark(p1, Size, Start, m->position == Current, true); + Start = !Start; + } + } } } -void cText2SkinRender::DisplayLogo(cText2SkinItem *Item) { +void cText2SkinRender::DrawMark(const POINT &Pos, const SIZE &Size, bool Start, bool Current, bool Horizontal) { + tColor mark = clrBlack; + tColor current = clrRed; + POINT p1 = { Pos.x, Pos.y }; + if (Horizontal) { + SIZE s1 = { Size.w, 1 }; + DrawRectangle(p1, s1, &mark); + const int d = Size.w / (Current ? 3 : 9); + for (int i = 0; i < d; i++) { + int h = Start ? i : Size.w - 1 - i; + POINT p2 = { Pos.x + h, Pos.y - d + i }; + SIZE s2 = { 1, (d - i) * 2 }; + DrawRectangle(p2, s2, Current ? ¤t : &mark); + } + } else { + SIZE s1 = { 1, Size.h }; + DrawRectangle(p1, s1, &mark); + const int d = Size.h / (Current ? 3 : 9); + for (int i = 0; i < d; i++) { + int h = Start ? i : Size.h - 1 - i; + POINT p2 = { Pos.x - d + i, Pos.y + h }; + SIZE s2 = { (d - i) * 2, 1 }; + DrawRectangle(p2, s2, Current ? ¤t : &mark); + } + } +} + +void cText2SkinRender::DisplayBackground(cText2SkinItem *Item) { + DrawBackground(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), Item->Path()); +} + +void cText2SkinRender::DisplayChannelLogo(cText2SkinItem *Item) { + if (Item->Type() != "" && mChannel) { + string path = Item->Path() + "/" + ChannelName(mChannel, mChannelNumber) + "." + Item->Type(); + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), path); + } +} + +void cText2SkinRender::DisplayLanguage(cText2SkinItem *Item) { + printf("DisplayLanguage, %s %s\n", Item->Path().c_str(), Item->Type().c_str()); + int current; + const char **tracks = cDevice::PrimaryDevice()->GetAudioTracks(¤t); + if (Item->Path() != "" && Item->Type() != "" && tracks) { + printf("Languages: "); + int i = 0; + while (tracks[i]) { + printf("%s%s, ", tracks[i], i == current ? " (current)" : ""); + ++i; + } + printf("\n"); + string path = Item->Path() + "/" + tracks[current] + "." + Item->Type(); + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), path); + } } void cText2SkinRender::DisplayText(cText2SkinItem *Item) { printf("DisplayText\n"); - DrawTextTransparent(mOsd, Item->X(), Item->Y(), Item->Text(), Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), Item->Text(), Item->Font(), Item->Align()); +} + +void cText2SkinRender::DisplayImage(cText2SkinItem *Item) { + printf("DisplayImage\n"); + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), Item->Path()); } void cText2SkinRender::DisplayDateTime(cText2SkinItem *Item) { const char *text = DayDateTime(time(NULL)); - DrawTextTransparent(mOsd, Item->X(), Item->Y(), text, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, text), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayDate(cText2SkinItem *Item) { char *text = strdup(DayDateTime(time(NULL))); + text[9] = '.'; text[10] = '\0'; - DrawTextTransparent(mOsd, Item->X(), Item->Y(), text + 5, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + printf("DisplayDate %d:%d:%d:%d %s\n", Item->Pos().x, Item->Pos().y, Item->Size().w, Item->Size().h, text + 4); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, text + 4), Item->Font(), Item->Align()); free(text); } void cText2SkinRender::DisplayTime(cText2SkinItem *Item) { char *text = strdup(DayDateTime(time(NULL))); text[18] = '\0'; - DrawTextTransparent(mOsd, Item->X(), Item->Y(), text + 13, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, text + 13), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayChannelNumberName(cText2SkinItem *Item) { - DrawTextTransparent(mOsd, Item->X(), Item->Y(), ChannelString(mChannel, mNumber), Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, ChannelString(mChannel, mChannelNumber)), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayChannelNumber(cText2SkinItem *Item) { - char *text = strdup(ChannelString(mChannel, mNumber)); - char *ptr = text; - while (*ptr && *ptr != ' ') ++ptr; - *ptr = '\0'; - DrawTextTransparent(mOsd, Item->X(), Item->Y(), text, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); - free(text); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, ChannelNumber(mChannel, mChannelNumber)), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayChannelName(cText2SkinItem *Item) { - const char *text = ChannelString(mChannel, mNumber); - while (*text && *text != ' ') ++text; - if (strlen(text) > 1) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), text + 1, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, ChannelName(mChannel, mChannelNumber)), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayRectangle(cText2SkinItem *Item) { - mOsd->DrawRectangle(Item->X(), Item->Y(), Item->X() + Item->Width() - 1, Item->Y() + Item->Height() - 1, Item->Fg()); + DrawRectangle(Item->Pos(), Item->Size(), Item->Fg()); } void cText2SkinRender::DisplayEllipse(cText2SkinItem *Item) { - mOsd->DrawEllipse(Item->X(), Item->Y(), Item->X() + Item->Width() - 1, Item->Y() + Item->Height() - 1, Item->Fg()); + DrawEllipse(Item->Pos(), Item->Size(), Item->Fg(), Item->Arc()); +} + +void cText2SkinRender::DisplaySlope(cText2SkinItem *Item) { + DrawSlope(Item->Pos(), Item->Size(), Item->Fg(), Item->Arc()); } void cText2SkinRender::DisplayTimebar(cText2SkinItem *Item) { time_t now = time(NULL); - if (mPresent && now > mPresent->StartTime()) { - int total = mPresent->Duration(); - int current = total - (now - mPresent->StartTime()); - if (Item->Width() > Item->Height()) { - mOsd->DrawRectangle(Item->X(), Item->Y(), Item->X() + Item->Width() - 1, Item->Y() + Item->Height() - 1, Item->Bg()); - mOsd->DrawRectangle(Item->X() + 2, Item->Y() + 2, Item->X() + (Item->Width() * current / total) - 3, Item->Y() + Item->Height() - 3, Item->Fg()); - } else { - mOsd->DrawRectangle(Item->X(), Item->Y(), Item->X() + Item->Width() - 3, Item->Y() + Item->Height() - 3, Item->Bg()); - mOsd->DrawRectangle(Item->X() + 2, Item->Y() + 2, Item->X() + Item->Width() - 3, Item->Y() + (Item->Height() * current / total) - 3, Item->Fg()); - } + if (mChannelPresent && now > mChannelPresent->StartTime()) { + int total = mChannelPresent->Duration(); + int current = now - mChannelPresent->StartTime(); + DrawProgressbar(Item->Pos(), Item->Size(), current, total, Item->Bg(), Item->Fg()); } } void cText2SkinRender::DisplayPresentTime(cText2SkinItem *Item) { - if (mPresent) { - const char *text = DayDateTime(mPresent->StartTime()); - DrawTextTransparent(mOsd, Item->X(), Item->Y(), text + 10, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mChannelPresent) { + const char *text = DayDateTime(mChannelPresent->StartTime()); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, text + 10), Item->Font(), Item->Align()); } } void cText2SkinRender::DisplayPresentTitle(cText2SkinItem *Item) { - if (mPresent && mPresent->Title()) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mPresent->Title(), Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mChannelPresent && mChannelPresent->Title()) + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mChannelPresent->Title()), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayPresentShortText(cText2SkinItem *Item) { - if (mPresent && mPresent->ShortText()) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mPresent->ShortText(), Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mChannelPresent && mChannelPresent->ShortText()) + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mChannelPresent->ShortText()), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayFollowingTime(cText2SkinItem *Item) { - if (mFollowing) { - const char *text = DayDateTime(mFollowing->StartTime()); - DrawTextTransparent(mOsd, Item->X(), Item->Y(), text + 10, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mChannelFollowing) { + const char *text = DayDateTime(mChannelFollowing->StartTime()); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, text + 10), Item->Font(), Item->Align()); } } void cText2SkinRender::DisplayFollowingTitle(cText2SkinItem *Item) { - if (mFollowing && mFollowing->Title()) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mFollowing->Title(), Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mChannelFollowing && mChannelFollowing->Title()) + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mChannelFollowing->Title()), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayFollowingShortText(cText2SkinItem *Item) { - if (mFollowing && mFollowing->ShortText()) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mFollowing->ShortText(), Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mChannelFollowing && mChannelFollowing->ShortText()) + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mChannelFollowing->ShortText()), Item->Font(), Item->Align()); } void cText2SkinRender::DisplaySymbol(cText2SkinItem *Item) { - const char *image = NULL; + string image; if (mSection == sectionChannel && mChannel) { switch (Item->Item()) { case itemSymbolTeletext: @@ -294,128 +440,149 @@ void cText2SkinRender::DisplaySymbol(cText2SkinItem *Item) { image = mChannel->Dpid1() ? Item->Path() : Item->AltPath(); break; case itemSymbolEncrypted: image = mChannel->Ca() ? Item->Path() : Item->AltPath(); break; + case itemSymbolRadio: + image = (mChannel->Vpid() == 0 || mChannel->Vpid() == 1 || mChannel->Vpid() == 0x1FFF) ? Item->Path() : Item->AltPath(); break; + case itemSymbolRecording: + image = cRecordControls::Active() ? Item->Path() : Item->AltPath(); break; default: break; } + } else if (mSection == sectionReplay) { + switch (Item->Item()) { + case itemSymbolPlay: + image = (mReplaySpeed == -1 && mReplayPlay) ? Item->Path() : Item->AltPath(); break; + case itemSymbolPause: + image = (mReplaySpeed == -1 && !mReplayPlay) ? Item->Path() : Item->AltPath(); break; + case itemSymbolFastFwd: + image = (mReplayPlay && mReplayForward) ? Item->Path() : Item->AltPath(); break; + case itemSymbolFastRew: + image = (mReplayPlay && !mReplayForward) ? Item->Path() : Item->AltPath(); break; + case itemSymbolSlowFwd: + image = (!mReplayPlay && mReplayForward) ? Item->Path() : Item->AltPath(); break; + case itemSymbolSlowRew: + image = (!mReplayPlay && !mReplayForward) ? Item->Path() : Item->AltPath(); break; + default: + break; + } } - if (image) { - char *p; - asprintf(&p, "%s/%s/%s", SkinPath(), mData->Skin(), image); - printf("trying %s\n", p); - cText2SkinBitmap bm(p); - free(p); - if (Item->HasBg()) bm.SetColor(0, Item->Bg()); - if (Item->HasFg()) bm.SetColor(1, Item->Fg()); - mOsd->DrawBitmap(Item->X(), Item->Y(), bm); - } + if (image != "") + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), image); } void cText2SkinRender::DisplayVolumebar(cText2SkinItem *Item) { if (mVolumeTotal && mVolumeCurrent <= mVolumeTotal) { int total = mVolumeTotal; int current = mVolumeCurrent; - if (Item->Width() > Item->Height()) { - mOsd->DrawRectangle(Item->X(), Item->Y(), Item->X() + Item->Width() - 1, Item->Y() + Item->Height() - 1, Item->Bg()); - mOsd->DrawRectangle(Item->X() + 2, Item->Y() + 2, Item->X() + (Item->Width() * current / total) - 3, Item->Y() + Item->Height() - 3, Item->Fg()); - } else { - mOsd->DrawRectangle(Item->X(), Item->Y(), Item->X() + Item->Width() - 3, Item->Y() + Item->Height() - 3, Item->Bg()); - mOsd->DrawRectangle(Item->X() + 2, Item->Y() + 2, Item->X() + Item->Width() - 3, Item->Y() + (Item->Height() * current / total) - 3, Item->Fg()); - } + DrawProgressbar(Item->Pos(), Item->Size(), current, total, Item->Bg(), Item->Fg()); } } void cText2SkinRender::DisplayMute(cText2SkinItem *Item) { if (mVolumeMute) { - if (Item->Path()) { - char *p; - asprintf(&p, "%s/%s/%s", SkinPath(), mData->Skin(), Item->Path()); - cText2SkinBitmap bm(p); - free(p); - if (Item->HasBg()) bm.SetColor(0, Item->Bg()); - if (Item->HasFg()) bm.SetColor(1, Item->Fg()); - mOsd->DrawBitmap(Item->X(), Item->Y(), bm); - } - - if (Item->Text()) { - DrawTextTransparent(mOsd, Item->X(), Item->Y(), Item->Text(), Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); - } - } + if (Item->Path() != "") + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), Item->Path()); + if (Item->Text() != "") + DrawText(Item->Pos(), Item->Size(), Item->Fg(), Item->Text(), Item->Font(), Item->Align()); + } else if (Item->Path() != "") + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), Item->AltPath()); } -void cText2SkinRender::DisplayProgressbar(cText2SkinItem *Item) { +void cText2SkinRender::DisplayReplaybar(cText2SkinItem *Item) { if (mReplayTotal && mReplayCurrent <= mReplayTotal) { int total = mReplayTotal; int current = mReplayCurrent; - if (Item->Width() > Item->Height()) { - mOsd->DrawRectangle(Item->X(), Item->Y(), Item->X() + Item->Width() - 1, Item->Y() + Item->Height() - 1, Item->Bg()); - mOsd->DrawRectangle(Item->X() + 2, Item->Y() + 2, Item->X() + (Item->Width() * current / total) - 3, Item->Y() + Item->Height() - 3, Item->Fg()); - } else { - mOsd->DrawRectangle(Item->X(), Item->Y(), Item->X() + Item->Width() - 3, Item->Y() + Item->Height() - 3, Item->Bg()); - mOsd->DrawRectangle(Item->X() + 2, Item->Y() + 2, Item->X() + Item->Width() - 3, Item->Y() + (Item->Height() * current / total) - 3, Item->Fg()); - } + DrawProgressbar(Item->Pos(), Item->Size(), current, total, Item->Bg(), Item->Fg(), mReplayMarks); } } void cText2SkinRender::DisplayReplayTitle(cText2SkinItem *Item) { - if (mReplayTitle) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mReplayTitle, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mReplayTitle != "") + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mReplayTitle), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayReplayCurrent(cText2SkinItem *Item) { - if (mReplayCurrentText) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mReplayCurrentText, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mReplayCurrentText != "") + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mReplayCurrentText), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayReplayTotal(cText2SkinItem *Item) { - if (mReplayTotalText) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mReplayTotalText, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mReplayTotalText != "") + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mReplayTotalText), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayReplayJump(cText2SkinItem *Item) { - if (mReplayJump) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mReplayJump, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); -} - -void cText2SkinRender::DisplayMessageStatus(cText2SkinItem *Item) { - if (mMessageType == mtStatus && mMessageText) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mMessageText, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); -} - -void cText2SkinRender::DisplayMessageInfo(cText2SkinItem *Item) { - if (mMessageType == mtInfo && mMessageText) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mMessageText, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); -} - -void cText2SkinRender::DisplayMessageWarning(cText2SkinItem *Item) { - if (mMessageType == mtWarning && mMessageText) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mMessageText, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); -} - -void cText2SkinRender::DisplayMessageError(cText2SkinItem *Item) { - if (mMessageType == mtError && mMessageText) - DrawTextTransparent(mOsd, Item->X(), Item->Y(), mMessageText, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); + if (mReplayJump != "") + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mReplayJump), Item->Font(), Item->Align()); +} + +void cText2SkinRender::DisplayMessage(cText2SkinItem *Item) { + string text; + switch (Item->Item()) { + case itemMessageStatus: + if (mMessageType == mtStatus) text = mMessageText; break; + case itemMessageInfo: + if (mMessageType == mtInfo) text = mMessageText; break; + case itemMessageWarning: + if (mMessageType == mtWarning) text = mMessageText; break; + case itemMessageError: + if (mMessageType == mtError) text = mMessageText; break; + default: + break; + } + if (text != "") + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, text), Item->Font(), Item->Align()); } void cText2SkinRender::DisplayMenuItems(cText2SkinItem *Item) { cText2SkinItem *area = mData->Get(itemMenuArea); cText2SkinItem *current = mData->Get(itemMenuCurrent); - int xoffs = area->X(); - int yoffs = area->Y(); + int xoffs = area->Pos().x; + int yoffs = area->Pos().y; - if (Item->X() != -1) - xoffs += Item->X(); - if (Item->Y() != -1) - yoffs += Item->Y(); + if (Item->Pos().x != -1) + xoffs += Item->Pos().x; + if (Item->Pos().y != -1) + yoffs += Item->Pos().y; printf("menu items\n"); int index = 0; - while (yoffs < area->Height() && index < (int)mItems.size()) { - if (index == mCurrent) - DrawTextTransparent(mOsd, xoffs + current->X(), yoffs + current->Y(), mItems[index].mName, current->Fg(), current->Bg(), SkinFont(Item), current->Width(), current->Height(), current->Align()); - else - DrawTextTransparent(mOsd, xoffs + Item->X(), yoffs + Item->Y(), mItems[index].mName, Item->Fg(), Item->Bg(), SkinFont(Item), Item->Width(), Item->Height(), Item->Align()); - yoffs += Item->Height(); + while (yoffs < area->Pos().y + area->Size().h && index < (int)mMenuItems.size()) { + if (index == mMenuCurrent) { + POINT pt = { xoffs + current->Pos().x, yoffs + current->Pos().y }; + SIZE size = { current->Size().w, current->Size().h }; + if (current->Bg()) + DrawRectangle(pt, size, current->Bg()); + DrawText(pt, size, current->Fg(), mMenuItems[index].name.c_str(), current->Font(), current->Align()); + } else { + POINT pt = { xoffs + Item->Pos().x, yoffs + Item->Pos().y }; + SIZE size = { Item->Size().w, Item->Size().h }; + DrawText(pt, size, Item->Fg(), mMenuItems[index].name.c_str(), Item->Font(), Item->Align()); + } + yoffs += Item->Size().h; ++index; } } + +void cText2SkinRender::DisplayMenuTitle(cText2SkinItem *Item) { + if (mMenuTitle != "") + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, mMenuTitle), Item->Font(), Item->Align()); +} + +void cText2SkinRender::DisplayMenuColorbutton(cText2SkinItem *Item) { + string text; + switch (Item->Item()) { + case itemMenuRed: + text = mMenuRed; break; + case itemMenuGreen: + text = mMenuGreen; break; + case itemMenuYellow: + text = mMenuYellow; break; + case itemMenuBlue: + text = mMenuBlue; break; + default: break; + } + if (text != "") + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, text), Item->Font(), Item->Align()); +} + @@ -1,16 +1,20 @@ /* - * $Id: render.h,v 1.3 2004/05/23 19:20:26 lordjaxom Exp $ + * $Id: render.h,v 1.10 2004/05/31 19:54:12 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_RENDER_H #define VDR_TEXT2SKIN_RENDER_H -#include <vector> +#define __STL_CONFIG_H #include <vdr/osd.h> #include <vdr/skins.h> +#undef __STL_CONFIG_H #include "data.h" +#include <vector> +#include <string> using std::vector; +using std::string; class cChannel; class cEvent; @@ -27,12 +31,11 @@ private: eSkinSection mSection; cOsd *mOsd; - // TODO: rename or restructure items // channel display const cChannel *mChannel; - int mNumber; - const cEvent *mPresent; - const cEvent *mFollowing; + int mChannelNumber; + const cEvent *mChannelPresent; + const cEvent *mChannelFollowing; // volume display int mVolumeCurrent; @@ -40,34 +43,51 @@ private: bool mVolumeMute; // replay display - const char *mReplayTitle; + string mReplayTitle; bool mReplayPlay; bool mReplayForward; int mReplaySpeed; int mReplayCurrent; int mReplayTotal; - const char *mReplayCurrentText; - const char *mReplayTotalText; - const char *mReplayJump; + const cMarks *mReplayMarks; + string mReplayCurrentText; + string mReplayTotalText; + string mReplayJump; // message display eMessageType mMessageType; - const char *mMessageText; + string mMessageText; // menu struct MenuItem { - const char *mName; - bool mSelectable; - bool operator!=(const MenuItem &b) { return b.mName != mName || b.mSelectable != mSelectable; } + string name; + bool sel; + bool operator!=(const MenuItem &b) { return b.name != name || b.sel != sel; } }; - const char *mTitle; - vector<MenuItem> mItems; - int mCurrent; + string mMenuTitle; + vector<MenuItem> mMenuItems; + int mMenuCurrent; + string mMenuRed; + string mMenuGreen; + string mMenuYellow; + string mMenuBlue; protected: + // Basic operations + void DrawBackground(const POINT &Pos, const SIZE &Size, const tColor *Bg, const tColor *Fg, const string &Path); + void DrawImage(const POINT &Pos, const SIZE &Size, const tColor *Bg, const tColor *Fg, const string &Path); + void DrawText(const POINT &Pos, const SIZE &Size, const tColor *Fg, const string &Text, const cFont *Font, int Align); + void DrawRectangle(const POINT &Pos, const SIZE &Size, const tColor *Fg); + void DrawEllipse(const POINT &Pos, const SIZE &Size, const tColor *Fg, int Arc); + void DrawSlope(const POINT &Pos, const SIZE &Size, const tColor *Fg, int Arc); + void DrawProgressbar(const POINT &Pos, const SIZE &Size, int Current, int Total, const tColor *Fg, const tColor *Bg, const cMarks *Marks = NULL); + void DrawMark(const POINT &Pos, const SIZE &Size, bool Start, bool Current, bool Horizontal); + void DisplayBackground(cText2SkinItem *Item); - void DisplayLogo(cText2SkinItem *Item); + void DisplayChannelLogo(cText2SkinItem *Item); + void DisplayLanguage(cText2SkinItem *Item); void DisplayText(cText2SkinItem *Item); + void DisplayImage(cText2SkinItem *Item); void DisplayDateTime(cText2SkinItem *Item); void DisplayDate(cText2SkinItem *Item); void DisplayTime(cText2SkinItem *Item); @@ -76,6 +96,7 @@ protected: void DisplayChannelName(cText2SkinItem *Item); void DisplayRectangle(cText2SkinItem *Item); void DisplayEllipse(cText2SkinItem *Item); + void DisplaySlope(cText2SkinItem *Item); void DisplayTimebar(cText2SkinItem *Item); void DisplayPresentTime(cText2SkinItem *Item); void DisplayPresentTitle(cText2SkinItem *Item); @@ -86,16 +107,16 @@ protected: void DisplaySymbol(cText2SkinItem *Item); void DisplayVolumebar(cText2SkinItem *Item); void DisplayMute(cText2SkinItem *Item); - void DisplayProgressbar(cText2SkinItem *Item); + void DisplayReplaybar(cText2SkinItem *Item); void DisplayReplayTitle(cText2SkinItem *Item); void DisplayReplayCurrent(cText2SkinItem *Item); void DisplayReplayTotal(cText2SkinItem *Item); void DisplayReplayJump(cText2SkinItem *Item); - void DisplayMessageStatus(cText2SkinItem *Item); - void DisplayMessageInfo(cText2SkinItem *Item); - void DisplayMessageWarning(cText2SkinItem *Item); - void DisplayMessageError(cText2SkinItem *Item); + void DisplayMessage(cText2SkinItem *Item); void DisplayMenuItems(cText2SkinItem *Item); + void DisplayMenuTitle(cText2SkinItem *Item); + void DisplayMenuColorbutton(cText2SkinItem *Item); + void DisplayMenuMessage(cText2SkinItem *Item); public: cText2SkinRender(cText2SkinData *Data, eSkinSection Section); diff --git a/text2skin.c b/text2skin.c index c445bc6..6ca2f97 100644 --- a/text2skin.c +++ b/text2skin.c @@ -3,13 +3,15 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: text2skin.c,v 1.3 2004/05/23 19:20:26 lordjaxom Exp $ + * $Id: text2skin.c,v 1.5 2004/05/31 19:55:51 lordjaxom Exp $ */ +#define __STL_CONFIG_H #include <vdr/plugin.h> +#undef __STL_CONFIG_H #include "loader.h" -static const char *VERSION = "0.0.1-pre2"; +static const char *VERSION = "0.0.1-rc1"; static const char *DESCRIPTION = "Loader for text-based skins"; class cText2SkinPlugin : public cPlugin { |