blob: c67080173446b0790c4b6f84ad272cd04b63ef79 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// Copyright (c) 2012 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_LAUNCHER_LAUNCHER_H_
6#define ASH_LAUNCHER_LAUNCHER_H_
7
8#include "ash/ash_export.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +00009#include "ash/launcher/launcher_types.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000010#include "ash/shelf/shelf_types.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000011#include "base/basictypes.h"
12#include "base/memory/scoped_ptr.h"
13#include "ui/gfx/size.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000014#include "ui/views/widget/widget_observer.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000015
Ben Murdochbb1529c2013-08-08 10:24:53 +010016namespace app_list {
17class ApplicationDragAndDropHost;
18}
19
Torne (Richard Coles)58218062012-11-14 11:43:16 +000020namespace aura {
21class Window;
22}
23
24namespace gfx {
25class Rect;
26}
27
28namespace views {
29class View;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000030}
31
32namespace ash {
33
34namespace internal {
35class FocusCycler;
36class LauncherView;
37class ShelfLayoutManager;
38}
39
40class LauncherIconObserver;
41class LauncherDelegate;
42class LauncherModel;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000043class ShelfWidget;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000044
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000045class ASH_EXPORT Launcher {
Torne (Richard Coles)58218062012-11-14 11:43:16 +000046 public:
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010047 static const char kNativeViewName[];
48
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000049 Launcher(LauncherModel* launcher_model,
50 LauncherDelegate* launcher_delegate,
51 ShelfWidget* shelf_widget);
Torne (Richard Coles)58218062012-11-14 11:43:16 +000052 virtual ~Launcher();
53
54 // Return the launcher for the primary display. NULL if no user is
55 // logged in yet.
56 static Launcher* ForPrimaryDisplay();
57
58 // Return the launcher for the display that |window| is currently on,
59 // or a launcher on primary display if the launcher per display feature
60 // is disabled. NULL if no user is logged in yet.
61 static Launcher* ForWindow(aura::Window* window);
62
Torne (Richard Coles)58218062012-11-14 11:43:16 +000063 void SetAlignment(ShelfAlignment alignment);
64 ShelfAlignment alignment() const { return alignment_; }
65
Torne (Richard Coles)58218062012-11-14 11:43:16 +000066 // Returns the screen bounds of the item for the specified window. If there is
67 // no item for the specified window an empty rect is returned.
68 gfx::Rect GetScreenBoundsOfItemIconForWindow(aura::Window* window);
69
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000070 // Updates the icon position given the current window bounds. This is used
71 // when dragging panels to reposition them with respect to the other panels.
72 void UpdateIconPositionForWindow(aura::Window* window);
73
Torne (Richard Coles)58218062012-11-14 11:43:16 +000074 // Activates the the launcher item specified by the index in the list
75 // of launcher items.
76 void ActivateLauncherItem(int index);
77
78 // Cycles the window focus linearly over the current launcher items.
79 void CycleWindowLinear(CycleDirection direction);
80
81 void AddIconObserver(LauncherIconObserver* observer);
82 void RemoveIconObserver(LauncherIconObserver* observer);
83
84 // Returns true if the Launcher is showing a context menu.
85 bool IsShowingMenu() const;
86
Torne (Richard Coles)58218062012-11-14 11:43:16 +000087 bool IsShowingOverflowBubble() const;
88
89 void SetVisible(bool visible) const;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000090 bool IsVisible() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000091
92 views::View* GetAppListButtonView() const;
93
Ben Murdocheb525c52013-07-10 11:40:50 +010094 // Launch a 0-indexed launcher item in the Launcher.
95 // A negative index launches the last launcher item in the launcher.
96 void LaunchAppIndexAt(int item_index);
Torne (Richard Coles)58218062012-11-14 11:43:16 +000097
98 // Only to be called for testing. Retrieves the LauncherView.
99 // TODO(sky): remove this!
100 internal::LauncherView* GetLauncherViewForTest();
101
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000102 LauncherDelegate* delegate() { return delegate_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000103
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000104 ShelfWidget* shelf_widget() { return shelf_widget_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000105
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000106 // Set the bounds of the launcher view.
107 void SetLauncherViewBounds(gfx::Rect bounds);
108 gfx::Rect GetLauncherViewBounds() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000109
Ben Murdochbb1529c2013-08-08 10:24:53 +0100110 // Returns ApplicationDragAndDropHost for this Launcher.
111 app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList();
112
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000113 private:
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000114 // LauncherView used to display icons.
115 internal::LauncherView* launcher_view_;
116
117 ShelfAlignment alignment_;
118
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000119 LauncherDelegate* delegate_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000120
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000121 ShelfWidget* shelf_widget_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000122
123 DISALLOW_COPY_AND_ASSIGN(Launcher);
124};
125
126} // namespace ash
127
128#endif // ASH_LAUNCHER_LAUNCHER_H_