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>