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

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

Issue 10566003: ash: Fix arrow color for 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') | ash/system/tray/tray_views.cc » ('J')
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 int index = parent->GetIndexOf(owner_); 66 int index = parent->GetIndexOf(owner_);
67 insets->Set(index == 0, 1, index != parent->child_count() - 1, 1); 67 insets->Set(index == 0, 1, index != parent->child_count() - 1, 1);
68 } 68 }
69 69
70 views::View* owner_; 70 views::View* owner_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemBorder); 72 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemBorder);
73 }; 73 };
74 74
75 // A view with some special behaviour for tray items in the popup: 75 // A view with some special behaviour for tray items in the popup:
76 // - changes background color on hover. 76 // - optionally changes background color on hover.
77 class TrayPopupItemContainer : public views::View { 77 class TrayPopupItemContainer : public views::View {
78 public: 78 public:
79 explicit TrayPopupItemContainer(views::View* view) : hover_(false) { 79 TrayPopupItemContainer(views::View* view, bool change_background)
80 : hover_(false),
81 change_background_(change_background) {
80 set_notify_enter_exit_on_child(true); 82 set_notify_enter_exit_on_child(true);
81 set_border(new TrayPopupItemBorder(this)); 83 set_border(new TrayPopupItemBorder(this));
82 views::BoxLayout* layout = new views::BoxLayout( 84 views::BoxLayout* layout = new views::BoxLayout(
83 views::BoxLayout::kVertical, 0, 0, 0); 85 views::BoxLayout::kVertical, 0, 0, 0);
84 layout->set_spread_blank_space(true); 86 layout->set_spread_blank_space(true);
85 SetLayoutManager(layout); 87 SetLayoutManager(layout);
86 SetPaintToLayer(view->layer() != NULL); 88 SetPaintToLayer(view->layer() != NULL);
87 if (view->layer()) 89 if (view->layer())
88 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely()); 90 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
89 AddChildView(view); 91 AddChildView(view);
(...skipping 24 matching lines...) Expand all
114 hover_ = false; 116 hover_ = false;
115 SchedulePaint(); 117 SchedulePaint();
116 } 118 }
117 119
118 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE { 120 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE {
119 if (child_count() == 0) 121 if (child_count() == 0)
120 return; 122 return;
121 123
122 views::View* view = child_at(0); 124 views::View* view = child_at(0);
123 if (!view->background()) { 125 if (!view->background()) {
124 canvas->FillRect(gfx::Rect(size()), 126 canvas->FillRect(gfx::Rect(size()), (hover_ && change_background_) ?
125 hover_ ? kHoverBackgroundColor : kBackgroundColor); 127 kHoverBackgroundColor : kBackgroundColor);
126 } 128 }
127 } 129 }
128 130
129 bool hover_; 131 bool hover_;
132 bool change_background_;
130 133
131 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemContainer); 134 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemContainer);
132 }; 135 };
133 136
134 // Implicit animation observer that deletes itself and the layer at the end of 137 // Implicit animation observer that deletes itself and the layer at the end of
135 // the animation. 138 // the animation.
136 class AnimationObserverDeleteLayer : public ui::ImplicitAnimationObserver { 139 class AnimationObserverDeleteLayer : public ui::ImplicitAnimationObserver {
137 public: 140 public:
138 explicit AnimationObserverDeleteLayer(ui::Layer* layer) 141 explicit AnimationObserverDeleteLayer(ui::Layer* layer)
139 : layer_(layer) { 142 : layer_(layer) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 case BUBBLE_TYPE_DEFAULT: 448 case BUBBLE_TYPE_DEFAULT:
446 view = (*it)->CreateDefaultView(login_status); 449 view = (*it)->CreateDefaultView(login_status);
447 break; 450 break;
448 case BUBBLE_TYPE_DETAILED: 451 case BUBBLE_TYPE_DETAILED:
449 view = (*it)->CreateDetailedView(login_status); 452 view = (*it)->CreateDetailedView(login_status);
450 break; 453 break;
451 case BUBBLE_TYPE_NOTIFICATION: 454 case BUBBLE_TYPE_NOTIFICATION:
452 view = (*it)->CreateNotificationView(login_status); 455 view = (*it)->CreateNotificationView(login_status);
453 break; 456 break;
454 } 457 }
455 if (view) 458 if (view) {
456 bubble_view_->AddChildView(new TrayPopupItemContainer(view)); 459 bubble_view_->AddChildView(new TrayPopupItemContainer(
460 view, bubble_type_ == BUBBLE_TYPE_DEFAULT));
461 }
457 } 462 }
458 } 463 }
459 464
460 bool SystemTrayBubble::ProcessLocatedEvent(const aura::LocatedEvent& event) { 465 bool SystemTrayBubble::ProcessLocatedEvent(const aura::LocatedEvent& event) {
461 DCHECK_NE(BUBBLE_TYPE_NOTIFICATION, bubble_type_); 466 DCHECK_NE(BUBBLE_TYPE_NOTIFICATION, bubble_type_);
462 gfx::Rect bounds = bubble_widget_->GetNativeWindow()->GetBoundsInRootWindow(); 467 gfx::Rect bounds = bubble_widget_->GetNativeWindow()->GetBoundsInRootWindow();
463 if (bounds.Contains(event.root_location())) 468 if (bounds.Contains(event.root_location()))
464 return false; 469 return false;
465 470
466 bubble_widget_->Close(); 471 bubble_widget_->Close();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 507 }
503 508
504 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) { 509 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) {
505 CHECK_EQ(bubble_widget_, widget); 510 CHECK_EQ(bubble_widget_, widget);
506 bubble_widget_ = NULL; 511 bubble_widget_ = NULL;
507 tray_->RemoveBubble(this); 512 tray_->RemoveBubble(this);
508 } 513 }
509 514
510 } // namespace internal 515 } // namespace internal
511 } // namespace ash 516 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/tray_bubble_view.cc » ('j') | ash/system/tray/tray_views.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698