@@ -66,10 +66,9 @@ def full_rebuild_on_size_change(self):
66
66
super ().full_rebuild_on_size_change ()
67
67
68
68
self .base_surface = None
69
- self .temp_additive_shape = None
70
69
self .temp_subtractive_shape = None
71
70
self .temp_shadow_subtractive_shape = None
72
-
71
+ self . temp_additive_shape = None
73
72
# clamping border, shadow widths and corner radii, so we can't form impossible shapes
74
73
# having impossible values here will also mean the shadow pre-generating system fails
75
74
# leading to slow down when creating elements
@@ -79,12 +78,13 @@ def full_rebuild_on_size_change(self):
79
78
self .shadow_width = min (math .floor (self .containing_rect .width / 2 ),
80
79
math .floor (self .containing_rect .height / 2 ))
81
80
warnings .warn (
82
- 'Clamping shadow_width of: ' + str (old_width ) + ', to: ' + str (self .shadow_width ))
81
+ f'Clamping shadow_width of: { str (old_width )} , to: { str (self .shadow_width )} '
82
+ )
83
83
84
84
if self .shadow_width < 0 :
85
85
old_width = self .shadow_width
86
86
self .shadow_width = 0
87
- warnings .warn ('Clamping shadow_width of: ' + str (old_width ) + ' , to: ' + str ( 0 ) )
87
+ warnings .warn (f 'Clamping shadow_width of: { str (old_width )} , to: 0' )
88
88
89
89
if self .border_width > min (math .floor ((self .containing_rect .width -
90
90
(self .shadow_width * 2 )) / 2 ),
@@ -95,13 +95,13 @@ def full_rebuild_on_size_change(self):
95
95
(self .shadow_width * 2 )) / 2 ),
96
96
math .floor ((self .containing_rect .height -
97
97
(self .shadow_width * 2 )) / 2 ))
98
- warnings .warn ('Clamping border_width of: ' +
99
- str (old_width ) + ' , to: ' +
100
- str ( self . border_width ) )
98
+ warnings .warn (
99
+ f'Clamping border_width of: { str (old_width )} , to: { str ( self . border_width ) } '
100
+ )
101
101
if self .border_width < 0 :
102
102
old_width = self .border_width
103
103
self .border_width = 0
104
- warnings .warn ('Clamping border_width of: ' + str (old_width ) + ' , to: ' + str ( 0 ) )
104
+ warnings .warn (f 'Clamping border_width of: { str (old_width )} , to: 0' )
105
105
106
106
corner_radii = self .theming ['shape_corner_radius' ]
107
107
if self .shadow_width > 0 :
@@ -120,12 +120,12 @@ def full_rebuild_on_size_change(self):
120
120
self .click_area_shape .height / 2 ):
121
121
corner_radius = int (min (self .click_area_shape .width / 2 ,
122
122
self .click_area_shape .height / 2 ))
123
- warnings .warn ('Clamping shape_corner_radius of: ' +
124
- str (old_radius ) + ', to: ' + str (corner_radius ))
123
+ warnings .warn (
124
+ f'Clamping shape_corner_radius of: { str (old_radius )} , to: { corner_radius } '
125
+ )
125
126
if corner_radius < 0 :
126
127
corner_radius = 0
127
- warnings .warn ('Clamping shape_corner_radius of: ' +
128
- str (old_radius ) + ', to: ' + str (0 ))
128
+ warnings .warn (f'Clamping shape_corner_radius of: { str (old_radius )} , to: 0' )
129
129
self .shape_corner_radius [i ] = corner_radius
130
130
131
131
shadow = self .ui_manager .get_shadow (self .containing_rect .size ,
@@ -326,10 +326,10 @@ def redraw_state(self, state_str: str, add_text: bool = True):
326
326
if self .containing_rect .width <= 0 or self .containing_rect .height <= 0 :
327
327
self .states [state_str ].surface = self .ui_manager .get_universal_empty_surface ()
328
328
else :
329
- text_colour_state_str = state_str + ' _text'
330
- text_shadow_colour_state_str = state_str + ' _text_shadow'
331
- bg_col = self .theming [state_str + ' _bg' ]
332
- border_col = self .theming [state_str + ' _border' ]
329
+ text_colour_state_str = f' { state_str } _text'
330
+ text_shadow_colour_state_str = f' { state_str } _text_shadow'
331
+ bg_col = self .theming [f' { state_str } _bg' ]
332
+ border_col = self .theming [f' { state_str } _border' ]
333
333
border_overlap = 0
334
334
if 'border_overlap' in self .theming :
335
335
border_overlap = self .theming ['border_overlap' ]
@@ -425,9 +425,13 @@ def redraw_state(self, state_str: str, add_text: bool = True):
425
425
shape_id )
426
426
self .states [state_str ].cached_background_id = shape_id
427
427
428
- self .finalise_images_and_text (state_str + '_image' , state_str ,
429
- text_colour_state_str ,
430
- text_shadow_colour_state_str , add_text )
428
+ self .finalise_images_and_text (
429
+ f'{ state_str } _image' ,
430
+ state_str ,
431
+ text_colour_state_str ,
432
+ text_shadow_colour_state_str ,
433
+ add_text ,
434
+ )
431
435
432
436
self .states [state_str ].has_fresh_surface = True
433
437
self .states [state_str ].generated = True
@@ -541,25 +545,22 @@ def create_subtract_surface(self,
541
545
surface to leave a transparent hole in it.
542
546
543
547
"""
544
- if subtract_size [0 ] > 0 and subtract_size [1 ] > 0 :
545
- if self .temp_subtractive_shape is None :
546
- # for the subtract surface we want to blend in all RGBA channels to clear
547
- # correctly for our new shape
548
- self .temp_subtractive_shape = pygame .surface .Surface (subtract_size ,
549
- flags = pygame .SRCALPHA ,
550
- depth = 32 )
551
- clear_colour = '#00000000'
552
- self .temp_subtractive_shape .fill (pygame .Color (clear_colour ))
553
- RoundedRectangleShape .draw_colourless_rounded_rectangle (corner_radii ,
554
- self .temp_subtractive_shape ,
555
- int (aa_amount / 2 ))
556
- large_sub_surface = self .temp_subtractive_shape
557
- else :
558
- large_sub_surface = pygame .transform .scale (self .temp_subtractive_shape ,
559
- subtract_size )
560
-
561
- return large_sub_surface
562
- return None
548
+ if subtract_size [0 ] <= 0 or subtract_size [1 ] <= 0 :
549
+ return None
550
+ if self .temp_subtractive_shape is not None :
551
+ return pygame .transform .scale (
552
+ self .temp_subtractive_shape , subtract_size
553
+ )
554
+ # for the subtract surface we want to blend in all RGBA channels to clear
555
+ # correctly for our new shape
556
+ self .temp_subtractive_shape = pygame .surface .Surface (subtract_size ,
557
+ flags = pygame .SRCALPHA ,
558
+ depth = 32 )
559
+ self .temp_subtractive_shape .fill (pygame .Color ('#00000000' ))
560
+ RoundedRectangleShape .draw_colourless_rounded_rectangle (
561
+ corner_radii , self .temp_subtractive_shape , aa_amount // 2
562
+ )
563
+ return self .temp_subtractive_shape
563
564
564
565
@staticmethod
565
566
def draw_colourless_rounded_rectangle (large_corner_radius : List [int ],
0 commit comments