Beispiel #1
0
void
MainWindow::_CreateGUI()
{
    SetLayout(new BGroupLayout(B_HORIZONTAL));

    BGridLayout* layout = new BGridLayout();
    layout->SetSpacing(0, 0);
    BView* rootView = new BView("root view", 0, layout);
    AddChild(rootView);
    rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    BGroupView* leftTopView = new BGroupView(B_VERTICAL, 0);
    layout->AddView(leftTopView, 0, 0);

    // views along the left side
    leftTopView->AddChild(_CreateMenuBar());

    float splitWidth = 13 * be_plain_font->Size();
    BSize minSize = leftTopView->MinSize();
    splitWidth = std::max(splitWidth, minSize.width);
    leftTopView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET));
    leftTopView->SetExplicitMinSize(BSize(splitWidth, B_SIZE_UNSET));

    BGroupView* iconPreviews = new BGroupView(B_HORIZONTAL);
    iconPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    iconPreviews->GroupLayout()->SetSpacing(5);

    // icon previews
    fIconPreview16Folder = new IconView(BRect(0, 0, 15, 15),
                                        "icon preview 16 folder");
    fIconPreview16Menu = new IconView(BRect(0, 0, 15, 15),
                                      "icon preview 16 menu");
    fIconPreview16Menu->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));

    fIconPreview32Folder = new IconView(BRect(0, 0, 31, 31),
                                        "icon preview 32 folder");
    fIconPreview32Desktop = new IconView(BRect(0, 0, 31, 31),
                                         "icon preview 32 desktop");
    fIconPreview32Desktop->SetLowColor(ui_color(B_DESKTOP_COLOR));

    fIconPreview64 = new IconView(BRect(0, 0, 63, 63), "icon preview 64");
    fIconPreview64->SetLowColor(ui_color(B_DESKTOP_COLOR));


    BGroupView* smallPreviews = new BGroupView(B_VERTICAL);
    smallPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    smallPreviews->GroupLayout()->SetSpacing(5);

    smallPreviews->AddChild(fIconPreview16Folder);
    smallPreviews->AddChild(fIconPreview16Menu);

    BGroupView* mediumPreviews = new BGroupView(B_VERTICAL);
    mediumPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    mediumPreviews->GroupLayout()->SetSpacing(5);

    mediumPreviews->AddChild(fIconPreview32Folder);
    mediumPreviews->AddChild(fIconPreview32Desktop);

//	iconPreviews->AddChild(fIconPreview48);

    iconPreviews->AddChild(smallPreviews);
    iconPreviews->AddChild(mediumPreviews);
    iconPreviews->AddChild(fIconPreview64);
    iconPreviews->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED));

    leftTopView->AddChild(iconPreviews);


    BGroupView* leftSideView = new BGroupView(B_VERTICAL, 0);
    layout->AddView(leftSideView, 0, 1);
    leftSideView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET));

    // path menu and list view
    BMenuBar* menuBar = new BMenuBar("path menu bar");
    menuBar->AddItem(fPathMenu);
    leftSideView->AddChild(menuBar);

    fPathListView = new PathListView(BRect(0, 0, splitWidth, 100),
                                     "path list view", new BMessage(MSG_PATH_SELECTED), this);

    BView* scrollView = new BScrollView("path list scroll view",
                                        fPathListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // shape list view
    menuBar = new BMenuBar("shape menu bar");
    menuBar->AddItem(fShapeMenu);
    leftSideView->AddChild(menuBar);

    fShapeListView = new ShapeListView(BRect(0, 0, splitWidth, 100),
                                       "shape list view", new BMessage(MSG_SHAPE_SELECTED), this);
    scrollView = new BScrollView("shape list scroll view",
                                 fShapeListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // transformer list view
    menuBar = new BMenuBar("transformer menu bar");
    menuBar->AddItem(fTransformerMenu);
    leftSideView->AddChild(menuBar);

    fTransformerListView = new TransformerListView(BRect(0, 0, splitWidth, 100),
            "transformer list view");
    scrollView = new BScrollView("transformer list scroll view",
                                 fTransformerListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // property list view
    menuBar = new BMenuBar("property menu bar");
    menuBar->AddItem(fPropertyMenu);
    leftSideView->AddChild(menuBar);

    fPropertyListView = new IconObjectListView();

    // scroll view around property list view
    ScrollView* propScrollView = new ScrollView(fPropertyListView,
            SCROLL_VERTICAL, BRect(0, 0, splitWidth, 100), "property scroll view",
            B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER,
            BORDER_RIGHT);
    leftSideView->AddChild(propScrollView);

    BGroupLayout* topSide = new BGroupLayout(B_HORIZONTAL);
    topSide->SetSpacing(0);
    BView* topSideView = new BView("top side view", 0, topSide);
    layout->AddView(topSideView, 1, 0);

    // canvas view
    BRect canvasBounds = BRect(0, 0, 200, 200);
    fCanvasView = new CanvasView(canvasBounds);

    // scroll view around canvas view
    canvasBounds.bottom += B_H_SCROLL_BAR_HEIGHT;
    canvasBounds.right += B_V_SCROLL_BAR_WIDTH;
    ScrollView* canvasScrollView = new ScrollView(fCanvasView, SCROLL_VERTICAL
            | SCROLL_HORIZONTAL | SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS,
            canvasBounds, "canvas scroll view", B_FOLLOW_NONE,
            B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER);
    layout->AddView(canvasScrollView, 1, 1);

    // views along the top

    BGroupLayout* styleGroup = new BGroupLayout(B_VERTICAL, 0);
    BView* styleGroupView = new BView("style group", 0, styleGroup);
    topSide->AddView(styleGroupView);

    // style list view
    menuBar = new BMenuBar("style menu bar");
    menuBar->AddItem(fStyleMenu);
    styleGroup->AddView(menuBar);

    fStyleListView = new StyleListView(BRect(0, 0, splitWidth, 100),
                                       "style list view", new BMessage(MSG_STYLE_SELECTED), this);
    scrollView = new BScrollView("style list scroll view", fStyleListView,
                                 B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    scrollView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNLIMITED));
    styleGroup->AddView(scrollView);

    // style view
    fStyleView = new StyleView(BRect(0, 0, 200, 100));
    topSide->AddView(fStyleView);

    // swatch group
    BGroupLayout* swatchGroup = new BGroupLayout(B_VERTICAL);
    swatchGroup->SetSpacing(0);
    BView* swatchGroupView = new BView("swatch group", 0, swatchGroup);
    topSide->AddView(swatchGroupView);

    menuBar = new BMenuBar("swatches menu bar");
    menuBar->AddItem(fSwatchMenu);
    swatchGroup->AddView(menuBar);

    fSwatchGroup = new SwatchGroup(BRect(0, 0, 100, 100));
    swatchGroup->AddView(fSwatchGroup);

    swatchGroupView->SetExplicitMaxSize(swatchGroupView->MinSize());

    // make sure the top side has fixed height
    topSideView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
                                          swatchGroupView->MinSize().height));
}
Beispiel #2
0
MainWindow::MainWindow(const BMessage& settings)
	:
	BWindow(BRect(50, 50, 650, 550), B_TRANSLATE_SYSTEM_NAME("HaikuDepot"),
		B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
	fScreenshotWindow(NULL),
	fUserMenu(NULL),
	fLogInItem(NULL),
	fLogOutItem(NULL),
	fModelListener(new MessageModelListener(BMessenger(this)), true),
	fTerminating(false),
	fSinglePackageMode(false),
	fModelWorker(B_BAD_THREAD_ID)
{
	BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu"));
	_BuildMenu(menuBar);

	BMenuBar* userMenuBar = new BMenuBar(B_TRANSLATE("User Menu"));
	_BuildUserMenu(userMenuBar);
	set_small_font(userMenuBar);
	userMenuBar->SetExplicitMaxSize(BSize(B_SIZE_UNSET,
		menuBar->MaxSize().height));

	fFilterView = new FilterView();
	fFeaturedPackagesView = new FeaturedPackagesView();
	fPackageListView = new PackageListView(fModel.Lock());
	fPackageInfoView = new PackageInfoView(fModel.Lock(), this);

	fSplitView = new BSplitView(B_VERTICAL, 5.0f);

	BGroupView* featuredPackagesGroup = new BGroupView(B_VERTICAL);
	BStringView* featuredPackagesTitle = new BStringView(
		"featured packages title", B_TRANSLATE("Featured packages"));
	BFont font(be_bold_font);
	font.SetSize(font.Size() * 1.3f);
	featuredPackagesTitle->SetFont(&font);
	featuredPackagesGroup->SetExplicitMaxSize(
		BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	BLayoutBuilder::Group<>(featuredPackagesGroup)
		.Add(featuredPackagesTitle)
		.Add(fFeaturedPackagesView)
	;

	BView* listArea = new BView("list area", 0);
	fListLayout = new BCardLayout();
	listArea->SetLayout(fListLayout);
	listArea->AddChild(featuredPackagesGroup);
	listArea->AddChild(fPackageListView);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
		.AddGroup(B_HORIZONTAL, 0.0f)
			.Add(menuBar, 1.0f)
			.Add(userMenuBar, 0.0f)
		.End()
		.Add(fFilterView)
		.AddSplit(fSplitView)
			.AddGroup(B_VERTICAL)
				.Add(listArea)
				.SetInsets(
					B_USE_DEFAULT_SPACING, 0.0f,
					B_USE_DEFAULT_SPACING, 0.0f)
			.End()
			.Add(fPackageInfoView)
		.End()
	;

	fSplitView->SetCollapsible(0, false);
	fSplitView->SetCollapsible(1, false);

	fModel.AddListener(fModelListener);

	// Restore settings
	BMessage columnSettings;
	if (settings.FindMessage("column settings", &columnSettings) == B_OK)
		fPackageListView->LoadState(&columnSettings);

	bool showOption;
	if (settings.FindBool("show featured packages", &showOption) == B_OK)
		fModel.SetShowFeaturedPackages(showOption);
	if (settings.FindBool("show available packages", &showOption) == B_OK)
		fModel.SetShowAvailablePackages(showOption);
	if (settings.FindBool("show installed packages", &showOption) == B_OK)
		fModel.SetShowInstalledPackages(showOption);
	if (settings.FindBool("show develop packages", &showOption) == B_OK)
		fModel.SetShowDevelopPackages(showOption);
	if (settings.FindBool("show source packages", &showOption) == B_OK)
		fModel.SetShowSourcePackages(showOption);

	if (fModel.ShowFeaturedPackages())
		fListLayout->SetVisibleItem((int32)0);
	else
		fListLayout->SetVisibleItem(1);

	_RestoreUserName(settings);
	_RestoreWindowFrame(settings);

	// start worker threads
	BPackageRoster().StartWatching(this,
		B_WATCH_PACKAGE_INSTALLATION_LOCATIONS);

	_StartRefreshWorker();

	_InitWorkerThreads();
}