HaikuDepot: Work in progress on featured packages

Not yet visible. But the package list area in the main window has a card
layout now and a second (hidden) page for featured packages. Which packages
are visible there will depend on the prominence value from the web-app
and other parameters later (suggestions based on packages already installed
and user-ratings). At the moment, there is no mechanism for updating the
package list when package info is retrieved asynchronously, even from the
cache. Also, the view should switch to the list when searching and perhaps
in other situations as well, like selecting a category or when no packages
would be featured. And clicking featured packages does not yet select them in
the info area...
This commit is contained in:
Stephan Aßmus 2014-10-26 23:32:09 +01:00
parent f545fe6acc
commit 4b930cca9c
3 changed files with 54 additions and 7 deletions

View File

@ -38,6 +38,8 @@ public:
BGroupView("package view", B_HORIZONTAL),
fPackageListener(new(std::nothrow) MessagePackageListener(this))
{
SetViewColor(255, 255, 255);
fIconView = new BitmapView("package icon view");
fTitleView = new BStringView("package title view", "");
fPublisherView = new BStringView("package publisher view", "");
@ -47,7 +49,7 @@ public:
GetFont(&font);
font_family family;
font_style style;
font.SetSize(ceilf(font.Size() * 1.5f));
font.SetSize(ceilf(font.Size() * 1.8f));
font.GetFamilyAndStyle(&family, &style);
font.SetFamilyAndStyle(family, "Bold");
fTitleView->SetFont(&font);
@ -81,6 +83,7 @@ public:
.AddGlue()
.SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET))
.End()
.SetInsets(B_USE_WINDOW_INSETS)
;
Clear();
@ -109,7 +112,7 @@ public:
if (package->Icon().Get() != NULL) {
fIconView->SetBitmap(
package->Icon()->Bitmap(SharedBitmap::SIZE_32));
package->Icon()->Bitmap(SharedBitmap::SIZE_64));
} else
fIconView->SetBitmap(NULL);
@ -136,6 +139,11 @@ public:
fVersionInfo->SetText("");
}
const char* PackageTitle() const
{
return fTitleView->Text();
}
private:
MessagePackageListener* fPackageListener;
@ -163,7 +171,8 @@ FeaturedPackagesView::FeaturedPackagesView()
fPackageListLayout = containerView->GroupLayout();
BScrollView* scrollView = new BScrollView(
"packages scroll view", containerView);
"featured packages scroll view", containerView,
0, false, true, B_FANCY_BORDER);
BLayoutBuilder::Group<>(this)
.Add(scrollView, 1.0f)
@ -181,7 +190,22 @@ FeaturedPackagesView::AddPackage(const PackageInfoRef& package)
{
PackageView* view = new PackageView();
view->SetPackage(package);
fPackageListLayout->AddView(view);
// Find insertion index (alphabetical)
int32 index = 0;
for (int32 i = 0; BLayoutItem* item = fPackageListLayout->ItemAt(i); i++) {
PackageView* view = dynamic_cast<PackageView*>(item->View());
if (view == NULL)
break;
BString title = view->PackageTitle();
if (title.Compare(package->Title()) >= 0)
break;
index++;
}
fPackageListLayout->AddView(index, view);
}

View File

@ -16,6 +16,7 @@
#include <Application.h>
#include <Button.h>
#include <Catalog.h>
#include <CardLayout.h>
#include <LayoutBuilder.h>
#include <MenuBar.h>
#include <MenuItem.h>
@ -39,6 +40,7 @@
#include "AutoDeleter.h"
#include "AutoLocker.h"
#include "DecisionProvider.h"
#include "FeaturedPackagesView.h"
#include "FilterView.h"
#include "JobStateListener.h"
#include "PackageInfoView.h"
@ -131,11 +133,22 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings)
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);
BView* listArea = new BView("list area", 0);
fListLayout = new BCardLayout();
listArea->SetLayout(fListLayout);
listArea->AddChild(fFeaturedPackagesView);
listArea->AddChild(fPackageListView);
fListLayout->SetVisibleItem((int32)1);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
.AddGroup(B_HORIZONTAL, 0.0f)
.Add(menuBar, 1.0f)
@ -144,7 +157,7 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings)
.Add(fFilterView)
.AddSplit(fSplitView)
.AddGroup(B_VERTICAL)
.Add(fPackageListView)
.Add(listArea)
.SetInsets(
B_USE_DEFAULT_SPACING, 0.0f,
B_USE_DEFAULT_SPACING, 0.0f)
@ -543,10 +556,16 @@ MainWindow::_AdoptModel()
{
fVisiblePackages = fModel.CreatePackageList();
fFeaturedPackagesView->Clear();
fPackageListView->Clear();
for (int32 i = 0; i < fVisiblePackages.CountItems(); i++) {
BAutolock locker(fModel.Lock());
fPackageListView->AddPackage(fVisiblePackages.ItemAtFast(i));
const PackageInfoRef& package = fVisiblePackages.ItemAtFast(i);
fPackageListView->AddPackage(package);
if (package->Title() == "beam" || package->Title() == "caya")
fFeaturedPackagesView->AddPackage(package);
}
BAutolock locker(fModel.Lock());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2013, Rene Gollent <rene@gollent.com>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
@ -14,9 +14,11 @@
#include "PackageInfoListener.h"
class BCardLayout;
class BMenu;
class BMenuItem;
class BSplitView;
class FeaturedPackagesView;
class FilterView;
class PackageActionsView;
class PackageInfoView;
@ -83,6 +85,8 @@ private:
private:
FilterView* fFilterView;
BCardLayout* fListLayout;
FeaturedPackagesView* fFeaturedPackagesView;
PackageListView* fPackageListView;
PackageInfoView* fPackageInfoView;
BSplitView* fSplitView;