»
S
I
D
E
B
A
R
«
Hello World – In Video!
3 February 2010 by Rob Spectre

Mark Tucker over at shazaml.com has put together a great six minute screencast showing how to develop a quick “Hello World” app on Boxee.  Mark’s video is very detailed and pro-quality, showing how to create a test app on Windows.  Great work here.

Building Your First Boxee App – Now Updated For Beta!
27 January 2010 by Rob Spectre

The popular step-by-step gonzo guide to building your first Boxee app has now been edited to reflect the API changes in the Boxee beta.  Several typographical errors and content applicable only to the Boxee Alpha client has been changed and the guide now produces a working app for the new Boxee Beta.

Enjoy!

Boxee Launches New Developer Wiki
15 January 2010 by Rob Spectre

Coming off their *huge* week at the International Consumer Electronics Show in Las Vegas, the folks at Boxee have released a revamped information resource for Boxee developers.  Most of the content was written by Boxee’s own Shawn Rieger who has been serving capably as the developer’s man on the inside and features a host of previously underdocumented features such as:

Shawn has put a lot of work into this documentation and it really shows – huge ups to the Boxee crew for continuing their commitment to the open source development community that has sprung up around this project!

Using The Sidebar In Your Apps
12 January 2010 by Joshua Jonah

Hi my name is Joshua, I am a boxee and all around Python developer who will now be contributing to gonzee.tv. I have a background in web application and social networking development, but I’m also a huge HTPC nut. Boxee is the perfect middle ground. I hope my articles help you out in times of need.

Without further ado…

The sidebar is used in the factory boxee sections. It’s on the side and lets you sort, filter, and otherwise manipulate the list in the factory boxee sections.

Boxee Movies section with sidebar visible</code>

The sidebar would be a great place to put things like preferences, sorting, and less used items within an app. The information is out of the way, but still in a comfortable place that is consistent throughout the boxee interface.

I’ve been wanting to use this in my own apps to really pull the experience together, so I started tearing apart the boxee skins. There are many “classes” and other things in the boxee skin files that you can use in your own apps to save code and increase consistency. I would recommend any developer to take a look.

I’ve recovered the base code required to have the sidebar working on your app:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<control type="group" id="9000">
    <include>BrowseListsAnimation</include> # This is required for some reason.
 
    # Put your main app xml here.
    #
    # For example a list:
    <control type="list" id="600">
        <description>Media items</description>
        <posx>40</posx>
        <posy>160</posy>
        <width>600</width>
        <height>520</height>
        <onleft>8000</onleft> # Notice pushing left activates the sidebar from this list.
        <onright>-</onright>
        <onup>200</onup>
        <ondown>-</ondown>
        <scrolltime>200</scrolltime>
        <pagecontrol>-</pagecontrol>
        <orientation>vertical</orientation>
        <itemlayout width="600" height="60">
            <control type="label">
                <posx>0</posx>
                <posy>0</posy>
                <width>560</width>
                <height>40</height>
                <font>font28</font>
                <align>left</align>
                <label>$INFO[ListItem.Label]</label>
                <textcolor>grey</textcolor>
            </control>
        </itemlayout>
        <focusedlayout width="1280" height="60">
            <control type="label">
                <posx>0</posx>
                <posy>0</posy>
                <width>560</width>
                <height>40</height>
                <font>font28</font>
                <align>left</align>
                <scroll>true</scroll>
                <scrollspeed>30</scrollspeed>
                <label>$INFO[ListItem.Label]</label>
                <textcolor>white</textcolor>
            </control>
        </focusedlayout>
    </control>
</control>
 
<control type="group" id="8000"> # This is the sidebar
    <include>BrowseLeftMenuAnimation</include>   # Required for some reason.
    <include>BrowseLeftMenuBackground</include>  # This includes everything to draw the
                                                 # background of the sidebar
    <control type="grouplist">                   # A grouplist is a good idea so that if
        <include>BrowseLeftMenu</include>        # there's too many controls, it can scroll.
        <control type="label" id="402">
            <include>BrowseLeftMenuTitle</include>      # <- there are some 'classes' I found
            <label>[UPPERCASE]Available Feeds[/UPPERCASE]</label>
        </control>
 
        # Include whatever you want on the sidebar here.
        # Make sure to add "<onright>9000</onright>" to the elements so you can get back to
        # your app.
 
    </control>
</control>

Make sure to remove all of the comments before trying this code, the boxee XML parser doesn’t like python comments (#).

This will get you an empty window with a sidebar on the left.

Enjoy.

The Complete Guide To Building Your First Boxee App
14 November 2009 by Rob Spectre

Here’s a quick table of contents for the gonzee.tv complete guide to building your first Boxee app.

  1. Designing Your Skin
  2. Breaking Down The Controls
  3. Creating the Skeleton
  4. Hello World
  5. Finishing the Graphics
  6. The List Container
  7. The Metadata Box
  8. Animation
  9. Release It!
Building Your First App – Release It!
13 November 2009 by Rob Spectre
This entry is part 9 of 9 in the series Building Your First App

At long last, we are at the final step of building your first Boxee application – release!  After designing, coding and debugging our app we’re ready to release it in the wild by submitting it to Boxee for inclusion in the App Box.

The App Box is similar to the iTunes App Store developers are familiar with for the iPhone.  It is the default repository for all Boxee software, all fully tested and confirmed to work on the platforms for which it is submitted.  The submission process, however, is far less intrusive than Apple’s and ultimately produces the highest quality experience for the Boxee community of 700,000 users.   Plus the submission process gets your app tested on hardware profiles you likely don’t have access to – a huge plus to guarantee your app looks good on all the devices running Boxee.

Let’s get started submitting the app we just built.

1) Make an App Thumbnail

The app thumbnail is what users see in the App Box as the icon to install your app.  Naturally, our app thumbnail should concisely represent what kind of content the app contains and should attract users to install it. The thumbnail should be 200×200 and placed in the Internet accessible location we defined in the <em>thumb</em> element of our <em>descriptor.xml</em>.

The standard background for a Boxee App thumbnail

If you would like to conform to the look of the rest of the App Box (always a good idea), you can use this black image as a background.

1) Zip up the app

All Boxee repositories distribute apps through zip files.  In order to speed up the review of your app, you can zip up your app so that it is ready to go for the quality assurance folks who will be putting your app through the paces. First we navigate to the <em>apps</em> directory in your local Boxee UserData folder and identify the folder containing our app – it should be the same as the <em>userid</em> we defined in our <em>descriptor.xml</em>.

Then zip the file with the convention <em>appid-version.zip</em>.  For example, if we were submitting Auto-Tune The News for the App Box, we would name our zip file <em>autotunethenews-1.0.zip</em>.

Note: Be sure to remove the <test-app> element from your descriptor.xml before submitting!

2) Sign up for Boxee JIRA

Before sending your zip file to Boxee for consideration, you need to sign up for an account in Boxee’s bug management software.  This will allow Boxee to get a hold of you in the event of any problems as well as use JIRA to submit your app.  You can sign up at http://jira.boxee.tv.

3) Follow the Application Submission Process

Once you’ve signed up on JIRA, you’re ready to start Boxee’s Application Submission Process.  Just hop on the developer wiki page linked here and you’re on your way!

When submitting your app to the Boxee App Box, expect that it will take 3-4 business days for your app to get checked by Boxee QA.  With over a dozen apps in the App Box, it is a process with which I have gained intimate familiarity and can offer a few tips to make your submission sail.

  • Debug Your App - Make sure you click on every button and every video in your app at least once.  Boxee QA will definitely be doing the same and you can save yourself (and them) a cycle of iteration by doing it yourself.
  • 1280×720 – Be sure you are always developing in a windowed Boxee client.  This will make Boxee default to 720p, which will ensure your app looks the best on all screens.  You can window your Boxee client by pressing the “\” key after you start.
  • 480i - Make sure your video is at least 480i quality.  If it’s not good enough for TV, it’s not good enough for Boxee.

Finally, there is one last step:

4) Tell people!

Be sure to post on the forums, your own blog and, if you would do me the courtesy, here on gonzee.tv to let the world know that you just published your first Boxee app!  Cable packages only get a few new channels a year – Boxee gets dozens of new apps a month.

Get on Twitter, Facebook, Cliqset, and every corner of the Internet to let them know you’re tired of television and ready to change the living room with your first Boxee app.

Building Your First App: Animation
12 November 2009 by Rob Spectre
This entry is part 8 of 9 in the series Building Your First App

