[Qt-qml] Advanced layout support

Adriano Rezende adriano.rezende at openbossa.org
Thu Oct 20 18:06:04 CEST 2011


On Thu, Oct 20, 2011 at 6:59 AM,  <jan-arve.saether at nokia.com> wrote:
> ext jens.bache-wiig at nokia.com wrote on 2011-10-19:
>> I don't neccessarily disagree, as having it built into the language
>> seems like the obvious solution. But I don't think it is _that_ clear
>> cut: - If we do not support those constraints it for anchors, but give
>> items properties like minimum/maximumWidth, it would just add to the
>> confusion. - Adding constraints could have a significant performance
>> penalty for low end hardware. Hopefully this would be negligible if you
>> don't make use of them. - Giving anchors hard constraints can impact how
>> easy it is to animate certain things. Making layouts explicit makes it
>> easier to determine when you are giving away control over positioning. -
>> Giving anchors constraints makes them unpredictable. Who wins when you
>> have conflicting min/max sizes? The largest item? Most likely by random?
>> Again, I somewhat like the distinction that anchors are somewhat more
>> rigid/harder and wins over layouts every time.
>
> As long as all anchors in QML are directional (it simply uses the property
> propagation system), it does not make sense to add min/max sizes. Think about how you can make an item stretch in Qt Quick anchor layout: Two independent propagation paths must meet one item (e.g. one stops on the left edge, the other stops on the right edge). This does not allow distribution of available space to different items. (it's rather all remaining space gets allocated to the item in "the middle")
> This would most likely mean that we'd need a different syntax (\see VisualFormatLanguage below) for anchors if we want to have proper distribution, and each anchor should not be directed.

Yes, it would not handle space distribution or item stretching
correctly, it's just a possible not-good-looking feature that could
raise from the 1st approach. For a more advanced anchor layout, maybe
the target is not QtQuick API but an independent layout component.
What do you think?

> Since Cocoa Autolayout is *very* similar to QGraphicsAnchorLayout, I have  wanted to try to make a similar "language" for QGAL. This could then be used in Qt Quick. Unfortunately I haven't had the time yet (sometimes I wish I could clone myself). It should be quite easy to implement, since it's a very simple language.

I think that would be a very nice feature. Would it make sense to
create an AnchorLayout component to provide that?

Br,
Adriano


More information about the Qt-qml mailing list