Skip to content

Commit

Permalink
Widgets|libcore: Added a rule pair utility
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 18, 2018
1 parent bfad5c6 commit 8171ba4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion doomsday/sdk/libcore/include/de/core/vector.h
Expand Up @@ -157,7 +157,13 @@ class Vector2
Vector2 operator - () const {
return Vector2(-x, -y);
}
Vector2 operator * (ddouble scalar) const {
Vector2 operator * (int scalar) const {
return Vector2(Type(x * scalar), Type(y * scalar));
}
Vector2 operator * (float scalar) const {
return Vector2(Type(x * scalar), Type(y * scalar));
}
Vector2 operator * (double scalar) const {
return Vector2(Type(x * scalar), Type(y * scalar));
}
Vector2 operator * (Vector2 const &other) const {
Expand Down
21 changes: 21 additions & 0 deletions doomsday/sdk/libcore/include/de/widgets/isizerule.h
Expand Up @@ -36,6 +36,27 @@ class DENG2_PUBLIC ISizeRule
virtual Rule const &height() const = 0;
};

/**
* Pair of rules that implements the ISizeRule interface.
* @ingroup widgets
*/
struct DENG2_PUBLIC RulePair
: public std::pair<const Rule &, const Rule &>
, public ISizeRule {
RulePair(const Rule &a, const Rule &b)
: std::pair<const Rule &, const Rule &>(a, b)
{}
// Implements ISizeRule.
const Rule &width() const override
{
return first;
}
const Rule &height() const override
{
return second;
}
};

} // namespace de

#endif // LIBDENG2_ISIZERULE_H

0 comments on commit 8171ba4

Please sign in to comment.