[haiku-development] Re: Possible layout bug

  • From: Alex Wilson <yourpalal2@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 21 Oct 2011 13:41:06 -0600

On Fri, Oct 21, 2011 at 6:19 AM, Stefano Ceccherini
<stefano.ceccherini@xxxxxxxxx> wrote:
> Hi,
> I might have encountered a possible layout bug, or maybe I'm just
> doing something wrong.
> I have a BWindow with a menubar and two views inside a horizontal splitview.
> To the left there is a BOutlineListView, and to the right a regular
> BView with a BStringView inside.
> The results are in the screenshot attached.
> Note that if I remove the BStringView from the equation, the problem goes 
> away.
> Attached is also the code, stripped down to the minimum.
> I'll file a ticket if it turns out a real bug.
> Thanks in advance.
>

I don't think this is a bug. I suspect the problem is this:
1) BStringView sets its min/max size to be just big enough to
accommodate the string it displays (IIRC)
2) BGroupLayout basically echoes the stringview's min/max constraints
to its parent layout.
3) Removing BStringView means the BGroupLayout is empty, and can
stretch out to any size. (Which is why this fixes your problem.)

Anyway, I made a little diff for you with a fix to this, and some
other changes I thought you might find helpful. Mainly, you aren't
required to call the End() method of BLayoutBuilder, it exists only to
let you get out of your nested layouts, also, to get the desired look
of your window, with the menubar flush to the top, just set the main
layout's insets to 0.

Hope that helps,
Alex
37a38
>           .SetInsets(0)
41,43c42
<                       .Add(fDetailView = new DetailView())
<               .End()
<       .End();
---
>                       .Add(fDetailView = new DetailView());
60c59,61
<       layout->AddView(new BStringView("foobar", "foobar"));
---
>       BStringView* stringView = new BStringView("foobar", "foobar");
>       stringView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
> B_SIZE_UNLIMITED));
>       layout->AddView(stringView);

Other related posts: