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

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: rebase 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
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | ash/system/tray/tray_details_view_unittest.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/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 return tray_background_view_->GetShelf();
110 } 108 }
111 109
112 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { 110 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const {
113 SkColor background_color = SK_ColorTRANSPARENT; 111 SkColor background_color = SK_ColorTRANSPARENT;
114 ShelfWidget* shelf_widget = GetShelfWidget(); 112 if (GetShelf()->GetBackgroundType() ==
115 if (shelf_widget && 113 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) {
116 shelf_widget->GetBackgroundType() ==
117 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) {
118 background_color = SkColorSetA(kShelfBaseColor, 114 background_color = SkColorSetA(kShelfBaseColor,
119 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); 115 GetShelfConstant(SHELF_BACKGROUND_ALPHA));
120 } 116 }
121 117
122 // TODO(bruthig|tdanderson): The background should be changed using a 118 // TODO(bruthig|tdanderson): The background should be changed using a
123 // fade in/out animation. 119 // fade in/out animation.
124 const int kCornerRadius = 2; 120 const int kCornerRadius = 2;
125 121
126 SkPaint background_paint; 122 SkPaint background_paint;
127 background_paint.setFlags(SkPaint::kAntiAlias_Flag); 123 background_paint.setFlags(SkPaint::kAntiAlias_Flag);
(...skipping 18 matching lines...) Expand all
146 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK), 142 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK),
147 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED), 143 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED),
148 }, 144 },
149 { // Vertical 145 { // Vertical
150 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL), 146 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL),
151 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK), 147 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK),
152 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED), 148 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED),
153 } 149 }
154 }; 150 };
155 151
156 int orientation = kImageHorizontal; 152 WmShelf* shelf = GetShelf();
157 ShelfWidget* shelf_widget = GetShelfWidget(); 153 const int orientation = IsHorizontalAlignment(shelf->GetAlignment())
158 if (shelf_widget && 154 ? kImageHorizontal
159 !shelf_widget->shelf_layout_manager()->IsHorizontalAlignment()) { 155 : kImageVertical;
160 orientation = kImageVertical;
161 }
162 156
163 int state = kImageTypeDefault; 157 int state = kImageTypeDefault;
164 if (tray_background_view_->draw_background_as_active()) 158 if (tray_background_view_->draw_background_as_active())
165 state = kImageTypePressed; 159 state = kImageTypePressed;
166 else if (shelf_widget && shelf_widget->GetDimsShelf()) 160 else if (shelf->IsDimmed())
167 state = kImageTypeOnBlack; 161 state = kImageTypeOnBlack;
168 else 162 else
169 state = kImageTypeDefault; 163 state = kImageTypeDefault;
170 164
171 ui::CreateNineImagePainter(kImages[orientation][state]) 165 ui::CreateNineImagePainter(kImages[orientation][state])
172 ->Paint(canvas, view->GetLocalBounds()); 166 ->Paint(canvas, view->GetLocalBounds());
173 } 167 }
174 168
175 // Overridden from views::Background. 169 // Overridden from views::Background.
176 void Paint(gfx::Canvas* canvas, views::View* view) const override { 170 void Paint(gfx::Canvas* canvas, views::View* view) const override {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 //////////////////////////////////////////////////////////////////////////////// 234 ////////////////////////////////////////////////////////////////////////////////
241 // TrayBackgroundView 235 // TrayBackgroundView
242 236
243 TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) 237 TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget)
244 : status_area_widget_(status_area_widget), 238 : status_area_widget_(status_area_widget),
245 tray_container_(NULL), 239 tray_container_(NULL),
246 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), 240 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM),
247 background_(NULL), 241 background_(NULL),
248 draw_background_as_active_(false), 242 draw_background_as_active_(false),
249 widget_observer_(new TrayWidgetObserver(this)) { 243 widget_observer_(new TrayWidgetObserver(this)) {
244 DCHECK(status_area_widget->wm_shelf());
250 set_notify_enter_exit_on_child(true); 245 set_notify_enter_exit_on_child(true);
251 246
252 tray_container_ = new TrayContainer(shelf_alignment_); 247 tray_container_ = new TrayContainer(shelf_alignment_);
253 SetContents(tray_container_); 248 SetContents(tray_container_);
254 tray_event_filter_.reset(new TrayEventFilter); 249 tray_event_filter_.reset(new TrayEventFilter);
255 250
256 SetPaintToLayer(true); 251 SetPaintToLayer(true);
257 layer()->SetFillsBoundsOpaquely(false); 252 layer()->SetFillsBoundsOpaquely(false);
258 // Start the tray items not visible, because visibility changes are animated. 253 // Start the tray items not visible, because visibility changes are animated.
259 views::View::SetVisible(false); 254 views::View::SetVisible(false);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 377
383 void TrayBackgroundView::SetContents(views::View* contents) { 378 void TrayBackgroundView::SetContents(views::View* contents) {
384 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 379 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
385 AddChildView(contents); 380 AddChildView(contents);
386 } 381 }
387 void TrayBackgroundView::SetContentsBackground() { 382 void TrayBackgroundView::SetContentsBackground() {
388 background_ = new TrayBackground(this); 383 background_ = new TrayBackground(this);
389 tray_container_->set_background(background_); 384 tray_container_->set_background(background_);
390 } 385 }
391 386
392 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { 387 WmShelf* TrayBackgroundView::GetShelf() {
393 return status_area_widget()->shelf_widget()->shelf_layout_manager(); 388 return status_area_widget_->wm_shelf();
394 } 389 }
395 390
396 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { 391 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
397 shelf_alignment_ = alignment; 392 shelf_alignment_ = alignment;
398 tray_container_->SetAlignment(alignment); 393 tray_container_->SetAlignment(alignment);
399 } 394 }
400 395
401 void TrayBackgroundView::OnImplicitAnimationsCompleted() { 396 void TrayBackgroundView::OnImplicitAnimationsCompleted() {
402 // If there is another animation in the queue, the reverse animation was 397 // 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 398 // 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; 528 return;
534 SchedulePaint(); 529 SchedulePaint();
535 } 530 }
536 531
537 void TrayBackgroundView::UpdateBubbleViewArrow( 532 void TrayBackgroundView::UpdateBubbleViewArrow(
538 views::TrayBubbleView* bubble_view) { 533 views::TrayBubbleView* bubble_view) {
539 // Nothing to do here. 534 // Nothing to do here.
540 } 535 }
541 536
542 } // namespace ash 537 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | ash/system/tray/tray_details_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698