🖼️ cursor's default size in 'build.py'

This commit is contained in:
ful1e5 2021-02-05 19:19:45 +05:30
parent c776ae7aef
commit 05ce070192
3 changed files with 31 additions and 46 deletions

View file

@ -2,19 +2,18 @@
# -*- coding: utf-8 -*-
from pathlib import Path
from typing import Any, Dict, List, Tuple, Union
from typing import Any, Dict, List, Tuple, TypeVar, Union
from clickgen.util import LikePath, PNGProvider
from applbuild.constants import (
WIN_CANVAS_SIZE,
WIN_CURSORS_CFG,
WIN_DELAY,
WIN_SIZE,
X_CURSORS_CFG,
X_DELAY,
X_SIZES,
)
from applbuild.constants import WIN_CURSORS_CFG, WIN_DELAY, X_CURSORS_CFG, X_DELAY
X = TypeVar("X")
def to_tuple(x: X) -> Tuple[X, X]:
return (x, x)
def get_config(bitmaps_dir: LikePath, **kwargs) -> Dict[str, Any]:
@ -27,11 +26,11 @@ def get_config(bitmaps_dir: LikePath, **kwargs) -> Dict[str, Any]:
Keywords Args:
:x_sizes: (List[Size] | Size) List of sizes or single size for xcursors.
:x_sizes: (List[int]) List of pixel-sizes for xcursors.
:win_canvas_size: (Size) Windows cursor's canvas size.
:win_canvas_size: (int) Windows cursor's canvas pixel-size.
:win_size: (Size) Size for Windows cursor.
:win_size: (int) Pixel-size for Windows cursor.
Example:
@ -41,15 +40,13 @@ def get_config(bitmaps_dir: LikePath, **kwargs) -> Dict[str, Any]:
```
"""
if kwargs.get("x_sizes"):
x_sizes = kwargs.pop("x_sizes")
else:
x_sizes = X_SIZES
w_size = to_tuple(kwargs.pop("win_size"))
w_canvas_size = to_tuple(kwargs.pop("win_canvas_size"))
x = kwargs.pop("x_sizes")
if kwargs.get("win_size"):
w_size = kwargs.pop("win_size")
else:
w_size = WIN_SIZE
x_sizes = []
for s in x:
x_sizes.append(to_tuple(s))
png = PNGProvider(bitmaps_dir)
config: Dict[str, Any] = {}
@ -77,7 +74,7 @@ def get_config(bitmaps_dir: LikePath, **kwargs) -> Dict[str, Any]:
position = win_data.get("position", "center")
win_delay: int = win_data.get("delay", WIN_DELAY)
canvas_size: Tuple[int, int] = win_data.get("canvas_size", WIN_CANVAS_SIZE)
canvas_size: Tuple[int, int] = win_data.get("canvas_size", w_canvas_size)
win_size: Tuple[int, int] = win_data.get("size", w_size)
# Because provided cursor size is bigger than cursor's canvas.

View file

@ -11,26 +11,10 @@ URL = "https://github.com/ful1e5/apple_cursor"
# XCursor
X_DELAY: int = 10
X_SIZES: List[Tuple[int, int]] = [
(22, 22),
(24, 24),
(28, 28),
(32, 32),
(40, 40),
(48, 48),
(56, 56),
(64, 64),
(72, 72),
(80, 80),
(88, 88),
(96, 96),
]
# Windows Cursor
WIN_DELAY = 1
WIN_CANVAS_SIZE = (32, 32)
WIN_SIZE = (24, 24)
X_CURSORS_CFG: Dict[str, Dict[str, int]] = {
##########
@ -108,5 +92,5 @@ WIN_CURSORS_CFG: Dict[str, Dict[str, str]] = {
############
# Note: Animated cursors don't need frame numbers.
"left_ptr_watch": {"to": "Work", "position": "top_left"},
"wait": {"to": "Busy", "size": WIN_CANVAS_SIZE},
"wait": {"to": "Busy"},
}

View file

@ -3,8 +3,8 @@
import argparse
from pathlib import Path
from applbuild.configure import get_config
from applbuild.configure import get_config
from applbuild.generator import build, wbuild, xbuild
parser = argparse.ArgumentParser(
@ -49,7 +49,7 @@ parser.add_argument(
"-xs",
"--xsizes",
dest="xsizes",
metavar="SIZE",
metavar="INT",
nargs="+",
default=[
22,
@ -74,7 +74,7 @@ parser.add_argument(
"-ws",
"--win-size",
dest="win_size",
metavar="SIZE",
metavar="INT",
default=24,
type=int,
help="Set pixel-size for Windows cursors. (default: %(default)s)",
@ -84,8 +84,8 @@ parser.add_argument(
parser.add_argument(
"-wcs",
"--win-canvas-size",
dest="win_sizes",
metavar="SIZE",
dest="win_canvas_size",
metavar="INT",
default=32,
type=int,
help="Set pixel-size for Windows cursor's canvas. (default: %(default)s)",
@ -99,8 +99,12 @@ bitmaps_dir = Path(args.png_dir)
x_out_dir = Path(args.out_dir) / "macOSBigSur"
win_out_dir = Path(args.out_dir) / "macOSBigSur_Windows"
config = get_config(bitmaps_dir)
config = get_config(
bitmaps_dir,
x_sizes=args.xsizes,
win_canvas_size=args.win_canvas_size,
win_size=args.win_size,
)
if args.platform == "unix":
xbuild(config, x_out_dir)