summaryrefslogtreecommitdiffstats
path: root/src/layouts/qquickgridlayoutengine.cpp
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2013-04-30 14:14:11 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-03 14:21:22 +0200
commit038a27e88bd75c7e01157455fd97b680cfaf5d58 (patch)
tree3acfdb14498706487709949a3f3a707646ad89dd /src/layouts/qquickgridlayoutengine.cpp
parenta0173a8b3b972ecf098515cda58b9c6d6f9486eb (diff)
Compile fix: Move the static functions to the correct file.
These static function are only used by effectiveSizeHints_helper. This broke because of commit 2b205db8514c0d64880edd77404b96460e5226bc Change-Id: I189a59195d2576f4212b28fff4596bd803f25f49 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/layouts/qquickgridlayoutengine.cpp')
-rw-r--r--src/layouts/qquickgridlayoutengine.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/layouts/qquickgridlayoutengine.cpp b/src/layouts/qquickgridlayoutengine.cpp
index 7dc6a3341..3906dfbb5 100644
--- a/src/layouts/qquickgridlayoutengine.cpp
+++ b/src/layouts/qquickgridlayoutengine.cpp
@@ -43,6 +43,60 @@
#include "qquickgridlayoutengine_p.h"
#include "qquicklayout_p.h"
+
+/*
+ The layout engine assumes:
+ 1. minimum <= preferred <= maximum
+ 2. descent is within minimum and maximum bounds (### verify)
+
+ This function helps to ensure that by the following rules (in the following order):
+ 1. If minimum > maximum, set minimum = maximum
+ 2. Make sure preferred is not outside the [minimum,maximum] range.
+ 3. If descent > minimum, set descent = minimum (### verify if this is correct, it might
+ need some refinements to multiline texts)
+
+ If any values are "not set" (i.e. negative), they will be left untouched, so that we
+ know which values needs to be fetched from the implicit hints (not user hints).
+ */
+static void normalizeHints(qreal &minimum, qreal &preferred, qreal &maximum, qreal &descent)
+{
+ if (minimum >= 0 && maximum >= 0 && minimum > maximum)
+ minimum = maximum;
+
+ if (preferred >= 0) {
+ if (minimum >= 0 && preferred < minimum) {
+ preferred = minimum;
+ } else if (maximum >= 0 && preferred > maximum) {
+ preferred = maximum;
+ }
+ }
+
+ if (minimum >= 0 && descent > minimum)
+ descent = minimum;
+}
+
+static void boundSize(QSizeF &result, const QSizeF &size)
+{
+ if (size.width() >= 0 && size.width() < result.width())
+ result.setWidth(size.width());
+ if (size.height() >= 0 && size.height() < result.height())
+ result.setHeight(size.height());
+}
+
+static void expandSize(QSizeF &result, const QSizeF &size)
+{
+ if (size.width() >= 0 && size.width() > result.width())
+ result.setWidth(size.width());
+ if (size.height() >= 0 && size.height() > result.height())
+ result.setHeight(size.height());
+}
+
+static inline void combineHints(qreal &current, qreal fallbackHint)
+{
+ if (current < 0)
+ current = fallbackHint;
+}
+
/*!
\internal
Note: Can potentially return the attached QQuickLayoutAttached object through \a attachedInfo.