Skip to content

Commit

Permalink
Refactor|libdeng2|RuleRectangle: No need to have a public Clock observer
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 9, 2013
1 parent bb2f008 commit 623a184
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
5 changes: 1 addition & 4 deletions doomsday/libdeng2/include/de/widgets/rulerectangle.h
Expand Up @@ -39,7 +39,7 @@ namespace de {
*
* @ingroup widgets
*/
class DENG2_PUBLIC RuleRectangle : DENG2_OBSERVES(Clock, TimeChange)
class DENG2_PUBLIC RuleRectangle
{
public:
RuleRectangle();
Expand Down Expand Up @@ -100,9 +100,6 @@ class DENG2_PUBLIC RuleRectangle : DENG2_OBSERVES(Clock, TimeChange)
*/
Rectanglei recti() const;

protected:
void timeChanged(Clock const &);

private:
DENG2_PRIVATE(d)
};
Expand Down
26 changes: 14 additions & 12 deletions doomsday/libdeng2/src/widgets/rulerectangle.cpp
Expand Up @@ -24,7 +24,9 @@

namespace de {

DENG2_PIMPL_NOREF(RuleRectangle), public DelegateRule::ISource
DENG2_PIMPL_NOREF(RuleRectangle),
DENG2_OBSERVES(Clock, TimeChange),
public DelegateRule::ISource
{
// Internal identifiers for the output rules.
enum OutputIds
Expand Down Expand Up @@ -316,6 +318,16 @@ DENG2_PIMPL_NOREF(RuleRectangle), public DelegateRule::ISource
break;
}
}

void timeChanged(Clock const &clock)
{
invalidateOutputs();

if(normalizedAnchorPoint.done())
{
clock.audienceForTimeChange -= this;
}
}
};

RuleRectangle::RuleRectangle() : d(new Instance)
Expand Down Expand Up @@ -405,17 +417,7 @@ void RuleRectangle::setAnchorPoint(Vector2f const &normalizedPoint, TimeDelta co
if(transition > 0.0)
{
// Animation started, keep an eye on the clock until it ends.
Clock::appClock().audienceForTimeChange += this;
}
}

void RuleRectangle::timeChanged(Clock const &clock)
{
d->invalidateOutputs();

if(d->normalizedAnchorPoint.done())
{
clock.audienceForTimeChange -= this;
Clock::appClock().audienceForTimeChange += d;
}
}

Expand Down

0 comments on commit 623a184

Please sign in to comment.