We’re almost there with the penultimate step in building your first Boxee application. In the last installment, we finished the construction of the application by finishing the metadata box. In this step, we’ll do our last round of polish before we’re ready for the best step of all – release!

Animation is the crucial last polish that can really make your application shine and is super easy to add. For our app, we are going to add a nice theater-light style fade in for the active elements of our interface while the application loads. This can be accomplished by applying an animation element to our list container and metadata box. Let’s take a look at what that element looks like:

1
2
3
<animation type="Conditional" condition="Window.IsVisible(DialogProgress.xml)">
   <effect type="fade" start="100" end="20" time="200"/>
</animation>

In this element we are doing two things – setting a condition and setting an effect. The condition is set with the animation element telling Boxee to render the animation when certain criteria are met. In this case, we are defining the condition as the visibility of Boxee’s default “loading clock” animation.

We then define what kind of animation with the effect element. Here we put the attributes of how we would like this animation to behave.

type
There are many animation effects available within Boxee; the type attribute defines which one we want. As mentioned before, we are using a “fade” animation for our first app.

start / end
The start and end attributes have deceiving names for their function in a fade animation. For this effect, start and end are the values we are setting for opacity at the beginning and end of the animation. So if we input the values “100″ and “20,” we are telling Boxee to render a fade effect that changes the interface object’s opacity from 100% (fully solid) to 20% (nearly transparent).

time
The time attribute defines the interval of the animation in milliseconds. With “200″ as our value, we are telling Boxee to fade the interface object from 100% to 20% in 0.2 seconds.

With our animation element defined, we need to just add it to the controls we wish to fade. Adding an animation is as simple as including the animation element to the control we wish to animate. First we’ll start with the image control that provides the background of the list container.

1
2
3
4
5
6
7
8
9
10
<control type="image">
	<animation type="Conditional" condition="Window.IsVisible(DialogProgress.xml)">
	   <effect type="fade" start="100" end="20" time="200"/>
	</animation>
	<posx>60</posx>
	<posy>230</posy>
	<width>502</width>
	<height>416</height>
	<texture>list.png</texture>
</control>

Now when we start our application, we can see that while Boxee loads our RSS feed, the list container background does a neat theater fade. To give the entire app that same polished look we will need to add the effect also to the metadata box’s image control, the list container, and the group control containing our metadata objects.

Here’s our final main.xml now fully animated:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?xml version="1.0"?>
   <window type="window" id="14000">
   <defaultcontrol always="true">100</defaultcontrol>
   <allowoverlay>no</allowoverlay>
   <controls>
      <control type="group">
          <control type="image">
             <posx>0</posx>
             <posy>0</posy>
             <width>1280</width>
             <height>720</height>
             <texture>bg.png</texture>
          </control>
          <control type="image">
             <animation type="Conditional" condition="Window.IsVisible(DialogProgress.xml)">
	         <effect type="fade" start="100" end="20" time="200"/>
	     </animation>
             <posx>60</posx>
             <posy>230</posy>
             <width>502</width>
             <height>416</height>
             <texture>list.png</texture>
         </control>
         <control type="image">
             <animation type="Conditional" condition="Window.IsVisible(DialogProgress.xml)">
	         <effect type="fade" start="100" end="20" time="200"/>
	     </animation>
             <posx>630</posx>
             <posy>255</posy>
             <width>574</width>
             <height>355</height>
             <texture>details.png</texture>
          </control>
          <control type="list" id="100">
           <animation type="Conditional" condition="Window.IsVisible(DialogProgress.xml)">
	       <effect type="fade" start="100" end="20" time="200"/>
	   </animation>
	   <posx>60</posx>
	   <posy>230</posy>
	   <width>502</width>
	   <height>416</height>
	   <orientation>vertical</orientation>
	   <itemlayout width="502" height="65">
	    <control type="label">
		<posx>0</posx>
		<posy>0</posy>
		<width>502</width>
		<height>62</height>
		<font>font40</font>
		<align>left</align>
		<aligny>center</aligny>
		<label>$INFO[ListItem.Label]</label>
		<textcolor>white</textcolor>
	    </control>
	    </itemlayout>
	    <focusedlayout width="502" height="65">
	       <control type="image">
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>65</height>
		   <texture>white.png</texture>
		   <colordiffuse>DD171717</colordiffuse>
	       </control>
	       <control type="label">
		   <visible>!Control.HasFocus(100)</visible>
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>62</height>
		   <font>font40</font>
		   <align>left</align>
		   <aligny>center</aligny>
		   <label>$INFO[ListItem.Label]</label>
		   <textcolor>white</textcolor>
		   <selectedcolor>DD171717</selectedcolor>
	       </control>
	       <control type="label">
		   <visible>!Control.HasFocus(100)</visible>   
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>62</height>
		   <font>font40</font>
		   <align>left</align>
		   <aligny>center</aligny>
		   <label>$INFO[ListItem.Label]</label>
		   <textcolor>white</textcolor>
		   <selectedcolor>DD171717</selectedcolor>
		   <scroll>true</scroll>
		   <scrollspeed>30</scrollspeed>
	       </control>
	    </focusedlayout>
	    <content type="url" url="rss://yourdomain.com/yourfeed.rss">
	    </content>
	</control>
        <control type="group">
           <animation type="Conditional" condition="Window.IsVisible(DialogProgress.xml)">
	      <effect type="fade" start="100" end="20" time="200"/>
           </animation>
           <control type="image">
              <visible>true</visible>
              <posx>635</posx>
              <posy>265</posy>
              <width>560</width>
              <height>230</height>
              <texture>$INFO[Container(100).ListItem.Thumb]</texture>
           </control>
           <control type="label">
              <visible>true</visible>
              <posx>635</posx>
              <posy>500</posy>
              <width>560</width>
              <height>115</height>
              <font>light23</font>
              <align>left</align>
              <aligny>center</aligny>
              <label>[B]Description:[/B] $INFO[Container(100).ListItem.property(description)]</label>
              <background>grey</background>
              <textcolor>white</textcolor>
              <wrapmultiline>true</wrapmultiline>
           </control>
         </control>
      </control>
   </controls>
</window>

For more information on animating your Boxee app, refer to this excellent guide for Xbox Media Center.

Only one step left – release!

Building Your First App: The Metadata Box
9 November 2009 by Rob Spectre
This entry is part 7 of 9 in the series Building Your First App

In our last installment we turned a significant corner with the construction of our list container. Now we can finish up the interface creation on our first app by creating the metadata box. The metadata box is the interface object next to the list container that displays to the user more information about the item they have selected in the list container. Examples of metadata boxes can be seen in the screenshots for AL TV and Associated Press. Typically they include a thumbnail of the video selected and some helpful information like a description.

To get started, we’re going to abstract this interface from the rest of the application by creating a new group control.

1
2
<control type="group">
</control>

By putting the metadata box in a separate group, it makes future maintenance much easier by keeps parts of the interface logically separate as we continue to develop the app. Inside that group control, we place our first interface element – the video thumbnail.

1
2
3
4
5
6
7
8
9
10
<control type="group">
  <control type="image">
    <visible>true</visible>
    <posx>635</posx>
    <posy>265</posy>
    <width>560</width>
    <height>230</height>
    <texture>$INFO[Container(100).ListItem.Thumb]</texture>
  </control>
</control>

You’ll notice that the thumbnail image control looks much like the many other image controls we’ve created so far with one significant difference in the element. Instead of a static file name, we have a dynamic INFO tag that leverages the Boxee API. We can break down the INFO tag into two parts.

Container(100)
This part of the tag tells the image to get its texture from the list container with id “111″.

ListItem.Thumb
This part of the tag tells the image to look for the thumbnail for the ListItem currently selected in the list container referenced in the first part of the tag.

This small example highlights one advantage of developing on Boxee – all controls can reference each other within the context of an app. We will do this again to add some description data underneath the thumbnail we just created using a label control.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<control type="group">
  <control type="image">
    <visible>true</visible>
    <posx>635</posx>
    <posy>265</posy>
    <width>560</width>
    <height>230</height>
    <texture>$INFO[Container(100).ListItem.Thumb]</texture>
  </control>
  <control type="label">
    <visible>true</visible>
    <posx>635</posx>
    <posy>500</posy>
    <width>560</width>
    <height>115</height>
    <font>light23</font>
    <align>left</align>
    <aligny>center</aligny>
    <label>[B]Description:[/B] $INFO[Container(100).ListItem.property(description)]</label>
    <background>grey</background>
    <textcolor>white</textcolor>
    <wrapmultiline>true</wrapmultiline>
  </control>
