[haiku-development] Possible layout bug

  • From: Stefano Ceccherini <stefano.ceccherini@xxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Fri, 21 Oct 2011 14:19:21 +0200

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.
#include <stdio.h>
#include <string.h>

#include <Application.h>
#include <Layout.h>
#include <LayoutBuilder.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <OutlineListView.h>
#include <StringView.h>


class DetailView : public BView {
public:
        DetailView();
private:
        BStringView* fManufacturerView;
};


class MainWindow : public BWindow {
public:
        MainWindow(BRect rect);
        
private:
        BOutlineListView* fListView;
        DetailView* fDetailView;
        BMenuBar* fMenuBar;
};


MainWindow::MainWindow(BRect rect)
        :
        BWindow(rect, "Main Window", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
        BLayoutBuilder::Group<>(this, B_VERTICAL)
                .Add(fMenuBar = new BMenuBar("Menu"))
                .AddSplit(B_HORIZONTAL, 3)
                        .Add(fListView = new BOutlineListView("listview"))
                        .Add(fDetailView = new DetailView())
                .End()
        .End();
        
        BMenu* menu = new BMenu("File");
        fMenuBar->AddItem(menu);
        BMenuItem* item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
                'Q');
        menu->AddItem(item);
        item->SetTarget(this);
}


DetailView::DetailView()
        :
        BView("detail", B_WILL_DRAW)
{
        BLayout *layout = new BGroupLayout(B_VERTICAL);
        SetLayout(layout);
        layout->AddView(new BStringView("foobar", "foobar"));
}


class Application : public BApplication {
public:
        Application();
        virtual void ReadyToRun();
};


Application::Application()
        :
        BApplication("application/x-vnd.USBExplorer")
{
}


/* virtual */
void
Application::ReadyToRun()
{
        BApplication::ReadyToRun();
        BWindow* window = new MainWindow(BRect(20, 20, 300, 400));
        window->Show();
}



int main()
{
        Application app;
        app.Run();
        
        return 0;       
}

Attachment: screenshot1.png
Description: PNG image

Other related posts: