181
206
def genBuff(self):
182
207
width=self.get_size()
183
208
self.modwidth=width
209
darkmulti=(1-self.darkness/10)
211
#logger.info(darkmulti)
185
212
hh=[0.2,0.4,0.7,0.8,0.9,1,1,0.98,0.93,0.85,0.80,0.80,0.80,
186
213
0.85,0.93,0.98,1,1,0.9,0.8,0.7,0.6,0.4,0.2]
187
214
#hh=[0.5,0.55,0.6,0.65,0.7,1,0.95,0.92,0.88,0.84,0.80,0.80,
188
#0.80,0.84,0.88,0.92,0.95,1,0.7,0.65,0.6,0.55,0.5,0.45]
215
#0.80,0.84,0.88,0.92,0.95,1,0.7,0.65,0.6,0.55,0.5,0.45]
189
216
#hh=[0.2,0.4,0.7,0.8,0.9,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9,0.8,
192
for x in range(width):
195
self.moodbar[int(x*1000/width)*3+i])*hh[h]))
218
self.defaultstyle_old =self.defaultstyle
219
self.theme_old=self.theme
220
self.flat_old=self.flat
221
self.color_old =self.color
222
self.darkness_old =self.darkness
223
self.cursor_old=self.cursor
225
self.bgcolor = self.mod.style.bg[gtk.STATE_NORMAL]
226
redf=self.bgcolor.red/255
227
greenf=self.bgcolor.green/255
228
bluef=self.bgcolor.blue/255
229
colortheme=gtk.gdk.Color(self.color)
230
c1,self.ivalue,self.qvalue=colorsys.rgb_to_yiq(float(colortheme.red)/256/256, float(colortheme.green)/256/256, float(colortheme.blue)/256/256)
231
gc.foreground = self.bgcolor;
233
self.pixmap = gtk.gdk.Pixmap(self.mod.window, width, 24)
234
self.pixmap2 = gtk.gdk.Pixmap(self.mod.window, width, 24)
235
self.pixmap.draw_rectangle(gc, True, 0, 0, self.modwidth, 24)
236
self.pixmap2.draw_rectangle(gc, True, 0, 0, self.modwidth, 24)
239
flatcolor1r=float(colortheme.red)/256/256
240
flatcolor1g=float(colortheme.green)/256/256
241
flatcolor1b=float(colortheme.blue)/256/256
242
flatcolor2r=darkmulti*float(colortheme.red)/256/256
243
flatcolor2g=darkmulti*float(colortheme.green)/256/256
244
flatcolor2b=darkmulti*float(colortheme.blue)/256/256
246
flatcolor1r=flatcolor1g=flatcolor1b=0.5
247
flatcolor2r=flatcolor2g=flatcolor2b=0.5*darkmulti
248
#render ---------------------------------------------------------
249
for x in range(width):
251
r=float(ord(self.moodbar[int(x*1000/width)*3]))/256
252
g=float(ord(self.moodbar[int(x*1000/width)*3+1]))/256
253
b=float(ord(self.moodbar[int(x*1000/width)*3+2]))/256
254
if (self.theme or self.defaultstyle):
255
c1,c2,c3=colorsys.rgb_to_yiq(r, g, b)
264
if self.defaultstyle:
265
r,g,b=colorsys.yiq_to_rgb(0.5,c2,c3)
266
waluelength=int(c1*24)
269
r,g,b=colorsys.yiq_to_rgb(c1,c2,c3)
270
if not self.defaultstyle:
273
buff=buff+chr(int(r*255*hh[h]+redf*(1-hh[h])))+chr(int(g*255*hh[h]+greenf*(1-hh[h])))+chr(int(b*255*hh[h]+bluef*(1-hh[h])))
274
self.pixmap.draw_rgb_image(gc, x, 0, 1, 24,
275
gtk.gdk.RGB_DITHER_NONE, buff, 3)
279
for h in range(24*3):
280
buff2=buff2+chr(int(ord(buff[h])*(darkmulti+(1-darkmulti)*(1-hh[int(h/3)]))))
282
self.pixmap2.draw_rgb_image(gc, x, 0, 1, 24,
283
gtk.gdk.RGB_DITHER_NONE, buff2, 3)
287
gc.foreground = self.mod.get_colormap().alloc_color(
288
int(flatcolor1r*0xFFFF), int(flatcolor1g*0xFFFF), int(flatcolor1b*0xFFFF))
290
gc.foreground = self.mod.get_colormap().alloc_color(
291
int(r*0xFFFF), int(g*0xFFFF), int(b*0xFFFF))
292
self.pixmap.draw_line(gc, x, 13-waluelength, x, 12+waluelength)
296
gc.foreground = self.mod.get_colormap().alloc_color(
297
int(flatcolor2r*0xFFFF), int(flatcolor2g*0xFFFF), int(flatcolor2b*0xFFFF))
299
r,g,b=colorsys.yiq_to_rgb(0.5*darkmulti,c2,c3)
300
gc.foreground = self.mod.get_colormap().alloc_color(
301
int(r*0xFFFF), int(g*0xFFFF), int(b*0xFFFF))
302
self.pixmap2.draw_line(gc, x, 13-waluelength, x, 12+waluelength)
304
#if not self.defaultstyle:
305
# self.pixmap2.draw_drawable(gc,self.pixmap, 0, 0, 0, 0, self.modwidth, 24)
306
# gc.foreground = self.mod.get_colormap().alloc_color(
307
# int(0xCCCC*darkmulti), int(0xCCCC*darkmulti), int(0xCCCC*darkmulti))
308
# gc.function=gtk.gdk.AND
309
# self.pixmap2.draw_rectangle(gc, True, 0, 0, self.modwidth, 24)
310
# gc.function=gtk.gdk.COPY
199
314
#Drawing mood UI---------------------------------------------------------
201
316
def drawMod(self,this,area):
317
darkmulti=(1-self.darkness/10)
320
self.bgcolor = self.mod.style.bg[gtk.STATE_NORMAL]
321
redf=self.bgcolor.red
322
greenf=self.bgcolor.green
323
bluef=self.bgcolor.blue
206
gc.foreground = this.get_colormap().alloc_color(0x0000,
326
gc.foreground = this.get_colormap().alloc_color(0x0000,
208
328
track = self.exaile.player.current
330
flatcolor1r,flatcolor1g,flatcolor1b=colorsys.yiq_to_rgb(0.5,self.ivalue,self.qvalue)
331
flatcolor2r,flatcolor2g,flatcolor2b=colorsys.yiq_to_rgb(0.5*darkmulti,self.ivalue,self.qvalue)
333
flatcolor1r=flatcolor1g=flatcolor1b=0.5
334
flatcolor2r=flatcolor2g=flatcolor2b=0.5*darkmulti
211
if not self.get_size()==self.modwidth:
337
if not self.get_size()==self.modwidth:
212
338
self.buff=self.genBuff()
339
if (not self.defaultstyle==self.defaultstyle_old or
340
not self.theme==self.theme_old or
341
not self.flat==self.flat_old or
342
not self.color==self.color_old or
343
not self.darkness==self.darkness_old or
344
not self.cursor==self.cursor_old):
345
self.buff=self.genBuff()
213
346
if (self.haveMod):
214
this.window.draw_rgb_image(gc, 0, 0, self.modwidth, 24,
215
gtk.gdk.RGB_DITHER_NONE, self.buff, self.modwidth*3)
347
this.window.draw_drawable(gc,self.pixmap, 0, 0, 0, 0, self.modwidth, 24)
219
gc.foreground = this.get_colormap().alloc_color(0xAAAA*i/5,
220
0xAAAA*i/5, 0xAAAA*i/5)
221
this.window.draw_rectangle(gc, True, 0, 0+i,
350
if not self.defaultstyle:
352
gc.foreground = this.get_colormap().alloc_color(int(flatcolor1r*0xFFFF*i/5+redf*((5-float(i))/5)),
353
int(flatcolor1g*0xFFFF*i/5+greenf*((5-float(i))/5)), int(flatcolor1b*0xFFFF*i/5+bluef*((5-float(i))/5)) )
354
this.window.draw_rectangle(gc, True, 0, 0+i,
222
355
self.modwidth, 24-i*2)
224
if self.modTimer and track.is_local():
225
gc.foreground = this.get_colormap().alloc_color(0xBBBB,
227
this.window.draw_rectangle(gc, True,
228
(self.modwidth/10)*(self.uptime%10),
357
if self.modTimer and track.is_local():
358
gc.foreground = this.get_colormap().alloc_color(flatcolor2r*0xFFFF,
359
flatcolor2g*0xFFFF, flatcolor2b*0xFFFF)
360
this.window.draw_rectangle(gc, True,
361
(self.modwidth/10)*(self.uptime%10),
229
362
5, self.modwidth/10, 14)
363
if self.defaultstyle:
364
gc.foreground = this.get_colormap().alloc_color(flatcolor1r*0xFFFF,
365
flatcolor1g*0xFFFF, flatcolor1b*0xFFFF)
366
this.window.draw_rectangle(gc, True,
367
0,12, self.modwidth, 2)
234
gc.foreground = this.get_colormap().alloc_color(0xFFFF*i/5,
371
gc.foreground = this.get_colormap().alloc_color(0xFFFF*i/5,
236
this.window.draw_rectangle(gc, True, 0, 0+i,
237
self.modwidth, 24-i*2)
239
if track and track.is_local():
240
self.lookformod(track)
373
this.window.draw_rectangle(gc, True, 0, 0+i,
374
self.modwidth, 24-i*2)
376
#if track and track.is_local():
377
#self.lookformod(track)
244
381
track = self.exaile.player.current
245
if not track or not track.is_local(): return
382
if not track or not (track.is_local() or \
383
track.get_tag_raw('__length')): return
247
385
if self.modTimer:
248
gc.foreground = this.get_colormap().alloc_color(0xFFFF,
251
this.window.draw_arc(gc, True, int(self.curpos*self.modwidth)-15,
252
-5, 30, 30, 60*64, 60*64)
253
gc.foreground = this.get_colormap().alloc_color(0x0000,
388
if not self.defaultstyle:
390
gc.foreground = this.get_colormap().alloc_color(flatcolor2r*0xFFFF*i/5+int(redf*((5-float(i))/5)),
391
flatcolor2g*0xFFFF*i/5+int(greenf*((5-float(i))/5)), flatcolor2b*0xFFFF*i/5+int(bluef*((5-float(i))/5)) )
392
this.window.draw_rectangle(gc, True, 0, 0+i,
393
int(self.curpos*self.modwidth), 24-i*2)
395
gc.foreground = this.get_colormap().alloc_color(flatcolor2r*0xFFFF,
396
flatcolor2g*0xFFFF, flatcolor2b*0xFFFF)
397
this.window.draw_rectangle(gc, True,
398
0,12, int(self.curpos*self.modwidth), 2)
400
this.window.draw_drawable(gc,self.pixmap2, 0, 0, 0, 0, int(self.curpos*self.modwidth), 24)
404
gc.foreground = self.bgcolor;
406
this.window.draw_arc(gc, True, int(self.curpos*self.modwidth)-15,
407
-5, 30, 30, 60*64, 60*64)
408
gc.foreground = this.get_colormap().alloc_color(0x0000,
256
this.window.draw_line(gc, int(self.curpos*self.modwidth), 10,
411
this.window.draw_line(gc, int(self.curpos*self.modwidth), 10,
257
412
int(self.curpos*self.modwidth)-10, -5)
258
this.window.draw_line(gc, int(self.curpos*self.modwidth), 10,
413
this.window.draw_line(gc, int(self.curpos*self.modwidth), 10,
259
414
int(self.curpos*self.modwidth)+10, -5)
261
416
length = self.exaile.player.current.get_duration()
262
417
seconds = self.exaile.player.get_time()
263
418
remaining_seconds = length - seconds
264
419
text = ("%d:%02d / %d:%02d" %
265
( seconds // 60, seconds % 60, remaining_seconds // 60,
266
remaining_seconds % 60))
420
( seconds // 60, seconds % 60, remaining_seconds // 60,
421
remaining_seconds % 60))
422
gc.foreground = this.get_colormap().alloc_color(0x0000,
268
424
this.pangolayout.set_text(text)
269
this.window.draw_layout(gc, self.modwidth/2-50,
271
this.window.draw_layout(gc, self.modwidth/2-52,
273
gc.foreground = this.get_colormap().alloc_color(0xFFFF,
276
this.window.draw_layout(gc, self.modwidth/2-51,
426
this.window.draw_layout(gc, int(self.modwidth/2)-35,
428
this.window.draw_layout(gc, int(self.modwidth/2)-37,
430
this.window.draw_layout(gc, int(self.modwidth/2)-35,
432
this.window.draw_layout(gc, int(self.modwidth/2)-37,
434
gc.foreground = this.get_colormap().alloc_color(0xFFFF,
437
this.window.draw_layout(gc, int(self.modwidth/2)-36,
280
441
#seeking-----------------------------------------------------------------
282
443
def modSeekBegin(self,this,event):