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