def do_render(self, ctx, widget, background_area, cell_area, flags): if self.album == Type.NONE: return surface = Lp().art.get_album_artwork(Album(self.album), ArtSize.MEDIUM, widget.get_scale_factor()) width = surface.get_width() height = surface.get_height() # If cover smaller than wanted size, translate translate_x = cell_area.x translate_y = cell_area.y wanted = ArtSize.MEDIUM * widget.get_scale_factor() if width < wanted: translate_x += (wanted - width) / 2 if height < wanted: translate_y += (wanted - height) / 2 ctx.translate(translate_x, translate_y) ctx.new_sub_path() radius = 2 degrees = pi / 180 ctx.arc(width + 2 - radius, radius, radius - 0.5, -90 * degrees, 0 * degrees) ctx.arc(width + 2 - radius, height + 2 - radius, radius - 0.5, 0 * degrees, 90 * degrees) ctx.arc(radius, height + 2 - radius, radius - 0.5, 90 * degrees, 180 * degrees) ctx.arc(radius, radius, radius - 0.5, 180 * degrees, 270 * degrees) ctx.close_path() ctx.set_line_width(1) ctx.fill() ctx.set_source_surface(surface, 1, 1) del surface ctx.paint()
def do_render(self, ctx, widget, background_area, cell_area, flags): if self.album == Type.NONE: return surface = Lp().art.get_album_artwork(Album(self.album), ArtSize.MEDIUM, widget.get_scale_factor()) width = surface.get_width() height = surface.get_height() # If cover smaller than wanted size, translate translate_x = cell_area.x translate_y = cell_area.y wanted = ArtSize.MEDIUM * widget.get_scale_factor() if width < wanted: translate_x += (wanted - width) / 2 if height < wanted: translate_y += (wanted - height) / 2 ctx.translate(translate_x, translate_y) ctx.new_sub_path() radius = 2 degrees = pi / 180 ctx.arc(width + 2 - radius, radius, radius - 0.5, -90 * degrees, 0 * degrees) ctx.arc(width + 2 - radius, height + 2 - radius, radius - 0.5, 0 * degrees, 90 * degrees) ctx.arc(radius, height + 2 - radius, radius - 0.5, 90 * degrees, 180 * degrees) ctx.arc(radius, radius, radius - 0.5, 180 * degrees, 270 * degrees) ctx.close_path() ctx.set_line_width(1) ctx.fill() ctx.set_source_surface(surface, 1, 1) ctx.paint()
def update_cover(self): """ Update cover for album id id needed """ if self._cover is None: return surface = Lp().art.get_album_artwork(self._album, self._art_size, self._cover.get_scale_factor()) self._cover.set_from_surface(surface) if surface.get_height() > surface.get_width(): self._overlay_orientation = Gtk.Orientation.VERTICAL else: self._overlay_orientation = Gtk.Orientation.HORIZONTAL
def update_cover(self): """ Update cover for album id id needed """ if self._cover is None: return surface = Lp().art.get_album_artwork( self._album, ArtSize.BIG * self._cover.get_scale_factor()) self._cover.set_from_surface(surface) if surface.get_height() > surface.get_width(): self._overlay_orientation = Gtk.Orientation.VERTICAL else: self._overlay_orientation = Gtk.Orientation.HORIZONTAL del surface
def update_cover(self, album_id): """ Update cover for album id id needed @param album id as int """ if self._widget is None: return surface = Lp().art.get_album_artwork( self._album, ArtSize.BIG * self._cover.get_scale_factor()) self._cover.set_from_surface(surface) if surface.get_height() > surface.get_width(): self._set_overlay_orientation(Gtk.Orientation.VERTICAL) else: self._set_overlay_orientation(Gtk.Orientation.HORIZONTAL) del surface
def set_cover(self): """ Set cover for album if state changed """ if self._widget is None: return surface = Lp().art.get_album_artwork( self._album, ArtSize.BIG * self._cover.get_scale_factor()) self._cover.set_from_surface(surface) self._cover.set_size_request(100, 100) if surface.get_height() > surface.get_width(): self._set_overlay_orientation(Gtk.Orientation.VERTICAL) else: self._set_overlay_orientation(Gtk.Orientation.HORIZONTAL) del surface
def set_cover(self): """ Set cover for album if state changed """ if self._cover is None: return surface = Lp().art.get_album_artwork( self._album, ArtSize.BIG * self._cover.get_scale_factor()) self._cover.set_from_surface(surface) self._cover.set_size_request(100, 100) if surface.get_height() > surface.get_width(): self._overlay_orientation = Gtk.Orientation.VERTICAL else: self._overlay_orientation = Gtk.Orientation.HORIZONTAL del surface
def do_render(self, ctx, widget, background_area, cell_area, flags): size = ArtSize.MEDIUM * widget.get_scale_factor() surface = Lp().art.get_album_artwork(Album(self.album), size) width = surface.get_width() height = surface.get_height() ctx.translate(cell_area.x, cell_area.y) ctx.new_sub_path() radius = 2 degrees = pi / 180 ctx.arc(width + 2 - radius, radius, radius - 0.5, -90 * degrees, 0 * degrees) ctx.arc(width + 2 - radius, height + 2 - radius, radius - 0.5, 0 * degrees, 90 * degrees) ctx.arc(radius, height + 2 - radius, radius - 0.5, 90 * degrees, 180 * degrees) ctx.arc(radius, radius, radius - 0.5, 180 * degrees, 270 * degrees) ctx.close_path() ctx.set_line_width(1) ctx.fill() ctx.set_source_surface(surface, 1, 1) ctx.paint()