157
def _paint_star_interactive(self, cr, widget, state, x, y, w, h, alpha):
158
# XXX: a bit of a mess, but i'm in a rush ...
163
def _paint_star_interactive(self, cr, widget, state, *args):
164
if state == gtk.STATE_ACTIVE:
165
self._paint_star_interactive_in(cr, widget, state, *args)
167
self._paint_star_interactive_out(cr, widget, state, *args)
170
def _paint_star_interactive_out(self, cr, widget, state, x, y, w, h, alpha):
161
171
shape = self.shape
173
# define the color palate
174
if self.fill == self.FILL_FULL:
175
grad0 = white = color_floats(widget.style.white)
176
grad1 = dark = color_floats('#B54D00') # brownish
178
if state == gtk.STATE_PRELIGHT:
179
fill = alpha_composite(self.fg_color+(0.75,), (1,1,1))
187
grad0, grad1 = theme.gradients[state]
188
grad0 = grad0.floats()
189
grad1 = grad1.floats()
191
white = theme.light_line[state].floats()
192
dark = theme.dark_line[state].floats()
165
195
cr.set_line_join(cairo.LINE_CAP_ROUND)
168
197
if not self.border:
169
shape.layout(cr, 0, 1, w, h)
170
cr.set_source_rgba(*color_floats(widget.style.white)+(0.8,))
199
shape.layout(cr, x, y+1, w, h)
201
light = self.theme.light_line[state].floats()
202
cr.set_source_rgba(*light + (0.9,))
173
shape.layout(cr, 0, 0, w, h)
174
lin = cairo.LinearGradient(0, 0, 0, h)
176
# bg linear vertical gradient
177
if self.fill == self.FILL_FULL:
179
if state == gtk.STATE_PRELIGHT:
180
color1 = alpha_composite(self.fg_color+(0.40,), (1,1,1))
181
color2 = alpha_composite(color1+(0.7,), (1,0,0))
183
elif state == gtk.STATE_ACTIVE:
184
color1 = color2 = alpha_composite(self.fg_color+(0.75,), (1,0,0))
186
else: # gtk state normal
187
color2 = alpha_composite(self.fg_color+(0.75,), (1,0,0))
188
color1 = alpha_composite(self.fg_color+(0.50,), (1,1,1))
191
color1, color2 = theme.gradients[state]
192
color1 = color1.floats()
193
color2 = color2.floats()
195
lin.add_color_stop_rgb(0.0, *color1)
196
lin.add_color_stop_rgb(1.0, *color2)
205
shape.layout(cr, x+1, y+1, w-2, h-2)
207
cr.set_source_rgb(*dark)
212
shape.layout(cr, x+1, y+1, w-2, h-2)
213
cr.set_source_rgb(*fill)
216
lin = cairo.LinearGradient(x, y, x, y+h)
217
lin.add_color_stop_rgba(0.0, *white + (0.5,))
218
lin.add_color_stop_rgba(1.0, *dark + (0.3,))
198
220
cr.set_source(lin)
202
shape.layout(cr, 2, 2, w-4, h-4)
203
if state != gtk.STATE_ACTIVE:
205
inline = theme.light_line[state].floats()
206
lin = cairo.LinearGradient(0, 0, 0, h)
207
lin.add_color_stop_rgba(0.0, *inline+(0.7,))
208
lin.add_color_stop_rgba(1.0, *inline+(0.1,))
211
if self.border == self.BORDER_ON:
212
outline = theme.theme.base[gtk.STATE_SELECTED].floats()
214
outline = theme.dark_line[state].floats()
218
if self.fill != self.FILL_FULL:
219
inline = outline = theme.dark_line[state].floats()
222
# state active, i.e. button is pressed in
223
brown = color_floats('#B54D00')
224
outline = alpha_composite(self.fg_color+(0.1,), brown)
225
inline = alpha_composite(self.fg_color+(0.05,), brown)
229
cr.set_source_rgba(*inline+(0.2,))
234
cr.set_source_rgba(*inline+(0.3,))
237
223
cr.set_line_width(1)
240
shape.layout(cr, 0.5, 0.5, w-1, h-1)
241
cr.set_source_rgb(*outline)
225
shape.layout(cr, x+1.5, y+1.5, w-3, h-3)
226
lin = cairo.LinearGradient(x, y, x, y+h)
227
lin.add_color_stop_rgba(0.0, *white + (0.6,))
228
lin.add_color_stop_rgba(1.0, *white + (0.15,))
234
def _paint_star_interactive_in(self, cr, widget, state, x, y, w, h, alpha):
237
# define the color palate
238
#~ black = color_floats(widget.style.black)
240
if self.fill == self.FILL_FULL:
241
white = color_floats(widget.style.white)
242
dark = color_floats('#B54D00') # brownish
243
darker = alpha_composite(dark+(0.65,), (0,0,0))
244
grad0 = grad1 = alpha_composite(self.fg_color+(0.9,), dark)
248
white = theme.light_line[state].floats()
249
dark = darker = theme.dark_line[state].floats()
250
grad0, grad1 = theme.gradients[state]
251
grad0 = grad0.floats()
252
grad1 = grad1.floats()
254
cr.set_line_join(cairo.LINE_CAP_ROUND)
256
shape.layout(cr, x+1, y+1, w-2, h-2)
257
cr.set_source_rgba(*dark+(0.35,))
262
cr.set_source_rgba(*dark+(0.8,))
266
self.shape.layout(cr, x+1, y+1, w-2, h-2)
268
lin = cairo.LinearGradient(x, y, x, y+h)
269
lin.add_color_stop_rgb(0.0, *grad0)
270
lin.add_color_stop_rgb(1.0, *grad1)
276
self.shape.layout(cr, x+1, y+1, w-2, h-2)
278
lin = cairo.LinearGradient(x, y, x, y+h)
279
lin.add_color_stop_rgba(0.0, *darker+(0.175,))
280
lin.add_color_stop_rgba(1.0, *darker+(0.05,))
283
#~ cr.set_source_rgba(*darker+(0.1*alpha,))
287
def _paint_star_big(self, cr, widget, state, x, y, w, h, alpha):
288
if self.fill == self.FILL_FULL:
290
dark = color_floats('#B54D00') # brownish
294
white = color_floats(widget.style.white)
295
dark = self.theme.dark_line[state].floats()
296
grad0, grad1 = self.theme.gradients[state]
297
fill = alpha_composite(grad0.floats()+(0.5,),
300
cr.set_line_join(cairo.LINE_CAP_ROUND)
301
self.shape.layout(cr, x+2, y+2, w-4, h-4)
303
cr.set_source_rgba(*white+(0.2,))
307
cr.set_source_rgba(*white+(0.5,))
311
cr.set_source_rgba(*dark+(0.8,))
315
cr.set_source_rgb(*fill)
321
lin = cairo.LinearGradient(x, y, x, y+h)
322
lin.add_color_stop_rgba(0.0, *white+(0.45,))
323
lin.add_color_stop_rgba(1.0, *white+(0.0,))
247
329
def set_paint_style(self, paint_style):