| 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_VIEW_H_ | 5 #ifndef ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
| 6 #define ASH_LAUNCHER_LAUNCHER_VIEW_H_ | 6 #define ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/launcher/launcher_button_host.h" | 12 #include "ash/launcher/launcher_button_host.h" |
| 13 #include "ash/launcher/launcher_model_observer.h" | 13 #include "ash/launcher/launcher_model_observer.h" |
| 14 #include "base/observer_list.h" | |
| 15 #include "ui/views/context_menu_controller.h" | 14 #include "ui/views/context_menu_controller.h" |
| 16 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
| 17 #include "ui/views/focus/focus_manager.h" | 16 #include "ui/views/focus/focus_manager.h" |
| 18 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 19 | 18 |
| 20 namespace views { | 19 namespace views { |
| 21 class BoundsAnimator; | 20 class BoundsAnimator; |
| 22 class ImageButton; | 21 class ImageButton; |
| 23 class MenuRunner; | 22 class MenuRunner; |
| 24 class ViewModel; | 23 class ViewModel; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace ash { | 26 namespace ash { |
| 28 | 27 |
| 29 class LauncherDelegate; | 28 class LauncherDelegate; |
| 30 struct LauncherItem; | 29 struct LauncherItem; |
| 31 class LauncherIconObserver; | |
| 32 class LauncherModel; | 30 class LauncherModel; |
| 33 | 31 |
| 34 namespace internal { | 32 namespace internal { |
| 35 | 33 |
| 36 class LauncherButton; | 34 class LauncherButton; |
| 37 | 35 |
| 38 class ASH_EXPORT LauncherView : public views::View, | 36 class ASH_EXPORT LauncherView : public views::View, |
| 39 public LauncherModelObserver, | 37 public LauncherModelObserver, |
| 40 public views::ButtonListener, | 38 public views::ButtonListener, |
| 41 public LauncherButtonHost, | 39 public LauncherButtonHost, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 61 | 59 |
| 62 LauncherView(LauncherModel* model, LauncherDelegate* delegate); | 60 LauncherView(LauncherModel* model, LauncherDelegate* delegate); |
| 63 virtual ~LauncherView(); | 61 virtual ~LauncherView(); |
| 64 | 62 |
| 65 void Init(); | 63 void Init(); |
| 66 | 64 |
| 67 // Returns the ideal bounds of the specified item, or an empty rect if id | 65 // Returns the ideal bounds of the specified item, or an empty rect if id |
| 68 // isn't know. | 66 // isn't know. |
| 69 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); | 67 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); |
| 70 | 68 |
| 71 void AddIconObserver(LauncherIconObserver* observer); | |
| 72 void RemoveIconObserver(LauncherIconObserver* observer); | |
| 73 | |
| 74 // Returns true if we're showing a menu. | 69 // Returns true if we're showing a menu. |
| 75 bool IsShowingMenu() const; | 70 bool IsShowingMenu() const; |
| 76 | 71 |
| 77 // Overridden from FocusTraversable: | 72 // Overridden from FocusTraversable: |
| 78 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; | 73 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; |
| 79 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; | 74 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; |
| 80 virtual View* GetFocusTraversableParentView() OVERRIDE; | 75 virtual View* GetFocusTraversableParentView() OVERRIDE; |
| 81 | 76 |
| 82 private: | 77 private: |
| 83 class FadeOutAnimationDelegate; | 78 class FadeOutAnimationDelegate; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // The model; owned by Launcher. | 162 // The model; owned by Launcher. |
| 168 LauncherModel* model_; | 163 LauncherModel* model_; |
| 169 | 164 |
| 170 // Delegate; owned by Launcher. | 165 // Delegate; owned by Launcher. |
| 171 LauncherDelegate* delegate_; | 166 LauncherDelegate* delegate_; |
| 172 | 167 |
| 173 // Used to manage the set of active launcher buttons. There is a view per | 168 // Used to manage the set of active launcher buttons. There is a view per |
| 174 // item in |model_|. | 169 // item in |model_|. |
| 175 scoped_ptr<views::ViewModel> view_model_; | 170 scoped_ptr<views::ViewModel> view_model_; |
| 176 | 171 |
| 177 // Last index of a launcher button that is visible | |
| 178 // (does not go into overflow). | |
| 179 int last_visible_index_; | |
| 180 | |
| 181 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 172 scoped_ptr<views::BoundsAnimator> bounds_animator_; |
| 182 | 173 |
| 183 views::ImageButton* overflow_button_; | 174 views::ImageButton* overflow_button_; |
| 184 | 175 |
| 185 // Are we dragging? This is only set if the mouse is dragged far enough to | 176 // Are we dragging? This is only set if the mouse is dragged far enough to |
| 186 // trigger a drag. | 177 // trigger a drag. |
| 187 bool dragging_; | 178 bool dragging_; |
| 188 | 179 |
| 189 // The view being dragged. This is set immediately when the mouse is pressed. | 180 // The view being dragged. This is set immediately when the mouse is pressed. |
| 190 // |dragging_| is set only if the mouse is dragged far enough. | 181 // |dragging_| is set only if the mouse is dragged far enough. |
| 191 views::View* drag_view_; | 182 views::View* drag_view_; |
| 192 | 183 |
| 193 // X coordinate of the mouse down event in |drag_view_|s coordinates. | 184 // X coordinate of the mouse down event in |drag_view_|s coordinates. |
| 194 int drag_offset_; | 185 int drag_offset_; |
| 195 | 186 |
| 196 // Index |drag_view_| was initially at. | 187 // Index |drag_view_| was initially at. |
| 197 int start_drag_index_; | 188 int start_drag_index_; |
| 198 | 189 |
| 199 // Used for the context menu of a particular item. | 190 // Used for the context menu of a particular item. |
| 200 LauncherID context_menu_id_; | 191 LauncherID context_menu_id_; |
| 201 | 192 |
| 202 scoped_ptr<views::FocusSearch> focus_search_; | 193 scoped_ptr<views::FocusSearch> focus_search_; |
| 203 | 194 |
| 204 #if !defined(OS_MACOSX) | 195 #if !defined(OS_MACOSX) |
| 205 scoped_ptr<views::MenuRunner> overflow_menu_runner_; | 196 scoped_ptr<views::MenuRunner> overflow_menu_runner_; |
| 206 | 197 |
| 207 scoped_ptr<views::MenuRunner> launcher_menu_runner_; | 198 scoped_ptr<views::MenuRunner> launcher_menu_runner_; |
| 208 #endif | 199 #endif |
| 209 | 200 |
| 210 ObserverList<LauncherIconObserver> observers_; | |
| 211 | |
| 212 DISALLOW_COPY_AND_ASSIGN(LauncherView); | 201 DISALLOW_COPY_AND_ASSIGN(LauncherView); |
| 213 }; | 202 }; |
| 214 | 203 |
| 215 } // namespace internal | 204 } // namespace internal |
| 216 } // namespace ash | 205 } // namespace ash |
| 217 | 206 |
| 218 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ | 207 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
| OLD | NEW |