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" $"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 { resource(601, "WonderBrush icon") #'VICN' array {
$"6E6369662604015F03010000020006023B24000000000000003B24004A570046" $"6E6369662604015F03010000020006023B24000000000000003B24004A570046"
$"240000E9C06AFFC7903302000602A83D70BA60513A6051A83D704A1085461F33" $"240000E9C06AFFC7903302000602A83D70BA60513A6051A83D704A1085461F33"

View File

@ -763,7 +763,8 @@ private:
class RatingItemView : public BGroupView { class RatingItemView : public BGroupView {
public: public:
RatingItemView(const UserRating& rating) RatingItemView(const UserRating& rating, const BitmapRef& voteUpIcon,
const BitmapRef& voteDownIcon)
: :
BGroupView(B_HORIZONTAL, 0.0f) BGroupView(B_HORIZONTAL, 0.0f)
{ {
@ -801,6 +802,27 @@ public:
fPackageVersionView->SetFont(&versionFont); fPackageVersionView->SetFont(&versionFont);
fPackageVersionView->SetHighColor(kLightBlack); 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 = new TextView("rating text");
fTextView->SetViewColor(ViewColor()); fTextView->SetViewColor(ViewColor());
fTextView->SetText(rating.Comment()); fTextView->SetText(rating.Comment());
@ -817,6 +839,13 @@ public:
.AddGlue(0.1f) .AddGlue(0.1f)
.Add(fPackageVersionView) .Add(fPackageVersionView)
.AddGlue(5.0f) .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() .End()
.Add(fTextView) .Add(fTextView)
.End() .End()
@ -830,6 +859,12 @@ private:
RatingView* fRatingView; RatingView* fRatingView;
BStringView* fRatingLabelView; BStringView* fRatingLabelView;
BStringView* fPackageVersionView; BStringView* fPackageVersionView;
BitmapView* fVoteUpIconView;
BStringView* fUpVoteCountView;
BitmapView* fVoteDownIconView;
BStringView* fDownVoteCountView;
TextView* fTextView; TextView* fTextView;
}; };
@ -951,7 +986,9 @@ class UserRatingsView : public BGroupView {
public: public:
UserRatingsView() 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), SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
kContentTint)); kContentTint));
@ -994,7 +1031,8 @@ public:
for (int i = userRatings.CountItems() - 1; i >= 0; i--) { for (int i = userRatings.CountItems() - 1; i >= 0; i--) {
const UserRating& rating = userRatings.ItemAtFast(i); const UserRating& rating = userRatings.ItemAtFast(i);
RatingItemView* view = new RatingItemView(rating); RatingItemView* view = new RatingItemView(rating, fThumbsUpIcon,
fThumbsDownIcon);
fRatingContainerLayout->AddView(0, view); fRatingContainerLayout->AddView(0, view);
} }
} }
@ -1021,6 +1059,8 @@ public:
private: private:
BGroupLayout* fRatingContainerLayout; BGroupLayout* fRatingContainerLayout;
RatingSummaryView* fRatingSummaryView; RatingSummaryView* fRatingSummaryView;
BitmapRef fThumbsUpIcon;
BitmapRef fThumbsDownIcon;
}; };