refactoring: created _update_color method
@@ -938,11 +938,10 @@ class TextLayout(object):
self._flow_lines(lines, 0, len(lines))
return lines
- def _update(self, color_only=False):
+ def _update(self):
if not self._update_enabled:
return
- if not color_only:
for _vertex_list in self._vertex_lists:
_vertex_list.delete()
for box in self._boxes:
@@ -971,7 +970,7 @@ class TextLayout(object):
self._create_vertex_lists(left + line.x, top + line.y,
line.start, line.boxes, context)
- else:
+ def _update_color(self):
colors_iter = self._document.get_style_runs('color')
colors = []
for start, end, color in colors_iter.ranges(0, colors_iter.length):
@@ -1030,8 +1029,8 @@ class TextLayout(object):
else:
assert False, 'Invalid anchor_y'
- def _init_document(self, color_only=False):
- self._update(color_only)
+ def _init_document(self):
+ self._update()
def _uninit_document(self):
pass
@@ -1058,11 +1057,10 @@ class TextLayout(object):
The event handler is bound by the text layout; there is no need for
applications to interact with this method.
"""
- color_only = False
if len(attributes) == 1 and 'color' in attributes.keys():
- color_only = True
-
- self._init_document(color_only)
+ self._update_color()
+ else:
+ self._init_document()
def _get_glyphs(self):
glyphs = []
