HaikuDepot: Show number of up and down votes per user rating

This commit is contained in:
Stephan Aßmus 2013-08-18 10:59:52 +02:00
parent c58fcc9888
commit 883b8dd0b9
2 changed files with 59 additions and 4 deletions

View File

@ -49,6 +49,21 @@ resource(501, "star") #'VICN' array {
$"C59EC928BEF3C457B84FC928BAD5C165010A00010000"
};
resource(502, "thumbs up") #'VICN' array {
$"6E63696601020016020000003DC000BD80000000004B30004960000056FF4A01"
$"060DF6FFFF0358404C4E4C524CC3AF4C3E5046503A50364EBC65C5F5344C3041"
$"3046303F383C343C3C3C3F3A3F3A3F383C323CBB103C303E2C3C2C402C403040"
$"2E40344638C16DBB23483C50404C405440010A00010000"
};
resource(503, "thumbs down") #'VICN' array {
$"6E63696601020016020000003DC000BD80000000004B30004960000056FF4A01"
$"060DF6FFFF035440344A344E34C217343A30423036303232BACDB98A30342C3F"
$"2C3A2C413444304438443B463B463B48384E38C46F38503A5438543C543C503C"
$"523C4C4248BFD5C45C44444C4048405040010A00010000"
};
resource(601, "WonderBrush icon") #'VICN' array {
$"6E6369662604015F03010000020006023B24000000000000003B24004A570046"
$"240000E9C06AFFC7903302000602A83D70BA60513A6051A83D704A1085461F33"

View File

@ -763,7 +763,8 @@ private:
class RatingItemView : public BGroupView {
public:
RatingItemView(const UserRating& rating)
RatingItemView(const UserRating& rating, const BitmapRef& voteUpIcon,
const BitmapRef& voteDownIcon)
:
BGroupView(B_HORIZONTAL, 0.0f)
{
@ -800,7 +801,28 @@ public:
versionFont.SetSize(std::max(9.0f, floorf(versionFont.Size() * 0.85f)));
fPackageVersionView->SetFont(&versionFont);
fPackageVersionView->SetHighColor(kLightBlack);
fVoteUpIconView = new BitmapView("vote up icon");
fUpVoteCountView = new BStringView("up vote count", "");
fVoteDownIconView = new BitmapView("vote down icon");
fDownVoteCountView = new BStringView("up vote count", "");
fVoteUpIconView->SetBitmap(
voteUpIcon->Bitmap(SharedBitmap::SIZE_16));
fVoteDownIconView->SetBitmap(
voteDownIcon->Bitmap(SharedBitmap::SIZE_16));
fUpVoteCountView->SetFont(&versionFont);
fUpVoteCountView->SetHighColor(kLightBlack);
fDownVoteCountView->SetFont(&versionFont);
fDownVoteCountView->SetHighColor(kLightBlack);
BString voteCountLabel;
voteCountLabel.SetToFormat("%ld", rating.UpVotes());
fUpVoteCountView->SetText(voteCountLabel);
voteCountLabel.SetToFormat("%ld", rating.DownVotes());
fDownVoteCountView->SetText(voteCountLabel);
fTextView = new TextView("rating text");
fTextView->SetViewColor(ViewColor());
fTextView->SetText(rating.Comment());
@ -817,6 +839,13 @@ public:
.AddGlue(0.1f)
.Add(fPackageVersionView)
.AddGlue(5.0f)
.AddGroup(B_HORIZONTAL, 0.0f, 0.0f)
.Add(fVoteUpIconView)
.Add(fUpVoteCountView)
.AddStrut(B_USE_HALF_ITEM_SPACING)
.Add(fVoteDownIconView)
.Add(fDownVoteCountView)
.End()
.End()
.Add(fTextView)
.End()
@ -830,6 +859,12 @@ private:
RatingView* fRatingView;
BStringView* fRatingLabelView;
BStringView* fPackageVersionView;
BitmapView* fVoteUpIconView;
BStringView* fUpVoteCountView;
BitmapView* fVoteDownIconView;
BStringView* fDownVoteCountView;
TextView* fTextView;
};
@ -951,7 +986,9 @@ class UserRatingsView : public BGroupView {
public:
UserRatingsView()
:
BGroupView("package ratings view", B_HORIZONTAL)
BGroupView("package ratings view", B_HORIZONTAL),
fThumbsUpIcon(BitmapRef(new SharedBitmap(502), true)),
fThumbsDownIcon(BitmapRef(new SharedBitmap(503), true))
{
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
kContentTint));
@ -994,7 +1031,8 @@ public:
for (int i = userRatings.CountItems() - 1; i >= 0; i--) {
const UserRating& rating = userRatings.ItemAtFast(i);
RatingItemView* view = new RatingItemView(rating);
RatingItemView* view = new RatingItemView(rating, fThumbsUpIcon,
fThumbsDownIcon);
fRatingContainerLayout->AddView(0, view);
}
}
@ -1021,6 +1059,8 @@ public:
private:
BGroupLayout* fRatingContainerLayout;
RatingSummaryView* fRatingSummaryView;
BitmapRef fThumbsUpIcon;
BitmapRef fThumbsDownIcon;
};