From c037be8b20d65964578b8caf0ab1b601e4eea343 Mon Sep 17 00:00:00 2001 From: andreamah Date: Wed, 8 Apr 2020 14:11:46 -0700 Subject: [PATCH 1/4] immediate changes on self x,y, and scale, incoporating self x and y --- src/base_circuitpython/displayio/group.py | 50 +++++++++++++++++++---- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/src/base_circuitpython/displayio/group.py b/src/base_circuitpython/displayio/group.py index edae6f3e2..42fb54aee 100644 --- a/src/base_circuitpython/displayio/group.py +++ b/src/base_circuitpython/displayio/group.py @@ -39,7 +39,7 @@ def __init__( self.__auto_write = auto_write self.__contents = [] self.__max_size = max_size - self.scale = scale + self.__scale = scale """ .. attribute:: scale @@ -47,14 +47,14 @@ def __init__( will be represented by 2x2 pixels. """ - self.x = x + self.__x = x """ .. attribute:: x X position of the Group in the parent. """ - self.y = y + self.__y = y """ .. attribute:: y @@ -63,6 +63,39 @@ def __init__( self.__parent = None self.__hidden = False + @property + def x(self): + return self.__x + + @x.setter + def x(self, val): + changed = val != self.__x + self.__x = val + if changed: + self.__elem_changed() + + @property + def y(self): + return self.__y + + @y.setter + def y(self, val): + changed = val != self.__y + self.__y = val + if changed: + self.__elem_changed() + + @property + def scale(self): + return self.__scale + + @scale.setter + def scale(self, val): + changed = val != self.__scale + self.__scale = val + if changed: + self.__elem_changed() + @property def hidden(self): """ @@ -260,18 +293,19 @@ def __draw(self, img=None, x=0, y=0, scale=None, show=True): x += self._anchor_point[0] y += self._anchor_point[1] - if self._boundingbox is not None and self.anchored_position is not None: - x += self.anchored_position[0] - y += self.anchored_position[1] except AttributeError: pass for elem in self.__contents: if not elem.hidden: if isinstance(elem, Group): - img = elem._Group__draw(img=img, x=x, y=y, scale=scale, show=False,) + img = elem._Group__draw( + img=img, x=x + self.x, y=y + self.y, scale=scale, show=False, + ) else: - img = elem._TileGrid__draw(img=img, x=x, y=y, scale=scale) + img = elem._TileGrid__draw( + img=img, x=x + self.x, y=y + self.y, scale=scale + ) # show should only be true to the highest parent group if show: From c0f713f37e57648ba43e7308de0c30873e455d15 Mon Sep 17 00:00:00 2001 From: andreamah Date: Wed, 8 Apr 2020 14:28:04 -0700 Subject: [PATCH 2/4] extra detail in comments --- src/base_circuitpython/displayio/group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base_circuitpython/displayio/group.py b/src/base_circuitpython/displayio/group.py index 42fb54aee..df62fb79e 100644 --- a/src/base_circuitpython/displayio/group.py +++ b/src/base_circuitpython/displayio/group.py @@ -288,7 +288,7 @@ def __draw(self, img=None, x=0, y=0, scale=None, show=True): # 1 unit (1 unit * scale = scale) y -= scale - # Group is positioned against anchored_position (default (0,0)), + # Group is positioned against anchored_position (already incorporated into self.x and self.y), # which is positioned against anchor_point x += self._anchor_point[0] From 01bccd1408743eaf3de013fee34b6b9629a3b308 Mon Sep 17 00:00:00 2001 From: andreamah Date: Wed, 8 Apr 2020 14:51:33 -0700 Subject: [PATCH 3/4] revised setters --- src/base_circuitpython/displayio/group.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/base_circuitpython/displayio/group.py b/src/base_circuitpython/displayio/group.py index df62fb79e..04f4cfff5 100644 --- a/src/base_circuitpython/displayio/group.py +++ b/src/base_circuitpython/displayio/group.py @@ -69,9 +69,8 @@ def x(self): @x.setter def x(self, val): - changed = val != self.__x - self.__x = val - if changed: + if val != self.__x: + self.__x = val self.__elem_changed() @property @@ -80,9 +79,8 @@ def y(self): @y.setter def y(self, val): - changed = val != self.__y - self.__y = val - if changed: + if val != self.__y: + self.__y = val self.__elem_changed() @property @@ -91,9 +89,8 @@ def scale(self): @scale.setter def scale(self, val): - changed = val != self.__scale - self.__scale = val - if changed: + if val != self.__scale: + self.__scale = val self.__elem_changed() @property From e0f12d554e84e9cdd5eb7e55fbd79e56b4a4a0d1 Mon Sep 17 00:00:00 2001 From: andreamah Date: Wed, 8 Apr 2020 17:08:37 -0700 Subject: [PATCH 4/4] changed comparator positioning --- src/base_circuitpython/displayio/group.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base_circuitpython/displayio/group.py b/src/base_circuitpython/displayio/group.py index 04f4cfff5..5c13b0746 100644 --- a/src/base_circuitpython/displayio/group.py +++ b/src/base_circuitpython/displayio/group.py @@ -69,7 +69,7 @@ def x(self): @x.setter def x(self, val): - if val != self.__x: + if self.__x != val: self.__x = val self.__elem_changed() @@ -79,7 +79,7 @@ def y(self): @y.setter def y(self, val): - if val != self.__y: + if self.__y != val: self.__y = val self.__elem_changed() @@ -89,7 +89,7 @@ def scale(self): @scale.setter def scale(self, val): - if val != self.__scale: + if self.__scale != val: self.__scale = val self.__elem_changed()