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

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

Issue 10831159: Fix Ash status area bubble borders (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/web_notification/web_notification_tray.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 12 matching lines...) Expand all
23 23
24 namespace { 24 namespace {
25 25
26 // Normally a detailed view is the same size as the default view. However, 26 // Normally a detailed view is the same size as the default view. However,
27 // when showing a detailed view directly (e.g. clicking on a notification), 27 // when showing a detailed view directly (e.g. clicking on a notification),
28 // we may not know the height of the default view, or the default view may 28 // we may not know the height of the default view, or the default view may
29 // be too short, so we use this as a default and minimum height for any 29 // be too short, so we use this as a default and minimum height for any
30 // detailed view. 30 // detailed view.
31 const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5; 31 const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5;
32 32
33 // TODO(stevenjb): Remove this when TrayBubbleBorder is integrated with
34 // BubbleBorder.
jennyz 2012/08/03 18:22:50 I am working on this item, please make it TODO(jen
stevenjb 2012/08/03 19:19:56 Done.
33 class TrayPopupItemBorder : public views::Border { 35 class TrayPopupItemBorder : public views::Border {
34 public: 36 public:
35 explicit TrayPopupItemBorder(views::View* owner) : owner_(owner) {} 37 explicit TrayPopupItemBorder(views::View* owner, ShelfAlignment alignment)
38 : owner_(owner),
39 alignment_(alignment) {
40 }
36 virtual ~TrayPopupItemBorder() {} 41 virtual ~TrayPopupItemBorder() {}
37 42
38 private: 43 private:
39 // Overridden from views::Border. 44 // Overridden from views::Border.
40 virtual void Paint(const views::View& view, 45 virtual void Paint(const views::View& view,
41 gfx::Canvas* canvas) const OVERRIDE { 46 gfx::Canvas* canvas) const OVERRIDE {
42 const views::View* parent = view.parent(); 47 const views::View* parent = view.parent();
43 int index = parent->GetIndexOf(&view); 48 int index = parent->GetIndexOf(&view);
44 49
45 // Draw a dark top-border for the first item. 50 // Draw a dark top-border for the first item.
46 if (index == 0) 51 if (index == 0)
47 canvas->FillRect(gfx::Rect(0, 0, view.width(), 1), kBorderDarkColor); 52 canvas->FillRect(gfx::Rect(0, 0, view.width(), 1), kBorderDarkColor);
48 53
49 // Bottom border. 54 // Bottom border.
50 if (index != parent->child_count() - 1) { 55 if ((index != parent->child_count() - 1) ||
56 (alignment_ != SHELF_ALIGNMENT_BOTTOM)) {
51 canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1), 57 canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1),
52 kBorderLightColor); 58 kBorderLightColor);
53 } 59 }
54 60
55 // Left and right borders. 61 // Left and right borders.
56 canvas->FillRect(gfx::Rect(0, 0, 1, view.height()), kBorderDarkColor); 62 if (alignment_ != SHELF_ALIGNMENT_LEFT) {
57 canvas->FillRect(gfx::Rect(view.width() - 1, 0, 1, view.height()), 63 canvas->FillRect(gfx::Rect(0, 0, 1, view.height()),
58 kBorderDarkColor); 64 kBorderDarkColor);
65 }
66 if (alignment_ != SHELF_ALIGNMENT_RIGHT) {
67 canvas->FillRect(gfx::Rect(view.width() - 1, 0, 1, view.height()),
68 kBorderDarkColor);
69 }
59 } 70 }
60 71
61 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE { 72 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE {
62 const views::View* parent = owner_->parent(); 73 const views::View* parent = owner_->parent();
63 int index = parent->GetIndexOf(owner_); 74 int index = parent->GetIndexOf(owner_);
64 insets->Set(index == 0, 1, index != parent->child_count() - 1, 1); 75 int left = (alignment_ == SHELF_ALIGNMENT_LEFT) ? 0 : 1;
76 int right = (alignment_ == SHELF_ALIGNMENT_RIGHT) ? 0 : 1;
77 insets->Set(index == 0 ? 1 : 0,
78 left,
79 (index != parent->child_count() - 1) ? 1 : 0,
80 right);
65 } 81 }
66 82
67 views::View* owner_; 83 views::View* owner_;
84 ShelfAlignment alignment_;
68 85
69 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemBorder); 86 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemBorder);
70 }; 87 };
71 88
72 // A view with some special behaviour for tray items in the popup: 89 // A view with some special behaviour for tray items in the popup:
73 // - optionally changes background color on hover. 90 // - optionally changes background color on hover.
74 class TrayPopupItemContainer : public views::View { 91 class TrayPopupItemContainer : public views::View {
75 public: 92 public:
76 TrayPopupItemContainer(views::View* view, bool change_background) 93 TrayPopupItemContainer(views::View* view,
94 ShelfAlignment alignment,
95 bool change_background)
77 : hover_(false), 96 : hover_(false),
78 change_background_(change_background) { 97 change_background_(change_background) {
79 set_notify_enter_exit_on_child(true); 98 set_notify_enter_exit_on_child(true);
80 set_border(new TrayPopupItemBorder(this)); 99 set_border(new TrayPopupItemBorder(this, alignment));
81 views::BoxLayout* layout = new views::BoxLayout( 100 views::BoxLayout* layout = new views::BoxLayout(
82 views::BoxLayout::kVertical, 0, 0, 0); 101 views::BoxLayout::kVertical, 0, 0, 0);
83 layout->set_spread_blank_space(true); 102 layout->set_spread_blank_space(true);
84 SetLayoutManager(layout); 103 SetLayoutManager(layout);
85 SetPaintToLayer(view->layer() != NULL); 104 SetPaintToLayer(view->layer() != NULL);
86 if (view->layer()) 105 if (view->layer())
87 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely()); 106 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
88 AddChildView(view); 107 AddChildView(view);
89 SetVisible(view->visible()); 108 SetVisible(view->visible());
90 } 109 }
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 break; 397 break;
379 case BUBBLE_TYPE_DETAILED: 398 case BUBBLE_TYPE_DETAILED:
380 view = (*it)->CreateDetailedView(login_status); 399 view = (*it)->CreateDetailedView(login_status);
381 break; 400 break;
382 case BUBBLE_TYPE_NOTIFICATION: 401 case BUBBLE_TYPE_NOTIFICATION:
383 view = (*it)->CreateNotificationView(login_status); 402 view = (*it)->CreateNotificationView(login_status);
384 break; 403 break;
385 } 404 }
386 if (view) { 405 if (view) {
387 bubble_view_->AddChildView(new TrayPopupItemContainer( 406 bubble_view_->AddChildView(new TrayPopupItemContainer(
388 view, bubble_type_ == BUBBLE_TYPE_DEFAULT)); 407 view, tray_->shelf_alignment(), bubble_type_ == BUBBLE_TYPE_DEFAULT));
389 } 408 }
390 } 409 }
391 } 410 }
392 411
393 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) { 412 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) {
394 CHECK_EQ(bubble_widget_, widget); 413 CHECK_EQ(bubble_widget_, widget);
395 bubble_widget_ = NULL; 414 bubble_widget_ = NULL;
396 tray_->RemoveBubble(this); 415 tray_->RemoveBubble(this);
397 } 416 }
398 417
399 } // namespace internal 418 } // namespace internal
400 } // namespace ash 419 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/web_notification/web_notification_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698