diff options
-rw-r--r-- | HISTORY | 11 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | bitmap.c | 4 | ||||
-rw-r--r-- | common.h | 25 | ||||
-rw-r--r-- | contrib/items.doc | 20 | ||||
-rw-r--r-- | data.c | 33 | ||||
-rw-r--r-- | data.h | 12 | ||||
-rw-r--r-- | deprecated/SKINS | 565 | ||||
-rw-r--r-- | deprecated/SKINS.de | 259 | ||||
-rw-r--r-- | display.c | 5 | ||||
-rw-r--r-- | render.c | 244 | ||||
-rw-r--r-- | render.h | 35 | ||||
-rw-r--r-- | screen.c | 65 | ||||
-rw-r--r-- | screen.h | 33 | ||||
-rw-r--r-- | scroller.c | 69 | ||||
-rw-r--r-- | scroller.h | 47 | ||||
-rw-r--r-- | text2skin.c | 4 |
17 files changed, 434 insertions, 1001 deletions
@@ -1,6 +1,17 @@ VDR Plugin 'text2skin' Revision History --------------------------------------- +2004-07-14: Version 0.0.8 + +- fixed display of scrollbar if there is no text present +- fixed animation delay if update takes longer than the delay +- using backgrounds also in 8-bit fullscreen mode to improve performance +- implemented screen layer to improve performance +- corrected offsets and tab widths in main menu +- implemented parameters "current", "mark" and "selected" to choose mark colors + in replay display (defaults to the old values) +- implemented color value "None" to be able to unset a color + 2004-06-25: Version 0.0.7 - on devices capable of full-color OSD, bpp's have no meaning anymore @@ -9,7 +9,7 @@ HAVE_IMAGEMAGICK=1 # DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING # ------------------------------------------------------------- # -# $Id: Makefile,v 1.14 2004/06/24 18:37:30 lordjaxom Exp $ +# $Id: Makefile,v 1.15 2004/07/02 19:00:22 lordjaxom Exp $ # # The official name of this plugin. @@ -73,7 +73,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): OBJS = $(PLUGIN).o loader.o data.o display.o render.o common.o bitmap.o \ - file.o i18n.o theme.o cache.o setup.o status.o + file.o i18n.o theme.o cache.o setup.o status.o scroller.o screen.o ### Implicit rules: @@ -1,5 +1,5 @@ /* - * $Id: bitmap.c,v 1.17 2004/06/18 16:08:11 lordjaxom Exp $ + * $Id: bitmap.c,v 1.18 2004/07/13 13:52:51 lordjaxom Exp $ */ #include "bitmap.h" @@ -72,7 +72,7 @@ cBitmap &cText2SkinBitmap::Get(int &UpdateIn) { } else if ((diff = cur - mLastGet) >= mDelay) { mCurrent = (mCurrent + 1) % mBitmaps.size(); mLastGet = cur; - upd = mDelay; + upd = mDelay - diff > 1 ? mDelay - diff : 1; } else { upd = mDelay - diff; } @@ -1,5 +1,5 @@ /* - * $Id: common.h,v 1.12 2004/06/25 17:51:34 lordjaxom Exp $ + * $Id: common.h,v 1.13 2004/07/02 19:00:22 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_COMMON_H @@ -147,7 +147,13 @@ extern const string DisplayNames[__DISPLAY_COUNT__]; extern const string ReplayNames[__REPLAY_COUNT__]; extern const string BaseNames[__BASE_COUNT__]; -// geometrical structures +// class forwards + +class cMarks; +class cChannel; +class cText2SkinItem; + +// geometrical and helper structures struct POINT { int x, y; @@ -159,11 +165,16 @@ struct SIZE { int w, h; SIZE(int _w = 0, int _h = 0) { w = _w; h = _h; } }; - -// class forwards - -class cChannel; -class cText2SkinItem; + +struct tItemData { + string text; + string path; + int current; + int shown; + int total; + const cMarks *marks; + tItemData(void) { marks = NULL; } +}; // helper functions diff --git a/contrib/items.doc b/contrib/items.doc index 518eb30..44863e4 100644 --- a/contrib/items.doc +++ b/contrib/items.doc @@ -24,13 +24,14 @@ This is the documentation to the Text2Skin file-format (version 0.0.2). How To create text-based skins ------------------------------ +[ THIS HAS CHANGED - BACKGROUNDS ARE MANDATORY ] + If you are using an output driver capable of displaying a full-screen 256 color OSD (i.e. an upgraded DVB-card, or plugins like SoftDevice), the plugin will -detect this and make use of the full-screen area. If you intend to write a skin -that will only work on such a device, you can skip the section concerning -backgrounds. However, if you plan to make the skin usable on a usual DVB-card, -even if you don't use one yourself, you should read the following sections -carefully. +detect this and make use of the full-screen area. However, you will still need +to define some drawing areas (backgrounds), because commiting a full-screen +area can take some time (depending on the output device). By specifying the +area you intend to draw on, things can be sped up a lot. It is important that you understand the limitations of the OSD memory. If there are too many objects with too many colors defined, VDR will throw an error and @@ -123,9 +124,16 @@ END_EN Wie man textbasierte Skins erstellt ----------------------------------- +[ HAT SICH GEÄNDERT - BACKGROUNDS SIND PFLICHT ] + Wenn Sie einen Ausgabetreiber nutzen, der fähig ist, ein 256-Farben Vollbild als OSD darzustellen (z.B. eine aufgerüstete DVB-Karte oder Plugins wie SoftDevice), wird das Plugin dies erkennen und die volle Bildfläche nutzen. +Dennoch werden Sie einige Malbereiche (Backgrounds) definieren müssen, weil +bspw. das Übermitteln des gesamten OSD-Bildes einige Zeit beanspruchen kann +(je nach Ausgabegerät). Durch die Angabe der Bereiche auf die später gemalt +werden soll, beschleunigt sich das ganze erheblich. + Wenn Sie beabsichtigen, ein Skin zu schreiben, welches nur auf solchen Geräten funktionieren soll, können Sie die folgenden Sektionen, die die Backgrounds betreffen überspringen. Wenn Sie jedoch planen Ihr Skin auch auf normalen @@ -423,7 +431,7 @@ END_DE "Rectangle" => "display, x, y, width, height, fg", "Ellipse" => "display, x, y, width, height, fg, arc", "Slope" => "display, x, y, width, height, fg, arc", - "Progress" => "display, x, y, width, height, bg, fg", + "Progress" => "display, x, y, width, height, bg, fg, selected, mark, current", "Logo" => "display, x, y, width, height, bg, fg, path, type", "Symbol" => "display, x, y, width, height, bg, fg, path, altpath", "MenuArea" => "x, y, width, height", @@ -1,5 +1,5 @@ /* - * $Id: data.c,v 1.20 2004/06/22 16:48:03 lordjaxom Exp $ + * $Id: data.c,v 1.21 2004/07/13 13:52:51 lordjaxom Exp $ */ #include "data.h" @@ -12,6 +12,9 @@ cText2SkinItem::cText2SkinItem(void) { mBpp = 4; mArc = 0; mAlpha = 0; + mSelected= "#FFFC1414"; + mMark = "#FF000000"; + mCurrent = "#FFFC1414"; mFont = cFont::GetFont(fontOsd); mAlign = taDefault; mBase = baseRelative; @@ -52,6 +55,9 @@ bool cText2SkinItem::ParseItem(const char *Text) { ParseVar(Text, "alpha", &mAlpha); ParseVar(Text, "fg", mFg); ParseVar(Text, "bg", mBg); + ParseVar(Text, "selected", mSelected); + ParseVar(Text, "mark", mMark); + ParseVar(Text, "current", mCurrent); ParseVar(Text, "font", &mFont); ParseVar(Text, "path", mPath); ParseVar(Text, "altpath", mAltPath); @@ -72,6 +78,31 @@ const SIZE cText2SkinItem::Size(void) const { return SIZE(p2.x - p1.x + 1, p2.y - p1.y + 1); } +const tColor *cText2SkinItem::Fg(void) const { + static tColor Fg; + return cText2SkinRender::ItemColor(mFg, Fg) ? &Fg : NULL; +} + +const tColor *cText2SkinItem::Bg(void) const { + static tColor Bg; + return cText2SkinRender::ItemColor(mBg, Bg) ? &Bg : NULL; +} + +const tColor *cText2SkinItem::Selected(void) const { + static tColor Selected; + return cText2SkinRender::ItemColor(mSelected, Selected) ? &Selected : NULL; +} + +const tColor *cText2SkinItem::Mark(void) const { + static tColor Mark; + return cText2SkinRender::ItemColor(mMark, Mark) ? &Mark : NULL; +} + +const tColor *cText2SkinItem::Current(void) const { + static tColor Current; + return cText2SkinRender::ItemColor(mCurrent, Current) ? &Current : NULL; +} + // --- cText2SkinData --------------------------------------------------------- cText2SkinData::cText2SkinData(const char *Skin): cText2SkinFile(Skin) { @@ -1,5 +1,5 @@ /* - * $Id: data.h,v 1.17 2004/06/22 16:48:03 lordjaxom Exp $ + * $Id: data.h,v 1.18 2004/07/13 13:52:51 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_DATA_H @@ -22,6 +22,9 @@ private: int mAlpha; string mFg; string mBg; + string mSelected; + string mMark; + string mCurrent; const cFont *mFont; string mName; string mVersion; @@ -55,8 +58,6 @@ public: int Bpp(void) const { return mBpp; } int Arc(void) const { return mArc; } int Alpha(void) const { return mAlpha; } - const string &Fg(void) const { return mFg; } - const string &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; } @@ -70,6 +71,11 @@ public: // auto-conversion const POINT Pos(void) const; const SIZE Size(void) const; + const tColor *Fg(void) const; + const tColor *Bg(void) const; + const tColor *Selected(void)const; + const tColor *Mark(void) const; + const tColor *Current(void) const; }; class cText2SkinData: public cText2SkinFile { diff --git a/deprecated/SKINS b/deprecated/SKINS deleted file mode 100644 index da5ea09..0000000 --- a/deprecated/SKINS +++ /dev/null @@ -1,565 +0,0 @@ - - -THIS DOCUMENT IS NOT UP-TO-DATE (sorry) - - -How To create text-based skins ------------------------------- - -[ TODO remove this ] -You may encounter bracketed phrases in this document. Please ignore them, they -are comments for me which will be removed in official release versions. - -[ TODO move this to manual ] -The Skin itself is located in a subdirectory "text2skin" inside the "plugins" -directory of your VDR configuration directory. This usually is the video -directory, if you didn't specify -c on the commandline. If you did, the -subdirectory is located there. Each skin has an own subdirectory there, which -holds the skin description file and the needed image files. The skin -description file must have the same name as the skin directory, with the -extension ".skin" - -Example (the Skin is called myskin): -/video0/plugins/text2skin/ -/video0/plugins/text2skin/myskin/ -/video0/plugins/text2skin/msykin/msykin.skin -/video0/plugins/text2skin/myskin/channeldisplay.png - -It is important that you understand the limitations of the OSD memory. If there -are too many objects with too many colors defined, VDR will throw an error and -some areas will not be displayed. For other output devices this limitations may -not apply, so if you are planning to design a skin for another output device, -feel free to use more colors, but remember that VDR can handle a maximum of 256 -areas per object. - -An object is defined to be a specific area with a specific palette and color -depth. Those objects will be referred to as 'backgrounds' later on. Calculate -the dimensions of them wisely, since overlapping areas or oversized areas will -lead to an error. Also, the widht and height of each area has to be a multiple -of four [ TODO may not apply to different output devices ]. - - -Creation of an image --------------------- - -I used gimp to create some test images displaying things on screen, although -I don't know much about image processing :-). To give an advice, I will point -out how I created those test images. - -I've used a template for a menu provided by a community member, tiled it into -sections fully covered by the image. That made three images in this case. Then -I added a little bit of transparency to the image covering the middle part. I've -resized the image so that it's width and height were multiples of four. Now I've -added 50% transparency to the top layer of the image. Then I've reduced the -colordepth of the image (Image->Mode->Indexed) to 14 colors (of course the -image may not be too extensive, but 14 colors can give some nice gradients). -That leaves two colors for text and progress bar in the same display. Reduce -the number of colors according to the background depth and additional -decoration you intend to use. I saved the results to a png file and placed the -result into the skin. - -If you intend to use xpm's, be aware that VDR doesn't know about named colors, -so some images GIMP creates will not be read on-the-fly, because GIMP may use -some named colors, but VDR only recognizes "None". - - -The Description File Format ---------------------------- - -It is a simple configuration file, consisting of Sections and items. -Commentary lines can be added when they are lead in by a '#'. Blank lines will -be ignored. A section is placed in '[]' brackets. An item is lead in by an -'Item=object' phrase. - -Example: -Item=Skin,name=Test,version=0.0.1; -[Channel] -Item=Background,path=channeltop.xpm,x=42,y=350,width=540,height=32,bg=#00FFFFFF; -Item=Background,path=channel.png,x=48,y=382,width=528,height=84; -Item=ChannelNumberName,x=50,y=355,fg=#FFFFFFFF,bg=#FF1965FF,font=Sml; -Item=PresentTime,x=52,y=387,fg=#FFFFFFFF,bg=#7F002254,font=Osd; -[Volume] -Item=Background,x=10,y=10,width=10,height=100; -Item=Volumebar,x=10,y=10,width=10,height=100,bg=#FF000000,fg=#FFFFFFFF; - - -Known Sections --------------- - -Section: [ChannelSmall] -Description: The channel display. It displays the current programme and number - only, together with some decoration. - -Section: [Channel] -Description: The channel display. It displays the current programme and number, - together with the currently running programme and possibly a - timebar and (not implemented yet) channel logo [ TODO remove - comment ]. - -Section: [Volume] -Description: The volume display. It displays the volumebar and possibly a mute - symbol, along with decorative items. - -Section: [ReplayMode] -Description: The replay modes display. Will be shown if only the replay mode - symbol shall be shown. - -Section: [Replay] -Description: [ TODO ] Full replay display. - -Section: [Message] -Description: [ TODO ] Message only display. - -Section: [Menu] -Description: [ TODO ] Full menu. - - -Known Items ------------ - -Item: Item=Skin -Description: This identifies the skin and adds a description to it. -Parameters: name, version - -Item: Item=Background -Description: This adds a background area for the specific display. This area - will be used to draw anything else, so you have to define a - 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 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 -Description: Draws plain text into the given area, using the given foreground - color. The background color is ignored, so no initializing - rectangle will be drawn. If no width or height are given, the - 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, 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, 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, text - -Item: Item=DateTimeF -Description: Draws a string expressing some details of the current date and - time. What is to be displayed will be decided by the skin author. - The paremeter "format" holds a format string according to the - manpage of strftime. -Parameters: x, y, width, height, fg, font, align, text, format - -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, 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, 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, text - -Item: Item=Rectangle -Description: Draws a filled rectangle into the defined area. -Parameters: x, y, width, height, fg - -Item: Item=Ellipse -Description: Draws a filled ellipse or a part of an ellipse into the defined - area. -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 (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, text - -Item: Item=PresentTitle -Description: Draws the title of the present programme. -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, text - -Item: Item=FollowingTime -Description: Draws the start time of the following programme. -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, text - -Item: Item=FollowingShortText -Description: Draws the short text (or episode name) of the following programme. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=SymbolTeletext -Description: Draws the specified image into the specified location if the - current channel has teletext. 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=SymbolAudio -Description: Draws the specified image into the specified location if the - current channel has multiple languages. 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=SymbolDolby -Description: Draws the specified image into the specified location if the - current channel has ac3 sound. 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=SymbolEncrypted -Description: Draws the specified image into the specified location if the - current channel is encrypted. 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=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=SymbolPlay -Description: Draws the specified image into the specified location if the - current replay is playing normally. 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=SymbolPause -Description: Draws the specified image into the specified location if the - current replay is paused. 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=SymbolFastFwd -Description: Draws the specified image into the specified location if the - current replay is fast forwarding. 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=SymbolFastRew -Description: Draws the specified image into the specified location if the - current replay is fast rewinding. 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=SymbolSlowFwd -Description: Draws the specified image into the specified location if the - current replay is slow forwarding. 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=SymbolSlowRew -Description: Draws the specified image into the specified location if the - current replay is slow rewinding. 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=SymbolEventRunning -Description: Draws the specified image into the specified location if the - displayed event (in menu display) is currently running. 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=SymbolEventTimer -Description: Draws the specified image into the specified location if the - displayed event (in menu display) will be recorded. 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=SymbolEventVPS -Description: Draws the specified image into the specified location if the - displayed event (in menu display) is VPS. 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=SymbolScrollUp -Description: Draws the specified image into the specified location if the - current display is scrollable and not at the top of its contents. - 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=SymbolScrollDown -Description: Draws the specified image into the specified location if the - current display is scrollable and not at the bottom of its - contents. 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. -Parameters: x, y, width, height, fg, bg - -Item: Item=Mute -Description: Draws a mute symbol and/or text (if given) into the specified area. - See Item=Text and Item=Background for more on text and image - handling. -Parameters: x, y, width, height, fg, bg, text, font, align, path - -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, text - -Item: Item=ReplayCurrent -Description: Draws the current time in the current replay. -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, text - -Item: Item=ReplayJump -Description: Draws the "Jump:" prompt (if present) of the current replay. -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, text - -Item: Item=MessageInfo -Description: Draws the current info message (if present). -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, text - -Item: Item=MessageError -Description: Draws the current error message (if present). -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuArea -Description: Specifies the area in which the menu items will be shown as a - list. -Parameters: x, y, width, height - -Item: Item=MenuItem -Description: Specifies how one item is drawn in the list of menu items. - list. -Parameters: [x,] [y,] width, height, fg, bg, font, align - -Item: Item=MenuCurrent -Description: Specifies how the currently selected item is drawn in the list of - menu items. - list. -Parameters: [x,] [y,] width, height, fg, bg, font, align - -Item: Item=MenuTitle -Description: Draws the title line of the displayed menu. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuRed, Item=MenuGreen, Item=MenuYellow, Item=MenuBlue -Description: Draws the red, green, yellow or blue (respectively) button. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuText -Description: Draws the current menu text in a scrollable text-area. If this - item is present, SymbolScrollUp and SymbolScrollDown apply, too. -Parameters: x, y, width, height, fg, [bg,] font, [align,] text - -Item: Item=MenuEventTitle -Description: Draws the title of the currently selected event when viewing EPG - entries. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuEventShortText -Description: Draws the short text or episode name of the currently selected - event when viewing EPG entries. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuEventDescription -Description: Draws the long text of the currently selected event when viewing - EPG entries in a scrollable text-area. If this item is present, - SymbolScrollUp and SymbolScrollDown apply, too. -Parameters: x, y, width, height, fg, [bg,] font, [align,] text - -Item: Item=MenuEventTime -Description: Draws the start time of the currently selected event when viewing - EPG entries. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuEventEndTime -Description: Draws the end time of the currently selected event when viewing - EPG entries. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuEventVPSTime -Description: Draws the vps time of the currently selected event when viewing - EPG entries, if that is different from the start time. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuEventDate -Description: Draws the date of the currently selected event when viewing - EPG entries. -Parameters: x, y, width, height, fg, font, align, text - -Item: Item=MenuEventDateTimeF -Description: Draws a string expressing some details of the start time of the - currently selected event when viewing EPG entries. What is to - be displayed will be decided by the skin author. The paremeter - "format" holds a format string according to the manpage of - strftime. -Parameters: x, y, width, height, fg, font, align, text, format - -Item: Item=MenuRecording -Description: Draws the summary of the currently selected recording when - browsing recordings in a scrollable text-area. If this item is - present, SymbolScrollUp and SymbolScrollDown apply, too. -Parameters: x, y, width, height, fg, [bg,] font, [align,] text - -Known Parameters ----------------- - -Parameter: x -Description: A positive number representing the vertical offset in pixels. -Default: MANDATORY - -Parameter: y -Description: A positive number representing the horizontal offset in pixels. -Default: MANDATORY - -Parameter: width -Description: A positive number representing the width in pixels. -Default: not given (sometimes mandatory) - -Parameter: height -Description: A positive number representing the height in pixels. -Default: not given (sometimes mandatory) - -Parameter: bpp -Description: A positive number representing the depth of a background area. - Possible values are 1, 2, 3, 4 and 8 mapping to 2, 4, 8, 16 and - 256 colors. -Default: 4 (16 colors) - -Parameter: fg -Description: A hex quadriplet [ TODO is this word correct?! ] introduced by '#' - representing a 32-bit foreground color in the order ARGB. -Default: not given -Example: #ff000000 - -Parameter: bg -Description: A hex quadriplet [ TODO is this word correct?! ] introduced by '#' - representing a 32-bit background color in the order ARGB. -Default: not given - -Parameter: font -Description: A string representing one of VDR's skins, possible values are - 'Osd', 'Sml' and 'Fix'. -Default: Osd - -Parameter: path -Description: A string representing a path- and filename relative to the skin - directory. Currently, xpm images and png files (with alphachannel - support) can be loaded, but the number of different colors used - in the image must not exceed those possible in the corresponding - background area. -Default: not given - -Parameter: altpath -Description: A string representing a path- and filename relative to the skin - directory. This is used for for displaying alternate images i.e. - for symbols. For more information, see path=... -Default: not given - -Parameter: text -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: type -Description: The format string for a date/time display according to strftime. -Default: "" - -Parameter: align -Description: A number describing the text alignment. Possible values are '0' - for left aligned, '1' for centered and '2' for right aligned. -Default: 0 - diff --git a/deprecated/SKINS.de b/deprecated/SKINS.de deleted file mode 100644 index 2e1cc8e..0000000 --- a/deprecated/SKINS.de +++ /dev/null @@ -1,259 +0,0 @@ - - -DIESES DOKUMENT IST NICHT AUF DEM NEUESTEN STAND (sorry) - - -Wie man textbasierte Skins erstellt ------------------------------------ - -Das Skin selbst findet in einem Unterverzeichnis "text2skin" innerhalb des -"plugins" Verzeichnisses ihres Konfigurationsordners. Das ist normalerweise das -Videoverzeichnis, wenn beim VDR-Start -c nicht angegeben wurde, sonst eben das -dort angegebene. Jedes Skin hat dort ein eigenes Verzeichnis, welches die -Beschreibungsdatei und Bilder enthält. Die Beschreibungsdatei muss den gleichen -Namen wie das Skin tragen, mit der Dateiendung ".skin". - -Beispiel (das Skin heisst myskin): -/video0/plugins/text2skin/ -/video0/plugins/text2skin/myskin/ -/video0/plugins/text2skin/myskin/myskin.skin -/video0/plugins/text2skin/myskin/channeldisplay.png - -Es ist wichtig, dass sie die Limitierungen des OSD Speichers verstehen. Wenn -zuviele Objekte mit zuvielen Farben definiert werden, dann wird VDR einen -Fehler ins Log schreiben und einige Bereiche werden nicht angezeigt werden. Bei -anderen Ausgabegeräten mag es sein, dass diese Limitierungen nicht zutreffen, -wenn Sie also ein Skin für ein anderes Gerät schreiben möchten, benutzen Sie -ruhig ein paar mehr Farben, aber denken Sie daran, dass VDR generell maximal -256 Farben pro Objekt verwalten kann. - -Ein Objekt ist als ein bestimmter Bereich definiert, der eine bestimmte -Farbpalette und Farbtiefe verwendet. Diese Objekte werden im Verlauf dieses -Dokuments "Backgrounds" genannt. Berechnen sie die Dimensionen dieser Bereiche -weise, denn überlappende oder übergroße Backgrounds führen zu einem Fehler. -Zusätzlich muss die Breite und Höhe jedes Backgrounds durch vier teilbar sein. - - -Die Erstellung eines Bildes ---------------------------- - -Ich habe mit gimp einige Beispielbilder erstellt, die Dinge auf dem Bildschirm -anzeigen, obwohl ich mit Grafik eigentlich recht wenig am Hut habe. Um einige -Hinweise zu geben, werde ich erklären wie ich diese Bilder erzeugt habe. - -Ich habe eine Vorlage für ein Kanaldisplay von einem Community-Mitglied -erhalten, dieses in drei Bereiche zerlegt, die jeweils komplett vom Hintergrund -gefüllt wurden. Nun habe ich das Bild so vergrößert, dass Breite und Höhe durch -vier teilbar sind. Um im mittleren Bereich etwas Transparenz zu erzeugen, habe -ich die Deckkraft der Bildebene auf 50% reduziert. Anschliessend habe ich alle -Bilder auf 14 Farben reduziert (Bild->Modus->Indiziert) (natürlich darf das -Bild nicht zu aufwändig sein, aber mit 14 Farben bekommt man schon schöne -Übergänge hin. Dann bleiben zwei Farben für Text und Symbole übrig, und das -ganze passt in einen 16-farb (4-bit) Background. Reduzieren sie die Azahl der -Farben entsprechend, wenn Sie beabsichtigen, mehr Vordergrundobjekte zu -zeichnen. Das Ergebnis habe ich als PNG gespeichert und in das Skin kopiert. - -Wenn sie beabsichtigen, xpm's zu nutzen, achten sie darauf dass VDR keine -benannten Farben beherrscht, es könnte also sein dass Bilder die gimp erzeugt -nicht sofort nutzbar sind. Die einzige benannte Farbe, die VDR beherrscht, ist -"None". - - -Das Format der Beschreibungsdatei ---------------------------------- - -Die Datei ist eine einfache Konfigurationsdatei, die aus Sektionen und Objekten -besteht. Kommentarzeilen können mit einem '#' eingeleitet werden. Leerzeilen -werden ignoriert. Eine Sektion ist von eckigen '[]' Klammern eingeschlossen. -Ein Objekt beginnt mit dem Text "Item=", gefolgt von der Art des Objekts. -Dahinter folgen Parameter für das Objekt, mit Komma getrennt. Die Zeile wird -durch ein Semikolon ';' abgeschlossen. - -Beispiel: -Item=Skin,name=Test,version=0.0.1; -[Channel] -Item=Background,path=channeltop.xpm,x=42,y=350,width=540,height=32,bg=#00FFFFFF; -Item=Background,path=channel.png,x=48,y=382,width=528,height=84; -Item=ChannelNumberName,x=50,y=355,fg=#FFFFFFFF,bg=#FF1965FF,font=Sml; -Item=PresentTime,x=52,y=387,fg=#FFFFFFFF,bg=#7F002254,font=Osd; -[Volume] -Item=Background,x=10,y=10,width=10,height=100; -Item=Volumebar,x=10,y=10,width=10,height=100,bg=#FF000000,fg=#FFFFFFFF; - - -Bekannte Sektionen ------------------- - -Sektion: [ChannelSmall] - Die Kanalanzeige, die nur aktuellen Kanalnamen und -nummer - anzeigt. - -Sektion: [Channel] -Beschreibung: Die Kanalanzeige. Sie zeigt aktuellen Kanalnamen und -nummer, - gemeinsam mit dem aktuellen Programm und möglicherweise eine - Zeitleiste und ein Kanallogo (noch nicht implementiert). - -Sektion: [Volume] -Beschreibung: Die Lautstärkeanzeige. Zeigt die Lautstärkeleiste und - möglicherweise ein Mute-Symbol und etwas Dekoration. - -Sektion: [ReplayMode] -Beschreibung: Die Wiedergabeanzeige. Wird angezeigt wenn nur der - Wiedergabemodus gezeigt werden soll. - -Sektion: [Replay] -Beschreibung: [ TODO ] Die große Wiedergabeanzeige - -Sektion: [Message] -Beschreibung: [ TODO ] Anzeige einer Nachricht - -Sektion: [Menu] -Beschreibung: [ TODO ] Vollständiges Menü - - -Bekannte Objekte ----------------- - -Objekt: Item=Skin -Beschreibung: Dieses Objekt identifiziert ein Skin und fügt eine Beschreibung - hinzu. -Parameter: name, version - -Objekt: Item=Background -Parameter: x, y, width, height, bpp, path, bg, fg - -Objekt: Item=Text -Parameter: x, y, text, width, height, fg, font, align - - -Objekt: Item=DateTime -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=Date -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=Time -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=ChannelNumberName -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=ChannelNumber -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=ChannelName -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=Rectangle -Parameter: x, y, width, height, fg - -Objekt: Item=Ellipse -Parameter: x, y, width, height, fg - -Objekt: Item=Timebar -Parameter: x, y, width, height, fg, bg - -Objekt: Item=PresentTime -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=PresentTitle -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=PresentShortText -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=FollowingTime -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=FollowingTitle -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=FollowingShortText -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=SymbolTeletext -Parameter: x, y, width, height, path, altpath, fg, bg - -Objekt: Item=SymbolAudio -Parameter: x, y, width, height, path, altpath, fg, bg - -Objekt: Item=SymbolDolby -Parameter: x, y, width, height, path, altpath, fg, bg - -Objekt: Item=SymbolEncrypted -Parameter: x, y, width, height, path, altpath, fg, bg - -Objekt: Item=Volumebar -Parameter: x, y, width, height, fg, bg - -Objekt: Item=Mute -Parameter: x, y, width, height, fg, bg, text, font, align, path - -Objekt: Item=Progressbar -Parameter: x, y, width, height, fg, bg - -Objekt: Item=ReplayTitle -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=ReplayCurrent -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=ReplayTotal -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=ReplayJump -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=MessageStatus -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=MessageInfo -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=MessageWarning -Parameter: x, y, width, height, fg, font, align - -Objekt: Item=MessageError -Parameter: x, y, width, height, fg, font, align - - -Bekannte Parameters ----------------- - -Parameter: x -Standard: PFLICHT - -Parameter: y -Standard: PFLICHT - -Parameter: width -Standard: nicht gesetzt (sometimes mandatory) - -Parameter: height -Standard: nicht gesetzt (sometimes mandatory) - -Parameter: bpp -Standard: 4 (16 Farbem) - -Parameter: fg -Standard: nicht gesetzt -Beispiel: #ff000000 - -Parameter: bg -Standard: nicht gesetzt - -Parameter: font -Standard: Osd - -Parameter: path -Standard: nicht gesetzt - -Parameter: altpath -Standard: nicht gesetzt - -Parameter: text -Standard: nicht gesetzt - -Parameter: align -Standard: 0 - @@ -1,11 +1,12 @@ /* - * $Id: display.c,v 1.18 2004/06/24 18:37:30 lordjaxom Exp $ + * $Id: display.c,v 1.19 2004/07/02 19:00:22 lordjaxom Exp $ */ #include "render.h" #include "data.h" #include "loader.h" #include "display.h" +#include "scroller.h" // --- cText2SkinDisplayChannel ----------------------------------------------- @@ -248,6 +249,7 @@ void cText2SkinDisplayMenu::Clear(void) { mRender->mMenuEvent = NULL; mRender->mMenuRecording = NULL; mRender->mMenuText = ""; + Dprintf("Clear\n"); //mRender->mMessageText = ""; DELETENULL(mRender->mScroller); mRender->Unlock(); @@ -281,6 +283,7 @@ void cText2SkinDisplayMenu::SetButtons(const char *Red, const char *Green, const } void cText2SkinDisplayMenu::SetMessage(eMessageType Type, const char *Text) { + Dprintf("SetMessage %s\n", Text); if (Text == NULL) Text = ""; mRender->Lock(); if (mRender->mMessageType != Type || mRender->mMessageText != Text) { @@ -1,5 +1,5 @@ /* - * $Id: render.c,v 1.36 2004/06/25 17:51:34 lordjaxom Exp $ + * $Id: render.c,v 1.39 2004/07/14 16:29:48 lordjaxom Exp $ */ #include "render.h" @@ -8,6 +8,8 @@ #include "theme.h" #include "bitmap.h" #include "status.h" +#include "screen.h" +#include "scroller.h" #include <vdr/channels.h> #include <vdr/epg.h> #include <vdr/menu.h> @@ -24,7 +26,7 @@ cText2SkinRender::cText2SkinRender(cText2SkinLoader *Loader, eSkinSection Sectio mI18n = Loader->I18n(); mTheme = Loader->Theme(); mSection = Section; - mOsd = NULL; + mScreen = NULL; mScroller = NULL; mChannel = NULL; mChannelNumber = 0; @@ -57,11 +59,11 @@ cText2SkinRender::cText2SkinRender(cText2SkinLoader *Loader, eSkinSection Sectio cText2SkinItem *item = mData->Get(sectionSkin, itemSkin); switch (mBase = item->Base()) { case baseRelative: - mOsd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop); + mScreen = new cText2SkinScreen(Setup.OSDLeft, Setup.OSDTop); mBaseSize = SIZE(Setup.OSDWidth, Setup.OSDHeight); break; case baseAbsolute: - mOsd = cOsdProvider::NewOsd(0, 0); + mScreen = new cText2SkinScreen(0, 0); mBaseSize = SIZE(720, 576); //XXX break; default: @@ -70,38 +72,24 @@ cText2SkinRender::cText2SkinRender(cText2SkinLoader *Loader, eSkinSection Sectio Dprintf("base: %d\n", item->Base()); - eOsdError res = oeOk; - areas[0].x1 = 0; - areas[0].y1 = 0; - areas[0].x2 = mBaseSize.w - 1; - areas[0].y2 = mBaseSize.h - 1; - areas[0].bpp = 8; - Dprintf("trying big area %d:%d:%d:%d\n", areas[0].x1, areas[0].y1, areas[0].x2, areas[0].y2, areas[0].bpp); - if ((res = mOsd->CanHandleAreas(areas, 1)) == oeOk) { - mOsd->SetAreas(areas, 1); - mOsd->DrawRectangle(areas[0].x1, areas[0].y1, areas[0].x2, areas[0].y2, areas[0].bpp); - } else { - Dprintf("failed, chunking\n"); - cText2SkinData::tIterator it = mData->First(mSection); - for (; it != mData->Last(mSection); ++it) { - if ((*it)->Item() == itemBackground) { - if (numAreas < MAXOSDAREAS) { - POINT p = (*it)->Pos(); - SIZE s = (*it)->Size(); - areas[numAreas].x1 = p.x; - areas[numAreas].y1 = p.y; - areas[numAreas].x2 = p.x + s.w - 1; - areas[numAreas].y2 = p.y + s.h - 1; - areas[numAreas].bpp = (*it)->Bpp(); - ++numAreas; - } else - esyslog("ERROR: text2skin: too many background areas\n"); - } + eOsdError res; + cText2SkinData::tIterator it = mData->First(mSection); + for (; it != mData->Last(mSection); ++it) { + if ((*it)->Item() == itemBackground) { + if (numAreas < MAXOSDAREAS) { + POINT p = (*it)->Pos(); + SIZE s = (*it)->Size(); + areas[numAreas].x1 = p.x; + areas[numAreas].y1 = p.y; + areas[numAreas].x2 = p.x + s.w - 1; + areas[numAreas].y2 = p.y + s.h - 1; + areas[numAreas].bpp = (*it)->Bpp(); + ++numAreas; + } else + esyslog("ERROR: text2skin: too many background areas\n"); } - - if ((res = mOsd->CanHandleAreas(areas, numAreas)) == oeOk) - mOsd->SetAreas(areas, numAreas); } + res = mScreen->SetAreas(areas, numAreas); if (res != oeOk) { const char *emsg = NULL; @@ -135,7 +123,7 @@ cText2SkinRender::~cText2SkinRender() { Cancel(3); } delete mScroller; - delete mOsd; + delete mScreen; cText2SkinBitmap::ResetCache(); mRender = NULL; } @@ -156,10 +144,7 @@ void cText2SkinRender::Action(void) { } void cText2SkinRender::Update(void) { - Dbench(update); - - if (mScroller && !mMenuScroll) - mOsd->SaveRegion(mScroller->Left(), mScroller->Top(), mScroller->Left() + mScroller->Width() - 1, mScroller->Top() + mScroller->Height() - 1); + // Dbench(update); cText2SkinData::tIterator it = mData->First(mSection); for (; it != mData->Last(mSection); ++it) { @@ -280,10 +265,10 @@ void cText2SkinRender::Update(void) { break; } } - Dbench(flush); - mOsd->Flush(); - Dprintf("flush only took %d ms\n", Ddiff(flush)); - Dprintf("complete flush took %d ms\n", Ddiff(update)); + // Dbench(flush); + mScreen->Flush(); + // Dprintf("flush only took %d ms\n", Ddiff(flush)); + // Dprintf("complete flush took %d ms\n", Ddiff(update)); } void cText2SkinRender::DrawBackground(const POINT &Pos, const SIZE &Size, const tColor *Bg, const tColor *Fg, int Alpha, const string &Path) { @@ -299,43 +284,45 @@ void cText2SkinRender::DrawBackground(const POINT &Pos, const SIZE &Size, const } if (bmp) - mOsd->DrawBitmap(Pos.x, Pos.y, bmp->Get(mUpdateIn)); - else - mOsd->DrawRectangle(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, Bg ? *Bg : 0); + mScreen->DrawBitmap(Pos.x, Pos.y, bmp->Get(mUpdateIn)); + else if (Bg) + mScreen->DrawRectangle(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, *Bg); } void cText2SkinRender::DrawImage(const POINT &Pos, const SIZE &Size, const tColor *Bg, const tColor *Fg, int Alpha, const string &Path) { cText2SkinBitmap *bmp; char *p; asprintf(&p, "%s/%s/%s", SkinPath(), mData->Skin().c_str(), Path.c_str()); - Dprintf("Trying to load image: %s\n", p); + // Dprintf("Trying to load image: %s\n", p); if ((bmp = cText2SkinBitmap::Load(p, Alpha)) != NULL) { if (Bg) bmp->SetColor(0, *Bg); if (Fg) bmp->SetColor(1, *Fg); - mOsd->DrawBitmap(Pos.x, Pos.y, bmp->Get(mUpdateIn)); + mScreen->DrawBitmap(Pos.x, Pos.y, bmp->Get(mUpdateIn)); } free(p); } void cText2SkinRender::DrawText(const POINT &Pos, const SIZE &Size, const tColor *Fg, const string &Text, const cFont *Font, int Align) { - mOsd->DrawText(Pos.x, Pos.y, Text.c_str(), Fg ? *Fg : 0, 0, Font, Size.w, Size.h, Align); + mScreen->DrawText(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); + mScreen->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); + mScreen->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); + mScreen->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) { +void cText2SkinRender::DrawProgressbar(const POINT &Pos, const SIZE &Size, int Current, int Total, const tColor *Bg, const tColor *Fg, const tColor *Selected, const tColor *Mark, const tColor *Cur, const cMarks *Marks) { if (Bg) DrawRectangle(Pos, Size, Bg); + if (Total == 0) + Total = 1; if (Current > Total) Current = Total; if (Size.w > Size.h) { @@ -345,12 +332,11 @@ void cText2SkinRender::DrawProgressbar(const POINT &Pos, const SIZE &Size, int C bool start = true; for (const cMark *m = Marks->First(); m; m = Marks->Next(m)) { POINT pt(Pos.x + m->position * Size.w / Total, Pos.y); - if (start) { + if (Selected && start) { const cMark *m2 = Marks->Next(m); - tColor col = clrRed; - DrawRectangle(POINT(pt.x, Pos.y + Size.h / 3), SIZE(((m2 ? m2->position : Total) - m->position) * Size.w / Total, Size.h / 3), &col); + DrawRectangle(POINT(pt.x, Pos.y + Size.h / 3), SIZE(((m2 ? m2->position : Total) - m->position) * Size.w / Total, Size.h / 3), Selected); } - DrawMark(pt, Size, start, m->position == Current, false); + DrawMark(pt, Size, start, m->position == Current, false, Mark, Cur); start = !start; } } @@ -361,51 +347,56 @@ void cText2SkinRender::DrawProgressbar(const POINT &Pos, const SIZE &Size, int C bool start = true; for (const cMark *m = Marks->First(); m; m = Marks->Next(m)) { POINT pt(Pos.x, Pos.y + m->position * Size.h / Total); - if (start) { + if (Selected && start) { const cMark *m2 = Marks->Next(m); - tColor col = clrRed; - DrawRectangle(POINT(Pos.x + Size.w / 3, pt.y), SIZE(Size.w / 3, ((m2 ? m2->position : Total) - m->position) * Size.h / Total), &col); + DrawRectangle(POINT(Pos.x + Size.w / 3, pt.y), SIZE(Size.w / 3, ((m2 ? m2->position : Total) - m->position) * Size.h / Total), Selected); } - DrawMark(pt, Size, start, m->position == Current, true); + DrawMark(pt, Size, start, m->position == Current, true, Mark, Cur); start = !start; } } } } -void cText2SkinRender::DrawMark(const POINT &Pos, const SIZE &Size, bool Start, bool Current, bool Horizontal) { - tColor mark = clrBlack; - tColor current = clrRed; +void cText2SkinRender::DrawMark(const POINT &Pos, const SIZE &Size, bool Start, bool Current, bool Horizontal, const tColor *Mark, const tColor *Cur) { POINT p1 = Pos; if (Horizontal) { - DrawRectangle(p1, SIZE(Size.w, 1), &mark); + if (Mark) + DrawRectangle(p1, SIZE(Size.w, 1), Mark); const int d = Size.w / (Current ? 3 : 9); for (int i = 0; i < d; i++) { + const tColor *col = Current ? Cur : Mark; int h = Start ? i : Size.w - 1 - i; - DrawRectangle(POINT(Pos.x + h, Pos.y - d + i), SIZE(1, (d - i) * 2), Current ? ¤t : &mark); + if (col) + DrawRectangle(POINT(Pos.x + h, Pos.y - d + i), SIZE(1, (d - i) * 2), col); } } else { - DrawRectangle(p1, SIZE(1, Size.h), &mark); + if (Mark) + DrawRectangle(p1, SIZE(1, Size.h), Mark); const int d = Size.h / (Current ? 3 : 9); for (int i = 0; i < d; i++) { + const tColor *col = Current ? Cur : Mark; int h = Start ? i : Size.h - 1 - i; - DrawRectangle(POINT(Pos.x - d + i, Pos.y + h), SIZE((d - i) * 2, 1), Current ? ¤t : &mark); + if (col) + DrawRectangle(POINT(Pos.x - d + i, Pos.y + h), SIZE((d - i) * 2, 1), col); } } } void cText2SkinRender::DrawScrolltext(const POINT &Pos, const SIZE &Size, const tColor *Fg, const string &Text, const cFont *Font, int Align) { if (mScroller == NULL) - mScroller = new cTextScroller(mOsd, Pos.x, Pos.y, Size.w, Size.h, Text.c_str(), Font, Fg ? *Fg : 0, clrTransparent); + mScroller = new cText2SkinScroller(mScreen, Pos.x, Pos.y, Size.w, Size.h, Text.c_str(), Font, Fg ? *Fg : 0, clrTransparent); else if (mMenuScroll) { mScroller->Scroll(mMenuScrollUp, mMenuScrollPage); mMenuScroll = false; } else - mOsd->RestoreRegion(); + mScroller->DrawText(); } void cText2SkinRender::DrawScrollbar(const POINT &Pos, const SIZE &Size, int Offset, int Shown, int Total, const tColor *Bg, const tColor *Fg) { DrawRectangle(Pos, Size, Bg); + if (Total == 0) + Total = 1; if (Size.h > Size.w) { POINT sp = Pos; SIZE ss = Size; @@ -421,48 +412,48 @@ void cText2SkinRender::DrawScrollbar(const POINT &Pos, const SIZE &Size, int Off } } -void cText2SkinRender::DisplayItem(cText2SkinItem *Item, const ItemData *Data) { - static ItemData dummyData; +void cText2SkinRender::DisplayItem(cText2SkinItem *Item, const tItemData *Data) { + static tItemData dummyData; if (Data == NULL) Data = &dummyData; switch (Item->Item()) { case itemBackground: - DrawBackground(Item->Pos(), Item->Size(), ItemBg(Item), ItemFg(Item), Item->Alpha(), Item->Path()); + DrawBackground(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), Item->Alpha(), Item->Path()); break; case itemText: - DrawText(Item->Pos(), Item->Size(), ItemFg(Item), ItemText(Item, Data->text), Item->Font(), Item->Align()); + DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, Data->text), Item->Font(), Item->Align()); break; case itemScrolltext: - DrawScrolltext(Item->Pos(), Item->Size(), ItemFg(Item), Data->text, Item->Font(), Item->Align()); + DrawScrolltext(Item->Pos(), Item->Size(), Item->Fg(), Data->text, Item->Font(), Item->Align()); break; case itemImage: - DrawImage(Item->Pos(), Item->Size(), ItemBg(Item), ItemFg(Item), Item->Alpha(), Item->Path()); + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), Item->Alpha(), Item->Path()); break; case itemLogo: case itemSymbol: if (Data->path != "") - DrawImage(Item->Pos(), Item->Size(), ItemBg(Item), ItemFg(Item), Item->Alpha(), Data->path); + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), Item->Alpha(), Data->path); break; case itemRectangle: - DrawRectangle(Item->Pos(), Item->Size(), ItemFg(Item)); + DrawRectangle(Item->Pos(), Item->Size(), Item->Fg()); break; case itemEllipse: - DrawEllipse(Item->Pos(), Item->Size(), ItemFg(Item), Item->Arc()); + DrawEllipse(Item->Pos(), Item->Size(), Item->Fg(), Item->Arc()); break; case itemSlope: - DrawSlope(Item->Pos(), Item->Size(), ItemFg(Item), Item->Arc()); + DrawSlope(Item->Pos(), Item->Size(), Item->Fg(), Item->Arc()); break; case itemProgress: - DrawProgressbar(Item->Pos(), Item->Size(), Data->current, Data->total, ItemBg(Item), ItemFg(Item), Data->marks); + DrawProgressbar(Item->Pos(), Item->Size(), Data->current, Data->total, Item->Bg(), Item->Fg(), Item->Selected(), Item->Mark(), Item->Current(), Data->marks); break; case itemScrollbar: - DrawScrollbar(Item->Pos(), Item->Size(), Data->current, Data->shown, Data->total, ItemBg(Item), ItemFg(Item)); + DrawScrollbar(Item->Pos(), Item->Size(), Data->current, Data->shown, Data->total, Item->Bg(), Item->Fg()); default: break; } } void cText2SkinRender::DisplayDateTime(cText2SkinItem *Item) { - ItemData data; + tItemData data; char text[1000]; time_t t = time(NULL); struct tm tm_r, *tm; @@ -492,7 +483,7 @@ void cText2SkinRender::DisplayDateTime(cText2SkinItem *Item) { void cText2SkinRender::DisplayChannelNumberName(cText2SkinItem *Item) { if (mChannel || mChannelNumber) { - ItemData data; + tItemData data; data.path = Item->Path() + "/" + ChannelName(mChannel, mChannelNumber) + "." + Item->Type(); switch (Item->Display()) { case displayChannelNumberName: @@ -526,7 +517,7 @@ void cText2SkinRender::DisplayPresentTime(cText2SkinItem *Item) { } if (event && event->StartTime()) { - ItemData data; + tItemData data; char text[1000]; const char *f = "%H:%M"; time_t t = 0, n = time(NULL); @@ -585,7 +576,7 @@ void cText2SkinRender::DisplayPresentIcon(cText2SkinItem *Item) { } if (event) { - ItemData data; + tItemData data; switch (Item->Display()) { case displayPresentVPS: data.path = event->Vps() && event->Vps() != event->StartTime() ? Item->Path() : Item->AltPath(); @@ -640,7 +631,7 @@ void cText2SkinRender::DisplayPresentText(cText2SkinItem *Item) { } if (text != "") { - ItemData data; + tItemData data; data.text = text; DisplayItem(Item, &data); } @@ -649,7 +640,7 @@ void cText2SkinRender::DisplayPresentText(cText2SkinItem *Item) { void cText2SkinRender::DisplayFollowingTime(cText2SkinItem *Item) { if (mChannelFollowing && mChannelFollowing->StartTime()) { - ItemData data; + tItemData data; char text[1000]; time_t t = 0, n = time(NULL); struct tm tm_r, *tm; @@ -680,7 +671,7 @@ void cText2SkinRender::DisplayFollowingTime(cText2SkinItem *Item) { void cText2SkinRender::DisplayFollowingTitle(cText2SkinItem *Item) { if (mChannelFollowing && mChannelFollowing->Title()) { - ItemData data; + tItemData data; data.text = mChannelFollowing->Title(); DisplayItem(Item, &data); } @@ -688,7 +679,7 @@ void cText2SkinRender::DisplayFollowingTitle(cText2SkinItem *Item) { void cText2SkinRender::DisplayFollowingShortText(cText2SkinItem *Item) { if (mChannelFollowing && mChannelFollowing->ShortText()) { - ItemData data; + tItemData data; data.text = mChannelFollowing->ShortText(); DisplayItem(Item, &data); } @@ -705,7 +696,7 @@ void cText2SkinRender::DisplayLanguage(cText2SkinItem *Item) { Dprintf("\n"); if (current < i) { - ItemData data; + tItemData data; data.text = tracks[current]; data.path = Item->Path() + "/" + tracks[current] + "." + Item->Type(); DisplayItem(Item, &data); @@ -715,7 +706,7 @@ void cText2SkinRender::DisplayLanguage(cText2SkinItem *Item) { void cText2SkinRender::DisplayChannelIcon(cText2SkinItem *Item) { if (mChannel && !mChannel->GroupSep()) { - ItemData data; + tItemData data; switch (Item->Display()) { case displayTeletext: data.path = mChannel->Tpid() ? Item->Path() : Item->AltPath(); @@ -745,7 +736,7 @@ void cText2SkinRender::DisplayChannelIcon(cText2SkinItem *Item) { void cText2SkinRender::DisplayVolume(cText2SkinItem *Item) { if (mVolumeTotal && mVolumeCurrent <= mVolumeTotal && !mVolumeMute) { - ItemData data; + tItemData data; char *text = NULL; data.total = mVolumeTotal; data.current = mVolumeCurrent; @@ -768,7 +759,7 @@ void cText2SkinRender::DisplayVolume(cText2SkinItem *Item) { } void cText2SkinRender::DisplayMuteIcon(cText2SkinItem *Item) { - ItemData data; + tItemData data; data.path = mVolumeMute ? Item->Path() : Item->AltPath(); if (data.path != "") DisplayItem(Item, &data); @@ -776,7 +767,7 @@ void cText2SkinRender::DisplayMuteIcon(cText2SkinItem *Item) { void cText2SkinRender::DisplayReplayTime(cText2SkinItem *Item) { if (mReplayTotal && mReplayCurrent <= mReplayTotal) { - ItemData data; + tItemData data; data.total = mReplayTotal; data.current = mReplayCurrent; data.marks = mReplayMarks; @@ -796,7 +787,7 @@ void cText2SkinRender::DisplayReplayTime(cText2SkinItem *Item) { void cText2SkinRender::DisplayReplayTitle(cText2SkinItem *Item) { if (mReplayTitle != "") { - ItemData data; + tItemData data; data.text = mReplayTitle; DisplayItem(Item, &data); } @@ -804,7 +795,7 @@ void cText2SkinRender::DisplayReplayTitle(cText2SkinItem *Item) { void cText2SkinRender::DisplayReplayPrompt(cText2SkinItem *Item) { if (mReplayJump != "") { - ItemData data; + tItemData data; data.text = mReplayJump; DisplayItem(Item, &data); } @@ -812,7 +803,7 @@ void cText2SkinRender::DisplayReplayPrompt(cText2SkinItem *Item) { void cText2SkinRender::DisplayReplaySymbol(cText2SkinItem *Item) { if (mReplayInfo) { - ItemData data; + tItemData data; switch (Item->Display()) { case displayPlay: data.path = (mReplaySpeed == -1 && mReplayPlay) ? Item->Path() : Item->AltPath(); @@ -841,7 +832,7 @@ void cText2SkinRender::DisplayReplaySymbol(cText2SkinItem *Item) { void cText2SkinRender::DisplayReplayMode(cText2SkinItem *Item) { if (cText2SkinStatus::ReplayMode() != replayNone) { - ItemData data; + tItemData data; Dprintf("Replay Type is %s\n", ReplayNames[cText2SkinStatus::ReplayMode()].c_str()); data.path = Item->Path() + "/" + ReplayNames[cText2SkinStatus::ReplayMode()] + "." + Item->Type(); DisplayItem(Item, &data); @@ -850,7 +841,7 @@ void cText2SkinRender::DisplayReplayMode(cText2SkinItem *Item) { void cText2SkinRender::DisplayMessage(cText2SkinItem *Item) { if (mMessageText != "" && (Item->Display() == displayMessage || (Item->Display() - displayMessageStatus) == mMessageType)) { - ItemData data; + tItemData data; data.text = mMessageText; DisplayItem(Item, &data); } @@ -858,14 +849,14 @@ void cText2SkinRender::DisplayMessage(cText2SkinItem *Item) { void cText2SkinRender::DisplayMenuTitle(cText2SkinItem *Item) { if (mMenuTitle != "") { - ItemData data; + tItemData data; data.text = mMenuTitle; DisplayItem(Item, &data); } } void cText2SkinRender::DisplayMenuButton(cText2SkinItem *Item) { - ItemData data; + tItemData data; switch (Item->Display()) { case displayMenuRed: data.text = mMenuRed; @@ -887,7 +878,7 @@ void cText2SkinRender::DisplayMenuButton(cText2SkinItem *Item) { } void cText2SkinRender::DisplayMenuText(cText2SkinItem *Item) { - ItemData data; + tItemData data; switch (Item->Display()) { case displayMenuText: @@ -913,7 +904,7 @@ void cText2SkinRender::DisplayMenuText(cText2SkinItem *Item) { void cText2SkinRender::DisplayMenuScrollIcon(cText2SkinItem *Item) { if (mScroller) { - ItemData data; + tItemData data; switch (Item->Display()) { case displayMenuScrollUp: data.path = mScroller->CanScrollUp() ? Item->Path() : Item->AltPath(); @@ -957,25 +948,29 @@ void cText2SkinRender::DisplayMenuItems(cText2SkinItem *Item) { POINT itempos = pos; itempos.y += i * item->Size().h; - itempos += Item->Pos1(); if (Item->Item() == itemText) { // draw tabs for (int t = 0; t < cSkinDisplayMenu::MaxTabs; ++t) { if (mMenuItems[i].tabs[t] != "") { - ItemData data; + tItemData data; cText2SkinItem cur = *Item; cur.Pos1() = itempos; + cur.Pos1() += Item->Pos1(); cur.Pos1().x += mMenuTabs[t]; cur.Pos2() += itempos; + if (t + 1 < cSkinDisplayMenu::MaxTabs && mMenuItems[i].tabs[t + 1] != "") + cur.Pos2().x = itempos.x + mMenuTabs[t + 1]; data.text = mMenuItems[i].tabs[t]; + // Dprintf("Menuitem: x = %d, w = %d, f = %08x\n", cur.Pos().x, cur.Pos2().x - cur.Pos1().x + 1, *ItemFg(&cur)); DisplayItem(&cur, &data); } if (!mMenuTabs[t + 1]) break; } } else { - ItemData data; + tItemData data; cText2SkinItem cur = *Item; cur.Pos1() = itempos; + cur.Pos1() += Item->Pos1(); cur.Pos2() += itempos; DisplayItem(&cur, &data); } @@ -998,30 +993,6 @@ string cText2SkinRender::ItemText(cText2SkinItem *Item, const string &Content) { return Content; } -tColor *cText2SkinRender::ItemFg(cText2SkinItem *Item) { - static tColor Fg; - if (Item->Fg() != "") { - if (Item->Fg()[0] == '#') - Fg = strtoul(Item->Fg().c_str() + 1, NULL, 16); - else - Fg = mTheme->Color(Item->Fg()); - } else - return NULL; - return &Fg; -} - -tColor *cText2SkinRender::ItemBg(cText2SkinItem *Item) { - static tColor Bg; - if (Item->Bg() != "") { - if (Item->Bg()[0] == '#') - Bg = strtoul(Item->Bg().c_str() + 1, NULL, 16); - else - Bg = mTheme->Color(Item->Bg()); - } else - return NULL; - return &Bg; -} - int cText2SkinRender::GetEditableWidth(MenuItem Item, bool Current) { cText2SkinItem *item; item = mData->Get(sectionMenu, itemMenuItem); @@ -1033,3 +1004,14 @@ POINT cText2SkinRender::Transform(const POINT &Pos) { return POINT(Pos.x < 0 ? base.w + Pos.x : Pos.x, Pos.y < 0 ? base.h + Pos.y : Pos.y); } +bool cText2SkinRender::ItemColor(const string &Color, tColor &Result) { + if (Color != "" && Color != "None") { + if (Color[0] == '#') + Result = strtoul(Color.c_str() + 1, NULL, 16); + else + Result = mRender->mTheme->Color(Color); + } else + return false; + return true; +} + @@ -1,5 +1,5 @@ /* - * $Id: render.h,v 1.24 2004/06/24 18:37:30 lordjaxom Exp $ + * $Id: render.h,v 1.26 2004/07/13 13:52:51 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_RENDER_H @@ -17,6 +17,8 @@ class cText2SkinLoader; class cText2SkinData; class cText2SkinI18n; class cText2SkinTheme; +class cText2SkinScroller; +class cText2SkinScreen; class cText2SkinRender: public cThread { friend class cText2SkinDisplayChannel; @@ -28,22 +30,12 @@ class cText2SkinRender: public cThread { private: static cText2SkinRender *mRender; - cText2SkinData *mData; - cText2SkinI18n *mI18n; - cText2SkinTheme *mTheme; - eSkinSection mSection; - cOsd *mOsd; - cTextScroller *mScroller; - - struct ItemData { - string text; - string path; - int current; - int shown; - int total; - const cMarks *marks; - ItemData(void) { marks = NULL; } - }; + cText2SkinData *mData; + cText2SkinI18n *mI18n; + cText2SkinTheme *mTheme; + eSkinSection mSection; + cText2SkinScreen *mScreen; + cText2SkinScroller *mScroller; // channel display const cChannel *mChannel; @@ -119,13 +111,13 @@ protected: 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 DrawProgressbar(const POINT &Pos, const SIZE &Size, int Current, int Total, const tColor *Fg, const tColor *Bg, const tColor *Selected, const tColor *Mark, const tColor *Cur, const cMarks *Marks = NULL); + void DrawMark(const POINT &Pos, const SIZE &Size, bool Start, bool Current, bool Horizontal, const tColor *Mark, const tColor *Cur); void DrawScrolltext(const POINT &Pos, const SIZE &Size, const tColor *Fg, const string &Text, const cFont *Font, int Align); void DrawScrollbar(const POINT &Pos, const SIZE &Size, int Offset, int Shown, int Total, const tColor *Bg, const tColor *Fg); // displays a full item - void DisplayItem(cText2SkinItem *Item, const ItemData *Data = NULL); + void DisplayItem(cText2SkinItem *Item, const tItemData *Data = NULL); // High-level operations void DisplayDateTime(cText2SkinItem *Item); @@ -155,8 +147,6 @@ protected: // Helpers string ItemText(cText2SkinItem *Item); string ItemText(cText2SkinItem *Item, const string &Content); - tColor *ItemFg(cText2SkinItem *Item); - tColor *ItemBg(cText2SkinItem *Item); int GetEditableWidth(MenuItem Item, bool Current); void Update(void); @@ -165,6 +155,7 @@ public: virtual ~cText2SkinRender(); static POINT Transform(const POINT &Pos); + static bool ItemColor(const string &Color, tColor &Result); void Flush(void) { Lock(); mDoUpdate.Broadcast(); Unlock(); } }; diff --git a/screen.c b/screen.c new file mode 100644 index 0000000..16f5418 --- /dev/null +++ b/screen.c @@ -0,0 +1,65 @@ +/* + * $Id: screen.c,v 1.2 2004/07/13 13:52:51 lordjaxom Exp $ + */ + +#include "screen.h" + +cText2SkinScreen::cText2SkinScreen(int x, int y) { + mOsd = cOsdProvider::NewOsd(x, y); +} + +cText2SkinScreen::~cText2SkinScreen() { + delete mOsd; +} + +eOsdError cText2SkinScreen::SetAreas(const tArea *Areas, int NumAreas) { + eOsdError result = mOsd->CanHandleAreas(Areas, NumAreas); + if (result == oeOk) { + mOsd->SetAreas(Areas, NumAreas); + mNumRegions = NumAreas; + for (int i = 0; i < mNumRegions; ++i) + mRegions[i] = new cBitmap(Areas[i].Width(), Areas[i].Height(), Areas[i].bpp, Areas[i].x1, Areas[i].y1); + Clear(); + } + return result; +} + +void cText2SkinScreen::Clear(void) { + for (int i = 0; i < mNumRegions; ++i) { + mRegions[i]->Reset(); + mRegions[i]->Clean(); + mRegions[i]->DrawRectangle(mRegions[i]->X0(), mRegions[i]->Y0(), mRegions[i]->X0() + mRegions[i]->Width() - 1, mRegions[i]->Y0() + mRegions[i]->Height() - 1, clrTransparent); + } +} + +void cText2SkinScreen::DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg, tColor ColorBg) { + for (int i = 0; i < mNumRegions; ++i) + mRegions[i]->DrawBitmap(x, y, Bitmap, ColorFg, ColorBg); +} + +void cText2SkinScreen::DrawRectangle(int x1, int y1, int x2, int y2, tColor Color) { + for (int i = 0; i < mNumRegions; ++i) + mRegions[i]->DrawRectangle(x1, y1, x2, y2, Color); +} + +void cText2SkinScreen::DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment) { + for (int i = 0; i < mNumRegions; ++i) + mRegions[i]->DrawText(x, y, s, ColorFg, ColorBg, Font, Width, Height, Alignment); +} + +void cText2SkinScreen::DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants) { + for (int i = 0; i < mNumRegions; ++i) + mRegions[i]->DrawEllipse(x1, y1, x2, y2, Color, Quadrants); +} + +void cText2SkinScreen::DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type) { + for (int i = 0; i < mNumRegions; ++i) + mRegions[i]->DrawSlope(x1, y1, x2, y2, Color, Type); +} + +void cText2SkinScreen::Flush(void) { + for (int i = 0; i < mNumRegions; ++i) + mOsd->DrawBitmap(mRegions[i]->X0(), mRegions[i]->Y0(), *mRegions[i]); + mOsd->Flush(); +} + diff --git a/screen.h b/screen.h new file mode 100644 index 0000000..71572a0 --- /dev/null +++ b/screen.h @@ -0,0 +1,33 @@ +/* + * $Id: screen.h,v 1.2 2004/07/13 13:52:51 lordjaxom Exp $ + */ + +#ifndef VDR_TEXT2SKIN_SCREEN_H +#define VDR_TEXT2SKIN_SCREEN_H + +#include "common.h" +#include <vdr/osd.h> + +class cText2SkinScreen { +private: + cOsd *mOsd; + cBitmap *mRegions[MAXOSDAREAS]; + int mNumRegions; + +public: + cText2SkinScreen(int x, int y); + ~cText2SkinScreen(); + + eOsdError SetAreas(const tArea *Areas, int NumAreas); + + void Clear(void); + void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0); + void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color); + void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault); + void DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants = 0); + void DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type); + + void Flush(void); +}; + +#endif // VDR_TEXT2SKIN_SCREEN_H diff --git a/scroller.c b/scroller.c new file mode 100644 index 0000000..465dcde --- /dev/null +++ b/scroller.c @@ -0,0 +1,69 @@ +/* + * $Id: scroller.c,v 1.1 2004/07/05 17:55:34 lordjaxom Exp $ + */ + +#include "scroller.h" +#include "screen.h" +#include <vdr/tools.h> + +cText2SkinScroller::cText2SkinScroller(void) { + mScreen = NULL; + mLeft = mTop = mWidth = mHeight = 0; + mFont = NULL; + mColorFg = 0; + mColorBg = 0; + mOffset = 0; + mShown = 0; +} + +cText2SkinScroller::cText2SkinScroller(cText2SkinScreen *Screen, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg) { + Set(Screen, Left, Top, Width, Height, Text, Font, ColorFg, ColorBg); +} + +void cText2SkinScroller::Set(cText2SkinScreen *Screen, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg) +{ + mScreen = Screen; + mLeft = Left; + mTop = Top; + mWidth = Width; + mHeight = Height; + mFont = Font; + mColorFg = ColorFg; + mColorBg = ColorBg; + mOffset = 0; + // sets mHeight to the actually used mHeight, which may be less than Height + mWrapper.Set(Text, Font, Width); + mShown = min(Total(), mHeight / mFont->Height()); + mHeight = mShown * mFont->Height(); + DrawText(); +} + +void cText2SkinScroller::Reset(void) { + mScreen = NULL; // just makes sure it won't draw anything +} + +void cText2SkinScroller::DrawText(void) { + if (mScreen) { + for (int i = 0; i < mShown; i++) + mScreen->DrawText(mLeft, mTop + i * mFont->Height(), mWrapper.GetLine(mOffset + i), mColorFg, mColorBg, mFont, mWidth); + } +} + +void cText2SkinScroller::Scroll(bool Up, bool Page) +{ + if (Up) { + if (CanScrollUp()) { + mOffset -= Page ? mShown : 1; + if (mOffset < 0) + mOffset = 0; + DrawText(); + } + } else { + if (CanScrollDown()) { + mOffset += Page ? mShown : 1; + if (mOffset + mShown > Total()) + mOffset = Total() - mShown; + DrawText(); + } + } +} diff --git a/scroller.h b/scroller.h new file mode 100644 index 0000000..9b338d9 --- /dev/null +++ b/scroller.h @@ -0,0 +1,47 @@ +/* + * $Id: scroller.h,v 1.1 2004/07/05 17:55:34 lordjaxom Exp $ + */ + +#ifndef VDR_TEXT2SKIN_SCROLLER_H +#define VDR_TEXT2SKIN_SCROLLER_H + +#include "common.h" +#include <vdr/font.h> + +class cText2SkinScreen; + +class cText2SkinScroller { +private: + cText2SkinScreen *mScreen; + const cFont *mFont; + int mLeft; + int mTop; + int mWidth; + int mHeight; + int mOffset; + int mShown; + tColor mColorFg; + tColor mColorBg; + cTextWrapper mWrapper; + +public: + cText2SkinScroller(void); + cText2SkinScroller(cText2SkinScreen *Screen, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg); + + void Set(cText2SkinScreen *Screen, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg); + void DrawText(void); + void Reset(void); + int Left(void) { return mLeft; } + int Top(void) { return mTop; } + int Width(void) { return mWidth; } + int Height(void) { return mHeight; } + int Total(void) { return mWrapper.Lines(); } + int Offset(void) { return mOffset; } + int Shown(void) { return mShown; } + bool CanScroll(void) { return CanScrollUp() || CanScrollDown(); } + bool CanScrollUp(void) { return mOffset > 0; } + bool CanScrollDown(void) { return mOffset + mShown < Total(); } + void Scroll(bool Up, bool Page); +}; + +#endif // VDR_TEXT2SKIN_SCROLLER_H diff --git a/text2skin.c b/text2skin.c index 5db7ff1..6ef67e3 100644 --- a/text2skin.c +++ b/text2skin.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: text2skin.c,v 1.23 2004/06/25 17:51:34 lordjaxom Exp $ + * $Id: text2skin.c,v 1.25 2004/07/14 16:01:38 lordjaxom Exp $ */ #include "text2skin.h" @@ -11,7 +11,7 @@ #include "i18n.h" #include "loader.h" -const char *cText2SkinPlugin::VERSION = "0.0.7"; +const char *cText2SkinPlugin::VERSION = "0.0.8"; const char *cText2SkinPlugin::THEMEVERSION = "0.0.3"; const char *cText2SkinPlugin::DESCRIPTION = "Loader for text-based skins"; |