Route animation timeline scrubbing through app core

This commit is contained in:
2026-06-05 00:28:06 +02:00
parent 59210c28ea
commit a9e12f2219
8 changed files with 194 additions and 5 deletions

View File

@@ -346,6 +346,12 @@ struct PlanAnimationPanelActionArgs {
bool playback_active = false;
};
struct PlanAnimationTimelineScrubArgs {
int total_duration = 1;
float cursor_x = 0.0F;
float frame_width = pp::app::document_animation_timeline_frame_width;
};
struct PlanBrushOperationArgs {
std::string kind = "settings";
std::string path;
@@ -1922,6 +1928,7 @@ void print_help()
<< " plan-layer-operation --kind add|duplicate|select|reorder|remove|opacity|visibility|alpha-lock|blend-mode|highlight [--layer-count N] [--index N] [--from-index N] [--to-index N] [--source-index N] [--name NAME] [--opacity N] [--blend-mode N] [--enabled]\n"
<< " plan-animation-operation --kind add|duplicate|remove|duration|move|select|goto|next|prev|playback|toggle-playback|onion [--frame-count N] [--total-duration N] [--current-frame N] [--selected-frame N] [--layer-index N] [--layer-id N] [--current-duration N] [--delta N] [--offset N] [--onion-size N] [--playing]\n"
<< " plan-animation-panel-action --action goto|next|prev|playback|toggle-playback [--total-duration N] [--current-frame N] [--target-frame N] [--playing]\n"
<< " plan-animation-timeline-scrub [--total-duration N] [--cursor-x N] [--frame-width N]\n"
<< " plan-brush-operation --kind color|tip|pattern|dual|preset|settings [--path FILE] [--thumb FILE] [--r N] [--g N] [--b N] [--a N] [--no-brush]\n"
<< " plan-brush-texture-list --kind add|remove|move [--dir NAME] [--data-path DIR] [--source FILE] [--item-count N] [--current-index N] [--offset N] [--user-texture]\n"
<< " plan-brush-preset-list --kind add|remove|move|up|down|select|clear [--item-count N] [--current-index N] [--offset N] [--no-current-brush]\n"
@@ -4827,6 +4834,74 @@ int plan_animation_panel_action(int argc, char** argv)
return 0;
}
pp::foundation::Status parse_plan_animation_timeline_scrub_args(
int argc,
char** argv,
PlanAnimationTimelineScrubArgs& args)
{
for (int i = 2; i < argc; ++i) {
const std::string_view key(argv[i]);
if (key == "--total-duration") {
if (i + 1 >= argc) {
return pp::foundation::Status::invalid_argument("missing value for option");
}
const auto value = parse_i32_arg(argv[++i]);
if (!value) {
return value.status();
}
args.total_duration = value.value();
} else if (key == "--cursor-x" || key == "--frame-width") {
if (i + 1 >= argc) {
return pp::foundation::Status::invalid_argument("missing value for option");
}
const auto value = parse_float_arg(argv[++i]);
if (!value) {
return value.status();
}
if (key == "--cursor-x") {
args.cursor_x = value.value();
} else {
args.frame_width = value.value();
}
} else {
return pp::foundation::Status::invalid_argument("unknown option");
}
}
return pp::foundation::Status::success();
}
int plan_animation_timeline_scrub(int argc, char** argv)
{
PlanAnimationTimelineScrubArgs args;
const auto status = parse_plan_animation_timeline_scrub_args(argc, argv, args);
if (!status.ok()) {
print_error("plan-animation-timeline-scrub", status.message);
return 2;
}
const auto plan = pp::app::plan_animation_timeline_scrub(
args.total_duration,
args.cursor_x,
args.frame_width);
if (!plan) {
print_error("plan-animation-timeline-scrub", plan.status().message);
return 2;
}
const auto& value = plan.value();
std::cout << "{\"ok\":true,\"command\":\"plan-animation-timeline-scrub\""
<< ",\"state\":{\"totalDuration\":" << args.total_duration
<< ",\"cursorX\":" << args.cursor_x
<< ",\"frameWidth\":" << args.frame_width
<< "},\"plan\":{\"totalDuration\":" << value.total_duration
<< ",\"cursorX\":" << value.cursor_x
<< ",\"frameWidth\":" << value.frame_width
<< ",\"targetFrame\":" << value.target_frame
<< "}}\n";
return 0;
}
pp::foundation::Status parse_plan_brush_operation_args(
int argc,
char** argv,
@@ -8970,6 +9045,10 @@ int main(int argc, char** argv)
return plan_animation_panel_action(argc, argv);
}
if (command == "plan-animation-timeline-scrub") {
return plan_animation_timeline_scrub(argc, argv);
}
if (command == "plan-brush-operation") {
return plan_brush_operation(argc, argv);
}