summaryrefslogtreecommitdiffstats
path: root/src/gui/util/qgridlayoutengine_p.h
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@theqtcompany.com>2014-11-25 12:15:37 +0100
committerJan Arve Sæther <jan-arve.saether@theqtcompany.com>2015-02-09 12:06:34 +0000
commit68293395ed6c513703a206389734201d3202c30c (patch)
tree3dfcc1f6d5d4b702b905579344f48a3d58dba32a /src/gui/util/qgridlayoutengine_p.h
parent18aae36a90c0753f1b1e615ba8437d8ebd1bd2fb (diff)
Add support for snapping to pixel grid
This enables us to do more intelligent distribution than simply doing the rounding on each individual items geometry (which often leads to larger spacings than specified). Instead of doing the rounding on the output geometries, we now do the snapping inside the layout engine. This allows us to do more intelligent distribution of items, and spacings should always be respected. There are some cases where items with fractional size hints might overlap with less than a pixel. This was also the case before this patch. Those cases are impossible to fix properly, since fractional size hints conflicts with the snapping in some cases. (Fractional size hints is normal for Text items.) Task-number: QTBUG-41216 Change-Id: I01a8bc3529f0b8b028d6eb0a530c751b67ac6f4e Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src/gui/util/qgridlayoutengine_p.h')
-rw-r--r--src/gui/util/qgridlayoutengine_p.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h
index b75312bfe8..1abeefe56a 100644
--- a/src/gui/util/qgridlayoutengine_p.h
+++ b/src/gui/util/qgridlayoutengine_p.h
@@ -226,10 +226,10 @@ class QGridLayoutRowData
{
public:
void reset(int count);
- void distributeMultiCells(const QGridLayoutRowInfo &rowInfo);
+ void distributeMultiCells(const QGridLayoutRowInfo &rowInfo, bool snapToPixelGrid);
void calculateGeometries(int start, int end, qreal targetSize, qreal *positions, qreal *sizes,
qreal *descents, const QGridLayoutBox &totalBox,
- const QGridLayoutRowInfo &rowInfo);
+ const QGridLayoutRowInfo &rowInfo, bool snapToPixelGrid);
QGridLayoutBox totalBox(int start, int end) const;
void stealBox(int start, int end, int which, qreal *positions, qreal *sizes);
@@ -331,7 +331,7 @@ private:
class Q_GUI_EXPORT QGridLayoutEngine
{
public:
- QGridLayoutEngine(Qt::Alignment defaultAlignment = Qt::Alignment(0));
+ QGridLayoutEngine(Qt::Alignment defaultAlignment = Qt::Alignment(0), bool snapToPixelGrid = false);
inline ~QGridLayoutEngine() { qDeleteAll(q_items); }
int rowCount(Qt::Orientation orientation) const;
@@ -436,7 +436,10 @@ private:
QLayoutParameter<qreal> q_defaultSpacings[NOrientations];
QGridLayoutRowInfo q_infos[NOrientations];
Qt::LayoutDirection m_visualDirection;
+
+ // Configuration
Qt::Alignment m_defaultAlignment;
+ unsigned m_snapToPixelGrid : 1;
// Lazily computed from the above user input
mutable int q_cachedEffectiveFirstRows[NOrientations];