hrev45961 adds 2 changesets to branch 'master' old head: 6f065b8bfeb4eb23213863db13da831c6bf03739 new head: bcc3ba4109e4138550d62f58e54f47f29d531817 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=bcc3ba4+%5E6f065b8 ---------------------------------------------------------------------------- 1058f86: BColumnListView: Regard StatusView in DoLayout() and Draw() bcc3ba4: HaikuDepot: Added item count view to package list [ Stephan Aßmus <superstippi@xxxxxx> ] ---------------------------------------------------------------------------- 3 files changed, 120 insertions(+), 1 deletion(-) src/apps/haiku-depot/PackageListView.cpp | 85 ++++++++++++++++++++++++++++ src/apps/haiku-depot/PackageListView.h | 4 ++ src/kits/interface/ColumnListView.cpp | 32 ++++++++++- ############################################################################ Commit: 1058f86a5f0b262f67b3cba0ab06daa71281dbcd URL: http://cgit.haiku-os.org/haiku/commit/?id=1058f86 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Aug 10 20:40:05 2013 UTC BColumnListView: Regard StatusView in DoLayout() and Draw() ---------------------------------------------------------------------------- diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index f9b67a0..fd5c574 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -1779,6 +1779,15 @@ BColumnListView::Draw(BRect updateRect) verticalScrollBarFrame, horizontalScrollBarFrame, base, fBorderStyle, flags); + if (fStatusView != NULL) { + rect = Bounds(); + BRegion region(rect & fStatusView->Frame().InsetByCopy(-2, -2)); + ConstrainClippingRegion(®ion); + rect.bottom = fStatusView->Frame().top - 1; + be_control_look->DrawScrollViewFrame(this, rect, updateRect, + BRect(), BRect(), base, fBorderStyle, flags); + } + return; } @@ -1958,7 +1967,7 @@ BColumnListView::LayoutInvalidated(bool descendants) void BColumnListView::DoLayout() { - if (!(Flags() & B_SUPPORTS_LAYOUT)) + if ((Flags() & B_SUPPORTS_LAYOUT) == 0) return; BRect titleRect; @@ -1978,6 +1987,27 @@ BColumnListView::DoLayout() fVerticalScrollBar->ResizeTo(vScrollBarRect.Width(), vScrollBarRect.Height()); + if (fStatusView != NULL) { + BSize size = fStatusView->MinSize(); + if (size.height > B_H_SCROLL_BAR_HEIGHT); + size.height = B_H_SCROLL_BAR_HEIGHT; + if (size.width > Bounds().Width() / 2) + size.width = floorf(Bounds().Width() / 2); + + BPoint offset(hScrollBarRect.LeftTop()); + + if (fBorderStyle == B_PLAIN_BORDER) { + offset += BPoint(0, 1); + } else if (fBorderStyle == B_FANCY_BORDER) { + offset += BPoint(-1, 2); + size.height -= 1; + } + + fStatusView->MoveTo(offset); + fStatusView->ResizeTo(size.width, size.height); + hScrollBarRect.left = offset.x + size.width + 1; + } + fHorizontalScrollBar->MoveTo(hScrollBarRect.LeftTop()); fHorizontalScrollBar->ResizeTo(hScrollBarRect.Width(), hScrollBarRect.Height()); ############################################################################ Revision: hrev45961 Commit: bcc3ba4109e4138550d62f58e54f47f29d531817 URL: http://cgit.haiku-os.org/haiku/commit/?id=bcc3ba4 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Aug 10 20:40:40 2013 UTC HaikuDepot: Added item count view to package list ---------------------------------------------------------------------------- diff --git a/src/apps/haiku-depot/PackageListView.cpp b/src/apps/haiku-depot/PackageListView.cpp index f1a2050..eb7edf4 100644 --- a/src/apps/haiku-depot/PackageListView.cpp +++ b/src/apps/haiku-depot/PackageListView.cpp @@ -9,6 +9,7 @@ #include <stdio.h> #include <Catalog.h> +#include <ScrollBar.h> #include <Window.h> @@ -402,6 +403,85 @@ PackageRow::PackageRow(const PackageInfo& package) } +// #pragma mark - ItemCountView + + +class PackageListView::ItemCountView : public BView { +public: + ItemCountView() + : + BView("item count view", B_WILL_DRAW), + fItemCount(0) + { + BFont font(be_plain_font); + font.SetSize(9.0f); + SetFont(&font); + + SetViewColor(B_TRANSPARENT_COLOR); + SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + } + + virtual BSize MinSize() + { + BString label(_GetLabel()); + return BSize(StringWidth(label) + 10, B_H_SCROLL_BAR_HEIGHT); + } + + virtual BSize PreferredSize() + { + return MinSize(); + } + + virtual BSize MaxSize() + { + return MinSize(); + } + + virtual void Draw(BRect updateRect) + { + FillRect(updateRect, B_SOLID_LOW); + + BString label(_GetLabel()); + + font_height fontHeight; + GetFontHeight(&fontHeight); + + BRect bounds(Bounds()); + float width = StringWidth(label); + + BPoint offset; + offset.x = bounds.left + (bounds.Width() - width) / 2.0f; + offset.y = bounds.top + (bounds.Height() + - (fontHeight.ascent + fontHeight.descent)) / 2.0f + + fontHeight.ascent; + + DrawString(label, offset); + } + + void SetItemCount(int32 count) + { + if (count == fItemCount) + return; + fItemCount = count; + InvalidateLayout(); + Invalidate(); + } + +private: + BString _GetLabel() const + { + BString label; + if (fItemCount == 1) + label = B_TRANSLATE("1 item"); + else + label.SetToFormat(B_TRANSLATE("%ld items"), fItemCount); + return label; + } + + int32 fItemCount; +}; + + // #pragma mark - PackageListView @@ -421,6 +501,9 @@ PackageListView::PackageListView() B_TRUNCATE_END), kStatusColumn); SetSortingEnabled(true); + + fItemCountView = new ItemCountView(); + AddStatusView(fItemCountView); } @@ -481,6 +564,8 @@ PackageListView::AddPackage(const PackageInfo& package) // make sure the row is initially expanded ExpandOrCollapse(packageRow, true); + + fItemCountView->SetItemCount(CountRows()); } diff --git a/src/apps/haiku-depot/PackageListView.h b/src/apps/haiku-depot/PackageListView.h index 05c57a3..9ffd576 100644 --- a/src/apps/haiku-depot/PackageListView.h +++ b/src/apps/haiku-depot/PackageListView.h @@ -34,6 +34,10 @@ public: private: PackageRow* _FindRow(const PackageInfo& package, PackageRow* parent = NULL); +private: + class ItemCountView; + + ItemCountView* fItemCountView; }; #endif // PACKAGE_LIST_VIEW_H