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.
5 #ifndef ASH_SHELF_SHELF_H_
6 #define ASH_SHELF_SHELF_H_
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"
17 class ApplicationDragAndDropHost
;
36 class ShelfLayoutManager
;
45 class ShelfIconObserver
;
49 class ASH_EXPORT Shelf
{
51 static const char kNativeViewName
[];
53 Shelf(ShelfModel
* model
, ShelfDelegate
* delegate
, ShelfWidget
* widget
);
56 // Return the shelf for the primary display. NULL if no user is logged in yet.
57 static Shelf
* ForPrimaryDisplay();
59 // Return the shelf for the display that |window| is currently on, or a shelf
60 // on primary display if the shelf per display feature is disabled. NULL if
61 // no user is logged in yet.
62 static Shelf
* ForWindow(aura::Window
* window
);
64 void SetAlignment(ShelfAlignment alignment
);
65 ShelfAlignment
alignment() const { return alignment_
; }
67 // Returns the screen bounds of the item for the specified window. If there is
68 // no item for the specified window an empty rect is returned.
69 gfx::Rect
GetScreenBoundsOfItemIconForWindow(aura::Window
* window
);
71 // Updates the icon position given the current window bounds. This is used
72 // when dragging panels to reposition them with respect to the other panels.
73 void UpdateIconPositionForWindow(aura::Window
* window
);
75 // Activates the the shelf item specified by the index in the list of shelf
77 void ActivateShelfItem(int index
);
79 // Cycles the window focus linearly over the current shelf items.
80 void CycleWindowLinear(CycleDirection direction
);
82 void AddIconObserver(ShelfIconObserver
* observer
);
83 void RemoveIconObserver(ShelfIconObserver
* observer
);
85 // Returns true if the shelf is showing a context menu.
86 bool IsShowingMenu() const;
88 bool IsShowingOverflowBubble() const;
90 void SetVisible(bool visible
) const;
91 bool IsVisible() const;
95 views::View
* GetAppListButtonView() const;
97 // Launch a 0-indexed shelf item in the shelf.
98 // A negative index launches the last shelf item in the shelf.
99 void LaunchAppIndexAt(int item_index
);
101 ShelfWidget
* shelf_widget() { return shelf_widget_
; }
103 // Set the bounds of the shelf view.
104 void SetShelfViewBounds(gfx::Rect bounds
);
105 gfx::Rect
GetShelfViewBounds() const;
107 // Returns rectangle bounding all visible shelf items. Used screen coordinate
109 gfx::Rect
GetVisibleItemsBoundsInScreen() const;
111 // Returns ApplicationDragAndDropHost for this shelf.
112 app_list::ApplicationDragAndDropHost
* GetDragAndDropHostForAppList();
115 friend class test::ShelfTestAPI
;
117 // ShelfView used to display icons.
118 internal::ShelfView
* shelf_view_
;
120 ShelfAlignment alignment_
;
122 ShelfDelegate
* delegate_
;
124 ShelfWidget
* shelf_widget_
;
126 DISALLOW_COPY_AND_ASSIGN(Shelf
);
131 #endif // ASH_SHELF_SHELF_H_