| 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 <memory> |    7 #include <memory> | 
|    8 #include <utility> |    8 #include <utility> | 
|    9  |    9  | 
|   10 #include "ash/public/cpp/shelf_types.h" |   10 #include "ash/public/cpp/shelf_types.h" | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|   37                              Shelf* shelf) |   37                              Shelf* shelf) | 
|   38     : views::ImageButton(nullptr), |   38     : views::ImageButton(nullptr), | 
|   39       is_showing_app_list_(false), |   39       is_showing_app_list_(false), | 
|   40       background_color_(kShelfDefaultBaseColor), |   40       background_color_(kShelfDefaultBaseColor), | 
|   41       listener_(listener), |   41       listener_(listener), | 
|   42       shelf_view_(shelf_view), |   42       shelf_view_(shelf_view), | 
|   43       shelf_(shelf) { |   43       shelf_(shelf) { | 
|   44   DCHECK(listener_); |   44   DCHECK(listener_); | 
|   45   DCHECK(shelf_view_); |   45   DCHECK(shelf_view_); | 
|   46   DCHECK(shelf_); |   46   DCHECK(shelf_); | 
|   47  |   47   Shell::Get()->AddShellObserver(this); | 
|   48   SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |   48   SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 
|   49   set_ink_drop_base_color(kShelfInkDropBaseColor); |   49   set_ink_drop_base_color(kShelfInkDropBaseColor); | 
|   50   set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |   50   set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 
|   51   SetAccessibleName( |   51   SetAccessibleName( | 
|   52       l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)); |   52       l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)); | 
|   53   SetSize(gfx::Size(kShelfSize, kShelfSize)); |   53   SetSize(gfx::Size(kShelfSize, kShelfSize)); | 
|   54   SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); |   54   SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); | 
|   55   set_notify_action(CustomButton::NOTIFY_ON_PRESS); |   55   set_notify_action(CustomButton::NOTIFY_ON_PRESS); | 
|   56 } |   56 } | 
|   57  |   57  | 
|   58 AppListButton::~AppListButton() {} |   58 AppListButton::~AppListButton() { | 
 |   59   Shell::Get()->RemoveShellObserver(this); | 
 |   60 } | 
|   59  |   61  | 
|   60 void AppListButton::OnAppListShown() { |   62 void AppListButton::OnAppListShown() { | 
|   61   AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); |   63   AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); | 
|   62   is_showing_app_list_ = true; |   64   is_showing_app_list_ = true; | 
|   63   shelf_->UpdateAutoHideState(); |   65   shelf_->UpdateAutoHideState(); | 
|   64 } |   66 } | 
|   65  |   67  | 
|   66 void AppListButton::OnAppListDismissed() { |   68 void AppListButton::OnAppListDismissed() { | 
|   67   AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); |   69   AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); | 
|   68   is_showing_app_list_ = false; |   70   is_showing_app_list_ = false; | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  232       alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { |  234       alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 
|  233     return gfx::Point(x_mid, x_mid); |  235     return gfx::Point(x_mid, x_mid); | 
|  234   } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |  236   } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 
|  235     return gfx::Point(y_mid, y_mid); |  237     return gfx::Point(y_mid, y_mid); | 
|  236   } else { |  238   } else { | 
|  237     DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); |  239     DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); | 
|  238     return gfx::Point(width() - y_mid, y_mid); |  240     return gfx::Point(width() - y_mid, y_mid); | 
|  239   } |  241   } | 
|  240 } |  242 } | 
|  241  |  243  | 
 |  244 void AppListButton::OnAppListVisibilityChanged(bool shown, | 
 |  245                                                aura::Window* root_window) { | 
 |  246   if (shelf_ != Shelf::ForWindow(root_window)) | 
 |  247     return; | 
 |  248  | 
 |  249   if (shown) | 
 |  250     OnAppListShown(); | 
 |  251   else | 
 |  252     OnAppListDismissed(); | 
 |  253 } | 
 |  254  | 
|  242 }  // namespace ash |  255 }  // namespace ash | 
| OLD | NEW |