Changeset 3638
- Timestamp:
- 18/10/08 17:58:14 (3 months ago)
- Location:
- trunk/candy/src/widgets
- Files:
-
- 2 modified
-
image.py (modified) (2 diffs)
-
rectangle.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/candy/src/widgets/image.py
r3586 r3638 131 131 """ 132 132 133 _clutter_resize_surface = True134 133 135 134 def _clutter_render(self): … … 138 137 """ 139 138 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) 145 141 self._obj.show() 146 142 return -
trunk/candy/src/widgets/rectangle.py
r3586 r3638 34 34 # kaa.candy imports 35 35 from ..core import Color 36 from .. import backend 36 37 from image import CairoTexture 37 38 … … 109 110 Render the widget 110 111 """ 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 115 126 super(Rectangle, self)._clutter_render() 116 127 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.Rectangle120 # would be faster here but we do not need that much normal121 # rectangles and it would make things more complicated122 context.set_source_rgba(*self.__color.to_cairo())123 context.paint()124 return125 126 128 stroke = self.__border_size or 1 127 129 width = self.inner_width - 2 * stroke 128 130 height = self.inner_height - 2 * stroke 129 131 radius = min(self.__radius, width, height) 130 131 132 x0 = stroke 132 133 y0 = stroke 133 134 x1 = x0 + width 134 135 y1 = y0 + height 135 136 136 if self.__color: 137 137 context.set_source_rgba(*self.__color.to_cairo()) … … 147 147 context.close_path() 148 148 context.fill() 149 150 149 if self.__border_size and self.__border_color: 151 150 context.set_source_rgba(*self.__border_color.to_cairo()) … … 161 160 context.close_path() 162 161 context.stroke() 163 164 162 del context 165 163
