[haiku-development] Re: BBox and layout

  • From: Clemens <clemens.zeidler@xxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 07 May 2012 11:27:24 +1200

On Mon, 07 May 2012 09:03:16 +1200, Alex Wilson <yourpalal2@xxxxxxxxx> wrote:

The reason the label is laid out is because it is a child of the view, and
all children are part of the layout (or a nested layout). The removal of
the child for the layout is the way to circumvent this. The infinite loop
should be avoidable using the {Disable|Enable}LayoutInvalidation() methods.

cool thank! tried it but it did not work very well. I called the BView::{Disable|Enable}LayoutInvalidation() but when adding a item to the layout the BView::_InvalidateParentLayout() is called (from BLayout::AddItem) which does not check if the layout invalidation is disabled. Adding the check there helps though. However, additionally calling BLayout::{Disable|Enable}LayoutInvalidation() solves the problem. What is the cleanest solution? and why are there flags for layout invalidation in BView and BLayout shouldn't BView just use the one from BLayout?

2) When setting a layout to a BBox its a bit annoying to set the correct
layout inset so that the content is exactly within the inner BBox frame. It
would be nice to have some convenient function to set the inset to the
layout. Or even better: the layout of a BBox is moved automatically into
the inner frame so that it is not event possible to place a layout item
outside the inner frame. What do you think?

It is annoying indeed. One solution would be to add a BLayout subclass that does a BBox layout, including the label and a single nested item (possibly another BLayout). Otherwise, if you wanted to keep the current system, but let BBox manage the insets of the layout it is assigned that could be done
if SetInsets() were a part of BLayout(). Currently it's not, but it is
implemented by all layouts (assuming BCardLayout does), so it could be
alright to make it part of BLayout. If there were a layout at some point
that couldn't reasonably support insets, it would be ok if it just ignored
whatever insets the user set.

Think its not the best idea to set the inset of an layout form within the BBox. Maybe the user already set the inset, this inset would be overwritten and cause unexpected behaviour... Think your first solution would be better. The question is should there be a method SetInnerLayout or should SetLayout set the inner layout directly? My first guest was that SetLayout does the right thing for me and so I would vote for just SetLayout to make it intuitive. If someone really has to have a layout that spans the whole BBox frame one could add a method like SetLayoutInInnerFrame(bool inFrame = true) to enable or disable this behaviour.


Other related posts: