Chromium Code Reviews| 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/shelf/app_list_button.h" | 5 #include "ash/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/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
| 10 #include "ash/common/shelf/shelf_item_types.h" | 10 #include "ash/common/shelf/shelf_item_types.h" |
| 11 #include "ash/common/shelf/shelf_types.h" | 11 #include "ash/common/shelf/shelf_types.h" |
| 12 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
| 13 #include "ash/common/system/tray/tray_constants.h" | |
| 13 #include "ash/shelf/ink_drop_button_listener.h" | 14 #include "ash/shelf/ink_drop_button_listener.h" |
| 14 #include "ash/shelf/shelf_layout_manager.h" | 15 #include "ash/shelf/shelf_layout_manager.h" |
| 15 #include "ash/shelf/shelf_view.h" | 16 #include "ash/shelf/shelf_view.h" |
| 16 #include "ash/shelf/shelf_widget.h" | 17 #include "ash/shelf/shelf_widget.h" |
| 17 #include "ash/shell.h" | 18 #include "ash/shell.h" |
| 18 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 19 #include "grit/ash_resources.h" | 20 #include "grit/ash_resources.h" |
| 20 #include "grit/ash_strings.h" | 21 #include "grit/ash_strings.h" |
| 21 #include "ui/accessibility/ax_view_state.h" | 22 #include "ui/accessibility/ax_view_state.h" |
| 22 #include "ui/app_list/app_list_switches.h" | 23 #include "ui/app_list/app_list_switches.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/base/ui_base_switches_util.h" | 26 #include "ui/base/ui_base_switches_util.h" |
| 26 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 27 #include "ui/gfx/paint_vector_icon.h" | 28 #include "ui/gfx/paint_vector_icon.h" |
| 28 #include "ui/gfx/vector_icons_public.h" | 29 #include "ui/gfx/vector_icons_public.h" |
| 29 #include "ui/views/painter.h" | 30 #include "ui/views/painter.h" |
| 30 | 31 |
| 31 namespace ash { | 32 namespace ash { |
| 32 | 33 |
| 33 // Radius of the app list button circular background. | |
| 34 const int kAppListButtonBackgroundRadius = 16; | |
| 35 | |
| 36 AppListButton::AppListButton(InkDropButtonListener* listener, | 34 AppListButton::AppListButton(InkDropButtonListener* listener, |
| 37 ShelfView* shelf_view) | 35 ShelfView* shelf_view) |
| 38 : views::ImageButton(nullptr), | 36 : views::ImageButton(nullptr), |
| 39 draw_background_as_active_(false), | 37 draw_background_as_active_(false), |
| 40 listener_(listener), | 38 listener_(listener), |
| 41 shelf_view_(shelf_view) { | 39 shelf_view_(shelf_view) { |
| 42 SetAccessibleName( | 40 SetAccessibleName( |
| 43 app_list::switches::IsExperimentalAppListEnabled() | 41 app_list::switches::IsExperimentalAppListEnabled() |
| 44 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) | 42 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) |
| 45 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); | 43 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 134 |
| 137 const ShelfWidget* shelf_widget = shelf_view_->shelf()->shelf_widget(); | 135 const ShelfWidget* shelf_widget = shelf_view_->shelf()->shelf_widget(); |
| 138 if (shelf_widget && | 136 if (shelf_widget && |
| 139 shelf_widget->GetBackgroundType() == | 137 shelf_widget->GetBackgroundType() == |
| 140 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { | 138 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { |
| 141 background_paint.setColor( | 139 background_paint.setColor( |
| 142 SkColorSetA(kShelfBaseColor, GetShelfConstant(SHELF_BACKGROUND_ALPHA))); | 140 SkColorSetA(kShelfBaseColor, GetShelfConstant(SHELF_BACKGROUND_ALPHA))); |
| 143 } | 141 } |
| 144 | 142 |
| 145 // Paint the circular background of AppList button. | 143 // Paint the circular background of AppList button. |
| 144 const int kRadius = kTrayItemSize / 2; | |
|
James Cook
2016/06/27 18:04:12
nit: elsewhere you use the style "const int radius
tdanderson
2016/06/27 21:29:42
Done.
| |
| 146 gfx::Point circle_center = GetContentsBounds().CenterPoint(); | 145 gfx::Point circle_center = GetContentsBounds().CenterPoint(); |
| 147 if (!IsHorizontalAlignment(shelf_view_->shelf()->alignment())) | 146 if (!IsHorizontalAlignment(shelf_view_->shelf()->alignment())) |
| 148 circle_center = gfx::Point(circle_center.y(), circle_center.x()); | 147 circle_center = gfx::Point(circle_center.y(), circle_center.x()); |
| 149 | 148 canvas->DrawCircle(circle_center, kRadius, background_paint); |
| 150 canvas->DrawCircle(circle_center, kAppListButtonBackgroundRadius, | |
| 151 background_paint); | |
| 152 | 149 |
| 153 if (Shell::GetInstance()->GetAppListTargetVisibility() || | 150 if (Shell::GetInstance()->GetAppListTargetVisibility() || |
| 154 draw_background_as_active_) { | 151 draw_background_as_active_) { |
| 155 SkPaint highlight_paint; | 152 SkPaint highlight_paint; |
| 156 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); | 153 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); |
| 157 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); | 154 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 158 highlight_paint.setStyle(SkPaint::kFill_Style); | 155 highlight_paint.setStyle(SkPaint::kFill_Style); |
| 159 | 156 canvas->DrawCircle(circle_center, kRadius, highlight_paint); |
| 160 canvas->DrawCircle(circle_center, kAppListButtonBackgroundRadius, | |
| 161 highlight_paint); | |
| 162 } | 157 } |
| 163 } | 158 } |
| 164 | 159 |
| 165 void AppListButton::PaintForegroundMD(gfx::Canvas* canvas, | 160 void AppListButton::PaintForegroundMD(gfx::Canvas* canvas, |
| 166 const gfx::ImageSkia& foreground_image) { | 161 const gfx::ImageSkia& foreground_image) { |
| 167 gfx::Rect foreground_bounds(foreground_image.size()); | 162 gfx::Rect foreground_bounds(foreground_image.size()); |
| 168 gfx::Rect contents_bounds = GetContentsBounds(); | 163 gfx::Rect contents_bounds = GetContentsBounds(); |
| 169 | 164 |
| 170 if (IsHorizontalAlignment(shelf_view_->shelf()->alignment())) { | 165 if (IsHorizontalAlignment(shelf_view_->shelf()->alignment())) { |
| 171 foreground_bounds.set_x( | 166 foreground_bounds.set_x( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 } | 243 } |
| 249 | 244 |
| 250 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) { | 245 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) { |
| 251 if (draw_background_as_active_ == draw_background_as_active) | 246 if (draw_background_as_active_ == draw_background_as_active) |
| 252 return; | 247 return; |
| 253 draw_background_as_active_ = draw_background_as_active; | 248 draw_background_as_active_ = draw_background_as_active; |
| 254 SchedulePaint(); | 249 SchedulePaint(); |
| 255 } | 250 } |
| 256 | 251 |
| 257 } // namespace ash | 252 } // namespace ash |
| OLD | NEW |