Label text stages in the chain list with their words

Effect::label(values) names a stage in a list, defaulting to the title;
the text effect answers "Text (words)", and the chain rows are renamed
in place as params change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Si
2026-09-23 21:37:26 +02:00
co-authored by Claude Opus 5.5
parent 134c575727
commit 5292c101db
6 changed files with 47 additions and 2 deletions
+16
View File
@@ -203,6 +203,22 @@ void TextEffect::loadBoxImage(const std::string& path, Image& image,
alpha = cachedAlpha_;
}
std::string TextEffect::label(const ParamValues& values) const {
// Several lines read as one: each run of whitespace becomes a single space.
std::string words;
bool gap = false;
for (const char c : paramText(values, "text", "")) {
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') {
gap = !words.empty();
continue;
}
if (gap) words += ' ';
gap = false;
words += c;
}
return words.empty() ? title() : title() + " (" + words + ")";
}
Image TextEffect::render(const std::vector<Image>& sources, int width, int height, Rng& rng,
const ParamValues& values) const {
if (width < 1 || height < 1) throw EffectError("Canvas size must be at least 1x1 pixels.");
+2
View File
@@ -30,6 +30,8 @@ public:
const std::vector<ParamSpec>& params() const override;
std::string styleKind() const override { return "text"; }
bool needsSources() const override { return false; }
// "Text (Hello world)", so stages writing different words tell apart.
std::string label(const ParamValues& values) const override;
Image render(const std::vector<Image>& sources, int width, int height, Rng& rng,
const ParamValues& values) const override;