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 17 matching lines...) Expand all Loading... |
28 #include "ui/views/animation/ink_drop_impl.h" | 28 #include "ui/views/animation/ink_drop_impl.h" |
29 #include "ui/views/animation/ink_drop_mask.h" | 29 #include "ui/views/animation/ink_drop_mask.h" |
30 | 30 |
31 namespace ash { | 31 namespace ash { |
32 | 32 |
33 OverflowButton::OverflowButton(ShelfView* shelf_view, WmShelf* wm_shelf) | 33 OverflowButton::OverflowButton(ShelfView* shelf_view, WmShelf* wm_shelf) |
34 : CustomButton(nullptr), | 34 : CustomButton(nullptr), |
35 bottom_image_(nullptr), | 35 bottom_image_(nullptr), |
36 shelf_view_(shelf_view), | 36 shelf_view_(shelf_view), |
37 wm_shelf_(wm_shelf), | 37 wm_shelf_(wm_shelf), |
38 background_alpha_(0) { | 38 background_color_(kShelfDefaultBaseColor) { |
39 DCHECK(shelf_view_); | 39 DCHECK(shelf_view_); |
40 if (MaterialDesignController::IsShelfMaterial()) { | 40 if (MaterialDesignController::IsShelfMaterial()) { |
41 SetInkDropMode(InkDropMode::ON); | 41 SetInkDropMode(InkDropMode::ON); |
42 set_ink_drop_base_color(kShelfInkDropBaseColor); | 42 set_ink_drop_base_color(kShelfInkDropBaseColor); |
43 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 43 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
44 set_hide_ink_drop_when_showing_context_menu(false); | 44 set_hide_ink_drop_when_showing_context_menu(false); |
45 bottom_image_md_ = CreateVectorIcon(kShelfOverflowIcon, kShelfIconColor); | 45 bottom_image_md_ = CreateVectorIcon(kShelfOverflowIcon, kShelfIconColor); |
46 bottom_image_ = &bottom_image_md_; | 46 bottom_image_ = &bottom_image_md_; |
47 } else { | 47 } else { |
48 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 48 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
(...skipping 15 matching lines...) Expand all Loading... |
64 if (!ash::MaterialDesignController::IsShelfMaterial()) | 64 if (!ash::MaterialDesignController::IsShelfMaterial()) |
65 SchedulePaint(); | 65 SchedulePaint(); |
66 } | 66 } |
67 | 67 |
68 void OverflowButton::OnOverflowBubbleHidden() { | 68 void OverflowButton::OnOverflowBubbleHidden() { |
69 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); | 69 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); |
70 if (!ash::MaterialDesignController::IsShelfMaterial()) | 70 if (!ash::MaterialDesignController::IsShelfMaterial()) |
71 SchedulePaint(); | 71 SchedulePaint(); |
72 } | 72 } |
73 | 73 |
74 void OverflowButton::SetBackgroundAlpha(int alpha) { | 74 void OverflowButton::UpdateShelfItemBackground(SkColor color) { |
75 background_alpha_ = alpha; | 75 background_color_ = color; |
76 SchedulePaint(); | 76 SchedulePaint(); |
77 } | 77 } |
78 | 78 |
79 void OverflowButton::OnPaint(gfx::Canvas* canvas) { | 79 void OverflowButton::OnPaint(gfx::Canvas* canvas) { |
80 gfx::Rect bounds = CalculateButtonBounds(); | 80 gfx::Rect bounds = CalculateButtonBounds(); |
81 PaintBackground(canvas, bounds); | 81 PaintBackground(canvas, bounds); |
82 PaintForeground(canvas, bounds); | 82 PaintForeground(canvas, bounds); |
83 } | 83 } |
84 | 84 |
85 std::unique_ptr<views::InkDrop> OverflowButton::CreateInkDrop() { | 85 std::unique_ptr<views::InkDrop> OverflowButton::CreateInkDrop() { |
(...skipping 28 matching lines...) Expand all Loading... |
114 gfx::Insets insets = GetLocalBounds().InsetsFrom(CalculateButtonBounds()); | 114 gfx::Insets insets = GetLocalBounds().InsetsFrom(CalculateButtonBounds()); |
115 return base::MakeUnique<views::RoundRectInkDropMask>( | 115 return base::MakeUnique<views::RoundRectInkDropMask>( |
116 size(), insets, kOverflowButtonCornerRadius); | 116 size(), insets, kOverflowButtonCornerRadius); |
117 } | 117 } |
118 | 118 |
119 void OverflowButton::PaintBackground(gfx::Canvas* canvas, | 119 void OverflowButton::PaintBackground(gfx::Canvas* canvas, |
120 const gfx::Rect& bounds) { | 120 const gfx::Rect& bounds) { |
121 if (MaterialDesignController::IsShelfMaterial()) { | 121 if (MaterialDesignController::IsShelfMaterial()) { |
122 cc::PaintFlags flags; | 122 cc::PaintFlags flags; |
123 flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 123 flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); |
124 flags.setColor(SkColorSetA(kShelfBaseColor, background_alpha_)); | 124 flags.setColor(background_color_); |
125 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, flags); | 125 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, flags); |
126 } else { | 126 } else { |
127 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 127 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
128 const gfx::ImageSkia* background = | 128 const gfx::ImageSkia* background = |
129 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); | 129 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); |
130 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); | 130 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 void OverflowButton::PaintForeground(gfx::Canvas* canvas, | 134 void OverflowButton::PaintForeground(gfx::Canvas* canvas, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 bounds = | 196 bounds = |
197 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, | 197 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, |
198 bounds.y() + kShelfItemInset, background->width(), | 198 bounds.y() + kShelfItemInset, background->width(), |
199 background->height()); | 199 background->height()); |
200 } | 200 } |
201 } | 201 } |
202 return bounds; | 202 return bounds; |
203 } | 203 } |
204 | 204 |
205 } // namespace ash | 205 } // namespace ash |
OLD | NEW |