Ejemplo n.º 1
0
 def expose_droplist_item(self, widget, event, item_content):
     '''Expose droplist item.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     font_color = ui_theme.get_color("menu_font").get_color()
     
     # Draw select effect.
     if self.subdroplist_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]:
         # Draw background.
         draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, 
                      ui_theme.get_shadow_color("menu_item_select").get_color_info())
         
         # Set font color.
         font_color = ui_theme.get_color("menu_select_font").get_color()
         
     # Draw item content.
     draw_text(cr, item_content, 
                 rect.x + self.item_padding_left,
                 rect.y,
                 rect.width,
                 rect.height,
                 self.font_size, font_color,
                 )
     
     # Propagate expose to children.
     propagate_expose(widget, event)
 
     return True
Ejemplo n.º 2
0
    def render(self, cr, rect):
        '''
        Render icon and name of DirItem.
        '''
        # Draw select background.
        if self.is_button_press == True:
            draw_vlinear(
                cr, rect.x, rect.y, rect.width, rect.height,
                ui_theme.get_shadow_color("listview_select").get_color_info())

        # Draw directory icon.
        draw_pixbuf(
            cr,
            self.pixbuf,
            rect.x + self.icon_size / 2,
            rect.y + (rect.height - self.icon_size) / 2,
        )

        # Draw directory name.
        draw_text(cr,
                  self.name,
                  rect.x,
                  rect.y + self.icon_size + ITEM_PADDING_Y * 2,
                  rect.width,
                  DEFAULT_FONT_SIZE,
                  DEFAULT_FONT_SIZE,
                  alignment=pango.ALIGN_CENTER)
Ejemplo n.º 3
0
    def render(self, cr, rect):
        font_color = ui_theme.get_color("menu_font").get_color()
        if isinstance(self.icon_normal_dpixbuf, gtk.gdk.Pixbuf):
            icon_pixbuf = self.icon_normal_dpixbuf
        elif isinstance(self.icon_normal_dpixbuf, DynamicPixbuf):
            icon_pixbuf = self.icon_normal_dpixbuf.get_pixbuf()

        if self.is_hover:
            # Draw background.
            draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height,
                         ui_theme.get_shadow_color("menu_item_select").get_color_info())

            # Set icon pixbuf.
            if isinstance(self.icon_hover_dpixbuf, gtk.gdk.Pixbuf):
                icon_pixbuf = self.icon_hover_dpixbuf
            elif isinstance(self.icon_hover_dpixbuf, DynamicPixbuf):
                icon_pixbuf = self.icon_hover_dpixbuf.get_pixbuf()

            # Set font color.
            font_color = ui_theme.get_color("menu_select_font").get_color()

        draw_pixbuf(cr, icon_pixbuf,
                    rect.x + self.padding_x,
                    rect.y + (rect.height - icon_pixbuf.get_height()) / 2)

        draw_text(cr,
                  self.text,
                  rect.x + self.padding_x * 2 + self.icon_width,
                  rect.y,
                  rect.width - self.padding_x * 2,
                  rect.height,
                  text_color=font_color)
Ejemplo n.º 4
0
 def render_size(self, cr, rect):
     '''
     Render size of DirItem.
     '''
     # Draw select background.
     if self.is_select:
         draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                      ui_theme.get_shadow_color("listview_select").get_color_info())
     
     # Draw directory size.
     draw_text(cr, self.size_name,
               rect.x,
               rect.y,
               rect.width, 
               rect.height,
               alignment=pango.ALIGN_RIGHT,
               )
     
     # Draw drag line.
     if self.drag_line:
         with cairo_disable_antialias(cr):
             cr.set_line_width(1)
             if self.drag_line_at_bottom:
                 cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
             else:
                 cr.rectangle(rect.x, rect.y, rect.width, 1)
             cr.fill()
Ejemplo n.º 5
0
    def render_size(self, cr, rect):
        '''
        Render size of DirItem.
        '''
        # Draw select background.
        if self.is_select or self.is_highlight:
            draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                         ui_theme.get_shadow_color("listview_select").get_color_info())

        # Draw directory size.
        draw_text(cr, self.size_name,
                  rect.x,
                  rect.y,
                  rect.width,
                  rect.height,
                  alignment=pango.ALIGN_RIGHT,
                  )

        # Draw drag line.
        if self.drag_line:
            with cairo_disable_antialias(cr):
                cr.set_line_width(1)
                if self.drag_line_at_bottom:
                    cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
                else:
                    cr.rectangle(rect.x, rect.y, rect.width, 1)
                cr.fill()
def render_pixbuf(widget, event, input_args):
    '''
    Render and save pixbuf.

    @param widget: Gtk.Widget instance.
    @param event: Expose event.
    @param input_args: Input arguments as format: (select_num, vlinear_color, text_color, filepath).
    '''
    # Init.
    (select_num, vlinear_color, text_color, filepath) = input_args

    cr = widget.window.cairo_create()
    rect = widget.allocation
    num_pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, rect.width, rect.height)

    # Draw background.
    cr.set_operator(cairo.OPERATOR_OVER)
    draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, eval(vlinear_color))

    # Draw text.
    draw_text(cr, select_num, rect.x, rect.y, rect.width, rect.height, text_color=text_color,
              alignment=pango.ALIGN_CENTER)

    # Render pixbuf from drawing area.
    num_pixbuf.get_from_drawable(
        widget.window, widget.get_colormap(), 0, 0, 0, 0,
        rect.width, rect.height).save(filepath, "png")

    # Exit after generate png file.
    gtk.main_quit()
Ejemplo n.º 7
0
    def render(self, cr, rect):
        """
        Render icon and name of DirItem.
        """
        # Draw select background.
        if self.is_button_press == True:
            draw_vlinear(
                cr,
                rect.x,
                rect.y,
                rect.width,
                rect.height,
                ui_theme.get_shadow_color("listview_select").get_color_info(),
            )

        # Draw directory icon.
        draw_pixbuf(cr, self.pixbuf, rect.x + self.icon_size / 2, rect.y + (rect.height - self.icon_size) / 2)

        # Draw directory name.
        draw_text(
            cr,
            self.name,
            rect.x,
            rect.y + self.icon_size + ITEM_PADDING_Y * 2,
            rect.width,
            DEFAULT_FONT_SIZE,
            DEFAULT_FONT_SIZE,
            alignment=pango.ALIGN_CENTER,
        )
Ejemplo n.º 8
0
    def render(self, cr, rect):
        font_color = ui_theme.get_color("menu_font").get_color()
        if isinstance(self.icon_normal_dpixbuf, gtk.gdk.Pixbuf):
            icon_pixbuf = self.icon_normal_dpixbuf
        elif isinstance(self.icon_normal_dpixbuf, DynamicPixbuf):
            icon_pixbuf = self.icon_normal_dpixbuf.get_pixbuf()

        if self.is_hover:
            # Draw background.
            draw_vlinear(
                cr, rect.x, rect.y, rect.width, rect.height,
                ui_theme.get_shadow_color("menu_item_select").get_color_info())

            # Set icon pixbuf.
            if isinstance(self.icon_hover_dpixbuf, gtk.gdk.Pixbuf):
                icon_pixbuf = self.icon_hover_dpixbuf
            elif isinstance(self.icon_hover_dpixbuf, DynamicPixbuf):
                icon_pixbuf = self.icon_hover_dpixbuf.get_pixbuf()

            # Set font color.
            font_color = ui_theme.get_color("menu_select_font").get_color()

        draw_pixbuf(cr, icon_pixbuf, rect.x + self.padding_x,
                    rect.y + (rect.height - icon_pixbuf.get_height()) / 2)

        draw_text(cr,
                  self.text,
                  rect.x + self.padding_x * 2 + self.icon_width,
                  rect.y,
                  rect.width - self.padding_x * 2,
                  rect.height,
                  text_color=font_color)
Ejemplo n.º 9
0
 def render_name(self, cr, rect):
     '''
     Render icon and name of DirItem.
     '''
     # Draw select background.
     if self.is_select:
         draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                      ui_theme.get_shadow_color("listview_select").get_color_info())
     
     # Init.
     expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_right.png").get_pixbuf()
     
     # Draw directory icon.
     draw_pixbuf(cr, self.pixbuf, 
                 rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT,
                 rect.y + (rect.height - ICON_SIZE) / 2,
                 )
     
     # Draw directory name.
     draw_text(cr, self.name, 
               rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT + ICON_SIZE + ICON_PADDING_RIGHT,
               rect.y,
               rect.width, rect.height)
     
     # Draw drag line.
     if self.drag_line:
         with cairo_disable_antialias(cr):
             cr.set_line_width(1)
             if self.drag_line_at_bottom:
                 cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
             else:
                 cr.rectangle(rect.x, rect.y, rect.width, 1)
             cr.fill()
Ejemplo n.º 10
0
 def expose_button(self, widget, event):
     '''Expose button.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     x, y, w, h = rect.x, rect.y, rect.width, rect.height
     
     # Get color info.
     if widget.state == gtk.STATE_NORMAL:
         text_color = ui_theme.get_color("button_font").get_color()
         border_color = ui_theme.get_color("button_border_normal").get_color()
         background_color = ui_theme.get_shadow_color("button_background_normal").get_color_info()
     elif widget.state == gtk.STATE_PRELIGHT:
         text_color = ui_theme.get_color("button_font").get_color()
         border_color = ui_theme.get_color("button_border_prelight").get_color()
         background_color = ui_theme.get_shadow_color("button_background_prelight").get_color_info()
     elif widget.state == gtk.STATE_ACTIVE:
         text_color = ui_theme.get_color("button_font").get_color()
         border_color = ui_theme.get_color("button_border_active").get_color()
         background_color = ui_theme.get_shadow_color("button_background_active").get_color_info()
     elif widget.state == gtk.STATE_INSENSITIVE:
         text_color = ui_theme.get_color("disable_text").get_color()
         border_color = ui_theme.get_color("disable_frame").get_color()
         disable_background_color = ui_theme.get_color("disable_background").get_color()
         background_color = [(0, (disable_background_color, 1.0)),
                             (1, (disable_background_color, 1.0))]
         
     # Draw background.
     draw_vlinear(
         cr,
         x + 1, y + 1, w - 2, h - 2,
         background_color)
     
     # Draw border.
     cr.set_source_rgb(*color_hex_to_cairo(border_color))
     draw_line(cr, x + 2, y + 1, x + w - 2, y + 1) # top
     draw_line(cr, x + 2, y + h, x + w - 2, y + h) # bottom
     draw_line(cr, x + 1, y + 2, x + 1, y + h - 2) # left
     draw_line(cr, x + w, y + 2, x + w, y + h - 2) # right
     
     # Draw four point.
     if widget.state == gtk.STATE_INSENSITIVE:
         top_left_point = ui_theme.get_pixbuf("button/disable_corner.png").get_pixbuf()
     else:
         top_left_point = ui_theme.get_pixbuf("button/corner.png").get_pixbuf()
     top_right_point = top_left_point.rotate_simple(270)
     bottom_right_point = top_left_point.rotate_simple(180)
     bottom_left_point = top_left_point.rotate_simple(90)
     
     draw_pixbuf(cr, top_left_point, x, y)
     draw_pixbuf(cr, top_right_point, x + w - top_left_point.get_width(), y)
     draw_pixbuf(cr, bottom_left_point, x, y + h - top_left_point.get_height())
     draw_pixbuf(cr, bottom_right_point, x + w - top_left_point.get_width(), y + h - top_left_point.get_height())
     
     # Draw font.
     draw_text(cr, self.label, x, y, w, h, self.font_size, text_color,
                 alignment=pango.ALIGN_CENTER)
     
     return True
Ejemplo n.º 11
0
    def expose_vseparator(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        start_x = rect.x + rect.width / 2
        draw_vlinear(cr, start_x, rect.y, 1, rect.height, self.color_infos)

        return True
Ejemplo n.º 12
0
 def expose_menu_item(self, widget, event):
     '''Expose menu item.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     font_color = ui_theme.get_color("menu_font").get_color()
     (item_icons, item_content, item_node) = self.item[0:3]
     
     # Draw select effect.
     if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]:
         # Draw background.
         draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, 
                      ui_theme.get_shadow_color("menu_item_select").get_color_info(),
                      MENU_ITEM_RADIUS)
         
         # Set font color.
         font_color = ui_theme.get_color("menu_select_font").get_color()
         
     # Draw item icon.
     pixbuf = None
     pixbuf_width = 0
     if item_icons:
         (item_normal_dpixbuf, item_hover_dpixbuf) = item_icons
         if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]:
             if item_hover_dpixbuf == None:
                 pixbuf = item_normal_dpixbuf.get_pixbuf()
             else:
                 pixbuf = item_hover_dpixbuf.get_pixbuf()
         else:
             pixbuf = item_normal_dpixbuf.get_pixbuf()
         pixbuf_width += pixbuf.get_width()
         draw_pixbuf(cr, pixbuf, rect.x + self.item_padding_x, rect.y + (rect.height - pixbuf.get_height()) / 2)
         
     # Draw item content.
     draw_text(cr, item_content, 
                 rect.x + self.item_padding_x * 2 + self.icon_width,
                 rect.y,
                 rect.width,
                 rect.height,
                 self.font_size, font_color,
                 )
     
     # Draw submenu arrow.
     if isinstance(item_node, Menu):
         if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]:
             submenu_pixbuf = ui_theme.get_pixbuf("menu/arrow_hover.png").get_pixbuf()
         else:
             submenu_pixbuf = ui_theme.get_pixbuf("menu/arrow_normal.png").get_pixbuf()
         draw_pixbuf(cr, submenu_pixbuf,
                     rect.x + rect.width - self.item_padding_x - submenu_pixbuf.get_width() - self.arrow_padding_x,
                     rect.y + (rect.height - submenu_pixbuf.get_height()) / 2)
     
     # Propagate expose to children.
     propagate_expose(widget, event)
 
     return True
Ejemplo n.º 13
0
    def render(self, cr, rect):
        # Draw select background.
        if self.is_select:
            draw_vlinear(
                cr, rect.x, rect.y, rect.width, rect.height,
                ui_theme.get_shadow_color("listview_select").get_color_info())

        # Draw loading text.
        draw_text(cr, "(空)", rect.x + COLUMN_OFFSET * self.column_index,
                  rect.y, rect.width, rect.height)
Ejemplo n.º 14
0
 def expose_category_item(self, widget, event):
     '''Expose navigate item.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     select_index = self.get_index()
     font_color = ui_theme.get_color("category_item").get_color()
     
     # Draw background.
     if widget.state == gtk.STATE_NORMAL:
         if select_index == self.index:
             select_status = BUTTON_PRESS
         else:
             select_status = BUTTON_NORMAL
     elif widget.state == gtk.STATE_PRELIGHT:
         if select_index == self.index:
             select_status = BUTTON_PRESS
         else:
             select_status = BUTTON_HOVER
     elif widget.state == gtk.STATE_ACTIVE:
         select_status = BUTTON_PRESS
         
     if select_status == BUTTON_PRESS:
         draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, 
                     ui_theme.get_shadow_color("category_item_press").get_color_info())
 
         font_color = ui_theme.get_color("category_select_item").get_color()
     elif select_status == BUTTON_HOVER:
         draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, 
                     ui_theme.get_shadow_color("category_item_hover").get_color_info())
         
         font_color = ui_theme.get_color("category_select_item").get_color()
         
     # Draw navigate item.
     category_item_pixbuf = self.icon_dpixbuf.get_pixbuf()
     draw_pixbuf(
         cr, category_item_pixbuf, 
         rect.x + self.padding_left,
         rect.y + (rect.height - category_item_pixbuf.get_height()) / 2
         )
     
     # Draw font.
     draw_text(cr, self.content, 
                 rect.x + self.padding_left + self.font_offset,
                 rect.y,
                 rect.width - self.padding_left - self.font_offset - self.padding_right,
                 rect.height,
                 self.font_size, 
                 font_color,
                 )
     
     # Propagate expose to children.
     propagate_expose(widget, event)
 
     return True
Ejemplo n.º 15
0
    def render(self, cr, rect):
        # Draw select background.
        if self.is_select:
            draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                         ui_theme.get_shadow_color("listview_select").get_color_info())

        # Draw loading text.
        draw_text(cr, "(空)",
                  rect.x + COLUMN_OFFSET * self.column_index,
                  rect.y,
                  rect.width, rect.height)
Ejemplo n.º 16
0
    def render_title(self, cr, rect):
        font_color = ui_theme.get_color("menu_font").get_color()

        if self.is_hover:
            draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, ui_theme.get_shadow_color("menu_item_select").get_color_info())
            font_color = ui_theme.get_color("menu_select_font").get_color()

        draw_text(cr, self.title, rect.x + self.padding_x,
                  rect.y, rect.width - self.padding_x * 2,
                  rect.height, text_size=self.font_size,
                  text_color = font_color,
                  alignment=pango.ALIGN_LEFT)
Ejemplo n.º 17
0
    def draw_mask(self, cr, x, y, w, h):
        '''
        Draw mask interface.

        @param cr: Cairo context.
        @param x: X coordiante of draw area.
        @param y: Y coordiante of draw area.
        @param w: Width of draw area.
        @param h: Height of draw area.
        '''
        draw_vlinear(
            cr, x, y, w, h,
            ui_theme.get_shadow_color("linear_background").get_color_info())
Ejemplo n.º 18
0
 def draw_mask_glass_page(self, cr, x, y, w, h):
     '''Draw make for glass page type.'''
     top_height = 70
     
     draw_vlinear(
         cr, x, y, w, top_height,
         ui_theme.get_shadow_color("mask_glass_page_top").get_color_info(),
         )
     
     draw_vlinear(
         cr, x, y + top_height, w, h - top_height,
         ui_theme.get_shadow_color("mask_glass_page_bottom").get_color_info(),
         )
Ejemplo n.º 19
0
 def draw_mask(self, cr, x, y, w, h):
     '''
     Mask render function.
     
     @param cr: Cairo context.
     @param x: X coordinate of draw area.
     @param y: Y coordinate of draw area.
     @param w: Width of draw area.
     @param h: Height of draw area.
     '''
     draw_vlinear(cr, x, y, w, h,
                  ui_theme.get_shadow_color("linear_background").get_color_info()
                  )
Ejemplo n.º 20
0
 def render(self, cr, rect):
     # Init.
     x, y, w, h = rect.x, rect.y, rect.width, rect.height
     
     # Draw background frame.
     with cairo_state(cr):
         cr.rectangle(x, y + 1, w, h - 2)
         cr.rectangle(x + 1, y, w - 2, h)
         cr.clip()
         
         cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("progressbar_background_frame").get_color()))
         cr.rectangle(x, y, w, h)
         cr.set_line_width(1)
         cr.stroke()
         
     # Draw background.
     with cairo_state(cr):
         cr.rectangle(x + 1, y + 1, w - 2, h - 2)
         cr.clip()
         
         draw_vlinear(cr, x + 1, y + 1, w - 2, h - 2,
                      ui_theme.get_shadow_color("progressbar_background").get_color_info(), 
                      )
         
     if self.progress > 0:    
         # Draw foreground frame.
         with cairo_state(cr):
             cr.rectangle(x, y + 1, w, h - 2)
             cr.rectangle(x + 1, y, w - 2, h)
             cr.clip()
         
             cr.set_antialias(cairo.ANTIALIAS_NONE)
             cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("progressbar_foreground_frame").get_color()))
             cr.rectangle(x + 1, y + 1, int(w * self.progress / 100) - 1, h - 1)
             cr.set_line_width(1)
             cr.stroke()
             
         # Draw foreground.
         with cairo_state(cr):
             cr.rectangle(x + 1, y + 1, w - 2, h - 2)
             cr.clip()
             
             draw_vlinear(cr, x + 1, y + 1, int(w * self.progress / 100) - 2, h - 2,
                          ui_theme.get_shadow_color("progressbar_foreground").get_color_info(), 
                          )
         
     # Draw light.
     with cairo_disable_antialias(cr):
         cr.set_source_rgba(1, 1, 1, 0.5)
         cr.rectangle(x + 1, y + 1, w - 2, 1)
         cr.fill()
Ejemplo n.º 21
0
    def draw_mask_tab_page(self, cr, x, y, w, h):
        '''Draw make for tab page type.'''
        button_box_height = self.right_button_box.get_allocation().height
        dominant_color = skin_config.dominant_color
        
        draw_vlinear(
            cr, x, y + h - button_box_height, w, button_box_height,
            [(0, (dominant_color, 1.0)),
             (1, (dominant_color, 1.0))])

        draw_vlinear(
            cr, x, y + h - button_box_height, w, button_box_height,
            ui_theme.get_shadow_color("mask_multiple_page").get_color_info(),
            )
Ejemplo n.º 22
0
    def expose_vseparator(self, widget, event):
        '''
        Callback for `expose-event` signal.

        @param widget: HSeparator instance.
        @param event: Expose event.
        @return: Return True.
        '''
        cr = widget.window.cairo_create()
        rect = widget.allocation

        start_x = rect.x + rect.width / 2
        draw_vlinear(cr, start_x, rect.y, 1, rect.height, self.color_infos)

        return True
Ejemplo n.º 23
0
    def expose_vseparator(self, widget, event):
        '''
        Callback for `expose-event` signal.

        @param widget: HSeparator instance.
        @param event: Expose event.
        @return: Return True.
        '''
        cr = widget.window.cairo_create()
        rect = widget.allocation

        start_x = rect.x + rect.width / 2
        draw_vlinear(cr, start_x, rect.y, 1, rect.height, self.color_infos)

        return True
