Skip to content

Commit

Permalink
libdeng2|RuleRectangle: Added midX/midY output rules
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 28, 2014
1 parent 0acbb96 commit 0a4a162
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doomsday/libdeng2/include/de/widgets/rulerectangle.h
Expand Up @@ -54,6 +54,8 @@ class DENG2_PUBLIC RuleRectangle
Rule const &bottom() const;
Rule const &width() const;
Rule const &height() const;
Rule const &midX() const;
Rule const &midY() const;

/**
* Sets one of the input rules of the rectangle.
Expand Down
17 changes: 17 additions & 0 deletions doomsday/libdeng2/src/widgets/rulerectangle.cpp
Expand Up @@ -47,6 +47,8 @@ DENG2_PIMPL(RuleRectangle)

// The output rules.
IndirectRule *outputRules[MAX_OUTPUT_RULES];
Rule *midX;
Rule *midY;

Instance(Public *i) : Base(i)
{
Expand All @@ -61,11 +63,16 @@ DENG2_PIMPL(RuleRectangle)
outputRules[i] = new IndirectRule;
}

midX = holdRef(*outputRules[OutLeft] + *outputRules[OutWidth] / 2);
midY = holdRef(*outputRules[OutTop] + *outputRules[OutHeight] / 2);

debugName = QString("0x%1").arg(dintptr(thisPublic), 0, 16);
}

~Instance()
{
releaseRef(midX);
releaseRef(midY);
releaseRef(normalizedAnchorX);
releaseRef(normalizedAnchorY);

Expand Down Expand Up @@ -241,6 +248,16 @@ Rule const &RuleRectangle::height() const
return *d->outputRules[Instance::OutHeight];
}

Rule const &RuleRectangle::midX() const
{
return *d->midX;
}

Rule const &RuleRectangle::midY() const
{
return *d->midY;
}

RuleRectangle &RuleRectangle::setInput(Rule::Semantic inputRule, Rule const &rule)
{
d->setInputRule(inputRule, rule);
Expand Down

0 comments on commit 0a4a162

Please sign in to comment.