| 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 <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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 private: | 109 private: |
| 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 const static int kImageTypeDefault = 0; | |
| 118 const static int kImageTypeOnBlack = 1; | |
| 119 const static int kImageTypePressed = 2; | |
| 120 const static int kNumStates = 3; | |
| 121 | |
| 122 const static int kImageHorizontal = 0; | |
| 123 const static int kImageVertical = 1; | |
| 124 const static int kNumOrientations = 2; | |
| 125 | |
| 126 TrayBackground(TrayBackgroundView* tray_background_view, bool draws_active) | 117 TrayBackground(TrayBackgroundView* tray_background_view, bool draws_active) |
| 127 : tray_background_view_(tray_background_view), | 118 : tray_background_view_(tray_background_view), |
| 128 draws_active_(draws_active), | 119 draws_active_(draws_active), |
| 129 alpha_(0) {} | 120 alpha_(0) {} |
| 130 | 121 |
| 131 ~TrayBackground() override {} | 122 ~TrayBackground() override {} |
| 132 | 123 |
| 133 void set_alpha(int alpha) { alpha_ = alpha; } | 124 void set_alpha(int alpha) { alpha_ = alpha; } |
| 134 | 125 |
| 135 private: | 126 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 147 | 138 |
| 148 if (draws_active_ && tray_background_view_->is_active()) { | 139 if (draws_active_ && tray_background_view_->is_active()) { |
| 149 SkPaint highlight_paint; | 140 SkPaint highlight_paint; |
| 150 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); | 141 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 151 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); | 142 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); |
| 152 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_paint); | 143 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_paint); |
| 153 } | 144 } |
| 154 } | 145 } |
| 155 | 146 |
| 156 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { | 147 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { |
| 148 const static int kImageTypeDefault = 0; |
| 149 // TODO(estade): leftover type which should be removed along with the rest |
| 150 // of pre-MD code. |
| 151 // const static int kImageTypeOnBlack = 1; |
| 152 const static int kImageTypePressed = 2; |
| 153 const static int kNumStates = 3; |
| 154 |
| 155 const static int kImageHorizontal = 0; |
| 156 const static int kImageVertical = 1; |
| 157 const static int kNumOrientations = 2; |
| 158 |
| 157 const int kGridSizeForPainter = 9; | 159 const int kGridSizeForPainter = 9; |
| 160 |
| 158 const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = { | 161 const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = { |
| 159 { | 162 { |
| 160 // Horizontal | 163 // Horizontal |
| 161 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ), | 164 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ), |
| 162 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK), | 165 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK), |
| 163 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED), | 166 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED), |
| 164 }, | 167 }, |
| 165 { | 168 { |
| 166 // Vertical | 169 // Vertical |
| 167 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL), | 170 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL), |
| 168 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK), | 171 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK), |
| 169 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED), | 172 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED), |
| 170 }}; | 173 }}; |
| 171 | 174 |
| 172 WmShelf* shelf = GetShelf(); | 175 WmShelf* shelf = GetShelf(); |
| 173 const int orientation = IsHorizontalAlignment(shelf->GetAlignment()) | 176 const int orientation = IsHorizontalAlignment(shelf->GetAlignment()) |
| 174 ? kImageHorizontal | 177 ? kImageHorizontal |
| 175 : kImageVertical; | 178 : kImageVertical; |
| 176 | 179 |
| 177 int state = kImageTypeDefault; | 180 int state = kImageTypeDefault; |
| 178 if (draws_active_ && tray_background_view_->is_active()) | 181 if (draws_active_ && tray_background_view_->is_active()) |
| 179 state = kImageTypePressed; | 182 state = kImageTypePressed; |
| 180 else if (shelf->IsDimmed()) | |
| 181 state = kImageTypeOnBlack; | |
| 182 else | 183 else |
| 183 state = kImageTypeDefault; | 184 state = kImageTypeDefault; |
| 184 | 185 |
| 185 ui::CreateNineImagePainter(kImages[orientation][state]) | 186 ui::CreateNineImagePainter(kImages[orientation][state]) |
| 186 ->Paint(canvas, view->GetLocalBounds()); | 187 ->Paint(canvas, view->GetLocalBounds()); |
| 187 } | 188 } |
| 188 | 189 |
| 189 // Overridden from views::Background. | 190 // Overridden from views::Background. |
| 190 void Paint(gfx::Canvas* canvas, views::View* view) const override { | 191 void Paint(gfx::Canvas* canvas, views::View* view) const override { |
| 191 if (MaterialDesignController::IsShelfMaterial()) | 192 if (MaterialDesignController::IsShelfMaterial()) |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 645 } |
| 645 | 646 |
| 646 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 647 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
| 647 gfx::Insets insets = GetBackgroundInsets(); | 648 gfx::Insets insets = GetBackgroundInsets(); |
| 648 gfx::Rect bounds = GetLocalBounds(); | 649 gfx::Rect bounds = GetLocalBounds(); |
| 649 bounds.Inset(insets); | 650 bounds.Inset(insets); |
| 650 return bounds; | 651 return bounds; |
| 651 } | 652 } |
| 652 | 653 |
| 653 } // namespace ash | 654 } // namespace ash |
| OLD | NEW |