</control>

The label control is similar to an image control with positional and dimensional elements, a content element (with label instead of texture), and some additional formatting element (e.g. align, font, textcolor). The important bit we need to pay attention to is the label element’s INFO tag.

Like our thumbnail, it references the list container we built in the last step but instead of getting the ListItem’s thumbnail, it gets the ListItem description. Why does it use “property” instead of just appending the name of the ListItem element? A longstanding bug in the Boxee API requires the developer to use “property(description)” instead of “Description” to ensure more consistent performance.

For more information on all the things you can do with label controls, refer to the Boxee developer docs.

And just like that, our metadata box is created. All that’s left is to drop it into our existing main.xml and adjust the position and dimensions to fit our content correctly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?xml version="1.0"?>
   <window type="window" id="14000">
   <defaultcontrol always="true">100</defaultcontrol>
   <allowoverlay>no</allowoverlay>
   <controls>
      <control type="group">
          <control type="image">
             <posx>0</posx>
             <posy>0</posy>
             <width>1280</width>
             <height>720</height>
             <texture>bg.png</texture>
          </control>
          <control type="image">
             <posx>60</posx>
             <posy>230</posy>
             <width>502</width>
             <height>416</height>
             <texture>list.png</texture>
         </control>
         <control type="image">
             <posx>630</posx>
             <posy>255</posy>
             <width>574</width>
             <height>355</height>
             <texture>details.png</texture>
          </control>
          <control type="list" id="100">
	   <posx>60</posx>
	   <posy>230</posy>
	   <width>502</width>
	   <height>416</height>
	   <orientation>vertical</orientation>
	   <itemlayout width="502" height="65">
	    <control type="label">
		<posx>0</posx>
		<posy>0</posy>
		<width>502</width>
		<height>62</height>
		<font>font40</font>
		<align>left</align>
		<aligny>center</aligny>
		<label>$INFO[ListItem.Label]</label>
		<textcolor>white</textcolor>
	    </control>
	    </itemlayout>
	    <focusedlayout width="502" height="65">
	       <control type="image">
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>65</height>
		   <texture>white.png</texture>
		   <colordiffuse>DD171717</colordiffuse>
	       </control>
	       <control type="label">
		   <visible>!Control.HasFocus(100)</visible>
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>62</height>
		   <font>font40</font>
		   <align>left</align>
		   <aligny>center</aligny>
		   <label>$INFO[ListItem.Label]</label>
		   <textcolor>white</textcolor>
		   <selectedcolor>DD171717</selectedcolor>
	       </control>
	       <control type="label">
		   <visible>!Control.HasFocus(100)</visible>   
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>62</height>
		   <font>font40</font>
		   <align>left</align>
		   <aligny>center</aligny>
		   <label>$INFO[ListItem.Label]</label>
		   <textcolor>white</textcolor>
		   <selectedcolor>DD171717</selectedcolor>
		   <scroll>true</scroll>
		   <scrollspeed>30</scrollspeed>
	       </control>
	    </focusedlayout>
	    <content type="url" url="rss://yourdomain.com/yourfeed.rss">
	    </content>
	</control>
        <control type="group">
           <control type="image">
              <visible>true</visible>
              <posx>635</posx>
              <posy>265</posy>
              <width>560</width>
              <height>230</height>
              <texture>$INFO[Container(100).ListItem.Thumb]</texture>
           </control>
           <control type="label">
              <visible>true</visible>
              <posx>635</posx>
              <posy>500</posy>
              <width>560</width>
              <height>115</height>
              <font>light23</font>
              <align>left</align>
              <aligny>center</aligny>
              <label>[B]Description:[/B] $INFO[Container(100).ListItem.property(description)]</label>
              <background>grey</background>
              <textcolor>white</textcolor>
              <wrapmultiline>true</wrapmultiline>
           </control>
         </control>
      </control>
   </controls>
</window>

And thus concludes the basic construction of our first app – we only have two more steps to go!

Building Your First App: The List Container
7 November 2009 by Rob Spectre
This entry is part 6 of 9 in the series Building Your First App

Last time, we finished up the last of the graphics work for our first application. The next step is building the list container. The list container is the primary interface of the application – the control that users browse through to view the content you’re delivering. The good news is they are not very hard to make and they are probably the most complex piece of your whole app.

