diff options
author | Sebastian Geerken <devnull@localhost> | 2016-01-01 14:54:31 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2016-01-01 14:54:31 +0100 |
commit | bf6aeb8e54aac0b5aec39de544ec41f3a59daddf (patch) | |
tree | c07ab632acc86a71bed08fe3d29b088a33277e2b /dw/tools.cc | |
parent | 21b11e2ef463d13f5ce1002a5ba2575c2cac3606 (diff) |
SRDOP: Consider references and positions in Widget::sizeRequest.
Diffstat (limited to 'dw/tools.cc')
-rw-r--r-- | dw/tools.cc | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/dw/tools.cc b/dw/tools.cc index a2d05367..60e5e029 100644 --- a/dw/tools.cc +++ b/dw/tools.cc @@ -1,14 +1,32 @@ -#include "tools.hh" +#include "core.hh" namespace dw { namespace core { +using namespace lout::misc; + SizeParams::SizeParams () { DBG_OBJ_CREATE ("dw::core::SizeParams"); init (); debugPrint (); } + +SizeParams::SizeParams (int numPos, Widget **references, int *x, int *y) +{ + DBG_OBJ_CREATE ("dw::core::SizeParams"); + init (); + fill (numPos, references, x, y); + debugPrint (); +} + +SizeParams::SizeParams (SizeParams &other) +{ + DBG_OBJ_CREATE ("dw::core::SizeParams"); + init (); + fill (other.numPos, other.references, other.x, other.y); + debugPrint (); +} SizeParams::~SizeParams () { @@ -127,7 +145,39 @@ bool SizeParams::findReference (Widget *reference, int *x, int *y) return found; } - +/** + * Compares two instances, but considers a change in the order of the reference + * widgets as equivalent. + */ +bool SizeParams::isEquivalent (SizeParams *other) +{ + DBG_OBJ_ENTER ("resize", 0, "isEquivalent", "%p", other); + bool result; + + if (numPos != other->numPos) + result = false; + else { + result = true; + + for (int i = 0; result && i < numPos; i++) { + bool otherFound = false; + for (int j = 0; !otherFound && j < numPos; j++) { + if (references[i] == other->references[j]) { + otherFound = true; + if (!(x[i] == other->x[j] && y[i] == other->y[j])) + result = false; + } + } + + if (!otherFound) + result = false; + } + } + + DBG_OBJ_LEAVE_VAL ("%s", boolToStr (result)); + return result; +} + } // namespace core } // namespace dw |