[haiku-development] Re: BScrollView and layouts

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 17 Jan 2017 10:31:58 -0500

On Tue, Jan 17, 2017 at 10:20 AM, Adrien Destugues
<pulkomandy@xxxxxxxxxxxxx> wrote:

SetLayout(new BGroupLayout(B_VERTICAL, 0));
BStringView* label = new BStringView("label", "Notification Center");
fContainerView = new BGroupView(B_VERTICAL);
fScrollView = new BScrollView("Notifications",
       fContainerView, 0, false, true, B_NO_BORDER);
GetLayout()->AddView(label);
GetLayout()->AddView(fScrollView);

I think you can use AddChild() here, which will add the view using the
current layout of the parent.

This code could likely also be simplified a bit by using
BLayoutBuilder, for which quite a few examples exist [1]. As far as
using a BScrollView with a layouted view as the target, nothing
prevents you from doing so, at least e.g. the debugger's source code
view does exactly that without issue [2].

Regards,

Rene

[1] A simple example:
http://cgit.haiku-os.org/haiku/tree/src/preferences/shortcuts/ShortcutsWindow.cpp#n225
[2] 
http://cgit.haiku-os.org/haiku/tree/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp#n1016

http://cgit.haiku-os.org/haiku/tree/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp#n1033

Other related posts: