def expose(self, widget, event): if self.is_composited: cr = self.win.window.cairo_create() ## Full transparent window cr.set_source_rgba(0, 0, 0, 0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() else: self.opacity = 1 x, y, width, height = self.win.get_allocation() pixmap = gtk.gdk.Pixmap(None, width, height, 1) cr = pixmap.cairo_create() # Clear the bitmap to False cr.set_source_rgb(0, 0, 0) cr.set_operator(cairo.OPERATOR_DEST_OUT) cr.paint() ## Draw next over cr.set_operator(cairo.OPERATOR_OVER) rect = self.win.get_allocation() cr.set_source_rgb(1, 1, 1) if self.cfg['bar_style'] == 0: # Edgy draw.rounded_rect2(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) elif self.cfg['bar_style'] == 1: # Floaty draw.rounded_rect(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) else: draw.rounded_rect(cr, rect, 0, self.cfg['position'], fill=True) self.win.shape_combine_mask(pixmap, 0, 0) cr = self.win.window.cairo_create() if (self.bar_hidden and self.cfg['fade_hidden']) or not self.init_flag: return False ## Draw next over 'transparent window' cr.set_operator(cairo.OPERATOR_OVER) ## paint background cr.set_source_surface(self.bg_surface, 0, 0) cr.paint() if DEBUG: x, y, width, height = self.win.get_allocation() cr.set_source_rgb(1, 0.2, 0.2) cr.set_line_width(1) cr.rectangle(x, y, width, height) cr.stroke() x, y, width, height = self.plg_mgr.box.get_allocation() cr.set_source_rgb(0.2, 1, 0.2) cr.set_line_width(1) cr.rectangle(x, y, width, height) cr.stroke() return False
def draw_bg(self): if self.cfg["bar_style"] == 3 and not self.is_composited: self.cfg["bar_style"] == 2 if not self.is_composited: self.opacity = 1 else: self.opacity = self.cfg["opacity"] / 100.0 cr = cairo.Context(self.bg_surface) cr.set_source_rgba(0, 0, 0, 0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() cr.set_operator(cairo.OPERATOR_OVER) cr.set_line_width(1) if self.bar_hidden or not self.is_composited: rect = self.win.get_allocation() else: rect = self.draw_x, self.draw_y, self.draw_width, self.draw_height cr.save() r, g, b = self.cfg["bg_color_rgb"] cr.set_source_rgba(r, g, b, self.opacity) if self.cfg["bar_style"] == 0: # Edgy draw.rounded_rect2(cr, rect, self.cfg["rounded_corner"], self.cfg["position"], fill=True) elif self.cfg["bar_style"] == 1: # Floaty draw.rounded_rect(cr, rect, self.cfg["rounded_corner"], self.cfg["position"], fill=True) elif self.cfg["bar_style"] == 2: # 3d draw.trapeze(cr, rect, self.cfg["rounded_corner"], self.cfg["position"], fill=True) if self.cfg["bg_gradient"]: r1, g1, b2 = self.cfg["bg_gradient_color_rgb"] lg = draw.gradient_color2trans( r1, g1, b2, rect, self.cfg["bg_gradient_alpha"] / 65535.0, self.cfg["position"], invert=False ) cr.set_source(lg) if self.cfg["bar_style"] == 0: # Edgy draw.rounded_rect2(cr, rect, self.cfg["rounded_corner"], self.cfg["position"], fill=True) elif self.cfg["bar_style"] == 1: # Floaty draw.rounded_rect(cr, rect, self.cfg["rounded_corner"], self.cfg["position"], fill=True) elif self.cfg["bar_style"] == 2: # 3d draw.trapeze(cr, rect, self.cfg["rounded_corner"], self.cfg["position"], fill=True) if self.cfg["show_border"]: r, g, b = self.cfg["border_color_rgb"] cr.set_source_rgba(r, g, b, self.opacity) rect = rect[0] + 1, rect[1] + 1, rect[2] - 2, rect[3] - 2 if self.cfg["bar_style"] == 0: # Edgy draw.rounded_rect2(cr, rect, self.cfg["rounded_corner"], self.cfg["position"]) elif self.cfg["bar_style"] == 1: # Floaty draw.rounded_rect(cr, rect, self.cfg["rounded_corner"], self.cfg["position"]) elif self.cfg["bar_style"] == 2: # 3d draw.trapeze(cr, rect, self.cfg["rounded_corner"], self.cfg["position"])
def draw_bg(self): if self.cfg['bar_style'] == 3 and not self.is_composited: self.cfg['bar_style'] == 2 if not self.is_composited: self.opacity = 1 else: self.opacity = self.cfg['opacity'] / 100.0 cr = cairo.Context(self.bg_surface) cr.set_source_rgba(0, 0, 0, 0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() cr.set_operator(cairo.OPERATOR_OVER) cr.set_line_width(1) if self.bar_hidden or not self.is_composited: rect = self.win.get_allocation() else: rect = self.draw_x, self.draw_y, self.draw_width, self.draw_height cr.save() r, g, b = self.cfg['bg_color_rgb'] cr.set_source_rgba(r, g, b, self.opacity) if self.cfg['bar_style'] == 0: # Edgy draw.rounded_rect2(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) elif self.cfg['bar_style'] == 1: # Floaty draw.rounded_rect(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) elif self.cfg['bar_style'] == 2: # 3d draw.trapeze(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) if self.cfg['bg_gradient']: r1, g1, b2 = self.cfg['bg_gradient_color_rgb'] lg = draw.gradient_color2trans(r1, g1, b2, rect, self.cfg['bg_gradient_alpha'] / 65535.0, self.cfg['position'], invert=False) cr.set_source(lg) if self.cfg['bar_style'] == 0: # Edgy draw.rounded_rect2(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) elif self.cfg['bar_style'] == 1: # Floaty draw.rounded_rect(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) elif self.cfg['bar_style'] == 2: # 3d draw.trapeze(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) if self.cfg['show_border']: r, g, b = self.cfg['border_color_rgb'] cr.set_source_rgba(r, g, b, self.opacity) rect = rect[0] + 1, rect[1] + 1, rect[2] - 2, rect[3] - 2 if self.cfg['bar_style'] == 0: # Edgy draw.rounded_rect2(cr, rect, self.cfg['rounded_corner'], self.cfg['position']) elif self.cfg['bar_style'] == 1: # Floaty draw.rounded_rect(cr, rect, self.cfg['rounded_corner'], self.cfg['position']) elif self.cfg['bar_style'] == 2: # 3d draw.trapeze(cr, rect, self.cfg['rounded_corner'], self.cfg['position'])
def expose(self, widget, event): if self.is_composited: cr = self.win.window.cairo_create() ## Full transparent window cr.set_source_rgba(0, 0, 0, 0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() else: self.opacity = 1 x, y, width, height = self.win.get_allocation() pixmap = gtk.gdk.Pixmap(None, width, height, 1) cr = pixmap.cairo_create() # Clear the bitmap to False cr.set_source_rgb(0, 0, 0) cr.set_operator(cairo.OPERATOR_DEST_OUT) cr.paint() ## Draw next over cr.set_operator(cairo.OPERATOR_OVER) rect = self.win.get_allocation() cr.set_source_rgb(1, 1, 1) if self.cfg['bar_style'] == 0: # Edgy draw.rounded_rect2(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) elif self.cfg['bar_style'] == 1: # Floaty draw.rounded_rect(cr, rect, self.cfg['rounded_corner'], self.cfg['position'], fill=True) else: draw.rounded_rect(cr, rect, 0, self.cfg['position'], fill=True) self.win.shape_combine_mask(pixmap, 0, 0) cr = self.win.window.cairo_create() if (self.bar_hidden and self.cfg['fade_hidden']) or not self.init_flag: return False ## Draw next over 'transparent window' cr.set_operator(cairo.OPERATOR_OVER) ## paint background cr.set_source_surface(self.bg_surface, 0, 0) cr.paint() if DEBUG_WIDGET: x, y, width, height = self.win.get_allocation() cr.set_source_rgb(1, 0.2, 0.2) cr.set_line_width(1) cr.rectangle(x, y, width, height) cr.stroke() x, y, width, height = self.plg_mgr.box.get_allocation() cr.set_source_rgb(0.2, 1, 0.2) cr.set_line_width(1) cr.rectangle(x, y, width, height) cr.stroke() return False