move images into assets dir. add default_icon. remove sized_group.py

This commit is contained in:
foamyguy 2025-04-14 16:06:34 -05:00
parent 5052bf7210
commit bf16795222
6 changed files with 4 additions and 53 deletions

View file

@ -34,7 +34,7 @@ bg_tg = displayio.TileGrid(bitmap=background_bmp, pixel_shader=bg_palette)
main_group.append(bg_tg) main_group.append(bg_tg)
# load the mouse cursor bitmap # load the mouse cursor bitmap
mouse_bmp = displayio.OnDiskBitmap("mouse_cursor.bmp") mouse_bmp = displayio.OnDiskBitmap("launcher_assets/mouse_cursor.bmp")
# make the background pink pixels transparent # make the background pink pixels transparent
mouse_bmp.pixel_shader.make_transparent(0) mouse_bmp.pixel_shader.make_transparent(0)
@ -150,7 +150,7 @@ config = {
cell_width = WIDTH // config["width"] cell_width = WIDTH // config["width"]
default_icon_bmp, default_icon_palette = adafruit_imageload.load("default_icon_64.bmp") default_icon_bmp, default_icon_palette = adafruit_imageload.load("launcher_assets/default_icon.bmp")
default_icon_palette.make_transparent(0) default_icon_palette.make_transparent(0)
menu_grid = GridLayout(x=10, y=26, width=WIDTH, height=HEIGHT, grid_size=(config["width"], config["height"]), menu_grid = GridLayout(x=10, y=26, width=WIDTH, height=HEIGHT, grid_size=(config["width"], config["height"]),
divider_lines=False) divider_lines=False)
@ -197,9 +197,9 @@ for path in app_path.iterdir():
menu_grid.add_content(cell_group, grid_position=(i % config["width"], i // config["width"]), cell_size=(1, 1)) menu_grid.add_content(cell_group, grid_position=(i % config["width"], i // config["width"]), cell_size=(1, 1))
i += 1 i += 1
left_bmp, left_palette = adafruit_imageload.load("arrow_left.bmp") left_bmp, left_palette = adafruit_imageload.load("launcher_assets/arrow_left.bmp")
left_palette.make_transparent(0) left_palette.make_transparent(0)
right_bmp, right_palette = adafruit_imageload.load("arrow_right.bmp") right_bmp, right_palette = adafruit_imageload.load("launcher_assets/arrow_right.bmp")
right_palette.make_transparent(0) right_palette.make_transparent(0)
left_tg = AnchoredTileGrid(bitmap=left_bmp, pixel_shader=left_palette) left_tg = AnchoredTileGrid(bitmap=left_bmp, pixel_shader=left_palette)

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B

View file

@ -1,49 +0,0 @@
import displayio
class SizedGroup(displayio.Group):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@property
def size(self):
min_x = 0
min_y = 0
max_x = 0
max_y = 0
for element in self:
# print(type(element))
if type(element) == displayio.TileGrid:
if element.x < min_x:
min_x = element.x
if element.y < min_y:
min_y = element.y
_element_max_x = element.x + (element.width * element.tile_width)
_element_max_y = element.y + (element.height * element.tile_height)
if _element_max_x > max_x:
max_x = _element_max_x
if _element_max_y > max_y:
max_y = _element_max_y
else:
if element.x < min_x:
min_x = element.x
if element.y < min_y:
min_y = element.y
_element_max_x = element.x + (element.width * element.scale)
_element_max_y = element.y + (element.height * element.scale)
if _element_max_x > max_x:
max_x = _element_max_x
if _element_max_y > max_y:
max_y = _element_max_y
return max_x - min_x, max_y - min_y
@property
def width(self):
return self.size[0]
@property
def height(self):
return self.size[1]