Skip to content

Commit

Permalink
All ButtonView functionality has been moved to View
Browse files Browse the repository at this point in the history
Code refactored
  • Loading branch information
TeaCondemns committed Feb 19, 2023
1 parent 7654574 commit 6c3973e
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 225 deletions.
3 changes: 1 addition & 2 deletions pygex/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from pygex.gui.view import GRAVITY_LEFT, GRAVITY_TOP, GRAVITY_RIGHT, GRAVITY_BOTTOM, GRAVITY_CENTER_HORIZONTAL
from pygex.gui.view import GRAVITY_LEFT, GRAVITY_TOP, GRAVITY_RIGHT, GRAVITY_BOTTOM, GRAVITY_CENTER_HORIZONTAL, View
from pygex.gui.view import GRAVITY_CENTER_VERTICAL, SIZE_WRAP_CONTENT, SIZE_MATCH_PARENT, VISIBILITY_INVISIBLE
from pygex.gui.textview import ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_BLOCK, TextView
from pygex.gui.view import VISIBILITY_VISIBLE, VISIBILITY_GONE
from pygex.gui.buttonview import ButtonView
from pygex.gui.toast import Toast
from pygex.gui.hint import Hint
from pygex.gui import drawable
177 changes: 0 additions & 177 deletions pygex/gui/buttonview.py

This file was deleted.

17 changes: 4 additions & 13 deletions pygex/gui/textview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pygex.gui.view import View, SIZE_WRAP_CONTENT, DEFAULT_PADDING, GRAVITY_LEFT, GRAVITY_TOP
from pygex.gui.drawable.drawable import Drawable
from pygex.color import COLOR_TYPE, C_BLACK
from pygame.surface import SurfaceType
from pygame.font import FontType
from typing import Sequence

Expand Down Expand Up @@ -51,22 +52,12 @@ def __init__(
if render_content_during_initialization:
self.render_content_surface()

def set_text(self, text: str):
self.text_renderer.set_text(text)

self._content_surface_buffer = self.text_renderer.text_surface

def set_text_color(self, text_color: COLOR_TYPE):
self.text_renderer.set_color(text_color)

self._content_surface_buffer = self.text_renderer.text_surface

def apply_text_surface(self):
self._content_surface_buffer = self.text_renderer.text_surface
@property
def buffered_content_surface(self) -> SurfaceType | None:
return self.text_renderer.text_surface

def render_content_surface(self):
self.text_renderer.set_size(self.get_computed_content_size())
self._content_surface_buffer = self.text_renderer.text_surface


__all__ = 'ALIGN_LEFT', 'ALIGN_RIGHT', 'ALIGN_CENTER', 'ALIGN_BLOCK', 'TextView',
Loading

0 comments on commit 6c3973e

Please sign in to comment.