-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy path_utils.py
More file actions
46 lines (30 loc) · 918 Bytes
/
_utils.py
File metadata and controls
46 lines (30 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class ChangeFlag:
"""
A flag that helps detect whether an imgui UI has been changed by the user.
Basically, once True, always True.
Example::
changed = ChangeFlag(False)
changed.value, bah = (False, False)
print(changed.value)
changed.value, bah = (True, False)
print(changed.value)
changed.value, bah = (False, False)
print(changed.value)
"""
def __init__(self, value: bool):
self._value = bool(value)
@property
def value(self) -> bool:
return self._value
@value.setter
def value(self, value: bool):
if value:
self._value = True
def __bool__(self):
return self.value
def __or__(self, other):
return self._value | other
def __eq__(self, other):
return self.value == other
def force_value(self, value):
self._value = value