Skip to content

Commit

Permalink
Rename subscribable to bindable.
Browse files Browse the repository at this point in the history
  • Loading branch information
salt-die committed Feb 19, 2024
1 parent ff4b8ae commit 850069d
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions batgrl/gadgets/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
subscribable,
)
from .image import Image, Interpolation

Expand Down Expand Up @@ -289,7 +289,7 @@ def alpha(self) -> float:
return self._alpha

@alpha.setter
@subscribable
@bindable
def alpha(self, alpha: float):
self._alpha = clamp(float(alpha), 0.0, 1.0)
for frame in self.frames:
Expand Down
10 changes: 5 additions & 5 deletions batgrl/gadgets/gadget.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"coerce_char",
"lerp",
"style_char",
"subscribable",
"bindable",
]

_UID = count(1)
Expand Down Expand Up @@ -397,8 +397,8 @@ class SizeHintDict(TypedDict, total=False):
"""Easings for :meth:`batgrl.gadgets.Gadget.tween`"""


def subscribable(setter):
"""Decorate property setters to make them subscribable."""
def bindable(setter):
"""Decorate property setters to make them bindable."""
instances: WeakKeyDictionary[Gadget, Callable[[], None]] = WeakKeyDictionary()

@wraps(setter)
Expand Down Expand Up @@ -588,7 +588,7 @@ def size(self) -> Size:
return self._size

@size.setter
@subscribable
@bindable
def size(self, size: Size):
if size == self._size:
self._apply_pos_hints()
Expand Down Expand Up @@ -638,7 +638,7 @@ def pos(self) -> Point:
return self._pos

@pos.setter
@subscribable
@bindable
def pos(self, pos: Point):
y, x = pos
pos = Point(int(y), int(x))
Expand Down
4 changes: 2 additions & 2 deletions batgrl/gadgets/graphic_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
subscribable,
)
from .texture_tools import _composite

Expand Down Expand Up @@ -228,7 +228,7 @@ def alpha(self) -> float:
return self._alpha

@alpha.setter
@subscribable
@bindable
def alpha(self, alpha: float):
self._alpha = clamp(float(alpha), 0.0, 1.0)

Expand Down
6 changes: 3 additions & 3 deletions batgrl/gadgets/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
lerp,
subscribable,
)
from .texture_tools import Interpolation, _composite

Expand All @@ -38,7 +38,7 @@
"SizeHintDict",
"clamp",
"lerp",
"subscribable",
"bindable",
]


Expand Down Expand Up @@ -226,7 +226,7 @@ def alpha(self) -> float:
return self._alpha

@alpha.setter
@subscribable
@bindable
def alpha(self, alpha: float):
self._alpha = clamp(float(alpha), 0.0, 1.0)

Expand Down
6 changes: 3 additions & 3 deletions batgrl/gadgets/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
lerp,
style_char,
subscribable,
)
from .texture_tools import _composite

Expand All @@ -36,7 +36,7 @@
"clamp",
"lerp",
"style_char",
"subscribable",
"bindable",
]


Expand Down Expand Up @@ -202,7 +202,7 @@ def alpha(self) -> float:
return self._alpha

@alpha.setter
@subscribable
@bindable
def alpha(self, alpha: float):
self._alpha = clamp(float(alpha), 0.0, 1.0)

Expand Down
4 changes: 2 additions & 2 deletions batgrl/gadgets/parallax.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
subscribable,
)
from .image import Image, Interpolation

Expand Down Expand Up @@ -275,7 +275,7 @@ def alpha(self) -> float:
return self._alpha

@alpha.setter
@subscribable
@bindable
def alpha(self, alpha: float):
self._alpha = clamp(float(alpha), 0.0, 1.0)
for layer in self.layers:
Expand Down
4 changes: 2 additions & 2 deletions batgrl/gadgets/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
subscribable,
)
from .text import Text
from .text_tools import smooth_horizontal_bar, smooth_vertical_bar
Expand Down Expand Up @@ -203,7 +203,7 @@ def progress(self) -> float:
return self._progress

@progress.setter
@subscribable
@bindable
def progress(self, progress: float):
self._progress = None if progress is None else clamp(progress, 0.0, 1.0)
self._update_bar()
Expand Down
10 changes: 5 additions & 5 deletions batgrl/gadgets/scroll_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
subscribable,
)
from .pane import Pane
from .text import Text
Expand Down Expand Up @@ -487,7 +487,7 @@ def show_vertical_bar(self) -> bool:
return self._vertical_bar.is_enabled

@show_vertical_bar.setter
@subscribable
@bindable
def show_vertical_bar(self, show: bool):
self._vertical_bar.is_enabled = show
self._corner.is_enabled = show or self._horizontal_bar.is_enabled
Expand All @@ -499,7 +499,7 @@ def show_horizontal_bar(self) -> bool:
return self._horizontal_bar.is_enabled

@show_horizontal_bar.setter
@subscribable
@bindable
def show_horizontal_bar(self, show: bool):
self._horizontal_bar.is_enabled = show
self._corner.is_enabled = show or self._vertical_bar.is_enabled
Expand All @@ -511,7 +511,7 @@ def vertical_proportion(self) -> float:
return self._vertical_proportion

@vertical_proportion.setter
@subscribable
@bindable
def vertical_proportion(self, vertical_proportion: float):
if self.allow_vertical_scroll:
if self._view is None or self.total_vertical_distance <= 0:
Expand All @@ -526,7 +526,7 @@ def horizontal_proportion(self) -> float:
return self._horizontal_proportion

@horizontal_proportion.setter
@subscribable
@bindable
def horizontal_proportion(self, horizontal_proportion: float):
if self.allow_horizontal_scroll:
if self._view is None or self.total_horizontal_distance <= 0:
Expand Down
6 changes: 3 additions & 3 deletions batgrl/gadgets/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
subscribable,
)
from .text import Text

Expand Down Expand Up @@ -341,7 +341,7 @@ def proportion(self) -> float:
return self._proportion

@proportion.setter
@subscribable
@bindable
def proportion(self, value: float):
if not self.slider_enabled:
return
Expand All @@ -362,7 +362,7 @@ def value(self) -> float:
return self._value

@value.setter
@subscribable
@bindable
def value(self, value: float):
value = clamp(value, self.min, self.max)
self.proportion = (value - self.min) / (self.max - self.min)
Expand Down
6 changes: 3 additions & 3 deletions batgrl/gadgets/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
coerce_char,
lerp,
style_char,
subscribable,
)
from .text_tools import (
_parse_batgrl_md,
Expand Down Expand Up @@ -57,7 +57,7 @@
"coerce_char",
"lerp",
"style_char",
"subscribable",
"bindable",
]

Border = Literal[
Expand Down Expand Up @@ -307,7 +307,7 @@ def alpha(self) -> float:
return self._alpha

@alpha.setter
@subscribable
@bindable
def alpha(self, alpha: float):
self._alpha = clamp(float(alpha), 0.0, 1.0)

Expand Down

0 comments on commit 850069d

Please sign in to comment.