Update of /cvsroot/freevo/freevo/skins/dischi1
In directory sc8-pr-cvs1:/tmp/cvs-serv26955

Modified Files:
        area.py blue_round1.xml skin_dischi1.py xml_skin.py 
Added Files:
        blue_round2.xml image_watermark.png listing_area.py 
        movie_watermark.png music_watermark.png shutdown_watermark.png 
        skin_utils.py tv_watermark.png view_area.py 
Removed Files:
        listing.py 
Log Message:
The view area is working, still no extended menu/info area. The 
blue_round1 skin looks like with the old skin, blue_round2 is the
beginning of recreating aubin_round1. tv and music player aren't
implemented yet. 


--- NEW FILE: blue_round2.xml ---
<?xml version="1.0" ?>
<freevo>

  <skin include="blue1_small" geometry="800x600">

    <main>
      <item pos="0" name="         Watch TV"       action="tv.tv.main_menu"  arg="" 
        visible="yes" icon="" image="skins/dischi1/tv_watermark.png" />
      <item pos="1" name="      Watch a Movie" action="MediaMenu().main_menu" 
arg="video" 
        visible="yes" icon="" image="skins/dischi1/movie_watermark.png"  />
      <item pos="2" name="     Listen to Music"   action="MediaMenu().main_menu" 
arg="audio" 
        visible="yes" icon="" image="skins/dischi1/music_watermark.png" />
      <item pos="3" name="     Look at Pictures"   action="MediaMenu().main_menu" 
arg="image" 
        visible="yes" icon="" image="skins/dischi1/image_watermark.png" />
      <item pos="4" name="Games"   action="MediaMenu().main_menu" arg="games" 
        visible="no" icon="" image="" />
      <item pos="5" name="         Shutdown" action="ShutdownItem" arg="" 
        visible="yes" icon="" image="skins/dischi1/shutdown_watermark.png" />
    </main>
    
    <!-- Redefine of the type default -->
    <menu type="default">
      <!-- screen0 is already defined in blue1_big -->
      <screen layout="screen0" visible="yes"/>

      <!-- 
      title0 is already defined in blue1_big, but there will
      is a new definition of the font from the layout (white big)
      -->
      <title layout="title0" visible="yes">
        <area x="10" y="10" width="780" height="60"/> 
      </title>

      <view layout="view0" visible="yes">
        <area x="545" y="90" width="245" height="450"/> 
      </view>

      <listing layout="transparent listing" visible="yes">
        <area x="10" y="130" width="550" height="450"/>
      </listing>
      <info visible="no"/>
    </menu>

    <menu type="main">
      <!-- definition of the main menu -->
      <screen layout="screen watermark" visible="yes">
        <area x="0" y="0" width="800" height="600"/>
      </screen>
      <listing layout="list_main" visible="yes">
        <area x="230" y="120" width="380" height="390"/> 
      </listing>
    </menu>

    <menu type="video">
      <screen layout="video screen"/>
    </menu>
      
    <menu type="audio">
      <screen layout="audio screen"/>
    </menu>
      
    <!-- 
    the main menu isn't redefined, the area is the same.
    But there is a new define of list_main later 
    -->

    <!-- ********************************************** -->
    <!-- LAYOUT DEFINITIONS -->


    <!-- background -->
    <layout label="screen0">
      <background>
        <image filename="../images/aubin/blurr.jpg" x="0" y="0" label="background"/>
        <image filename="../images/logo.png" x="10" y="0" width="200" height="98"/>
      </background>
    </layout>

    <layout label="screen watermark">
      <background>
        <image filename="../images/aubin/blurr.jpg" x="0" y="0" label="background"/>
        <image filename="../images/logo.png" x="10" y="0" width="200" height="98"/>
        <image x="500" y="300" width="300" height="300" label="watermark"/>
      </background>
    </layout>

    <layout label="video screen">
      <background>
        <image filename="../images/aubin/blurr.jpg" x="0" y="0" label="background"/>
        <image filename="../images/logo.png" x="10" y="0" width="200" height="98"/>
        <image filename="movie_watermark.png" x="500" y="300" width="300"
          height="300"/>
      </background>
    </layout>

    <layout label="audio screen">
      <background>
        <image filename="../images/aubin/blurr.jpg" x="0" y="0" label="background"/>
        <image filename="../images/logo.png" x="10" y="0" width="200" height="98"/>
        <image filename="music_watermark.png" x="500" y="300" width="300"
          height="300"/>
      </background>
    </layout>

    <layout label="view0">
      <content align="left" valign="top">
        <item type="default">
          <rectangle size="0" bgcolor="0x80000000" radius="10" x="-15" y="-15"
            width="max+30" height="max+30"/>
        </item>
      </content>
    </layout>
    
    <!-- default listing area -->
    <layout label="transparent listing">
      <background>
        <rectangle size="0" bgcolor="0x80000000" radius="10" width="max"/>
      </background>
      <content x="20" y="20" width="max-40" height="max-40" type="text"
        spacing="2">
        <item type="default" font="white shadow1"/>
        <item type="selected" font="white shadow1">
          <rectangle bgcolor="0xff000000" size="0" x="-5" y="-3" width="max+10"
            height="max+6" radius="5"/>
        </item>
      </content>
    </layout>


    <!-- redefine the main menu listing area -->
    <layout label="list_main">
      <content type="text" spacing="10">
        <item type="default" font="white shadow1 big"/>
        <item type="selected" font="white shadow3 big">
          <rectangle bgcolor="0xa0000000" size="0" y="-5" x="-10"
            width="max+20" height="max+10" radius="5"/>
        </item>
      </content>
    </layout>

    <!-- ********************************************** -->
    <!-- FONT DEFINITIONS -->

    <font label="white shadow1">
      <definition name="bluehigh" color="0xffffff" size="20"/>
      <shadow visible="yes" color="0x00000000" x="1" y="1"/>
    </font>

    <font label="white shadow1 big">
      <definition name="bluehigh" size="44" color="0xffffff"/>
      <shadow visible="yes" color="0xaa000000" x="1" y="1"/>
    </font>

    <font label="white shadow3 big">
      <definition name="bluehigh" size="44" color="0xffffff"/>
      <shadow visible="yes" color="0x000000" x="3" y="3"/>
    </font>

    <!-- this font is used by the title -->
    <font label="white big">
      <definition name="oliversb" size="29" color="0xffffff"/>
      <shadow visible="yes" color="0x80000000" x="3" y="3"/>
    </font>

  </skin>
</freevo>

--- NEW FILE: image_watermark.png ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: listing_area.py ---
#if 0
# -----------------------------------------------------------------------
# listing_area.py - A listing area for the Freevo skin
# -----------------------------------------------------------------------
# $Id: listing_area.py,v 1.1 2003/02/27 22:39:50 dischi Exp $
#
# Notes: WIP
# Todo:        
#
# -----------------------------------------------------------------------
# $Log: listing_area.py,v $
# Revision 1.1  2003/02/27 22:39:50  dischi
# The view area is working, still no extended menu/info area. The
# blue_round1 skin looks like with the old skin, blue_round2 is the
# beginning of recreating aubin_round1. tv and music player aren't
# implemented yet.
#
# Revision 1.5  2003/02/26 21:21:11  dischi
# blue_round1.xml working
#
# Revision 1.4  2003/02/26 19:59:26  dischi
# title area in area visible=(yes|no) is working
#
# Revision 1.3  2003/02/26 19:18:53  dischi
# Added blue1_small and changed the coordinates. Now there is no overscan
# inside the skin, it's only done via config.OVERSCAN_[XY]. The background
# images for the screen area should have a label "background" to override
# the OVERSCAN resizes.
#
# Revision 1.2  2003/02/25 23:27:36  dischi
# changed max usage
#
# Revision 1.1  2003/02/25 22:56:00  dischi
# New version of the new skin. It still looks the same (except that icons
# are working now), but the internal structure has changed. Now it will
# be easier to do the next steps.
#
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al. 
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
#endif


import copy

import osd
import pygame

from area import Skin_Area

osd = osd.get_singleton()

# Set to 1 for debug output
DEBUG = 1

TRUE = 1
FALSE = 0


class Listing_Area(Skin_Area):
    """
    this call defines the listing area
    """

    def __init__(self, parent, screen):
        Skin_Area.__init__(self, 'listing', screen)
        self.last_choices = ( None, None )


    def get_items_geometry(self, settings, menu):
        """
        get the geometry of the items. How many items per row/col, spaces
        between each item, etc
        """

        # store the old values in case we are called by ItemsPerMenuPage
        backup = ( self.area_val, self.layout)
        
        self.init_vars(settings, menu.item_types)

        layout    = self.layout
        area      = self.area_val
        content   = self.calc_geometry(layout.content, copy_object=TRUE)

        items_w = content.width
        items_h = 0

        possible_types = {}

        hskip = 0
        vskip = 0
        for i in menu.choices:
            if hasattr(i, 'display_type') and i.display_type and \
               content.types.has_key(i.display_type):
                possible_types[i.display_type] = content.types[i.display_type]
            else:
                possible_types['default'] = content.types['default']

            if hasattr(i, 'display_type') and i.display_type and \
               content.types.has_key('%s selected' % i.display_type):
                possible_types['%s selected' % i.display_type] = \
                                   content.types['%s selected' % i.display_type]
            else:
                possible_types['selected'] = content.types['selected']
                
        # get the max height of a text item
        for t in possible_types:
            ct = possible_types[t]

            if not settings.font.has_key(ct.font):
                print '*** font <%s> not found' % ct.font
                break

            font = settings.font[ct.font]
            font_w, font_h = osd.stringsize('Arj', font=font.name, ptsize=font.size)

            rh = 0
            rw = 0
            if ct.rectangle:
                rw, rh, r = self.get_item_rectangle(ct.rectangle, font_w, font_h)
                hskip = min(hskip, r.x)
                vskip = min(vskip, r.y)
                
            items_h = max(items_h, font_h, rh)
            items_w = max(items_w, font_w, rw)

        # restore
        self.area_val, self.layout = backup

        items_w
        items_h

        cols = 0
        rows = 0

        while (cols + 1) * (items_w + content.spacing) - \
              content.spacing <= content.width:
            cols += 1

        while (rows + 1) * (items_h + content.spacing) - \
              content.spacing <= content.height:
            rows += 1

        # return cols, rows, item_w, item_h
        return (cols, rows, items_w + content.spacing,
                items_h + content.spacing, -hskip, -vskip)



    def update_content_needed(self, settings, menuw):
        """
        check if the content needs an update
        """
        menu = menuw.menustack[-1]
        if self.last_choices[0] != menu.selected:
            return TRUE

        i = 0
        for choice in menuw.menu_items:
            if self.last_choices[1][i] != choice:
                return TRUE
            i += 1

        
    def update_content(self, settings, menuw):
        """
        update the listing area
        """
        menu = menuw.menustack[-1]

        layout    = self.layout
        area      = self.area_val
        content   = self.calc_geometry(layout.content, copy_object=TRUE)

        cols, rows, hspace, vspace, hskip, vskip = \
              self.get_items_geometry(settings, menu)

        x0 = content.x
        y0 = content.y

        width  = content.width

        for choice in menuw.menu_items:
            if choice == menu.selected:
                if content.types.has_key('% selected' % choice.type):
                    val = content.types['% selected' % choice.type]
                else:
                    val = content.types['selected']
            else:
                if content.types.has_key(choice.type):
                    val = content.types[choice.type]
                else:
                    val = content.types['default']
                
            if not settings.font.has_key(val.font):
                print '*** font <%s> not found' % val.font
                break

            font = settings.font[val.font]


            text = choice.name
            if not text:
                text = "unknown"

            if choice.type == 'playlist':
                text = 'PL: %s' % text

            if content.type == 'text':
                font_w, font_h = osd.stringsize('Arj', font=font.name, 
ptsize=font.size)
                if choice.icon:
                    image = osd.loadbitmap(choice.icon)
                    if image:
                        image = pygame.transform.scale(image, (font_h, font_h))
                        self.draw_image(image, (x0, y0))
                        icon_x = font_h + content.spacing
                else:
                    icon_x = 0

                if val.rectangle:
                    None, None, r = self.get_item_rectangle(val.rectangle, width, 
font_h)
                    if hskip + r.x + r.width > width:
                        r.width = width - hskip - r.y
                    self.drawroundbox(x0 + hskip + r.x + icon_x, y0 + vskip + r.y,
                                      r.width - icon_x, r.height, r)
                    
                self.write_text(text, font, content, x=x0 + hskip + icon_x, y=y0 + 
vskip,
                                width=width-icon_x, height=-1, mode='hard')

            else:
                print 'no support for content type %s' % content.type

            y0 += vspace

        self.last_choices = (menu.selected, copy.copy(menuw.menu_items))


        

--- NEW FILE: movie_watermark.png ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: music_watermark.png ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: shutdown_watermark.png ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: skin_utils.py ---
#if 0
# -----------------------------------------------------------------------
# skin_utils.py - some utils for the skin
# -----------------------------------------------------------------------
# $Id: skin_utils.py,v 1.1 2003/02/27 22:39:50 dischi Exp $
#
# Notes: WIP
# Todo:        
#
# -----------------------------------------------------------------------
# $Log: skin_utils.py,v $
# Revision 1.1  2003/02/27 22:39:50  dischi
# The view area is working, still no extended menu/info area. The
# blue_round1 skin looks like with the old skin, blue_round2 is the
# beginning of recreating aubin_round1. tv and music player aren't
# implemented yet.
#
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al. 
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
#endif


import pygame
import osd


osd = osd.get_singleton()

def format_image(item, width, height):
    if hasattr(item, 'display_type'):
        type = item.display_type
    else:
        type = item.type
        
    if item.image:
        image = osd.loadbitmap('thumb://%s' % item.image)

    if type == 'audio':
        m = min(height, width)
        height = m
        width  = m

    else:
        if type == 'video':
            # aspect 7:5
            i_w = 5
            i_h = 7
        else:
            i_w, i_h = image.get_size()

        if int(float(width * i_h) / i_w) > height:
            width = int(float(height * i_w) / i_h)
        else:
            height = int(float(width * i_h) / i_w)
    
    return pygame.transform.scale(image, (width, height))
    

--- NEW FILE: tv_watermark.png ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: view_area.py ---
#if 0
# -----------------------------------------------------------------------
# view_area.py - A view area for the Freevo skin
# -----------------------------------------------------------------------
# $Id: view_area.py,v 1.1 2003/02/27 22:39:50 dischi Exp $
#
# Notes: WIP
# Todo:        
#
# -----------------------------------------------------------------------
# $Log: view_area.py,v $
# Revision 1.1  2003/02/27 22:39:50  dischi
# The view area is working, still no extended menu/info area. The
# blue_round1 skin looks like with the old skin, blue_round2 is the
# beginning of recreating aubin_round1. tv and music player aren't
# implemented yet.
#
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al. 
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
#endif

from area import Skin_Area
from skin_utils import *

TRUE  = 1
FALSE = 0

class View_Area(Skin_Area):
    """
    this call defines the view area
    """

    def __init__(self, parent, screen):
        Skin_Area.__init__(self, 'view', screen)
        self.image = None


    def update_content_needed(self, settings, menuw):
        """
        check if the content needs an update
        """
        menu = menuw.menustack[-1]
        image = None

        if hasattr(menu.selected, 'image') and menu.selected.image:
            image = menu.selected.image

        return image != self.image
    

    def update_content(self, settings, menuw):
        """
        update the view area
        """
        menu = menuw.menustack[-1]
        item = menu.selected
        
        layout    = self.layout
        area      = self.area_val
        content   = self.calc_geometry(layout.content, copy_object=TRUE)

        if content.types.has_key(menu.selected.type):
            val = content.types[menu.selected.type]
        else:
            val = content.types['default']

        if hasattr(menu.selected, 'image') and item.image:
            self.image = item.image
        else:
            self.image = None
            return

        x0 = 0
        y0 = 0

        width  = content.width - 2*content.spacing
        height = content.height - 2*content.spacing

        
        if val.rectangle:
            x, y, r = self.get_item_rectangle(val.rectangle, width, height)

            if r.x < 0:
                x0 -= r.x
                r.x = 0
            
            if r.y < 0:
                y0 -= r.y
                r.y = 0
            
            if r.x + r.width > x0 + width:
                r.width, width = width, width - (r.width - width)

            if r.y + r.height > y0 + height:
                r.height, height = height, height - (r.height - height)

        addx = content.x + content.spacing
        addy = content.y + content.spacing

        image = format_image(item, width, height)
        i_w, i_h = image.get_size()

        if content.align == 'center' and i_w < width:
            addx += (width - i_w) / 2

        if content.align == 'right' and i_w < width:
            addx += width - i_w
            
        if content.valign == 'center' and i_h < height:
            addy += (height - i_h) / 2

        if content.valign == 'bottom' and i_h < height:
            addy += height - i_h

        x0 += addx
        y0 += addy

        self.draw_image(image, (x0, y0))

        if val.rectangle:
            r.width -= width - i_w
            r.height -= height - i_h
            self.drawroundbox(r.x + addx, r.y + addy, r.width, r.height, r)

Index: area.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/area.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** area.py     26 Feb 2003 19:59:25 -0000      1.4
--- area.py     27 Feb 2003 22:39:49 -0000      1.5
***************
*** 5,13 ****
  # $Id$
  #
! # Notes: WIP
! # Todo:        
  #
  # -----------------------------------------------------------------------
  # $Log$
  # Revision 1.4  2003/02/26 19:59:25  dischi
  # title area in area visible=(yes|no) is working
--- 5,47 ----
  # $Id$
  #
! # Notes:
! #
! #
! # This is the main class for all area. Right now it's working, but
! # some things are not very good. Maybe someone can create a new
! # Skin_Area with a different behaviour.
! #
! # My first draft was an area which redraws only the needed parts and
! # blits it onto the surface.. But there are some problems with that,
! # which makes this a little bit difficult. This version redraws too
! # much, but blits only the needed parts on the screen.
! #
! # If you want to create a new Skin_Area, please keep my problems in mind:
! #
! #
! # 1. Not all areas are visible at the same time, some areas may change
! #    the settings and others don't
! # 2. The listing and the view area can overlap, at the next item the image
! #    may be gone
! # 3. alpha layers are slow to blit on a non alpha surface.
! # 4. the blue_round1 draws two alpha masks, one for the listing, one
! #    for the view area. They overlap, but the overlapping area
! #    shouldn't be an addition of the transparent value
! # 5. If you drop an alpha layer on the screen, you can't get the original
! #    background back by making a reverse alpha layer.
! #
! # For more informations contact me ([EMAIL PROTECTED])
! #
! #
! # Todo: make it faster :-)
  #
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.5  2003/02/27 22:39:49  dischi
+ # The view area is working, still no extended menu/info area. The
+ # blue_round1 skin looks like with the old skin, blue_round2 is the
+ # beginning of recreating aubin_round1. tv and music player aren't
+ # implemented yet.
+ #
  # Revision 1.4  2003/02/26 19:59:25  dischi
  # title area in area visible=(yes|no) is working
***************
*** 56,59 ****
--- 90,94 ----
  import osd
  import config
+ import objectcache
  
  import xml_skin
***************
*** 70,106 ****
  
  
  class Skin_Area:
!     def __init__(self, name):
          self.area_name = name
-         self.alpha     = None           # alpha layer for rectangles
-         self.screen    = None           # backup of the final screen
          self.area_val  = None
          self.redraw    = TRUE
          self.depends   = ()
-         self.bg        = [ None, None ]
          self.layout    = None
!         self.visible   = FALSE
          
      def draw(self, settings, menuw):
          menu = menuw.menustack[-1]
  
          self.redraw = FALSE
! 
!         for d in self.depends:
!             self.redraw = d.redraw or self.redraw
          
!         dep_redraw = self.redraw
          self.redraw = self.init_vars(settings, menu.item_types)
  
!         # we need to restore the area we want to draw in
!         if not dep_redraw and self.redraw and self.bg[0] and self.visible:
!             osd.screen.blit(self.bg[0][0], self.bg[0][1:])
  
!         self.visible = self.area_val.visible
  
!         # maybe we are invisible
!         if not self.visible:
!             return
  
          self.draw_background()
  
--- 105,200 ----
  
  
+ background = None
+ alpha = None
+ 
+ 
+ class Screen:
+     """
+     this call is a set of surfaces for the area to do it's job
+     """
+ 
+     def __init__(self):
+         self.background  = pygame.Surface((osd.width, osd.height), 1, 32)
+         self.alpha       = self.background.convert_alpha()
+         self.alpha.fill((0,0,0,0))
+         self.alpha_bg    = self.background.convert()
+         
+     def clear(self):
+         self.alpha.fill((0,0,0,0))
+ 
+ 
+       
  class Skin_Area:
!     """
!     the base call for all areas. Each child needs two functions:
! 
!     def update_content_needed
!     def update_content
!     """
! 
!     def __init__(self, name, screen):
          self.area_name = name
          self.area_val  = None
          self.redraw    = TRUE
          self.depends   = ()
          self.layout    = None
!         self.name      = name
          
