Skip to content

Commit

Permalink
Removed PosHint/SizeHint dataclasses.
Browse files Browse the repository at this point in the history
Renamed PosHintDict/SizeHintDict to PosHint/SizeHint.
This is technically a breaking API change, but only if one was mutating size/pos hints.
Now mutating size/pos hints is extremely discouraged; instead, it's better to set a new size or
pos hint.
  • Loading branch information
salt-die committed Aug 15, 2024
1 parent f5a7972 commit d2ca6d7
Show file tree
Hide file tree
Showing 45 changed files with 355 additions and 568 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"batgrl.colors.color_types.AColor": False,
"batgrl.colors.color_types.ColorPair": False,
"batgrl.colors.color_types.ColorTheme": False,
"batgrl.gadgets.gadget.PosHintDict": False,
"batgrl.gadgets.gadget.SizeHintDict": False,
"batgrl.gadgets.gadget.PosHint": False,
"batgrl.gadgets.gadget.SizeHint": False,
"batgrl.geometry.basic.Point": False,
"batgrl.geometry.basic.Size": False,
"batgrl.figfont.FullLayout": False,
Expand Down
26 changes: 12 additions & 14 deletions src/batgrl/gadgets/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
Gadget,
Point,
PosHint,
PosHintDict,
Region,
Size,
SizeHint,
SizeHintDict,
bindable,
clamp,
)
Expand Down Expand Up @@ -66,9 +64,9 @@ class Animation(Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: True
Whether gadget is transparent.
Expand Down Expand Up @@ -213,8 +211,8 @@ def __init__(
interpolation: Interpolation = "linear",
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = True,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down Expand Up @@ -371,8 +369,8 @@ def from_textures(
interpolation: Interpolation = "linear",
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = True,
is_visible: bool = True,
is_enabled: bool = True,
Expand All @@ -399,9 +397,9 @@ def from_textures(
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: True
Whether gadget is transparent.
Expand Down Expand Up @@ -458,8 +456,8 @@ def from_images(
interpolation: Interpolation = "linear",
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = True,
is_visible: bool = True,
is_enabled: bool = True,
Expand All @@ -486,9 +484,9 @@ def from_images(
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: True
Whether gadget is transparent.
Expand Down
10 changes: 5 additions & 5 deletions src/batgrl/gadgets/ans_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ..colors import BLACK, WHITE, Color, lerp_colors
from ..geometry import Point, Size
from ..text_tools import Cell, new_cell
from .gadget import Gadget, PosHint, PosHintDict, SizeHint, SizeHintDict
from .gadget import Gadget, PosHint, SizeHint
from .scroll_view import ScrollView
from .text import Text

Expand Down Expand Up @@ -257,9 +257,9 @@ class AnsViewer(Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -383,8 +383,8 @@ def __init__(
guess_width: bool = True,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
10 changes: 4 additions & 6 deletions src/batgrl/gadgets/bar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
Gadget,
Point,
PosHint,
PosHintDict,
Size,
SizeHint,
SizeHintDict,
lerp,
)
from .pane import Pane
Expand Down Expand Up @@ -72,9 +70,9 @@ class BarChart(Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -244,8 +242,8 @@ def __init__(
grid_line_color: Color = DEFAULT_GRID_COLOR,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
10 changes: 4 additions & 6 deletions src/batgrl/gadgets/box_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
Gadget,
Point,
PosHint,
PosHintDict,
Size,
SizeHint,
SizeHintDict,
)
from .text import Text

Expand All @@ -34,9 +32,9 @@ class BoxImage(Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -159,8 +157,8 @@ def __init__(
alpha: float = 1.0,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
10 changes: 4 additions & 6 deletions src/batgrl/gadgets/braille_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
Gadget,
Point,
PosHint,
PosHintDict,
Size,
SizeHint,
SizeHintDict,
)
from .text import Text

Expand All @@ -34,9 +32,9 @@ class BrailleImage(Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -159,8 +157,8 @@ def __init__(
alpha: float = 1.0,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
10 changes: 4 additions & 6 deletions src/batgrl/gadgets/braille_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
Gadget,
Point,
PosHint,
PosHintDict,
Size,
SizeHint,
SizeHintDict,
)
from .text import Text

Expand Down Expand Up @@ -56,9 +54,9 @@ class BrailleVideo(Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -209,8 +207,8 @@ def __init__(
alpha: float = 1.0,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
10 changes: 4 additions & 6 deletions src/batgrl/gadgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
Gadget,
Point,
PosHint,
PosHintDict,
Size,
SizeHint,
SizeHintDict,
)
from .pane import Pane
from .text import Text
Expand All @@ -37,9 +35,9 @@ class Button(Themable, ButtonBehavior, Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -182,8 +180,8 @@ def __init__(
alpha: float = 1.0,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
10 changes: 4 additions & 6 deletions src/batgrl/gadgets/color_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
Gadget,
Point,
PosHint,
PosHintDict,
Size,
SizeHint,
SizeHintDict,
)
from .graphics import Graphics
from .pane import Pane
Expand Down Expand Up @@ -162,9 +160,9 @@ class ColorPicker(Themable, Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -287,8 +285,8 @@ def __init__(
alpha: float = 1.0,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
10 changes: 4 additions & 6 deletions src/batgrl/gadgets/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
Gadget,
Point,
PosHint,
PosHintDict,
Size,
SizeHint,
SizeHintDict,
)
from .pane import Pane
from .scroll_view import ScrollView
Expand Down Expand Up @@ -282,9 +280,9 @@ class Console(Themable, Focusable, Gadget):
Transparency of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -429,8 +427,8 @@ def __init__(
alpha: float = 1.0,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
10 changes: 4 additions & 6 deletions src/batgrl/gadgets/data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
Gadget,
Point,
PosHint,
PosHintDict,
Size,
SizeHint,
SizeHintDict,
)
from .grid_layout import GridLayout
from .pane import Pane
Expand Down Expand Up @@ -340,9 +338,9 @@ class DataTable(Themable, Gadget):
Size of gadget.
pos : Point, default: Point(0, 0)
Position of upper-left corner in parent.
size_hint : SizeHint | SizeHintDict | None, default: None
size_hint : SizeHint | None, default: None
Size as a proportion of parent's height and width.
pos_hint : PosHint | PosHintDict | None , default: None
pos_hint : PosHint | None, default: None
Position as a proportion of parent's height and width.
is_transparent : bool, default: False
Whether gadget is transparent.
Expand Down Expand Up @@ -491,8 +489,8 @@ def __init__(
alpha: float = 1.0,
size: Size = Size(10, 10),
pos: Point = Point(0, 0),
size_hint: SizeHint | SizeHintDict | None = None,
pos_hint: PosHint | PosHintDict | None = None,
size_hint: SizeHint | None = None,
pos_hint: PosHint | None = None,
is_transparent: bool = False,
is_visible: bool = True,
is_enabled: bool = True,
Expand Down
Loading

0 comments on commit d2ca6d7

Please sign in to comment.