diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 23:50:37 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 23:50:37 +0000 |
commit | 3e3c50a734c08fb5ffb541a62263b3863ed417cb (patch) | |
tree | 929962ef27e52af992f993b33640330fd9ae03c9 | |
parent | e80a74d42e28be1bb47676d62e8ba16b378c9a74 (diff) | |
download | chromium_src-3e3c50a734c08fb5ffb541a62263b3863ed417cb.zip chromium_src-3e3c50a734c08fb5ffb541a62263b3863ed417cb.tar.gz chromium_src-3e3c50a734c08fb5ffb541a62263b3863ed417cb.tar.bz2 |
ash: Draw a line after the list in the uber tray sub-popups.
BUG=132880
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10560012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142529 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/system/tray/tray_details_view.cc | 47 | ||||
-rw-r--r-- | ash/system/tray/tray_details_view.h | 6 |
2 files changed, 51 insertions, 2 deletions
diff --git a/ash/system/tray/tray_details_view.cc b/ash/system/tray/tray_details_view.cc index b1fbd48..5cf8612 100644 --- a/ash/system/tray/tray_details_view.cc +++ b/ash/system/tray/tray_details_view.cc @@ -6,6 +6,7 @@ #include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_views.h" +#include "ui/gfx/canvas.h" #include "ui/views/background.h" #include "ui/views/controls/scroll_view.h" #include "ui/views/layout/box_layout.h" @@ -14,10 +15,37 @@ namespace ash { namespace internal { +class ScrollBorder : public views::Border { + public: + ScrollBorder() {} + virtual ~ScrollBorder() {} + + void set_visible(bool visible) { visible_ = visible; } + + private: + // Overridden from views::Border. + virtual void Paint(const views::View& view, + gfx::Canvas* canvas) const OVERRIDE { + if (!visible_) + return; + canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1), + kBorderLightColor); + } + + virtual void GetInsets(gfx::Insets* insets) const OVERRIDE { + insets->Set(0, 0, 1, 0); + } + + bool visible_; + + DISALLOW_COPY_AND_ASSIGN(ScrollBorder); +}; + TrayDetailsView::TrayDetailsView() : footer_(NULL), scroller_(NULL), - scroll_content_(NULL) { + scroll_content_(NULL), + scroll_border_(NULL) { SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); set_background(views::Background::CreateSolidBackground(kBackgroundColor)); @@ -41,6 +69,11 @@ void TrayDetailsView::CreateScrollableList() { views::BoxLayout::kVertical, 0, 0, 1)); scroller_ = new FixedSizedScrollView; scroller_->SetContentsView(scroll_content_); + + // Note: |scroller_| takes ownership of |scroll_border_|. + scroll_border_ = new ScrollBorder; + scroller_->set_border(scroll_border_); + AddChildView(scroller_); } @@ -74,5 +107,17 @@ void TrayDetailsView::Layout() { footer_->SetBoundsRect(fbounds); } +void TrayDetailsView::OnPaintBorder(gfx::Canvas* canvas) { + if (scroll_border_) { + int index = GetIndexOf(scroller_); + if (index < child_count() - 1 && child_at(index + 1) != footer_) + scroll_border_->set_visible(true); + else + scroll_border_->set_visible(false); + } + + views::View::OnPaintBorder(canvas); +} + } // namespace internal } // namespace ash diff --git a/ash/system/tray/tray_details_view.h b/ash/system/tray/tray_details_view.h index add338f8..044c54d 100644 --- a/ash/system/tray/tray_details_view.h +++ b/ash/system/tray/tray_details_view.h @@ -15,6 +15,7 @@ namespace ash { namespace internal { class FixedSizedScrollView; +class ScrollBorder; class SpecialPopupRow; class ViewClickListener; @@ -27,7 +28,8 @@ class TrayDetailsView : public views::View { // bottom-most row in the popup. void CreateSpecialRow(int string_id, ViewClickListener* listener); - // Creates a scrollable list. + // Creates a scrollable list. The list has a border at the bottom if there is + // any other view between the list and the footer row at the bottom. void CreateScrollableList(); // Removes (and destroys) all child views. @@ -40,11 +42,13 @@ class TrayDetailsView : public views::View { protected: // Overridden from views::View. virtual void Layout() OVERRIDE; + virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE; private: SpecialPopupRow* footer_; FixedSizedScrollView* scroller_; views::View* scroll_content_; + ScrollBorder* scroll_border_; DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); }; |