Qt Declarative (Quick 2)
Go to file
Mitch Curtis 2556bfdab4 Positioners: allow distinguishing between implicit/explicit child size
In Qt Quick Controls 2, we plan on using positioners to layout an icon
next to text in a button, for example.

Consider the following example:

    AbstractButton {
       id: button
       text: "Button"
       contentItem: Row {
           Text {
               text: button.text
               width: parent.width
           }
       }
       background: Rectangle {
           radius: 5
           color: "lightsteelblue"
           opacity: button.pressed ? 1.0 : 0.8
       }
    }

In Qt Quick Controls 2, implicit size propagates "up" from the
delegates/building blocks to the control, whereas explicit size
propagates "down" from the control to the delegates/building blocks.
Providing a reasonable implicit size is important to make controls
behave well in layouts, etc., and the internal building blocks must
follow the size of the control to retain sensible looks when a control
is resized.

In the example above, contentItem needs to have a "natural" (implicit)
size representing the ideal fit of the content, but it needs to respect
the explicitly provided size from the control too.

With the current behavior, as the explicit width of the Row is 0, the
Text item (via the width binding) sets explicit width to 0, and Row
uses that explicit width rather than the implicit width, thus, Row here
will have an implicit width of 0, which is not what the control wants.

This patch:

- Allows subclasses of positioners to set
  QQuickBasePositionerPrivate::useImplicitSize to true in order to tell
  positioners to use implicit size rather than explicit size. This is
  not exposed as public API, as this behavior is typically not
  something desirable in the positioners themselves. For example,
  Row { Rectangle { width: 100; height: 100 } } would have an implicit
  size of 0, as Rectangle has no implicit size.
- Adds QQuickImplicitRow and QQuickImplicitGrid, which are private
  subclasses of their respective positioners that simply set
  useImplicitSize to true in their constructors.
- Exports the wrappers privately so that they can be registered by
  other modules as QML types.

Change-Id: Ie68aabd7fbf6c76375badf6e338f2f238f3fc392
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
2017-02-23 13:45:52 +00:00
config.tests/d3d12
dist Add changes file for 5.8.0 2016-12-09 12:14:10 +00:00
examples Merge remote-tracking branch 'origin/5.8' into dev 2017-01-30 12:56:18 +01:00
features
src Positioners: allow distinguishing between implicit/explicit child size 2017-02-23 13:45:52 +00:00
tests Positioners: allow distinguishing between implicit/explicit child size 2017-02-23 13:45:52 +00:00
tools Merge remote-tracking branch 'origin/5.9' into dev 2017-02-14 08:21:39 +01:00
.gitattributes
.gitignore Merge remote-tracking branch 'origin/5.7' into dev 2016-08-19 21:22:10 +02:00
.gitmodules
.qmake.conf Bump version 2017-02-02 15:30:41 +01:00
.tag
LGPL_EXCEPTION.txt
LICENSE.FDL
LICENSE.GPL2
LICENSE.GPL3
LICENSE.GPL3-EXCEPT
LICENSE.GPLv3
LICENSE.LGPL3
LICENSE.LGPLv3
LICENSE.LGPLv21
configure.json Convert qtdeclarative over to use the new configure system 2016-10-10 14:11:39 +00:00
qtdeclarative.pro Convert qtdeclarative over to use the new configure system 2016-10-10 14:11:39 +00:00
sync.profile Merge remote-tracking branch 'origin/5.6' into 5.7 2016-11-15 10:57:49 +01:00