Add compound Color and Vector animation targets (pos, fill_color), closes #218

UIFrame, UICaption, and UISprite now accept "pos" as an alias for "position"
in the animation property system. UICaption and UISprite gain Vector2f
setProperty/getProperty overrides enabling animate("pos", (x, y), duration).
Color compound animation (fill_color, outline_color) was already supported.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-04-10 02:05:55 -04:00
commit 061b29a07a
6 changed files with 144 additions and 6 deletions

View file

@ -803,6 +803,32 @@ bool UICaption::getProperty(const std::string& name, float& value) const {
return false;
}
bool UICaption::setProperty(const std::string& name, const sf::Vector2f& value) {
if (name == "position" || name == "pos") {
position = value;
text.setPosition(position);
markDirty();
return true;
} else if (name == "origin") {
origin = value;
text.setOrigin(origin);
markDirty();
return true;
}
return false;
}
bool UICaption::getProperty(const std::string& name, sf::Vector2f& value) const {
if (name == "position" || name == "pos") {
value = position;
return true;
} else if (name == "origin") {
value = origin;
return true;
}
return false;
}
bool UICaption::getProperty(const std::string& name, sf::Color& value) const {
if (name == "fill_color") {
value = text.getFillColor();
@ -843,7 +869,7 @@ bool UICaption::hasProperty(const std::string& name) const {
return true;
}
// Vector2f properties
if (name == "origin") {
if (name == "origin" || name == "position" || name == "pos") {
return true;
}
// #106: Check for shader uniform properties

View file

@ -22,10 +22,12 @@ public:
// Property system for animations
bool setProperty(const std::string& name, float value) override;
bool setProperty(const std::string& name, const sf::Color& value) override;
bool setProperty(const std::string& name, const sf::Vector2f& value) override;
bool setProperty(const std::string& name, const std::string& value) override;
bool getProperty(const std::string& name, float& value) const override;
bool getProperty(const std::string& name, sf::Color& value) const override;
bool getProperty(const std::string& name, sf::Vector2f& value) const override;
bool getProperty(const std::string& name, std::string& value) const override;
bool hasProperty(const std::string& name) const override;

View file

@ -924,7 +924,7 @@ bool UIFrame::setProperty(const std::string& name, const sf::Color& value) {
}
bool UIFrame::setProperty(const std::string& name, const sf::Vector2f& value) {
if (name == "position") {
if (name == "position" || name == "pos") {
position = value;
box.setPosition(position); // Keep box in sync
markDirty();
@ -1019,7 +1019,7 @@ bool UIFrame::getProperty(const std::string& name, sf::Color& value) const {
}
bool UIFrame::getProperty(const std::string& name, sf::Vector2f& value) const {
if (name == "position") {
if (name == "position" || name == "pos") {
value = position;
return true;
} else if (name == "size") {
@ -1048,7 +1048,7 @@ bool UIFrame::hasProperty(const std::string& name) const {
return true;
}
// Vector2f properties
if (name == "position" || name == "size" || name == "origin") {
if (name == "position" || name == "pos" || name == "size" || name == "origin") {
return true;
}
// #106: Check for shader uniform properties

View file

@ -756,6 +756,32 @@ bool UISprite::getProperty(const std::string& name, float& value) const {
return false;
}
bool UISprite::setProperty(const std::string& name, const sf::Vector2f& value) {
if (name == "position" || name == "pos") {
position = value;
sprite.setPosition(position);
markDirty();
return true;
} else if (name == "origin") {
origin = value;
sprite.setOrigin(origin);
markDirty();
return true;
}
return false;
}
bool UISprite::getProperty(const std::string& name, sf::Vector2f& value) const {
if (name == "position" || name == "pos") {
value = position;
return true;
} else if (name == "origin") {
value = origin;
return true;
}
return false;
}
bool UISprite::getProperty(const std::string& name, int& value) const {
if (name == "sprite_index") {
value = sprite_index;
@ -781,7 +807,7 @@ bool UISprite::hasProperty(const std::string& name) const {
return true;
}
// Vector2f properties
if (name == "origin") {
if (name == "origin" || name == "position" || name == "pos") {
return true;
}
// #106: Check for shader uniform properties

View file

@ -60,8 +60,10 @@ public:
// Property system for animations
bool setProperty(const std::string& name, float value) override;
bool setProperty(const std::string& name, int value) override;
bool setProperty(const std::string& name, const sf::Vector2f& value) override;
bool getProperty(const std::string& name, float& value) const override;
bool getProperty(const std::string& name, int& value) const override;
bool getProperty(const std::string& name, sf::Vector2f& value) const override;
bool hasProperty(const std::string& name) const override;