+         self.background = screen.background
+         self.alpha = screen.alpha
+         self.alpha_bg = screen.alpha_bg
+ 
+         self.redraw_background  = []
+         self.redraw_alpha       = []
+         self.content_alpha      = []
+ 
+         self._write_text   = []
+         self._draw_image   = []
+ 
+         self.imagecache = objectcache.ObjectCache(5, desc='%s_image' % self.name)
+ 
      def draw(self, settings, menuw):
+         """
+         this is the main draw function. This function draws the background,
+         checks if redraws are needed and calls the two update functions for
+         the different types of areas
+         """
+         
          menu = menuw.menustack[-1]
  
+         self.menu = menu
+         
          self.redraw = FALSE
!         self.mode = 0                   # start draw
          
!         area = self.area_val
! 
!         if area:
!             visible = area.visible
!         else:
!             visible = FALSE
!             
          self.redraw = self.init_vars(settings, menu.item_types)
  
!         if area and area != self.area_val:
!             self.redraw_alpha += [ (area.x, area.y, area.width, area.height) ]
!             old_area = area
!         else:
!             old_area = None
!             
!         area = self.area_val
  
!         # maybe we are NOW invisible
!         if visible and not area.visible:
!             for rect in self.content_alpha:
!                 self.alpha_bg.blit(self.background, (rect[0], rect[1]), rect)
!                 self.alpha_bg.blit(self.alpha, (rect[0], rect[1]), rect)
!                 osd.screen.blit(self.alpha_bg, (rect[0], rect[1]), rect)
  
!             self.content_alpha = []
  
+         if not area.visible:
+             return
+         
          self.draw_background()
  
***************
*** 111,121 ****
                  return
  
!             # restore the background
!             osd.screen.blit(self.bg[1], (self.area_val.x, self.area_val.y))
  
          self.update_content(settings, menuw)
          
  
!     def calc_geometry(self, object, copy_object=0, fit_area=1):
          if copy_object:
              object = copy.deepcopy(object)
--- 205,270 ----
                  return
  
!         for rect in self.content_alpha:
!             self.alpha_bg.blit(self.background, (rect[0], rect[1]), rect)
!             self.alpha_bg.blit(self.alpha, (rect[0], rect[1]), rect)
!             osd.screen.blit(self.alpha_bg, (rect[0], rect[1]), rect)
! 
!         self.content_alpha = []
  
+         self.mode = 1                   # draw alpha stuff
          self.update_content(settings, menuw)
+ 
+         for rect in self.redraw_background:
+             # FIXME: redraw background
+             self.alpha_bg.blit(self.background, rect[:2], rect)
+ 
+ 
+         for rect in self.redraw_alpha:
+             # redraw alpha means to create a new merge of background
+             # and alpha on alpha_bg and blit it into osd.screen
+             self.alpha_bg.blit(self.background, rect[:2], rect)
+             self.alpha_bg.blit(self.alpha, rect[:2], rect)
+ 
+         self.redraw_alpha = []
+         self.redraw_background = []
+ 
+         if old_area:
+             osd.screen.blit(self.alpha_bg, (old_area.x,old_area.y),
+                             (old_area.x, old_area.y, old_area.width,
+                              old_area.height))
+ 
+         osd.screen.blit(self.alpha_bg, (area.x,area.y),
+                         (area.x, area.y, area.width, area.height))
+ 
+ 
+ 
          
+         for t in self._write_text:
+             ( text, font, x, y, width, height, align_h, align_v, mode, ellipses ) = t
+             if font.shadow.visible:
+                 osd.drawstringframed(text, x+font.shadow.x, y+font.shadow.y,
+                                      width, height, font.shadow.color, None,
+                                      font=font.name, ptsize=font.size,
+                                      align_h = align_h, align_v = align_v,
+                                      mode=mode, ellipses=ellipses)
+             osd.drawstringframed(text, x, y, width, height, font.color, None,
+                                  font=font.name, ptsize=font.size,
+                                  align_h = align_h, align_v = align_v,
+                                  mode=mode, ellipses=ellipses)
  
!         for i in self._draw_image:
!             osd.screen.blit(i[0], i[1])
! 
!         self._write_text = []
!         self._draw_image = []
! 
! 
! 
! 
!     def calc_geometry(self, object, copy_object=0):
!         """
!         calculate the real values of the object (e.g. content) based
!         on the geometry of the area
!         """
          if copy_object:
              object = copy.deepcopy(object)
***************
*** 127,134 ****
          object.height = eval('%s' % object.height)
  
!         if fit_area:
!             object.x += self.area_val.x
!             object.y += self.area_val.y
! 
          if not object.width:
              object.width = self.area_val.width
--- 276,282 ----
          object.height = eval('%s' % object.height)
  
!         object.x += self.area_val.x
!         object.y += self.area_val.y
!         
          if not object.width:
              object.width = self.area_val.width
***************
*** 146,173 ****
  
          
      def init_vars(self, settings, display_type):
          redraw = self.redraw
          
          if settings.menu.has_key(display_type):
!             area_val = settings.menu[display_type][0]
          else:
!             area_val = settings.menu['default'][0]
  
!         area_val = eval('area_val.%s' % self.area_name)
          
!         if (not self.area_val) or area_val != self.area_val:
!             self.area_val = area_val
              redraw = TRUE
              
!         if not settings.layout.has_key(area_val.layout):
!             print '*** layout <%s> not found' % area_val.layout
              return FALSE
  
          old_layout = self.layout
!         self.layout = settings.layout[area_val.layout]
  
          if old_layout and old_layout != self.layout:
              redraw = TRUE
  
          return redraw
          
--- 294,356 ----
  
          
+     def get_item_rectangle(self, rectangle, item_w, item_h):
+         """
+         calculates the values for a rectangle inside the item tag
+         """
+         r = copy.copy(rectangle)
+         
+         if not r.width:
+             r.width = item_w
+ 
+         if not r.height:
+             r.height = item_h
+ 
+         MAX = item_w
+         r.x = int(eval('%s' % r.x))
+         r.width = int(eval('%s' % r.width))
+             
+         MAX = item_h
+         r.y = int(eval('%s' % r.y))
+         r.height = int(eval('%s' % r.height))
+ 
+         if r.x < 0:
+             item_w -= r.x
+ 
+         if r.y < 0:
+             item_h -= r.y
+ 
+         return max(item_w, r.width), max(item_h, r.height), r
+     
+ 
+ 
      def init_vars(self, settings, display_type):
+         """
+         check which layout is used and set variables for the object
+         """
          redraw = self.redraw
          
          if settings.menu.has_key(display_type):
!             area = settings.menu[display_type][0]
          else:
!             area = settings.menu['default'][0]
  
!         area = eval('area.%s' % self.area_name)
          
!         if (not self.area_val) or area != self.area_val:
!             self.area_val = area
              redraw = TRUE
              
!         if not settings.layout.has_key(area.layout):
!             print '*** layout <%s> not found' % area.layout
              return FALSE
  
          old_layout = self.layout
!         self.layout = settings.layout[area.layout]
  
          if old_layout and old_layout != self.layout:
              redraw = TRUE
  
+         area.r = (area.x, area.y, area.width, area.height)
+ 
          return redraw
          
***************
*** 175,195 ****
  
      def draw_background(self):
!         if not self.redraw:
!             return
! 
          area = self.area_val
  
!         self.bg = [ [ None, area.x, area.y ], None ]
!         self.bg[0][0] = osd.createlayer(area.width, area.height)
!         self.bg[0][0].blit(osd.screen, (0,0), (area.x, area.y,
!                                                area.x + area.width,
!                                                area.y + area.height))
! 
!         self.alpha = None
          for bg in copy.deepcopy(self.layout.background):
              if isinstance(bg, xml_skin.XML_image):
                  self.calc_geometry(bg)
!                 image = osd.loadbitmap(bg.filename)
! 
                  # if this is the real background image, ignore the
                  # OVERSCAN to fill the whole screen
--- 358,375 ----
  
      def draw_background(self):
!         """
!         draw the <background> of the area
!         """
          area = self.area_val
  
!         if hasattr(self, 'has_watermark') and self.has_watermark:
!             self.redraw = TRUE
!             self.has_watermark = FALSE
!             
          for bg in copy.deepcopy(self.layout.background):
              if isinstance(bg, xml_skin.XML_image):
                  self.calc_geometry(bg)
!                 imagefile = ''
!                 
                  # if this is the real background image, ignore the
                  # OVERSCAN to fill the whole screen
***************
*** 199,246 ****
                      bg.width  += 2 * config.OVERSCAN_X
                      bg.height += 2 * config.OVERSCAN_Y
-                 if image:
-                     
osd.screen.blit(pygame.transform.scale(image,(bg.width,bg.height)),
-                                     (bg.x, bg.y))
-             elif isinstance(bg, xml_skin.XML_rectangle):
-                 self.calc_geometry(bg, fit_area=FALSE)
-                 if not self.alpha:
-                     self.alpha = osd.createlayer(area.width, area.height)
-                     # clear surface
-                     self.alpha.fill((0,0,0,0))
-                 osd.drawroundbox(bg.x, bg.y, bg.x+bg.width, bg.y+bg.height, 
bg.bgcolor,
-                                  bg.size, bg.color, bg.radius, layer=self.alpha)
  
!         if self.alpha:
!             osd.screen.blit(self.alpha, (area.x, area.y))
  
!         if hasattr(self, 'bg'):
!             self.bg[1] = osd.createlayer(area.width, area.height)
!             self.bg[1].blit(osd.screen, (0,0), (area.x, area.y,
!                                                 area.x + area.width,
!                                                 area.y + area.height))
  
  
  
!     def drawroundbox(self, x, y, width, height, rect):
          area = self.area_val
!         if self.alpha:
!             osd.screen.blit(self.bg[0][0], (x, y), (x-area.x, y-area.y, width, 
height))
!             a = osd.createlayer(width, height)
!             a.blit(self.alpha, (0,0), (x - area.x, y - area.y, width, height))
  
!             osd.drawroundbox(0, 0, width, height,
!                              color = rect.bgcolor, border_size=rect.size,
!                              border_color=rect.color, radius=rect.radius, layer=a)
!             osd.screen.blit(a, (x, y))
!         else:
!             osd.drawroundbox(x, y, x+width, y+height,
!                              color = rect.bgcolor, border_size=rect.size,
!                              border_color=rect.color, radius=rect.radius)
  
!         
      # Draws a text inside a frame based on the settings in the XML file
      def write_text(self, text, font, content, x=-1, y=-1, width=None, height=None,
                     align_h = None, align_v = None, mode='hard', ellipses='...'):
!     
          if x == -1: x = content.x
          if y == -1: y = content.y
--- 379,436 ----
                      bg.width  += 2 * config.OVERSCAN_X
                      bg.height += 2 * config.OVERSCAN_Y
  
!                 if bg.label == 'watermark' and self.menu.selected.image:
!                     imagefile = self.menu.selected.image
!                     self.has_watermark = TRUE
!                     self.redraw = TRUE
!                 else:
!                     imagefile = bg.filename
  
!                 if self.name == 'screen':
!                     bg.label = 'background'
!                     
!                 if imagefile:
!                     cname = '%s-%s-%s' % (imagefile, bg.width, bg.height)
!                     image = self.imagecache[cname]
!                     if not image:
!                         image = osd.loadbitmap(imagefile)
!                         if image:
!                             image = 
pygame.transform.scale(image,(bg.width,bg.height))
!                             self.imagecache[cname] = image
!                     if image:
!                         self.draw_image(image, bg, redraw=self.redraw)
!                 
!             elif isinstance(bg, xml_skin.XML_rectangle):
!                 self.calc_geometry(bg)
!                 self.drawroundbox(bg.x, bg.y, bg.width, bg.height, bg, 
redraw=self.redraw)
  
  
  
!     def drawroundbox(self, x, y, width, height, rect, redraw=TRUE):
!         """
!         draw a round box
!         """
!         # only call this function in mode 0 and mode 1
!         if self.mode > 1:
!             return
! 
          area = self.area_val
!         osd.drawroundbox(x, y, x+width, y+height,
!                          color = rect.bgcolor, border_size=rect.size,
!                          border_color=rect.color, radius=rect.radius, 
layer=self.alpha)
!         if redraw:
!             self.redraw_alpha  += [ (x, y, width, height) ]
  
!         if self.mode == 1:
!             self.content_alpha += [ (x, y, width, height) ]
  
!             
      # Draws a text inside a frame based on the settings in the XML file
      def write_text(self, text, font, content, x=-1, y=-1, width=None, height=None,
                     align_h = None, align_v = None, mode='hard', ellipses='...'):
!         """
!         writes a text ... or better stores the information about this call
!         in a variable. The real drawing is done inside draw()
!         """
          if x == -1: x = content.x
          if y == -1: y = content.y
***************
*** 260,276 ****
              if not align_v:
                  align_v = 'top'
!                 
!         if font.shadow.visible:
!             osd.drawstringframed(text, x+font.shadow.x, y+font.shadow.y,
!                                  width, height, font.shadow.color, None,
!                                  font=font.name, ptsize=font.size,
!                                  align_h = align_h, align_v = align_v,
!                                  mode=mode, ellipses=ellipses)
!         osd.drawstringframed(text, x, y, width, height, font.color, None,
!                              font=font.name, ptsize=font.size,
!                              align_h = align_h, align_v = align_v,
!                              mode=mode, ellipses=ellipses)
  
  
  
-     
--- 450,478 ----
              if not align_v:
                  align_v = 'top'
! 
!         self._write_text += [ ( text, font, x, y, width, height, align_h,
!                                 align_v, mode, ellipses ) ]
! 
! 
! 
!     def draw_image(self, image, val, redraw=TRUE):
!         """
!         draws an image ... or better stores the information about this call
!         in a variable. The real drawing is done inside draw()
!         """
!         if isinstance(val, tuple):
!             self._draw_image += [ ( image, val ) ]
!             
!             
!         elif hasattr(val, 'label') and val.label == 'background':
!             if redraw:
!                 self.background.blit(image, (val.x, val.y))
!                 self.redraw_background += [ (val.x, val.y, val.width, val.height) ]
!                 if val.label == 'background':
!                     osd.screen.blit(image, (val.x, val.y))
!         else:
!             self._draw_image += [ ( image, (val.x, val.y)) ]
!             
  
  
  

Index: blue_round1.xml
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/blue_round1.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** blue_round1.xml     26 Feb 2003 21:21:11 -0000      1.1
--- blue_round1.xml     27 Feb 2003 22:39:50 -0000      1.2
***************
*** 23,29 ****
        </title>
  
-       <!-- unsupported -->
        <view layout="view0" visible="yes">
!       <area x="560" y="115" width="200" height="300"/> 
        </view>
  
--- 23,28 ----
        </title>
  
        <view layout="view0" visible="yes">
!       <area x="545" y="90" width="245" height="450"/> 
        </view>
  
***************
*** 42,49 ****
      <!-- LAYOUT DEFINITIONS -->
  
      <!-- default listing area -->
      <layout label="transparent listing">
        <background>
!       <rectangle size="0" bgcolor="0x80000000" radius="10"/>
        </background>
        <content x="20" y="20" width="max-40" height="max-40" type="text"
--- 41,58 ----
      <!-- LAYOUT DEFINITIONS -->
  
+ 
+     <layout label="view0">
+       <content align="left" valign="top">
+       <item type="default">
+         <rectangle size="0" bgcolor="0x80000000" radius="10" x="-15" y="-15"
+           width="max+30" height="max+30"/>
+       </item>
+       </content>
+     </layout>
+     
      <!-- default listing area -->
      <layout label="transparent listing">
        <background>
!       <rectangle size="0" bgcolor="0x80000000" radius="10" width="max"/>
        </background>
        <content x="20" y="20" width="max-40" height="max-40" type="text"

Index: skin_dischi1.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/skin_dischi1.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** skin_dischi1.py     26 Feb 2003 21:21:11 -0000      1.21
--- skin_dischi1.py     27 Feb 2003 22:39:50 -0000      1.22
***************
*** 10,13 ****
--- 10,19 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.22  2003/02/27 22:39:50  dischi
+ # The view area is working, still no extended menu/info area. The
+ # blue_round1 skin looks like with the old skin, blue_round2 is the
+ # beginning of recreating aubin_round1. tv and music player aren't
+ # implemented yet.
+ #
  # Revision 1.21  2003/02/26 21:21:11  dischi
  # blue_round1.xml working
***************
*** 101,132 ****
  # We have five areas, all inherit from Skin_Area (file area.py)
  #
! # Skin_Screen   (this file)
! # Skin_Title    (this file)
! # Skin_View     (not implemented yet)
! # Skin_Listing  (listing.py)
! # Skin_Info     (not implemented yet)
  
  from area import Skin_Area
! from listing import Skin_Listing
  
! class Skin_Screen(Skin_Area):
!     def __init__(self, parent):
!         Skin_Area.__init__(self, 'screen')
  
      def update_content_needed(self, settings, menuw):
          return FALSE
  
      def update_content(self, settings, menuw):
          pass
  
  
! class Skin_Title(Skin_Area):
!     def __init__(self, parent):
!         Skin_Area.__init__(self, 'title')
!         self.depends = ( parent.screen_area, )
          self.text = ''
  
          
      def update_content_needed(self, settings, menuw):
          menu = menuw.menustack[-1]
  
--- 107,157 ----
  # We have five areas, all inherit from Skin_Area (file area.py)
  #
! # Screen_Area   (this file)
! # Title_Area    (this file)
! # View_Area     (view_area.py)
! # Listing_Area  (listing_area.py)
! # Info_Area     (not implemented yet)
  
  from area import Skin_Area
! from area import Screen
! 
! from listing_area import Listing_Area
! from view_area import View_Area
  
! 
! class Screen_Area(Skin_Area):
!     """
!     this area is the screen or background of the skin
!     """
!     def __init__(self, parent, screen):
!         Skin_Area.__init__(self, 'screen', screen)
  
      def update_content_needed(self, settings, menuw):
+         """
+         this area needs never a content update
+         """
          return FALSE
  
      def update_content(self, settings, menuw):
+         """
+         there is no content in this area
+         """
          pass
  
  
! 
! class Title_Area(Skin_Area):
!     """
!     in this area the title of the menu is drawn
!     """
!     def __init__(self, parent, screen):
!         Skin_Area.__init__(self, 'title', screen)
          self.text = ''
  
          
      def update_content_needed(self, settings, menuw):
+         """
+         check if the content needs an update
+         """
          menu = menuw.menustack[-1]
  
***************
*** 144,147 ****
--- 169,175 ----
  
      def update_content(self, settings, menuw):
+         """
+         update the content
+         """
          menu = menuw.menustack[-1]
  
***************
*** 163,166 ****
--- 191,196 ----
          self.write_text(text, settings.font[content.font], content, mode='hard')
  
+ 
+ 
  ###############################################################################
  
***************
*** 194,200 ****
  
      def __init__(self):
!         self.area_names = ( 'screen', 'title', 'listing')
          for a in self.area_names:
!             setattr(self, '%s_area' % a, eval('Skin_%s%s(self)' % (a[0].upper(), 
a[1:])))
  
  
--- 224,232 ----
  
      def __init__(self):
!         self.screen = Screen()
!         self.area_names = ( 'screen', 'title', 'listing', 'view')
          for a in self.area_names:
!             setattr(self, '%s_area' % a, eval('%s%s_Area(self, self.screen)' % \
!                                               (a[0].upper(), a[1:])))
  
  
***************
*** 293,296 ****
--- 325,329 ----
              menu.item_types = 'main'
              
+         self.screen.clear()
          for a in self.area_names:
              area = eval('self.%s_area' % a)
***************
*** 303,304 ****
--- 336,367 ----
          osd.update()
  
+     def format_track (self, array):
+         """ Return a formatted string for use in music.py """
+       # This is the default - track name only
+       formatstr = '%(t)s'
+               # This will show the track number as well 
+       #formatstr = '%(n)s - %(t)s'
+ 
+       # Since we can't specify the length of the integer in the
+       # format string (Python doesn't seem to recognize it) we
+       # strip it out first, when we see the only thing that can be
+       # a number.
+ 
+ 
+         # Before we begin, make sure track is an integer
+     
+         if array.track:
+             try:
+               mytrack = ('%0.2d' % int(array.track))
+             except ValueError:
+               mytrack = None
+         else:
+            mytrack = None
+     
+         song_info = {  'a'  : array.artist,
+                              'l'  : array.album,
+                      'n'  : mytrack,
+                      't'  : array.title,
+                      'y'  : array.year }
+    
+         return formatstr % song_info

Index: xml_skin.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/xml_skin.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** xml_skin.py 26 Feb 2003 21:21:12 -0000      1.14
--- xml_skin.py 27 Feb 2003 22:39:50 -0000      1.15
***************
*** 10,13 ****
--- 10,19 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.15  2003/02/27 22:39:50  dischi
+ # The view area is working, still no extended menu/info area. The
+ # blue_round1 skin looks like with the old skin, blue_round2 is the
+ # beginning of recreating aubin_round1. tv and music player aren't
+ # implemented yet.
+ #
  # Revision 1.14  2003/02/26 21:21:12  dischi
  # blue_round1.xml working
***************
*** 350,353 ****
--- 356,363 ----
                              self.types[type].rectangle.parse(rnode, scale, 
current_dir)
  
+         if not self.types.has_key('default'):
+             self.types['default'] = XML_data(('font',))
+             self.types['default'].rectangle = None
+         
  
          

--- listing.py DELETED ---




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to