Changeset 3638

Show
Ignore:
Timestamp:
18/10/08 17:58:14 (3 months ago)
Author:
dmeyer
Message:

use clutter.Rectangle for radius=0

Location:
trunk/candy/src/widgets
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/candy/src/widgets/image.py

    r3586 r3638  
    131131    """ 
    132132 
    133     _clutter_resize_surface = True 
    134133 
    135134    def _clutter_render(self): 
     
    138137        """ 
    139138        if self._obj is None: 
    140             if self._clutter_resize_surface: 
    141                 self._obj = backend.CairoTexture(self.inner_width, self.inner_height) 
    142             else: 
    143                 self._obj = backend.CairoTexture(10, 10) 
    144                 self._obj.set_size(self.inner_width, self.inner_height) 
     139            self._obj = backend.CairoTexture(10, 10) 
     140            self._obj.set_size(self.inner_width, self.inner_height) 
    145141            self._obj.show() 
    146142            return 
  • trunk/candy/src/widgets/rectangle.py

    r3586 r3638  
    3434# kaa.candy imports 
    3535from ..core import Color 
     36from .. import backend 
    3637from image import CairoTexture 
    3738 
     
    109110        Render the widget 
    110111        """ 
    111         if not self.__border_size and not self.__radius: 
    112             # FIXME: update this variable when border_size or radius 
    113             # change. This makes drawing MUCH faster. 
    114             self._clutter_resize_surface = False 
     112        if not self.__radius: 
     113            # Use a clutter Rectangle here to make it faster 
     114            # FIXME: change _obj radius changes 
     115            if self._obj is None: 
     116                self._obj = backend.Rectangle() 
     117                self._obj.show() 
     118            self._obj.set_size(self.inner_width, self.inner_height) 
     119            self._obj.set_color(backend.Color(*self.__color)) 
     120            if self.__border_color and self.__border_size: 
     121                self._obj.set_border_width(self.__border_size) 
     122                self._obj.set_border_color(backend.Color(*self.__border_color)) 
     123            else: 
     124                self._obj.set_border_width(0) 
     125            return 
    115126        super(Rectangle, self)._clutter_render() 
    116127        context = self._obj.cairo_create() 
    117  
    118         if not self.__border_size and not self.__radius: 
    119             # A simple fill on the surface. Using clutter.Rectangle 
    120             # would be faster here but we do not need that much normal 
    121             # rectangles and it would make things more complicated 
    122             context.set_source_rgba(*self.__color.to_cairo()) 
    123             context.paint() 
    124             return 
    125  
    126128        stroke = self.__border_size or 1 
    127129        width  = self.inner_width - 2 * stroke 
    128130        height = self.inner_height - 2 * stroke 
    129131        radius = min(self.__radius, width, height) 
    130  
    131132        x0 = stroke 
    132133        y0 = stroke 
    133134        x1 = x0 + width 
    134135        y1 = y0 + height 
    135  
    136136        if self.__color: 
    137137            context.set_source_rgba(*self.__color.to_cairo()) 
     
    147147            context.close_path() 
    148148            context.fill() 
    149  
    150149        if self.__border_size and self.__border_color: 
    151150            context.set_source_rgba(*self.__border_color.to_cairo()) 
     
    161160            context.close_path() 
    162161            context.stroke() 
    163  
    164162        del context 
    165163