示例#1
0
 def pack_bubble(self, hbox, layout_manager, count, color, selected=False):
     radius = int(layout_manager.current_font.line_height() / 2.0) + 1
     if selected:
         layout_manager.set_text_color(widgetutil.BLACK)
         layout_manager.set_text_shadow(None)
         color = widgetutil.WHITE
     else:
         layout_manager.set_text_color(widgetutil.WHITE)
         layout_manager.set_text_shadow(
             widgetutil.Shadow(self.SELECTED_FONT_SHADOW, 0.5, (0, 1), 0))
     if PLATFORMNAME == 'windows':
         # XXX FIXME HACK For 17305, the bubble text needs to move
         # up 2px on Windows.  I can't figure out what the
         # difference is between Linux and Windows; it's not
         # miro.plat.frontends.widgets.use_custom_tablist_font.
         # Either way, there are better things to be spending time
         # on right now.
         bottom_extra = 2
     else:
         bottom_extra = 0
     if PLATFORMNAME == 'osx':
         # XXX FIXME HACK 17305, text on OSX needs to move 1px to the left
         left_extra = 0.5
     else:
         left_extra = 0
     if self.is_tall():
         margin = (0, radius + left_extra, 2 + bottom_extra,
                   radius - left_extra)
     else:
         margin = (1, radius + left_extra, 1 + bottom_extra,
                   radius - left_extra)
     background = cellpack.Background(layout_manager.textbox(str(count)),
                                      margin=margin)
     background.set_callback(self.draw_bubble, color)
     hbox.pack(cellpack.align_middle(background))
示例#2
0
 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)