OLD | NEW |
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 "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.h" |
10 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { | 99 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { |
100 SkColor background_color = SK_ColorTRANSPARENT; | 100 SkColor background_color = SK_ColorTRANSPARENT; |
101 if (GetShelf()->GetBackgroundType() == | 101 if (GetShelf()->GetBackgroundType() == |
102 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { | 102 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { |
103 background_color = SkColorSetA(kShelfBaseColor, | 103 background_color = SkColorSetA(kShelfBaseColor, |
104 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); | 104 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); |
105 } | 105 } |
106 | 106 |
107 // TODO(bruthig|tdanderson): The background should be changed using a | 107 // TODO(bruthig|tdanderson): The background should be changed using a |
108 // fade in/out animation. | 108 // fade in/out animation. |
109 const int kCornerRadius = 2; | |
110 | |
111 SkPaint background_paint; | 109 SkPaint background_paint; |
112 background_paint.setFlags(SkPaint::kAntiAlias_Flag); | 110 background_paint.setFlags(SkPaint::kAntiAlias_Flag); |
113 background_paint.setColor(background_color); | 111 background_paint.setColor(background_color); |
114 canvas->DrawRoundRect(view->GetLocalBounds(), kCornerRadius, | 112 canvas->DrawRoundRect(view->GetLocalBounds(), kTrayRoundedBorderRadius, |
115 background_paint); | 113 background_paint); |
116 | 114 |
117 if (tray_background_view_->draw_background_as_active()) { | 115 if (tray_background_view_->draw_background_as_active()) { |
118 SkPaint highlight_paint; | 116 SkPaint highlight_paint; |
119 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); | 117 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); |
120 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); | 118 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); |
121 canvas->DrawRoundRect(view->GetLocalBounds(), kCornerRadius, | 119 canvas->DrawRoundRect(view->GetLocalBounds(), kTrayRoundedBorderRadius, |
122 highlight_paint); | 120 highlight_paint); |
123 } | 121 } |
124 } | 122 } |
125 | 123 |
126 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { | 124 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { |
127 const int kGridSizeForPainter = 9; | 125 const int kGridSizeForPainter = 9; |
128 const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = { | 126 const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = { |
129 { | 127 { |
130 // Horizontal | 128 // Horizontal |
131 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ), | 129 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) { | 194 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) { |
197 PreferredSizeChanged(); | 195 PreferredSizeChanged(); |
198 } | 196 } |
199 | 197 |
200 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( | 198 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( |
201 const ViewHierarchyChangedDetails& details) { | 199 const ViewHierarchyChangedDetails& details) { |
202 if (details.parent == this) | 200 if (details.parent == this) |
203 PreferredSizeChanged(); | 201 PreferredSizeChanged(); |
204 } | 202 } |
205 | 203 |
206 // TODO(tdanderson): Adjust TrayContainer borders according to the material | |
207 // design specs. See crbug.com/617295. | |
208 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 204 void TrayBackgroundView::TrayContainer::UpdateLayout() { |
209 // Adjust the size of status tray dark background by adding additional | 205 // Adjust the size of status tray dark background by adding additional |
210 // empty border. | 206 // empty border. |
211 views::BoxLayout::Orientation orientation = | 207 views::BoxLayout::Orientation orientation = |
212 IsHorizontalAlignment(alignment_) ? views::BoxLayout::kHorizontal | 208 IsHorizontalAlignment(alignment_) ? views::BoxLayout::kHorizontal |
213 : views::BoxLayout::kVertical; | 209 : views::BoxLayout::kVertical; |
214 SetBorder(views::Border::CreateEmptyBorder( | 210 |
215 kAdjustBackgroundPadding, kAdjustBackgroundPadding, | 211 if (!ash::MaterialDesignController::IsShelfMaterial()) { |
216 kAdjustBackgroundPadding, kAdjustBackgroundPadding)); | 212 // Additional padding used to adjust the user-visible size of status tray |
| 213 // dark background. |
| 214 const int padding = 3; |
| 215 SetBorder( |
| 216 views::Border::CreateEmptyBorder(padding, padding, padding, padding)); |
| 217 } |
217 | 218 |
218 views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0); | 219 views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0); |
219 layout->SetDefaultFlex(1); | 220 layout->SetDefaultFlex(1); |
220 views::View::SetLayoutManager(layout); | 221 views::View::SetLayoutManager(layout); |
221 PreferredSizeChanged(); | 222 PreferredSizeChanged(); |
222 } | 223 } |
223 | 224 |
224 //////////////////////////////////////////////////////////////////////////////// | 225 //////////////////////////////////////////////////////////////////////////////// |
225 // TrayBackgroundView | 226 // TrayBackgroundView |
226 | 227 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 return; | 504 return; |
504 SchedulePaint(); | 505 SchedulePaint(); |
505 } | 506 } |
506 | 507 |
507 void TrayBackgroundView::UpdateBubbleViewArrow( | 508 void TrayBackgroundView::UpdateBubbleViewArrow( |
508 views::TrayBubbleView* bubble_view) { | 509 views::TrayBubbleView* bubble_view) { |
509 // Nothing to do here. | 510 // Nothing to do here. |
510 } | 511 } |
511 | 512 |
512 } // namespace ash | 513 } // namespace ash |
OLD | NEW |