adafruit-circuitpython-displayio-layout 2.0.1__tar.gz → 2.2.1__tar.gz
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.
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.readthedocs.yaml +3 -0
- {adafruit-circuitpython-displayio-layout-2.0.1/adafruit_circuitpython_displayio_layout.egg-info → adafruit_circuitpython_displayio_layout-2.2.1}/PKG-INFO +2 -2
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1/adafruit_circuitpython_displayio_layout.egg-info}/PKG-INFO +2 -2
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_circuitpython_displayio_layout.egg-info/SOURCES.txt +2 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/layouts/grid_layout.py +61 -7
- adafruit_circuitpython_displayio_layout-2.2.1/adafruit_displayio_layout/layouts/linear_layout.py +151 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/layouts/page_layout.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/layouts/tab_layout.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/cartesian.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/control.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/easing.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/flip_input.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/icon_animated.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/icon_widget.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/switch_round.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/widget.py +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/conf.py +1 -1
- adafruit_circuitpython_displayio_layout-2.2.1/examples/displayio_layout_linearlayout_simpletest.py +37 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/pyproject.toml +1 -1
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.github/workflows/build.yml +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.github/workflows/failure-help-text.yml +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.github/workflows/release_gh.yml +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.github/workflows/release_pypi.yml +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.gitignore +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.pre-commit-config.yaml +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/.pylintrc +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/CODE_OF_CONDUCT.md +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/LICENSE +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/LICENSES/CC-BY-4.0.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/LICENSES/MIT.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/LICENSES/OFL-1.1.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/LICENSES/Unlicense.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/README.rst +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/README.rst.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_circuitpython_displayio_layout.egg-info/dependency_links.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_circuitpython_displayio_layout.egg-info/requires.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_circuitpython_displayio_layout.egg-info/top_level.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/__init__.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/layouts/__init__.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/adafruit_displayio_layout/widgets/__init__.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/_static/favicon.ico +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/_static/favicon.ico.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/api.rst +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/api.rst.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/cartesian.gif +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/cartesian.gif.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/cartesian_explanation.png +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/cartesian_explanation.png.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/cartesian_zones.png +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/cartesian_zones.png.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/examples.rst +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/examples.rst.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/gui_layout_coordinates.png +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/gui_layout_coordinates.png.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/index.rst +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/index.rst.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/docs/requirements.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/bmps/active_tab_sprite.bmp +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/bmps/active_tab_sprite.bmp.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/bmps/inactive_tab_sprite.bmp +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/bmps/inactive_tab_sprite.bmp.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_cartesian_advanced_test.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_cartesian_lineplot.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_cartesian_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_flip_input_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_grid_layout_get_cell_test.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_gridlayout_dividers.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_gridlayout_pygame_display_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_gridlayout_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_icon_animated_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_page_layout_advancedtest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_page_layout_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_pygame_display_switch_round.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_switch_multiple.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_switch_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_tab_layout_simpletest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/displayio_layout_tab_layout_touchtest.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/fonts/Arial-16.bdf +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/fonts/Arial-16.bdf.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/fonts/DSEG14Classic-Regular-64-ModS.pcf +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/fonts/DSEG14Classic-Regular-64-ModS.pcf.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/hotplug_sensor_examples/displayio_layout_hotplug_rtc.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/hotplug_sensor_examples/displayio_layout_hotplug_temp_sensor.py +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/hotplug_sensor_examples/images/BGimage4.bmp +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/hotplug_sensor_examples/images/BGimage4.bmp.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/icons/Play_48x48_small.bmp +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/examples/icons/Play_48x48_small.bmp.license +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/optional_requirements.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/requirements.txt +0 -0
- {adafruit-circuitpython-displayio-layout-2.0.1 → adafruit_circuitpython_displayio_layout-2.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: adafruit-circuitpython-displayio-layout
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: CircuitPython helper library for displayio layouts and widgets.
|
|
5
5
|
Author-email: Adafruit Industries <circuitpython@adafruit.com>
|
|
6
6
|
License: MIT
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: adafruit-circuitpython-displayio-layout
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: CircuitPython helper library for displayio layouts and widgets.
|
|
5
5
|
Author-email: Adafruit Industries <circuitpython@adafruit.com>
|
|
6
6
|
License: MIT
|
|
@@ -26,6 +26,7 @@ adafruit_circuitpython_displayio_layout.egg-info/top_level.txt
|
|
|
26
26
|
adafruit_displayio_layout/__init__.py
|
|
27
27
|
adafruit_displayio_layout/layouts/__init__.py
|
|
28
28
|
adafruit_displayio_layout/layouts/grid_layout.py
|
|
29
|
+
adafruit_displayio_layout/layouts/linear_layout.py
|
|
29
30
|
adafruit_displayio_layout/layouts/page_layout.py
|
|
30
31
|
adafruit_displayio_layout/layouts/tab_layout.py
|
|
31
32
|
adafruit_displayio_layout/widgets/__init__.py
|
|
@@ -64,6 +65,7 @@ examples/displayio_layout_gridlayout_dividers.py
|
|
|
64
65
|
examples/displayio_layout_gridlayout_pygame_display_simpletest.py
|
|
65
66
|
examples/displayio_layout_gridlayout_simpletest.py
|
|
66
67
|
examples/displayio_layout_icon_animated_simpletest.py
|
|
68
|
+
examples/displayio_layout_linearlayout_simpletest.py
|
|
67
69
|
examples/displayio_layout_page_layout_advancedtest.py
|
|
68
70
|
examples/displayio_layout_page_layout_simpletest.py
|
|
69
71
|
examples/displayio_layout_pygame_display_switch_round.py
|
|
@@ -32,7 +32,7 @@ import math
|
|
|
32
32
|
import displayio
|
|
33
33
|
from vectorio import Rectangle
|
|
34
34
|
|
|
35
|
-
__version__ = "2.
|
|
35
|
+
__version__ = "2.2.1"
|
|
36
36
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout.git"
|
|
37
37
|
|
|
38
38
|
|
|
@@ -111,8 +111,14 @@ class GridLayout(displayio.Group):
|
|
|
111
111
|
):
|
|
112
112
|
self.cell_padding = 1
|
|
113
113
|
|
|
114
|
+
def layout_cells(self):
|
|
115
|
+
"""render the grid with all cell content and dividers"""
|
|
116
|
+
self._layout_cells()
|
|
117
|
+
|
|
114
118
|
def _layout_cells(self) -> None:
|
|
115
119
|
# pylint: disable=too-many-locals, too-many-branches, too-many-statements
|
|
120
|
+
for line_obj in self._divider_lines:
|
|
121
|
+
self.remove(line_obj["rect"])
|
|
116
122
|
for cell in self._cell_content_list:
|
|
117
123
|
if cell["content"] not in self:
|
|
118
124
|
grid_size_x = self.grid_size[0]
|
|
@@ -297,9 +303,6 @@ class GridLayout(displayio.Group):
|
|
|
297
303
|
x=_right_line_loc_x,
|
|
298
304
|
)
|
|
299
305
|
|
|
300
|
-
for line_obj in self._divider_lines:
|
|
301
|
-
self.remove(line_obj["rect"])
|
|
302
|
-
|
|
303
306
|
"""
|
|
304
307
|
Only use bottom divider lines on the bottom row. All
|
|
305
308
|
other rows rely on top divder lines of the row beneath them.
|
|
@@ -359,8 +362,8 @@ class GridLayout(displayio.Group):
|
|
|
359
362
|
}
|
|
360
363
|
)
|
|
361
364
|
|
|
362
|
-
|
|
363
|
-
|
|
365
|
+
for line_obj in self._divider_lines:
|
|
366
|
+
self.append(line_obj["rect"])
|
|
364
367
|
|
|
365
368
|
def add_content(
|
|
366
369
|
self,
|
|
@@ -368,6 +371,7 @@ class GridLayout(displayio.Group):
|
|
|
368
371
|
grid_position: Tuple[int, int],
|
|
369
372
|
cell_size: Tuple[int, int],
|
|
370
373
|
cell_anchor_point: Optional[Tuple[float, ...]] = None,
|
|
374
|
+
layout_cells=True,
|
|
371
375
|
) -> None:
|
|
372
376
|
"""Add a child to the grid.
|
|
373
377
|
|
|
@@ -395,7 +399,8 @@ class GridLayout(displayio.Group):
|
|
|
395
399
|
"cell_size": cell_size,
|
|
396
400
|
}
|
|
397
401
|
self._cell_content_list.append(sub_view_obj)
|
|
398
|
-
|
|
402
|
+
if layout_cells:
|
|
403
|
+
self._layout_cells()
|
|
399
404
|
|
|
400
405
|
def get_cell(self, cell_coordinates: Tuple[int, int]) -> displayio.Group:
|
|
401
406
|
"""
|
|
@@ -406,9 +411,21 @@ class GridLayout(displayio.Group):
|
|
|
406
411
|
:return: the displayio content object at those coordinates
|
|
407
412
|
"""
|
|
408
413
|
for index, cell in enumerate(self._cell_content_list):
|
|
414
|
+
# exact location 1x1 cell
|
|
409
415
|
if cell["grid_position"] == cell_coordinates:
|
|
410
416
|
return self._cell_content_list[index]["content"]
|
|
411
417
|
|
|
418
|
+
# multi-spanning cell, any size bigger than 1x1
|
|
419
|
+
if (
|
|
420
|
+
cell["grid_position"][0]
|
|
421
|
+
<= cell_coordinates[0]
|
|
422
|
+
< cell["grid_position"][0] + cell["cell_size"][0]
|
|
423
|
+
and cell["grid_position"][1]
|
|
424
|
+
<= cell_coordinates[1]
|
|
425
|
+
< cell["grid_position"][1] + cell["cell_size"][1]
|
|
426
|
+
):
|
|
427
|
+
return self._cell_content_list[index]["content"]
|
|
428
|
+
|
|
412
429
|
raise KeyError(
|
|
413
430
|
"GridLayout does not contain cell at coordinates {}".format(
|
|
414
431
|
cell_coordinates
|
|
@@ -425,3 +442,40 @@ class GridLayout(displayio.Group):
|
|
|
425
442
|
pixels of a 1x1 cell in the GridLayout
|
|
426
443
|
"""
|
|
427
444
|
return (self._width // self.grid_size[0], self._height // self.grid_size[1])
|
|
445
|
+
|
|
446
|
+
@property
|
|
447
|
+
def width(self) -> int:
|
|
448
|
+
"""
|
|
449
|
+
The width in pixels of the GridLayout.
|
|
450
|
+
"""
|
|
451
|
+
return self._width
|
|
452
|
+
|
|
453
|
+
@property
|
|
454
|
+
def height(self) -> int:
|
|
455
|
+
"""
|
|
456
|
+
The height in pixels of the GridLayout.
|
|
457
|
+
"""
|
|
458
|
+
return self._height
|
|
459
|
+
|
|
460
|
+
def which_cell_contains(
|
|
461
|
+
self, pixel_location: Union[Tuple[int, int], List[int]]
|
|
462
|
+
) -> Optional[tuple]:
|
|
463
|
+
"""
|
|
464
|
+
Given a pixel x,y coordinate returns the location of the cell
|
|
465
|
+
that contains the coordinate.
|
|
466
|
+
|
|
467
|
+
:param pixel_location: x,y pixel coordinate as a tuple or list
|
|
468
|
+
:returns: cell coordinates x,y tuple or None if the pixel coordinates are
|
|
469
|
+
outside the bounds of the GridLayout
|
|
470
|
+
"""
|
|
471
|
+
cell_size = self.cell_size_pixels
|
|
472
|
+
if (
|
|
473
|
+
not self.x <= pixel_location[0] < self.x + self.width
|
|
474
|
+
or not self.y <= pixel_location[1] < self.y + self.height
|
|
475
|
+
):
|
|
476
|
+
return None
|
|
477
|
+
|
|
478
|
+
cell_x_coord = (pixel_location[0] - self.x) // cell_size[0]
|
|
479
|
+
cell_y_coord = (pixel_location[1] - self.y) // cell_size[1]
|
|
480
|
+
|
|
481
|
+
return cell_x_coord, cell_y_coord
|
adafruit_circuitpython_displayio_layout-2.2.1/adafruit_displayio_layout/layouts/linear_layout.py
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2021 Tim Cocks
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""
|
|
5
|
+
`linear_layout`
|
|
6
|
+
================================================================================
|
|
7
|
+
|
|
8
|
+
A layout that organizes cells into a vertical or horizontal line.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
* Author(s): Tim Cocks
|
|
12
|
+
|
|
13
|
+
Implementation Notes
|
|
14
|
+
--------------------
|
|
15
|
+
|
|
16
|
+
**Hardware:**
|
|
17
|
+
|
|
18
|
+
**Software and Dependencies:**
|
|
19
|
+
|
|
20
|
+
* Adafruit CircuitPython firmware for the supported boards:
|
|
21
|
+
https://github.com/adafruit/circuitpython/releases
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from adafruit_displayio_layout.widgets.widget import Widget
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class LinearLayout(Widget):
|
|
29
|
+
"""
|
|
30
|
+
LinearLayout holds multiple content elements and arranges
|
|
31
|
+
them in a line either horizontally or vertically.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
VERTICAL_ORIENTATION = 1
|
|
35
|
+
HORIZONTAL_ORIENTATION = 2
|
|
36
|
+
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
x,
|
|
40
|
+
y,
|
|
41
|
+
orientation=VERTICAL_ORIENTATION,
|
|
42
|
+
padding=0,
|
|
43
|
+
):
|
|
44
|
+
"""
|
|
45
|
+
:param int x: The horizontal position of the layout
|
|
46
|
+
:param int y: The vertical position of the layout
|
|
47
|
+
:param int orientation: The orientation of the layout. Must be VERTICAL_ORIENTATION
|
|
48
|
+
or HORIZONTAL_ORIENTATION
|
|
49
|
+
:param int padding: The padding between items in the layout
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
super().__init__(x=x, y=y, width=1, height=1)
|
|
53
|
+
|
|
54
|
+
self.x = x
|
|
55
|
+
self.y = y
|
|
56
|
+
self.padding = padding
|
|
57
|
+
if orientation not in [self.VERTICAL_ORIENTATION, self.HORIZONTAL_ORIENTATION]:
|
|
58
|
+
raise ValueError(
|
|
59
|
+
"Orientation must be either LinearLayout.VERTICAL_ORIENTATION"
|
|
60
|
+
" or LinearLayout.HORIZONTAL_ORIENTATION"
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
self.orientation = orientation
|
|
64
|
+
self._content_list = []
|
|
65
|
+
self._prev_content_end = 0
|
|
66
|
+
|
|
67
|
+
def add_content(self, content):
|
|
68
|
+
"""Add a child to the linear layout.
|
|
69
|
+
|
|
70
|
+
:param content: the content to add to the linear layout e.g. label, button, etc...
|
|
71
|
+
Group subclasses that have width and height properties can be used.
|
|
72
|
+
|
|
73
|
+
:return: None"""
|
|
74
|
+
|
|
75
|
+
self._content_list.append(content)
|
|
76
|
+
self.append(content)
|
|
77
|
+
self._layout()
|
|
78
|
+
|
|
79
|
+
def _layout(self):
|
|
80
|
+
# pylint: disable=too-many-branches, protected-access
|
|
81
|
+
self._prev_content_end = 0
|
|
82
|
+
|
|
83
|
+
for _, content in enumerate(self._content_list):
|
|
84
|
+
if not hasattr(content, "anchor_point"):
|
|
85
|
+
if self.orientation == self.VERTICAL_ORIENTATION:
|
|
86
|
+
content.y = self._prev_content_end
|
|
87
|
+
try:
|
|
88
|
+
self._prev_content_end = (
|
|
89
|
+
self._prev_content_end + content.height + self.padding
|
|
90
|
+
)
|
|
91
|
+
except AttributeError as error:
|
|
92
|
+
print(error)
|
|
93
|
+
try:
|
|
94
|
+
self._prev_content_end = (
|
|
95
|
+
self._prev_content_end + content._height + self.padding
|
|
96
|
+
)
|
|
97
|
+
except AttributeError as inner_error:
|
|
98
|
+
print(inner_error)
|
|
99
|
+
|
|
100
|
+
else:
|
|
101
|
+
content.x = self._prev_content_end
|
|
102
|
+
if not hasattr(content, "tile_width"):
|
|
103
|
+
self._prev_content_end = (
|
|
104
|
+
content.x + content.width + (self.padding * 2)
|
|
105
|
+
)
|
|
106
|
+
else:
|
|
107
|
+
self._prev_content_end = (
|
|
108
|
+
content.x
|
|
109
|
+
+ (content.width * content.tile_width)
|
|
110
|
+
+ (self.padding * 2)
|
|
111
|
+
)
|
|
112
|
+
else: # use anchor point
|
|
113
|
+
content.anchor_point = (
|
|
114
|
+
0,
|
|
115
|
+
content.anchor_point[1] if content.anchor_point is not None else 0,
|
|
116
|
+
)
|
|
117
|
+
if self.orientation == self.VERTICAL_ORIENTATION:
|
|
118
|
+
content.anchored_position = (0, self._prev_content_end)
|
|
119
|
+
# self._prev_content_end = content.y + content.height
|
|
120
|
+
if not hasattr(content, "bounding_box"):
|
|
121
|
+
self._prev_content_end = (
|
|
122
|
+
self._prev_content_end + content.height + self.padding
|
|
123
|
+
)
|
|
124
|
+
else:
|
|
125
|
+
self._prev_content_end = (
|
|
126
|
+
self._prev_content_end
|
|
127
|
+
+ (content.bounding_box[3] * content.scale)
|
|
128
|
+
+ self.padding
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
else:
|
|
132
|
+
original_achored_pos_y = (
|
|
133
|
+
content.anchored_position[1]
|
|
134
|
+
if content.anchored_position is not None
|
|
135
|
+
else 0
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
content.anchored_position = (
|
|
139
|
+
self._prev_content_end,
|
|
140
|
+
original_achored_pos_y,
|
|
141
|
+
)
|
|
142
|
+
if not hasattr(content, "bounding_box"):
|
|
143
|
+
self._prev_content_end = (
|
|
144
|
+
self._prev_content_end + content.width + self.padding
|
|
145
|
+
)
|
|
146
|
+
else:
|
|
147
|
+
self._prev_content_end = (
|
|
148
|
+
self._prev_content_end
|
|
149
|
+
+ (content.bounding_box[2] * content.scale)
|
|
150
|
+
+ self.padding
|
|
151
|
+
)
|
|
@@ -37,7 +37,7 @@ from adafruit_display_text.bitmap_label import Label
|
|
|
37
37
|
from adafruit_imageload.tilegrid_inflator import inflate_tilegrid
|
|
38
38
|
from adafruit_displayio_layout.layouts.page_layout import PageLayout
|
|
39
39
|
|
|
40
|
-
__version__ = "2.
|
|
40
|
+
__version__ = "2.2.1"
|
|
41
41
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout.git"
|
|
42
42
|
|
|
43
43
|
|
|
@@ -32,6 +32,7 @@ inheritance_graph_attrs = dict(rankdir="TB")
|
|
|
32
32
|
# autodoc module docs will fail to generate with a warning.
|
|
33
33
|
autodoc_mock_imports = [
|
|
34
34
|
"vectorio",
|
|
35
|
+
"terminalio",
|
|
35
36
|
"bitmaptools",
|
|
36
37
|
]
|
|
37
38
|
|
|
@@ -117,7 +118,6 @@ napoleon_numpy_docstring = False
|
|
|
117
118
|
import sphinx_rtd_theme
|
|
118
119
|
|
|
119
120
|
html_theme = "sphinx_rtd_theme"
|
|
120
|
-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
|
|
121
121
|
|
|
122
122
|
# Add any paths that contain custom static files (such as style sheets) here,
|
|
123
123
|
# relative to this directory. They are copied after the builtin static files,
|
adafruit_circuitpython_displayio_layout-2.2.1/examples/displayio_layout_linearlayout_simpletest.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 Tim C, written for Adafruit Industries
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""
|
|
5
|
+
Illustrates usage of LinearLayout to display a text label to the right of
|
|
6
|
+
an icon.
|
|
7
|
+
"""
|
|
8
|
+
import adafruit_imageload
|
|
9
|
+
import board
|
|
10
|
+
import displayio
|
|
11
|
+
import terminalio
|
|
12
|
+
from adafruit_display_text import label
|
|
13
|
+
from adafruit_displayio_layout.layouts.linear_layout import LinearLayout
|
|
14
|
+
|
|
15
|
+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
|
|
16
|
+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
|
|
17
|
+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
|
|
18
|
+
display = board.DISPLAY
|
|
19
|
+
|
|
20
|
+
# Make the display context
|
|
21
|
+
main_group = displayio.Group()
|
|
22
|
+
display.root_group = main_group
|
|
23
|
+
|
|
24
|
+
layout = LinearLayout(
|
|
25
|
+
x=10, y=10, padding=4, orientation=LinearLayout.HORIZONTAL_ORIENTATION
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
lbl = label.Label(terminalio.FONT, scale=4, x=0, y=0, text="Hello")
|
|
29
|
+
|
|
30
|
+
icon, icon_palette = adafruit_imageload.load("icons/Play_48x48_small.bmp")
|
|
31
|
+
icon_tile_grid = displayio.TileGrid(icon, pixel_shader=icon_palette)
|
|
32
|
+
layout.add_content(icon_tile_grid)
|
|
33
|
+
layout.add_content(lbl)
|
|
34
|
+
|
|
35
|
+
main_group.append(layout)
|
|
36
|
+
while True:
|
|
37
|
+
pass
|
|
@@ -12,7 +12,7 @@ requires = [
|
|
|
12
12
|
[project]
|
|
13
13
|
name = "adafruit-circuitpython-displayio-layout"
|
|
14
14
|
description = "CircuitPython helper library for displayio layouts and widgets."
|
|
15
|
-
version = "2.
|
|
15
|
+
version = "2.2.1"
|
|
16
16
|
readme = "README.rst"
|
|
17
17
|
authors = [
|
|
18
18
|
{name = "Adafruit Industries", email = "circuitpython@adafruit.com"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|