From: Olivier Teulière Date: Thu, 20 May 2004 11:18:55 +0000 (+0000) Subject: Docbook documentation on how to create a skin for the skins2 module. X-Git-Tag: 0.7.2~17 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=701fb9653df0320013bfdefb81c28795fa0ca9d4;p=vlc Docbook documentation on how to create a skin for the skins2 module. --- diff --git a/doc/skins/skins2-howto.xml b/doc/skins/skins2-howto.xml new file mode 100644 index 0000000000..d38ce4f18f --- /dev/null +++ b/doc/skins/skins2-howto.xml @@ -0,0 +1,893 @@ + + + +
+ + + +HowTo create your own skin + + +2004 + +the VideoLAN project + + + + + +Skin creation HowTo + + + + + +Permission is granted to copy, distribute and/or +modify this document under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. The text of the license +can be found on the GNU +website. + + + + + + Olivier + Teulière + + + + + Skin + XML + Bezier + + + + + + +Basic principles + +A skin (or theme, the two words have almost the same meaning) for VLC is made of: + + + many PNG (Portable Network Graphics) files, for the images of the different states of the controls, + font files in the TTF (TrueType Font) format, + a XML file describing the logical structure of the skin (which bitmaps correspond to which controls, where to place buttons, sliders, and so on) and its behaviour (what happens when the user clicks on a button, etc.). + + +Those of you who have already made skins for other software should have no +difficulty to understand how VLC skins work. + + + + +Bezier curves + +One cool thing with VLC sliders is that they are not necessarily rectilinear, but they can follow any Bezier curve. So if you want to have a slider moving on a half-circle, or even doing a loop, you can! + +This is not the place to explain how Bezier curves work (see http://astronomy.swin.edu.au/~pbourke/curves/bezier/ for a nice introduction), the main thing to know is that a Bezier curve can be characterized by a set of points. Once you have them (thanks to the CurveMaker utility for example), you just need to enter the list of points in the points attribute. Here is an example with 3 points: points="(2,50),(45,120),(88,50)". + +Bezier curves can be used with the Slider and Anchor tags: + + + For sliders, it defines the curve followed by the cursor of the slider. This curve is of course invisible, so if you want a visible background for your Slider you need to provide it yourself using the Image tag. + For anchors, the use of Bezier curves is more anecdotic. Its purpose is to have non-ponctual anchor, the whole curve becoming the anchor. In this case, a ponctual anchor (and only a ponctual one) can be attracted by any point of the curve, if it is in its range of action. In fact, you can consider the curve as an easy way to define at once many anchors that share the same properties (except their position, of course :)). + + +The coordinates are relative to the upper-left corner of the control (i.e. to its x and y attributes). + + + + +The bitmaps + +Basically, you need one bitmap file (in PNG format) by state of control. For example, with a Image control you need 1 image, with a Button control you need 3 images (for the up, down and mouseover states). Of course, the same bitmap file can be used for many controls, provided you want to display the same image! + +The PNG format allows setting a transparency mask, which will be used wherever the image needs to be displayed (only non-transparent parts will be drawn). In addition, you can also specify a transparency color in the XML file: the bitmap will be considered as transparent wherever this color appears in the bitmap file. + +Both the transparency mask and the transparent color will be taken into acount, so if the transparency mask is correctly set in the bitmap file you need to choose a unused color for the transparency color. + + + + +The XML file + +XML is a markup language, like HTML. It won't be explained here any further, please use Google if you don't know what XML is. You'll see, it is rather easy to understand. + +The XML file used for the VLC skins follows a predefined DTD. You can find this DTD in VLC CVS, and its reading is strongly advised, since it contains the default values used for the parameters. A skin that does not follow the DTD with which VLC was compiled won't be loaded by VLC (and it might even crash it...). + +For a better undestanding of what follows, you should have a look at the DTD and/or at an example of valid XML skin. + +OK, let's go for an enumeration of the different tags and their attributes: + + + Theme + Main tag, for global attributes + + version + Version of the DTD used when making the skin, such as "2.0" (you can find the version in the DTD itself). This number might be used in the future to provide a better backward compatibility with older skins. + Required. + + + tooltipfont + Identifiant of a Font or BitmapFont, used for the tooltips (beware that any character not present in a BitmapFont will be printed as a space, so will be invisible). The default value uses a font provided with VLC, so you don't need to provide it with your skin. + Default value: defaultfont + + + magnet + Allows to select the range of action (in pixels) of magnetism with borders of the screen: when the distance between the border of the screen and an anchor of a window is less than this value, the window will stick to the border. 0 disables magnetism with the screen borders. + Default value: 15 + + + alpha + Sets the alpha transparency of the windows. The value must be between 1 (nearly total transparency) and 255 (total opacity). Low values should be avoided. +This only works if transparency is not disabled in the preferences of the skins2 module. + Default value: 255 + + + movealpha + Sets the alpha transparency of the windows when they are moving. Same range as alpha. + This only works if transparency is not disabled in the preferences of the skins2 module. + Default value: 255 + + + + + ThemeInfo + You can enter here some information about you (but this information is currently unused by VLC...) + + name + Skin name. Not supported yet. + Implied. + + + author + Author of the skin. Not supported yet. + Implied. + + + email + Email of the author. Not supported yet. + Implied. + + + webpage + Web page in relation with the skin. Not supported yet. + Default value: http://www.videolan.org/vlc/ + + + + + Bitmap + Associates a bitmap file in PNG format with an identifiant (=name) that will be used by the various controls. Obviously, you need one Bitmap tag for each bitmap file you have. + + id + This is the identifiant of the bitmap that will be used with controls. Two bitmaps cannot have the same id. + Required. + + + file + This attribute is used to indicate the path and name of the bitmap file used. This path can be absolute (but you should definitely avoid it), or relative to the path of the XML file. + Required. + + + alphacolor + This is the transparency color of the bitmap. It must be indicated with the following format: "#RRGGBB" (where RR stands for the hexadecimal value of the red component, GG for the green one, and BB for the blue one). + If your PNG file specifies a transparency mask, it will be taken into account too. + Default value: #000000 + + + + + Font + Declares a font to be used in a Text or Playlist. + + id + Identifiant of the font that will be used with controls. + Required. + + + file + This is the file containing a TrueType font. + Required. + + + size + This is the size of the font, in points. + Default value: 12 + + + + + BitmapFont + + + id + Identifiant of the font that will be used with controls. + Required. + + + file + This is the file containing a bitmap font, à la Winamp. + Required. + + + type + Type of font, one of "digits" or "text". + Default value: digits + + + + + Window + A window that will appear on screen. + + id + Name of the window (it may be used for actions). Two windows cannot have the same id. + Default value: none + + + visible + Indicates whether the window should appear when VLC is started. Since VLC remembers the skin windows position and visibility, this attribute will only be used the first time the skin is started. + Default value: true + + + x + Initial left position of the window. + Default value: 0 + + + y + Initial top position of the window. + Default value: 0 + + + dragdrop + Indicates whether drag and drop of media files is allowed on this window. + Default value: true + + + playondrop + Indicates whether a dropped file is played directly (true) or only enqueued (false). This attribute has no effect if dragdrop is set to "false". + Default value: true + + + + + Layout + A layout is one aspect of a window, i.e. a set of controls and anchors. A window can have many layouts, but only one will be visible at any time. + + width + Width of the layout. this value is required since VLC is not (yet?) able to calculate it using the sizes and positions of the controls. + Required. + + + height + Height of the layout. this value is required since VLC is not (yet?) able to calculate it using the sizes and positions of the controls. + + + minwidth + Minimum width of the layout. This value is only used when resizing the layout. If this value is set to "-1", the initial width (as specified by the width attribute) will be used as minimum width. + Default value: -1 + + + maxwidth + Maximum width of the layout. This value is only used when resizing the layout. If this value is set to "-1", the initial width (as specified by the width attribute) will be used as maximum width. + Default value: -1 + + + minheight + Minimum height of the layout. This value is only used when resizing the layout. If this value is set to "-1", the initial height (as specified by the height attribute) will be used as minimum height. + Default value: -1 + + + maxheight + Maximum height of the layout. This value is only used when resizing the layout. If this value is set to "-1", the initial height (as specified by the height attribute) will be used as maximum height. + Default value: -1 + + + + + Group + Adds an offset to the elements it contains. A Group is only supposed to ease the job of the skin designer, who can adjust the position of a group of controls without modifying all the coordinates, but you can ignore it if you want (only one Group is necessary, inside the Window tag). Group tags can be nested. + + x + Try and guess. + Default value: 0 + + + y + What do you think? + Default value: 0 + + + + + Anchor + Create a "magnetic point" (or curve) in the current window. If an anchor of another window enters in the range of action of this anchor, the 2 anchors will automatically be on the same place, and the windows are "sticked". Each anchor has a priority (priority attribute), and the anchor with the highest priority is the winner, which means that when moving its window all the other anchored windows will move too. To break the effect of 2 anchored windows, you need to move the window whose anchor has the lower priority. + + x + Is it really necessary to explain ? + Default value: 0 + + + y + ... + Default value: 0 + + + priority + Priority of anchor (see the previous description). + Required. + + + points + Points defining the Bezier curve followed by the anchor. + You don't need to change this parameter if all you want is a ponctual anchor. + Default value: (0,0) + + + range + Range of action of the anchor, in pixels. Default is "10". + Default value: 10 + + + + + + Attributes common to all the controls + The following attributes are common to all the controls (Image, Button, Checkbox, Text, Slider, RadialSlider, Playlist, Video) + + id + Identifiant of the control. Currently unused. + Default value: none + + + visible + See Boolean expressions. + Default value: true + + + x + Horizontal offset of the control, relative to the parent tag (usually Group or Layout). + Default value: 0 + + + y + Vertical offset of the control, relative to the parent tag (usually Group or Layout). + Default value: 0 + + + lefttop + Indicate to which corner of the Layout the top-left-hand corner of this control is attached, in case of resizing. Possible values are 'lefttop', 'leftbottom', 'righttop' and 'rightbottom'. + Default value: lefttop + + + rightbottom + Indicate to which corner of the Layout the bottom-right-hand corner of this control is attached, in case of resizing. + Default value: lefttop + + + help + Help text for the current control. The variable '$H' will be expanded to this value when the mouse hovers the current control (see Text variables). + Default value: + + + + + Image + Create a simple image. Particularly useful for backgrounds. + See the Common attributes. + + image + Identifiant of a Bitmap. + Required. + + + action + Action triggered by a click on the control. Possible values are "move", to move the window, or "resizeSE" (SE as in South-East ; other directions will be added in the future) to resize the window in the corresponding direction. + Default value: none + + + + + Button + Create a button. + See the common attributes. + + up + Identifiant of a Bitmap, used when the button is up. + Required. + + + down + Identifiant of a Bitmap, used when the button is down. + Default value: none + + + over + Identifiant of a Bitmap, used when the mouse is over the button. + Default value: none + + + action + Action executed when the button is clicked. See Actions for a list of possible actions. + Default value: none + + + + + Checkbox + Create a checkbox, i.e. a button with 2 states (checked/unchecked). So you need 6 images for a full-featured checkbox: each state has a basic image ('up' state), an image for the control being hovered by the mouse ('over' state) and an image corresponding to a click not yet released ('down' state). If you supply only the basic images, the other ones will be identical. + See the common attributes. + + up1 + Identifiant of a Bitmap, used when the checkbox is up in the first state. + Required. + + + down1 + Identifiant of a Bitmap, used when the checkbox is down in the first state. + Default value: none + + + over1 + Identifiant of a Bitmap, used when the mouse is over the checkbox in the first state. + Default value: none + + + up2 + Identifiant of a Bitmap, used when the checkbox is up in the second state. + Required. + + + down2 + Identifiant of a Bitmap, used when the checkbox is down in the second state. + Default value: none + + + over2 + Identifiant of a Bitmap, used when the mouse is over the checkbox in the second state. + Default value: none + + + state + Boolean expression specifying the state of the checkbox: if the expression resolves to 'false', the first state will be used, and if it resolves to 'true' the second state will be used. Example for a checkbox showing/hiding a window whose id is "playlist_window": state="playlist_window.isVisible" (or state="not playlist_window.isVisible", depending on the states you chose). + Required. + + + action1 + Action executed when the checkbox is clicked (state 1 to state 2). See Actions for a list of possible actions. + Default value: none + + + action2 + Action executed when the checkbox is clicked (state 2 to state 1). See Actions for a list of possible actions. + Default value: none + + + tooltiptext1 + Tooltip associated with the checkbox in state 1. See also Text variables. + Default value: + + + tooltiptext2 + Tooltip associated with the checkbox in state 2. See also Text variables. + Default value: + + + + + Text + Control to display some text. + See the common attributes. + + font + Identifiant of a Font or BitmapFont (beware that any character not present in the BitmapFont will be printed as a space, so will be invisible). + Required. + + + text + Text to display. See Text variables. + Default value: + + + color + Color of the text, using the #RRGGBB format. + Default value: #000000 + + + width + Width of the text in pixels. If set to "0", the width is automatically calculated to fit with the current text. + Default value: 0 + + + + + Slider + Create a slider. + See the common attributes. + + up + Identifiant of a Bitmap, used when the slider cursor is up. + Required. + + + down + Identifiant of a Bitmap, used when the slider cursor is down. + Default value: none + + + over + Identifiant of a Bitmap, used when the mouse is over the slider cursor. + Default value: none + + + points + Points defining the Bezier curve followed by the slider cursor. + Default value: none + + + thickness + Thickness of the slider curve. This attribute is used to determine whether the mouse is over the slider (hence whether a mouse click will have an effect on the cursor position). + Default value: 10 + + + value + Variable controlled by the slider. Recognized values are "volume" and "time" (only exception: the Slider defined inside the Playlist tag does not need to set this attribute). + Default value: none + + + tooltiptext + Tooltip associated with the slider. See also Text variables. + Default value: + + + + + RadialSlider + Create a circular slider from a list of images with the different possible positions. + See the common attributes. + + sequence + Identifiant of a Bitmap containing the list of images of the different positions of the slider, concatenated vertically. + Required. + + + nbimages + Number of elementary images contained in the sequence. + Required. + + + minangle + Minimum angle of the rotation, corresponging to 0%. + Default value: 0 + + + maxangle + Maximum angle of the rotation, corresponging to 100%. + Default value: 360 + + + value + Variable controlled by the slider. Recognized values are "volume" and "time". + Default value: none + + + tooltiptext + Tooltip associated with the slider. See also Text variables. + Default value: + + + + + Video + Control containing a video. This allows skinable video outputs! + this control is still under development and its behaviour may change a lot in the future. + + width + Initial width of the control, in pixels. + Default value: 0 + + + height + Initial height of the control, in pixels. + Default value: 0 + + + + + Playlist + Create a playlist. This tag must contain a Slider tag (to allow scrolling in the playlist). + See the common attributes. + + width + Width of the playlist, in pixels. If playlist items are wider, the end of the name will be replaced with '...'. + Default value: 0 + + + height + Height of the playlist, in pixels. + Default value: 0 + + + font + Identifiant of a Font tag. + Required. + + + var + Type of playlist. Currently, only "playlist" is recognized, so don't bother with this attribute :) + Default value: playlist + + + fgcolor + Foreground color of the playlist items. + Default value: #000000 + + + playcolor + Foreground color of the item currently played. + Default value: #FF0000 + + + selcolor + Background color of selected items. + Default value: #0000FF + + + bgcolor1 + Background color for odd playlist items. + Default value: #FFFFFF + + + bgcolor2 + Background color for even playlist items. + Default value: #FFFFFF + + + + + + +Actions + +There is a predefined list of actions: + + + + none: Do nothing + + + dialogs.changeSkin(): Show a dialog box to load a new skin. This does the same as the predefined hotkey Ctrl+S. + + + dialogs.fileSimple(): Show the simple "Open File" dialog box. + + + dialog.file(): Show the "Open File" dialog box, with many options (stream output, subtitles, etc...). + + + dialog.disc(): Show the "Open Disc" dialog box. + + + dialogs.net(): Show the "Open Network Stream" dialog box. + + + dialogs.messages(): Show the "Meessage" dialog box (which gives error/warning/debug messages). + + + dialogs.prefs(): Show the "Preferences" dialog box. + + + dialogs.fileInfo(): Show the "File Info" dialog box. + + + dialogs.popup(): Show the popup menu, (already available with a right-click on a Image control). + + + vlc.play(): Play the current playlist item. + + + vlc.pause(): Pause the current playlist item. + + + vlc.stop(): Stop the current playlist item. + + + vlc.faster(): Play the current playlist item faster. + + + vlc.slower(): Play the current playlist item slower. + + + vlc.mute(): Toggle mute/un-mute. + + + vlc.fullscreen(): Toggle the fullscreen mode. + + + vlc.quit(): Quit VLC. + + + playlist.add(): Add a new item to the playlist. + + + playlist.del(): Remove the selected items from the playlist. + + + playlist.next(): Go to the next playlist item. + + + playlist.previous(): Go to the previous playlist item. + + + playlist.setRandom(true): Play the playlist items in random order. + + + playlist.setRandom(false): Play the playlist items in the playlist order. + + + playlist.setLoop(true): Loop at playlist end. + + + playlist.setLoop(false): Do not loop at playlist end. + + + WindowID.show(): Show the Window whose id attribute is 'WindowID'. + + + WindowID.hide(): Hide the Window whose id attribute is 'WindowID'. + + + WindowID.setLayout(LayoutID): Change the layout of the Window whose id attribute is 'WindowID', using the Layout whose id attribute is 'LayoutID'. + + + + + + +Text variables + +When specifying the text attribute of the Text control or any tooltip attribute, you can insert escape sequences which will be expanded dynamically. An escape sequence always starts with the '$' character, followed by one or more predefined letters. Here is the list of accepted escape sequences: + + + + $V: Value of the volume (from 0 to 100 --> useful for a percentage). + + + $T: Current time (the output format is H:MM:SS). + + + $L: Remaining time, when available (the output format is H:MM:SS). + + + $D: Duration of the stream, when available (the output format is H:MM:SS). + + + $H: Value of the help attribute of the control that is under the mouse. The main use of this escape character is to create a kind of status bar, providing contextual help. + Escape sequences in the help string are also transformed (except $H itself, it would generate an infinite loop!). + + + $N: Name of the stream that is being played. + + + $F: Full name (with path) of the stream that is being played. + + + +Example of tooltiptext value for a slider controlling the volume: "Volume: $V%". + + + + +Boolean expressions + +Some attributes in the XML file require a boolean value, such as "true" or "false". But sometimes, you may need something more complex than a mere "static" boolean value. For example, let's say that you want a Text control to display "Pause" whenever the stream is paused. Wouldn't it be nice to show this control only when the stream is paused, and to hide it the rest of the time? Well, guess what: this is possible. You only have to set the visible attribute of the Text control to "vlc.isPaused". + +Here is a list of all the dynamic statuses that can be used in boolean expressions: + + + + vlc.isPlaying: True when VLC is playing, false otherwise. + + + vlc.isStopped: True when VLC is stopped, false otherwise. + + + vlc.isPaused: True when VLC is paused, false otherwise. + + + vlc.isSeekable: True when the stream is seekable, false otherwise. This one can be used if you want to display a slider only when seeking is allowed. + + + vlc.isMute: True when the sound is mute (in VLC, not on your OS), false otherwise. + + + playlist.isRandom: True when the playlist items are played in a random order, false otherwise. + + + window_name.isVisible: True when the window whose id is "window_name" is visible, false otherwise. + + + +In addition to these dynamic values, you can use the constant values "true" and "false". And of course, any combination is allowed, using the "and", "or" and "not" operators. For example, supposing that you have a window named "playlist_window", the following expression is valid (even though completely stupid): +visible="(true) and ((not playlist_window.isVisible) and (not vlc.isStopped or false))" + + + + + +Compression + +When designing a new skin, it can be useful to organize your files in different directories. For example, you can have one directory for the fonts, another one for the images of the main window, yet another one for the images of the playlist window, etc... + +But such a structure is not very convenient when it comes to distributing the skin. To address this problem, VLC is able to load skins directly from a .tar.gz archive containing all your files, along with directory information. When loading the skin, the files will be extracted in a temporary directory, then VLC will recursively search a file named "theme.xml", and the first one to be found will be used to load the skin. Of course, the temporary directory will be removed when you quit VLC or change the interface. + +On Linux, creating a .tar.gz archive is rather straight-forward using the 'tar' and 'gzip' commands. On Windows, it can be done using Winzip, UltimateZip, or any other (well, almost) compression software... + +It is advised to rename your .tar.gz archive with the .vlt extention, for 2 main reasons: + + + on some systems, the "Change skin" dialog box only displays files which have a .vlt or .xml extention, + in the future, .vlt files could be associated to VLC in such a way that double-clicking a .vlt file would automatically load the skin in VLC. + + + + + +Tools and advice + + + Generating Bezier curves + + +To generate easily Bezier curves, you can use the curve-maker (sorry, this is for Windows users only). Basically, you add and remove points at will, and you can move them to see how the curve evolves. When you have reached the perfect curve, you just have to copy-paste the list of abscissas and ordinates to form the points attribute of your Slider or Playlist. The curve-maker also allows to load a .bmp file, this could be useful if you want to follow a specific pattern of a slider, for example. + + +This tool was made for the first version of the skins and has not been modified since then. This explains why it does not use PNG files and why it does not generate directly the value of the points attribute. + + + + Using VLC warning messages + +VLC is able to give warnings and error messages about a loaded skin if it finds problems in the XML file. This can be very helpful to detect syntax errors (a tag which is never closed for example), or incorrect values of attributes. Here is how to see these messages: + + + + on Linux, simply start VLC from a console with the following command-line: 'vlc -I skins2 -v' (you can use -vv if you want to see debug messages too), + on Windows it is more difficult to use the same method (but you can use it with a rxvt console, in the Cygwin environment). Then another solution is to start VLC with a command-line such as 'vlc -I skins2 -v --extraintf logger'. This should open both VLC and a log window containing the messages. What's more, the logs should be saved in a file named 'vlc-log.txt', in VLC installation directory. The relevant lines are those starting with "[00000178] skins2 interface" (the number may be different). + + + + + + Relative paths + + +For the Bitmap tags, do not use absolute paths but relative paths (they are relative to the XML file directory), so that your skin can be reused by anybody without a particular file structure. + + + + + Get inspiration + + +In order to use plainly the possibilities given, you should look at how existing skins are made, it may give you ideas for your own skins... + + + + + Submit your skin! + + +Once your skin is finished, you can share it with other people. The easiest way is probably to send it by email to vlc -at- videolan -dot- org, so that we can put it on the website with the other ones. + + + + + +