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

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

Issue 2072023003: mash: Break ash system tray dependencies on ash::ShelfWidget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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/tray_background_view.h" 5 #include "ash/system/tray/tray_background_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/shelf/shelf_constants.h" 8 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/shelf/wm_shelf.h"
9 #include "ash/common/shelf/wm_shelf_util.h" 10 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/common/shell_window_ids.h" 11 #include "ash/common/shell_window_ids.h"
11 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
12 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
13 #include "ash/screen_util.h" 14 #include "ash/screen_util.h"
14 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/shelf_util.h"
16 #include "ash/shelf/shelf_widget.h"
17 #include "ash/shell.h" 15 #include "ash/shell.h"
18 #include "ash/system/status_area_widget.h" 16 #include "ash/system/status_area_widget.h"
19 #include "ash/system/status_area_widget_delegate.h" 17 #include "ash/system/status_area_widget_delegate.h"
20 #include "ash/system/tray/system_tray.h" 18 #include "ash/system/tray/system_tray.h"
21 #include "ash/system/tray/tray_event_filter.h" 19 #include "ash/system/tray/tray_event_filter.h"
22 #include "ash/wm/window_animations.h" 20 #include "ash/wm/window_animations.h"
23 #include "base/command_line.h" 21 #include "base/command_line.h"
24 #include "grit/ash_resources.h" 22 #include "grit/ash_resources.h"
25 #include "ui/accessibility/ax_view_state.h" 23 #include "ui/accessibility/ax_view_state.h"
26 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const static int kImageVertical = 1; 96 const static int kImageVertical = 1;
99 const static int kNumOrientations = 2; 97 const static int kNumOrientations = 2;
100 98
101 explicit TrayBackground(TrayBackgroundView* tray_background_view) : 99 explicit TrayBackground(TrayBackgroundView* tray_background_view) :
102 tray_background_view_(tray_background_view) { 100 tray_background_view_(tray_background_view) {
103 } 101 }
104 102
105 ~TrayBackground() override {} 103 ~TrayBackground() override {}
106 104
107 private: 105 private:
108 ShelfWidget* GetShelfWidget() const { 106 WmShelf* GetShelf() const {
109 return tray_background_view_->GetShelfLayoutManager()->shelf_widget(); 107 WmShelf* shelf = tray_background_view_->GetShelf();
108 DCHECK(shelf);
msw 2016/06/17 19:58:37 q: why DCHECK here? nit: just one-line return tray
James Cook 2016/06/17 20:14:32 Done.
109 return shelf;
110 } 110 }
111 111
112 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { 112 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const {
113 SkColor background_color = SK_ColorTRANSPARENT; 113 SkColor background_color = SK_ColorTRANSPARENT;
114 ShelfWidget* shelf_widget = GetShelfWidget(); 114 if (GetShelf()->GetBackgroundType() ==
115 if (shelf_widget && 115 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) {
116 shelf_widget->GetBackgroundType() ==
117 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) {
118 background_color = SkColorSetA(kShelfBaseColor, 116 background_color = SkColorSetA(kShelfBaseColor,
119 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); 117 GetShelfConstant(SHELF_BACKGROUND_ALPHA));
120 } 118 }
121 119
122 // TODO(bruthig|tdanderson): The background should be changed using a 120 // TODO(bruthig|tdanderson): The background should be changed using a
123 // fade in/out animation. 121 // fade in/out animation.
124 const int kCornerRadius = 2; 122 const int kCornerRadius = 2;
125 123
126 SkPaint background_paint; 124 SkPaint background_paint;
127 background_paint.setFlags(SkPaint::kAntiAlias_Flag); 125 background_paint.setFlags(SkPaint::kAntiAlias_Flag);
(...skipping 18 matching lines...) Expand all
146 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK), 144 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK),
147 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED), 145 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED),
148 }, 146 },
149 { // Vertical 147 { // Vertical
150 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL), 148 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL),
151 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK), 149 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK),
152 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED), 150 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED),
153 } 151 }
154 }; 152 };
155 153
156 int orientation = kImageHorizontal; 154 WmShelf* shelf = GetShelf();
157 ShelfWidget* shelf_widget = GetShelfWidget(); 155 const int orientation = IsHorizontalAlignment(shelf->GetAlignment())
158 if (shelf_widget && 156 ? kImageHorizontal
159 !shelf_widget->shelf_layout_manager()->IsHorizontalAlignment()) { 157 : kImageVertical;
160 orientation = kImageVertical;
161 }
162 158
163 int state = kImageTypeDefault; 159 int state = kImageTypeDefault;
164 if (tray_background_view_->draw_background_as_active()) 160 if (tray_background_view_->draw_background_as_active())
165 state = kImageTypePressed; 161 state = kImageTypePressed;
166 else if (shelf_widget && shelf_widget->GetDimsShelf()) 162 else if (shelf->IsDimmed())
167 state = kImageTypeOnBlack; 163 state = kImageTypeOnBlack;
168 else 164 else
169 state = kImageTypeDefault; 165 state = kImageTypeDefault;
170 166
171 ui::CreateNineImagePainter(kImages[orientation][state]) 167 ui::CreateNineImagePainter(kImages[orientation][state])
172 ->Paint(canvas, view->GetLocalBounds()); 168 ->Paint(canvas, view->GetLocalBounds());
173 } 169 }
174 170
175 // Overridden from views::Background. 171 // Overridden from views::Background.
176 void Paint(gfx::Canvas* canvas, views::View* view) const override { 172 void Paint(gfx::Canvas* canvas, views::View* view) const override {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 //////////////////////////////////////////////////////////////////////////////// 236 ////////////////////////////////////////////////////////////////////////////////
241 // TrayBackgroundView 237 // TrayBackgroundView
242 238
243 TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) 239 TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget)
244 : status_area_widget_(status_area_widget), 240 : status_area_widget_(status_area_widget),
245 tray_container_(NULL), 241 tray_container_(NULL),
246 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), 242 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM),
247 background_(NULL), 243 background_(NULL),
248 draw_background_as_active_(false), 244 draw_background_as_active_(false),
249 widget_observer_(new TrayWidgetObserver(this)) { 245 widget_observer_(new TrayWidgetObserver(this)) {
246 DCHECK(status_area_widget->wm_shelf());
250 set_notify_enter_exit_on_child(true); 247 set_notify_enter_exit_on_child(true);
251 248
252 tray_container_ = new TrayContainer(shelf_alignment_); 249 tray_container_ = new TrayContainer(shelf_alignment_);
253 SetContents(tray_container_); 250 SetContents(tray_container_);
254 tray_event_filter_.reset(new TrayEventFilter); 251 tray_event_filter_.reset(new TrayEventFilter);
255 252
256 SetPaintToLayer(true); 253 SetPaintToLayer(true);
257 layer()->SetFillsBoundsOpaquely(false); 254 layer()->SetFillsBoundsOpaquely(false);
258 // Start the tray items not visible, because visibility changes are animated. 255 // Start the tray items not visible, because visibility changes are animated.
259 views::View::SetVisible(false); 256 views::View::SetVisible(false);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 379
383 void TrayBackgroundView::SetContents(views::View* contents) { 380 void TrayBackgroundView::SetContents(views::View* contents) {
384 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 381 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
385 AddChildView(contents); 382 AddChildView(contents);
386 } 383 }
387 void TrayBackgroundView::SetContentsBackground() { 384 void TrayBackgroundView::SetContentsBackground() {
388 background_ = new TrayBackground(this); 385 background_ = new TrayBackground(this);
389 tray_container_->set_background(background_); 386 tray_container_->set_background(background_);
390 } 387 }
391 388
392 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { 389 WmShelf* TrayBackgroundView::GetShelf() {
393 return status_area_widget()->shelf_widget()->shelf_layout_manager(); 390 return status_area_widget_->wm_shelf();
394 } 391 }
395 392
396 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { 393 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
397 shelf_alignment_ = alignment; 394 shelf_alignment_ = alignment;
398 tray_container_->SetAlignment(alignment); 395 tray_container_->SetAlignment(alignment);
399 } 396 }
400 397
401 void TrayBackgroundView::OnImplicitAnimationsCompleted() { 398 void TrayBackgroundView::OnImplicitAnimationsCompleted() {
402 // If there is another animation in the queue, the reverse animation was 399 // If there is another animation in the queue, the reverse animation was
403 // triggered before the completion of animating to invisible. Do not turn off 400 // triggered before the completion of animating to invisible. Do not turn off
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 return; 530 return;
534 SchedulePaint(); 531 SchedulePaint();
535 } 532 }
536 533
537 void TrayBackgroundView::UpdateBubbleViewArrow( 534 void TrayBackgroundView::UpdateBubbleViewArrow(
538 views::TrayBubbleView* bubble_view) { 535 views::TrayBubbleView* bubble_view) {
539 // Nothing to do here. 536 // Nothing to do here.
540 } 537 }
541 538
542 } // namespace ash 539 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698