• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
9 #include "ash/launcher/launcher_types.h"
10 #include "ash/shelf/shelf_types.h"
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/gfx/size.h"
14 #include "ui/views/widget/widget_observer.h"
15 
16 namespace app_list {
17 class ApplicationDragAndDropHost;
18 }
19 
20 namespace aura {
21 class Window;
22 }
23 
24 namespace gfx {
25 class Rect;
26 }
27 
28 namespace views {
29 class View;
30 }
31 
32 namespace ash {
33 
34 namespace internal {
35 class FocusCycler;
36 class ShelfLayoutManager;
37 class ShelfView;
38 }
39 
40 namespace test {
41 class LauncherTestAPI;
42 }
43 
44 class ShelfDelegate;
45 class ShelfIconObserver;
46 class ShelfModel;
47 class ShelfWidget;
48 
49 class ASH_EXPORT Launcher {
50  public:
51   static const char kNativeViewName[];
52 
53   Launcher(ShelfModel* model, ShelfDelegate* delegate, ShelfWidget* widget);
54   virtual ~Launcher();
55 
56   // Return the launcher for the primary display. NULL if no user is
57   // logged in yet.
58   static Launcher* ForPrimaryDisplay();
59 
60   // Return the launcher for the display that |window| is currently on,
61   // or a launcher on primary display if the launcher per display feature
62   // is disabled. NULL if no user is logged in yet.
63   static Launcher* ForWindow(aura::Window* window);
64 
65   void SetAlignment(ShelfAlignment alignment);
alignment()66   ShelfAlignment alignment() const { return alignment_; }
67 
68   // Returns the screen bounds of the item for the specified window. If there is
69   // no item for the specified window an empty rect is returned.
70   gfx::Rect GetScreenBoundsOfItemIconForWindow(aura::Window* window);
71 
72   // Updates the icon position given the current window bounds. This is used
73   // when dragging panels to reposition them with respect to the other panels.
74   void UpdateIconPositionForWindow(aura::Window* window);
75 
76   // Activates the the launcher item specified by the index in the list
77   // of launcher items.
78   void ActivateLauncherItem(int index);
79 
80   // Cycles the window focus linearly over the current launcher items.
81   void CycleWindowLinear(CycleDirection direction);
82 
83   void AddIconObserver(ShelfIconObserver* observer);
84   void RemoveIconObserver(ShelfIconObserver* observer);
85 
86   // Returns true if the Launcher is showing a context menu.
87   bool IsShowingMenu() const;
88 
89   bool IsShowingOverflowBubble() const;
90 
91   void SetVisible(bool visible) const;
92   bool IsVisible() const;
93 
94   void SchedulePaint();
95 
96   views::View* GetAppListButtonView() const;
97 
98   // Launch a 0-indexed launcher item in the Launcher.
99   // A negative index launches the last launcher item in the launcher.
100   void LaunchAppIndexAt(int item_index);
101 
shelf_widget()102   ShelfWidget* shelf_widget() { return shelf_widget_; }
103 
104   // Set the bounds of the shelf view.
105   void SetShelfViewBounds(gfx::Rect bounds);
106   gfx::Rect GetShelfViewBounds() const;
107 
108   // Returns rectangle bounding all visible launcher items. Used screen
109   // coordinate system.
110   gfx::Rect GetVisibleItemsBoundsInScreen() const;
111 
112   // Returns ApplicationDragAndDropHost for this Launcher.
113   app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList();
114 
115  private:
116   friend class ash::test::LauncherTestAPI;
117 
118   // ShelfView used to display icons.
119   internal::ShelfView* shelf_view_;
120 
121   ShelfAlignment alignment_;
122 
123   ShelfDelegate* delegate_;
124 
125   ShelfWidget* shelf_widget_;
126 
127   DISALLOW_COPY_AND_ASSIGN(Launcher);
128 };
129 
130 }  // namespace ash
131 
132 #endif  // ASH_LAUNCHER_LAUNCHER_H_
133