Skip to content

Commit

Permalink
libcore|RuleRectangle: Added convenience method for defining mid X/Y …
Browse files Browse the repository at this point in the history
…rules
  • Loading branch information
skyjake committed Oct 29, 2014
1 parent caf12fe commit 66d5954
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doomsday/libcore/include/de/widgets/rulerectangle.h
Expand Up @@ -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.
*
Expand Down
14 changes: 14 additions & 0 deletions doomsday/libcore/src/widgets/rulerectangle.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 66d5954

Please sign in to comment.