Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1 | // 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) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 9 | #include "ash/launcher/launcher_types.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 10 | #include "ash/shelf/shelf_types.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 11 | #include "base/basictypes.h" |
| 12 | #include "base/memory/scoped_ptr.h" |
| 13 | #include "ui/gfx/size.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 14 | #include "ui/views/widget/widget_observer.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 15 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 16 | namespace app_list { |
| 17 | class ApplicationDragAndDropHost; |
| 18 | } |
| 19 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 20 | namespace aura { |
| 21 | class Window; |
| 22 | } |
| 23 | |
| 24 | namespace gfx { |
| 25 | class Rect; |
| 26 | } |
| 27 | |
| 28 | namespace views { |
| 29 | class View; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | namespace ash { |
| 33 | |
| 34 | namespace internal { |
| 35 | class FocusCycler; |
| 36 | class LauncherView; |
| 37 | class ShelfLayoutManager; |
| 38 | } |
| 39 | |
| 40 | class LauncherIconObserver; |
| 41 | class LauncherDelegate; |
| 42 | class LauncherModel; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 43 | class ShelfWidget; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 44 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 45 | class ASH_EXPORT Launcher { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 46 | public: |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 47 | static const char kNativeViewName[]; |
| 48 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 49 | Launcher(LauncherModel* launcher_model, |
| 50 | LauncherDelegate* launcher_delegate, |
| 51 | ShelfWidget* shelf_widget); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 52 | 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) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 63 | void SetAlignment(ShelfAlignment alignment); |
| 64 | ShelfAlignment alignment() const { return alignment_; } |
| 65 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 66 | // 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) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 70 | // 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) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 74 | // 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) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 87 | bool IsShowingOverflowBubble() const; |
| 88 | |
| 89 | void SetVisible(bool visible) const; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 90 | bool IsVisible() const; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 91 | |
| 92 | views::View* GetAppListButtonView() const; |
| 93 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 94 | // 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) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 97 | |
| 98 | // Only to be called for testing. Retrieves the LauncherView. |
| 99 | // TODO(sky): remove this! |
| 100 | internal::LauncherView* GetLauncherViewForTest(); |
| 101 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 102 | LauncherDelegate* delegate() { return delegate_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 103 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 104 | ShelfWidget* shelf_widget() { return shelf_widget_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 105 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 106 | // Set the bounds of the launcher view. |
| 107 | void SetLauncherViewBounds(gfx::Rect bounds); |
| 108 | gfx::Rect GetLauncherViewBounds() const; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 109 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 110 | // Returns ApplicationDragAndDropHost for this Launcher. |
| 111 | app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList(); |
| 112 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 113 | private: |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 114 | // LauncherView used to display icons. |
| 115 | internal::LauncherView* launcher_view_; |
| 116 | |
| 117 | ShelfAlignment alignment_; |
| 118 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 119 | LauncherDelegate* delegate_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 120 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 121 | ShelfWidget* shelf_widget_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 122 | |
| 123 | DISALLOW_COPY_AND_ASSIGN(Launcher); |
| 124 | }; |
| 125 | |
| 126 | } // namespace ash |
| 127 | |
| 128 | #endif // ASH_LAUNCHER_LAUNCHER_H_ |