feat: split rotation and flip icon build functions

This commit is contained in:
2026-09-07 20:52:24 +08:00
parent bb5032d502
commit a563917aa8
2 changed files with 42 additions and 31 deletions
@@ -124,6 +124,7 @@ def link_artifact(src: Path, dst: Path) -> None:
f'No common directory between "{src}" and "{dst}", ' f'No common directory between "{src}" and "{dst}", '
f"can not create relative symlink." f"can not create relative symlink."
) )
# SAFETY: the symlink target must always be stored with POSIX # SAFETY: the symlink target must always be stored with POSIX
# separators ("/"). On Windows, "relative_to" yields a # separators ("/"). On Windows, "relative_to" yields a
# backslash-separated path, and "symlink_to" stores the target string # backslash-separated path, and "symlink_to" stores the target string
@@ -21,24 +21,36 @@ def register(ctx: AuroraContext) -> None:
) )
ctx.register( ctx.register(
"std/action/object-flip-*", "std/action/object-flip-horizontal",
( (
SvgSource("object-flip-horizontal.svg"), SvgSource("object-flip-horizontal.svg"),
SvgSource("object-flip-vertical.svg"),
FdArtSink(FdContext.Actions, "object-flip-horizontal"), FdArtSink(FdContext.Actions, "object-flip-horizontal"),
FdArtSink(FdContext.Actions, "object-flip-vertical"),
), ),
build_object_flip_icons, build_object_flip_horizontal_icon,
) )
ctx.register( ctx.register(
"std/action/object-rotate-*", "std/action/object-flip-vertical",
(
SvgSource("object-flip-vertical.svg"),
FdArtSink(FdContext.Actions, "object-flip-vertical"),
),
build_object_flip_vertical_icon,
)
ctx.register(
"std/action/object-rotate-left",
( (
SvgSource("object-rotate-left.svg"), SvgSource("object-rotate-left.svg"),
SvgSource("object-rotate-right.svg"),
FdArtSink(FdContext.Actions, "object-rotate-left"), FdArtSink(FdContext.Actions, "object-rotate-left"),
),
build_object_rotate_left_icon,
)
ctx.register(
"std/action/object-rotate-right",
(
SvgSource("object-rotate-right.svg"),
FdArtSink(FdContext.Actions, "object-rotate-right"), FdArtSink(FdContext.Actions, "object-rotate-right"),
), ),
build_object_rotate_icons, build_object_rotate_right_icon,
) )
ctx.register( ctx.register(
@@ -92,34 +104,32 @@ def build_go_icons(
go_mask = go_mask.transpose(PIL.Image.Transpose.ROTATE_90) go_mask = go_mask.transpose(PIL.Image.Transpose.ROTATE_90)
def build_object_flip_icons( def build_object_flip_horizontal_icon(
env: AuroraEnvironment, env: AuroraEnvironment, src: SvgSource, sink: FdArtSink
horizontal_src: SvgSource,
vertical_src: SvgSource,
horizontal_sink: FdArtSink,
vertical_sink: FdArtSink,
) -> None: ) -> None:
art = horizontal_src.pull(env) with src.pull(env) as art:
with art: sink.push(env, art)
horizontal_sink.push(env, art)
art = vertical_src.pull(env)
with art:
vertical_sink.push(env, art)
def build_object_rotate_icons( def build_object_flip_vertical_icon(
env: AuroraEnvironment, env: AuroraEnvironment, src: SvgSource, sink: FdArtSink
left_src: SvgSource,
right_src: SvgSource,
left_sink: FdArtSink,
right_sink: FdArtSink,
) -> None: ) -> None:
art = left_src.pull(env) with src.pull(env) as art:
with art: sink.push(env, art)
left_sink.push(env, art)
art = right_src.pull(env)
with art: def build_object_rotate_left_icon(
right_sink.push(env, art) env: AuroraEnvironment, src: SvgSource, sink: FdArtSink
) -> None:
with src.pull(env) as art:
sink.push(env, art)
def build_object_rotate_right_icon(
env: AuroraEnvironment, src: SvgSource, sink: FdArtSink
) -> None:
with src.pull(env) as art:
sink.push(env, art)
def build_zoom_origin_and_fit_best_icons( def build_zoom_origin_and_fit_best_icons(