Skip to content

Commit ba02f24

Browse files
authored
Gui/performance (#2603)
* fix UITextWidget subclasses did not set style during construction, causing a double render * gui: fix update font triggered render on each frame, when font_color was not a Color
1 parent fcd6a1d commit ba02f24

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

arcade/gui/widgets/buttons.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ def __init__(
140140

141141
bind(self, "_textures", self.trigger_render)
142142

143+
# prepare label with default style
144+
_style = self.get_current_style()
145+
if _style is None:
146+
raise ValueError(f"No style found for state {self.get_current_state()}")
147+
self._apply_style(_style)
148+
143149
def get_current_state(self) -> str:
144150
"""Returns the current state of the button i.e.disabled, press, hover or normal."""
145151
if self.disabled:
@@ -330,6 +336,12 @@ def __init__(
330336
**kwargs,
331337
)
332338

339+
# prepare label with default style
340+
_style = self.get_current_style()
341+
if _style is None:
342+
raise ValueError(f"No style found for state {self.get_current_state()}")
343+
self._apply_style(_style)
344+
333345
def get_current_state(self) -> str:
334346
"""Returns the current state of the button i.e.disabled, press, hover or normal."""
335347
if self.disabled:

arcade/gui/widgets/text.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ def update_font(
273273
font_bold = bold if bold is not None else self._label.bold
274274
font_italic = italic if italic is not None else self._label.italic
275275

276+
# ensure type of font_color, label will allways be a color
277+
font_color = Color.from_iterable(font_color)
278+
276279
# Check if values actually changed, if then update and trigger render
277280
font_name_changed = self._label.font_name != font_name
278281
font_size_changed = self._label.font_size != font_size

0 commit comments

Comments
 (0)