2.5. Using the skin

Some plugins may want to draw something on the screen. One example is the weather plugin (external plugin, download it from http://freevo.sf.net/addons/). Since this has nothing to do with the normal menu system, such plugins also need an eventhandler to react on buttons.

Since Freevo knows nothing about which elements should be displayed and were to put them, the plugin needs to define a fxd file in share/skins/plugins with the needed information.

<?xml version="1.0" ?>
<freevo>
  <skin geometry="800x600">
    <foo>
      <screen layout="screen" x="0" y="0" width="800" height="600"/>
      <title .../>
      <view  .../>
    </foo>
  </skin>
</freevo>
	

Now the freevo skin has fxd information about the type foo, but doesn't know which areas are allowed (ok, the skin could guess it). So the plugin needs to call

skin.register('foo', ('screen', 'title', 'view', 'plugin'))
once. Now the plugin can call
skin.draw('foo', item)
to draw item with the settings of foo.

So far so good, but it may happen that the plugin needs an area which isn't defined right now. The default areas for Freevo are screen, title, subtitle, listing, info, view and plugin. The plugin area is used for smaller plugins to draw on the screen, e.g. the idlebar.

To create an area of your own, you first need to define it in the fxd file:

<?xml version="1.0" ?>
<freevo>
  <skin geometry="800x600">
    <foo>
      <screen layout="screen" x="0" y="0" width="800" height="600"/>
      <foo_area layout="foo" x="10" y="100" width="300" height="200"/>
    </foo>
  </skin>

  <layout label="foo">
    <background>
      ...
    </background>
    <content ...>
      ...
    </content>
  </layout>
</freevo>
	

Now the skin has fxd information about an area foo. The skin knows were it is and can also draw the background of the layout. But it needs an object to draw the real content. The following example defines a class which inherits from skin.Area. It defines itself as class to draw foo_area. The skin now calls the function update_content_needed to check if the area needs an update (return True or False). When Freevo knows that an update is needed, this function may not be called after all. The real work is done is update_content.

(add more doc here)