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

Side by Side Diff: chrome/browser/views/tabs/tab_overview_controller.h

Issue 126185: Improved tab overview animations with better animation and wiring to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_
6 #define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_ 6 #define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_
7 7
8 #include "base/gfx/rect.h" 8 #include "base/gfx/rect.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "chrome/browser/tabs/tab_strip_model.h" 10 #include "chrome/browser/tabs/tab_strip_model.h"
11 11
12 class Animation;
12 class Browser; 13 class Browser;
13 class TabOverviewCell; 14 class TabOverviewCell;
14 class TabOverviewContainer; 15 class TabOverviewContainer;
15 class TabOverviewGrid; 16 class TabOverviewGrid;
16 17
17 namespace views { 18 namespace views {
18 class Widget; 19 class Widget;
19 } 20 }
20 21
21 // TabOverviewController is responsible for showing a TabOverviewGrid and 22 // TabOverviewController is responsible for showing a TabOverviewGrid and
22 // keeping it in sync with the TabStripModel of a browser. 23 // keeping it in sync with the TabStripModel of a browser.
23 class TabOverviewController : public TabStripModelObserver { 24 class TabOverviewController : public TabStripModelObserver {
24 public: 25 public:
25 // Creates a TabOverviewController that will be shown on the monitor 26 // Creates a TabOverviewController that will be shown on the monitor
26 // containing |monitor_origin|. 27 // containing |monitor_origin|.
27 explicit TabOverviewController(const gfx::Point& monitor_origin); 28 explicit TabOverviewController(const gfx::Point& monitor_origin);
28 ~TabOverviewController(); 29 ~TabOverviewController();
29 30
30 // Sets the browser we're showing the tab strip for. 31 // Sets the browser we're showing the tab strip for. |horizontal_center|
31 void SetBrowser(Browser* browser); 32 // gives the center of the window.
33 void SetBrowser(Browser* browser, int horizontal_center);
32 Browser* browser() const { return browser_; } 34 Browser* browser() const { return browser_; }
33 TabOverviewGrid* grid() const { return grid_; } 35 TabOverviewGrid* grid() const { return grid_; }
34 TabStripModel* model() const; 36 TabStripModel* model() const;
35 37
36 // Returns true if the grid has been moved off screen. The grid is moved 38 // Returns true if the grid has been moved off screen. The grid is moved
37 // offscren if the user detaches the last tab in the tab strip. 39 // offscren if the user detaches the last tab in the tab strip.
38 bool moved_offscreen() const { return moved_offscreen_; } 40 bool moved_offscreen() const { return moved_offscreen_; }
39 41
40 // Shows the grid. 42 // Shows the grid.
41 void Show(); 43 void Show();
42 44
43 // Configures a cell from the model. 45 // Configures a cell from the model.
44 void ConfigureCell(TabOverviewCell* cell, TabContents* contents); 46 void ConfigureCell(TabOverviewCell* cell, TabContents* contents);
45 47
46 // Invoked from TabOverviewDragController. 48 // Invoked from TabOverviewDragController.
47 virtual void DragStarted(); 49 void DragStarted();
48 virtual void DragEnded(); 50 void DragEnded();
49 virtual void MoveOffscreen(); 51 void MoveOffscreen();
50 virtual void SelectTabContents(TabContents* contents); 52 void SelectTabContents(TabContents* contents);
53
54 // Forwarded from TabOverviewGrid as the animation of the grid changes.
55 void GridAnimationEnded();
56 void GridAnimationProgressed();
57 void GridAnimationCanceled();
51 58
52 // TabStripModelObserver overrides. 59 // TabStripModelObserver overrides.
53 virtual void TabInsertedAt(TabContents* contents, 60 virtual void TabInsertedAt(TabContents* contents,
54 int index, 61 int index,
55 bool foreground); 62 bool foreground);
56 virtual void TabClosingAt(TabContents* contents, int index); 63 virtual void TabClosingAt(TabContents* contents, int index);
57 virtual void TabDetachedAt(TabContents* contents, int index); 64 virtual void TabDetachedAt(TabContents* contents, int index);
58 virtual void TabMoved(TabContents* contents, 65 virtual void TabMoved(TabContents* contents,
59 int from_index, 66 int from_index,
60 int to_index); 67 int to_index);
61 virtual void TabChangedAt(TabContents* contents, int index, 68 virtual void TabChangedAt(TabContents* contents, int index,
62 bool loading_only); 69 bool loading_only);
63 virtual void TabStripEmpty(); 70 virtual void TabStripEmpty();
64 // Currently don't care about these as we're not rendering the selection. 71 // Currently don't care about these as we're not rendering the selection.
65 virtual void TabDeselectedAt(TabContents* contents, int index) { } 72 virtual void TabDeselectedAt(TabContents* contents, int index) { }
66 virtual void TabSelectedAt(TabContents* old_contents, 73 virtual void TabSelectedAt(TabContents* old_contents,
67 TabContents* new_contents, 74 TabContents* new_contents,
68 int index, 75 int index,
69 bool user_gesture) { } 76 bool user_gesture) { }
70 77
71 private: 78 private:
72 // Configures a cell from the model. 79 // Configures a cell from the model.
73 void ConfigureCell(TabOverviewCell* cell, int index); 80 void ConfigureCell(TabOverviewCell* cell, int index);
74 81
75 // Removes all the cells in the grid and populates it from the model. 82 // Removes all the cells in the grid and populates it from the model.
76 void RecreateCells(); 83 void RecreateCells();
77 84
78 // Invoked when the count of the model changes. Notifies the host the pref 85 // Updates the target and start bounds.
79 // size changed. 86 void UpdateStartAndTargetBounds();
80 void TabCountChanged(); 87
88 // Sets the bounds of the hosting window to |bounds|.
89 void SetHostBounds(const gfx::Rect& bounds);
90
91 // Returns the bounds for the window based on the current content.
92 gfx::Rect CalculateHostBounds();
81 93
82 // The widget showing the view. 94 // The widget showing the view.
83 views::Widget* host_; 95 views::Widget* host_;
84 96
85 // Bounds of the monitor we're being displayed on. This is used to position 97 // Bounds of the monitor we're being displayed on. This is used to position
86 // the widget. 98 // the widget.
87 gfx::Rect monitor_bounds_; 99 gfx::Rect monitor_bounds_;
88 100
89 // View containing the grid, owned by host. 101 // View containing the grid, owned by host.
90 TabOverviewContainer* container_; 102 TabOverviewContainer* container_;
91 103
92 // The view. This is owned by host. 104 // The view. This is owned by host.
93 TabOverviewGrid* grid_; 105 TabOverviewGrid* grid_;
94 106
95 // The browser, not owned by us. 107 // The browser, not owned by us.
96 Browser* browser_; 108 Browser* browser_;
97 109
98 // The browser a drag was started on. 110 // The browser a drag was started on.
99 Browser* drag_browser_; 111 Browser* drag_browser_;
100 112
101 // True if the host has been moved offscreen. 113 // True if the host has been moved offscreen.
102 bool moved_offscreen_; 114 bool moved_offscreen_;
103 115
104 // Has Show been invoked? 116 // Has Show been invoked?
105 bool shown_; 117 bool shown_;
106 118
119 // Position of the center of the window along the horizontal axis. This is
120 // used to position the overview window.
121 int horizontal_center_;
122
123 // Should we change the window bounds on animate? This is true while the
124 // animation is running on the grid to move things around.
125 bool change_window_bounds_on_animate_;
126
127 // When the model changes we animate the bounds of the window. These two
128 // give the start and target bounds of the window.
129 gfx::Rect start_bounds_;
130 gfx::Rect target_bounds_;
131
132 // Are we in the process of mutating the grid? This is used to avoid changing
133 // bounds when we're responsible for the mutation.
134 bool mutating_grid_;
135
107 DISALLOW_COPY_AND_ASSIGN(TabOverviewController); 136 DISALLOW_COPY_AND_ASSIGN(TabOverviewController);
108 }; 137 };
109 138
110 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_ 139 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698