[haiku-development] Re: BBox and layout

  • From: Alex Wilson <yourpalal2@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 7 May 2012 18:01:18 -0600

On Sun, May 6, 2012 at 5:27 PM, Clemens <clemens.zeidler@xxxxxxxxxxxxxx>wrote:

> 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?


BView::_InvalidateParentLayout() resides in BView mainly because it needs
access to BView stuff, and is useful even in the absence of a BLayout. That
said, it's just a convenient way to find the nearest layout and invalidate
it, regardless of where the invalidation is coming from, so it's right that
it doesn't check for invalidation being disabled.

BLayout maybe could share invalidation disabled flags with the BView, when
it is attached to one, I can't remember any specific reason why it doesn't.


> 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.
>

I don't think there's any need for any new methods. In the scenario of
using a default custom BBox layout, if a user wants full manual control
over everything in the BBox, they just use SetLayout(), if they want to
embed a layout into the BBox content area, they add it with AddChild().
This would also have the benefit of being backwards compatible with current
behaviour, meaning there's no need to rework all the layout'd BBoxes in the
repo.

--Alex

Other related posts: