diff options
author | Pablo Moleri <pmoleri@gmail.com> | 2010-12-22 02:05:13 (GMT) |
---|---|---|
committer | Pablo Moleri <pmoleri@gmail.com> | 2010-12-22 02:05:13 (GMT) |
commit | b79686b7a96b69f6e0ffdf9d730e63061e6d98d4 (patch) | |
tree | 97049575ef4eea28e0f82ea2647d58e507bc0a20 | |
parent | c60544a1850c08a1ff4a6e4ed2ee41336c056612 (diff) | |
parent | 0ffb56713808c0316858cd927aaba13652eb0083 (diff) |
Merge branch 'master' of git.sugarlabs.org:saludame/mainline
-rwxr-xr-x | Saludame.activity/utilities.py | 17 | ||||
-rwxr-xr-x | Saludame.activity/windows_controller.py | 5 |
2 files changed, 13 insertions, 9 deletions
diff --git a/Saludame.activity/utilities.py b/Saludame.activity/utilities.py index 3e4b4ba..f005561 100755 --- a/Saludame.activity/utilities.py +++ b/Saludame.activity/utilities.py @@ -13,7 +13,7 @@ class Text(Widget): ALIGN_RIGHT = 1 ALIGN_CENTER = 2 - def __init__(self, container_rect, x, y, frame_rate, text, size, color, alignment=ALIGN_LEFT, bold=False, italic=False): + def __init__(self, container_rect, x, y, frame_rate, text, size, color, type="normal", alignment=ALIGN_LEFT, bold=False, italic=False): self.font = get_font(size, bold, italic) self.text = unicode(text) self.color = color @@ -26,12 +26,15 @@ class Text(Widget): rect = render.get_rect(topright=(x, y)) else: rect = render.get_rect(center=(x, y)) - + + if type == "tooltip": + rect.bottomleft = (x, y) + # Make it fit in the container if rect.right > container_rect.right: rect.right = container_rect.right if rect.bottom > container_rect.bottom: - rect.bottom = container_rect.bottom + rect.bottom = container_rect.bottom Widget.__init__(self, container_rect, rect, frame_rate) @@ -99,8 +102,7 @@ class Button(Widget): self.function_on_mouse_over = fn def set_on_mouse_out(self, fn): - self.function_on_mouse_out = fn - + self.function_on_mouse_out = fn class ImageButton(Button): @@ -178,7 +180,7 @@ def get_color_tuple(color): return get_color_tuple(color) class TextBlock(Widget): - def __init__(self, container, x, y, frame_rate, text, size, color, fill=True): + def __init__(self, container, x, y, frame_rate, text, size, color, type="normal", fill=True): Widget.__init__(self, container, pygame.Rect(x, y, 0, 0), frame_rate) @@ -190,6 +192,9 @@ class TextBlock(Widget): self.prepare_text_block() self.fill = fill + if type == "tooltip": + self.rect_absolute.bottomleft = (x, y) + def parse_lines(self, text): self.lines = [] if isinstance(text, unicode): diff --git a/Saludame.activity/windows_controller.py b/Saludame.activity/windows_controller.py index 4a8896a..6bc7628 100755 --- a/Saludame.activity/windows_controller.py +++ b/Saludame.activity/windows_controller.py @@ -160,7 +160,7 @@ class WindowsController: #### Tooltips ##### def show_tooltip(self, tooltip): x, y = self.scaled_game.scale_coordinates(pygame.mouse.get_pos()) - self.active_tooltip = Text(self.screen.get_rect(), x, y, 1, tooltip, 18, pygame.Color('red')) + self.active_tooltip = Text(self.screen.get_rect(), x, y, 1, tooltip, 18, pygame.Color('red'), "tooltip") # Necesitamos guardar lo que esta atras del tooltip para cuando lo querramos esconder self.active_tooltip_bg = (self.screen.subsurface(self.active_tooltip.rect_absolute).copy(), self.active_tooltip.rect_absolute) @@ -168,7 +168,7 @@ class WindowsController: def show_super_tooltip(self, tooltip): x, y = self.scaled_game.scale_coordinates(pygame.mouse.get_pos()) - self.active_tooltip = TextBlock(self.screen.get_rect(), x, y, 1, tooltip, 18, pygame.Color('red')) + self.active_tooltip = TextBlock(self.screen.get_rect(), x, y, 1, tooltip, 18, pygame.Color('red'), "tooltip") self.active_tooltip_bg = (self.screen.subsurface(self.active_tooltip.rect_absolute).copy(), self.active_tooltip.rect_absolute) self.showing_tooltip = True @@ -219,7 +219,6 @@ class WindowsController: self.scaled_game.update_screen(changes) #self.scaled_game.flip() - class ScaledGame: def __init__(self, pygame_screen, internal_size): |