def render(self, context, layout_manager, selected, hotspot, hover): layout_manager.set_text_color(context.style.text_color) bold = False if selected: bold = True if use_custom_tablist_font: layout_manager.set_text_color(self.SELECTED_FONT_COLOR) layout_manager.set_text_shadow( widgetutil.Shadow(self.SELECTED_FONT_SHADOW, 0.5, (0, 1), 0)) if not use_custom_tablist_font or getattr(self.data, 'tall', False): min_icon_width = self.MIN_ICON_WIDTH_TALL layout_manager.set_font(self.TALL_FONT_SIZE, bold=bold) else: min_icon_width = self.MIN_ICON_WIDTH layout_manager.set_font(self.FONT_SIZE, bold=bold) titlebox = layout_manager.textbox(self.data.name) hbox = cellpack.HBox(spacing=4) self.pack_leading_space(hbox) if selected and hasattr(self.data, 'active_icon'): icon = self.data.active_icon else: icon = self.data.icon alignment = cellpack.Alignment(icon, yalign=0.5, yscale=0.0, xalign=0.0, xscale=0.0, min_width=min_icon_width) hbox.pack(alignment) # morgan wants the text to be 1px higher than align_middle() would # place it, so we align to slightly less than 0.5 alignment = cellpack.Alignment(cellpack.TruncatedTextLine(titlebox), yalign=0.45, yscale=0.0) hbox.pack(alignment, expand=True) layout_manager.set_font(0.77, bold=True) self.pack_bubbles(hbox, layout_manager, selected=selected) hbox.pack_space(2) alignment = cellpack.Alignment(hbox, yscale=0.0, yalign=0.5) if self.blink: renderer = cellpack.Background(alignment) renderer.set_callback(self.draw_blink_background) else: renderer = alignment renderer.render_layout(context)
def pack_bubbles(self, hbox, layout_manager, selected=False): if getattr(self.data, 'fake', False): return self.hbox = None if self.updating_frame > -1: return TabRenderer.pack_bubbles(self, hbox, layout_manager) if getattr(self.data, 'mount', None): eject_image = widgetutil.make_surface('icon-eject') hotspot = cellpack.Hotspot('eject-device', eject_image) alignment = cellpack.Alignment(hotspot, yalign=0.5, yscale=0.0, xalign=0.0, xscale=0.0, min_width=20) hbox.pack(alignment) self.hbox = hbox
def pack_bubbles(self, hbox, layout_manager, selected=False): if self.updating_frame > -1: image_name = 'icon-updating-%s' % self.updating_frame updating_image = widgetutil.make_surface(image_name) alignment = cellpack.Alignment(updating_image, yalign=0.5, yscale=0.0, xalign=0.0, xscale=0.0, min_width=20) hbox.pack(alignment) elif self.data.unwatched > 0: self.pack_bubble(hbox, layout_manager, self.data.unwatched, UNPLAYED_COLOR, selected=selected) if self.data.downloading > 0: self.pack_bubble(hbox, layout_manager, self.data.downloading, DOWNLOADING_COLOR, selected=selected)