James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef ASH_SHELF_APP_LIST_BUTTON_H_ |
| 6 | #define ASH_SHELF_APP_LIST_BUTTON_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | |
| 10 | #include "ash/ash_export.h" |
Michael Giuffrida | 01adeb07 | 2019-03-21 22:05:30 | [diff] [blame] | 11 | #include "ash/shelf/app_list_button_controller.h" |
Manu Cornet | 40f90812 | 2018-11-08 23:15:25 | [diff] [blame] | 12 | #include "ash/shelf/shelf_control_button.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 13 | #include "base/macros.h" |
Ahmed Mehfooz | 6509620f | 2019-05-21 20:35:12 | [diff] [blame^] | 14 | #include "ui/views/view_targeter_delegate.h" |
xiaohuic | fb5c54fc | 2017-06-28 17:32:02 | [diff] [blame] | 15 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 16 | namespace ash { |
Sammie Quon | 9b911f2f | 2017-12-15 02:53:15 | [diff] [blame] | 17 | |
James Cook | 840177e | 2017-05-25 02:20:01 | [diff] [blame] | 18 | class Shelf; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 19 | class ShelfView; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 20 | |
Michael Giuffrida | 01adeb07 | 2019-03-21 22:05:30 | [diff] [blame] | 21 | // Button used for the AppList icon on the shelf. It opens the app list (in |
| 22 | // clamshell mode) or home screen (in tablet mode). Because the clamshell-mode |
| 23 | // app list appears like a dismissable overlay, the button is highlighted while |
| 24 | // the app list is open in clamshell mode. |
| 25 | // |
| 26 | // If Assistant is enabled, the button is filled in; long-pressing it will |
| 27 | // launch Assistant. |
Ahmed Mehfooz | 6509620f | 2019-05-21 20:35:12 | [diff] [blame^] | 28 | class ASH_EXPORT AppListButton : public ShelfControlButton, |
| 29 | public views::ViewTargeterDelegate { |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 30 | public: |
Manu Cornet | c006633 | 2019-02-20 19:26:03 | [diff] [blame] | 31 | static const char kViewClassName[]; |
| 32 | |
Manu Cornet | e363aec | 2019-01-13 13:07:07 | [diff] [blame] | 33 | AppListButton(ShelfView* shelf_view, Shelf* shelf); |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 34 | ~AppListButton() override; |
| 35 | |
Manu Cornet | e363aec | 2019-01-13 13:07:07 | [diff] [blame] | 36 | // views::Button: |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 37 | void OnGestureEvent(ui::GestureEvent* event) override; |
Manu Cornet | c006633 | 2019-02-20 19:26:03 | [diff] [blame] | 38 | const char* GetClassName() const override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 39 | |
Michael Giuffrida | 01adeb07 | 2019-03-21 22:05:30 | [diff] [blame] | 40 | // Called when the availability of a long-press gesture may have changed, e.g. |
| 41 | // when Assistant becomes enabled. |
| 42 | void OnVoiceInteractionAvailabilityChanged(); |
| 43 | |
| 44 | // True if the app list is shown for the display containing this button. |
| 45 | bool IsShowingAppList() const; |
| 46 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 47 | protected: |
Manu Cornet | e363aec | 2019-01-13 13:07:07 | [diff] [blame] | 48 | // views::Button: |
Evan Stade | bad2bc6 | 2017-05-30 21:53:24 | [diff] [blame] | 49 | void PaintButtonContents(gfx::Canvas* canvas) override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 50 | |
| 51 | private: |
Ahmed Mehfooz | 6509620f | 2019-05-21 20:35:12 | [diff] [blame^] | 52 | // views::ViewTargeterDelegate: |
| 53 | bool DoesIntersectRect(const views::View* target, |
| 54 | const gfx::Rect& rect) const override; |
| 55 | |
Michael Giuffrida | 01adeb07 | 2019-03-21 22:05:30 | [diff] [blame] | 56 | // The controller used to determine the button's behavior. |
| 57 | AppListButtonController controller_; |
Xiaohui Chen | 294e7bd | 2017-06-13 16:57:38 | [diff] [blame] | 58 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 59 | DISALLOW_COPY_AND_ASSIGN(AppListButton); |
| 60 | }; |
| 61 | |
| 62 | } // namespace ash |
| 63 | |
| 64 | #endif // ASH_SHELF_APP_LIST_BUTTON_H_ |