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

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

Issue 10388036: Adds the option of aligning the launcher to the left or right. There (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 8 years, 7 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_unittest.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 #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 "ash/wm/shelf_auto_hide_behavior.h"
14 #include "base/observer_list.h" 15 #include "base/observer_list.h"
15 #include "ui/views/context_menu_controller.h" 16 #include "ui/views/context_menu_controller.h"
16 #include "ui/views/controls/button/button.h" 17 #include "ui/views/controls/button/button.h"
17 #include "ui/views/focus/focus_manager.h" 18 #include "ui/views/focus/focus_manager.h"
18 #include "ui/views/view.h" 19 #include "ui/views/view.h"
19 20
20 namespace views { 21 namespace views {
21 class BoundsAnimator; 22 class BoundsAnimator;
22 class ImageButton; 23 class ImageButton;
23 class MenuRunner; 24 class MenuRunner;
(...skipping 20 matching lines...) Expand all
44 public views::ButtonListener, 45 public views::ButtonListener,
45 public LauncherButtonHost, 46 public LauncherButtonHost,
46 public views::ContextMenuController, 47 public views::ContextMenuController,
47 public views::FocusTraversable { 48 public views::FocusTraversable {
48 public: 49 public:
49 LauncherView(LauncherModel* model, LauncherDelegate* delegate); 50 LauncherView(LauncherModel* model, LauncherDelegate* delegate);
50 virtual ~LauncherView(); 51 virtual ~LauncherView();
51 52
52 void Init(); 53 void Init();
53 54
55 void SetAlignment(ShelfAlignment alignment);
56
54 // Returns the ideal bounds of the specified item, or an empty rect if id 57 // Returns the ideal bounds of the specified item, or an empty rect if id
55 // isn't know. 58 // isn't know.
56 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); 59 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id);
57 60
58 void AddIconObserver(LauncherIconObserver* observer); 61 void AddIconObserver(LauncherIconObserver* observer);
59 void RemoveIconObserver(LauncherIconObserver* observer); 62 void RemoveIconObserver(LauncherIconObserver* observer);
60 63
61 // Returns true if we're showing a menu. 64 // Returns true if we're showing a menu.
62 bool IsShowingMenu() const; 65 bool IsShowingMenu() const;
63 66
64 views::View* GetAppListButtonView() const; 67 views::View* GetAppListButtonView() const;
65 68
66 // Overridden from FocusTraversable: 69 // Overridden from FocusTraversable:
67 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; 70 virtual views::FocusSearch* GetFocusSearch() OVERRIDE;
68 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; 71 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE;
69 virtual View* GetFocusTraversableParentView() OVERRIDE; 72 virtual View* GetFocusTraversableParentView() OVERRIDE;
70 73
71 private: 74 private:
72 friend class ash::test::LauncherViewTestAPI; 75 friend class ash::test::LauncherViewTestAPI;
73 76
74 class FadeOutAnimationDelegate; 77 class FadeOutAnimationDelegate;
75 class StartFadeAnimationDelegate; 78 class StartFadeAnimationDelegate;
76 79
77 struct IdealBounds { 80 struct IdealBounds {
78 gfx::Rect overflow_bounds; 81 gfx::Rect overflow_bounds;
79 }; 82 };
80 83
84 // Used in calculating ideal bounds.
85 int primary_axis_coordinate(int x, int y) const {
86 return is_horizontal_alignment() ? x : y;
87 }
88
89 bool is_horizontal_alignment() const {
90 return alignment_ == SHELF_ALIGNMENT_BOTTOM;
91 }
92
81 // Sets the bounds of each view to its ideal bounds. 93 // Sets the bounds of each view to its ideal bounds.
82 void LayoutToIdealBounds(); 94 void LayoutToIdealBounds();
83 95
84 // Calculates the ideal bounds. The bounds of each button corresponding to an 96 // Calculates the ideal bounds. The bounds of each button corresponding to an
85 // item in the model is set in |view_model_|. 97 // item in the model is set in |view_model_|.
86 void CalculateIdealBounds(IdealBounds* bounds); 98 void CalculateIdealBounds(IdealBounds* bounds);
87 99
88 // Returns the index of the last view whose max x-coordinate is less than 100 // Returns the index of the last view whose max primary axis coordinate is
89 // |max_x|. Returns -1 if nothing fits, or there are no views. 101 // less than |max_value|. Returns -1 if nothing fits, or there are no views.
90 int DetermineLastVisibleIndex(int max_x); 102 int DetermineLastVisibleIndex(int max_value);
91 103
92 // Animates the bounds of each view to its ideal bounds. 104 // Animates the bounds of each view to its ideal bounds.
93 void AnimateToIdealBounds(); 105 void AnimateToIdealBounds();
94 106
95 // Creates the view used to represent |item|. 107 // Creates the view used to represent |item|.
96 views::View* CreateViewForItem(const LauncherItem& item); 108 views::View* CreateViewForItem(const LauncherItem& item);
97 109
98 // Fades |view| from an opacity of 0 to 1. This is when adding a new item. 110 // Fades |view| from an opacity of 0 to 1. This is when adding a new item.
99 void FadeIn(views::View* view); 111 void FadeIn(views::View* view);
100 112
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; 149 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
138 150
139 // Overridden from LauncherButtonHost: 151 // Overridden from LauncherButtonHost:
140 virtual void MousePressedOnButton(views::View* view, 152 virtual void MousePressedOnButton(views::View* view,
141 const views::MouseEvent& event) OVERRIDE; 153 const views::MouseEvent& event) OVERRIDE;
142 virtual void MouseDraggedOnButton(views::View* view, 154 virtual void MouseDraggedOnButton(views::View* view,
143 const views::MouseEvent& event) OVERRIDE; 155 const views::MouseEvent& event) OVERRIDE;
144 virtual void MouseReleasedOnButton(views::View* view, 156 virtual void MouseReleasedOnButton(views::View* view,
145 bool canceled) OVERRIDE; 157 bool canceled) OVERRIDE;
146 virtual void MouseExitedButton(views::View* view) OVERRIDE; 158 virtual void MouseExitedButton(views::View* view) OVERRIDE;
159 virtual ShelfAlignment GetShelfAlignment() const OVERRIDE;
147 virtual string16 GetAccessibleName(const views::View* view) OVERRIDE; 160 virtual string16 GetAccessibleName(const views::View* view) OVERRIDE;
148 161
149 // Overriden from views::ButtonListener: 162 // Overriden from views::ButtonListener:
150 virtual void ButtonPressed(views::Button* sender, 163 virtual void ButtonPressed(views::Button* sender,
151 const views::Event& event) OVERRIDE; 164 const views::Event& event) OVERRIDE;
152 165
153 // Overriden from views::ContextMenuController: 166 // Overriden from views::ContextMenuController:
154 virtual void ShowContextMenuForView(views::View* source, 167 virtual void ShowContextMenuForView(views::View* source,
155 const gfx::Point& point) OVERRIDE; 168 const gfx::Point& point) OVERRIDE;
156 169
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 scoped_ptr<views::FocusSearch> focus_search_; 205 scoped_ptr<views::FocusSearch> focus_search_;
193 206
194 #if !defined(OS_MACOSX) 207 #if !defined(OS_MACOSX)
195 scoped_ptr<views::MenuRunner> overflow_menu_runner_; 208 scoped_ptr<views::MenuRunner> overflow_menu_runner_;
196 209
197 scoped_ptr<views::MenuRunner> launcher_menu_runner_; 210 scoped_ptr<views::MenuRunner> launcher_menu_runner_;
198 #endif 211 #endif
199 212
200 ObserverList<LauncherIconObserver> observers_; 213 ObserverList<LauncherIconObserver> observers_;
201 214
215 ShelfAlignment alignment_;
216
202 DISALLOW_COPY_AND_ASSIGN(LauncherView); 217 DISALLOW_COPY_AND_ASSIGN(LauncherView);
203 }; 218 };
204 219
205 } // namespace internal 220 } // namespace internal
206 } // namespace ash 221 } // namespace ash
207 222
208 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ 223 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_
OLDNEW
« no previous file with comments | « ash/launcher/launcher_unittest.cc ('k') | ash/launcher/launcher_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698