Let a chain stage be switched off without taking it apart

Trying a stage out meant removing it and building it again from scratch,
settings and all, to see what the picture looked like without it. A stage now
carries an `enabled` flag and can simply be switched off: it keeps its place
in the chain and everything it was set to.

`enabledStages` is the one place that reads the flag, and renderChain,
chainNeedsSources, chainTitle and chainSlug all go through it. A disabled
stage is skipped whole — handed no image and drawing nothing from the shared
rng — so switching one off renders byte for byte what the chain rendered
before that stage was added, which is the only thing that makes the switch
worth anything while comparing. Whichever stage runs first is the one handed
the sources, so disabling a leading scanlines lets blur lead and the chain
needs no images at all. The status line and the generated file name follow
too: they name what was rendered, not what sits in the sidebar. A chain with
every stage disabled throws rather than quietly rendering nothing.

In the interface it is a check on the chain row: the row dims, the params
heading says "(off)" and the settings stay editable — a stage being worked on
is not the same as one being deleted. On the command line it is
`--disable NAME`, which picks its stage by effect name exactly as the params
do. A project writes `"enabled": false` only for a stage that is off, so
existing project files are unchanged and an ordinary one stays uncluttered.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Si
2026-09-19 21:11:17 +02:00
co-authored by Claude Opus 5
parent f61161aef0
commit eb417bb41a
9 changed files with 185 additions and 28 deletions
+8
View File
@@ -1,5 +1,6 @@
#include "cli/options.hpp"
#include <algorithm>
#include <charconv>
#include <cstdint>
#include <cstring>
@@ -89,6 +90,10 @@ Options parseOptions(int argc, char** argv) {
std::to_string(kMinDpi) + "-" + std::to_string(kMaxDpi));
}
options.dpi = static_cast<int>(dpi);
} else if (arg == "--disable") {
const std::string name = requireValue(argc, argv, i, arg);
effectByName(name); // validate now, exactly as -e does
options.disabled.push_back(name);
} else if (arg == "--seed") {
const std::string value = requireValue(argc, argv, i, arg);
long seed = 0;
@@ -176,6 +181,7 @@ std::string usage(const char* programName) {
<< " --format NAME canvas format, overrides --size (see below)\n"
<< " --dpi N resolution of a print format, " << kMinDpi << "-" << kMaxDpi
<< " (default: " << kDefaultDpi << ")\n"
<< " --disable NAME keep this effect in the chain but skip it\n"
<< " --seed N random seed (default: random)\n"
<< " --list-effects list available effects and exit\n"
<< " -h, --help show this help and exit\n";
@@ -207,6 +213,8 @@ std::vector<ChainStage> buildChain(const Options& options) {
ChainStage stage;
stage.effect = effectByName(name);
stage.values = stage.effect->defaults();
stage.enabled = std::find(options.disabled.begin(), options.disabled.end(), name) ==
options.disabled.end();
for (const auto& spec : stage.effect->params()) {
const auto it = options.params.find(spec.key);
if (it != options.params.end()) stage.values[spec.key] = it->second;
+6 -1
View File
@@ -14,6 +14,10 @@ namespace effector {
struct Options {
std::vector<std::string> images;
std::vector<std::string> effects; // one per cascade stage, in order
// The effects named by --disable: their stages stay in the chain, in
// place, but are skipped. Named rather than numbered, exactly as the
// params are, so two stages of one effect are disabled together.
std::vector<std::string> disabled;
std::string output; // empty -> launch the interface
int width = 1920;
int height = 1080;
@@ -33,7 +37,8 @@ std::string usage(const char* programName);
// Turns the parsed names and flags into cascade stages: every flag goes to the
// stage whose effect declares it, so --strip-height and --radius can be given
// together for `-e scanlines -e blur`.
// together for `-e scanlines -e blur`. A stage named by --disable is built
// with all its settings and marked to be skipped.
std::vector<ChainStage> buildChain(const Options& options);
} // namespace effector