[haiku-development] Layout api bug or user error

  • From: Stefano Ceccherini <stefano.ceccherini@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 30 Oct 2009 11:20:36 +0100

Hi,
I'm adapting an application of mine to the haiku layout api, but I hit
a problem which could be a bug in the layout implementation, or just
an error from my side:

The attached code will display a window which can't be resized
horizontally at all.
Note that I stripped down the code as much as possible, but I have the
same problem with the full code, obviously.
Thanks in advance.
#include <Application.h>
#include <Box.h>
#include <Button.h>
#include <GroupLayoutBuilder.h>
#include <GroupView.h>
#include <LayoutBuilder.h>
#include <LayoutUtils.h>
#include <Screen.h>
#include <String.h>
#include <TabView.h>
#include <Window.h>



const static BRect kWindowRect(0, 0, 600, 500);


class BSCWindow : public BWindow {
public:
        BSCWindow();
        
private:
        BTabView *fTabView;
        BButton *fStartStopButton;
};

class OutputView : public BView {
public: 
        OutputView();
                
        virtual BSize   MinSize();              
};


int main()
{
        BApplication app("application/foobar");
        
        (new BSCWindow())->Show();
        app.Run();
        return 0;
}


BSCWindow::BSCWindow()
        :
        BWindow(kWindowRect, "test", B_TITLED_WINDOW,
                B_ASYNCHRONOUS_CONTROLS|B_AUTO_UPDATE_SIZE_LIMITS)
{
        OutputView *outputView
                = new OutputView();
        
        fStartStopButton = new BButton("test", "test",
                new BMessage()); 
                                        
        BLayoutBuilder::Group<>(this, B_VERTICAL)
                .AddGroup(B_VERTICAL, 1)
                .SetInsets(10, 10, 10, 10)
                        .Add(fTabView = new BTabView("Tab View"))
                        .AddGroup(B_HORIZONTAL)
                                .Add(fStartStopButton)
                        .End()
                .End();
                                
        BGroupView* outputGroup = new BGroupView(B_HORIZONTAL);
        outputGroup->SetName("Output");
        fTabView->AddTab(outputGroup);
        BLayoutBuilder::Group<>(outputGroup)
                .Add(outputView);
}


OutputView::OutputView()
        :
        BView("output", B_WILL_DRAW)
{
        SetLayout(new BGroupLayout(B_HORIZONTAL));
        BSplitView *split = new BSplitView(B_HORIZONTAL);
        AddChild(split);
}


BSize
OutputView::MinSize()
{
        return BLayoutUtils::ComposeSize(ExplicitMinSize(), BSize(600, 300));
}

Other related posts: