HaikuDepot: Improve featured package items
Show the summary instead of the version. The layout still sucks, but I will have to implement some kind of row/flow BLayout to get what I initially had in mind. Another TODO is to highlight the clicked item somehow.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "BitmapView.h"
|
#include "BitmapView.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
#include "MarkupTextView.h"
|
||||||
#include "MessagePackageListener.h"
|
#include "MessagePackageListener.h"
|
||||||
#include "RatingView.h"
|
#include "RatingView.h"
|
||||||
#include "ScrollableGroupView.h"
|
#include "ScrollableGroupView.h"
|
||||||
@@ -64,14 +65,22 @@ public:
|
|||||||
fPublisherView->SetFont(&font);
|
fPublisherView->SetFont(&font);
|
||||||
fPublisherView->SetHighColor(kLightBlack);
|
fPublisherView->SetHighColor(kLightBlack);
|
||||||
|
|
||||||
// slightly bigger font
|
|
||||||
GetFont(&font);
|
|
||||||
font.SetSize(ceilf(font.Size() * 1.2f));
|
|
||||||
|
|
||||||
// Version info
|
// Version info
|
||||||
fVersionInfo = new BStringView("package version info", "");
|
fSummaryView = new MarkupTextView("package summary");
|
||||||
fVersionInfo->SetFont(&font);
|
|
||||||
fVersionInfo->SetHighColor(kLightBlack);
|
// Rating view
|
||||||
|
fRatingView = new RatingView("package rating view");
|
||||||
|
|
||||||
|
fAvgRating = new BStringView("package average rating", "");
|
||||||
|
fAvgRating->SetFont(&font);
|
||||||
|
fAvgRating->SetHighColor(kLightBlack);
|
||||||
|
|
||||||
|
fVoteInfo = new BStringView("package vote info", "");
|
||||||
|
// small font
|
||||||
|
GetFont(&font);
|
||||||
|
font.SetSize(std::max(9.0f, floorf(font.Size() * 0.85f)));
|
||||||
|
fVoteInfo->SetFont(&font);
|
||||||
|
fVoteInfo->SetHighColor(kLightBlack);
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this)
|
BLayoutBuilder::Group<>(this)
|
||||||
.Add(fIconView)
|
.Add(fIconView)
|
||||||
@@ -81,11 +90,14 @@ public:
|
|||||||
.SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET))
|
.SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET))
|
||||||
.End()
|
.End()
|
||||||
.AddGlue(0.1f)
|
.AddGlue(0.1f)
|
||||||
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING, 2.0f)
|
.AddGroup(B_HORIZONTAL, 0.8f)
|
||||||
.Add(fVersionInfo)
|
.Add(fRatingView)
|
||||||
.AddGlue()
|
.Add(fAvgRating)
|
||||||
.SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET))
|
.Add(fVoteInfo)
|
||||||
.End()
|
.End()
|
||||||
|
.AddGlue(0.2f)
|
||||||
|
.Add(fSummaryView, 2.0f)
|
||||||
|
|
||||||
.SetInsets(B_USE_WINDOW_INSETS)
|
.SetInsets(B_USE_WINDOW_INSETS)
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -138,9 +150,29 @@ public:
|
|||||||
BString publisher = package->Publisher().Name();
|
BString publisher = package->Publisher().Name();
|
||||||
fPublisherView->SetText(publisher);
|
fPublisherView->SetText(publisher);
|
||||||
|
|
||||||
BString version = B_TRANSLATE("%Version%");
|
BString summary = package->ShortDescription();
|
||||||
version.ReplaceAll("%Version%", package->Version().ToString());
|
fSummaryView->SetText(summary);
|
||||||
fVersionInfo->SetText(version);
|
|
||||||
|
RatingSummary ratingSummary = package->CalculateRatingSummary();
|
||||||
|
|
||||||
|
fRatingView->SetRating(ratingSummary.averageRating);
|
||||||
|
|
||||||
|
if (ratingSummary.ratingCount > 0) {
|
||||||
|
BString avgRating;
|
||||||
|
avgRating.SetToFormat("%.1f", ratingSummary.averageRating);
|
||||||
|
fAvgRating->SetText(avgRating);
|
||||||
|
|
||||||
|
BString votes;
|
||||||
|
votes.SetToFormat("%d", ratingSummary.ratingCount);
|
||||||
|
|
||||||
|
BString voteInfo(B_TRANSLATE("(%Votes%)"));
|
||||||
|
voteInfo.ReplaceAll("%Votes%", votes);
|
||||||
|
|
||||||
|
fVoteInfo->SetText(voteInfo);
|
||||||
|
} else {
|
||||||
|
fAvgRating->SetText("");
|
||||||
|
fVoteInfo->SetText("");
|
||||||
|
}
|
||||||
|
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@@ -153,7 +185,10 @@ public:
|
|||||||
fIconView->SetBitmap(NULL);
|
fIconView->SetBitmap(NULL);
|
||||||
fTitleView->SetText("");
|
fTitleView->SetText("");
|
||||||
fPublisherView->SetText("");
|
fPublisherView->SetText("");
|
||||||
fVersionInfo->SetText("");
|
fSummaryView->SetText("");
|
||||||
|
fRatingView->SetRating(-1.0f);
|
||||||
|
fAvgRating->SetText("");
|
||||||
|
fVoteInfo->SetText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* PackageTitle() const
|
const char* PackageTitle() const
|
||||||
@@ -169,7 +204,11 @@ private:
|
|||||||
BStringView* fTitleView;
|
BStringView* fTitleView;
|
||||||
BStringView* fPublisherView;
|
BStringView* fPublisherView;
|
||||||
|
|
||||||
BStringView* fVersionInfo;
|
MarkupTextView* fSummaryView;
|
||||||
|
|
||||||
|
RatingView* fRatingView;
|
||||||
|
BStringView* fAvgRating;
|
||||||
|
BStringView* fVoteInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user