# Released under the MIT License. See LICENSE for details.
#
"""Useful bits to use with UIs."""
from __future__ import annotations # Docs-generation hack.
from typing import TYPE_CHECKING
import bauiv1 as bui
from bauiv1 import stdassets
from bauiv1 import builtinassets
if TYPE_CHECKING:
pass
def _scroll_fade(
container: bui.Widget,
scrollleft: float,
scrollbottom: float,
scrollwidth: float,
scrollheight: float,
*,
yoffs: float,
center: bool,
yscale: float,
) -> None:
del scrollheight # Unused.
clr = (0.4, 0.37, 0.49)
# clr = (1, 0, 0)
blotchwidth = scrollwidth * 0.57
blotchheight = scrollwidth * 0.23
bimg = bui.imagewidget(
parent=container,
texture=builtinassets.textures.ui_atlas,
mesh_transparent=stdassets.meshes.window_bgblotch,
position=(
scrollleft + 60.0 - blotchwidth * 0.5,
scrollbottom + yoffs - yscale * blotchheight * 0.5,
),
size=(blotchwidth, yscale * blotchheight),
color=clr,
)
bui.widget(edit=bimg, depth_range=(0.9, 1.0))
bimg = bui.imagewidget(
parent=container,
texture=builtinassets.textures.ui_atlas,
mesh_transparent=stdassets.meshes.window_bgblotch,
position=(
scrollleft + scrollwidth - 60.0 - blotchwidth * 0.5,
scrollbottom + yoffs - yscale * blotchheight * 0.5,
),
size=(blotchwidth, yscale * blotchheight),
color=clr,
)
bui.widget(edit=bimg, depth_range=(0.9, 1.0))
if center:
bimg = bui.imagewidget(
parent=container,
texture=builtinassets.textures.ui_atlas,
mesh_transparent=stdassets.meshes.window_bgblotch,
position=(
scrollleft + scrollwidth * 0.5 - blotchwidth * 0.5,
scrollbottom + yoffs - yscale * blotchheight * 0.5,
),
size=(blotchwidth, yscale * blotchheight),
color=clr,
)
bui.widget(edit=bimg, depth_range=(0.9, 1.0))
# Docs-generation hack; import some stuff that we likely only forward-declared
# in our actual source code so that docs tools can find it.
from typing import (Coroutine, Any, Literal, Callable,
Generator, Awaitable, Sequence, Self)
import asyncio
from concurrent.futures import Future
from pathlib import Path
from enum import Enum