Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: ash/system/tray/system_tray_bubble.cc

Issue 10546147: ash: Fix the border colors in the uber-tray popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/system/tray/tray_bubble_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/tray/system_tray_bubble.h" 5 #include "ash/system/tray/system_tray_bubble.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ash/system/tray/system_tray_item.h" 10 #include "ash/system/tray/system_tray_item.h"
(...skipping 15 matching lines...) Expand all
26 26
27 const int kAnimationDurationForPopupMS = 200; 27 const int kAnimationDurationForPopupMS = 200;
28 28
29 // Normally a detailed view is the same size as the default view. However, 29 // Normally a detailed view is the same size as the default view. However,
30 // when showing a detailed view directly (e.g. clicking on a notification), 30 // when showing a detailed view directly (e.g. clicking on a notification),
31 // we may not know the height of the default view, or the default view may 31 // we may not know the height of the default view, or the default view may
32 // be too short, so we use this as a default and minimum height for any 32 // be too short, so we use this as a default and minimum height for any
33 // detailed view. 33 // detailed view.
34 const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5; 34 const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5;
35 35
36 class TrayPopupItemBorder : public views::Border {
37 public:
38 explicit TrayPopupItemBorder(views::View* owner) : owner_(owner) {}
39 virtual ~TrayPopupItemBorder() {}
40
41 private:
42 // Overridden from views::Border.
43 virtual void Paint(const views::View& view,
44 gfx::Canvas* canvas) const OVERRIDE {
45 const views::View* parent = view.parent();
sky 2012/06/13 16:22:35 Do you really ever paint with no parent?
sadrul 2012/06/13 16:39:20 Good point. Removed this NULL check
46 if (!parent)
47 return;
48 int index = parent->GetIndexOf(&view);
49
50 // Draw a dark top-border for the first item.
51 if (index == 0)
52 canvas->FillRect(gfx::Rect(0, 0, view.width(), 1), kBorderDarkColor);
53
54 // Bottom border.
55 if (index != parent->child_count() - 1) {
56 canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1),
57 kBorderLightColor);
58 }
59
60 // Left and right borders.
61 canvas->FillRect(gfx::Rect(0, 0, 1, view.height()), kBorderDarkColor);
62 canvas->FillRect(gfx::Rect(view.width() - 1, 0, 1, view.height()),
63 kBorderDarkColor);
64 }
65
66 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE {
67 const views::View* parent = owner_->parent();
68 if (!parent)
69 return;
70 int index = parent->GetIndexOf(owner_);
71 insets->Set(index == 0, 1, index != parent->child_count() - 1, 1);
72 }
73
74 views::View* owner_;
75
76 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemBorder);
77 };
78
36 // A view with some special behaviour for tray items in the popup: 79 // A view with some special behaviour for tray items in the popup:
37 // - changes background color on hover. 80 // - changes background color on hover.
38 class TrayPopupItemContainer : public views::View { 81 class TrayPopupItemContainer : public views::View {
39 public: 82 public:
40 explicit TrayPopupItemContainer(views::View* view) : hover_(false) { 83 explicit TrayPopupItemContainer(views::View* view) : hover_(false) {
41 set_notify_enter_exit_on_child(true); 84 set_notify_enter_exit_on_child(true);
42 set_border(view->border() ? views::Border::CreateEmptyBorder(0, 0, 0, 0) : 85 set_border(new TrayPopupItemBorder(this));
43 views::Border::CreateSolidSidedBorder(1, 1, 0, 1, kBorderDarkColor));
44 views::BoxLayout* layout = new views::BoxLayout( 86 views::BoxLayout* layout = new views::BoxLayout(
45 views::BoxLayout::kVertical, 0, 0, 0); 87 views::BoxLayout::kVertical, 0, 0, 0);
46 layout->set_spread_blank_space(true); 88 layout->set_spread_blank_space(true);
47 SetLayoutManager(layout); 89 SetLayoutManager(layout);
48 SetPaintToLayer(view->layer() != NULL); 90 SetPaintToLayer(view->layer() != NULL);
49 if (view->layer()) 91 if (view->layer())
50 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely()); 92 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
51 AddChildView(view); 93 AddChildView(view);
52 SetVisible(view->visible()); 94 SetVisible(view->visible());
53 } 95 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 492 }
451 493
452 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) { 494 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) {
453 CHECK_EQ(bubble_widget_, widget); 495 CHECK_EQ(bubble_widget_, widget);
454 bubble_widget_ = NULL; 496 bubble_widget_ = NULL;
455 tray_->RemoveBubble(this); 497 tray_->RemoveBubble(this);
456 } 498 }
457 499
458 } // namespace internal 500 } // namespace internal
459 } // namespace ash 501 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/tray_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698