Esempio n. 1
0
 def draw_background(self):
     set_color(*self.style.get('bg-color'))
     state = 'active' is self._is_active_input or None
     drawCSSRectangle(pos=self.pos,
                      size=self.size,
                      style=self.style,
                      state=state)
Esempio n. 2
0
    def draw(self):
        px, py = self.style['padding']
        px2, py2 = px / 2, py / 2
        if self.orientation == 'vertical':
            pos = (self.x + px2, self.y + self.value_min * self.ratio + py2)
            size = (self.width - px, (self.value_max - self.value_min) *
                    self.ratio - py)
            textposmin = (self.x + self.width, self.y + self.value_min * self.ratio)
            textposmax = (self.x + self.width, self.y + self.value_max * self.ratio)
        elif self.orientation == 'horizontal':
            pos = (self.x + self.value_min * self.ratio + px2, self.y + py2)
            size = ((self.value_max - self.value_min) * self.ratio - px,
                    self.height - py)
            textposmin = (self.x + self.value_min * self.ratio, self.y + self.height)
            textposmax = (self.x + self.value_max * self.ratio, self.y + self.height)

        # draw outer rectangle
        set_color(*self.style.get('bg-color'))
        drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)

        # draw inner rectangle
        set_color(*self.style.get('slider-color'))
        drawCSSRectangle(pos=pos, size=size, style=self.style, prefix='slider')
        if self.showtext and len(self.touchstarts):
            drawLabel(u'%.1f' % (self.value_min), pos=textposmin, font_size=self.style['font-size'])
            drawLabel(u'%.1f' % (self.value_max), pos=textposmax, font_size=self.style['font-size'])
Esempio n. 3
0
    def draw(self):
        # background
        set_color(*self.style['bg-color'])
        drawCSSRectangle(size=self.size, style=self.style)

        # content dynamic update
        with gx_matrix:
            glTranslatef(self.style['margin'][3], self.style['margin'][2], 0)

            # draw precalculated background
            self._current_cache['background'].draw()

            # draw active keys layer
            # +2 and -4 result of hard margin coded in _do_update (m = 3 * s)
            # we substract 1 cause of border (draw-border is activated.)
            set_color(*self.style['color-down'])
            for key, size in self._active_keys:
                x, y, w, h = size
                drawCSSRectangle(pos=(x+2, y+2), size=(w-4, h-4),
                    style=self.style, prefix='key', state='down')

            # search the good scale for current precalculated keys layer
            if self._last_update_scale == self.scale:
                s = 1. / self.scale# / self._last_update_scale
                glScalef(s, s, s)
            else:
                s = 1. / self._last_update_scale
                glScalef(s, s, s)
            self._current_cache['keys'].draw()
Esempio n. 4
0
 def draw(self):
     w = self.get_parent_window()
     if not w:
         return
     self.size = w.size
     set_color(*self.style['bg-color'])
     drawCSSRectangle(size=self.size, style=self.style)
Esempio n. 5
0
    def draw(self):
        px, py = self.style['padding']
        px2, py2 = px / 2., py / 2.
        diff = self.max - self.min
        if self.orientation == 'vertical':
            if diff == 0:
                length = 0
            else:
                length = int((self._value - self.min) * \
                             (self.height - py) / diff)
            pos = self.x + px2, self.y + py2
            size = self.width - px, length
        else:
            if diff == 0:
                length = 0
            else:
                length = int((self._value - self.min) * \
                             (self.width - px) / diff)
            pos = self.x + px2, self.y + py2
            size = length, self.height - py

        # draw outer rectangle
        set_color(*self.style.get('bg-color'))
        drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)

        # draw inner rectangle
        if self.touchstarts:
            set_color(*self.style.get('slider-color-down'))
        else:
            set_color(*self.style.get('slider-color'))
        drawCSSRectangle(pos=pos, size=size, style=self.style, prefix='slider')

        if self.value_show:
            self.draw_value()
Esempio n. 6
0
 def draw(self):
     if not self.layout.visible:
         return
     set_color(*self.style.get('bg-color'))
     drawCSSRectangle(pos=self.layout.pos,
                      size=self.layout.size,
                      style=self.style)
Esempio n. 7
0
 def draw(self):
     b = self.bordersize
     b2 = b * 2
     set_color(*self.style['bg-color'])
     drawCSSRectangle((-b, -b), (self.width + b2, self.height + b2),
                      style=self.style)
     super(MTVideo, self).draw()
Esempio n. 8
0
 def on_popup_draw(self):
     self._xml.root.center = self.get_parent_window().center
     popup = self._xml.getById('popup')
     set_color(*self.style.get('bg-color-full'))
     drawCSSRectangle(pos=Vector(popup.pos) - (10, 10),
                      size=Vector(popup.size) + (20, 20),
                      style=self.style)
Esempio n. 9
0
 def draw(self):
     w = self.get_parent_window()
     if not w:
         return
     self.size = w.size
     set_color(*self.style['bg-color'])
     drawCSSRectangle(size=self.size, style=self.style)
Esempio n. 10
0
    def draw(self):
        # background
        set_color(*self.style['bg-color'])
        drawCSSRectangle(size=self.size, style=self.style)

        # content dynamic update
        with gx_matrix:
            glTranslatef(self.style['margin'][3], self.style['margin'][2], 0)

            # draw precalculated background
            self._current_cache['background'].draw()

            # draw active keys layer
            # +2 and -4 result of hard margin coded in _do_update (m = 3 * s)
            # we substract 1 cause of border (draw-border is activated.)
            set_color(*self.style['color-down'])
            for key, size in self._active_keys:
                x, y, w, h = size
                drawCSSRectangle(pos=(x+2, y+2), size=(w-4, h-4),
                    style=self.style, prefix='key', state='down')

            # search the good scale for current precalculated keys layer
            if self._last_update_scale == self.scale:
                s = 1. / self.scale# / self._last_update_scale
                glScalef(s, s, s)
            else:
                s = 1. / self._last_update_scale
                glScalef(s, s, s)
            self._current_cache['keys'].draw()
Esempio n. 11
0
    def draw(self):
        # background
        set_color(*self.style.get('bg-color'))
        drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)

        # draw children
        self.stencil_push()
        for w in self.children[:]:
            # internal update of children
            w.update()
            # optimization to draw only viewed children
            if self.do_y and (w.y + w.height < self.y
                              or w.y > self.y + self.height):
                continue
            if self.do_x and (w.x + w.width < self.x
                              or w.x > self.x + self.width):
                continue
            w.on_draw()
        self.stencil_pop()

        # draw widgets
        for w in self.widgets:
            w.dispatch_event('on_draw')
        # title bar
        if self.titletext is not None:
            set_color(*self.style.get('title-color'))
            w = 0
            if self.searchable:
                x = 80
                w += 80
            else:
                x = 0
            if self.deletable:
                w += 80
            drawCSSRectangle(pos=(self.x + x, self.height + self.y - 40),
                             size=(self.width - w, 40),
                             prefix='title',
                             style=self.style)
            self.title.x = self.width / 2 + self.x
            self.title.y = self.height - 20 + self.y
            self.title.draw()

        # scrollbar
        sb_size = self.style.get('scrollbar-size')
        if sb_size > 0:
            mtop, mright, mbottom, mleft = self.style.get('scrollbar-margin')
            if self.do_y:
                pos = [
                    self.x + self.width - mright - sb_size, self.y + mbottom
                ]
                size = [sb_size, self.height - mbottom - mtop]
                pos[1] += size[1] * self._scrollbar_index
                size[1] = size[1] * self._scrollbar_size
            elif self.do_x:
                pos = [self.x + mleft, self.y + self.height - mtop - sb_size]
                size = [self.width - mleft - mright, sb_size]
                pos[0] += size[0] * self._scrollbar_index
                size[0] = size[0] * self._scrollbar_size
            set_color(*self.style.get('scrollbar-color'))
            drawRectangle(pos=pos, size=size)
Esempio n. 12
0
 def draw(self):
     b = self.bordersize
     b2 = b * 2
     set_color(*self.style['bg-color'])
     drawCSSRectangle((-b, -b), (self.width + b2, self.height + b2),
                           style=self.style)
     super(MTVideo, self).draw()
Esempio n. 13
0
 def on_popup_draw(self):
     self._xml.root.center = self.get_parent_window().center
     popup = self._xml.getById('popup')
     set_color(*self.style.get('bg-color-full'))
     drawCSSRectangle(
         pos=Vector(popup.pos) - (10, 10),
         size=Vector(popup.size) + (20, 20),
         style=self.style)
Esempio n. 14
0
 def draw_background(self):
     if self.is_active_input:
         set_color(*self.style.get('bg-color'))
         drawCSSRectangle(pos=self.pos, size=self.size, style=self.style,
                         state='active')
     else:
         set_color(*self.style.get('bg-color'))
         drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
Esempio n. 15
0
    def draw(self):
        if not self.dl.is_compiled():
            with self.dl:
                set_color(*self.style['bg-color'])
                drawCSSRectangle(size=self.size, style=self.style)

                set_color(*self.current_color)
                drawRectangle(pos=(10, 220), size=(110, 60))
        self.dl.draw()
Esempio n. 16
0
    def draw(self):
        if not self.dl.is_compiled():
            with self.dl:
                set_color(*self.style['bg-color'])
                drawCSSRectangle(size=self.size, style=self.style)

                set_color(*self.current_color)
                drawRectangle(pos=(10, 220), size=(110, 60))
        self.dl.draw()
Esempio n. 17
0
    def draw(self):
        # background
        set_color(*self.style.get('bg-color'))
        drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)

        # draw children
        self.stencil_push()
        for w in self.children[:]:
            # internal update of children
            w.update()
            # optimization to draw only viewed children
            if self.do_y and (w.y + w.height < self.y or w.y > self.y + self.height):
                continue
            if self.do_x and (w.x + w.width < self.x or w.x > self.x + self.width):
                continue
            w.on_draw()
        self.stencil_pop()

        # draw widgets
        for w in self.widgets:
            w.dispatch_event('on_draw')
        # title bar
        if self.titletext is not None:
            set_color(*self.style.get('title-color'))
            w = 0
            if self.searchable:
                x = 80
                w += 80
            else:
                x = 0
            if self.deletable:
                w += 80
            drawCSSRectangle(pos=(self.x + x, self.height + self.y - 40),
                             size=(self.width - w, 40), prefix='title',
                             style=self.style)
            self.title.x = self.width/2 + self.x
            self.title.y = self.height - 20 + self.y
            self.title.draw()


        # scrollbar
        sb_size = self.style.get('scrollbar-size')
        if sb_size > 0:
            mtop, mright, mbottom, mleft = self.style.get('scrollbar-margin')
            if self.do_y:
                pos = [self.x + self.width - mright - sb_size, self.y + mbottom]
                size = [sb_size, self.height - mbottom - mtop]
                pos[1] += size[1] * self._scrollbar_index
                size[1] = size[1] * self._scrollbar_size
            if self.do_x:
                pos = [self.x + mleft, self.y + self.height - mtop - sb_size]
                size = [self.width - mleft - mright, sb_size]
                pos[0] += size[0] * self._scrollbar_index
                size[0] = size[0] * self._scrollbar_size
            set_color(*self.style.get('scrollbar-color'))
            drawRectangle(pos=pos, size=size)
Esempio n. 18
0
 def draw(self):
     if self.selected:
         selected_color = self.style.get('selected-color', (0.4,) * 4)
         set_color(*selected_color)
         drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
     pos = int(self.x + self.width / 2.), int(self.y + 10)
     drawLabel(label=self.striptext(self.label_txt, 10), pos=pos)
     self.image.x        = self.x + int(self.image.width / 2) - 5
     self.image.y        = self.y + int(self.image.height / 2) - 5
     self.image.draw()
Esempio n. 19
0
    def draw(self):
        # draw outer rectangle
        set_color(*self.style.get('bg-color'))
        drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)

        # draw inner circle
        set_color(*self.style.get('slider-color'))
        pos_x = int((self._value_x - self.min_x) * (self.width - self.padding*2) / (self.max_x - self.min_x))  + self.x + self.padding
        pos_y = int((self._value_y - self.min_y) * (self.height - self.padding*2) / (self.max_y - self.min_y)) + self.y + self.padding
        drawCircle(pos=(pos_x, pos_y), radius=self.radius)
Esempio n. 20
0
 def draw(self):
     if self.selected:
         selected_color = self.style.get('selected-color', (0.4, ) * 4)
         set_color(*selected_color)
         drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
     pos = int(self.x + self.width / 2.), int(self.y + 10)
     drawLabel(label=self.striptext(self.label_txt, 10), pos=pos)
     self.image.x = self.x + int(self.image.width / 2) - 5
     self.image.y = self.y + int(self.image.height / 2) - 5
     self.image.draw()
Esempio n. 21
0
    def draw(self):
        pos = self.image.width, self.y
        # Max number of chars for this entry's label
        max_chars = 20
        # Simple trick to get the maximum label width for the current font size
        self.width = getLabel('W'*max_chars, font_size=self.font_size).width
        if self.selected:
            selected_color = self.style.get('selected-color', (0.4,) * 4)
            set_color(*selected_color)
            drawCSSRectangle(pos=(0, self.y), size=self.size, style=self.style)
        kwargs = {'pos': pos, 'anchor_x': 'left', 'anchor_y': 'bottom', 'font_size':self.style['font-size'],
                  'color':self.style['color']}
        drawLabel(label=self.striptext(self.label_txt, max_chars), **kwargs )

        self.image.pos = (0, self.y)
        self.image.draw()
Esempio n. 22
0
 def draw(self):
     pos = self.image.width, self.y
     # Max number of chars for this entry's label
     max_chars = 20
     # Simple trick to get the maximum label width for the current font size
     self.width = getLabel('W' * max_chars, font_size=self.font_size).width
     if self.selected:
         selected_color = self.style.get('selected-color', (0.4, ) * 4)
         set_color(*selected_color)
         drawCSSRectangle(pos=(0, self.y), size=self.size, style=self.style)
     drawLabel(label=self.striptext(self.label_txt, max_chars),
               pos=pos,
               anchor_x='left',
               anchor_y='bottom',
               font_size=self.style.get('font-size'),
               color=self.style.get('color'))
     self.image.pos = (0, self.y)
     self.image.draw()
Esempio n. 23
0
    def draw(self):
        if not self.visible:
            return

        for objectID in self.objects:
            x, y, angle = self.objects[objectID]
            with gx_matrix:
                glTranslatef(x, y, 0.0)
                glRotatef(angle, 0.0, 0.0, 1.0)

                set_color(.5)
                drawCSSRectangle(
                    pos=(-0.5 * self.width, -0.5 * self.height),
                    size=(self.width, self.height),
                    style=self.style
                )

                set_color(*self.style['vector-color'])
                with gx_begin(GL_LINES):
                    glVertex2f(0., 0.)
                    glVertex2f(0., -0.5 * self.height)
Esempio n. 24
0
 def draw_background(self):
     set_color(*self.style.get('bg-color'))
     state = 'active' is self._is_active_input or None
     drawCSSRectangle(pos=self.pos, size=self.size,
                      style=self.style, state=state)
Esempio n. 25
0
 def draw_background(self):
     set_color(*self.style.get('bg-color'))
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style,
                      state=self.state)
Esempio n. 26
0
 def draw(self):
     '''Handle the draw of widget.
     Derivate this method to draw your widget.'''
     set_color(*self.style.get('bg-color'))
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
Esempio n. 27
0
 def draw(self):
     set_color(*self.style['bg-color'])
     drawCSSRectangle(pos=(0, 0), size=(self.width, self.height), style=self.style)
Esempio n. 28
0
 def draw_background(self):
     '''Draw the background of the widget'''
     set_color(*self.style['bg-color'])
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
Esempio n. 29
0
 def draw(self):
     set_color(*self.style.get('bg-color'))
     drawCSSRectangle(pos=(0, 0), size=self.size, style=self.style)
Esempio n. 30
0
 def draw_background(self):
     '''Draw the background of the widget'''
     set_color(*self.style['bg-color'])
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
Esempio n. 31
0
 def draw(self):
     # draw background
     set_color(*self.style['bg-color'])
     drawCSSRectangle(size=self.size, style=self.style)
Esempio n. 32
0
    def _do_update(self, mode=None):
        # we absolutly want mode to update displaylist.
        if mode not in ('background', 'keys'):
            return

        # don't update background if it's already compiled
        if mode == 'background' and self._current_cache['background'].is_compiled():
            return

        # calculate margin
        s = self.scale
        w, h = self.container_width, self.container_height
        if mode == 'background':
            s = 1.
            w, h = self.size
        mtop, mright, mbottom, mleft = map(lambda x: x * s, self.style['margin'])
        self.texsize = Vector(w - mleft - mright,
                              h - mtop - mbottom)
        kx, ky = self.layout.SIZE
        self.keysize = Vector(self.texsize.x / kx, self.texsize.y / ky)
        m = 3 * s
        x, y = 0, self.texsize.y - self.keysize.y

        # update display list
        self._current_cache['usedlabel'] = []
        with self._current_cache[mode]:

            # draw lines
            for index in xrange(1, ky + 1):
                line = self.layout.__getattribute__('%s_%d' % (self.mode, index))

                # draw keys
                for key in line:
                    displayed_str, internal_str, internal_action, scale = key
                    kw = self.keysize.x * scale

                    # don't display empty keys
                    if displayed_str is not None:
                        set_color(*self.style['key-color'])
                        if mode == 'background':
                            if internal_action is not None:
                                set_color(*self.style['syskey-color'])
                            drawCSSRectangle(
                                pos=(x+m, y+m),
                                size=(kw-m*2, self.keysize.y-m*2),
                                style=self.style, prefix='key')
                        elif mode == 'keys':
                            font_size = int(14 * s)
                            if font_size < 8:
                                font_size = 8
                            color = self.style['color']
                            if internal_action is not None:
                                color = self.style['color-syskey']
                            drawLabel(label=displayed_str,
                                    pos=(x + kw / 2., y + self.keysize.y / 2.),
                                    font_size=font_size, bold=False,
                                    font_name=self.style.get('font-name'),
                                    color=color)
                            self._current_cache['usedlabel'].append(getLastLabel())
                    # advance X
                    x += kw
                # advance Y
                y -= self.keysize.y
                x = 0

        # update completed
        self._need_update = None
Esempio n. 33
0
 def draw(self):
     set_color(*self.style['bg-color'])
     drawCSSRectangle(pos=(0, 0),
                      size=(self.width, self.height),
                      style=self.style)
Esempio n. 34
0
 def draw_background(self):
     set_color(*self.style.get('bg-color'))
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style,
                      state=self.state)
Esempio n. 35
0
 def draw(self):
     if not is_color_transparent(color):
         set_color(*color)
         drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
Esempio n. 36
0
 def draw(self):
     if not self.layout.visible:
         return
     set_color(*self.style.get('bg-color'))
     drawCSSRectangle(pos=self.layout.pos, size=self.layout.size, style=self.style)
Esempio n. 37
0
 def draw(self):
     set_color(*self.style.get('bg-color'))
     drawCSSRectangle(pos=(0, 0), size=self.size, style=self.style)
Esempio n. 38
0
 def draw(self):
     """Handle the draw of widget.
     Derivate this method to draw your widget."""
     set_color(*self.style.get("bg-color"))
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
Esempio n. 39
0
    def _do_update(self, mode=None):
        # we absolutly want mode to update displaylist.
        if mode not in ('background', 'keys'):
            return

        # don't update background if it's already compiled
        if mode == 'background' and self._current_cache['background'].is_compiled():
            return

        # calculate margin
        s = self.scale
        w, h = self.container_width, self.container_height
        if mode == 'background':
            s = 1.
            w, h = self.size
        mtop, mright, mbottom, mleft = map(lambda x: x * s, self.style['margin'])
        self.texsize = Vector(w - mleft - mright,
                              h - mtop - mbottom)
        kx, ky = self.layout.SIZE
        self.keysize = Vector(self.texsize.x / kx, self.texsize.y / ky)
        m = 3 * s
        x, y = 0, self.texsize.y - self.keysize.y

        # update display list
        self._current_cache['usedlabel'] = []
        with self._current_cache[mode]:

            # draw lines
            for index in xrange(1, ky + 1):
                line = self.layout.__getattribute__('%s_%d' % (self.mode, index))

                # draw keys
                for key in line:
                    displayed_str, internal_str, internal_action, scale = key
                    kw = self.keysize.x * scale

                    # don't display empty keys
                    if displayed_str is not None:
                        set_color(*self.style['key-color'])
                        if mode == 'background':
                            if internal_action is not None:
                                set_color(*self.style['syskey-color'])
                            drawCSSRectangle(
                                pos=(x+m, y+m),
                                size=(kw-m*2, self.keysize.y-m*2),
                                style=self.style, prefix='key')
                        elif mode == 'keys':
                            font_size = int(14 * s)
                            if font_size < 8:
                                font_size = 8
                            color = self.style['color']
                            if internal_action is not None:
                                color = self.style['color-syskey']
                            drawLabel(label=displayed_str,
                                    pos=(x + kw / 2., y + self.keysize.y / 2.),
                                    font_size=font_size, bold=False,
                                    font_name=self.style.get('font-name'),
                                    color=color)
                            self._current_cache['usedlabel'].append(getLastLabel())
                    # advance X
                    x += kw
                # advance Y
                y -= self.keysize.y
                x = 0

        # update completed
        self._need_update = None
Esempio n. 40
0
 def draw(self):
     set_color(*self.style['bg-color'])
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
     self.image.color = self.style['color']
     super(MTButtonVideo, self).draw()
Esempio n. 41
0
 def draw(self):
     set_color(*self.style['bg-color'])
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
     self.image.color = self.style['color']
     super(MTButtonVideo, self).draw()
Esempio n. 42
0
 def draw(self):
     '''Handle the draw of widget.
     Derivate this method to draw your widget.'''
     set_color(*self.style.get('bg-color'))
     drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)