Skip to content

Commit

Permalink
minimum_grid_size renamed min_grid_size to be consistent with oth…
Browse files Browse the repository at this point in the history
…er similar names.
  • Loading branch information
salt-die committed Aug 19, 2024
1 parent 245a6d5 commit 4ee075b
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/advanced/connect4/connect4/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Board(GridLayout):
def __init__(self):
super().__init__(grid_rows=6, grid_columns=7, pos=(2, 0), is_transparent=True)
self.add_gadgets(BoardPiece() for _ in range(42))
self.size = self.minimum_grid_size
self.size = self.min_grid_size
self._last_col = -1

def on_mouse(self, mouse_event):
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/shadow_casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def callback(state):
button_f,
button_g,
)
grid_layout.size = grid_layout.minimum_grid_size
grid_layout.size = grid_layout.min_grid_size

container = Gadget(pos_hint={"y_hint": 0.5, "x_hint": 0.5}, size=(17, 58))
container.add_gadgets(caster, grid_layout)
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/borders.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async def on_start(self):
gadget.add_str(f"{f'*{border}*':^17}", pos=(1, 1), markdown=True)
grid_layout.add_gadget(gadget)

grid_layout.size = grid_layout.minimum_grid_size
grid_layout.size = grid_layout.min_grid_size
self.add_gadget(grid_layout)


Expand Down
5 changes: 3 additions & 2 deletions examples/basic/buttons.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Button showcase."""

from batgrl.app import App
from batgrl.gadgets.button import Button
from batgrl.gadgets.flat_toggle import FlatToggle
Expand Down Expand Up @@ -57,7 +58,7 @@ def callback(state):
)
for i in range(10, 15)
)
grid_layout.size = grid_layout.minimum_grid_size
grid_layout.size = grid_layout.min_grid_size

flat_grid = GridLayout(
grid_rows=2,
Expand All @@ -73,7 +74,7 @@ def callback(state):
FlatToggle(group=1, callback=toggle_button_callback(i))
for i in range(20, 25)
)
flat_grid.size = flat_grid.minimum_grid_size
flat_grid.size = flat_grid.min_grid_size
self.add_gadgets(display, grid_layout, flat_grid)


Expand Down
2 changes: 1 addition & 1 deletion examples/basic/spinners.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def on_start(self):

grid.add_gadget(container)

grid.size = grid.minimum_grid_size
grid.size = grid.min_grid_size
sv.view = grid
self.add_gadget(sv)

Expand Down
4 changes: 2 additions & 2 deletions src/batgrl/gadgets/data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ def _fix_sizes(self):
for row, row_height in zip(self._table.children, row_heights):
for cell, column_width in zip(row.children, column_widths):
cell.size = row_height, column_width
row.size = row.minimum_grid_size
self._table.size = self._table.minimum_grid_size
row.size = row.min_grid_size
self._table.size = self._table.min_grid_size

# Remove hovered rows/columns:
self._hover_column_id = self._hover_row_id = -1
Expand Down
10 changes: 5 additions & 5 deletions src/batgrl/gadgets/grid_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class GridLayout(Gadget):
Attributes
----------
minimum_grid_size : Size
min_grid_size : Size
Minimum grid size needed to show all children.
grid_rows : int
Number of rows.
Expand Down Expand Up @@ -217,9 +217,9 @@ class GridLayout(Gadget):
Re-ordering children (such as through :meth:`pull_to_front`) and calling
:meth:`_reposition_children` will change the positions of the children in the grid.
The read-only attribute :attr:`minimum_grid_size` is the minimum size the grid must
The read-only attribute :attr:`min_grid_size` is the minimum size the grid must
be to show all children. This can be used to set the size of the grid layout, e.g.,
``my_grid.size = my_grid.minimum_grid_size``.
``my_grid.size = my_grid.min_grid_size``.
"""

grid_rows: int = _RepositionProperty()
Expand Down Expand Up @@ -260,7 +260,7 @@ def __init__(
self._padding_bottom = padding_bottom
self._horizontal_spacing = horizontal_spacing
self._vertical_spacing = vertical_spacing
self._minimum_grid_size = Size(0, 0)
self._min_grid_size = Size(0, 0)

super().__init__(
size=size,
Expand Down Expand Up @@ -353,7 +353,7 @@ def _col_width(self, i: int) -> int:
)

@property
def minimum_grid_size(self) -> Size:
def min_grid_size(self) -> Size:
"""Return the minimum grid size to show all children."""
nrows, ncols = self.grid_rows, self.grid_columns
if nrows == 0 or ncols == 0:
Expand Down
10 changes: 5 additions & 5 deletions src/batgrl/gadgets/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def __init__(self, items, prefix):
bullet.set_text(getattr(item, "check", prefix))
self.add_gadgets(bullet, item)

self.size = self.minimum_grid_size
self.size = self.min_grid_size


class _Quote(Pane):
Expand All @@ -293,7 +293,7 @@ def __init__(self, content: Gadget, depth):
self.grid = GridLayout(grid_rows=1, grid_columns=2, is_transparent=True)
self.grid.add_gadgets(margin, content)
self.add_gadget(self.grid)
self.size = self.grid.size = self.grid.minimum_grid_size
self.size = self.grid.size = self.grid.min_grid_size
self.color_content()

def color_content(self):
Expand Down Expand Up @@ -537,7 +537,7 @@ def render_quote(self, token: block_token.Quote) -> _Quote:
else:
grid = GridLayout(grid_rows=len(items), is_transparent=True)
grid.add_gadgets(items)
grid.size = grid.minimum_grid_size
grid.size = grid.min_grid_size
quote = _Quote(grid, self.quote_depth)

quote.width = max(quote.width, self.render_width)
Expand Down Expand Up @@ -600,7 +600,7 @@ def render_list_item(self, token: block_token.ListItem) -> Gadget:
grid_columns=1, grid_rows=len(blocks), is_transparent=True
)
list_item.add_gadgets(blocks)
list_item.size = list_item.minimum_grid_size
list_item.size = list_item.min_grid_size
return list_item

def render_table(self, token: block_token.Table) -> Text:
Expand Down Expand Up @@ -692,7 +692,7 @@ def render_document(self, token: block_token.Document) -> GridLayout:
blocks = [block for block in rendered if not hasattr(block, "skip_blank_line")]
grid = GridLayout(grid_rows=len(blocks), is_transparent=True)
grid.add_gadgets(blocks)
grid.size = grid.minimum_grid_size
grid.size = grid.min_grid_size
grid.footnotes = token.footnotes
return grid

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class Menu(GridLayout):
Whether to close the menu when a click doesn't collide with it.
alpha : float
Transparency of gadget.
minimum_grid_size : Size
min_grid_size : Size
Minimum grid size needed to show all children.
grid_rows : int
Number of rows.
Expand Down

0 comments on commit 4ee075b

Please sign in to comment.