~glitter-team/glitter/trunk

« back to all changes in this revision

Viewing changes to glitter/data/themes/nublo/resources/slider_range_texture_normal.py

  • Committer: Jan Jokela
  • Date: 2008-12-10 22:18:59 UTC
  • Revision ID: janjokela@gmail.com-20081210221859-zxr2ut255a7xu15x
Hi, Glitter here

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# !/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# nublo
 
5
# a redefinition of senses
 
6
        
 
7
__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
 
8
__licenses__ = ["LICENSE.LGPL"]
 
9
__description__ = "Slider filled area texture"
 
10
 
 
11
import math
 
12
import clutter
 
13
import cairo
 
14
from cluttercairo import CairoTexture
 
15
 
 
16
class Texture(CairoTexture):
 
17
    """ A CairoTexture for the filled area of a slider """
 
18
 
 
19
    def __init__(self, width, height):
 
20
        
 
21
        if width is 0 or height is 0:
 
22
            width = 1
 
23
            height = 1
 
24
        
 
25
        CairoTexture.__init__(self, width, height)
 
26
        
 
27
        self.width = width
 
28
        self.height = height
 
29
        
 
30
        self.context = self.cairo_create()
 
31
        
 
32
        #self.context.set_line_width(self.height * 0.01)
 
33
        #self.context.set_source_rgba(1.0, 1.0, 1.0, 1.0)
 
34
        #self.context.rectangle(0.0, 0.0, self.width, self.height)
 
35
        
 
36
        linpat = cairo.LinearGradient(self.width / 2.0, 0.0, self.width / 2.0, self.height);
 
37
 
 
38
        linpat.add_color_stop_rgba (0.0,  0.7, 0.7, 1.0, 1.0);
 
39
        linpat.add_color_stop_rgba (0.45,  0.5, 0.5, 0.8, 1.0);
 
40
        linpat.add_color_stop_rgba (0.45,  0.5, 0.5, 0.8, 1.0);
 
41
        linpat.add_color_stop_rgba (0.55,  0.1, 0.1, 0.5, 1.0);
 
42
        linpat.add_color_stop_rgba (0.55,  0.1, 0.1, 0.5, 1.0);
 
43
        linpat.add_color_stop_rgba (1.0,  0.3, 0.3, 0.7, 1.0);
 
44
        
 
45
        self.context.arc(self.height * 0.5, self.height * 0.5, 
 
46
                         self.height * 0.5, math.pi, 3.0 * math.pi / 2.0)
 
47
        self.context.line_to(self.width, 0.0)
 
48
        self.context.line_to(self.width, self.height)
 
49
        self.context.line_to(self.height * 0.5, self.height)
 
50
        self.context.arc(self.height * 0.5,
 
51
                         self.height - (self.height * 0.5), 
 
52
                         self.height * 0.5, 
 
53
                         math.pi / 2.0, 
 
54
                         math.pi)
 
55
        
 
56
        self.context.close_path()
 
57
        #self.context.set_source_rgba(0.0, 1.0, 0.0, 1.0)
 
58
        self.context.set_source(linpat)
 
59
        self.context.fill()
 
60
        
 
61
        self.context.stroke()
 
62
        del self.context
 
63
          
 
64
    def update(self):
 
65
 
 
66
        pass
 
67