Skip to content

Commit

Permalink
Refactor|libdeng2|RuleRectangle: Reimplemented based on IndirectRule
Browse files Browse the repository at this point in the history
RuleRectangle now defines the output rules directly in terms of
inputs, however the outputs are indirect so that anyone depending on
them does not get distracted by the possible changing of inputs
later on.

This results in a substantially more elegant implementation for
RuleRectangle that no longer has to rely on crutches to operate
correctly: each output rule knows exactly how it depends on its
inputs, so rule invalidation can work normally.

Furthermore, the rectangle's anchor point animation can now be done
with scalar rules without need for any extra work.

The clunky DelegateRule was removed entirely.
  • Loading branch information
skyjake committed Aug 19, 2013
1 parent fc39979 commit d65a9ab
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 423 deletions.
1 change: 0 additions & 1 deletion doomsday/libdeng2/include/de/DelegateRule

This file was deleted.

88 changes: 0 additions & 88 deletions doomsday/libdeng2/include/de/widgets/delegaterule.h

This file was deleted.

2 changes: 2 additions & 0 deletions doomsday/libdeng2/include/de/widgets/indirectrule.h
Expand Up @@ -45,6 +45,8 @@ class IndirectRule : public Rule
*/
void setSource(Rule const &rule);

void unsetSource();

void update();

Rule const &source() const;
Expand Down
1 change: 0 additions & 1 deletion doomsday/libdeng2/include/de/widgets/rules.h
Expand Up @@ -19,7 +19,6 @@

#include "../Rule"
#include "../ConstantRule"
#include "../DelegateRule"
#include "../IndirectRule"
#include "../OperatorRule"
#include "../ScalarRule"
Expand Down
73 changes: 0 additions & 73 deletions doomsday/libdeng2/src/widgets/delegaterule.cpp

This file was deleted.

15 changes: 10 additions & 5 deletions doomsday/libdeng2/src/widgets/indirectrule.cpp
Expand Up @@ -25,22 +25,27 @@ IndirectRule::IndirectRule() : _source(0)

IndirectRule::~IndirectRule()
{
independentOf(_source);
unsetSource();
}

void IndirectRule::setSource(Rule const &rule)
{
if(_source)
{
independentOf(_source);
}
unsetSource();
dependsOn(_source = &rule);

invalidate();
}

void IndirectRule::unsetSource()
{
independentOf(_source);
_source = 0;
}

void IndirectRule::update()
{
DENG2_ASSERT(_source != 0);

setValue(_source? _source->value() : 0);
}

Expand Down

0 comments on commit d65a9ab

Please sign in to comment.