MediaPortal Wiki > MediaPortal 1 > Contribute > Skins > Skin Architecture

Skin Architecture

Was this page helpful?
Redirected from MediaPortal1 Development/SkinArchitecture
    Split.png

    On 24 Sep 2010, chefkoch suggested that the content of this page or section be split into sub pages.

    Introduction

    The MediaPortal graphical user interface is a modular solution that uses skins to separate the look and feel from the logic in the application code. MediaPortal application functionality is surfaced through user interface windows (GUIWindow) containing many graphical user interface controls (GUIControl). However, without a skin file, none of this functionality is visible to the user.

    The user accesses the functionality surfaced from the application code through skins which are defined using XML. The application will load the appropriate XML skin file upon initialization. For example, when MediaPortal starts, the first skin to generally be loaded will be the myHome.xml or BasicHome.xml skin file depending on which option the user has configured.

    The use of XML simply provides a structured way to tell MediaPortal the layout, type of control and coordinates of every item on screen such as color of text, transparency if graphics etc. By changing the XML file within a skin the entire look and feel can be modified. Although the details are very different, the idea is the same as making a webpage however XML files are CASE SENSITIVE.

    Skin Folders

    Skin files are contained in the skins folder within the main MediaPortal application folder.

    Within the main skins folder there are sub-folders for each skin (Default and DefaultWide are installed with MediaPortal) and those folders contain the individual skin files (e.g. myHome.xml).

    There are also sub-folders for fonts, media and sounds. The media folder should have all the textures that the skin file uses (normally in PNG format for best quality).

    Special XML files

    There are two special XML files within the skin directory. fonts.xml and references.xml:

    Fonts (fonts.xml)

    The fonts that are available to the skin are defined in the fonts.xml file. The actual fonts are stored in the fonts sub-folder. Each font element defines:

    • The name that the font will be referenced as in the skin files
    • The filename of the actual font file
    • The height of the font
    • Whether the font is bold
    • Whether the font is italic
    • The numeric start character (default 0)
    • The numeric end character (default 255)

    References (references.xml)

    The references.xml file contains at minimum information about the skin version and resolution (width and height). It can also include default values for any of the controls (using the <control> tag) that are used in the skin so you don't have to define, for example, the sizes of buttons each and every time you use one in your other skin files. It can also define styles that can be applied to any control - see Styles below. Here is a partial references.xml file for example purposes. It shows that this skin is designed for a 720x576 pixel display (MediaPortal will scale it to whatever display the end user has) and the version is 0.1.0.15. It also contains the default values that will be used for any button control in any other skin file within this skin folder:

    <controls>
      <skin>
        <width>720</width>
        <height>576</height>
        <version>0.1.0.15</version>
      </skin>
      <control>
        <description>default button</description>
        <type>button</type>
        <id>1</id>
        <posX>300</posX>
        <posY>200</posY>
        <width>190</width>
        <height>32</height>
        <textXOff>10</textXOff>
        <textYOff>5</textYOff>
        <textureFocus>menu_list_focus.png</textureFocus>
        <textureNoFocus>menu_list_nofocus.png</textureNoFocus>
        <font>font13</font>
        <textcolor>ffffffff</textcolor>
        <colordiffuse>ffffffff</colordiffuse>
        <disabledcolor>60ffffff</disabledcolor>
      </control>
      ...

    Element Name

    Data Type

    Description

    width

    Integer

    Width of skin

    height

    Integer

    Height of skin

    version

    String

    Skin version displayed in configuration application

    Information on controls can be found in the controls section of this document.

    'Global' XML files

    A number of xml files are used by MediaPortal 'globally' - i.e. they are displayed by the software under certain conditions and may be displayed in any or all windows: Dialogs, Media Overlays, Topbar

    Dialogs

    Dialogs are displayed when a user presses the More/Info key on their remote or the F9 key on their keyboard, or sometimes when a user selects an option from a context menu. Different Dialogs display depending on the window and current action. See List of Dialogs

    Media Overlays

    Media Overlays, sometimes called 'previews', are the small windows that overlay the currently playing video, TV or music on any window. The default overlays (videoOverlay.xml, musicOverlay.xml) can be turned on or off in any xml using the allowoverlay window element: <allowoverlay>yes</allowoverlay>.

    A 'special' xml: videoOverlayTop.xml is also displayed whenever the default overlays are used and video is playing. The controls in this file display 'on top' of the video window.

    Media overlays can also be defined uniquely in a skin xml file and then imported (see <import> files below) into any xml thus replacing the default overlays when <allowoverlay>no</allowoverlay> is set in the xml.

    . For further Information: See Media Overlays

    Topbar

    The topbar displays at the top of most windows when the mouse hovers there, or when users select the up arrow key in most menus. It enables control of playback functions as well as exit MediaPortal, fullscreen video, home screen, etc.

    There are two xml files which define the topbar: topbarhome.xml which defines the topbar in the MyHome window, and topbar.xml which defines it in all other windows. Both topbars are fully 'skinnable'. Topbar.xml can automatically hidden or disabled in any xml using the window elements (before the <controls>): autohidetopbar (yes/no) and disabletopbar (yes/no) see Window Elements below for syntax.

    See also Topbar

    Media and Sound Folders

    The sounds folder contain WAV files used by the MediaPortal application and plugins.

    The following sounds are included in the default skins for navigational sounds. They can be adjusted in the configuration utility under General settings, Keys and Sounds.

    • back.wav
    • click.wav
    • cursor.wav
    • photo.wav
    • The following sounds are used by plugins:
    • notify.wav (MyMail plugin)

    • MyTetris.Block.wav (MyTetris plugin)

    • MyTetris.Knock.wav (MyTetris plugin)

    • MyTetris.Level.wav (MyTetris plugin)

    • MyTetris.Line.wav (MyTetris plugin)

    Packed Graphic Files

    Why are they needed?

    • Packed textures are decreasing the work load that GPU has to do with every single rendering pass.
    • More informations can be found at gamasutra and catnapgames

    How are they created?

    • Packed graphics are generated at runtime and are used to help keep the rendering portion of the application as efficient as possible. They are only created when no packed graphics already exist. They can be identified by the filename prefix packedgfx and end with either .bxml (binary xml) or .png.

    • When the individual graphic files of a skin are modified the packed graphic files and the related .bxml files must be deleted otherwise you'll not see your changes in MediaPortal.

    • The packed graphics files are located within individual skin folders in the Cache folder C:\Program Files\Team MediaPortal\MediaPortal\Cache\. In MediaPortal 1.0, the cache folder is in C:\Documents and Settings\All Users\Application Data\Team MediaPortal\ in Windows XP or C:\ProgramData\Team MediaPortal\MediaPortal\Cache\ in Vista.

    What skin designers have to pay attention on when design skins

    1. A 128MB GPU can only take 4 packed textures files.

      • If your skin creates more, then it will not work with such gfx-cards!

    2. texture sizes: no other than power of two dimensions should be used

    3. texture sizes: trim all unused space around the actual texture (if any)

    Skin Files

    This section covers the layout and tag definitions for the skin files. Unlike web pages, XML files

    are not forgiving of any mistakes and using the correct case for tag names is very important.

    <import> files

    Skin files have the ability to import/include files into the skin markup using the <import> or <include> tags.

    The concept is to move all the common markup into smaller and easier to manage files to minimize the amount of work required to create new skin files and to make it easier to maintain and modify existing skin files.

    The <import> control should be added to the <controls> section of the xml. The elements defined in the imported file will overlay elements which are defined previously in the xml, so the location of the <import> control is significant.

    Two of the most commonly imported files are common.window.xml which defines elements common to most or all windows, and common.time.xml which defines the display of the date and time on each window.

    <define> tags

    In order to realize the full benefits from import/include files there is also the <define> tag. The tag allows a basic form of parameter to be used so that the imported files can be as generic as possible. A define tag's value is a simple name - value pairing.

     

    MPLogo120.png

    1.2.0 alpha:   <define> tags can be used in the references.xml to define global defines. See Global Define Tags for details.

    <define> tags can also be used in any xml not only imported files

    <define> tags are entered in the window elements control at the top of the xml before the <controls>.

    The following would be a typical example of how this new feature could be used:

    <window>
      <!-- include the common window features here -->
      <define>#header.label:134</define>
      <define>#header.image:videos_logo.png</define>
      <define>#header.hover:hover_my videos.png</define>
      <controls>
        <!-- include the header logo, text and other common elements -->
        <import>common.window.xml</import>
        <control>
        ...

    The value 134 in the above example references a text string in the corresponding language file. For english, this would be the ""strings_en.xml"" in the language folder in the MediaPortal application folder.

    Any occurance of the token represented by the define's name will be replaced with the appropriate value in any imported markup. The following is an example of how an imported file could look:

    <window>
      <control>
        <type>image</type>
        <id>1</id>
        <posX>60</posX>
        <posY>20</posY>
        <texture>#header.image</texture>
      </control>
      <control>
        <type>label</type>
        <id>1</id>
        <posX>250</posX>
        <posY>70</posY>
        <label>#header.label</label>
        <font>font16</font>
        <textcolor>ffffffff</textcolor>
      </control>
      ...

    <window> element

    The first element in a skin file must be the <window> tag which contains information that applies to the entire window. Here is a partial skin.xml file for example purposes. Each of the tags is defined below:

    <window>
      <id>1234</id>
      <defaultcontrol>2</defaultcontrol>
      <allowoverlay>yes</allowoverlay>
      <autohidetopbar>no</autohidetopbar>
      <disabletopbar>no</disabletopbar>
      <define>#header.label:5900</define>
      <define>#header.image:trailers_logo.png</define>
      <define>#header.hover:hover_my trailers.png</define>
      <controls>
        <import>common.window.xml</import>
        <control>
        ...

    Element Name

    Data Type

    Description

    id

    Integer

    Each skin file must have a unique id and it must match the id in the application or plugin using the skin. This id is used to reference this skin page from a hyperlink in another skin page.

    defaultcontrol

    Integer

    Specifies the id of the default control in this skin file

    allowoverlay

    Boolean (yes or no)

    Show the video/tv/music preview screen in the bottom corner when a media file is playing

    autohidetopbar

    Boolean (yes or no)

    Automatically hide the top bar

    disabletopbar

    Boolean (yes or now)

    Disable top bar completely in the current window

    define

    String

    Specify a value of "#Named Token:Replacement Value". Any occurrence of the token represented by the define's name will be replaced with the appropriate value in any imported markup. Images are imported from the Media within the current skin directory. Labels (e.g. 5900 in the above example) are imported from the language folder in the MediaPortal application folder. This element may be repeated as many times as tokens are required.

    <controls> element

    The controls element is a container for all of the controls on a page.

    Element Name

    Data Type

    Description

    import

    String

    The name of a xml file to import within the same skin folder. Normally used to reference all the common markup into smaller and easier to manage files. You may have multiple import elements

    include

    String

    Same as import

    control

    Control

    A graphical control. There will be as many of these as there are controls on a window


    <control> element

    All the GUI controls are put between the <controls> and </controls> tag and each one is contained with a <control> tag. Some controls (e.g. group) may allow you to nest subcontrols within them so you may have <control> tags within a parent <control> tag.

    <window>
      ...
      <controls>
        ...
        <control>
          <id>1</id>
          <description>default button</description>
          <type>button</type>
          ...

     

    Every control is derived from a base control (GuiControl) and has at least the following attributes:

     

    Element Name

    Data Type

    Description

    id

    Integer

    The id of the control. The id will couple the skin file to the code, so if we later on want to check that a user pressed a button, the id will be required and must be unique. For controls that will never be referenced in the code it is safe to set it to "1"

    description

    String

    An optional description of the control for your reference

    type

    String

    The type of control you want. See the list below for valid types of control

    posX

    Integer

    The X-position on the window for this control (left edge = 0, measures positive to the right)

    posY

    Integer

    The Y-position on the window for this control (top edge = 0, measures positive down)

    width

    Integer

    The width of this control

    height

    Integer

    The height of this control

    onleft

    Integer

    The control id to move the focus to when the user moves left. If not specified (or zero) MediaPortal will find the closest control in that direction to move to

    onright

    Integer

    The control id to move the focus to when the user moves right. If not specified (or zero) MediaPortal will find the closest control in that direction to move to

    onup

    Integer

    The control id to move the focus to when the user moves up. If not specified (or zero) MediaPortal will find the closest control in that direction to move to

    ondown

    Integer

    The control id to move the focus to when the user moves down. If not specified (or zero) MediaPortal will find the closest control in that direction to move to

    colordiffuse

    Long

    Allows you to mix a color & a graphics texture. E.g. If you have a graphics texture like a blue button you can mix it with a yellow color diffuse and the end result will be green. Defaults to 0xFFFFFFFF

    dimColor

    Integer

    Color for a control when it is not focused. Defaults to half transparent (0x60ffffff)

    Control Types

    Depending on the value of the control type tag in the control element above there will be additional tags specific to that type of control. A list of all available controls and a description on how to use them can be found on the Skin Controls page.

    Example plugin with most controls implemented

    If you want to see how the different controls look/work within MediaPortal download and install the plugin GuiControlsDemo, which can be found in the MP Repository.

    guicontrolsdemo_overview.png

    Detailled Description of GuiControlsDemo

    Colors

    • Colors can be specified in the following ways:
    • Named colors from the W3C standard HTML palette e.g.

      • White
      • Gainsboro
      • White:#60 (White using an alpha hex channel value of 60)

      • White:96 (White using an alpha non-hex channel value of 60)

    • Hex values in the format #RRGGBB (e.g. #330099)
      • RR = red hex value
      • GG = green hex value
      • BB = blue hex value
    • Hex values in the format #AARRGGBB (e.g. #20FFFFFF)
      • AA = Alpha (transparency) channel hex value
      • RR = red hex value
      • GG = green hex value
      • BB = blue hex value

    Examples:

    <textcolor>White</textcolor>
    <textcolor>#20FFFFFF</textcolor>
    <textcolor>#330099</textcolor>
    <textcolor>Gainsboro</textcolor>
    <!-- specify a named color with non-default alpha (using hex, preferred) -->
    <textcolor>White:#60</textcolor>
    <!-- not using hex -->
    <textcolor>White:96</textcolor>

    Styles

    Styles are a 'set' of tags that can be used to format the presentation of a control in a skin xml. As is the case with the use of styles in any software, they help ensure consistency of formatting and reduce the duplication of control tags throughout the skin.

    Styles are defined in the references.xml file, usually right after the <skin> control at the top of the file. They are defined using the following format:

    • <style Name="stylename"> where stylename is any name you choose for the style

      </style>

      • <id>0</id> (optional)

      • .. whatever tags you wish to include (see examples)

    Once the style has been defined in references.xml, it can be used instead of <control> in an xml in the following format:

    • <control Style="stylename"> where stylename is the name of the style in references.xml

    Example (from streamedMP skin)

    • in references.xml:

    <style Name="smallTitle">
      <id>0</id>
      <width>220</width>
      <font>mediastream9c</font>
      <textcolor>ffffffff</textcolor>
    </style>
    • in movingpictures.views.xml:

    <control Style="smallTitle">
      <type>label</type>
      <label>#MovingPictures.SelectedMovie.genres</label>
      <posX>825</posX>
      <posY>485</posY>
      <width>580</width>
      <visible>facadeview.filmstrip+Control.IsVisible(50)</visible>
    </control>

    Example (from aMPed skin)

    • in references.xml:

    <style Name="Square Filmstrip">
      <posX>40</posX>
      <posY>225</posY>
      <width>720</width>
      <height>576</height>
      <itemWidth>135</itemWidth>
      <itemHeight>135</itemHeight>
      <textureWidth>123</textureWidth>
      <textureHeight>123</textureHeight>
      <thumbWidth>115</thumbWidth>
      <thumbHeight>116</thumbHeight>
      <thumbPosX>3</thumbPosX>
      <thumbPosY>3</thumbPosY>
      <frame>Picture_cover.png</frame>
      <frameFocus>Picture_cover.png</frameFocus>
      <keepaspectratio>no</keepaspectratio>
    </style>
    • in common.facade.music.xml:

    <control Style="Square Filmstrip">
      <description>Filmstrip view</description>
      <type>filmstrip</type>
      <id>50</id>
      <onup>2</onup>
      <animation effect="rotatey" start="60" end="0" center="600,0"
      tween="back" ease="easeout" time="500" reversible="false">
      focus</animation>
      <animation effect="rotatey" start="0" end="60" center="600,0"
      tween="back" ease="easeout" time="500" reversible="false">
      unfocus</animation>
    </control>

    Internationalization

    MediaPortal supports internationalization of skin files through the use of strings.xml which is used for all skins. You will find this file in the language folder of the application directory. There are sub-folders for each supported language. Instructions on creating a translation can be found in the Translator Guide.

    Tip: When designing skins, remember that the same words in other languages are often longer than in English so as a rule of thumb, add 30% to the width of dialogs.

    The following is the start of the English strings.xml file:

    <strings>
      <characters>512</characters>
      <string Prefix="My">
        <id>0</id>
        <value>Programs</value>
      </string>
      <string Prefix="My">
        <id>1</id>
        <value>Pictures</value>
      </string>
      <string Prefix="My">
        <id>2</id>
        <value>Music</value>
      </string>
      <string Prefix="My">
        <id>3</id>
        <value>Videos</value>
      </string>
      ...

    The following are the set of attributes that all string elements have:

    Attribute Name

    Data Type

    Description

    Prefix

    String

    The string prefix. If the user has enabled prefixes in the configuration application this string is prefixed before displaying (e.g. displaying "My Music vs. "Music")

    • The following are the set of tags that all string elements have:

    Element Name

    Data Type

    Description

    id

    Integer

    The unique id of the string used in the application and by skin files to reference this string

    value

    String

    The translated text to display to the user

     

    Conditional Visibility

    1. Conditional Visibility

    2. The visibility of all controls can be determined using the <visible> tag (yes/no). Also, many preset boolean conditions can be used to determine the conditions under which a control displays. Not only that, you can also specify how Mediaportal should transition between a visible state and a hidden state, using animations.

    Animations

    1. Animations

    How to Install a New Skin

    1. Download the .ZIP file.
    2. Unzip the files to a New directory under 'MediaPortal\Skin'
    3. Run the MediaPortal Configuration/Setup
    4. Select the new skin under 'General', 'Skin'
    5. Enjoy! 

    Optimize your skin

    unused png files

    To ensure that MediaPortal only has to load (add to packedgfx file) the png's which are required, you should ensure that no unused files are inside the Media folder.

    optimize png files

    To keep the gpu memory load as small as possible, you should ensure that your png files are only as large as required (resolution). This means that it does not contain empty spaces.

    This would only cause that more packedgfx files get created, and this will require more gpu memory.

    The resolution of your png files should always be a power of 2.

    fonts

    MediaPortal 1 handles fonts as textures.

    So the more fonts (different sizes) you use in your skin, the higher the gpu-memory load will be.

    In virtually every MediaPortal release, we must make changes which require that the updates to skins.

    If this happens, then all community skins must be updated with this change as well, in order to maintain its functionality.




    Go to top
    Powered by MindTouch
    Running the latest version?
    V1.2.3 - released April 2012
    Releasenews | Download
    Changelog
     | Requirements
    opensource-logoTeam-MediaPortal 
    About
    Contact |  Press
    Partners