JoeTheZombie's VLC Skin Tutorial
Posted: 02 Aug 2007 17:45
.:: JoeTheZombie's VLC Skin Tutorial ::.
Basics : XML (And no, it's not a football league or T-shirt size)
At the heart of a custom skin for VLC is the theme.xml file. This file contains all the necessary tags to define a skin. Since it is an XML file, we have to (oddly enough) understand how XML files work before we can create our own. There are many XML primers on the Interwebs, so we won't get into too much detail here; we'll only cover enough to get us skinning. For those adventuresome enough to really tackle the XML specifications, here are some links to other XML resources:
Step 1 : <!DOCTYPE>
First off, let's create a directory to hold our skin. C:\tskin\
Using your favorite text editor, create a text file in this directory called theme.xml. Be careful not to accidentally create a theme.xml.txt file. This is especially problematic if using Windows, and Windows is set to hide file extensions. Some text editors try to automatically add .txt extension to our filename, so be warned. And now we can enter the first line of our skin:
Simply put, this tells us what tags our theme.xml file can contain and is the exact same line for all VLC skins. Basically it is saying this document is a public theme document and can only contain tags as defined in VLC's skin.dtd. You can actually look at the DTD here. It contains all the building blocks we can use to make our skin. It should be noted that the <!DOCTYPE> must always be the very first line of the document. When VLC loads a skin, it looks at this line to make sure the file really is a skin file.
Step 2 : <Theme>
Now, enter these next two lines:
The first line is saying we are going to create a new theme based on skins version 2. The second line says we are done creating our theme. You can think of them as the covers on a book. All of our tags for creating a new skin will need to be inserted between these two lines, to keep them in the "book". The <Theme> tag also supports several other attributes which you can read about right here. The only required attribute is version, but we can use the other attributes to change other aspects of our skin. For instance, if we look at the magnet attribute we read
Now our <Theme> tag is specifying that it is a version 2 skin, and also our skin won't snap to the edges of the screen when we get close. However, I like that snap to functionality, so for this tutorial, we won't alter that attribute from the default. Instead, how about we cause our skin to become slightly transparent when dragging the window around the desktop. Can you spot the attribute that will help us do this? Look at the <Theme> definition one more time and go over each of the attributes. If you guessed "movealpha" as the correct attribute, then give yourself a pat on the back. But now can you correctly alter the <Theme> tag?
Now our <Theme> tag is specifying that it is a version 2 skin, and also our skin will become slightly transparent (255 = solid, 0 = invisible) when we are moving the interface around. You also probably noticed the alpha attribute. If you wanted your skin to always be slightly transparent, you could define this attribute as well like this:
Now our <Theme> tag is specifying that it is a version 2 skin, it will be slightly transparent on the desktop, and will be even more transparent when we are moving the interface around. Of course, we haven't yet created our interface, so there is no way to test it...
For reference, here are all the attributes we can use with <Theme>, with required attributes highlighted. You can find out more about each attribute by referencing the <Theme> section of the skinning guide, just as we did before.
Step 3 : <ThemeInfo>
Now enter this next line. Remember, it needs to go in between the covers of our "book":
If we look at the <ThemeInfo> section of the skinning guide, we see that <ThemeInfo> has the following attributes:
One final note about <ThemeInfo> is that it does not contain other tags, so it does not have a closing partner. Instead, we just include the final forward slash at the end of the line (before the >) as to tell us we are done with <ThemeInfo>.
Step 4 : <Font>
<Font> is used to select which TrueType (.ttf) or OpenType (.otf) font we want to use to present text. If we look at the <Font> section of the skinning guide, we see it requires two attributes, with a third (size) having a default value of 12:
Our first attribute is id. This is what we are going to name our font/size pair. Our second attribute is file. This is the filename of our .ttf or .otf font file. Finally, the size attribute is used to determine what size the font will be. In this case, 11. Now, look carefully at the <Font> section of the skinning guide. You'll notice the size attribute is not a required attribute. What happens if we don't include it in our definition like this?:
Since we didn't include it, the default size of 12 will be used. Even though we named our font with the id of "lacuna-11", it would now be a size 12 font because we didn't include the size attribute, and thus the default will be used.
If you wish to use two different fonts or font sizes in your skin, we need to have multiple <Font> lines. An import note is that no two ids can be the same, so when we choose which fonts to use, make sure you give them different ids.
Here we'll be using two sizes of the same font. The first font we've named lacuna-small and will be a size 10 font. The second font we've named lacuna-big and will be a size 11 font.
Summary
In this section of the guide, we've learned how to start creating a skin. We haven't actually created an interface yet, but have our directory and theme.xml file created, and any fonts copied to our skin directory. We've also made sure that VLC will know this is a theme file (using the <!DOCTYPE> tag). At this stage, our directory (C:\tskin\) should contain two files:
theme.xml
LACURG__.TTF
Our theme.xml file should look like:
{ more to come... }
Basics : XML (And no, it's not a football league or T-shirt size)
At the heart of a custom skin for VLC is the theme.xml file. This file contains all the necessary tags to define a skin. Since it is an XML file, we have to (oddly enough) understand how XML files work before we can create our own. There are many XML primers on the Interwebs, so we won't get into too much detail here; we'll only cover enough to get us skinning. For those adventuresome enough to really tackle the XML specifications, here are some links to other XML resources:
- An XML primer - A very basic easy to understand guide (necessary reading!)
- XML Tutorial - Take XML school from w3schools.com (a somewhat complex guide)
- The XML FAQ - The FAQ on XML
- Extensible Markup Language (XML) 1.0 (Fourth Edition) - For the truly brave!
Step 1 : <!DOCTYPE>
First off, let's create a directory to hold our skin. C:\tskin\
Using your favorite text editor, create a text file in this directory called theme.xml. Be careful not to accidentally create a theme.xml.txt file. This is especially problematic if using Windows, and Windows is set to hide file extensions. Some text editors try to automatically add .txt extension to our filename, so be warned. And now we can enter the first line of our skin:
Code: Select all
<!DOCTYPE Theme PUBLIC "-//VideoLAN//DTD VLC Skins V2.0//EN" "skin.dtd">
Step 2 : <Theme>
Now, enter these next two lines:
Code: Select all
<Theme version="2.0">
</Theme>
This tells us that by default, if a skin gets within 15 pixels of the border of the screen, the window will snap to the border. Well, what if we don't want our skin to snap to the borders of the screen? Well, we can change the <Theme> tag to: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
Code: Select all
<Theme version="2.0" magnet="0">
Code: Select all
<Theme version="2.0" movealpha="192">
Code: Select all
<Theme version="2.0" alpha="192" movealpha="128">
For reference, here are all the attributes we can use with <Theme>, with required attributes highlighted. You can find out more about each attribute by referencing the <Theme> section of the skinning guide, just as we did before.
- version
- tooltipfont
- magnet
- alpha
- movealpha
Step 3 : <ThemeInfo>
Now enter this next line. Remember, it needs to go in between the covers of our "book":
Code: Select all
<ThemeInfo name="Tutorial Skin" author="me" webpage="http://www.mywebpage.com"/>
- name
- author
- webpage
One final note about <ThemeInfo> is that it does not contain other tags, so it does not have a closing partner. Instead, we just include the final forward slash at the end of the line (before the >) as to tell us we are done with <ThemeInfo>.
Step 4 : <Font>
<Font> is used to select which TrueType (.ttf) or OpenType (.otf) font we want to use to present text. If we look at the <Font> section of the skinning guide, we see it requires two attributes, with a third (size) having a default value of 12:
- id
- file
- size
Code: Select all
<Font id="lacuna-11" file="LACURG__.TTF" size="11"/>
Code: Select all
<Font id="lacuna-11" file="LACURG__.TTF"/>
If you wish to use two different fonts or font sizes in your skin, we need to have multiple <Font> lines. An import note is that no two ids can be the same, so when we choose which fonts to use, make sure you give them different ids.
Code: Select all
<Font id="lacuna-small" file="LACURG__.TTF" size="10"/>
<Font id="lacuna-big" file="LACURG__.TTF" size="11"/>
Summary
In this section of the guide, we've learned how to start creating a skin. We haven't actually created an interface yet, but have our directory and theme.xml file created, and any fonts copied to our skin directory. We've also made sure that VLC will know this is a theme file (using the <!DOCTYPE> tag). At this stage, our directory (C:\tskin\) should contain two files:
theme.xml
LACURG__.TTF
Our theme.xml file should look like:
Code: Select all
<!DOCTYPE Theme PUBLIC "-//VideoLAN//DTD VLC Skins V2.0//EN" "skin.dtd">
<Theme version="2.0" movealpha="192">
<ThemeInfo name="Tutorial Skin" author="me" webpage="http://www.mywebpage.com"/>
<Font id="lacuna-small" file="LACURG__.TTF" size="10"/>
<Font id="lacuna-big" file="LACURG__.TTF" size="11"/>
</Theme>