Skip to content

Commit

Permalink
Cache decoded toga color on gtk (#3117)
Browse files Browse the repository at this point in the history
Cache decoded color on GTK backend.
  • Loading branch information
proneon267 authored Jan 24, 2025
1 parent 59d427a commit e400294
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions changes/3117.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On GTK, native colors representations are now cached.
1 change: 1 addition & 0 deletions gtk/src/toga_gtk/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ def native_color(c):
color = CACHE[c]
except KeyError:
color = (c.rgba.r / 255, c.rgba.g / 255, c.rgba.b / 255, c.rgba.a)
CACHE[c] = color

return color
4 changes: 1 addition & 3 deletions gtk/src/toga_gtk/widgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def set_enabled(self, value):

def set_background_color(self, color):
# Buttons interpret TRANSPARENT backgrounds as a reset
if color == TRANSPARENT:
color = None
super().set_background_color(color)
super().set_background_color(None if color is TRANSPARENT else color)

def rehint(self):
# print(
Expand Down

0 comments on commit e400294

Please sign in to comment.