Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ Arcade [PyPi Release History](https://pypi.org/project/arcade/#history) page.

## Version 3.0.1 (unreleased)

### Improvements

- `UIWidget.with_background` now accepts a tuple for color

### Bug Fixes

- Fixed division error in box layout algorithm
- Fix example added buttons to multiple layouts


## Version 3.0.1

### Bug Fixes

- Fixed blurriness in `UIWidget` text during interaction
Expand Down
10 changes: 4 additions & 6 deletions arcade/examples/gui/5_uicolor_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,10 @@ def __init__(self):
)
)
for i, (name, color) in enumerate(self.colors.items()):
button = self.root.add(
ColorButton(
color_name=name,
color=color,
size_hint=(1, 1),
)
button = ColorButton(
color_name=name,
color=color,
size_hint=(1, 1),
)
self.grid.add(button, row=i // 5, column=i % 5)

Expand Down
3 changes: 3 additions & 0 deletions arcade/gui/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ def with_background(
self
"""
if color is not ...:
if color is not None:
color = Color.from_iterable(color)

self._bg_color = color

if texture is not ...:
Expand Down
8 changes: 8 additions & 0 deletions arcade/gui/widgets/layout.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import warnings
from dataclasses import dataclass
from typing import Dict, Iterable, List, Optional, Tuple, TypeVar

Expand Down Expand Up @@ -900,6 +901,13 @@ def _box_axis_algorithm(constraints: list[_C], container_size: float) -> List[fl
Returns:
List of tuples with the sizes of each element
"""

# if there is no space, return the min value of each constraint
# this will cause a overflow, so we give a warning
if container_size <= 0:
warnings.warn("Container size is 0, cannot calculate sizes for children.")
return [c.min for c in constraints]

# adjust hint value based on min and max values
for c in constraints:
c.hint = max(c.min / container_size, c.hint)
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/gui/test_layouting_box_main_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ def test_shw_smaller_1(window):
assert sizes == [10, 10, 50]


def test_container_size_zero(window):
# GIVEN
entries = [
_C(hint=0.1, min=50, max=None),
_C(hint=0.1, min=50, max=None),
_C(hint=0.5, min=50, max=None),
]

# WHEN
sizes = _box_axis_algorithm(entries, 0)

# THEN
assert sizes == [50, 50, 50]


def test_complex_example_with_max_value():
# GIVEN
entries = [
Expand Down
Loading