| 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 15 matching lines...) Expand all Loading... |
| 26 #include "ui/views/animation/ink_drop_impl.h" | 26 #include "ui/views/animation/ink_drop_impl.h" |
| 27 #include "ui/views/animation/ink_drop_mask.h" | 27 #include "ui/views/animation/ink_drop_mask.h" |
| 28 #include "ui/views/painter.h" | 28 #include "ui/views/painter.h" |
| 29 | 29 |
| 30 namespace ash { | 30 namespace ash { |
| 31 | 31 |
| 32 AppListButton::AppListButton(InkDropButtonListener* listener, | 32 AppListButton::AppListButton(InkDropButtonListener* listener, |
| 33 ShelfView* shelf_view, | 33 ShelfView* shelf_view, |
| 34 WmShelf* wm_shelf) | 34 WmShelf* wm_shelf) |
| 35 : views::ImageButton(nullptr), | 35 : views::ImageButton(nullptr), |
| 36 draw_background_as_active_(false), | |
| 37 background_alpha_(0), | |
| 38 listener_(listener), | 36 listener_(listener), |
| 39 shelf_view_(shelf_view), | 37 shelf_view_(shelf_view), |
| 40 wm_shelf_(wm_shelf) { | 38 wm_shelf_(wm_shelf) { |
| 41 DCHECK(listener_); | 39 DCHECK(listener_); |
| 42 DCHECK(shelf_view_); | 40 DCHECK(shelf_view_); |
| 43 DCHECK(wm_shelf_); | 41 DCHECK(wm_shelf_); |
| 44 if (ash::MaterialDesignController::IsShelfMaterial()) { | 42 if (ash::MaterialDesignController::IsShelfMaterial()) { |
| 45 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 43 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
| 46 set_ink_drop_base_color(kShelfInkDropBaseColor); | 44 set_ink_drop_base_color(kShelfInkDropBaseColor); |
| 47 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 45 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
| 48 } | 46 } |
| 49 SetAccessibleName( | 47 SetAccessibleName( |
| 50 l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)); | 48 l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)); |
| 51 SetSize( | 49 SetSize( |
| 52 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE))); | 50 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE))); |
| 53 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 51 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 54 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); | 52 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); |
| 55 set_notify_action(CustomButton::NOTIFY_ON_PRESS); | 53 set_notify_action(CustomButton::NOTIFY_ON_PRESS); |
| 56 } | 54 } |
| 57 | 55 |
| 58 AppListButton::~AppListButton() {} | 56 AppListButton::~AppListButton() {} |
| 59 | 57 |
| 60 void AppListButton::OnAppListShown() { | 58 void AppListButton::OnAppListShown() { |
| 61 if (ash::MaterialDesignController::IsShelfMaterial()) | 59 if (ash::MaterialDesignController::IsShelfMaterial()) |
| 62 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); | 60 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); |
| 63 else | 61 else |
| 64 SchedulePaint(); | 62 SchedulePaint(); |
| 63 is_showing_app_list_ = true; |
| 64 wm_shelf_->UpdateAutoHideState(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void AppListButton::OnAppListDismissed() { | 67 void AppListButton::OnAppListDismissed() { |
| 68 if (ash::MaterialDesignController::IsShelfMaterial()) | 68 if (ash::MaterialDesignController::IsShelfMaterial()) |
| 69 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); | 69 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); |
| 70 else | 70 else |
| 71 SchedulePaint(); | 71 SchedulePaint(); |
| 72 is_showing_app_list_ = false; |
| 73 wm_shelf_->UpdateAutoHideState(); |
| 72 } | 74 } |
| 73 | 75 |
| 74 void AppListButton::SetBackgroundAlpha(int alpha) { | 76 void AppListButton::SetBackgroundAlpha(int alpha) { |
| 75 background_alpha_ = alpha; | 77 background_alpha_ = alpha; |
| 76 SchedulePaint(); | 78 SchedulePaint(); |
| 77 } | 79 } |
| 78 | 80 |
| 79 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { | 81 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { |
| 80 ImageButton::OnMousePressed(event); | 82 ImageButton::OnMousePressed(event); |
| 81 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); | 83 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 int center = std::max(width(), height()) / 2.f; | 292 int center = std::max(width(), height()) / 2.f; |
| 291 gfx::Point centroid(center, center); | 293 gfx::Point centroid(center, center); |
| 292 // For the left shelf alignment, we need to right-justify. For other shelf | 294 // For the left shelf alignment, we need to right-justify. For other shelf |
| 293 // alignments, left/top justification (i.e. no adjustments are necessary). | 295 // alignments, left/top justification (i.e. no adjustments are necessary). |
| 294 if (SHELF_ALIGNMENT_LEFT == wm_shelf_->GetAlignment()) | 296 if (SHELF_ALIGNMENT_LEFT == wm_shelf_->GetAlignment()) |
| 295 centroid.set_x(width() - center); | 297 centroid.set_x(width() - center); |
| 296 return centroid; | 298 return centroid; |
| 297 } | 299 } |
| 298 | 300 |
| 299 } // namespace ash | 301 } // namespace ash |
| OLD | NEW |