| 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/ash_constants.h" | 7 #include "ash/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_item_types.h" | 9 #include "ash/common/shelf/shelf_item_types.h" |
| 10 #include "ash/shelf/ink_drop_button_listener.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 11 #include "ash/shelf/shelf_view.h" | 12 #include "ash/shelf/shelf_view.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 13 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 15 #include "grit/ash_resources.h" | 16 #include "grit/ash_resources.h" |
| 16 #include "grit/ash_strings.h" | 17 #include "grit/ash_strings.h" |
| 17 #include "ui/accessibility/ax_view_state.h" | 18 #include "ui/accessibility/ax_view_state.h" |
| 18 #include "ui/app_list/app_list_switches.h" | 19 #include "ui/app_list/app_list_switches.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/base/ui_base_switches_util.h" | 22 #include "ui/base/ui_base_switches_util.h" |
| 22 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/paint_vector_icon.h" | 24 #include "ui/gfx/paint_vector_icon.h" |
| 24 #include "ui/gfx/vector_icons_public.h" | 25 #include "ui/gfx/vector_icons_public.h" |
| 25 #include "ui/views/painter.h" | 26 #include "ui/views/painter.h" |
| 26 | 27 |
| 27 namespace ash { | 28 namespace ash { |
| 28 | 29 |
| 29 AppListButton::AppListButton(ShelfView* shelf_view) | 30 AppListButton::AppListButton(InkDropButtonListener* listener, |
| 30 : views::ImageButton(shelf_view), | 31 ShelfView* shelf_view) |
| 32 : views::ImageButton(nullptr), |
| 31 draw_background_as_active_(false), | 33 draw_background_as_active_(false), |
| 34 listener_(listener), |
| 32 shelf_view_(shelf_view) { | 35 shelf_view_(shelf_view) { |
| 33 SetAccessibleName( | 36 SetAccessibleName( |
| 34 app_list::switches::IsExperimentalAppListEnabled() | 37 app_list::switches::IsExperimentalAppListEnabled() |
| 35 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) | 38 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) |
| 36 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); | 39 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); |
| 37 SetSize(gfx::Size(kShelfSize, kShelfSize)); | 40 SetSize(gfx::Size(kShelfSize, kShelfSize)); |
| 38 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 41 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 39 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); | 42 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); |
| 40 set_notify_action(CustomButton::NOTIFY_ON_PRESS); | 43 set_notify_action(CustomButton::NOTIFY_ON_PRESS); |
| 41 } | 44 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 foreground_bounds.y()); | 161 foreground_bounds.y()); |
| 159 | 162 |
| 160 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); | 163 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); |
| 161 } | 164 } |
| 162 | 165 |
| 163 void AppListButton::GetAccessibleState(ui::AXViewState* state) { | 166 void AppListButton::GetAccessibleState(ui::AXViewState* state) { |
| 164 state->role = ui::AX_ROLE_BUTTON; | 167 state->role = ui::AX_ROLE_BUTTON; |
| 165 state->name = shelf_view_->GetTitleForView(this); | 168 state->name = shelf_view_->GetTitleForView(this); |
| 166 } | 169 } |
| 167 | 170 |
| 171 void AppListButton::NotifyClick(const ui::Event& event) { |
| 172 ImageButton::NotifyClick(event); |
| 173 if (listener_) |
| 174 listener_->ButtonPressed(this, event, ink_drop()); |
| 175 } |
| 176 |
| 168 void AppListButton::SetDrawBackgroundAsActive( | 177 void AppListButton::SetDrawBackgroundAsActive( |
| 169 bool draw_background_as_active) { | 178 bool draw_background_as_active) { |
| 170 if (draw_background_as_active_ == draw_background_as_active) | 179 if (draw_background_as_active_ == draw_background_as_active) |
| 171 return; | 180 return; |
| 172 draw_background_as_active_ = draw_background_as_active; | 181 draw_background_as_active_ = draw_background_as_active; |
| 173 SchedulePaint(); | 182 SchedulePaint(); |
| 174 } | 183 } |
| 175 | 184 |
| 176 } // namespace ash | 185 } // namespace ash |
| OLD | NEW |