Route brush refresh view through app core
This commit is contained in:
@@ -385,6 +385,21 @@ struct PlanBrushOperationArgs {
|
||||
bool has_brush = true;
|
||||
};
|
||||
|
||||
struct PlanBrushRefreshArgs {
|
||||
bool update_color = true;
|
||||
bool update_brush = true;
|
||||
bool has_brush = true;
|
||||
bool floating_picker = false;
|
||||
bool floating_color = false;
|
||||
float tip_flow = 0.9F;
|
||||
float tip_size = 64.0F;
|
||||
float r = 0.25F;
|
||||
float g = 0.5F;
|
||||
float b = 0.75F;
|
||||
float a = 1.0F;
|
||||
bool bad_float = false;
|
||||
};
|
||||
|
||||
struct PlanBrushTextureListArgs {
|
||||
std::string kind = "add";
|
||||
std::string directory_name = "brushes";
|
||||
@@ -1967,6 +1982,7 @@ void print_help()
|
||||
<< " plan-animation-panel-view [--layer-count N] [--frame-count N] [--frame-duration N] [--total-duration N] [--current-layer N] [--current-frame N] [--selected-layer-id N] [--selected-frame N] [--onion-size N] [--hidden-layer N]\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-refresh [--color|--no-color] [--brush|--no-brush-update] [--no-brush] [--floating-picker] [--floating-color] [--tip-flow N] [--tip-size N] [--r N] [--g N] [--b N] [--a N] [--bad-float]\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"
|
||||
<< " plan-brush-stroke-control --kind float|bool|blend|tip-aspect-reset|default-reset [--setting NAME] [--value N] [--enabled|--disabled] [--blend-mode N]\n"
|
||||
@@ -5303,6 +5319,116 @@ int plan_brush_operation(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_brush_refresh_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
PlanBrushRefreshArgs& args)
|
||||
{
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
const std::string_view key(argv[i]);
|
||||
if (key == "--tip-flow" || key == "--tip-size" || key == "--r" || key == "--g" || key == "--b" || key == "--a") {
|
||||
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 == "--tip-flow") {
|
||||
args.tip_flow = value.value();
|
||||
} else if (key == "--tip-size") {
|
||||
args.tip_size = value.value();
|
||||
} else if (key == "--r") {
|
||||
args.r = value.value();
|
||||
} else if (key == "--g") {
|
||||
args.g = value.value();
|
||||
} else if (key == "--b") {
|
||||
args.b = value.value();
|
||||
} else {
|
||||
args.a = value.value();
|
||||
}
|
||||
} else if (key == "--color") {
|
||||
args.update_color = true;
|
||||
} else if (key == "--no-color") {
|
||||
args.update_color = false;
|
||||
} else if (key == "--brush") {
|
||||
args.update_brush = true;
|
||||
} else if (key == "--no-brush-update") {
|
||||
args.update_brush = false;
|
||||
} else if (key == "--no-brush") {
|
||||
args.has_brush = false;
|
||||
} else if (key == "--floating-picker") {
|
||||
args.floating_picker = true;
|
||||
} else if (key == "--floating-color") {
|
||||
args.floating_color = true;
|
||||
} else if (key == "--bad-float") {
|
||||
args.bad_float = true;
|
||||
} else {
|
||||
return pp::foundation::Status::invalid_argument("unknown option");
|
||||
}
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
int plan_brush_refresh(int argc, char** argv)
|
||||
{
|
||||
PlanBrushRefreshArgs args;
|
||||
const auto status = parse_plan_brush_refresh_args(argc, argv, args);
|
||||
if (!status.ok()) {
|
||||
print_error("plan-brush-refresh", status.message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto view = pp::app::plan_brush_ui_refresh(pp::app::BrushUiRefreshInput {
|
||||
.update_color = args.update_color,
|
||||
.update_brush = args.update_brush,
|
||||
.has_current_brush = args.has_brush,
|
||||
.has_floating_picker = args.floating_picker,
|
||||
.has_floating_color_panel = args.floating_color,
|
||||
.tip_flow = args.bad_float ? std::nanf("") : args.tip_flow,
|
||||
.tip_size = args.tip_size,
|
||||
.r = args.r,
|
||||
.g = args.g,
|
||||
.b = args.b,
|
||||
.a = args.a,
|
||||
});
|
||||
if (!view) {
|
||||
print_error("plan-brush-refresh", view.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto& value = view.value();
|
||||
std::cout << "{\"ok\":true,\"command\":\"plan-brush-refresh\""
|
||||
<< ",\"state\":{\"updateColor\":" << json_bool(args.update_color)
|
||||
<< ",\"updateBrush\":" << json_bool(args.update_brush)
|
||||
<< ",\"hasBrush\":" << json_bool(args.has_brush)
|
||||
<< ",\"floatingPicker\":" << json_bool(args.floating_picker)
|
||||
<< ",\"floatingColor\":" << json_bool(args.floating_color)
|
||||
<< ",\"tipFlow\":" << args.tip_flow
|
||||
<< ",\"tipSize\":" << args.tip_size
|
||||
<< ",\"r\":" << args.r
|
||||
<< ",\"g\":" << args.g
|
||||
<< ",\"b\":" << args.b
|
||||
<< ",\"a\":" << args.a
|
||||
<< "},\"view\":{\"updatesStrokeControls\":" << json_bool(value.updates_stroke_controls)
|
||||
<< ",\"updatesQuickFlow\":" << json_bool(value.updates_quick_flow)
|
||||
<< ",\"updatesQuickSize\":" << json_bool(value.updates_quick_size)
|
||||
<< ",\"updatesQuickBrushPreview\":" << json_bool(value.updates_quick_brush_preview)
|
||||
<< ",\"updatesQuickColor\":" << json_bool(value.updates_quick_color)
|
||||
<< ",\"updatesFloatingPicker\":" << json_bool(value.updates_floating_picker)
|
||||
<< ",\"updatesFloatingColorPanel\":" << json_bool(value.updates_floating_color_panel)
|
||||
<< ",\"noOp\":" << json_bool(value.no_op)
|
||||
<< ",\"tipFlow\":" << value.tip_flow
|
||||
<< ",\"tipSize\":" << value.tip_size
|
||||
<< ",\"r\":" << value.r
|
||||
<< ",\"g\":" << value.g
|
||||
<< ",\"b\":" << value.b
|
||||
<< ",\"a\":" << value.a
|
||||
<< "}}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_brush_texture_list_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
@@ -9487,6 +9613,10 @@ int main(int argc, char** argv)
|
||||
return plan_brush_operation(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-brush-refresh") {
|
||||
return plan_brush_refresh(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-brush-texture-list") {
|
||||
return plan_brush_texture_list(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user