mirror of
https://github.com/ful1e5/apple_cursor.git
synced 2025-05-14 07:04:47 -04:00
⚡ Build UNIX & Windows cursor
This commit is contained in:
parent
37d0dfca4d
commit
1b4fdce0b5
6 changed files with 285 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
########## Custom
|
########## Custom
|
||||||
pngs
|
pngs
|
||||||
|
themes
|
||||||
|
|
||||||
########## Python
|
########## Python
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,56 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any, Dict, List, Tuple, Union
|
||||||
|
|
||||||
def gg() -> None:
|
from clickgen.util import LikePath, PNGProvider
|
||||||
print("sdsd")
|
|
||||||
|
from applbuild.constants import *
|
||||||
|
|
||||||
|
|
||||||
|
def get_config(bitmaps_dir: LikePath) -> Dict[str, Any]:
|
||||||
|
"""Return configuration of `macOSBigSur` pointers.
|
||||||
|
|
||||||
|
:bitmaps_dir: (str | Path) Path to .png file's directory.
|
||||||
|
"""
|
||||||
|
|
||||||
|
png = PNGProvider(bitmaps_dir)
|
||||||
|
config: Dict[str, Any] = {}
|
||||||
|
|
||||||
|
for key, item in X_CURSORS_CFG.items():
|
||||||
|
x_hot: int = item.get("x_hot", 0)
|
||||||
|
y_hot: int = item.get("y_hot", 0)
|
||||||
|
hotspot: Tuple[int, int] = (x_hot, y_hot)
|
||||||
|
|
||||||
|
delay: int = item.get("delay", X_DELAY)
|
||||||
|
p: Union[List[Path], Path] = png.get(key)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"png": p,
|
||||||
|
"hotspot": hotspot,
|
||||||
|
"delay": delay,
|
||||||
|
}
|
||||||
|
|
||||||
|
win_data = WIN_CURSORS_CFG.get(key)
|
||||||
|
|
||||||
|
if win_data:
|
||||||
|
win_key = win_data.get("to")
|
||||||
|
|
||||||
|
position = win_data.get("position", "center")
|
||||||
|
canvas_size: Tuple[int, int] = win_data.get("canvas_size", CANVAS_SIZE)
|
||||||
|
size: Tuple[int, int] = win_data.get("size", SIZE)
|
||||||
|
win_delay: int = win_data.get("delay", WIN_DELAY)
|
||||||
|
|
||||||
|
config[key] = {
|
||||||
|
**data,
|
||||||
|
"win_key": win_key,
|
||||||
|
"position": position,
|
||||||
|
"canvas_size": canvas_size,
|
||||||
|
"size": size,
|
||||||
|
"win_delay": win_delay,
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
config[key] = data
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
114
builder/applbuild/constants.py
Normal file
114
builder/applbuild/constants.py
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from typing import Dict, List, Tuple
|
||||||
|
|
||||||
|
# Info
|
||||||
|
THEME_NAME = "macOSBigSur"
|
||||||
|
COMMENT = "macOS Big Sur Pointers"
|
||||||
|
AUTHOR = "Kaiz Khatri"
|
||||||
|
URL = "https://github.com/ful1e5/apple_cursor"
|
||||||
|
|
||||||
|
# XCursor
|
||||||
|
X_DELAY: int = 10
|
||||||
|
X_SIZES: List[Tuple[int, int]] = [(24, 24), (32, 32)]
|
||||||
|
|
||||||
|
|
||||||
|
# Windows Cursor
|
||||||
|
CANVAS_SIZE = (32, 32)
|
||||||
|
SIZE = (24, 24)
|
||||||
|
WIN_DELAY = 3
|
||||||
|
|
||||||
|
X_CURSORS_CFG: Dict[str, Dict[str, int]] = {
|
||||||
|
#
|
||||||
|
# Static
|
||||||
|
#
|
||||||
|
"all_scroll.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"bottom_left_corner.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"fd_double_arrow.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"top_right_corner.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"bottom_right_corner.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"bd_double_arrow.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"top_left_corner.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"bottom_tee.png": {"xhot": 141, "yhot": 99},
|
||||||
|
"center_ptr.png": {"xhot": 61, "yhot": 100},
|
||||||
|
"circle.png": {"xhot": 47, "yhot": 39},
|
||||||
|
"crossed_circle.png": {"xhot": 47, "yhot": 39},
|
||||||
|
"dnd_no_drop.png": {"xhot": 47, "yhot": 39},
|
||||||
|
"context_menu.png": {"xhot": 61, "yhot": 58},
|
||||||
|
"copy.png": {"xhot": 47, "yhot": 39},
|
||||||
|
"dnd_copy.png": {"xhot": 47, "yhot": 39},
|
||||||
|
"cross.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"tcross.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"crosshair.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"dotbox.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"hand1.png": {"xhot": 94, "yhot": 105},
|
||||||
|
"hand2.png": {"xhot": 66, "yhot": 34},
|
||||||
|
"left_ptr.png": {"xhot": 68, "yhot": 41},
|
||||||
|
"left_side.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"right_side.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"left_tee.png": {"xhot": 100, "yhot": 58},
|
||||||
|
"link.png": {"xhot": 61, "yhot": 105},
|
||||||
|
"dnd_link.png": {"xhot": 61, "yhot": 105},
|
||||||
|
"ll_angle.png": {"xhot": 141, "yhot": 58},
|
||||||
|
"lr_angle.png": {"xhot": 141, "yhot": 138},
|
||||||
|
"move.png": {"xhot": 80, "yhot": 106},
|
||||||
|
"dnd_move.png": {"xhot": 80, "yhot": 106},
|
||||||
|
"dnd_none.png": {"xhot": 80, "yhot": 106},
|
||||||
|
"grabbing.png": {"xhot": 80, "yhot": 106},
|
||||||
|
"pointer_move.png": {"xhot": 80, "yhot": 106},
|
||||||
|
"pencil.png": {"xhot": 141, "yhot": 58},
|
||||||
|
"plus.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"question_arrow.png": {"xhot": 105, "yhot": 105},
|
||||||
|
"dnd_ask.png": {"xhot": 105, "yhot": 105},
|
||||||
|
"right_ptr.png": {"xhot": 61, "yhot": 138},
|
||||||
|
"right_tee.png": {"xhot": 100, "yhot": 138},
|
||||||
|
"sb_down_arrow.png": {"xhot": 133, "yhot": 99},
|
||||||
|
"sb_h_double_arrow.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"sb_left_arrow.png": {"xhot": 100, "yhot": 68},
|
||||||
|
"sb_right_arrow.png": {"xhot": 100, "yhot": 138},
|
||||||
|
"sb_up_arrow.png": {"xhot": 68, "yhot": 99},
|
||||||
|
"sb_v_double_arrow.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"top_side.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"bottom_side.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"top_tee.png": {"xhot": 61, "yhot": 99},
|
||||||
|
"ul_angle.png": {"xhot": 61, "yhot": 65},
|
||||||
|
"ur_angle.png": {"xhot": 61, "yhot": 138},
|
||||||
|
"vertical_text.png": {"xhot": 100, "yhot": 102},
|
||||||
|
"wayland_cursor.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"x_cursor.png": {"xhot": 100, "yhot": 100},
|
||||||
|
"xterm.png": {"xhot": 97, "yhot": 97},
|
||||||
|
"zoom_in.png": {"xhot": 76, "yhot": 78},
|
||||||
|
"zoom_out.png": {"xhot": 76, "yhot": 78},
|
||||||
|
#
|
||||||
|
# Animated
|
||||||
|
#
|
||||||
|
# Note: Animated cursors not need any extension & frames number
|
||||||
|
"wait": {"xhot": 104, "yhot": 105},
|
||||||
|
"left_ptr_watch": {"xhot": 104, "yhot": 105},
|
||||||
|
}
|
||||||
|
|
||||||
|
WIN_CURSORS_CFG: Dict[str, Dict[str, str]] = {
|
||||||
|
#
|
||||||
|
# Static
|
||||||
|
#
|
||||||
|
"right_ptr.png": {"to": "Alternate", "position": "top_left"},
|
||||||
|
"cross.png": {"to": "Cross"},
|
||||||
|
"left_ptr.png": {"to": "Default", "position": "top_left"},
|
||||||
|
"fd_double_arrow.png": {"to": "Diagonal_1"},
|
||||||
|
"bd_double_arrow.png": {"to": "Diagonal_2"},
|
||||||
|
"pencil.png": {"to": "Handwriting"},
|
||||||
|
"question_arrow.png": {"to": "Help", "position.png": "top_left"},
|
||||||
|
"sb_h_double_arrow.png": {"to": "Horizontal"},
|
||||||
|
"xterm.png": {"to": "IBeam", "position": "top_left"},
|
||||||
|
"hand2.png": {"to": "Link", "position": "top_left"},
|
||||||
|
"hand1.png": {"to": "Move"},
|
||||||
|
"circle.png": {"to": "Unavailiable", "position": "top_left"},
|
||||||
|
"sb_v_double_arrow.png": {"to": "Vertical"},
|
||||||
|
#
|
||||||
|
# Animated
|
||||||
|
#
|
||||||
|
# Note: Animated cursors not need any extension & frames number
|
||||||
|
"wait": {"to": "Busy", "size": (28, 28)},
|
||||||
|
"left_ptr_watch": {"to": "Work", "position": "top_left", "size": (28, 28)},
|
||||||
|
}
|
|
@ -1,6 +1,114 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
def build() -> None:
|
from clickgen.builders import WindowsCursor, XCursor
|
||||||
print("hdddddd")
|
from clickgen.core import CursorAlias
|
||||||
|
from clickgen.packagers import WindowsPackager, XPackager
|
||||||
|
from clickgen.util import LikePath, add_missing_xcursors
|
||||||
|
|
||||||
|
from applbuild.configure import get_config
|
||||||
|
from applbuild.constants import *
|
||||||
|
|
||||||
|
#
|
||||||
|
# 📝 Note: All CONSTANT variables are imported from `applbuild.constants` module.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
def xbuild(bitmaps_dir: LikePath, x_out_dir: Path) -> None:
|
||||||
|
"""Build `macOSBigSur` cursor theme for only `X11`(UNIX) platform.
|
||||||
|
|
||||||
|
:bitmaps_dir: (str | Path) Path to .png file's directory.
|
||||||
|
|
||||||
|
:x_out_dir: (Path) Path to output directory, Where X11 cursor theme package store. Created automatically if not exists.
|
||||||
|
"""
|
||||||
|
|
||||||
|
config = get_config(bitmaps_dir)
|
||||||
|
|
||||||
|
# Building
|
||||||
|
for _, item in config.items():
|
||||||
|
png = item["png"]
|
||||||
|
hotspot = item["hotspot"]
|
||||||
|
delay = item["delay"]
|
||||||
|
|
||||||
|
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
||||||
|
x_cfg = alias.create(X_SIZES, delay)
|
||||||
|
XCursor.create(x_cfg, x_out_dir)
|
||||||
|
|
||||||
|
add_missing_xcursors(x_out_dir / "cursors", rename=True, force=True)
|
||||||
|
XPackager(x_out_dir, THEME_NAME, COMMENT)
|
||||||
|
|
||||||
|
|
||||||
|
def wbuild(bitmaps_dir: LikePath, win_out_dir: Path) -> None:
|
||||||
|
"""Build `macOSBigSur` cursor theme for only `Windows` platforms.
|
||||||
|
|
||||||
|
:bitmaps_dir: (str | Path) Path to .png file's directory.
|
||||||
|
|
||||||
|
:win_out_dir: (Path) Path to output directory, Where Windows Cursor theme package store. Created automatically if not exists.
|
||||||
|
"""
|
||||||
|
|
||||||
|
config = get_config(bitmaps_dir)
|
||||||
|
|
||||||
|
# Building
|
||||||
|
for _, item in config.items():
|
||||||
|
png = item["png"]
|
||||||
|
hotspot = item["hotspot"]
|
||||||
|
delay = item["delay"]
|
||||||
|
|
||||||
|
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
||||||
|
alias = alias.create(X_SIZES, delay)
|
||||||
|
|
||||||
|
if item.get("win_key"):
|
||||||
|
position = item["position"]
|
||||||
|
size = item["size"]
|
||||||
|
win_key = item["win_key"]
|
||||||
|
canvas_size = item["canvas_size"]
|
||||||
|
|
||||||
|
win_cfg = alias.reproduce(size, canvas_size, position, delay=3).rename(
|
||||||
|
win_key
|
||||||
|
)
|
||||||
|
WindowsCursor.create(win_cfg, win_out_dir)
|
||||||
|
|
||||||
|
WindowsPackager(win_out_dir, THEME_NAME, COMMENT, AUTHOR, URL)
|
||||||
|
|
||||||
|
|
||||||
|
def build(bitmaps_dir: LikePath, x_out_dir: Path, win_out_dir: Path) -> None:
|
||||||
|
"""Build `macOSBigSur` cursor theme for `X11` & `Windows` platforms.
|
||||||
|
|
||||||
|
:bitmaps_dir: (str | Path) Path to .png file's directory.
|
||||||
|
|
||||||
|
:x_out_dir: (Path) Path to output directory, Where X11 cursor theme package store. Created automatically if not exists.
|
||||||
|
|
||||||
|
:win_out_dir: (Path) Path to output directory, Where Windows Cursor theme package store. Created automatically if not exists.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def win_build(item: Any, alias: CursorAlias) -> None:
|
||||||
|
position = item["position"]
|
||||||
|
size = item["size"]
|
||||||
|
win_key = item["win_key"]
|
||||||
|
canvas_size = item["canvas_size"]
|
||||||
|
|
||||||
|
win_cfg = alias.reproduce(size, canvas_size, position, delay=3).rename(win_key)
|
||||||
|
WindowsCursor.create(win_cfg, win_out_dir)
|
||||||
|
|
||||||
|
config = get_config(bitmaps_dir)
|
||||||
|
|
||||||
|
# Building
|
||||||
|
for _, item in config.items():
|
||||||
|
png = item["png"]
|
||||||
|
hotspot = item["hotspot"]
|
||||||
|
delay = item["delay"]
|
||||||
|
|
||||||
|
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
||||||
|
x_cfg = alias.create(X_SIZES, delay)
|
||||||
|
XCursor.create(x_cfg, x_out_dir)
|
||||||
|
|
||||||
|
if item.get("win_key"):
|
||||||
|
win_build(item, alias)
|
||||||
|
|
||||||
|
add_missing_xcursors(x_out_dir / "cursors", rename=True, force=True)
|
||||||
|
|
||||||
|
XPackager(x_out_dir, THEME_NAME, COMMENT)
|
||||||
|
WindowsPackager(win_out_dir, THEME_NAME, COMMENT, AUTHOR, URL)
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from applbuild.generator import build
|
from pathlib import Path
|
||||||
|
|
||||||
build()
|
from applbuild.generator import xbuild
|
||||||
|
|
||||||
|
bitmaps_dir = Path("../pngs")
|
||||||
|
x_out_dir = Path("../themes") / "macOSBigSur"
|
||||||
|
|
||||||
|
xbuild(bitmaps_dir, x_out_dir)
|
||||||
|
|
|
@ -5,7 +5,7 @@ from setuptools import setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="applbuild",
|
name="applbuild",
|
||||||
version="1.0.7",
|
version="1.0.8",
|
||||||
description="Generate 'macOSBigSur' cursor theme from PNGs file",
|
description="Generate 'macOSBigSur' cursor theme from PNGs file",
|
||||||
url="https://github.com/ful1e5/apple_cursor",
|
url="https://github.com/ful1e5/apple_cursor",
|
||||||
packages=["applbuild"],
|
packages=["applbuild"],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue