예제 #1
0
파일: buttons.py 프로젝트: Peeveli/puavo-os
 def draw_icon(self, ctx):
     if self.icon:
         self.icon.draw(ctx, self.icon_pos[0], self.icon_pos[1])
     else:
         utils_gui.draw_x(ctx,
                          self.icon_pos[0], self.icon_pos[1],
                          self.icon_size, self.icon_size,
                          self.icon_color)
예제 #2
0
 def draw_icon(self, ctx):
     if self.icon:
         ctx.set_source_surface(self.icon, 0, 0)
         ctx.rectangle(0, 0, self.ICON_SIZE, self.ICON_SIZE)
         ctx.fill()
     else:
         utils_gui.draw_x(ctx, self.icon_pos[0], self.icon_pos[1],
                          self.icon_size, self.icon_size, self.icon_color)
예제 #3
0
    def draw_icon(self, ctx):
        if self.icon:
            self.icon.draw(ctx, self.icon_pos[0], self.icon_pos[1])
        else:
            utils_gui.draw_x(ctx, self.icon_pos[0], self.icon_pos[1],
                             self.icon_size, self.icon_size, self.icon_color)

        if self.disabled:
            # hack to make the icon look "grayed out"
            # not a very good hack as the rectangle is quite visible
            ctx.set_source_rgba(0.96, 0.96, 0.96, 0.75)
            ctx.rectangle(self.icon_pos[0], self.icon_pos[1], self.icon_size,
                          self.icon_size)
            ctx.fill()
예제 #4
0
    def draw_icon(self, ctx, icon, x, y):
        """Draws the icon onto the Cairo context at the specified
        coordinates."""

        if (not isinstance(icon, Icon)) or \
                (not icon.usable) or \
                (icon.size != self.__icon_size) or \
                (icon.index < 0) or (icon.index > len(self.__icons) - 1):
            draw_x(ctx, x, y, self.__icon_size, self.__icon_size)
        else:
            slot = self.__icons[icon.index]

            # https://www.cairographics.org/FAQ/#paint_from_a_surface
            ctx.set_source_surface(self.__atlas_surface, x - slot.x, y - slot.y)
            ctx.rectangle(x, y, self.__icon_size, self.__icon_size)
            ctx.fill()