Example #1
0
    def expose_background_box(self, widget, event):
        '''
        Callback for `expose-event` signal.

        @param widget: BackgroundBox self.
        @param event: Expose event.
        @return: Always return False.
        '''
        cr = widget.window.cairo_create()
        with cairo_state(cr):
            rect = widget.allocation
            toplevel = widget.get_toplevel()
            (offset_x, offset_y) = widget.translate_coordinates(toplevel, 0, 0)
            (shadow_x, shadow_y) = get_window_shadow_size(toplevel)

            x = shadow_x - offset_x
            y = shadow_y - offset_y

            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.clip()
            cr.translate(x, y)
            skin_config.render_background(cr, widget, 0, 0)

        self.draw_mask(cr, rect.x, rect.y, rect.width, rect.height)

        return False
Example #2
0
    def expose_background_box(self, widget, event):
        '''
        Callback for `expose-event` signal.

        @param widget: BackgroundBox self.
        @param event: Expose event.
        @return: Always return False.
        '''
        cr = widget.window.cairo_create()
        with cairo_state(cr):
            rect = widget.allocation
            toplevel = widget.get_toplevel()
            (offset_x, offset_y) = widget.translate_coordinates(toplevel, 0, 0)
            (shadow_x, shadow_y) = get_window_shadow_size(toplevel)

            x = shadow_x - offset_x
            y = shadow_y - offset_y

            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.clip()
            cr.translate(x, y)
            skin_config.render_background(cr, widget, 0, 0)

        self.draw_mask(cr, rect.x, rect.y, rect.width, rect.height)

        return False
Example #3
0
 def draw_title_background(self, cr, widget):
     (offset_x, offset_y) = widget.translate_coordinates(self.get_toplevel(), 0, 0)
     with cairo_state(cr):
         cr.translate(-offset_x, -offset_y)
         
         (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
         skin_config.render_background(cr, widget, shadow_x, shadow_y)
Example #4
0
    def expose_tab_content_box(self, widget, event):
        '''
        Internal function to `expose-event` signal.
        '''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        self.tab_box_width = rect.width

        # Draw background.
        toplevel = widget.get_toplevel()
        coordinate = widget.translate_coordinates(toplevel, 0, 0)
        (offset_x, offset_y) = coordinate

        with cairo_state(cr):
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.clip()
            
            (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
            skin_config.render_background(cr, self, shadow_x, shadow_y)
        
        # Draw mask.
        cr.set_source_rgba(*alpha_color_hex_to_cairo((self.tab_select_bg_color.get_color(), 0.93)))
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()
Example #5
0
    def expose_tab_content_box(self, widget, event):
        '''
        Internal function to `expose-event` signal.
        '''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        self.tab_box_width = rect.width

        # Draw background.
        toplevel = widget.get_toplevel()
        coordinate = widget.translate_coordinates(toplevel, 0, 0)
        (offset_x, offset_y) = coordinate

        with cairo_state(cr):
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.clip()

            (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
            skin_config.render_background(cr, self, shadow_x, shadow_y)

        # Draw mask.
        cr.set_source_rgba(
            *alpha_color_hex_to_cairo((self.tab_select_bg_color.get_color(),
                                       0.93)))
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()
Example #6
0
 def expose_icon_view(self, widget, event):
     '''
     Internal callback for `expose-event` signal.
     '''
     # Update vadjustment.
     self.update_vadjustment()    
     
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     # 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)
     
     # Draw items.
     self.draw_items(cr, rect, offset_x, offset_y, viewport)
Example #7
0
    def draw_title_background(self, cr, widget):
        (offset_x,
         offset_y) = widget.translate_coordinates(self.get_toplevel(), 0, 0)
        with cairo_state(cr):
            cr.translate(-offset_x, -offset_y)

            (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
            skin_config.render_background(cr, widget, shadow_x, shadow_y)
Example #8
0
    def expose_window(self, widget, event):
        """
        Internal function to expose the window.

        @param widget: A window of type Gtk.Widget.
        @param event: The expose event of type gtk.gdk.Event.

        @return: Always return True.
        """
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        x, y, w, h = rect.x, rect.y, rect.width, rect.height
        
        # Clear color to transparent window.
        cr.set_source_rgba(*self.background_color)
        cr.set_operator(cairo.OPERATOR_SOURCE)
        cr.paint()
        
        # Draw background.
        with cairo_state(cr):
            if self.window.get_state() != gtk.gdk.WINDOW_STATE_MAXIMIZED:
                cr.rectangle(x + 2, y, w - 4, 1)
                cr.rectangle(x + 1, y + 1, w - 2, 1)
                cr.rectangle(x, y + 2, w, h - 4)
                cr.rectangle(x + 2, y + h - 1, w - 4, 1)
                cr.rectangle(x + 1, y + h - 2, w - 2, 1)
                
                cr.clip()
            
            skin_config.render_background(cr, self, x, y)
        
            # Draw mask.
            self.draw_mask(cr, x, y, w, h)
            
        # Draw window frame.
        if self.window.get_state() != gtk.gdk.WINDOW_STATE_MAXIMIZED:
            draw_window_frame(cr, x, y, w, h,
                              ui_theme.get_alpha_color("window_frame_outside_1"),
                              ui_theme.get_alpha_color("window_frame_outside_2"),
                              ui_theme.get_alpha_color("window_frame_outside_3"),
                              ui_theme.get_alpha_color("window_frame_inside_1"),
                              ui_theme.get_alpha_color("window_frame_inside_2"),
                              )
        
        # Propagate expose.
        propagate_expose(widget, event)
        
        return True
Example #9
0
 def expose_dragable_tabbar(self, widget, event):
     '''
     docs
     '''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     x, w, h = rect.x, rect.width, rect.height
     y = 0
     
     # Draw background.
     (offset_x, offset_y) = widget.translate_coordinates(self.get_toplevel(), 0, 0)
     with cairo_state(cr):
         cr.translate(-offset_x, -offset_y)
         
         (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
         skin_config.render_background(cr, widget, shadow_x, shadow_y)
     
     # Draw inactive tab.
     draw_x_list = []
     width_offset = 0
     for (index, tab_name) in enumerate(self.names):
         draw_x_list.append(x + width_offset)
         width_offset += (self.name_widths[index] - (self.triangle_width + self.tab_radious * 2))
         
     for (index, tab_name) in enumerate(reversed(self.names)):
         tab_index = len(self.names) - index - 1
         if tab_index != self.active_index:
             self.draw_tab(cr, draw_x_list[tab_index], y, tab_name, tab_index)
             
     # Draw active tab.
     self.draw_tab(cr, draw_x_list[self.active_index], y, self.names[self.active_index], self.active_index)        
     
     # Draw bottom line.
     frame_color = alpha_color_hex_to_cairo(ui_theme.get_alpha_color("dragable_tab_bottom_active_frame").get_color_info())        
     cr.set_source_rgba(*frame_color)
     cr.rectangle(x, 
                  y + h - 1, 
                  draw_x_list[self.active_index],
                  1)
     cr.rectangle(x + draw_x_list[self.active_index] + self.name_widths[self.active_index], 
                  y + h - 1,
                  w - draw_x_list[self.active_index] - self.name_widths[self.active_index],
                  1)
     cr.fill()
     
     return True
Example #10
0
 def draw_background(self, widget, cr):
     with cairo_state(cr):
         scrolled_window = get_match_parent(self, ["ScrolledWindow"])
         (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
         (offset_x, offset_y) = self.translate_coordinates(self.get_toplevel(), 0, 0)
         vadjust = scrolled_window.get_vadjustment()    
         vadjust_value = int(vadjust.get_value())
         hadjust = scrolled_window.get_hadjustment()    
         hadjust_value = int(hadjust.get_value())
         
         x = shadow_x - offset_x
         y = shadow_y - offset_y
         
         cr.rectangle(hadjust_value, vadjust_value, scrolled_window.allocation.width, scrolled_window.allocation.height)
         cr.clip()
         cr.translate(x, y)
         skin_config.render_background(cr, widget, 0, 0)
Example #11
0
    def expose_background_box(self, widget, event):
        '''Expose background box.'''
        cr = widget.window.cairo_create()
        rect = widget.allocation
        toplevel = widget.get_toplevel()
        coordinate = widget.translate_coordinates(toplevel, rect.x, rect.y)
        (offset_x, offset_y) = coordinate
        
        with cairo_state(cr):
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.clip()
            
            (shadow_x, shadow_y) = get_window_shadow_size(toplevel)
            skin_config.render_background(cr, widget, shadow_x, shadow_y)
            
        self.draw_mask(cr, rect.x, rect.y, rect.width, rect.height)    

        return False
Example #12
0
    def draw_background(self, widget, cr):
        with cairo_state(cr):
            scrolled_window = get_match_parent(self, ["ScrolledWindow"])
            (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
            (offset_x,
             offset_y) = self.translate_coordinates(self.get_toplevel(), 0, 0)
            vadjust = scrolled_window.get_vadjustment()
            vadjust_value = int(vadjust.get_value())
            hadjust = scrolled_window.get_hadjustment()
            hadjust_value = int(hadjust.get_value())

            x = shadow_x - offset_x
            y = shadow_y - offset_y

            cr.rectangle(hadjust_value, vadjust_value,
                         scrolled_window.allocation.width,
                         scrolled_window.allocation.height)
            cr.clip()
            cr.translate(x, y)
            skin_config.render_background(cr, widget, 0, 0)
Example #13
0
 def expose_window(self, widget, event):
     '''Expose window.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     x, y, w, h = rect.x, rect.y, rect.width, rect.height
     
     # Clear color to transparent window.
     cr.set_source_rgba(0.0, 0.0, 0.0, 0.0)
     cr.set_operator(cairo.OPERATOR_SOURCE)
     cr.paint()
     
     # Draw background.
     with cairo_state(cr):
         cr.rectangle(x + 2, y, w - 4, 1)
         cr.rectangle(x + 1, y + 1, w - 2, 1)
         cr.rectangle(x, y + 2, w, h - 4)
         cr.rectangle(x + 2, y + h - 1, w - 4, 1)
         cr.rectangle(x + 1, y + h - 2, w - 2, 1)
         
         cr.clip()
         
         skin_config.render_background(cr, self, x, y)
     
         # Draw mask.
         self.draw_mask(cr, x, y, w, h)
         
     # Draw window frame.
     draw_window_frame(cr, x, y, w, h,
                       ui_theme.get_alpha_color("window_frame_outside_1"),
                       ui_theme.get_alpha_color("window_frame_outside_2"),
                       ui_theme.get_alpha_color("window_frame_outside_3"),
                       ui_theme.get_alpha_color("window_frame_inside_1"),
                       ui_theme.get_alpha_color("window_frame_inside_2"),
                       )
     
     # Propagate expose.
     propagate_expose(widget, event)
     
     return True
Example #14
0
 def draw_skin(self, cr, x, y, w, h):
     skin_config.render_background(cr, self, x, y)
Example #15
0
 def draw_skin(self, cr, x, y, w, h):
     skin_config.render_background(cr, self, x, y)
Example #16
0
 def expose_window_background(self, widget, event):
     '''Expose window background.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     # Clear color to transparent window.
     cr.set_source_rgba(0.0, 0.0, 0.0, 0.0)
     cr.set_operator(cairo.OPERATOR_SOURCE)
     cr.paint()
     
     # Save cairo context.
     if self.shadow_is_visible:
         x = rect.x + self.shadow_padding
         y = rect.y + self.shadow_padding
         w = rect.width - self.shadow_padding * 2
         h = rect.height - self.shadow_padding * 2
     else:
         x, y, w, h = rect.x, rect.y, rect.width, rect.height
         
     # Draw background.
     with cairo_state(cr):
         cr.rectangle(x + 2, y, w - 4, 1)
         cr.rectangle(x + 1, y + 1, w - 2, 1)
         cr.rectangle(x, y + 2, w, h - 4)
         cr.rectangle(x + 2, y + h - 1, w - 4, 1)
         cr.rectangle(x + 1, y + h - 2, w - 2, 1)
         
         cr.clip()
         
         skin_config.render_background(cr, self, x, y)
     
         # Draw mask.
         self.draw_mask(cr, x, y, w, h)
         
     # Draw corner shadow.
     with cairo_state(cr):
         cr.set_source_rgba(*alpha_color_hex_to_cairo(ui_theme.get_alpha_color("window_shadow_corner").get_color_info()))
         
         cr.rectangle(x, y + 1, 1, 1) # top-left
         cr.rectangle(x + 1, y, 1, 1)
         
         cr.rectangle(x + w - 1, y + 1, 1, 1) # top-right
         cr.rectangle(x + w - 2, y, 1, 1)
         
         cr.rectangle(x, y + h - 2, 1, 1) # bottom-left
         cr.rectangle(x + 1, y + h - 1, 1, 1)
         
         cr.rectangle(x + w - 1, y + h - 2, 1, 1) # bottom-right
         cr.rectangle(x + w - 2, y + h - 1, 1, 1)
         
         cr.fill()
         
     # Draw background corner.
     with cairo_state(cr):
         cr.rectangle(x, y + 1, 1, 1) # top-left
         cr.rectangle(x + 1, y, 1, 1)
         
         cr.rectangle(x + w - 1, y + 1, 1, 1) # top-right
         cr.rectangle(x + w - 2, y, 1, 1)
         
         cr.rectangle(x, y + h - 2, 1, 1) # bottom-left
         cr.rectangle(x + 1, y + h - 1, 1, 1)
         
         cr.rectangle(x + w - 1, y + h - 2, 1, 1) # bottom-right
         cr.rectangle(x + w - 2, y + h - 1, 1, 1)
         
         cr.clip()
         
         skin_config.render_background(cr, self, x, y)
         
     # Propagate expose.
     propagate_expose(widget, event)
     
     return True
Example #17
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     
Example #18
0
    def expose_tab_title_box(self, widget, event):
        '''
        Internal callback for `expose-event` signal.
        '''
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        # Draw background.
        (offset_x, offset_y) = widget.translate_coordinates(self.get_toplevel(), 0, 0)
        with cairo_state(cr):
            cr.translate(-offset_x, -offset_y)
            
            (shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
            skin_config.render_background(cr, widget, shadow_x, shadow_y)
        
        if len(self.tab_items) > 0:    
            # Draw title unselect tab.
            tab_title_width = sum(self.tab_title_widths)
            
            with cairo_state(cr):
                with cairo_disable_antialias(cr):
                    cr.rectangle(0,
                                 0,
                                 sum(self.tab_title_widths[0:self.tab_index]),
                                 self.tab_height)
                    cr.rectangle(sum(self.tab_title_widths[0:min(self.tab_index + 1, len(self.tab_items))]) + 1,
                                 0,
                                 sum(self.tab_title_widths) - sum(self.tab_title_widths[0:min(self.tab_index + 1, len(self.tab_items))]),
                                 self.tab_height)
                    cr.clip()
                    
                    cr.set_source_rgba(*alpha_color_hex_to_cairo((self.tab_unselect_bg_color.get_color(), 0.7)))
                    cr.rectangle(1, 1, tab_title_width, self.tab_height)
                    cr.fill()
                        
                    cr.set_line_width(1)
                    cr.set_source_rgba(*alpha_color_hex_to_cairo((self.tab_unselect_frame_color.get_color(), 1.0)))
                    cr.rectangle(1, 1, tab_title_width, self.tab_height)
                    cr.stroke()
                    
                    for (index, width) in enumerate(self.tab_title_widths[:-1]):
                        cr.set_source_rgba(*alpha_color_hex_to_cairo((self.tab_unselect_frame_color.get_color(), 1.0)))
                        cr.rectangle(1 + sum(self.tab_title_widths[0:index]) + width,
                                     1,
                                     1,
                                     self.tab_height)
                        cr.fill()
                        
                    cr.set_source_rgb(*color_hex_to_cairo(self.tab_select_frame_color.get_color()))    
                    cr.rectangle(0,
                                 rect.height - 1,
                                 sum(self.tab_title_widths[0:self.tab_index]),
                                 1)
                    cr.fill()
                
                    cr.set_source_rgb(*color_hex_to_cairo(self.tab_select_frame_color.get_color()))    
                    cr.rectangle(1 + sum(self.tab_title_widths[0:self.tab_index]),
                                 rect.height - 1,
                                 rect.width - sum(self.tab_title_widths[0:self.tab_index]),
                                 1)
                    cr.fill()
                            
            for (index, item) in enumerate(self.tab_items):
                # Draw title background.
                title = item[0]
                
                # Draw title tab.
                with cairo_disable_antialias(cr):
                    if index == self.tab_index:
                        # Draw title select tab.
                        cr.set_source_rgba(*alpha_color_hex_to_cairo((self.tab_select_bg_color.get_color(), 0.93)))    
                        if index == 0:
                            cr.rectangle(sum(self.tab_title_widths[0:index]),
                                         1,
                                         self.tab_title_widths[index] + 1,
                                         self.tab_height)
                        else:
                            cr.rectangle(1 + sum(self.tab_title_widths[0:index]),
                                         1,
                                         self.tab_title_widths[index],
                                         self.tab_height)
                        cr.fill()
                        
                        if index == 0:
                            cr.rectangle(0,
                                         0,
                                         rect.width,
                                         self.tab_height)
                            cr.clip()
                            
                        cr.set_line_width(1)
                        cr.set_source_rgb(*color_hex_to_cairo(self.tab_select_frame_color.get_color()))    
                        if index == 0:
                            cr.rectangle(sum(self.tab_title_widths[0:index]),
                                         1,
                                         self.tab_title_widths[index] + 2,
                                         self.tab_height)
                        else:
                            cr.rectangle(1 + sum(self.tab_title_widths[0:index]),
                                         1,
                                         self.tab_title_widths[index] + 1,
                                         self.tab_height)
                        cr.stroke()
                        
                draw_text(cr, title, 
                          sum(self.tab_title_widths[0:index]) + self.tab_padding_x,
                          self.tab_padding_y,
                          self.tab_title_widths[index] - self.tab_padding_x * 2,
                          self.tab_height - self.tab_padding_y * 2,
                          )
                
                # Draw close button.
                if self.can_close_tab:
                    button_x = sum(self.tab_title_widths[0:index + 1]) - self.close_button_padding_x - self.close_button_size
                    button_y = self.close_button_padding_y
                    
                    if self.hover_close_button_index == index:
                        cr.set_source_rgb(*color_hex_to_cairo(self.close_button_select_background_color))
                        draw_round_rectangle(
                            cr,
                            button_x - self.close_button_frame_size,
                            button_y - self.close_button_frame_size,
                            self.close_button_size + self.close_button_frame_size * 2,
                            self.close_button_size + self.close_button_frame_size * 2,
                            2
                            )
                        cr.fill()
                    
                    cr.set_line_width(1.5)
                    if self.hover_close_button_index == index:
                        cr.set_source_rgb(*color_hex_to_cairo(self.close_button_select_foreground_color))
                    else:
                        cr.set_source_rgb(*color_hex_to_cairo(self.close_button_color))
                    cr.move_to(button_x, button_y)
                    cr.line_to(button_x + self.close_button_size, button_y + self.close_button_size)
                    cr.stroke()

                    cr.move_to(button_x + self.close_button_size, button_y)
                    cr.line_to(button_x, button_y + self.close_button_size)
                    cr.stroke()
        else:
            cr.set_source_rgba(*alpha_color_hex_to_cairo((self.tab_select_bg_color.get_color(), 0.93)))
            cr.rectangle(0, 0, rect.width, rect.height)
            cr.fill()
Example #19
0
 def expose_icon_view(self, widget, event):
     '''Expose list view.'''
     # Update vadjustment.
     self.update_vadjustment()    
     
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     # 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)
         
     # Draw item.
     if len(self.items) > 0:
         with cairo_state(cr):
             # Don't draw any item out of viewport area.
             cr.rectangle(offset_x, offset_y,
                          viewport.allocation.width, 
                          viewport.allocation.height)        
             cr.clip()
             
             # Draw item.
             item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
             scrolled_window = get_match_parent(self, ["ScrolledWindow"])
             columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
                 
             # Get viewport index.
             start_y = offset_y - self.padding_y
             start_row = max(int(start_y / item_height), 0)
             start_index = start_row * columns
             
             end_y = offset_y - self.padding_y + viewport.allocation.height
             if end_y % item_height == 0:
                 end_row = end_y / item_height - 1
             else:
                 end_row = end_y / item_height
             end_index = min((end_row + 1) * columns, len(self.items))
             
             for (index, item) in enumerate(self.items[start_index:end_index]):
                 row = int((start_index + index) / columns)
                 column = (start_index + index) % columns
                 render_x = rect.x + self.padding_x + column * item_width
                 render_y = rect.y + self.padding_y + row * item_height
                 
                 with cairo_state(cr):
                     # Don't allow draw out of item area.
                     cr.rectangle(render_x, render_y, item_width, item_height)
                     cr.clip()
                     
                     item.render(cr, gtk.gdk.Rectangle(render_x, render_y, item_width, item_height))
Example #20
0
    def expose_window_background(self, widget, event):
        """
        Internal function to expose the window background.

        @param widget: A window of type Gtk.Widget.
        @param event: The expose event of type gtk.gdk.Event.
        @return: Always return True.
        """
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        # Clear color to transparent window.
        cr.set_source_rgba(*self.background_color)
        cr.set_operator(cairo.OPERATOR_SOURCE)
        cr.paint()
        
        # Save cairo context.
        if self.shadow_is_visible:
            x = rect.x + self.shadow_padding
            y = rect.y + self.shadow_padding
            w = rect.width - self.shadow_padding * 2
            h = rect.height - self.shadow_padding * 2
        else:
            x, y, w, h = rect.x, rect.y, rect.width, rect.height
            
        # Draw background.
        with cairo_state(cr):
            if self.window.get_state() != gtk.gdk.WINDOW_STATE_MAXIMIZED:
                cr.rectangle(x + 2, y, w - 4, 1)
                cr.rectangle(x + 1, y + 1, w - 2, 1)
                cr.rectangle(x, y + 2, w, h - 4)
                cr.rectangle(x + 2, y + h - 1, w - 4, 1)
                cr.rectangle(x + 1, y + h - 2, w - 2, 1)
                
                cr.clip()
            
            skin_config.render_background(cr, self, x, y)
        
            # Draw mask.
            self.draw_mask(cr, x, y, w, h)
            
        # Draw corner shadow.
        with cairo_state(cr):
            cr.set_source_rgba(*alpha_color_hex_to_cairo(ui_theme.get_alpha_color("window_shadow_corner").get_color_info()))
            
            cr.rectangle(x, y + 1, 1, 1) # top-left
            cr.rectangle(x + 1, y, 1, 1)
            
            cr.rectangle(x + w - 1, y + 1, 1, 1) # top-right
            cr.rectangle(x + w - 2, y, 1, 1)
            
            cr.rectangle(x, y + h - 2, 1, 1) # bottom-left
            cr.rectangle(x + 1, y + h - 1, 1, 1)
            
            cr.rectangle(x + w - 1, y + h - 2, 1, 1) # bottom-right
            cr.rectangle(x + w - 2, y + h - 1, 1, 1)
            
            cr.fill()
            
        # Draw background corner.
        with cairo_state(cr):
            cr.rectangle(x, y + 1, 1, 1) # top-left
            cr.rectangle(x + 1, y, 1, 1)
            
            cr.rectangle(x + w - 1, y + 1, 1, 1) # top-right
            cr.rectangle(x + w - 2, y, 1, 1)
            
            cr.rectangle(x, y + h - 2, 1, 1) # bottom-left
            cr.rectangle(x + 1, y + h - 1, 1, 1)
            
            cr.rectangle(x + w - 1, y + h - 2, 1, 1) # bottom-right
            cr.rectangle(x + w - 2, y + h - 1, 1, 1)
            
            cr.clip()
            
            skin_config.render_background(cr, self, x, y)
            
        # Propagate expose.
        propagate_expose(widget, event)
        
        return True