GUI XML Documentation

From DevWiki

Jump to: navigation, search

Back to Home

Contents


Overview

The Boxee UI API enables developers to build their own content portal and media applications on top of the Boxee platform. For more information on the basics of every application please read Anatomy of a Boxee App.

Your application UI is built using xml & python. Each xml file is a different window however one can design multiple views in one window. The UI, or skin, xml files are located in the 720p folder. There are many controls (lists, buttons, images, editboxes...) you can incorporate in your UI which represent the visual design of the application. For many controls you can embed python scripts which preform operations for retrieval of media information and/or UI related actions.

Animations are available and can be defined for each control on specific events. Conditional visiblility can be set to each control in your skin making many UI actions a breeze. Prompting the user for imput is also possible using the python api and much more. This document will define each control and animation available to you as well as go over different uses and how to handle events.

Note: For the remainder of this section of documentation, if your confused about the reference to any of the following please refer to the Anatomy of a Boxee App unless stated otherwise. Also note that any mention of python is always optional.

  • window(s)
  • skin folder
  • 720p folder
  • media folder
  • descriptor
  • python includes


Windows

Each window (screen) in your application is managed by its own xml file under the skin/Boxee Skin NG/720p folder. Each window must have its own unique ID number ranging from 14000-14099. Using IDs out of this range will stop python code from executing properly along with other unforeseen issues. In addition, the window IDs are used to launch specific windows in your skin.

Window Element
type Required. Always 'window' when you are defining the window itself.
id Required. The ID number assigned to this specific window. Range from 14000-14099.


Elements that reside within the window tag
defaultcontrol Defines the control ID which should be focused whenever the window is loaded.
allowoverlay ...
onload Event tag to perform action when the window it loaded.
onunload Event tag to perform action when the window is unloaded.


Example for the default window structure. ID's here can and should be changed to work appropriately with your UI.
<?xml version="1.0"?>
<window type="window" id="14000">
   <defaultcontrol always="true">120</defaultcontrol>
   <allowoverlay>no</allowoverlay>
   <onload>Control.SetVisible(122)</onload>
   <controls>
     ...
   </controls>
</window>


Controls

Controls define everything from buttons, labels, images, lists and more. Each control section will explain the selected control in detail. There are many different types of controls, all which represent UI elements displayed on-screen and most can be interacted with by the user. Each control, as the window it self, has a basic structure with default properties and specific properties which represent its behavior and look.

Also important to read the following:


Control Events

The window and each control has event tags (like onclick, onfocus, onload etc.) which are triggered upon specific events. Each event supports the attribute lang="python" after which, python code may be inlined and wrapped with CDATA tags. It's important to note that Boxee currently supports Python 2.4. Below is a list of available event tags for focusable controls.

  • onload (windows)
  • onunload (windows)
  • onfocus (controls)
  • onclick (controls)
  • onright (controls)
  • onleft (controls)
  • onup (controls)
  • ondown (controls)


Example of onclick event with Button Control
<control type="button" id="1000">
   <width>88</width>
   <height>39</height>
   <label>VIDEO</label>
   <align>center</align>
   <textcolor>ffffffff</textcolor>
   <texturefocus>menuitem_on.png</texturefocus>
   <texturenofocus>-</texturenofocus>
   <visible>true</visible>
   <onclick lang="python">
<![CDATA[
mc.ShowDialogNotification('You pressed a button!')
]]>
   </onclick>
</control>

Conditional Visibility

The power of the skinning engine is based on the ability to show and hide controls using conditional statements (boolean conditions). Conditions can me compared and combined with no limit. The logic is simple yes/no logic. Take a look at the following examples.

show list if button 100 has focus -> Control.HasFocus(100)
show list if button 100 is hidden and button 200 has focus -> !Control.IsVisible(100) + Control.HasFocus(200)


Default Control Properties

Default properties and events (tags and attributes) are available for all skin controls: Note that all tag names are lower case. XML tag names are case sensitive! Credit goes to the xbmc documentation

description Only used to make things clear for the skinner. Not read by Boxee at all.
type The type of control.
id Specifies the control's id. The value this takes depends on the control type, and the window that you are using the control on. There are special control id's that must be present in each window. Any other controls that the skinner adds can be any id they like. Any controls that the skinner specifies content needs not have an id unless it's needed for animation purposes. For instance, most image and label controls don't need an id if the skinner specifies they're content.
posx Specifies where the left edge of the control should be drawn, relative to it's parent's left edge. If an "r" is included (eg 180r) then the measurement is taken from the parent's right edge (in the left direction).
posy Specifies where the top edge of the control should be drawn, relative to it's parent's top edge. If an "r" is included (eg 180r) then the measurement is taken from the parent's bottom edge (in the up direction).
width Specifies the width that should be used to draw the control.
height Specifies the height that should be used to draw the control.
visible Specifies a condition as to when this control will be visible. Can be true, false, or a condition. See here for more information. Defaults to true.
animation Specifies the animation to be run when the control enters a particular state. See here for more information
camera Specifies the location (relative to the parent's coordinates) of the camera. Useful for the 3D animations such as rotatey. Format is <camera x="20" y="30" />
colordiffuse This specifies the color to be used for the texture basis. It's in hex AARRGGBB format. If you define <colordiffuse>FFFF00FF</colordiffuse> (magenta), the image will be given a magenta tint when rendered. Defaults to FFFFFFFF (no tint). You can also specify this as a name from the colour theme.


For fusable events, the following are also available:

onup Specifies the <id> of the control that should be moved to when the user moves up off this control. Can point to a control group (which remembers previous focused items).
ondown Specifies the <id> of the control that should be moved to when the user moves down off this control. Can point to a control group (which remembers previous focused items).
onleft Specifies the <id> of the control that should be moved to when the user moves left off this control. Can point to a control group (which remembers previous focused items).
onright Specifies the <id> of the control that should be moved to when the user moves right off this control. Can point to a control group (which remembers previous focused items).
hitrect Specifies the location and size of the "focus area" of this control (relative to the parent's coordinates) used by the mouse cursor. Format is <hitrect x="20" y="30" w="50" h="10" />
enable Specifies a condition as to when this control will be enabled. Can be true, false, or a condition. See here for more information. Defaults to true.
pulseonselect This specifies whether or not a button type will "pulse" when it has focus. This is done by varying the alpha channel of the button. Defaults to true.


Animations

The skinning engine supports animations of any control allowing them to rotate, slide, fade or any combination there-of. Combining animations with conditional statements ensure your skin will have stunning effects that appear as professional as a 1st party product. For further information, see the UI Animations section.


Textures

For all <texture> properties in controls (like <textureonfocus>) it is suggested to use PNG and JPG as much as possible. For transparency use PNG. For animated textures, only animated GIF is supported. There are also SOME animated gifs that may not work. Use ImageReady CS and make sure you set the gif-anim to "restore to background" and they should work fine. The following attributes can be used within the texture tag to alter how the texture is rendered:

border Used to specify a region of the texture to be considered a border that should not be scaled when the texture is scaled to fit a control's dimensions. The portion in the border region will remain unscaled. Particularly useful to achieve rounded corners that do not change size when a control is resized. Note that zoom animations and GUI rescaling will still affect the border region - it is just the scaling of the texture to the control size which is unaffected. Using border="5" will give a 5 pixel border all around the texture. You can specify each of the border amounts on each edge individually using border="left,right,top,bottom".
flipx Specifies that the texture should be flipped in the horizontal direction. Useful for reflections.
flipy Specifies that the texture should be flipped in the vertical direction. Useful for reflections.
align Specifies that the texture should be aligned in the horizontal direction. Valid values are "left" "right "center".
aligny Specifies that the texture should be aligned in the Vertical direction. Valid values are "top" "bottom" "center".
diffuse Specifies a diffuse texture which is "modulated" or multiplied with the texture in order to give specific effects, such as making the image gain transparency, or tint it in various ways. As it's applied per-pixel, many effects are possible, the most popular being by a transparent reflection which slowly gets more and more opaque. This is achieved using a WHITE image where the transparency increases as you move down the texture.


Example:

<texture border="3" align="right" aligny="top" flipy="true" diffuse="diffuse_mirror.png">keyboard_key.png</texture>


Label Formatting

In the Boxee framework, there are predefined font and color values. Labels can also be formatted using special tags in the text label property it self. The tags allow the use of different languages through a localization support, it enables the label to display application variables and system variables and it allow visual formatting of the label to bold, italics, full caps, lower case and colored, or all of them together.

Fonts

Since the early days of Boxee, there has only been one font. While this worked for a while we realized the need for some more styles. Now we support the Boxee default font, Sans and Serif. See Boxee Fonts


Color Values

In the Boxee framework, there are predefined font and color values. Colors can be manually defined using the scheme AARRGGBB where AA is alpha blending value, RR is red, GG is green and BB is blue. All color values are in HEX values between 0-255. Any color tag in your skin can accept the word values below (<textcolor>red</textcolor). Default colors are listed below but are subject to change between Boxee releases. Its best to use your own color codes to guarantee the colors in your application don't change if we change these default values:

  • black (F3000000)
  • grey (80FFFFFF)
  • lightgrey (40FFFFFF)
  • white (F3FFFFFF)
  • green (F38EC641)
  • yellow (F3ECDB12)
  • blue (F39CD4F5)
  • red (F3F05322)
  • disabled (30FFFFFF)
  • title (F3F6BB1C)
  • listitem (E6FFFFFF)
  • wizard (DD4D4D4D)
  • darkgrey (DD171717)
  • medgrey (DD999999)

Note that we changed these values with beta. The old color codes are no longer avilable and only the above will work.


Formatting

  • $INFO[ListItem.Title,prefix,postfix]: used for application and system variables title=InfoLabels>.
  • $LOCALIZE[12345]: used for specifying a localized string from the language strings.xml.
  • [B]bold[/B]: format the block of the text to bold.
  • [I]italics[/I]: format the block of the text to italic.
  • [COLOR red]red text[/COLOR]: format the block of the text to the specific color.
  • [UPPERCASE]force text uppercase[/UPPERCASE]: force block of text to uppercase
  • [LOWERCASE]Force Text Lowercase[/LOWERCASE]: force block of text to lowercase
  • [CR]: carriage return (line break).


Parsing

  • Replaces any $LOCALIZE[number] blocks with the real string from strings.xml (number is the number of the string in the strings.xml file).
  • Translates the [infolabel,prefix,postfix] blocks from left to right.
  • If an empty string is returned from the infolabel, then nothing is rendered for that block.
  • If a non-empty string is returned from the infolabel, then prefix string is applied, then the returned infolabel information, then the postfix string is applied. Note that any $COMMA fields are replaced by real commas, and $$ is replaced by $.
  • Any pieces of information outside of the $INFO[] blocks are rendered unchanged.


Example:

<label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label>
If nothing is playing then the label will print:
A good example of a

If a song is playing but it has no Title (ie MusicPlayer.Title returns an empty string) but does have an artist, it will return:
A good example of a song artist: <Artist>

If a song is playing that has title and artist information, it will return:
A good example of a song title: <Title>, and a song artist: <Artist>


Example:

<label>This is a long label that features different [COLOR red]colors[/COLOR] and
[I]styles[/I] and [B]looks[/B].[CR][LOWERCASE]$LOCALIZE[12345][/LOWERCASE] can be used to force a
localize string to lowercase.[CR][UPPERCASE]$LOCALIZE[12345] else[/UPPERCASE] can be used to force
a localize string to uppercase.</label>
This is a long label that features different colors, styles and looks.
something can be used to force a localize string to lowercase.
SOMETHING ELSE can be used to force a localize string to uppercase.
Personal tools