Esempio n. 1
0
    def draw(self, cr, hover=None):
        if hover is not None:
            hover, Hside = hover
        
        set_fonts(cr, * self._cells[0][1][:2] )
        for i, ((cx, cy, ch, ck), textline) in enumerate(self._cells):
            count = self._table[i][0]
            if count: # nonzero count
                if count > 0:
                    R = range(count)
                    bg = accent
                else:
                    R = reversed(range(0, count, -1))
                    bg = negative_accent
                for c in R:
                    cr.set_source_rgba(1, 1, 1, 0.5)
                    cr.rectangle(cx + 2*c - 1, cy - 2*c + 1, ch, ck)
                    cr.fill()
                    cr.set_source_rgb( * bg )
                    cr.rectangle(cx + 2*c, cy - 2*c, ch, ck)
                    cr.fill()
                
                offset = max(0, (count - 1) * 2)
                
                cr.set_source_rgb(1, 1, 1)
                cr.show_glyphs((g[0], g[1] + offset, g[2] - offset) for g in textline[2])
                minus_sign(cr, cx - 2 + offset, cy - 1 - offset)
                plus_sign(cr, cx + ch - 24 + offset, cy - 1 - offset)
                
                cr.fill()
                continue
            
            elif hover == i:
                minus_sign(cr, cx - 2, cy)
                if Hside:
                    cr.set_source_rgba(0, 0, 0, 0.7)
                else:
                    cr.set_source_rgb( * accent )
                cr.fill()

                plus_sign(cr, cx + ch - 24, cy)
                if Hside:
                    cr.set_source_rgb( * accent )
                else:
                    cr.set_source_rgba(0, 0, 0, 0.7)
                cr.fill()

                cr.set_source_rgb( * accent )
                cr.show_glyphs(textline[2])
            
            else:
                cr.set_source_rgba(0, 0, 0, 0.7)
                cr.show_glyphs(textline[2])
Esempio n. 2
0
 def draw(self, cr, hover=None):
     if hover is None:
         ink = (1, 1, 1), (0.4, 0.4, 0.4), (0.4, 0.4, 0.4), negative_accent
     else:
         ink = (1, 1, 1), (0  , 0  , 0  ), (0.2, 0.2, 0.2), negative_accent_dark
     if self._state:
         half_pi = pi*0.5
         radius = 13
         centerline = self._from_top + 13
         cr.arc(self._zero + radius - 6, centerline, radius,  half_pi, -half_pi)
         cr.arc( self._one - radius + 6, centerline, radius, -half_pi,  half_pi)
         cr.close_path()
         ink = ink[2 + (self._state < 0)], ink[0]
         cr.set_source_rgba( * ink[0] )
         cr.fill()
         hover = None
     
     inks = [ink[1]] * 3
     if hover is not None:
         inks[hover - 1] = accent
     
     cr.set_source_rgba( * inks[0] )
     show_text(cr, self._label)
     if self._state < 0:
         cr.fill()
         cr.set_line_width(2)
         cross(cr, self._anchors[0], self._from_top)
         cr.stroke()
     else:
         show_text(cr, self._number)
         cr.fill()
     
     cr.set_source_rgba( * inks[1] )
     minus_sign(cr, self._anchors[2] - 6, self._from_top)
     cr.fill()
     
     cr.set_source_rgba( * inks[2] )
     plus_sign (cr, self._anchors[3] - 6, self._from_top)
     cr.fill()
Esempio n. 3
0
 def draw(self, cr, hover=None):
     cr.set_line_width(2)
     if self._dropdown_active or hover == 1:
         colors = [accent] + [(0, 0, 0, 0.7)] * 3
     else:
         colors = [(0, 0, 0, 0.7)] * 4
     
     if hover is not None:
         colors[hover - 1] = accent
     
     # v
     cr.set_source_rgba( * colors[0] )
     downchevron(cr, 3, 1)
     cr.stroke()
     
     if self._O is None:
         # +
         cr.set_source_rgba( * colors[2] )
         show_text(cr, self._nonelabel)
         plus_sign(cr, self._d3, 1)
         cr.fill()
     else:
         cr.save()
         cr.translate(self._d1, 0)
         self._NAMEWIDGET.draw(cr, hover)
         cr.restore()
         
         # +
         cr.set_source_rgba( * colors[2] )
         plus_sign(cr, self._d2, 1)
         cr.fill()
         
         # x
         cr.set_source_rgba( * colors[3] )
         cross(cr, self._d3, 1)
         cr.stroke()
Esempio n. 4
0
    def draw(self, cr, hover=(None, None)):
        cr.set_line_width(2)
        
        y1 = self._y
        for i, (value, textlines) in enumerate(zip(self._fullcontent, self._labels)):
            if value is self._active:
                radius = 5
                halfpi = pi*0.5
                y2 = y1 + self._itemheight
                cr.move_to(self._x           , y1 + radius)
                cr.arc(self._x       + radius, y1 + radius, radius, pi      , 3*halfpi)
                cr.arc(self._x_right - radius, y1 + radius, radius, 3*halfpi, 2*pi    )
                cr.arc(self._x_right - radius, y2 - radius, radius, 0       , halfpi  )
                cr.arc(self._x       + radius, y2 - radius, radius, halfpi  , pi      )
                cr.close_path()
                
                if self._colored(value):
                    cr.set_source_rgb( * accent )
                else:
                    cr.set_source_rgb(0.7, 0.7, 0.7)
                cr.fill()

                cr.set_source_rgb(1, 1, 1)
                upchevron(cr, self._subdivisions[0], y1)
                downchevron(cr, self._subdivisions[1], y1)
                cross(cr, self._subdivisions[2], y1)
                cr.stroke()

            elif hover[1] is not None and hover[1][0] == i:
                colors = [(0.3, 0.3, 0.3)] * 3
                if hover[1][1] > 1:
                    colors[hover[1][1] - 2] = accent
                
                cr.set_source_rgba( * colors[0] )
                upchevron(cr, self._subdivisions[0], y1)
                cr.stroke()

                cr.set_source_rgba( * colors[1] )
                downchevron(cr, self._subdivisions[1], y1)
                cr.stroke()

                cr.set_source_rgba( * colors[2] )
                cross(cr, self._subdivisions[2], y1)
                cr.stroke()
                
                if self._colored(value):
                    cr.set_source_rgba( * accent )
                else:
                    cr.set_source_rgb(0.6, 0.6, 0.6)

            elif self._colored(value):
                cr.set_source_rgb(0.3, 0.3, 0.3)

            else:
                cr.set_source_rgb(0.6, 0.6, 0.6)
            
            for textline in textlines:
                show_text(cr, textline)
            y1 += self._itemheight

        if hover[1] is not None and hover[1][0] == self._LMAX:
            cr.set_source_rgb( * accent )
        else:
            cr.set_source_rgb(0.3, 0.3, 0.3)
        plus_sign(cr, self._x, y1)
        cr.fill()
Esempio n. 5
0
    def draw(self, cr, hover=(None, None)):
        cr.set_line_width(2)

        y1 = self._y
        for i, (value,
                textlines) in enumerate(zip(self._fullcontent, self._labels)):
            if value is self._active:
                radius = 5
                halfpi = pi * 0.5
                y2 = y1 + self._itemheight
                cr.move_to(self._x, y1 + radius)
                cr.arc(self._x + radius, y1 + radius, radius, pi, 3 * halfpi)
                cr.arc(self._x_right - radius, y1 + radius, radius, 3 * halfpi,
                       2 * pi)
                cr.arc(self._x_right - radius, y2 - radius, radius, 0, halfpi)
                cr.arc(self._x + radius, y2 - radius, radius, halfpi, pi)
                cr.close_path()

                if self._colored(value):
                    cr.set_source_rgb(*accent)
                else:
                    cr.set_source_rgb(0.7, 0.7, 0.7)
                cr.fill()

                cr.set_source_rgb(1, 1, 1)
                upchevron(cr, self._subdivisions[0], y1)
                downchevron(cr, self._subdivisions[1], y1)
                cross(cr, self._subdivisions[2], y1)
                cr.stroke()

            elif hover[1] is not None and hover[1][0] == i:
                colors = [(0.3, 0.3, 0.3)] * 3
                if hover[1][1] > 1:
                    colors[hover[1][1] - 2] = accent

                cr.set_source_rgba(*colors[0])
                upchevron(cr, self._subdivisions[0], y1)
                cr.stroke()

                cr.set_source_rgba(*colors[1])
                downchevron(cr, self._subdivisions[1], y1)
                cr.stroke()

                cr.set_source_rgba(*colors[2])
                cross(cr, self._subdivisions[2], y1)
                cr.stroke()

                if self._colored(value):
                    cr.set_source_rgba(*accent)
                else:
                    cr.set_source_rgb(0.6, 0.6, 0.6)

            elif self._colored(value):
                cr.set_source_rgb(0.3, 0.3, 0.3)

            else:
                cr.set_source_rgb(0.6, 0.6, 0.6)

            for textline in textlines:
                show_text(cr, textline)
            y1 += self._itemheight

        if hover[1] is not None and hover[1][0] == self._LMAX:
            cr.set_source_rgb(*accent)
        else:
            cr.set_source_rgb(0.3, 0.3, 0.3)
        plus_sign(cr, self._x, y1)
        cr.fill()