Opened 22 months ago

Last modified 4 months ago

#18316 new enhancement

Add BBox support to BLayoutBuilder

Reported by: pulkomandy Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Kits/Interface Kit Version: R1/beta4
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

It would be nice to be able to do this:

BLayoutBuilder::Group<>(someView)
    .Add(...)
    .AddBox("box label")
        .AddGroup(B_VERTICAL)
            ...
        .End()
    .End()
.End();

Currently, using BBox in layout mode is annoying, you have to:

  • Declare and allocate the BBox
  • Set its label
  • Add an inner view to it
  • Use a BLayoutBuilder to populate that inner view
  • Finally add the box to the global layout

This breaks the nice pseudo-declarative workflow for GUIs.

Change History (4)

comment:1 by X512, 21 months ago

Can you give an equivalent code based on current existing API?

comment:2 by pulkomandy, 21 months ago

With current API you have to do something like this:

BBox* box = new BBox("box label");
BGroupView* innerView = new BGroupView(B_VERTICAL);
box->AddChild(innerView);

BLayoutBuilder::Group<>(innerView)
    ... // Same content as the ... in the initial example
.End();

BLayoutBuilder::Group<>(someView)
    .Add(...)
    .Add("box")
.End();

comment:3 by cafeina, 4 months ago

Would it make sense to also have a template like this:

BLayoutBuilder::Box<>("Title", ...)
    .Add(...)
.End();
Last edited 4 months ago by cafeina (previous) (diff)

comment:4 by pulkomandy, 4 months ago

Yes, for completeness and consistency with the other layouts, and it may be required by the implementation of AddBox in the other layouts as well (that will return such a type)

Note: See TracTickets for help on using tickets.