Update of /cvsroot/freevo/freevo/src/skins/main
In directory sc8-pr-cvs1:/tmp/cvs-serv1723

Added Files:
        default_areas.py screen.py 
Log Message:
move some classes into extra files

--- NEW FILE: default_areas.py ---
#if 0
# -----------------------------------------------------------------------
# default_areas.py - Some areas for the skin
# -----------------------------------------------------------------------
# $Id: default_areas.py,v 1.1 2003/12/06 16:41:45 dischi Exp $
#
# Notes: This file contains only small areas, other areas like
#        ListingArea have there own file
#
# Todo:        
#
# -----------------------------------------------------------------------
# $Log: default_areas.py,v $
# Revision 1.1  2003/12/06 16:41:45  dischi
# move some classes into extra files
#
#
# -----------------------------------------------------------------------
# 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 config
import osd
import plugin

from area import Skin_Area

# Create the OSD object
osd = osd.get_singleton()


class Screen_Area(Skin_Area):
    """
    this area is the screen or background of the skin
    """
    def __init__(self):
        Skin_Area.__init__(self, 'screen')

    def update_content_needed(self):
        """
        this area needs never a content update
        """
        return False

    def update_content(self):
        """
        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):
        Skin_Area.__init__(self, 'title')
        self.text = ''

        
    def update_content_needed(self):
        """
        check if the content needs an update. This function does the same as
        update_content, so it's faster to return always 1
        """
        return 1


    def update_content(self):
        """
        update the content
        """
        menu      = self.menu
        layout    = self.layout
        area      = self.area_val
        content   = self.calc_geometry(layout.content, copy_object=True)

        text = ''
        try:
            if content.type == 'menu':
                text = menu.heading
            elif len(menu.choices) == 0:
                text = ''
            elif content.type == 'short item':
                if menu.selected.image and menu.selected.type == 'video' and \
                   hasattr(menu.selected, 'tv_show') and menu.selected.tv_show:
                    sn = menu.selected.show_name
                    text = sn[1] + "x" + sn[2] + " - " + sn[3] 
                else:
                    text = menu.selected.name
            else:
                text = menu.selected.name
        except AttributeError:
            try:
                if menu.type == 'tv':
                    if content.type == 'item' or content.type == 'short item':
                        text = menu.table[1].title
                    else:
                        text = _('TV GUIDE')
            except:
                pass

        if not text:
            text = self.infoitem.name

        self.text = text
        self.drawstring(text, content.font, content, height=-1, mode='hard')



class Subtitle_Area(Title_Area):
    """
    in this area the subtitle of the menu is drawn
    """
    def __init__(self):
        Skin_Area.__init__(self, 'subtitle')
        self.text = ''



class Plugin_Area(Skin_Area):
    """
    in this area all plugins can draw
    """
    def __init__(self):
        Skin_Area.__init__(self, 'plugin')
        self.plugins = None
        self.x = config.OSD_OVERSCAN_X
        self.y = config.OSD_OVERSCAN_Y
        self.width   = osd.width  - 2 * config.OSD_OVERSCAN_X
        self.height  = osd.height - 2 * config.OSD_OVERSCAN_Y

        
    def get_font(self, name):
        try:
            return self.xml_settings.font[name]
        except:
            return self.xml_settings.font['default']
    

    def update_content(self):
        """
        there is no content in this area
        """
        if self.plugins == None:
            self.plugins = plugin.get('daemon_draw')

        for p in self.plugins:
            p.draw((self.widget_type, self.menuw), self)


--- NEW FILE: screen.py ---
#if 0
# -----------------------------------------------------------------------
# screen.py - The screen for the Freevo areas to draw on
# -----------------------------------------------------------------------
# $Id: screen.py,v 1.1 2003/12/06 16:41:45 dischi Exp $
#
# -----------------------------------------------------------------------
# $Log: screen.py,v $
# Revision 1.1  2003/12/06 16:41:45  dischi
# move some classes into extra files
#
#
# -----------------------------------------------------------------------
# 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 osd
osd = osd.get_singleton()


singleton = None

def get_singleton():
    global singleton
    if not singleton:
        singleton = Screen()
    return singleton


class Screen:
    """
    this call is a set of surfaces for the area to do it's job
    """

    def __init__(self):
        self.s_content  = osd.screen.convert()
        self.s_alpha    = self.s_content.convert_alpha()
        self.s_bg       = self.s_content.convert()

        self.s_alpha.fill((0,0,0,0))

        self.update_bg      = None
        self.update_alpha   = []
        self.update_content = []

        self.drawlist = []
        self.avoid_list = []

        
    def clear(self):
        self.update_bg      = None
        self.update_alpha   = []
        self.update_content = []
        self.drawlist = []


    def draw(self, obj):
        self.drawlist.append(obj)


    def update(self, layer, rect):
        if layer == 'content':
            self.update_content.append(rect)
        elif layer == 'alpha':
            self.update_alpha.append(rect)
        else:
            if self.update_bg:
                self.update_bg = ( min(self.update_bg[0], rect[0]),
                                   min(self.update_bg[1], rect[1]),
                                   max(self.update_bg[2], rect[2]),
                                   max(self.update_bg[3], rect[3]))
            else:
                self.update_bg = rect

            
    def in_update(self, x1, y1, x2, y2, update_area, full=FALSE):
        if full:
            for ux1, uy1, ux2, uy2 in update_area:
                # if the area is not complete inside the area but is inside on
                # some pixels, return FALSE
                if (not (ux1 >= x1 and uy1 >= y1 and ux2 <= x2 and uy2 <= y2)) and \
                   (not (x2 < ux1 or y2 < uy1 or x1 > ux2 or y1 > uy2)):
                    return FALSE
            return TRUE
        
        for ux1, uy1, ux2, uy2 in update_area:
            if not (x2 < ux1 or y2 < uy1 or x1 > ux2 or y1 > uy2):
                return TRUE
        return FALSE


    def show(self, force_redraw=FALSE):
        """
        the main drawing function
        """
        if osd.must_lock:
            self.s_bg.lock()
            self.s_alpha.lock()
            self.s_content.lock()
            osd.screen.lock()

        if force_redraw:
            _debug_('show, force update', 2)
            self.update_bg      = (0,0,osd.width, osd.height)
            self.update_alpha   = []
            self.update_content = []

        update_area = self.update_alpha

        # if the background has some changes ...
        if self.update_bg:
            ux1, uy1, ux2, uy2 = self.update_bg 
            for area in self.drawlist:
                for x1, y1, x2, y2, image in area.bgimages:
                    if not (x2 < ux1 or y2 < uy1 or x1 > ux2 or y1 > uy2):
                        self.s_bg.blit(image, (ux1, uy1), (ux1-x1, uy1-y1, ux2-ux1, 
uy2-uy1))

            update_area.append(self.update_bg)
            
        if update_area:
            # clear it
            self.s_alpha.fill((0,0,0,0))

            for area in self.drawlist:
                for x1, y1, x2, y2, bgcolor, size, color, radius in area.rectangles:
                    # only redraw if necessary
                    if self.in_update(x1, y1, x2, y2, update_area):
                        # if the radius and the border is not inside the update area,
                        # use drawbox, it's faster
                        if self.in_update(x1+size+radius, y1+size+radius, 
x2-size-radius,
                                          y2-size-radius, update_area, full=TRUE):
                            osd.drawroundbox(x1, y1, x2, y2, color=bgcolor,
                                             layer=self.s_alpha)
                        else:
                            osd.drawroundbox(x1, y1, x2, y2, color=bgcolor,
                                             border_size=size, border_color=color,
                                             radius=radius, layer=self.s_alpha)
            # and than blit only the changed parts of the screen
            for x0, y0, x1, y1 in update_area:
                self.s_content.blit(self.s_bg, (x0, y0), (x0, y0, x1-x0, y1-y0))
                self.s_content.blit(self.s_alpha, (x0, y0), (x0, y0, x1-x0, y1-y0))

        layer = self.s_content.convert()
        update_area += self.update_content

        # if something changed redraw all content objects
        if update_area:
            for area in self.drawlist:
                for x1, y1, x2, y2, image in area.images:
                    if self.in_update(x1, y1, x2, y2, update_area):
                        layer.blit(image, (x1, y1))

                for x1, y1, x2, y2, text, font, height, align_h, align_v, mode, \
                        ellipses in area.text:
                    if self.in_update(x1, y1, x2, y2, update_area):
                        width = x2 - x1
                        if font.shadow.visible:
                            width -= font.shadow.x
                            osd.drawstringframed(text, x1+font.shadow.x, 
y1+font.shadow.y,
                                                 width, height, font.font, 
font.shadow.color,
                                                 None, align_h = align_h, align_v = 
align_v,
                                                 mode=mode, ellipses=ellipses, 
layer=layer)
                        osd.drawstringframed(text, x1, y1, width, height, font.font,
                                             font.color, None, align_h = align_h,
                                             align_v = align_v, mode=mode,
                                             ellipses=ellipses, layer=layer)

        for x0, y0, x1, y1 in update_area:
            osd.screen.blit(layer, (x0, y0), (x0, y0, x1-x0, y1-y0))

        if osd.must_lock:
            self.s_bg.unlock()
            self.s_alpha.unlock()
            self.s_content.unlock()
            osd.screen.unlock()







-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to