| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/base/ui_base_switches_util.h" | 25 #include "ui/base/ui_base_switches_util.h" |
| 26 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 27 #include "ui/gfx/paint_vector_icon.h" | 27 #include "ui/gfx/paint_vector_icon.h" |
| 28 #include "ui/gfx/vector_icons_public.h" | 28 #include "ui/gfx/vector_icons_public.h" |
| 29 #include "ui/views/painter.h" | 29 #include "ui/views/painter.h" |
| 30 | 30 |
| 31 namespace ash { | 31 namespace ash { |
| 32 | 32 |
| 33 // Radius of the app list button circular background. | |
| 34 const int kAppListButtonBackgroundRadius = 16; | |
| 35 | |
| 36 AppListButton::AppListButton(InkDropButtonListener* listener, | 33 AppListButton::AppListButton(InkDropButtonListener* listener, |
| 37 ShelfView* shelf_view) | 34 ShelfView* shelf_view) |
| 38 : views::ImageButton(nullptr), | 35 : views::ImageButton(nullptr), |
| 39 draw_background_as_active_(false), | 36 draw_background_as_active_(false), |
| 40 listener_(listener), | 37 listener_(listener), |
| 41 shelf_view_(shelf_view) { | 38 shelf_view_(shelf_view) { |
| 42 SetAccessibleName( | 39 SetAccessibleName( |
| 43 app_list::switches::IsExperimentalAppListEnabled() | 40 app_list::switches::IsExperimentalAppListEnabled() |
| 44 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) | 41 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) |
| 45 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); | 42 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 shelf_widget->GetBackgroundType() == | 136 shelf_widget->GetBackgroundType() == |
| 140 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { | 137 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { |
| 141 background_paint.setColor( | 138 background_paint.setColor( |
| 142 SkColorSetA(kShelfBaseColor, GetShelfConstant(SHELF_BACKGROUND_ALPHA))); | 139 SkColorSetA(kShelfBaseColor, GetShelfConstant(SHELF_BACKGROUND_ALPHA))); |
| 143 } | 140 } |
| 144 | 141 |
| 145 // Paint the circular background of AppList button. | 142 // Paint the circular background of AppList button. |
| 146 gfx::Point circle_center = GetContentsBounds().CenterPoint(); | 143 gfx::Point circle_center = GetContentsBounds().CenterPoint(); |
| 147 if (!IsHorizontalAlignment(shelf_view_->shelf()->alignment())) | 144 if (!IsHorizontalAlignment(shelf_view_->shelf()->alignment())) |
| 148 circle_center = gfx::Point(circle_center.y(), circle_center.x()); | 145 circle_center = gfx::Point(circle_center.y(), circle_center.x()); |
| 149 | 146 canvas->DrawCircle(circle_center, kAppListButtonRadius, background_paint); |
| 150 canvas->DrawCircle(circle_center, kAppListButtonBackgroundRadius, | |
| 151 background_paint); | |
| 152 | 147 |
| 153 if (Shell::GetInstance()->GetAppListTargetVisibility() || | 148 if (Shell::GetInstance()->GetAppListTargetVisibility() || |
| 154 draw_background_as_active_) { | 149 draw_background_as_active_) { |
| 155 SkPaint highlight_paint; | 150 SkPaint highlight_paint; |
| 156 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); | 151 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); |
| 157 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); | 152 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 158 highlight_paint.setStyle(SkPaint::kFill_Style); | 153 highlight_paint.setStyle(SkPaint::kFill_Style); |
| 159 | 154 canvas->DrawCircle(circle_center, kAppListButtonRadius, highlight_paint); |
| 160 canvas->DrawCircle(circle_center, kAppListButtonBackgroundRadius, | |
| 161 highlight_paint); | |
| 162 } | 155 } |
| 163 } | 156 } |
| 164 | 157 |
| 165 void AppListButton::PaintForegroundMD(gfx::Canvas* canvas, | 158 void AppListButton::PaintForegroundMD(gfx::Canvas* canvas, |
| 166 const gfx::ImageSkia& foreground_image) { | 159 const gfx::ImageSkia& foreground_image) { |
| 167 gfx::Rect foreground_bounds(foreground_image.size()); | 160 gfx::Rect foreground_bounds(foreground_image.size()); |
| 168 gfx::Rect contents_bounds = GetContentsBounds(); | 161 gfx::Rect contents_bounds = GetContentsBounds(); |
| 169 | 162 |
| 170 if (IsHorizontalAlignment(shelf_view_->shelf()->alignment())) { | 163 if (IsHorizontalAlignment(shelf_view_->shelf()->alignment())) { |
| 171 foreground_bounds.set_x( | 164 foreground_bounds.set_x( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 241 } |
| 249 | 242 |
| 250 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) { | 243 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) { |
| 251 if (draw_background_as_active_ == draw_background_as_active) | 244 if (draw_background_as_active_ == draw_background_as_active) |
| 252 return; | 245 return; |
| 253 draw_background_as_active_ = draw_background_as_active; | 246 draw_background_as_active_ = draw_background_as_active; |
| 254 SchedulePaint(); | 247 SchedulePaint(); |
| 255 } | 248 } |
| 256 | 249 |
| 257 } // namespace ash | 250 } // namespace ash |
| OLD | NEW |