X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fwidgets%2Ftext.py;h=6862b968907ec7132a15bc1a01f509e63d446e45;hb=84c542f883e16a7f40c70e8a7096b92c063a0e7f;hp=02de03fd955be7f9b45324077df7390daa6a8dcd;hpb=3ce2165747dd660edcf1ec98f291438bfdddb9c6;p=naja.git diff --git a/naja/widgets/text.py b/naja/widgets/text.py index 02de03f..6862b96 100644 --- a/naja/widgets/text.py +++ b/naja/widgets/text.py @@ -3,7 +3,7 @@ import pygame.locals as pgl from naja.constants import FONT, FONT_SIZE, EIGHT_BIT_SCALE, PALETTE, KEYS from naja.resources import resources -from naja.resources.mutators import EIGHT_BIT, blender +from naja.resources.mutators import EIGHT_BIT, R180, blender from naja.utils import convert_colour from naja.widgets.base import Widget @@ -104,6 +104,23 @@ class TextWidget(Widget): rect = self.pos area = self.view_port surface.blit(self.surface, rect, area) + if self.view_port is not None: + self.draw_arrows(surface) + + def draw_arrows(self, surface): + if self.view_port.top > 0: + up = resources.get_image('bits', 'arrow_on.png', + transforms=(EIGHT_BIT,)) + icon_size = up.get_rect().height + pos = (self.pos[0] + self.view_port.width - icon_size, self.pos[1]) + surface.blit(up, pos) + if self.view_port.bottom < self.surface.get_rect().bottom: + down = resources.get_image('bits', 'arrow_on.png', + transforms=(R180, EIGHT_BIT)) + icon_size = down.get_rect().height + pos = (self.pos[0] + self.view_port.width - icon_size, + self.pos[1] + self.view_port.height - icon_size) + surface.blit(down, pos) class TextBoxWidget(TextWidget): @@ -153,7 +170,7 @@ class TextBoxWidget(TextWidget): def _wrapped_lines(self, image_map): def words_fit(words): words_line = ' '.join(words) - width = self.font.size(words_line)[0] + width = self.font.size(words_line)[0] * EIGHT_BIT_SCALE if width < self.box_width: return True elif len(words) == 1: