diff --git a/doomsday/libcore/include/de/widgets/rulerectangle.h b/doomsday/libcore/include/de/widgets/rulerectangle.h index fe4b683b79..3cea834b45 100644 --- a/doomsday/libcore/include/de/widgets/rulerectangle.h +++ b/doomsday/libcore/include/de/widgets/rulerectangle.h @@ -71,6 +71,16 @@ class DENG2_PUBLIC RuleRectangle RuleRectangle &setSize(Rule const &width, Rule const &height); + RuleRectangle &setMidAnchorX(Rule const &middle); + + /** + * Sets the AnchorY rule to @a middle and Y anchor point to 0.5. This is + * equivalent to first calling setInput() and then setAnchorPoint(). + * + * @param middle Rule for the Y anchor. + */ + RuleRectangle &setMidAnchorY(Rule const &middle); + /** * Sets the outputs of another rule rectangle as the inputs of this one. * diff --git a/doomsday/libcore/src/widgets/rulerectangle.cpp b/doomsday/libcore/src/widgets/rulerectangle.cpp index 844da92cff..39467b9ff8 100644 --- a/doomsday/libcore/src/widgets/rulerectangle.cpp +++ b/doomsday/libcore/src/widgets/rulerectangle.cpp @@ -310,6 +310,20 @@ RuleRectangle &RuleRectangle::setSize(Rule const &width, Rule const &height) return *this; } +RuleRectangle &RuleRectangle::setMidAnchorX(Rule const &middle) +{ + setInput(Rule::AnchorX, middle); + d->normalizedAnchorX->set(.5f); + return *this; +} + +RuleRectangle &RuleRectangle::setMidAnchorY(Rule const &middle) +{ + setInput(Rule::AnchorY, middle); + d->normalizedAnchorY->set(.5f); + return *this; +} + RuleRectangle &RuleRectangle::clearInput(Rule::Semantic inputRule) { d->clearInputRule(inputRule);