| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shelf/overflow_button.h" | 5 #include "ash/common/shelf/overflow_button.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_constants.h" | 7 #include "ash/common/ash_constants.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/shelf/ink_drop_button_listener.h" | 9 #include "ash/common/shelf/ink_drop_button_listener.h" |
| 10 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
| 25 #include "ui/gfx/vector_icons_public.h" | 25 #include "ui/gfx/vector_icons_public.h" |
| 26 | 26 |
| 27 namespace ash { | 27 namespace ash { |
| 28 | 28 |
| 29 OverflowButton::OverflowButton(InkDropButtonListener* listener, | 29 OverflowButton::OverflowButton(InkDropButtonListener* listener, |
| 30 WmShelf* wm_shelf) | 30 WmShelf* wm_shelf) |
| 31 : CustomButton(nullptr), | 31 : CustomButton(nullptr), |
| 32 bottom_image_(nullptr), | 32 bottom_image_(nullptr), |
| 33 listener_(listener), | 33 listener_(listener), |
| 34 wm_shelf_(wm_shelf) { | 34 wm_shelf_(wm_shelf), |
| 35 background_alpha_(0) { |
| 35 if (MaterialDesignController::IsShelfMaterial()) { | 36 if (MaterialDesignController::IsShelfMaterial()) { |
| 36 bottom_image_md_ = | 37 bottom_image_md_ = |
| 37 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERFLOW, kShelfIconColor); | 38 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERFLOW, kShelfIconColor); |
| 38 bottom_image_ = &bottom_image_md_; | 39 bottom_image_ = &bottom_image_md_; |
| 39 } else { | 40 } else { |
| 40 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 41 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 41 IDR_ASH_SHELF_OVERFLOW); | 42 IDR_ASH_SHELF_OVERFLOW); |
| 42 } | 43 } |
| 43 | 44 |
| 44 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 45 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
| 45 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME)); | 46 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 OverflowButton::~OverflowButton() {} | 49 OverflowButton::~OverflowButton() {} |
| 49 | 50 |
| 50 void OverflowButton::OnShelfAlignmentChanged() { | 51 void OverflowButton::OnShelfAlignmentChanged() { |
| 51 SchedulePaint(); | 52 SchedulePaint(); |
| 52 } | 53 } |
| 53 | 54 |
| 55 void OverflowButton::SetBackgroundAlpha(int alpha) { |
| 56 background_alpha_ = alpha; |
| 57 SchedulePaint(); |
| 58 } |
| 59 |
| 54 void OverflowButton::OnPaint(gfx::Canvas* canvas) { | 60 void OverflowButton::OnPaint(gfx::Canvas* canvas) { |
| 55 gfx::Rect bounds = CalculateButtonBounds(); | 61 gfx::Rect bounds = CalculateButtonBounds(); |
| 56 PaintBackground(canvas, bounds); | 62 PaintBackground(canvas, bounds); |
| 57 PaintForeground(canvas, bounds); | 63 PaintForeground(canvas, bounds); |
| 58 } | 64 } |
| 59 | 65 |
| 60 void OverflowButton::NotifyClick(const ui::Event& event) { | 66 void OverflowButton::NotifyClick(const ui::Event& event) { |
| 61 CustomButton::NotifyClick(event); | 67 CustomButton::NotifyClick(event); |
| 62 if (listener_) | 68 if (listener_) |
| 63 listener_->ButtonPressed(this, event, ink_drop()); | 69 listener_->ButtonPressed(this, event, ink_drop()); |
| 64 } | 70 } |
| 65 | 71 |
| 66 void OverflowButton::PaintBackground(gfx::Canvas* canvas, | 72 void OverflowButton::PaintBackground(gfx::Canvas* canvas, |
| 67 const gfx::Rect& bounds) { | 73 const gfx::Rect& bounds) { |
| 68 if (MaterialDesignController::IsShelfMaterial()) { | 74 if (MaterialDesignController::IsShelfMaterial()) { |
| 69 SkColor background_color = SK_ColorTRANSPARENT; | |
| 70 if (wm_shelf_->GetBackgroundType() == | |
| 71 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { | |
| 72 background_color = SkColorSetA(kShelfBaseColor, | |
| 73 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); | |
| 74 } | |
| 75 | |
| 76 // TODO(bruthig|tdanderson): The background should be changed using a | |
| 77 // fade in/out animation. | |
| 78 SkPaint background_paint; | 75 SkPaint background_paint; |
| 79 background_paint.setFlags(SkPaint::kAntiAlias_Flag); | 76 background_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 80 background_paint.setColor(background_color); | 77 background_paint.setColor(SkColorSetA(kShelfBaseColor, background_alpha_)); |
| 81 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, | 78 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, |
| 82 background_paint); | 79 background_paint); |
| 83 | 80 |
| 84 if (wm_shelf_->IsShowingOverflowBubble()) { | 81 if (wm_shelf_->IsShowingOverflowBubble()) { |
| 85 SkPaint highlight_paint; | 82 SkPaint highlight_paint; |
| 86 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); | 83 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 87 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); | 84 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); |
| 88 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, | 85 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, |
| 89 highlight_paint); | 86 highlight_paint); |
| 90 } | 87 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 bounds = | 161 bounds = |
| 165 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, | 162 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, |
| 166 bounds.y() + kShelfItemInset, background->width(), | 163 bounds.y() + kShelfItemInset, background->width(), |
| 167 background->height()); | 164 background->height()); |
| 168 } | 165 } |
| 169 } | 166 } |
| 170 return bounds; | 167 return bounds; |
| 171 } | 168 } |
| 172 | 169 |
| 173 } // namespace ash | 170 } // namespace ash |
| OLD | NEW |