This one is a little long-winded, I’ll warn you. But not at all as daunting as it might initially seem.

First we start much the same way that we did when building an image control – by setting its position and dimensions:

1
2
3
4
5
6
<control type="list" id="100">
   <posx>65</posx>
   <posy>235</posy>
   <width>492</width>
   <height>406</height>
</control>

Notice that we set the positioning five pixels to the right of the list.png image control and five pixels down. This will make the list seem indented with list.png as its background. Similarly, we reduced the dimensions both height and width by ten pixels, thus giving us a five pixel margin around our list container. We also assign it the id “100″ – the same value as our the defaultcontrol element we defined earlier.

Next, we define our orientation.

1
2
3
4
5
6
7
<control type="list" id="100">
   <posx>60</posx>
   <posy>230</posy>
   <width>502</width>
   <height>416</height>
   <orientation>vertical</orientation>
</control>

This element can have two values – horizontal or vertical. For this particular app, we want a vertical orientation (much like Auto-Tune The News). A horizontal orientation is generally used in panel containers, like those seen in Digg or Revision3.

Third, we need to define our item layout. This is the only part that gets a little tricky. Every item in your RSS feed gets parsed by Boxee and becomes a “ListItem.” The list container we are building will be populated by these ListItems and their appearance must be defined within this control. Consider the following XML:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<control type="list" id="100">
   <posx>60</posx>
   <posy>230</posy>
   <width>502</width>
   <height>416</height>
   <orientation>vertical</orientation>
   <itemlayout width="502" height="65">
    <control type="label">
        <posx>0</posx>
        <posy>0</posy>
        <width>502</width>
        <height>62</height>
        <font>font40</font>
        <align>left</align>
        <aligny>center</aligny>
        <label>$INFO[ListItem.Label]</label>
        <textcolor>white</textcolor>
    </control>
    </itemlayout>
</control>

The item layout element – like the list control – is a container for all the subelements within it. In this case, we only have one, the ListItem’s Label (read: title). In it you will notice the same position and dimension elements (e.g. posx, width, etc). You will also notice the width and height attributes for the element.

What the item layout attributes do is define the total size of the individual item. In this case, we want to make it as wide as the list container and big enough to have some space between the text. We can then define the dimensions of our label control as slightly shorter, giving us a 3 pixel gap between the labels.

The next step after we define our item layout, is to define our focused item layout. If the item layout defines what all ListItems look like in our app, focused item layout defines how the one focused item in the list should look. This is how we distinguish to the user which piece of content they have selected.

This can be done many ways and fortunately Boxee has some built in features you can use without adding any more graphics assets. Take a look at this addition to our list container:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<control type="list" id="100">
   <posx>60</posx>
   <posy>230</posy>
   <width>502</width>
   <height>416</height>
   <orientation>vertical</orientation>
   <itemlayout width="502" height="65">
    <control type="label">
        <posx>0</posx>
        <posy>0</posy>
        <width>502</width>
        <height>62</height>
        <font>font40</font>
        <align>left</align>
        <aligny>center</aligny>
        <label>$INFO[ListItem.Label]</label>
        <textcolor>white</textcolor>
    </control>
    </itemlayout>
    <focusedlayout width="502" height="65">
      <control type="image">
           <posx>0</posx>
           <posy>0</posy>
           <width>502</width>
           <height>65</height>
           <texture>white.png</texture>
           <colordiffuse>DD171717</colordiffuse>
       </control>
       <control type="label">
           <visible>!Control.HasFocus(100)</visible>
           <posx>0</posx>
           <posy>0</posy>
           <width>502</width>
           <height>62</height>
           <font>font40</font>
           <align>left</align>
           <aligny>center</aligny>
           <label>$INFO[ListItem.Label]</label>
           <textcolor>white</textcolor>
           <selectedcolor>DD171717</selectedcolor>
       </control>
       <control type="label">
           <visible>Control.HasFocus(100)</visible>
           <posx>0</posx>
           <posy>0</posy>
           <width>502</width>
           <height>62</height>
           <font>font40</font>
           <align>left</align>
           <aligny>center</aligny>
           <label>$INFO[ListItem.Label]</label>
           <textcolor>white</textcolor>
           <selectedcolor>DD171717</selectedcolor>
           <scroll>true</scroll>
           <scrollspeed>30</scrollspeed>
       </control>
    </focusedlayout>
</control>

You’ll notice looks exactly like , only with a few additions. The first addition you will notice is the image control. What this does is give the selected item in the list a tinted background. To accomplish the tint look, we use a default image texture white.png and a colordiffuse element. The colordiffuse element will tint that white with the color you specify, making it in this case just a little more gray. The second difference you’ll notice is that there are two label controls instead of one.

We need two labels in the focused layout to handle two use cases – when the application has focus and when it does not. When Boxee is in focus and the user is actively browsing the list container, he/she sees the label control on the bottom. That label control is set to scroll the text of the label (if it is longer than the width allowed), letting the user preview the content’s full label before selecting it. But, what if that user clicks away into another application or a menu? Obviously we wouldn’t want to continue scrolling, which is what the label control above it does. It stops the scrolling and waits for the user to return his/her focus to the app before scrolling again.

Phew! This is getting long, but we’re almost there.

The final element in your list container is the plumbing to hook your RSS feed up to the application. It can be added easily, like below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<control type="list" id="100">
   <posx>60</posx>
   <posy>230</posy>
   <width>502</width>
   <height>416</height>
   <orientation>vertical</orientation>
   <itemlayout width="502" height="65">
    <control type="label">
        <posx>0</posx>
        <posy>0</posy>
        <width>502</width>
        <height>62</height>
        <font>font40</font>
        <align>left</align>
        <aligny>center</aligny>
        <label>$INFO[ListItem.Label]</label>
        <textcolor>white</textcolor>
    </control>
    </itemlayout>
    <focusedlayout width="502" height="65">
       <control type="image">
           <posx>0</posx>
           <posy>0</posy>
           <width>502</width>
           <height>65</height>
           <texture>white.png</texture>
           <colordiffuse>DD171717</colordiffuse>
       </control>
       <control type="label">
           <visible>!Control.HasFocus(100)</visible>
           <posx>0</posx>
           <posy>0</posy>
           <width>502</width>
           <height>62</height>
           <font>font40</font>
           <align>left</align>
           <aligny>center</aligny>
           <label>$INFO[ListItem.Label]</label>
           <textcolor>white</textcolor>
           <selectedcolor>DD171717</selectedcolor>
       </control>
       <control type="label">
           <visible>Control.HasFocus(100)</visible>   
           <posx>0</posx>
           <posy>0</posy>
           <width>502</width>
           <height>62</height>
           <font>font40</font>
           <align>left</align>
           <aligny>center</aligny>
           <label>$INFO[ListItem.Label]</label>
           <textcolor>white</textcolor>
           <selectedcolor>DD171717</selectedcolor>
           <scroll>true</scroll>
           <scrollspeed>30</scrollspeed>
       </control>
    </focusedlayout>
    <content type="url" url="rss://yourdomain.com/yourfeed.rss">
    </content>
</control>

It’s the easy piece of the whole list container puzzle – just plug in the path for your RSS feed into the url attribute, and you’re done-diggy. Once you drop your completed code in the group control after the metadata box image, you can reload the app and see your content now populating. Once you add the container to your app, your main.xml should look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?xml version="1.0"?>
   <window type="window" id="14000">
   <defaultcontrol always="true">100</defaultcontrol>
   <allowoverlay>no</allowoverlay>
   <controls>
      <control type="group">
          <control type="image">
             <posx>0</posx>
             <posy>0</posy>
             <width>1280</width>
             <height>720</height>
             <texture>bg.png</texture>
          </control>
          <control type="image">
             <posx>60</posx>
             <posy>230</posy>
             <width>502</width>
             <height>416</height>
             <texture>list.png</texture>
         </control>
         <control type="image">
             <posx>630</posx>
             <posy>255</posy>
             <width>574</width>
             <height>355</height>
             <texture>details.png</texture>
          </control>
          <control type="list" id="100">
	   <posx>60</posx>
	   <posy>230</posy>
	   <width>502</width>
	   <height>416</height>
	   <orientation>vertical</orientation>
	   <itemlayout width="502" height="65">
	    <control type="label">
		<posx>0</posx>
		<posy>0</posy>
		<width>502</width>
		<height>62</height>
		<font>font40</font>
		<align>left</align>
		<aligny>center</aligny>
		<label>$INFO[ListItem.Label]</label>
		<textcolor>white</textcolor>
	    </control>
	    </itemlayout>
	    <focusedlayout width="502" height="65">
	       <control type="image">
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>65</height>
		   <texture>white.png</texture>
		   <colordiffuse>DD171717</colordiffuse>
	       </control>
	       <control type="label">
		   <visible>!Control.HasFocus(100)</visible>
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>62</height>
		   <font>font40</font>
		   <align>left</align>
		   <aligny>center</aligny>
		   <label>$INFO[ListItem.Label]</label>
		   <textcolor>white</textcolor>
		   <selectedcolor>DD171717</selectedcolor>
	       </control>
	       <control type="label">
		   <visible>Control.HasFocus(100)</visible>   
		   <posx>0</posx>
		   <posy>0</posy>
		   <width>502</width>
		   <height>62</height>
		   <font>font40</font>
		   <align>left</align>
		   <aligny>center</aligny>
		   <label>$INFO[ListItem.Label]</label>
		   <textcolor>white</textcolor>
		   <selectedcolor>DD171717</selectedcolor>
		   <scroll>true</scroll>
		   <scrollspeed>30</scrollspeed>
	       </control>
	    </focusedlayout>
	    <content type="url" url="rss://yourdomain.com/yourfeed.rss">
	    </content>
	</control>
      </control>
   </controls>
</window>

For more information of the possibilities of the list container, check out Boxee’s developer documentation.

Building Your First App: Finishing The Graphics
5 November 2009 by Rob Spectre
This entry is part 5 of 9 in the series Building Your First App

In our last installment, we successfully got our app installed and running – though it is only displaying our background.  We have two more graphic assets that we need to position in our app before we can get to building the interactive controls of our application.

The two assets we have left are the blue background boxes for the list container and the metadata box we pulled out of our original design.  This is easily accomplished by placing one image control for each graphic in the group we created in the last step.

First, let’s look at what we have to work with from last time:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0"?>
   <window type="window" id="14000">
   <defaultcontrol always="true">100</defaultcontrol>
   <allowoverlay>no</allowoverlay>
   <controls>
      <control type="group">
          <control type="image">
             <posx>0</posx>
             <posy>0</posy>
             <width>1280</width>
             <height>720</height>
             <texture>bg.png</texture>
          </control>
      </control>
   </controls>
</window>

An important rule to remember when placing your graphics is that Boxee renders controls sequentially. This means if you want a graphic to appear on top of another graphic (as we want with our list container box over our app background), we must place one after the other in the file. Thus, we add the image control after our bg.png in the same group control:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0"?>
   <window type="window" id="14000">
   <defaultcontrol always="true">100</defaultcontrol>
   <allowoverlay>no</allowoverlay>
   <controls>
      <control type="group">
          <control type="image">
             <posx>0</posx>
             <posy>0</posy>
             <width>1280</width>
             <height>720</height>
             <texture>bg.png</texture>
          </control>
          <control type="image">
             <posx>60</posx>
             <posy>230</posy>
             <width>502</width>
             <height>416</height>
             <texture>list.png</texture>
         </control>
      </control>
   </controls>
</window>

With our list graphic in place, adding the metadata box graphic is just as easy. Just add it after the list container graphic:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?xml version="1.0"?>
   <window type="window" id="14000">
   <defaultcontrol always="true">100</defaultcontrol>
   <allowoverlay>no</allowoverlay>
   <controls>
      <control type="group">
          <control type="image">
             <posx>0</posx>
             <posy>0</posy>
             <width>1280</width>
             <height>720</height>
             <texture>bg.png</texture>
          </control>
          <control type="image">
             <posx>60</posx>
             <posy>230</posy>
             <width>502</width>
             <height>416</height>
             <texture>list.png</texture>
         </control>
         <control type="image">
             <posx>630</posx>
             <posy>255</posy>
             <width>574</width>
             <height>355</height>
             <texture>details.png</texture>
          </control>
      </control>
   </controls>
</window>

Now, the next time we open our app in Boxee, we will see our original design faithfully reproduced within Boxee!

For more information on the possibilities of the image control, check out Boxee’s developer documentation.

»  Substance: WordPress   »  Style: Ahren Ahimsa
© 2009, all rights reserved.