OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app_list_button.h" | 5 #include "ash/common/shelf/app_list_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 20 matching lines...) Expand all Loading... |
31 #include "ui/views/painter.h" | 31 #include "ui/views/painter.h" |
32 | 32 |
33 namespace ash { | 33 namespace ash { |
34 | 34 |
35 AppListButton::AppListButton(InkDropButtonListener* listener, | 35 AppListButton::AppListButton(InkDropButtonListener* listener, |
36 ShelfView* shelf_view, | 36 ShelfView* shelf_view, |
37 WmShelf* wm_shelf) | 37 WmShelf* wm_shelf) |
38 : views::ImageButton(nullptr), | 38 : views::ImageButton(nullptr), |
39 is_showing_app_list_(false), | 39 is_showing_app_list_(false), |
40 draw_background_as_active_(false), | 40 draw_background_as_active_(false), |
41 background_alpha_(0), | 41 background_color_(kShelfDefaultBaseColor), |
42 listener_(listener), | 42 listener_(listener), |
43 shelf_view_(shelf_view), | 43 shelf_view_(shelf_view), |
44 wm_shelf_(wm_shelf) { | 44 wm_shelf_(wm_shelf) { |
45 DCHECK(listener_); | 45 DCHECK(listener_); |
46 DCHECK(shelf_view_); | 46 DCHECK(shelf_view_); |
47 DCHECK(wm_shelf_); | 47 DCHECK(wm_shelf_); |
48 if (ash::MaterialDesignController::IsShelfMaterial()) { | 48 if (ash::MaterialDesignController::IsShelfMaterial()) { |
49 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 49 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
50 set_ink_drop_base_color(kShelfInkDropBaseColor); | 50 set_ink_drop_base_color(kShelfInkDropBaseColor); |
51 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 51 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
(...skipping 19 matching lines...) Expand all Loading... |
71 | 71 |
72 void AppListButton::OnAppListDismissed() { | 72 void AppListButton::OnAppListDismissed() { |
73 if (ash::MaterialDesignController::IsShelfMaterial()) | 73 if (ash::MaterialDesignController::IsShelfMaterial()) |
74 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); | 74 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); |
75 else | 75 else |
76 SchedulePaint(); | 76 SchedulePaint(); |
77 is_showing_app_list_ = false; | 77 is_showing_app_list_ = false; |
78 wm_shelf_->UpdateAutoHideState(); | 78 wm_shelf_->UpdateAutoHideState(); |
79 } | 79 } |
80 | 80 |
81 void AppListButton::SetBackgroundAlpha(int alpha) { | 81 void AppListButton::UpdateShelfItemBackground(SkColor color) { |
82 background_alpha_ = alpha; | 82 background_color_ = color; |
83 SchedulePaint(); | 83 SchedulePaint(); |
84 } | 84 } |
85 | 85 |
86 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { | 86 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { |
87 ImageButton::OnMousePressed(event); | 87 ImageButton::OnMousePressed(event); |
88 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); | 88 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); |
89 return true; | 89 return true; |
90 } | 90 } |
91 | 91 |
92 void AppListButton::OnMouseReleased(const ui::MouseEvent& event) { | 92 void AppListButton::OnMouseReleased(const ui::MouseEvent& event) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 | 159 |
160 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); | 160 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); |
161 } | 161 } |
162 | 162 |
163 void AppListButton::PaintMd(gfx::Canvas* canvas) { | 163 void AppListButton::PaintMd(gfx::Canvas* canvas) { |
164 gfx::PointF circle_center(GetCenterPoint()); | 164 gfx::PointF circle_center(GetCenterPoint()); |
165 | 165 |
166 // Paint the circular background. | 166 // Paint the circular background. |
167 cc::PaintFlags bg_flags; | 167 cc::PaintFlags bg_flags; |
168 bg_flags.setColor(SkColorSetA(kShelfBaseColor, background_alpha_)); | 168 bg_flags.setColor(background_color_); |
169 bg_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 169 bg_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); |
170 bg_flags.setStyle(cc::PaintFlags::kFill_Style); | 170 bg_flags.setStyle(cc::PaintFlags::kFill_Style); |
171 canvas->DrawCircle(circle_center, kAppListButtonRadius, bg_flags); | 171 canvas->DrawCircle(circle_center, kAppListButtonRadius, bg_flags); |
172 | 172 |
173 // Paint a white ring as the foreground. The ceil/dsf math assures that the | 173 // Paint a white ring as the foreground. The ceil/dsf math assures that the |
174 // ring draws sharply and is centered at all scale factors. | 174 // ring draws sharply and is centered at all scale factors. |
175 const float kRingOuterRadiusDp = 7.f; | 175 const float kRingOuterRadiusDp = 7.f; |
176 const float kRingThicknessDp = 1.5f; | 176 const float kRingThicknessDp = 1.5f; |
177 gfx::ScopedCanvas scoped_canvas(canvas); | 177 gfx::ScopedCanvas scoped_canvas(canvas); |
178 const float dsf = canvas->UndoDeviceScaleFactor(); | 178 const float dsf = canvas->UndoDeviceScaleFactor(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 return gfx::Point(x_mid, x_mid); | 303 return gfx::Point(x_mid, x_mid); |
304 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 304 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
305 return gfx::Point(y_mid, y_mid); | 305 return gfx::Point(y_mid, y_mid); |
306 } else { | 306 } else { |
307 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); | 307 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); |
308 return gfx::Point(width() - y_mid, y_mid); | 308 return gfx::Point(width() - y_mid, y_mid); |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 } // namespace ash | 312 } // namespace ash |
OLD | NEW |