Exemplo n.º 1
0
    def _draw(self, screen: Surface, changes: List[Rect]) -> None:
        """Draw the slider's visuals to the screen. <change> is a list of
        rectangles that represent the changed areas of the screen.
        """
        Component._draw(self, screen, changes)

        # Fill Background
        changes.append(screen.fill(self._style.primary_color, self._fill_rect))

        filled_rect = self._fill_rect.copy()
        filled_rect.width = filled_rect.width * \
            (self._value - self._min_value) / \
            (self._max_value - self._min_value)

        # Fill Foreground
        changes.append(screen.fill(self._style.secondary_color, filled_rect))

        if (self._show_handle):
            # Handle Fill
            changes.append(
                draw.circle(screen, self._style.tertiary_color,
                            filled_rect.midright, self._handle_radius - 1))

            # Handle Outline
            if (self._style.border_width > 0
                    and self._style.border_color is not None):

                changes.append(
                    draw.circle(screen, self._style.border_color,
                                filled_rect.midright, self._handle_radius,
                                self._style.border_width))
Exemplo n.º 2
0
    def _draw(self, screen: Surface, changes: List[Rect]) -> None:
        """Draw the current animation frame to the screen. <changes> is a list
        of rectangles that represent the changed areas of the screen.
        """
        Component._draw(self, screen, changes)

        if (len(self._animation_frames) == 0):
            return

        changes.append(
            screen.blit(self._animation_frames[self._frame_index], self._rect))
Exemplo n.º 3
0
    def _draw(self, screen: Surface, changes: List[Rect]) -> None:
        """Draw the button's visuals to the screen. <change> is a list of
        rectangles that represent the changed areas of the screen.
        """
        Component._draw(self, screen, changes)

        # Draw hover color
        if (self.is_hovered()):
            changes.append(
                screen.fill(self._style.hover_color, self._rect,
                            BLEND_RGB_MULT))

        self._draw_text(screen, changes)
Exemplo n.º 4
0
    def _draw(self, screen: pygame.Surface,
              changes: List[pygame.Rect]) -> None:
        """Draw the textbox's visuals to the screen. <change> is a list of
        rectangles that represent the changed areas of the screen.
        """
        Component._draw(self, screen, changes)

        text_rect = self._text_image.get_rect()
        text_rect.center = self._rect.center

        # Draw Selection Background
        if (self._has_multi_char_selection()):
            start = self._style.font.size(self.get_text()[:self._cursor_pos])
            end = self._style.font.size(
                self.get_text()[:self._selection_end_pos])

            start_x = min(start[0], end[0])
            end_x = max(start[0], end[0])

            background_rect = pygame.Rect(text_rect.x + start_x, text_rect.y,
                                          end_x - start_x, text_rect.height)
            changes.append(screen.fill((0, 0, 255), background_rect))
            Label._draw_text(self, screen, changes)
            return

        # Draw text
        Label._draw_text(self, screen, changes)

        # Draw Blinker
        if (self._is_blinker_on):
            size = self._style.font.size(self.get_text()[:self._cursor_pos])
            cursor_rect = pygame.Rect(text_rect.x + size[0], text_rect.y, 2,
                                      text_rect.height)

            if (self._rect.x < cursor_rect.x < self._rect.right):
                changes.append(
                    screen.fill(self._style.primary_color, cursor_rect))
Exemplo n.º 5
0
 def _draw(self, screen: Surface, changes: List[Rect]) -> None:
     """Draw the label's background and text to the <screen>. <change> is a
     list of rectangles that represent the changed areas of the screen.
     """
     Component._draw(self, screen, changes)
     self._draw_text(screen, changes)