[haiku-development] Re: BBox and layout

  • From: Clemens <clemens.zeidler@xxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 09 May 2012 15:45:35 +1200

On Wed, 09 May 2012 02:08:00 +1200, Alex Wilson <yourpalal2@xxxxxxxxx> wrote:

So you propose to
leave everything as it is or do I miss something? AddChild is even more
unusable than the current SetLayout, not only you have to calculate the
correct inset but also the frame size and add a dummy layout container

No, in layout mode, AddChild() would nicely layout the child you add
into the BBox in the right place, with the right insets. The custom
layout would just lay out 2 things, the label, and the child (BBox
only allows one child sort of). If you want multiple items in the
BBox, you would add a nested layout using
BBox::AddChild(BLayoutItem*). Because BLayout is also a BLayoutItem,
you no longer need the dummy layout containers.

thats definitely a solution but IMHO not a nice one. I just took a look at qt *) and they do it my way :-)

Using AddChild to add a layout if there is a SetLayout method does not follow the principle of least astonishment either. I think its only astonishing for someone who knows BLayout very well that SetLayout adds a layout that not spans the whole BView frame.

To go back to the discussion where Ingo wondered that the "adding to view adds to layout" automatism was not a wise decision. After giving it another thought I think it has the following advantages to remove that automatism:

- AddChild does not change its behaviour if there is a layout present -> there is no need for a B_EXCLUDE[_VIEW]_FROM_LAYOUT flag
- AddChild can be used for "overlay" stuff like the label view in BBox
- AddChild is just the raw base method for adding a view, no hidden intelligence here - view and layout are more decoupled, only the layout class can be used to add stuff into the layout -> more consistency - a view could be in multiple layouts (yes it is not a very common example (but also not totally beside the point) but it shows that it is possible without further effort)


*) Example in Detailed Description: http://qt-project.org/doc/qt-4.8/qgroupbox.html

Other related posts: