Home | History | Annotate | Download | only in launcher
      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 LauncherView;
     37 class ShelfLayoutManager;
     38 }
     39 
     40 class LauncherIconObserver;
     41 class LauncherDelegate;
     42 class LauncherModel;
     43 class ShelfWidget;
     44 
     45 class ASH_EXPORT Launcher {
     46  public:
     47   static const char kNativeViewName[];
     48 
     49   Launcher(LauncherModel* launcher_model,
     50            LauncherDelegate* launcher_delegate,
     51            ShelfWidget* shelf_widget);
     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 
     63   void SetAlignment(ShelfAlignment alignment);
     64   ShelfAlignment alignment() const { return alignment_; }
     65 
     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 
     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 
     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 
     87   bool IsShowingOverflowBubble() const;
     88 
     89   void SetVisible(bool visible) const;
     90   bool IsVisible() const;
     91 
     92   void SchedulePaint();
     93 
     94   views::View* GetAppListButtonView() const;
     95 
     96   // Launch a 0-indexed launcher item in the Launcher.
     97   // A negative index launches the last launcher item in the launcher.
     98   void LaunchAppIndexAt(int item_index);
     99 
    100   // Only to be called for testing. Retrieves the LauncherView.
    101   // TODO(sky): remove this!
    102   internal::LauncherView* GetLauncherViewForTest();
    103 
    104   LauncherDelegate* delegate() { return delegate_; }
    105 
    106   ShelfWidget* shelf_widget() { return shelf_widget_; }
    107 
    108   // Set the bounds of the launcher view.
    109   void SetLauncherViewBounds(gfx::Rect bounds);
    110   gfx::Rect GetLauncherViewBounds() const;
    111 
    112   // Returns ApplicationDragAndDropHost for this Launcher.
    113   app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList();
    114 
    115  private:
    116   // LauncherView used to display icons.
    117   internal::LauncherView* launcher_view_;
    118 
    119   ShelfAlignment alignment_;
    120 
    121   LauncherDelegate* delegate_;
    122 
    123   ShelfWidget* shelf_widget_;
    124 
    125   DISALLOW_COPY_AND_ASSIGN(Launcher);
    126 };
    127 
    128 }  // namespace ash
    129 
    130 #endif  // ASH_LAUNCHER_LAUNCHER_H_
    131