Beispiel #1
0
    def __init__(self, size=None, color=None, clip="auto", radius_ext=None,
                 radius_int=None, pressed=False, dark=None, light=None, thick=1,
                 hovered=False, border_color=None): #changer border
        """If radius is in the range [0, 1], self.radius_value is the fraction
        of radius * min(size), else it is interpreted as a raw pixel value.
        """
        if clip == "auto":
            inflation = -2 * thick
            clip = (inflation, inflation)
        ClassicFrame.__init__(self,
                              size=size,
                              color=color,
                              pressed=pressed,
                              hovered=hovered,
                              dark=dark,
                              light=light,
                              thick=thick,
                              clip=clip)
        radius_value = style.DEF_RADIUS if radius_ext is None else radius_ext
        if 0. <= radius_value <= 1.:
            radius_value = min(self.size) * radius_value
        self.radius_ext = radius_value
        self.radius_int = radius_int
        if radius_int == None:
            self.radius_int = self.radius_ext - self.thick

        self.border_color = style.BORDER_FACT if border_color is None else border_color
        if isinstance(self.border_color, float):
            self.border_color = normalize_color(grow_color(self.border_color,
                                                           self.color))
 def __init__(self, size=style.SIZE, color=style.DEF_COLOR, pressed=False,
              dark=None, light=None, thick=1, clip="auto",
              ambient=style.DEF_COLOR3, hfact=0.6):
     self.thick = 1
     if clip is "auto":
         inflation = -2 * thick
         clip = (inflation, inflation)
     ClassicFrame.__init__(self, size, color, pressed, dark, light, thick,
                           clip)
     self.ambient = ambient
     self.hfact = hfact
 def draw(self, title_length):
     # actual surface (transparent):
     surface = Surface(self.size, flags=SRCALPHA).convert_alpha()
     surface.fill((0, 0, 0, 0))
     # computing frame length: tot = title + space + frame
     frame_length = self.size[0] - title_length - self.space
     frame_size = (frame_length, self.size[1])
     self.txt_zone = Rect((title_length + self.space, 0), frame_size)
     frame_painter = ClassicFrame(frame_size, self.color, True, self.dark,
                                  self.light, self.thick)
     # frame in which text will be inserted:
     frame = frame_painter.get_surface()
     surface.blit(frame, (title_length + self.space, 0))
     return surface
Beispiel #4
0
 def draw(self, title_length):
     # actual surface (transparent):
     surface = Surface(self.size, flags=SRCALPHA).convert_alpha()
     surface.fill((0, 0, 0, 0))
     # computing frame length: tot = title + space + frame
     frame_length = self.size[0] - title_length - self.space
     frame_size = (frame_length, self.size[1])
     self.txt_zone = Rect((title_length + self.space, 0), frame_size)
     frame_painter = ClassicFrame(frame_size, self.color, True, self.dark,
                                  self.light, self.thick)
     # frame in which text will be inserted:
     frame = frame_painter.get_surface()
     surface.blit(frame, (title_length + self.space, 0))
     return surface
 def __init__(self, size=None, color=None, clip="auto", radius_ext=12,
              radius_int=10, pressed=False, dark=None, light=None, thick=1,
              border_color=None): #changer border
     """Radius = [0, 1]"""
     if clip == "auto":
         inflation = -2 * thick
         clip = (inflation, inflation)
     ClassicFrame.__init__(self, size, color, pressed, dark, light, thick,
                           clip)
     self.radius_int = radius_int
     self.radius_ext = radius_ext
     self.border_color = style.BORDER_FACT if border_color is None else border_color
     if isinstance(self.border_color, float):
         self.border_color = normalize_color(grow_color(self.border_color,
                                                        self.color))
Beispiel #6
0
 def __init__(self, size=None, color=None, pressed=False, space=8, dark=None,
              light=None, thick=1, clip="auto"):
     size = style.XLARGE_SIZE if size is None else size
     color = style.DEF_COLOR2 if color is None else color
     ClassicFrame.__init__(self,
                           size=size,
                           color=color,
                           pressed=pressed,
                           hovered=hovered,
                           dark=dark,
                           light=light,
                           thick=thick,
                           clip=clip)
     self.space = space
     self.txt_zone = None
 def __init__(self, size=None, color=None, pressed=False, space=8, dark=None,
              light=None, thick=1, clip="auto"):
     size = style.XLARGE_SIZE if size is None else size
     color = style.DEF_COLOR2 if color is None else color
     ClassicFrame.__init__(self,
                           size=size,
                           color=color,
                           pressed=pressed,
                           hovered=hovered,
                           dark=dark,
                           light=light,
                           thick=thick,
                           clip=clip)
     self.space = space
     self.txt_zone = None
Beispiel #8
0
 def draw(self):
     surface = ClassicFrame.draw(self)
     h = int(self.hfact * self.size[1])
     linear_v_monogradation(surface, 1, h, self.light, self.ambient, 1)
     linear_v_monogradation(surface, h + 1, self.size[1], self.dark,
                            self.color, 1)
     return surface
 def __init__(self,
              size=style.SIZE,
              color=style.DEF_COLOR,
              pressed=False,
              dark=None,
              light=None,
              thick=1,
              clip="auto",
              ambient=style.DEF_COLOR3,
              hfact=0.6):
     self.thick = 1
     if clip is "auto":
         inflation = -2 * thick
         clip = (inflation, inflation)
     ClassicFrame.__init__(self, size, color, pressed, dark, light, thick,
                           clip)
     self.ambient = ambient
     self.hfact = hfact
    def set_color(self, color):
        ClassicFrame.set_color(self, color)
        if len(color) == 4:
            self.border_color = tuple(list(self.border_color) + [color[3]])



##class RoundReflect(ClassicFrame):
##
##    def __init__(self, size=None, color=None, clip="auto", radius_ext=12,
##                 radius_int=10, pressed=False, dark=None, light=None, thick=1):
##        """Radius = [0, 1]"""
##        if clip == "auto":
##            inflation = -2 * thick
##            clip = (inflation, inflation)
##        ClassicFrame.__init__(self, size, color, pressed, dark, light, thick,
##                              clip)
##        self.radius_int = radius_int
##        self.radius_ext = radius_ext
##
##    def draw(self):
##        exterior = RoundRect(self.size, self.dark, self.clip, self.radius_ext)
##        w, h = (self.size[0] - 2*self.thick, self.size[1] - 2*self.thick)
##        w = 0 if w < 0 else w
##        h = 0 if h < 0 else h
##        int_size = (w, h)
##        if self.pressed:
##            interior = RoundRect(int_size, self.color, self.clip, self.radius_int)
##        else:
##            interior = RoundRect(int_size, self.light, self.clip, self.radius_int)
##        sext = exterior.draw()
##        sint = interior.draw()
##        degrad = Surface(int_size)
##        semih = int(int_size[1]/2)
##        if self.pressed:
##            linear_v_monogradation(degrad, 0, semih, self.dark, self.color)
##            sint.blit(degrad, (0, semih), special_flags=BLEND_RGBA_MIN)
##        else:
##            linear_v_monogradation(degrad, 0, semih, self.light, self.color)
##            sint.blit(degrad, (0, semih), special_flags=BLEND_RGBA_MIN)
##        sext.blit(sint, (self.thick, self.thick))
##        return sext
    def set_color(self, color):
        ClassicFrame.set_color(self, color)
        if len(color) == 4:
            self.border_color = tuple(list(self.border_color) + [color[3]])


##class RoundReflect(ClassicFrame):
##
##    def __init__(self, size=None, color=None, clip="auto", radius_ext=12,
##                 radius_int=10, pressed=False, dark=None, light=None, thick=1):
##        """Radius = [0, 1]"""
##        if clip == "auto":
##            inflation = -2 * thick
##            clip = (inflation, inflation)
##        ClassicFrame.__init__(self, size, color, pressed, dark, light, thick,
##                              clip)
##        self.radius_int = radius_int
##        self.radius_ext = radius_ext
##
##    def draw(self):
##        exterior = RoundRect(self.size, self.dark, self.clip, self.radius_ext)
##        w, h = (self.size[0] - 2*self.thick, self.size[1] - 2*self.thick)
##        w = 0 if w < 0 else w
##        h = 0 if h < 0 else h
##        int_size = (w, h)
##        if self.pressed:
##            interior = RoundRect(int_size, self.color, self.clip, self.radius_int)
##        else:
##            interior = RoundRect(int_size, self.light, self.clip, self.radius_int)
##        sext = exterior.draw()
##        sint = interior.draw()
##        degrad = Surface(int_size)
##        semih = int(int_size[1]/2)
##        if self.pressed:
##            linear_v_monogradation(degrad, 0, semih, self.dark, self.color)
##            sint.blit(degrad, (0, semih), special_flags=BLEND_RGBA_MIN)
##        else:
##            linear_v_monogradation(degrad, 0, semih, self.light, self.color)
##            sint.blit(degrad, (0, semih), special_flags=BLEND_RGBA_MIN)
##        sext.blit(sint, (self.thick, self.thick))
##        return sext
Beispiel #12
0
    def __init__(self,
                 size=None,
                 color=None,
                 clip="auto",
                 radius_ext=None,
                 radius_int=None,
                 pressed=False,
                 dark=None,
                 light=None,
                 thick=1,
                 hovered=False,
                 border_color=None):  #changer border
        """If radius is in the range [0, 1], self.radius_value is the fraction
        of radius * min(size), else it is interpreted as a raw pixel value.
        """
        if clip == "auto":
            inflation = -2 * thick
            clip = (inflation, inflation)
        ClassicFrame.__init__(self,
                              size=size,
                              color=color,
                              pressed=pressed,
                              hovered=hovered,
                              dark=dark,
                              light=light,
                              thick=thick,
                              clip=clip)
        radius_value = style.DEF_RADIUS if radius_ext is None else radius_ext
        if 0. <= radius_value <= 1.:
            radius_value = min(self.size) * radius_value
        self.radius_ext = radius_value
        self.radius_int = radius_int
        if radius_int == None:
            self.radius_int = self.radius_ext - self.thick

        self.border_color = style.BORDER_FACT if border_color is None else border_color
        if isinstance(self.border_color, float):
            self.border_color = normalize_color(
                grow_color(self.border_color, self.color))
Beispiel #13
0
 def __init__(self, size, type_, color=None, pressed=True):
     """Set type_ to 'horizontal' or 'vertical' in order to produce a graphi-
     cal line of desired, color, size [px].
     """
     Element.__init__(self)
     self.size = size
     self.type = type_
     if type_ == "horizontal" or type_ == "h":
         size = (size, 2)
     elif type_ == "vertical" or type_ == "v":
         size = (2, size)
     painter = ClassicFrame(size, color, pressed)
     self.set_painter(painter)
 def __init__(self,
              size=None,
              color=None,
              clip="auto",
              radius_ext=12,
              radius_int=10,
              pressed=False,
              dark=None,
              light=None,
              thick=1,
              border_color=None):  #changer border
     """Radius = [0, 1]"""
     if clip == "auto":
         inflation = -2 * thick
         clip = (inflation, inflation)
     ClassicFrame.__init__(self, size, color, pressed, dark, light, thick,
                           clip)
     self.radius_int = radius_int
     self.radius_ext = radius_ext
     self.border_color = style.BORDER_FACT if border_color is None else border_color
     if isinstance(self.border_color, float):
         self.border_color = normalize_color(
             grow_color(self.border_color, self.color))
Beispiel #15
0
 def __init__(self, size, type_, color=None, pressed=True):
     """Vertical or horizontal graphical separation Line.
     <size>: the size in pixel (single int value).
     <type>: either 'horizontal', 'h' or 'vertical', 'v'.
     <color>: a 3 or 4-tuple specifying the color.
     <pressed>: if True, the line looks pressed.
     """
     Element.__init__(self)
     self.size = size
     self.type = type_
     if type_ == "horizontal" or type_ == "h":
         size = (size, 2)
     elif type_ == "vertical" or type_ == "v":
         size = (2, size)
     painter = ClassicFrame(size, color, pressed)
     self.set_painter(painter)
Beispiel #16
0
 def set_color(self, color):
     ClassicFrame.set_color(self, color)
     if len(color) == 4:
         self.border_color = tuple(list(self.border_color) + [color[3]])
Beispiel #17
0
 def set_color(self, color):
     ClassicFrame.set_color(self, color)
     if len(color) == 4:
         self.border_color = tuple(list(self.border_color) + [color[3]])
 def draw(self):
     surface = ClassicFrame.draw(self)
     h = int(self.hfact*self.size[1])
     linear_v_monogradation(surface, 1, h, self.light, self.ambient, 1)
     linear_v_monogradation(surface, h+1, self.size[1], self.dark, self.color, 1)
     return surface