Ejemplo n.º 24
0
    def render_title(self, cr, rect):
        font_color = ui_theme.get_color("menu_font").get_color()

        if self.is_hover:
            draw_vlinear(
                cr, rect.x, rect.y, rect.width, rect.height,
                ui_theme.get_shadow_color("menu_item_select").get_color_info())
            font_color = ui_theme.get_color("menu_select_font").get_color()

        draw_text(cr,
                  self.title,
                  rect.x + self.padding_x,
                  rect.y,
                  rect.width - self.padding_x * 2,
                  rect.height,
                  text_size=self.font_size,
                  text_color=font_color,
                  alignment=pango.ALIGN_LEFT)
Ejemplo n.º 25
0
    def render_name(self, cr, rect):
        '''
        Render icon and name of DirItem.
        '''
        if self.pixbuf == None:
            self.pixbuf = get_file_icon_pixbuf(self.directory_path, ICON_SIZE)

        # Draw select background.
        if self.is_select or self.is_highlight:
            draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                         ui_theme.get_shadow_color("listview_select").get_color_info())

        # Draw directory arrow icon.
        if self.is_expand:
            expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_down.png").get_pixbuf()
        else:
            expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_right.png").get_pixbuf()
        draw_pixbuf(cr, expand_indicator_pixbuf,
                    rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT,
                    rect.y + (rect.height - expand_indicator_pixbuf.get_height()) / 2,
                    )

        # Draw directory icon.
        draw_pixbuf(cr, self.pixbuf,
                    rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT,
                    rect.y + (rect.height - ICON_SIZE) / 2,
                    )

        # Draw directory name.
        draw_text(cr, self.name,
                  rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT + ICON_SIZE + ICON_PADDING_RIGHT,
                  rect.y,
                  rect.width, rect.height)

        # Draw drag line.
        if self.drag_line:
            with cairo_disable_antialias(cr):
                cr.set_line_width(1)
                if self.drag_line_at_bottom:
                    cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
                else:
                    cr.rectangle(rect.x, rect.y, rect.width, 1)
                cr.fill()
Ejemplo n.º 26
0
    def color_test_widget_expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        # Draw pixbuf.
        draw_pixbuf(cr, self.pixbuf, 0, 0)

        # Draw mask.
        draw_vlinear(cr, rect.x,
                     rect.y + self.pixbuf.get_height() - SHADOW_SIZE,
                     rect.width, SHADOW_SIZE,
                     [(0, (self.background_color, 0)),
                      (1, (self.background_color, 1))])

        draw_hlinear(cr, rect.x + self.pixbuf.get_width() - SHADOW_SIZE,
                     rect.y, SHADOW_SIZE, rect.height,
                     [(0, (self.background_color, 0)),
                      (1, (self.background_color, 1))])

        # Draw background.
        (similar_color_name,
         similar_color_value) = find_similar_color(self.background_color)
        print(similar_color_name, self.background_color, similar_color_value)
        cr.set_source_rgb(*color_hex_to_cairo(similar_color_value))
        cr.rectangle(rect.x + self.pixbuf.get_width(), rect.y,
                     rect.width - self.pixbuf.get_width(), rect.height)
        cr.fill()
        cr.set_source_rgb(*color_hex_to_cairo(self.background_color))
        cr.rectangle(rect.x, rect.y + self.pixbuf.get_height(), rect.width,
                     rect.height - self.pixbuf.get_height())
        cr.fill()

        # cr.set_source_rgb(*color_hex_to_cairo(self.background_color))
        # cr.rectangle(rect.x + self.pixbuf.get_width(), rect.y,
        #              rect.width - self.pixbuf.get_width(), rect.height)
        # cr.rectangle(rect.x, rect.y + self.pixbuf.get_height(),
        #              rect.width, rect.height - self.pixbuf.get_height())

        # cr.fill()

        propagate_expose(widget, event)

        return True
Ejemplo n.º 27
0
    def expose_droplist_item(self, widget, event, item_content):
        '''
        Internal function to handle `expose-event` signal of item.

        @param widget: DropItem widget.
        @param event: Expose event.
        @param item_content: Item content.
        '''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        font_color = ui_theme.get_color("menu_font").get_color()

        # Draw select effect.
        if self.subdroplist_active or widget.state in [
                gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE
        ]:
            # Draw background.
            draw_vlinear(
                cr, rect.x, rect.y, rect.width, rect.height,
                ui_theme.get_shadow_color("menu_item_select").get_color_info())

            # Set font color.
            font_color = ui_theme.get_color("menu_select_font").get_color()

        # Draw item content.
        draw_text(
            cr,
            item_content,
            rect.x + self.item_padding_left,
            rect.y,
            rect.width,
            rect.height,
            self.font_size,
            font_color,
        )

        # Propagate expose to children.
        propagate_expose(widget, event)

        return True
Ejemplo n.º 28
0
 def expose_progressbar(self, widget, event):
     '''Expose progressbar.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     # Draw frame.
     cr.set_source_rgba(*alpha_color_hex_to_cairo(ui_theme.get_alpha_color("progressbar_frame").get_color_info()))
     cr.set_operator(cairo.OPERATOR_OVER)
     draw_round_rectangle(cr, rect.x, rect.y, rect.width, rect.height, 1)
     cr.stroke()
     
     # Draw background.
     draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, 
                  ui_theme.get_shadow_color("progressbar_background").get_color_info(), 
                  1)
 
     # Draw foreground.
     draw_vlinear(cr, rect.x, rect.y, rect.width * self.progress / 100.0, rect.height, 
                  ui_theme.get_shadow_color("progressbar_foreground").get_color_info(), 
                  1)
     
     # Draw font.
     draw_text(cr, str(self.progress) + "%", 
               rect.x, rect.y, rect.width, rect.height, 
               rect.height - 5, "#000000",
               alignment=pango.ALIGN_CENTER)
     
     # Draw light.
     light_radius = rect.height * 4
     light_offset_x = min(self.light_ticker % 150, 100) / 100.0 * (rect.width + light_radius * 2)
     with cairo_state(cr):
         cr.rectangle(rect.x, rect.y, rect.width * self.progress / 100.0, rect.height)
         cr.clip()
         draw_radial_round(cr, rect.x + light_offset_x - light_radius, rect.y - light_radius / 2, light_radius, 
                           ui_theme.get_shadow_color("progressbar_light").get_color_info())
            
     # Propagate expose.
     propagate_expose(widget, event)
     
     return True        
Ejemplo n.º 29
0
    def color_test_widget_expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        # Draw pixbuf.
        draw_pixbuf(cr, self.pixbuf, 0, 0)
        
        # Draw mask.
        draw_vlinear(
            cr, rect.x, rect.y + self.pixbuf.get_height() - SHADE_SIZE, rect.width, SHADE_SIZE,
            [(0, (self.background_color, 0)),
             (1, (self.background_color, 1))])
        
        draw_hlinear(
            cr, rect.x + self.pixbuf.get_width() - SHADE_SIZE, rect.y, SHADE_SIZE, rect.height,
            [(0, (self.background_color, 0)),
             (1, (self.background_color, 1))])

        # Draw background.
        (similar_color_name, similar_color_value) = find_similar_color(self.background_color)
        print (similar_color_name, self.background_color, similar_color_value)
        cr.set_source_rgb(*color_hex_to_cairo(similar_color_value))
        cr.rectangle(rect.x + self.pixbuf.get_width(), rect.y,
                     rect.width - self.pixbuf.get_width(), rect.height)
        cr.fill()
        cr.set_source_rgb(*color_hex_to_cairo(self.background_color))
        cr.rectangle(rect.x, rect.y + self.pixbuf.get_height(), 
                     rect.width, rect.height - self.pixbuf.get_height())
        cr.fill()
        
        # cr.set_source_rgb(*color_hex_to_cairo(self.background_color))
        # cr.rectangle(rect.x + self.pixbuf.get_width(), rect.y,
        #              rect.width - self.pixbuf.get_width(), rect.height)
        # cr.rectangle(rect.x, rect.y + self.pixbuf.get_height(), 
        #              rect.width, rect.height - self.pixbuf.get_height())
        
        # cr.fill()
        
        propagate_expose(widget, event)
        
        return True
Ejemplo n.º 30
0
    def draw_mask_glass_page(self, cr, x, y, w, h):
        '''
        Internal render function for DIALOG_MASK_GLASS_PAGE type.

        @param cr: Cairo context.
        @param x: X coordinate of draw area.
        @param y: Y coordinate of draw area.
        @param w: Width of draw area.
        @param h: Height of draw area.
        '''
        top_height = 70

        draw_vlinear(
            cr, x, y, w, top_height,
            ui_theme.get_shadow_color("mask_glass_page_top").get_color_info(),
            )

        draw_vlinear(
            cr, x, y + top_height, w, h - top_height,
            ui_theme.get_shadow_color("mask_glass_page_bottom").get_color_info(),
            )
Ejemplo n.º 31
0
 def draw_mask_glass_page(self, cr, x, y, w, h):
     '''
     Internal render function for DIALOG_MASK_GLASS_PAGE type.
     
     @param cr: Cairo context.
     @param x: X coordinate of draw area.
     @param y: Y coordinate of draw area.
     @param w: Width of draw area.
     @param h: Height of draw area.
     '''
     top_height = 70
     
     draw_vlinear(
         cr, x, y, w, top_height,
         ui_theme.get_shadow_color("mask_glass_page_top").get_color_info(),
         )
     
     draw_vlinear(
         cr, x, y + top_height, w, h - top_height,
         ui_theme.get_shadow_color("mask_glass_page_bottom").get_color_info(),
         )
Ejemplo n.º 32
0
    def draw_mask_multiple_page(self, cr, x, y, w, h):
        '''
        Internal render function for DIALOG_MASK_MULTIPLE_PAGE type.
        
        @param cr: Cairo context.
        @param x: X coordinate of draw area.
        @param y: Y coordinate of draw area.
        @param w: Width of draw area.
        @param h: Height of draw area.
        '''
        titlebar_height = self.titlebar.get_allocation().height
        button_box_height = self.right_button_box.get_allocation().height
        dominant_color = skin_config.dominant_color
        
        draw_vlinear(
            cr, x, y + titlebar_height, w, h - titlebar_height,
            ui_theme.get_shadow_color("mask_single_page_bottom").get_color_info(),
            )
        
        draw_vlinear(
            cr, x, y + h - button_box_height, w, button_box_height,
            [(0, (dominant_color, 1.0)),
             (1, (dominant_color, 1.0))])

        draw_vlinear(
            cr, x, y + h - button_box_height, w, button_box_height,
            ui_theme.get_shadow_color("mask_multiple_page").get_color_info(),
            )
Ejemplo n.º 33
0
    def draw_mask_multiple_page(self, cr, x, y, w, h):
        '''
        Internal render function for DIALOG_MASK_MULTIPLE_PAGE type.

        @param cr: Cairo context.
        @param x: X coordinate of draw area.
        @param y: Y coordinate of draw area.
        @param w: Width of draw area.
        @param h: Height of draw area.
        '''
        titlebar_height = self.titlebar.get_allocation().height
        button_box_height = self.right_button_box.get_allocation().height
        dominant_color = skin_config.dominant_color

        draw_vlinear(
            cr, x, y + titlebar_height, w, h - titlebar_height,
            ui_theme.get_shadow_color("mask_single_page_bottom").get_color_info(),
            )

        draw_vlinear(
            cr, x, y + h - button_box_height, w, button_box_height,
            [(0, (dominant_color, 1.0)),
             (1, (dominant_color, 1.0))])

        draw_vlinear(
            cr, x, y + h - button_box_height, w, button_box_height,
            ui_theme.get_shadow_color("mask_multiple_page").get_color_info(),
            )
Ejemplo n.º 34
0
def render_pixbuf(widget, event, input_args):
    '''
    Render and save pixbuf.

    @param widget: Gtk.Widget instance.
    @param event: Expose event.
    @param input_args: Input arguments as format: (select_num, vlinear_color, text_color, filepath).
    '''
    # Init.
    (select_num, vlinear_color, text_color, filepath) = input_args

    cr = widget.window.cairo_create()
    rect = widget.allocation
    num_pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, rect.width,
                                rect.height)

    # Draw background.
    cr.set_operator(cairo.OPERATOR_OVER)
    draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height,
                 eval(vlinear_color))

    # Draw text.
    draw_text(cr,
              select_num,
              rect.x,
              rect.y,
              rect.width,
              rect.height,
              text_color=text_color,
              alignment=pango.ALIGN_CENTER)

    # Render pixbuf from drawing area.
    num_pixbuf.get_from_drawable(widget.window, widget.get_colormap(), 0, 0, 0,
                                 0, rect.width,
                                 rect.height).save(filepath, "png")

    # Exit after generate png file.
    gtk.main_quit()
Ejemplo n.º 35
0
 def render_type(self, cr, rect):
     '''
     Render type of DirItem.
     '''
     # Draw select background.
     if self.is_select:
         draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                      ui_theme.get_shadow_color("listview_select").get_color_info())
     
     # Draw directory type.
     draw_text(cr, self.content_type, 
               rect.x + CONTENT_TYPE_PADDING_LEFT,
               rect.y,
               rect.width, rect.height)
     
     # Draw drag line.
     if self.drag_line:
         with cairo_disable_antialias(cr):
             cr.set_line_width(1)
             if self.drag_line_at_bottom:
                 cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
             else:
                 cr.rectangle(rect.x, rect.y, rect.width, 1)
             cr.fill()
Ejemplo n.º 36
0
 def render_modification_time(self, cr, rect):
     '''
     Render type of DirItem.
     '''
     # Draw select background.
     if self.is_select or self.is_highlight:
         draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                      ui_theme.get_shadow_color("listview_select").get_color_info())
     
     # Draw directory type.
     draw_text(cr, self.modification_time, 
               rect.x + MODIFICATION_TIME_PADDING_LEFT,
               rect.y,
               rect.width, rect.height)
     
     # Draw drag line.
     if self.drag_line:
         with cairo_disable_antialias(cr):
             cr.set_line_width(1)
             if self.drag_line_at_bottom:
                 cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
             else:
                 cr.rectangle(rect.x, rect.y, rect.width, 1)
             cr.fill()
Ejemplo n.º 37
0
    def render_type(self, cr, rect):
        '''
        Render type of DirItem.
        '''
        # Draw select background.
        if self.is_select or self.is_highlight:
            draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                         ui_theme.get_shadow_color("listview_select").get_color_info())

        # Draw directory type.
        draw_text(cr, self.content_type,
                  rect.x + CONTENT_TYPE_PADDING_LEFT,
                  rect.y,
                  rect.width, rect.height)

        # Draw drag line.
        if self.drag_line:
            with cairo_disable_antialias(cr):
                cr.set_line_width(1)
                if self.drag_line_at_bottom:
                    cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
                else:
                    cr.rectangle(rect.x, rect.y, rect.width, 1)
                cr.fill()
Ejemplo n.º 38
0
def render_background(item, cr, rect):
    if item.is_select:
        draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                     ui_theme.get_shadow_color("listview_select").get_color_info())
Ejemplo n.º 39
0
    def expose_button(self, widget, event):
        '''
        Internal function to handle `expose-event` signal.

        @param widget: ColorButton instance.
        @param event: Expose event.
        '''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        x, y, w, h = rect.x, rect.y, rect.width, rect.height

        # Get color info.
        if widget.state == gtk.STATE_NORMAL:
            border_color = ui_theme.get_color(
                "button_border_normal").get_color()
            background_color = ui_theme.get_shadow_color(
                "button_background_normal").get_color_info()
        elif widget.state == gtk.STATE_PRELIGHT:
            border_color = ui_theme.get_color(
                "button_border_prelight").get_color()
            background_color = ui_theme.get_shadow_color(
                "button_background_prelight").get_color_info()
        elif widget.state == gtk.STATE_ACTIVE:
            border_color = ui_theme.get_color(
                "button_border_active").get_color()
            background_color = ui_theme.get_shadow_color(
                "button_background_active").get_color_info()
        elif widget.state == gtk.STATE_INSENSITIVE:
            border_color = ui_theme.get_color("disable_frame").get_color()
            disable_background_color = ui_theme.get_color(
                "disable_background").get_color()
            background_color = [(0, (disable_background_color, 1.0)),
                                (1, (disable_background_color, 1.0))]

        # Draw background.
        draw_vlinear(cr, x + 1, y + 1, w - 2, h - 2, background_color)

        # Draw border.
        cr.set_source_rgb(*color_hex_to_cairo(border_color))
        draw_line(cr, x + 2, y + 1, x + w - 2, y + 1)  # top
        draw_line(cr, x + 2, y + h, x + w - 2, y + h)  # bottom
        draw_line(cr, x + 1, y + 2, x + 1, y + h - 2)  # left
        draw_line(cr, x + w, y + 2, x + w, y + h - 2)  # right

        # Draw four point.
        if widget.state == gtk.STATE_INSENSITIVE:
            top_left_point = ui_theme.get_pixbuf(
                "button/disable_corner.png").get_pixbuf()
        else:
            top_left_point = ui_theme.get_pixbuf(
                "button/corner.png").get_pixbuf()
        top_right_point = top_left_point.rotate_simple(270)
        bottom_right_point = top_left_point.rotate_simple(180)
        bottom_left_point = top_left_point.rotate_simple(90)

        draw_pixbuf(cr, top_left_point, x, y)
        draw_pixbuf(cr, top_right_point, x + w - top_left_point.get_width(), y)
        draw_pixbuf(cr, bottom_left_point, x,
                    y + h - top_left_point.get_height())
        draw_pixbuf(cr, bottom_right_point, x + w - top_left_point.get_width(),
                    y + h - top_left_point.get_height())

        # Draw color frame.
        cr.set_source_rgb(*color_hex_to_cairo("#c0c0c0"))
        cr.rectangle(x + (w - self.color_area_width) / 2,
                     y + (h - self.color_area_height) / 2,
                     self.color_area_width, self.color_area_height)
        cr.stroke()

        # Draw color.
        cr.set_source_rgb(*color_hex_to_cairo(self.color))
        cr.rectangle(x + (w - self.color_area_width) / 2,
                     y + (h - self.color_area_height) / 2,
                     self.color_area_width, self.color_area_height)
        cr.fill()

        # Draw mask when widget is insensitive.
        if widget.state == gtk.STATE_INSENSITIVE:
            cr.set_source_rgba(*alpha_color_hex_to_cairo(
                ui_theme.get_alpha_color(
                    "color_button_disable_mask").get_color_info()))
            cr.rectangle(x + (w - self.color_area_width) / 2,
                         y + (h - self.color_area_height) / 2,
                         self.color_area_width, self.color_area_height)
            cr.fill()

        return True
Ejemplo n.º 40
0
def render_background(item, cr, rect):
    if item.is_select:
        draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                     ui_theme.get_shadow_color("listview_select").get_color_info())
Ejemplo n.º 41
0
 def draw_mask(self, cr, x, y, w, h):
     '''Draw mask.'''
     draw_vlinear(cr, x, y, w, h,
                  ui_theme.get_shadow_color("linear_background").get_color_info())
Ejemplo n.º 42
0
 def draw_mask(self, cr, x, y, w, h):
     '''Draw mask.'''
     draw_vlinear(cr, x, y, w, h,
                  [(0, ("#FF0000", 1)),
                   (1, ("#FF0000", 1))]
                  )
Ejemplo n.º 43
0
 def render_background(self, cr, widget, x, y, 
                       translate_width=0,
                       translate_height=0):
     '''Render background.'''
     # Init.
     toplevel_rect = widget.get_toplevel().allocation
     render_width = toplevel_rect.width + translate_width
     render_height = toplevel_rect.height + translate_height
     
     # Draw background.
     background_x = int(self.x * self.scale_x)
     background_y = int(self.y * self.scale_y)
     background_width = int(self.background_pixbuf.get_width() * self.scale_x)
     background_height = int(self.background_pixbuf.get_height() * self.scale_y)
     self.cache_pixbuf.scale(self.background_pixbuf, background_width, background_height,
                             self.vertical_mirror, self.horizontal_mirror)
             
     draw_pixbuf(
         cr,
         self.cache_pixbuf.get_cache(),
         x + background_x,
         y + background_y)
     
     # Draw dominant color if necessarily.
     if ((background_width + background_x) < render_width 
         and (background_height + background_y) < render_height):
         cr.set_source_rgb(*color_hex_to_cairo(self.dominant_color))
         cr.rectangle(
             x + background_x + background_width,
             y + background_y + background_height,
             render_width - (background_width + background_x),
             render_height - (background_height + background_y))
         cr.fill()
     
     if (background_width + background_x) < render_width:
         draw_hlinear(
             cr,
             x + (background_width + background_x) - SHADE_SIZE,
             y,
             SHADE_SIZE,
             (background_height + background_y),
             [(0, (self.dominant_color, 0)),
              (1, (self.dominant_color, 1))])
         
         cr.set_source_rgb(*color_hex_to_cairo(self.dominant_color))
         cr.rectangle(
             x + (background_width + background_x),
             y,
             render_width - (background_width + background_x),
             (background_height + background_y))
         cr.fill()
         
     if (background_height + background_y) < render_height:
         draw_vlinear(
             cr,
             x,
             y + (background_height + background_y) - SHADE_SIZE,
             (background_width + background_x),
             SHADE_SIZE,
             [(0, (self.dominant_color, 0)),
              (1, (self.dominant_color, 1))])
         
         cr.set_source_rgb(*color_hex_to_cairo(self.dominant_color))
         cr.rectangle(
             x,
             y + (background_height + background_y),
             (background_width + background_x),
             render_height - (background_height + background_y))
         cr.fill()
Ejemplo n.º 44
0
    def render_background(self, cr, widget, x, y,
                          translate_width=0,
                          translate_height=0):
        '''
        Internal function to render background.
        '''
        # Init.
        toplevel_rect = widget.get_toplevel().allocation
        render_width = toplevel_rect.width + translate_width
        render_height = toplevel_rect.height + translate_height

        # Draw background.
        background_x = int(self.x * self.scale_x)
        background_y = int(self.y * self.scale_y)
        background_width = int(self.background_pixbuf.get_width() * self.scale_x)
        background_height = int(self.background_pixbuf.get_height() * self.scale_y)
        self.cache_pixbuf.scale(self.background_pixbuf, background_width, background_height,
                                self.vertical_mirror, self.horizontal_mirror)

        draw_pixbuf(
            cr,
            self.cache_pixbuf.get_cache(),
            x + background_x,
            y + background_y)

        # Draw dominant color if necessarily.
        if ((background_width + background_x) < render_width
            and (background_height + background_y) < render_height):
            cr.set_source_rgb(*color_hex_to_cairo(self.dominant_color))
            cr.rectangle(
                x + background_x + background_width,
                y + background_y + background_height,
                render_width - (background_width + background_x),
                render_height - (background_height + background_y))
            cr.fill()

        if (background_width + background_x) < render_width:
            draw_hlinear(
                cr,
                x + (background_width + background_x) - SHADOW_SIZE,
                y,
                SHADOW_SIZE,
                (background_height + background_y),
                [(0, (self.dominant_color, 0)),
                 (1, (self.dominant_color, 1))])

            cr.set_source_rgb(*color_hex_to_cairo(self.dominant_color))
            cr.rectangle(
                x + (background_width + background_x),
                y,
                render_width - (background_width + background_x),
                (background_height + background_y))
            cr.fill()

        if (background_height + background_y) < render_height:
            draw_vlinear(
                cr,
                x,
                y + (background_height + background_y) - SHADOW_SIZE,
                (background_width + background_x),
                SHADOW_SIZE,
                [(0, (self.dominant_color, 0)),
                 (1, (self.dominant_color, 1))])

            cr.set_source_rgb(*color_hex_to_cairo(self.dominant_color))
            cr.rectangle(
                x,
                y + (background_height + background_y),
                (background_width + background_x),
                render_height - (background_height + background_y))
            cr.fill()
Ejemplo n.º 45
0
    def expose_menu_item(self, widget, event):
        '''
        Internal callback for `expose` signal.
        '''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        font_color = ui_theme.get_color("menu_font").get_color()
        (item_icons, item_content, item_node) = self.item[0:3]

        # Draw select effect.
        if widget.state == gtk.STATE_INSENSITIVE:
            # Set font color.
            font_color = ui_theme.get_color("menu_disable_font").get_color()
        elif self.submenu_active or widget.state in [
                gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE
        ]:
            # Draw background.
            if self.menu_item_select_color:
                item_select_color = self.menu_item_select_color
            else:
                item_select_color = ui_theme.get_shadow_color(
                    "menu_item_select").get_color_info()
            draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height,
                         item_select_color, MENU_ITEM_RADIUS)

            # Set font color.
            font_color = ui_theme.get_color("menu_select_font").get_color()

        # Draw item icon.
        pixbuf = None
        pixbuf_width = 0
        if item_icons:
            (item_normal_dpixbuf, item_hover_dpixbuf,
             item_disable_dpixbuf) = item_icons
            if widget.state == gtk.STATE_INSENSITIVE:
                pixbuf = item_disable_dpixbuf.get_pixbuf()
            elif self.submenu_active or widget.state in [
                    gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE
            ]:
                if item_hover_dpixbuf == None:
                    pixbuf = item_normal_dpixbuf.get_pixbuf()
                else:
                    pixbuf = item_hover_dpixbuf.get_pixbuf()
            else:
                pixbuf = item_normal_dpixbuf.get_pixbuf()
            pixbuf_width += pixbuf.get_width()
            draw_pixbuf(cr, pixbuf, rect.x + self.item_padding_x,
                        rect.y + (rect.height - pixbuf.get_height()) / 2)

        # Draw item content.
        draw_text(
            cr,
            item_content,
            rect.x + self.item_padding_x * 2 + self.icon_width,
            rect.y,
            rect.width,
            rect.height,
            self.font_size,
            font_color,
        )

        # Draw submenu arrow.
        if isinstance(item_node, Menu):
            if widget.state == gtk.STATE_INSENSITIVE:
                submenu_pixbuf = ui_theme.get_pixbuf(
                    "menu/arrow_disable.png").get_pixbuf()
            elif self.submenu_active or widget.state in [
                    gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE
            ]:
                submenu_pixbuf = ui_theme.get_pixbuf(
                    "menu/arrow_hover.png").get_pixbuf()
            else:
                submenu_pixbuf = ui_theme.get_pixbuf(
                    "menu/arrow_normal.png").get_pixbuf()
            draw_pixbuf(
                cr, submenu_pixbuf, rect.x + rect.width - self.item_padding_x -
                submenu_pixbuf.get_width() - self.arrow_padding_x,
                rect.y + (rect.height - submenu_pixbuf.get_height()) / 2)

        # Propagate expose to children.
        propagate_expose(widget, event)

        return True
Ejemplo n.º 46
0
    def render(self, cr, rect):
        # Init.
        x, y, w, h = rect.x, rect.y, rect.width, rect.height

        # Draw background frame.
        with cairo_state(cr):
            cr.rectangle(x, y + 1, w, h - 2)
            cr.rectangle(x + 1, y, w - 2, h)
            cr.clip()

            cr.set_source_rgb(*color_hex_to_cairo(
                ui_theme.get_color(
                    "progressbar_background_frame").get_color()))
            cr.rectangle(x, y, w, h)
            cr.set_line_width(1)
            cr.stroke()

        # Draw background.
        with cairo_state(cr):
            cr.rectangle(x + 1, y + 1, w - 2, h - 2)
            cr.clip()

            draw_vlinear(
                cr,
                x + 1,
                y + 1,
                w - 2,
                h - 2,
                ui_theme.get_shadow_color(
                    "progressbar_background").get_color_info(),
            )

        if self.progress > 0:
            # Draw foreground frame.
            with cairo_state(cr):
                cr.rectangle(x, y + 1, w, h - 2)
                cr.rectangle(x + 1, y, w - 2, h)
                cr.clip()

                cr.set_antialias(cairo.ANTIALIAS_NONE)
                cr.set_source_rgb(*color_hex_to_cairo(
                    ui_theme.get_color(
                        "progressbar_foreground_frame").get_color()))
                cr.rectangle(x + 1, y + 1,
                             int(w * self.progress / 100) - 1, h - 1)
                cr.set_line_width(1)
                cr.stroke()

            # Draw foreground.
            with cairo_state(cr):
                cr.rectangle(x + 1, y + 1, w - 2, h - 2)
                cr.clip()

                draw_vlinear(
                    cr,
                    x + 1,
                    y + 1,
                    int(w * self.progress / 100) - 2,
                    h - 2,
                    ui_theme.get_shadow_color(
                        "progressbar_foreground").get_color_info(),
                )

        # Draw light.
        with cairo_disable_antialias(cr):
            cr.set_source_rgba(1, 1, 1, 0.5)
            cr.rectangle(x + 1, y + 1, w - 2, 1)
            cr.fill()
Ejemplo n.º 47
0
    def expose_button(self, widget, event):
        '''
        Internal function to handle `expose-event` signal.
        
        @param widget: ColorButton instance.
        @param event: Expose event.
        '''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        x, y, w, h = rect.x, rect.y, rect.width, rect.height
        
        # Get color info.
        if widget.state == gtk.STATE_NORMAL:
            border_color = ui_theme.get_color("button_border_normal").get_color()
            background_color = ui_theme.get_shadow_color("button_background_normal").get_color_info()
        elif widget.state == gtk.STATE_PRELIGHT:
            border_color = ui_theme.get_color("button_border_prelight").get_color()
            background_color = ui_theme.get_shadow_color("button_background_prelight").get_color_info()
        elif widget.state == gtk.STATE_ACTIVE:
            border_color = ui_theme.get_color("button_border_active").get_color()
            background_color = ui_theme.get_shadow_color("button_background_active").get_color_info()
        elif widget.state == gtk.STATE_INSENSITIVE:
            border_color = ui_theme.get_color("disable_frame").get_color()
            disable_background_color = ui_theme.get_color("disable_background").get_color()
            background_color = [(0, (disable_background_color, 1.0)),
                                (1, (disable_background_color, 1.0))]
            
        # Draw background.
        draw_vlinear(
            cr,
            x + 1, y + 1, w - 2, h - 2,
            background_color)
        
        # Draw border.
        cr.set_source_rgb(*color_hex_to_cairo(border_color))
        draw_line(cr, x + 2, y + 1, x + w - 2, y + 1) # top
        draw_line(cr, x + 2, y + h, x + w - 2, y + h) # bottom
        draw_line(cr, x + 1, y + 2, x + 1, y + h - 2) # left
        draw_line(cr, x + w, y + 2, x + w, y + h - 2) # right
        
        # Draw four point.
        if widget.state == gtk.STATE_INSENSITIVE:
            top_left_point = ui_theme.get_pixbuf("button/disable_corner.png").get_pixbuf()
        else:
            top_left_point = ui_theme.get_pixbuf("button/corner.png").get_pixbuf()
        top_right_point = top_left_point.rotate_simple(270)
        bottom_right_point = top_left_point.rotate_simple(180)
        bottom_left_point = top_left_point.rotate_simple(90)
        
        draw_pixbuf(cr, top_left_point, x, y)
        draw_pixbuf(cr, top_right_point, x + w - top_left_point.get_width(), y)
        draw_pixbuf(cr, bottom_left_point, x, y + h - top_left_point.get_height())
        draw_pixbuf(cr, bottom_right_point, x + w - top_left_point.get_width(), y + h - top_left_point.get_height())
        
        # Draw color frame.
        cr.set_source_rgb(*color_hex_to_cairo("#c0c0c0"))
        cr.rectangle(x + (w - self.color_area_width) / 2,
                     y + (h - self.color_area_height) / 2,
                     self.color_area_width,
                     self.color_area_height)
        cr.stroke()
        
        # Draw color.
        cr.set_source_rgb(*color_hex_to_cairo(self.color))
        cr.rectangle(x + (w - self.color_area_width) / 2,
                     y + (h - self.color_area_height) / 2,
                     self.color_area_width,
                     self.color_area_height)
        cr.fill()

        # Draw mask when widget is insensitive.
        if widget.state == gtk.STATE_INSENSITIVE:
            cr.set_source_rgba(*alpha_color_hex_to_cairo(ui_theme.get_alpha_color("color_button_disable_mask").get_color_info()))
            cr.rectangle(x + (w - self.color_area_width) / 2,
                         y + (h - self.color_area_height) / 2,
                         self.color_area_width,
                         self.color_area_height)
            cr.fill()
        
        return True
Ejemplo n.º 48
0
 def tree_view_expose_event(self, widget, event):
     cr = widget.window.cairo_create()
     rect = widget.allocation
     x, y, w, h = rect.x, rect.y, rect.width, rect.height
     
     # Get offset.
     (offset_x, offset_y, viewport) = self.get_offset_coordinate(widget)
     
     
     # Draw background.
     with cairo_state(cr):
         scrolled_window = get_match_parent(self, ["ScrolledWindow"])
         cr.translate(-scrolled_window.allocation.x, -scrolled_window.allocation.y)
         cr.rectangle(offset_x, offset_y, 
                      scrolled_window.allocation.x + scrolled_window.allocation.width, 
                      scrolled_window.allocation.y + scrolled_window.allocation.height)
         cr.clip()
         
         (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
         skin_config.render_background(cr, self, offset_x + shadow_x, offset_y + shadow_y)
         
     # Draw mask.
     self.draw_mask(cr, offset_x, offset_y, viewport.allocation.width, viewport.allocation.height)
     
     if self.press_draw_bool:
         self.draw_y_padding = int(self.press_height) / self.height * self.height
         draw_vlinear(
             cr,
             x, y + self.draw_y_padding, w, self.height,
             ui_theme.get_shadow_color("tree_item_select").get_color_info())
     
     if self.move_draw_bool:
         if int(self.press_height) / self.height * self.height != int(self.move_height) / self.height * self.height:
             self.draw_y_padding = int(self.move_height) / self.height * self.height
             draw_vlinear(
                 cr,
                 x, y + self.draw_y_padding, w, self.height,
                 ui_theme.get_shadow_color("tree_item_hover").get_color_info())
         
     if self.tree_list:    
         temp_height = 0
         # (cr, text, font_size, font_color, x, y, width, height, font_align
         for (widget_index, draw_widget) in enumerate(self.tree_list):
             if draw_widget.text:
                 index = int(self.press_height) / self.height
                 if widget_index == index:
                     font_color = ui_theme.get_color("tree_item_select_font").get_color()
                 else:
                     font_color = ui_theme.get_color("tree_item_normal_font").get_color()
                 draw_text(cr, draw_widget.text, 
                             self.font_x_padding + draw_widget.width,
                             temp_height + self.height/2, 
                             self.font_width, 
                             self.font_height,
                             self.font_size,
                             font_color,
                             alignment=self.font_align
                           )    
                 
             font_w, font_h = get_content_size(draw_widget.text, self.font_size)    
             index = int(self.press_height) / self.height
             if draw_widget.tree_view_item.get_has_arrow():
                 if not draw_widget.show_child_items_bool:
                     if widget_index == index:
                         pixbuf = self.normal_hover_pixbuf.get_pixbuf()
                     else:
                         pixbuf = self.normal_pixbuf.get_pixbuf()
                     draw_pixbuf(cr, pixbuf,
                                 widget.allocation.width - self.arrow_x_padding - self.font_x_padding,
                                 # draw_widget.width - self.arrow_x_padding + self.font_x_padding,
                                 # font_w + self.font_x_padding + draw_widget.width + self.arrow_x_padding, 
                                 temp_height + (self.height - self.normal_pixbuf.get_pixbuf().get_height()) / 2)
                 else:
                     if widget_index == index:
                         pixbuf = self.press_hover_pixbuf.get_pixbuf()
                     else:
                         pixbuf = self.press_pixbuf.get_pixbuf()
                     draw_pixbuf(cr, pixbuf,
                                 widget.allocation.width - self.arrow_x_padding - self.font_x_padding,
                                 # draw_widget.width - self.arrow_x_padding + self.font_x_padding,
                                 # font_w + self.font_x_padding + draw_widget.width + self.arrow_x_padding, 
                                 temp_height + (self.height - self.normal_pixbuf.get_pixbuf().get_height()) / 2)
                 
             temp_height += self.height