| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_LAUNCHER_LAUNCHER_H_ | 5 #ifndef ASH_LAUNCHER_LAUNCHER_H_ |
| 6 #define ASH_LAUNCHER_LAUNCHER_H_ | 6 #define ASH_LAUNCHER_LAUNCHER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/launcher/background_animator.h" | |
| 10 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
| 11 #include "ash/shelf_types.h" | 10 #include "ash/shelf/shelf_types.h" |
| 12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 14 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
| 15 #include "ui/views/widget/widget_observer.h" | 14 #include "ui/views/widget/widget_observer.h" |
| 16 | 15 |
| 17 namespace aura { | 16 namespace aura { |
| 18 class Window; | 17 class Window; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace gfx { | 20 namespace gfx { |
| 22 class Rect; | 21 class Rect; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace views { | 24 namespace views { |
| 26 class View; | 25 class View; |
| 27 class Widget; | |
| 28 } | 26 } |
| 29 | 27 |
| 30 namespace ash { | 28 namespace ash { |
| 31 | 29 |
| 32 namespace internal { | 30 namespace internal { |
| 33 class FocusCycler; | 31 class FocusCycler; |
| 34 class LauncherView; | 32 class LauncherView; |
| 35 class ShelfLayoutManager; | 33 class ShelfLayoutManager; |
| 36 } | 34 } |
| 37 | 35 |
| 38 class LauncherIconObserver; | 36 class LauncherIconObserver; |
| 39 class LauncherDelegate; | 37 class LauncherDelegate; |
| 40 class LauncherModel; | 38 class LauncherModel; |
| 39 class ShelfWidget; |
| 41 | 40 |
| 42 class ASH_EXPORT Launcher: public views::WidgetObserver { | 41 class ASH_EXPORT Launcher { |
| 43 public: | 42 public: |
| 44 Launcher(LauncherModel* launcher_model, | 43 Launcher(LauncherModel* launcher_model, |
| 45 LauncherDelegate* launcher_delegate, | 44 LauncherDelegate* launcher_delegate, |
| 46 aura::Window* window_container, | 45 ShelfWidget* shelf_widget); |
| 47 internal::ShelfLayoutManager* shelf_layout_manager); | |
| 48 virtual ~Launcher(); | 46 virtual ~Launcher(); |
| 49 | 47 |
| 50 // Return the launcher for the primary display. NULL if no user is | 48 // Return the launcher for the primary display. NULL if no user is |
| 51 // logged in yet. | 49 // logged in yet. |
| 52 static Launcher* ForPrimaryDisplay(); | 50 static Launcher* ForPrimaryDisplay(); |
| 53 | 51 |
| 54 // Return the launcher for the display that |window| is currently on, | 52 // Return the launcher for the display that |window| is currently on, |
| 55 // or a launcher on primary display if the launcher per display feature | 53 // or a launcher on primary display if the launcher per display feature |
| 56 // is disabled. NULL if no user is logged in yet. | 54 // is disabled. NULL if no user is logged in yet. |
| 57 static Launcher* ForWindow(aura::Window* window); | 55 static Launcher* ForWindow(aura::Window* window); |
| 58 | 56 |
| 59 // Sets the focus cycler. Also adds the launcher to the cycle. | |
| 60 void SetFocusCycler(internal::FocusCycler* focus_cycler); | |
| 61 internal::FocusCycler* GetFocusCycler(); | |
| 62 | |
| 63 void SetAlignment(ShelfAlignment alignment); | 57 void SetAlignment(ShelfAlignment alignment); |
| 64 ShelfAlignment alignment() const { return alignment_; } | 58 ShelfAlignment alignment() const { return alignment_; } |
| 65 | 59 |
| 66 // Sets whether the launcher paints a background. Default is false, but is set | |
| 67 // to true if a window overlaps the shelf. | |
| 68 void SetPaintsBackground( | |
| 69 bool value, | |
| 70 internal::BackgroundAnimator::ChangeType change_type); | |
| 71 bool paints_background() const { | |
| 72 return background_animator_.paints_background(); | |
| 73 } | |
| 74 | |
| 75 // Causes shelf items to be slightly dimmed. | |
| 76 void SetDimsShelf(bool value); | |
| 77 bool GetDimsShelf() const; | |
| 78 | |
| 79 // Sets the size of the status area. | |
| 80 void SetStatusSize(const gfx::Size& size); | |
| 81 const gfx::Size& status_size() const { return status_size_; } | |
| 82 | |
| 83 // Returns the screen bounds of the item for the specified window. If there is | 60 // Returns the screen bounds of the item for the specified window. If there is |
| 84 // no item for the specified window an empty rect is returned. | 61 // no item for the specified window an empty rect is returned. |
| 85 gfx::Rect GetScreenBoundsOfItemIconForWindow(aura::Window* window); | 62 gfx::Rect GetScreenBoundsOfItemIconForWindow(aura::Window* window); |
| 86 | 63 |
| 87 // Activates the the launcher item specified by the index in the list | 64 // Activates the the launcher item specified by the index in the list |
| 88 // of launcher items. | 65 // of launcher items. |
| 89 void ActivateLauncherItem(int index); | 66 void ActivateLauncherItem(int index); |
| 90 | 67 |
| 91 // Cycles the window focus linearly over the current launcher items. | 68 // Cycles the window focus linearly over the current launcher items. |
| 92 void CycleWindowLinear(CycleDirection direction); | 69 void CycleWindowLinear(CycleDirection direction); |
| 93 | 70 |
| 94 void AddIconObserver(LauncherIconObserver* observer); | 71 void AddIconObserver(LauncherIconObserver* observer); |
| 95 void RemoveIconObserver(LauncherIconObserver* observer); | 72 void RemoveIconObserver(LauncherIconObserver* observer); |
| 96 | 73 |
| 97 // Returns true if the Launcher is showing a context menu. | 74 // Returns true if the Launcher is showing a context menu. |
| 98 bool IsShowingMenu() const; | 75 bool IsShowingMenu() const; |
| 99 | 76 |
| 100 // Show the context menu for the Launcher. | 77 // Show the context menu for the Launcher. |
| 101 void ShowContextMenu(const gfx::Point& location); | 78 void ShowContextMenu(const gfx::Point& location); |
| 102 | 79 |
| 103 bool IsShowingOverflowBubble() const; | 80 bool IsShowingOverflowBubble() const; |
| 104 | 81 |
| 105 void SetVisible(bool visible) const; | 82 void SetVisible(bool visible) const; |
| 83 bool IsVisible() const; |
| 106 | 84 |
| 107 views::View* GetAppListButtonView() const; | 85 views::View* GetAppListButtonView() const; |
| 108 | 86 |
| 109 // Sets the bounds of the launcher widget, and the dimmer if visible. | |
| 110 void SetWidgetBounds(const gfx::Rect bounds); | |
| 111 | |
| 112 // Switches to a 0-indexed (in order of creation) window. | 87 // Switches to a 0-indexed (in order of creation) window. |
| 113 // A negative index switches to the last window in the list. | 88 // A negative index switches to the last window in the list. |
| 114 void SwitchToWindow(int window_index); | 89 void SwitchToWindow(int window_index); |
| 115 | 90 |
| 116 // Only to be called for testing. Retrieves the LauncherView. | 91 // Only to be called for testing. Retrieves the LauncherView. |
| 117 // TODO(sky): remove this! | 92 // TODO(sky): remove this! |
| 118 internal::LauncherView* GetLauncherViewForTest(); | 93 internal::LauncherView* GetLauncherViewForTest(); |
| 119 | 94 |
| 120 LauncherDelegate* delegate() { return delegate_; } | 95 LauncherDelegate* delegate() { return delegate_; } |
| 121 | 96 |
| 122 views::Widget* widget() { return widget_.get(); } | 97 ShelfWidget* shelf_widget() { return shelf_widget_; } |
| 123 | 98 |
| 124 views::Widget* GetDimmerWidgetForTest() { return dimmer_.get(); } | 99 // Set the bounds of the launcher view. |
| 125 | 100 void SetLauncherViewBounds(gfx::Rect bounds); |
| 126 aura::Window* window_container() { return window_container_; } | 101 gfx::Rect GetLauncherViewBounds() const; |
| 127 | |
| 128 // Called by the activation delegate, before the launcher is activated | |
| 129 // when no other windows are visible. | |
| 130 void WillActivateAsFallback() { activating_as_fallback_ = true; } | |
| 131 | |
| 132 // Overridden from views::WidgetObserver: | |
| 133 virtual void OnWidgetActivationChanged( | |
| 134 views::Widget* widget, bool active) OVERRIDE; | |
| 135 | 102 |
| 136 private: | 103 private: |
| 137 class DelegateView; | |
| 138 class DimmerView; | |
| 139 | |
| 140 // Widget hosting the view. | |
| 141 scoped_ptr<views::Widget> widget_; | |
| 142 scoped_ptr<views::Widget> dimmer_; | |
| 143 | |
| 144 aura::Window* window_container_; | |
| 145 | |
| 146 // Contents view of the widget. Houses the LauncherView. | |
| 147 DelegateView* delegate_view_; | |
| 148 | |
| 149 // LauncherView used to display icons. | 104 // LauncherView used to display icons. |
| 150 internal::LauncherView* launcher_view_; | 105 internal::LauncherView* launcher_view_; |
| 151 | 106 |
| 152 ShelfAlignment alignment_; | 107 ShelfAlignment alignment_; |
| 153 | 108 |
| 154 LauncherDelegate* delegate_; | 109 LauncherDelegate* delegate_; |
| 155 | 110 |
| 156 // Size reserved for the status area. | 111 ShelfWidget* shelf_widget_; |
| 157 gfx::Size status_size_; | |
| 158 | |
| 159 // Used to animate the background. | |
| 160 internal::BackgroundAnimator background_animator_; | |
| 161 | |
| 162 // Used then activation is forced from the activation delegate. | |
| 163 bool activating_as_fallback_; | |
| 164 | 112 |
| 165 DISALLOW_COPY_AND_ASSIGN(Launcher); | 113 DISALLOW_COPY_AND_ASSIGN(Launcher); |
| 166 }; | 114 }; |
| 167 | 115 |
| 168 } // namespace ash | 116 } // namespace ash |
| 169 | 117 |
| 170 #endif // ASH_LAUNCHER_LAUNCHER_H_ | 118 #endif // ASH_LAUNCHER_LAUNCHER_H_ |
| OLD | NEW |