Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: ash/launcher/launcher_view.h

Issue 10659003: ash: Add launcher overflow bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + fix clang Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/launcher/launcher.cc ('k') | ash/launcher/launcher_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 class LauncherDelegate; 34 class LauncherDelegate;
35 struct LauncherItem; 35 struct LauncherItem;
36 class LauncherIconObserver; 36 class LauncherIconObserver;
37 class LauncherModel; 37 class LauncherModel;
38 38
39 namespace internal { 39 namespace internal {
40 40
41 class LauncherButton; 41 class LauncherButton;
42 class LauncherTooltipManager; 42 class LauncherTooltipManager;
43 class ShelfLayoutManager; 43 class ShelfLayoutManager;
44 class OverflowBubble;
44 45
45 class ASH_EXPORT LauncherView : public views::View, 46 class ASH_EXPORT LauncherView : public views::View,
46 public LauncherModelObserver, 47 public LauncherModelObserver,
47 public views::ButtonListener, 48 public views::ButtonListener,
48 public LauncherButtonHost, 49 public LauncherButtonHost,
49 public views::ContextMenuController, 50 public views::ContextMenuController,
50 public views::FocusTraversable, 51 public views::FocusTraversable,
51 public views::BoundsAnimatorObserver { 52 public views::BoundsAnimatorObserver {
52 public: 53 public:
53 LauncherView(LauncherModel* model, 54 LauncherView(LauncherModel* model,
(...skipping 10 matching lines...) Expand all
64 // 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
65 // isn't know. 66 // isn't know.
66 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); 67 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id);
67 68
68 void AddIconObserver(LauncherIconObserver* observer); 69 void AddIconObserver(LauncherIconObserver* observer);
69 void RemoveIconObserver(LauncherIconObserver* observer); 70 void RemoveIconObserver(LauncherIconObserver* observer);
70 71
71 // Returns true if we're showing a menu. 72 // Returns true if we're showing a menu.
72 bool IsShowingMenu() const; 73 bool IsShowingMenu() const;
73 74
75 // Returns true if overflow bubble is shown.
76 bool IsShowingOverflowBubble() const;
77
74 views::View* GetAppListButtonView() const; 78 views::View* GetAppListButtonView() const;
75 79
76 // Returns true if the mouse cursor exits the area for launcher tooltip. 80 // Returns true if the mouse cursor exits the area for launcher tooltip.
77 // There are thin gaps between launcher buttons but the tooltip shouldn't hide 81 // There are thin gaps between launcher buttons but the tooltip shouldn't hide
78 // in the gaps, but the tooltip should hide if the mouse moved totally outside 82 // in the gaps, but the tooltip should hide if the mouse moved totally outside
79 // of the buttons area. 83 // of the buttons area.
80 bool ShouldHideTooltip(const gfx::Point& cursor_location); 84 bool ShouldHideTooltip(const gfx::Point& cursor_location);
81 85
86 void set_first_visible_index(int first_visible_index) {
87 first_visible_index_ = first_visible_index;
88 }
89
90 int leading_inset() const { return leading_inset_; }
91 void set_leading_inset(int leading_inset) { leading_inset_ = leading_inset; }
92
82 // Overridden from FocusTraversable: 93 // Overridden from FocusTraversable:
83 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; 94 virtual views::FocusSearch* GetFocusSearch() OVERRIDE;
84 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; 95 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE;
85 virtual View* GetFocusTraversableParentView() OVERRIDE; 96 virtual View* GetFocusTraversableParentView() OVERRIDE;
86 97
87 private: 98 private:
88 friend class ash::test::LauncherViewTestAPI; 99 friend class ash::test::LauncherViewTestAPI;
89 100
90 class FadeOutAnimationDelegate; 101 class FadeOutAnimationDelegate;
91 class StartFadeAnimationDelegate; 102 class StartFadeAnimationDelegate;
92 103
93 struct IdealBounds { 104 struct IdealBounds {
94 gfx::Rect overflow_bounds; 105 gfx::Rect overflow_bounds;
95 }; 106 };
96 107
97 // Used in calculating ideal bounds. 108 // Used in calculating ideal bounds.
98 int primary_axis_coordinate(int x, int y) const { 109 int primary_axis_coordinate(int x, int y) const {
99 return is_horizontal_alignment() ? x : y; 110 return is_horizontal_alignment() ? x : y;
100 } 111 }
101 112
102 bool is_horizontal_alignment() const { 113 bool is_horizontal_alignment() const {
103 return alignment_ == SHELF_ALIGNMENT_BOTTOM; 114 return alignment_ == SHELF_ALIGNMENT_BOTTOM;
104 } 115 }
105 116
117 bool is_overflow_mode() const {
118 return first_visible_index_ > 0;
119 }
120
106 // Sets the bounds of each view to its ideal bounds. 121 // Sets the bounds of each view to its ideal bounds.
107 void LayoutToIdealBounds(); 122 void LayoutToIdealBounds();
108 123
109 // Calculates the ideal bounds. The bounds of each button corresponding to an 124 // Calculates the ideal bounds. The bounds of each button corresponding to an
110 // item in the model is set in |view_model_|. 125 // item in the model is set in |view_model_|.
111 void CalculateIdealBounds(IdealBounds* bounds); 126 void CalculateIdealBounds(IdealBounds* bounds);
112 127
113 // Returns the index of the last view whose max primary axis coordinate is 128 // Returns the index of the last view whose max primary axis coordinate is
114 // less than |max_value|. Returns -1 if nothing fits, or there are no views. 129 // less than |max_value|. Returns -1 if nothing fits, or there are no views.
115 int DetermineLastVisibleIndex(int max_value); 130 int DetermineLastVisibleIndex(int max_value);
(...skipping 25 matching lines...) Expand all
141 // is valid, the new position of the corresponding item is returned. 156 // is valid, the new position of the corresponding item is returned.
142 int CancelDrag(int modified_index); 157 int CancelDrag(int modified_index);
143 158
144 // Common setup done for all children. 159 // Common setup done for all children.
145 void ConfigureChildView(views::View* view); 160 void ConfigureChildView(views::View* view);
146 161
147 // Returns the items whose icons are not shown because they don't fit. 162 // Returns the items whose icons are not shown because they don't fit.
148 void GetOverflowItems(std::vector<LauncherItem>* items); 163 void GetOverflowItems(std::vector<LauncherItem>* items);
149 164
150 // Shows the overflow menu. 165 // Shows the overflow menu.
151 void ShowOverflowMenu(); 166 void ShowOverflowBubble();
152 167
153 // Update first launcher button's padding. This method adds padding to the 168 // Update first launcher button's padding. This method adds padding to the
154 // first button to include the leading inset. It needs to be called once on 169 // first button to include the leading inset. It needs to be called once on
155 // button creation and every time when shelf alignment is changed. 170 // button creation and every time when shelf alignment is changed.
156 void UpdateFirstButtonPadding(); 171 void UpdateFirstButtonPadding();
157 172
158 // Overridden from views::View: 173 // Overridden from views::View:
159 virtual gfx::Size GetPreferredSize() OVERRIDE; 174 virtual gfx::Size GetPreferredSize() OVERRIDE;
160 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 175 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
161 virtual FocusTraversable* GetPaneFocusTraversable() OVERRIDE; 176 virtual FocusTraversable* GetPaneFocusTraversable() OVERRIDE;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // The model; owned by Launcher. 213 // The model; owned by Launcher.
199 LauncherModel* model_; 214 LauncherModel* model_;
200 215
201 // Delegate; owned by Launcher. 216 // Delegate; owned by Launcher.
202 LauncherDelegate* delegate_; 217 LauncherDelegate* delegate_;
203 218
204 // Used to manage the set of active launcher buttons. There is a view per 219 // Used to manage the set of active launcher buttons. There is a view per
205 // item in |model_|. 220 // item in |model_|.
206 scoped_ptr<views::ViewModel> view_model_; 221 scoped_ptr<views::ViewModel> view_model_;
207 222
223 // Index of first visible launcher item. When it it greater than 0,
224 // LauncherView is hosted in an overflow bubble. In this mode, it does not
225 // show browser, app list and overflow button.
226 int first_visible_index_;
227
208 // Last index of a launcher button that is visible 228 // Last index of a launcher button that is visible
209 // (does not go into overflow). 229 // (does not go into overflow).
210 int last_visible_index_; 230 int last_visible_index_;
211 231
212 scoped_ptr<views::BoundsAnimator> bounds_animator_; 232 scoped_ptr<views::BoundsAnimator> bounds_animator_;
213 233
214 views::ImageButton* overflow_button_; 234 views::ImageButton* overflow_button_;
215 235
236 scoped_ptr<OverflowBubble> overflow_bubble_;
237
216 scoped_ptr<LauncherTooltipManager> tooltip_; 238 scoped_ptr<LauncherTooltipManager> tooltip_;
217 239
218 // Are we dragging? This is only set if the mouse is dragged far enough to 240 // Are we dragging? This is only set if the mouse is dragged far enough to
219 // trigger a drag. 241 // trigger a drag.
220 bool dragging_; 242 bool dragging_;
221 243
222 // The view being dragged. This is set immediately when the mouse is pressed. 244 // The view being dragged. This is set immediately when the mouse is pressed.
223 // |dragging_| is set only if the mouse is dragged far enough. 245 // |dragging_| is set only if the mouse is dragged far enough.
224 views::View* drag_view_; 246 views::View* drag_view_;
225 247
226 // X coordinate of the mouse down event in |drag_view_|s coordinates. 248 // X coordinate of the mouse down event in |drag_view_|s coordinates.
227 int drag_offset_; 249 int drag_offset_;
228 250
229 // Index |drag_view_| was initially at. 251 // Index |drag_view_| was initially at.
230 int start_drag_index_; 252 int start_drag_index_;
231 253
232 // Used for the context menu of a particular item. 254 // Used for the context menu of a particular item.
233 LauncherID context_menu_id_; 255 LauncherID context_menu_id_;
234 256
235 scoped_ptr<views::FocusSearch> focus_search_; 257 scoped_ptr<views::FocusSearch> focus_search_;
236 258
237 #if !defined(OS_MACOSX) 259 #if !defined(OS_MACOSX)
238 scoped_ptr<views::MenuRunner> overflow_menu_runner_;
239
240 scoped_ptr<views::MenuRunner> launcher_menu_runner_; 260 scoped_ptr<views::MenuRunner> launcher_menu_runner_;
241 #endif 261 #endif
242 262
243 ObserverList<LauncherIconObserver> observers_; 263 ObserverList<LauncherIconObserver> observers_;
244 264
245 ShelfAlignment alignment_; 265 ShelfAlignment alignment_;
246 266
267 // Amount content is inset on the left edge (or top edge for vertical
268 // alignment).
269 int leading_inset_;
270
247 DISALLOW_COPY_AND_ASSIGN(LauncherView); 271 DISALLOW_COPY_AND_ASSIGN(LauncherView);
248 }; 272 };
249 273
250 } // namespace internal 274 } // namespace internal
251 } // namespace ash 275 } // namespace ash
252 276
253 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ 277 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_
OLDNEW
« no previous file with comments | « ash/launcher/launcher.cc ('k') | ash/launcher/launcher_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698