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

Side by Side Diff: ash/common/system/tray/tray_background_view.cc

Issue 2679133003: [ash-md] Wired in the Shelf color to be derived from the Wallpaper. (Closed)
Patch Set: Addressed nits. Created 3 years, 10 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
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/common/system/tray/tray_background_view.h" 5 #include "ash/common/system/tray/tray_background_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/ash_constants.h" 9 #include "ash/common/ash_constants.h"
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 TrayBackgroundView* host_; 110 TrayBackgroundView* host_;
111 111
112 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); 112 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver);
113 }; 113 };
114 114
115 class TrayBackground : public views::Background { 115 class TrayBackground : public views::Background {
116 public: 116 public:
117 TrayBackground(TrayBackgroundView* tray_background_view, bool draws_active) 117 TrayBackground(TrayBackgroundView* tray_background_view, bool draws_active)
118 : tray_background_view_(tray_background_view), 118 : tray_background_view_(tray_background_view),
119 draws_active_(draws_active), 119 draws_active_(draws_active),
120 alpha_(0) {} 120 color_(SK_ColorTRANSPARENT) {}
121 121
122 ~TrayBackground() override {} 122 ~TrayBackground() override {}
123 123
124 void set_alpha(int alpha) { alpha_ = alpha; } 124 void set_color(SkColor color) { color_ = color; }
125 125
126 private: 126 private:
127 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } 127 WmShelf* GetShelf() const { return tray_background_view_->shelf(); }
128 128
129 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { 129 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const {
130 cc::PaintFlags background_flags; 130 cc::PaintFlags background_flags;
131 background_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); 131 background_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag);
132 background_flags.setColor(SkColorSetA(kShelfBaseColor, alpha_)); 132 background_flags.setColor(color_);
133 gfx::Insets insets = 133 gfx::Insets insets =
134 GetMirroredBackgroundInsets(GetShelf()->GetAlignment()); 134 GetMirroredBackgroundInsets(GetShelf()->GetAlignment());
135 gfx::Rect bounds = view->GetLocalBounds(); 135 gfx::Rect bounds = view->GetLocalBounds();
136 bounds.Inset(insets); 136 bounds.Inset(insets);
137 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags); 137 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags);
138 138
139 if (draws_active_ && tray_background_view_->is_active()) { 139 if (draws_active_ && tray_background_view_->is_active()) {
140 cc::PaintFlags highlight_flags; 140 cc::PaintFlags highlight_flags;
141 highlight_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); 141 highlight_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag);
142 highlight_flags.setColor(kShelfButtonActivatedHighlightColor); 142 highlight_flags.setColor(kShelfButtonActivatedHighlightColor);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // Reference to the TrayBackgroundView for which this is a background. 198 // Reference to the TrayBackgroundView for which this is a background.
199 TrayBackgroundView* tray_background_view_; 199 TrayBackgroundView* tray_background_view_;
200 200
201 // Determines whether we should draw an active background for the view when it 201 // Determines whether we should draw an active background for the view when it
202 // is active. This is used in non-MD mode. In material design mode, an active 202 // is active. This is used in non-MD mode. In material design mode, an active
203 // ink drop ripple would indicate if the view is active or not. 203 // ink drop ripple would indicate if the view is active or not.
204 // TODO(mohsen): This is used only in non-MD version. Remove when non-MD code 204 // TODO(mohsen): This is used only in non-MD version. Remove when non-MD code
205 // is removed (see https://crbug.com/614453). 205 // is removed (see https://crbug.com/614453).
206 bool draws_active_; 206 bool draws_active_;
207 207
208 int alpha_; 208 SkColor color_;
209 209
210 DISALLOW_COPY_AND_ASSIGN(TrayBackground); 210 DISALLOW_COPY_AND_ASSIGN(TrayBackground);
211 }; 211 };
212 212
213 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) 213 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment)
214 : alignment_(alignment) { 214 : alignment_(alignment) {
215 UpdateLayout(); 215 UpdateLayout();
216 } 216 }
217 217
218 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { 218 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // TODO(mohsen): This is needed for non-MD version. Remove when non-MD code is 507 // TODO(mohsen): This is needed for non-MD version. Remove when non-MD code is
508 // removed (see https://crbug.com/614453). 508 // removed (see https://crbug.com/614453).
509 SchedulePaint(); 509 SchedulePaint();
510 } 510 }
511 511
512 void TrayBackgroundView::UpdateBubbleViewArrow( 512 void TrayBackgroundView::UpdateBubbleViewArrow(
513 views::TrayBubbleView* bubble_view) { 513 views::TrayBubbleView* bubble_view) {
514 // Nothing to do here. 514 // Nothing to do here.
515 } 515 }
516 516
517 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { 517 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) {
518 if (background_) { 518 if (background_) {
519 background_->set_alpha(alpha); 519 background_->set_color(color);
520 SchedulePaint(); 520 SchedulePaint();
521 } 521 }
522 } 522 }
523 523
524 views::View* TrayBackgroundView::GetBubbleAnchor() const { 524 views::View* TrayBackgroundView::GetBubbleAnchor() const {
525 return tray_container_; 525 return tray_container_;
526 } 526 }
527 527
528 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const { 528 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const {
529 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets(); 529 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 633 }
634 634
635 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { 635 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const {
636 gfx::Insets insets = GetBackgroundInsets(); 636 gfx::Insets insets = GetBackgroundInsets();
637 gfx::Rect bounds = GetLocalBounds(); 637 gfx::Rect bounds = GetLocalBounds();
638 bounds.Inset(insets); 638 bounds.Inset(insets);
639 return bounds; 639 return bounds;
640 } 640 }
641 641
642 } // namespace ash 642 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_background_view.h ('k') | ash/common/wallpaper/wallpaper_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698