1
1
from abc import ABCMeta , abstractmethod
2
- from typing import Union , List , Set , Any , Dict
2
+ from typing import Union , List , Set , Dict , Optional
3
3
4
4
import pygame
5
5
@@ -15,6 +15,25 @@ class IUIElementInterface(IGUISpriteInterface, metaclass=ABCMeta):
15
15
16
16
"""
17
17
18
+ @property
19
+ @abstractmethod
20
+ def is_focused (self ) -> bool :
21
+ """
22
+ Returns True if we are focusing this element.
23
+
24
+ :return: True if focused.
25
+ """
26
+
27
+ @is_focused .setter
28
+ @abstractmethod
29
+ def is_focused (self , value : bool ):
30
+ """
31
+ Setter for if we are focusing this element.
32
+
33
+ :param value: the focus value to set.
34
+ :return:
35
+ """
36
+
18
37
@property
19
38
@abstractmethod
20
39
def hovered (self ) -> bool :
@@ -35,7 +54,7 @@ def hovered(self, value: bool):
35
54
"""
36
55
37
56
@abstractmethod
38
- def get_relative_rect (self ) -> pygame .Rect :
57
+ def get_relative_rect (self ) -> pygame .Rect | pygame . FRect :
39
58
"""
40
59
The relative positioning rect.
41
60
@@ -44,7 +63,7 @@ def get_relative_rect(self) -> pygame.Rect:
44
63
"""
45
64
46
65
@abstractmethod
47
- def get_abs_rect (self ) -> pygame .Rect :
66
+ def get_abs_rect (self ) -> pygame .Rect | pygame . FRect :
48
67
"""
49
68
The absolute positioning rect.
50
69
@@ -53,7 +72,7 @@ def get_abs_rect(self) -> pygame.Rect:
53
72
"""
54
73
55
74
@abstractmethod
56
- def get_element_base_ids (self ) -> List [str ]:
75
+ def get_element_base_ids (self ) -> List [str | None ]:
57
76
"""
58
77
A list of all the element base IDs in this element's theming/event hierarchy.
59
78
@@ -69,23 +88,23 @@ def get_element_ids(self) -> List[str]:
69
88
"""
70
89
71
90
@abstractmethod
72
- def get_class_ids (self ) -> List [str ]:
91
+ def get_class_ids (self ) -> List [str | None ]:
73
92
"""
74
93
A list of all the class IDs in this element's theming/event hierarchy.
75
94
76
95
:return: a list of strings, one for each element in the hierarchy.
77
96
"""
78
97
79
98
@abstractmethod
80
- def get_object_ids (self ) -> List [str ]:
99
+ def get_object_ids (self ) -> List [str | None ]:
81
100
"""
82
101
A list of all the object IDs in this element's theming/event hierarchy.
83
102
84
103
:return: a list of strings, one for each element in the hierarchy.
85
104
"""
86
105
87
106
@abstractmethod
88
- def get_anchors (self ) -> Dict [str , Union [str , "IUIElementInterface" ]]:
107
+ def get_anchors (self ) -> Optional [ Dict [str , Union [str , "IUIElementInterface" ] ]]:
89
108
"""
90
109
A dictionary containing all the anchors defining what the relative rect is relative to
91
110
@@ -94,7 +113,7 @@ def get_anchors(self) -> Dict[str, Union[str, "IUIElementInterface"]]:
94
113
95
114
@abstractmethod
96
115
def set_anchors (
97
- self , anchors : Union [Dict [str , Union [str , "IUIElementInterface" ]], None ]
116
+ self , anchors : Optional [Dict [str , Union [str , "IUIElementInterface" ]]]
98
117
) -> None :
99
118
"""
100
119
Wraps the setting of the anchors with some validation
@@ -342,13 +361,13 @@ def get_starting_height(self) -> int:
342
361
"""
343
362
344
363
@abstractmethod
345
- def get_focus_set (self ) -> Set [Any ]:
364
+ def get_focus_set (self ) -> Optional [ Set ["IUIElementInterface" ] ]:
346
365
"""
347
366
Return the set of elements to focus when we focus this element.
348
367
"""
349
368
350
369
@abstractmethod
351
- def set_focus_set (self , focus_set : Set [Any ]):
370
+ def set_focus_set (self , focus_set : Optional [ Set ["IUIElementInterface" ] ]):
352
371
"""
353
372
Set the focus set to a specific set of elements.
354
373
0 commit comments