batframework 1.0.9a7__py3-none-any.whl → 1.0.9a9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- batFramework/__init__.py +20 -11
- batFramework/action.py +1 -1
- batFramework/animatedSprite.py +47 -116
- batFramework/animation.py +30 -5
- batFramework/audioManager.py +8 -5
- batFramework/baseScene.py +240 -0
- batFramework/camera.py +4 -0
- batFramework/constants.py +6 -2
- batFramework/cutscene.py +221 -21
- batFramework/cutsceneManager.py +5 -2
- batFramework/drawable.py +7 -5
- batFramework/easingController.py +10 -11
- batFramework/entity.py +21 -2
- batFramework/enums.py +48 -33
- batFramework/gui/__init__.py +6 -3
- batFramework/gui/animatedLabel.py +10 -2
- batFramework/gui/button.py +4 -31
- batFramework/gui/clickableWidget.py +63 -50
- batFramework/gui/constraints/constraints.py +212 -136
- batFramework/gui/container.py +77 -58
- batFramework/gui/debugger.py +12 -17
- batFramework/gui/draggableWidget.py +21 -17
- batFramework/gui/image.py +3 -10
- batFramework/gui/indicator.py +56 -1
- batFramework/gui/interactiveWidget.py +127 -108
- batFramework/gui/label.py +73 -64
- batFramework/gui/layout.py +286 -445
- batFramework/gui/meter.py +42 -20
- batFramework/gui/radioButton.py +20 -69
- batFramework/gui/root.py +99 -29
- batFramework/gui/selector.py +250 -0
- batFramework/gui/shape.py +13 -5
- batFramework/gui/slider.py +262 -107
- batFramework/gui/syncedVar.py +49 -0
- batFramework/gui/textInput.py +46 -22
- batFramework/gui/toggle.py +70 -52
- batFramework/gui/tooltip.py +30 -0
- batFramework/gui/widget.py +222 -135
- batFramework/manager.py +7 -8
- batFramework/particle.py +4 -1
- batFramework/propertyEaser.py +79 -0
- batFramework/renderGroup.py +17 -50
- batFramework/resourceManager.py +43 -13
- batFramework/scene.py +15 -335
- batFramework/sceneLayer.py +138 -0
- batFramework/sceneManager.py +31 -36
- batFramework/scrollingSprite.py +8 -3
- batFramework/sprite.py +1 -1
- batFramework/templates/__init__.py +1 -2
- batFramework/templates/controller.py +97 -0
- batFramework/timeManager.py +76 -22
- batFramework/transition.py +37 -103
- batFramework/utils.py +125 -66
- {batframework-1.0.9a7.dist-info → batframework-1.0.9a9.dist-info}/METADATA +24 -3
- batframework-1.0.9a9.dist-info/RECORD +67 -0
- {batframework-1.0.9a7.dist-info → batframework-1.0.9a9.dist-info}/WHEEL +1 -1
- batFramework/character.py +0 -27
- batFramework/templates/character.py +0 -43
- batFramework/templates/states.py +0 -166
- batframework-1.0.9a7.dist-info/RECORD +0 -63
- /batframework-1.0.9a7.dist-info/LICENCE → /batframework-1.0.9a9.dist-info/LICENSE +0 -0
- {batframework-1.0.9a7.dist-info → batframework-1.0.9a9.dist-info}/top_level.txt +0 -0
batFramework/gui/toggle.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
from .button import Button
|
2
2
|
from .indicator import Indicator, ToggleIndicator
|
3
|
+
from .shape import Shape
|
3
4
|
import batFramework as bf
|
4
5
|
from typing import Self,Callable,Any
|
5
|
-
import pygame
|
6
|
-
|
7
6
|
|
8
7
|
class Toggle(Button):
|
9
8
|
def __init__(self, text: str = "", callback : Callable[[bool],Any]=None, default_value: bool = False) -> None:
|
@@ -54,57 +53,76 @@ class Toggle(Button):
|
|
54
53
|
def get_min_required_size(self) -> tuple[float, float]:
|
55
54
|
if not self.text_rect:
|
56
55
|
self.text_rect.size = self._get_text_rect_required_size()
|
57
|
-
size = (
|
58
|
-
max(
|
59
|
-
self.indicator.get_min_required_size()[0],
|
60
|
-
self.text_rect.w + self.font_object.point_size + (self.gap if self.text else 0),
|
61
|
-
),
|
62
|
-
self.text_rect.h+self.unpressed_relief,
|
63
|
-
)
|
64
|
-
return self.inflate_rect_by_padding((0, 0, *size)).size
|
65
56
|
|
66
|
-
|
57
|
+
text_width, text_height = self.text_rect.size
|
58
|
+
indicator_size = self.indicator.get_min_required_size()[1]
|
67
59
|
gap = self.gap if self.text else 0
|
60
|
+
|
61
|
+
total_width = text_width + gap + indicator_size
|
62
|
+
total_height = text_height + self.unpressed_relief
|
63
|
+
|
64
|
+
return self.expand_rect_with_padding((0, 0, total_width, total_height)).size
|
65
|
+
|
66
|
+
def _build_composed_layout(self,other:Shape):
|
67
|
+
size_changed = False
|
68
68
|
self.text_rect.size = self._get_text_rect_required_size()
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
70
|
+
gap = self.gap if self.text else 0
|
71
|
+
full_rect = self.text_rect.copy()
|
72
|
+
|
73
|
+
other_height = min(self.text_rect.h, self.font_object.get_height()+1)
|
74
|
+
other.set_size(other.resolve_size((other_height,other_height)))
|
75
|
+
|
76
|
+
full_rect.w += other.rect.w + gap
|
77
|
+
full_rect.h += self.unpressed_relief
|
78
|
+
|
79
|
+
|
80
|
+
# take into account the relief when calculating target size
|
81
|
+
inflated = self.expand_rect_with_padding((0, 0, *full_rect.size)).size
|
82
|
+
target_size = self.resolve_size(inflated)
|
83
|
+
if self.rect.size != target_size:
|
84
|
+
self.set_size(target_size)
|
85
|
+
size_changed = True
|
86
|
+
|
87
|
+
self._align_composed(other)
|
88
|
+
return size_changed
|
89
|
+
|
90
|
+
def _align_composed(self,other:Shape):
|
91
|
+
|
92
|
+
full_rect = self.get_local_inner_rect()
|
93
|
+
left_rect = self.text_rect
|
94
|
+
right_rect = other.rect
|
95
|
+
gap = {
|
96
|
+
bf.spacing.MIN: 0,
|
97
|
+
bf.spacing.HALF: (full_rect.width - left_rect.width - right_rect.width) // 2,
|
98
|
+
bf.spacing.MAX: full_rect.width - left_rect.width - right_rect.width,
|
99
|
+
bf.spacing.MANUAL: self.gap
|
100
|
+
}.get(self.spacing, 0)
|
101
|
+
|
102
|
+
gap = max(0, gap)
|
103
|
+
combined_width = left_rect.width + right_rect.width + gap
|
104
|
+
|
105
|
+
group_x = {
|
106
|
+
bf.alignment.LEFT: full_rect.left,
|
107
|
+
bf.alignment.MIDLEFT: full_rect.left,
|
108
|
+
bf.alignment.RIGHT: full_rect.right - combined_width,
|
109
|
+
bf.alignment.MIDRIGHT: full_rect.right - combined_width,
|
110
|
+
bf.alignment.CENTER: full_rect.centerx - combined_width // 2
|
111
|
+
}.get(self.alignment, full_rect.left)
|
112
|
+
|
113
|
+
left_rect.x, right_rect.x = group_x, group_x + left_rect.width + gap
|
114
|
+
|
115
|
+
if self.alignment in {bf.alignment.TOP, bf.alignment.TOPLEFT, bf.alignment.TOPRIGHT}:
|
116
|
+
left_rect.top = right_rect.top = full_rect.top
|
117
|
+
elif self.alignment in {bf.alignment.BOTTOM, bf.alignment.BOTTOMLEFT, bf.alignment.BOTTOMRIGHT}:
|
118
|
+
left_rect.bottom = right_rect.bottom = full_rect.bottom
|
119
|
+
else:
|
120
|
+
left_rect.centery = right_rect.centery = full_rect.centery
|
121
|
+
|
122
|
+
right_rect.move_ip(*self.rect.topleft)
|
123
|
+
|
124
|
+
def _build_layout(self) -> None:
|
125
|
+
return self._build_composed_layout(self.indicator)
|
126
|
+
|
127
|
+
|
128
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
from .label import Label
|
2
|
+
import batFramework as bf
|
3
|
+
import sys
|
4
|
+
|
5
|
+
class ToolTip(Label):
|
6
|
+
def __init__(self, text = ""):
|
7
|
+
super().__init__(text)
|
8
|
+
self.fade_in_duration : float = 0.1
|
9
|
+
self.fade_out_duration : float = 0.1
|
10
|
+
self.set_render_order(sys.maxsize)
|
11
|
+
|
12
|
+
def __str__(self):
|
13
|
+
return f"ToolTip('{self.text}')"
|
14
|
+
|
15
|
+
def top_at(self, x, y):
|
16
|
+
return None
|
17
|
+
|
18
|
+
def fade_in(self):
|
19
|
+
self.set_visible(True)
|
20
|
+
bf.PropertyEaser(
|
21
|
+
self.fade_in_duration,bf.easing.EASE_OUT,
|
22
|
+
0,self.parent_scene.name
|
23
|
+
).add_custom(self.get_alpha,self.set_alpha,255).start()
|
24
|
+
|
25
|
+
def fade_out(self):
|
26
|
+
bf.PropertyEaser(
|
27
|
+
self.fade_out_duration,bf.easing.EASE_IN,
|
28
|
+
0,self.parent_scene.name,
|
29
|
+
lambda : self.set_visible(False)
|
30
|
+
).add_custom(self.get_alpha,self.set_alpha,0).start()
|