[go: nahoru, domu]

blob: 37bed7669ef54701599b6cfcaa261227d6742f03 [file] [log] [blame]
James Cookb0bf8e82017-04-09 17:01:441// 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 Giuffrida01adeb072019-03-21 22:05:3011#include "ash/shelf/app_list_button_controller.h"
Manu Cornet40f908122018-11-08 23:15:2512#include "ash/shelf/shelf_control_button.h"
James Cookb0bf8e82017-04-09 17:01:4413#include "base/macros.h"
Ahmed Mehfooz6509620f2019-05-21 20:35:1214#include "ui/views/view_targeter_delegate.h"
xiaohuicfb5c54fc2017-06-28 17:32:0215
James Cookb0bf8e82017-04-09 17:01:4416namespace ash {
Sammie Quon9b911f2f2017-12-15 02:53:1517
James Cook840177e2017-05-25 02:20:0118class Shelf;
James Cookb0bf8e82017-04-09 17:01:4419class ShelfView;
James Cookb0bf8e82017-04-09 17:01:4420
Michael Giuffrida01adeb072019-03-21 22:05:3021// 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 Mehfooz6509620f2019-05-21 20:35:1228class ASH_EXPORT AppListButton : public ShelfControlButton,
29 public views::ViewTargeterDelegate {
James Cookb0bf8e82017-04-09 17:01:4430 public:
Manu Cornetc0066332019-02-20 19:26:0331 static const char kViewClassName[];
32
Manu Cornete363aec2019-01-13 13:07:0733 AppListButton(ShelfView* shelf_view, Shelf* shelf);
James Cookb0bf8e82017-04-09 17:01:4434 ~AppListButton() override;
35
Manu Cornete363aec2019-01-13 13:07:0736 // views::Button:
James Cookb0bf8e82017-04-09 17:01:4437 void OnGestureEvent(ui::GestureEvent* event) override;
Manu Cornetc0066332019-02-20 19:26:0338 const char* GetClassName() const override;
James Cookb0bf8e82017-04-09 17:01:4439
Michael Giuffrida01adeb072019-03-21 22:05:3040 // 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 Cookb0bf8e82017-04-09 17:01:4447 protected:
Manu Cornete363aec2019-01-13 13:07:0748 // views::Button:
Evan Stadebad2bc62017-05-30 21:53:2449 void PaintButtonContents(gfx::Canvas* canvas) override;
James Cookb0bf8e82017-04-09 17:01:4450
51 private:
Ahmed Mehfooz6509620f2019-05-21 20:35:1252 // views::ViewTargeterDelegate:
53 bool DoesIntersectRect(const views::View* target,
54 const gfx::Rect& rect) const override;
55
Michael Giuffrida01adeb072019-03-21 22:05:3056 // The controller used to determine the button's behavior.
57 AppListButtonController controller_;
Xiaohui Chen294e7bd2017-06-13 16:57:3858
James Cookb0bf8e82017-04-09 17:01:4459 DISALLOW_COPY_AND_ASSIGN(AppListButton);
60};
61
62} // namespace ash
63
64#endif // ASH_SHELF_APP_LIST_BUTTON_H_