| OLD | NEW |
| 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 Animation; |
| 13 class Browser; | 13 class Browser; |
| 14 class TabOverviewCell; | 14 class TabOverviewCell; |
| 15 class TabOverviewContainer; | 15 class TabOverviewContainer; |
| 16 class TabOverviewGrid; | 16 class TabOverviewGrid; |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 class Widget; | 19 class Widget; |
| 20 } | 20 } |
| 21 | 21 |
| 22 // TabOverviewController is responsible for showing a TabOverviewGrid and | 22 // TabOverviewController is responsible for showing a TabOverviewGrid and |
| 23 // keeping it in sync with the TabStripModel of a browser. | 23 // keeping it in sync with the TabStripModel of a browser. |
| 24 // |
| 25 // As tabs are added/removed from the TabStripModel the size and position |
| 26 // of the container animates. Ideally this would be done by changing the |
| 27 // bounds of the host window, but that proved janktastic. Instead the |
| 28 // size of the host window is created at the largest possible size the |
| 29 // window can be and the bounds of the container are changed during the |
| 30 // animation. |
| 24 class TabOverviewController : public TabStripModelObserver { | 31 class TabOverviewController : public TabStripModelObserver { |
| 25 public: | 32 public: |
| 26 // Creates a TabOverviewController that will be shown on the monitor | 33 // Creates a TabOverviewController that will be shown on the monitor |
| 27 // containing |monitor_origin|. | 34 // containing |monitor_origin|. |
| 28 explicit TabOverviewController(const gfx::Point& monitor_origin); | 35 explicit TabOverviewController(const gfx::Point& monitor_origin); |
| 29 ~TabOverviewController(); | 36 ~TabOverviewController(); |
| 30 | 37 |
| 31 // Sets the browser we're showing the tab strip for. |horizontal_center| | 38 // Sets the browser we're showing the tab strip for. |horizontal_center| |
| 32 // gives the center of the window. | 39 // gives the center of the window. |
| 33 void SetBrowser(Browser* browser, int horizontal_center); | 40 void SetBrowser(Browser* browser, int horizontal_center); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 private: | 85 private: |
| 79 // Configures a cell from the model. | 86 // Configures a cell from the model. |
| 80 void ConfigureCell(TabOverviewCell* cell, int index); | 87 void ConfigureCell(TabOverviewCell* cell, int index); |
| 81 | 88 |
| 82 // Removes all the cells in the grid and populates it from the model. | 89 // Removes all the cells in the grid and populates it from the model. |
| 83 void RecreateCells(); | 90 void RecreateCells(); |
| 84 | 91 |
| 85 // Updates the target and start bounds. | 92 // Updates the target and start bounds. |
| 86 void UpdateStartAndTargetBounds(); | 93 void UpdateStartAndTargetBounds(); |
| 87 | 94 |
| 88 // Sets the bounds of the hosting window to |bounds|. | 95 // Returns the bounds for the tab overview container based on the preferred |
| 89 void SetHostBounds(const gfx::Rect& bounds); | 96 // size of the container. The returned value is the coordinates of the |
| 97 // root view (container's parent). |
| 98 // See comment above class description for more details. |
| 99 gfx::Rect CalculateContainerBounds(); |
| 90 | 100 |
| 91 // Returns the bounds for the window based on the current content. | 101 // Returns the bounds needed for the host. |
| 102 // See comment above class description for more details. |
| 92 gfx::Rect CalculateHostBounds(); | 103 gfx::Rect CalculateHostBounds(); |
| 93 | 104 |
| 94 // The widget showing the view. | 105 // The widget showing the view. |
| 95 views::Widget* host_; | 106 views::Widget* host_; |
| 96 | 107 |
| 97 // Bounds of the monitor we're being displayed on. This is used to position | 108 // Bounds of the monitor we're being displayed on. This is used to position |
| 98 // the widget. | 109 // the widget. |
| 99 gfx::Rect monitor_bounds_; | 110 gfx::Rect monitor_bounds_; |
| 100 | 111 |
| 101 // View containing the grid, owned by host. | 112 // View containing the grid, owned by host. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 130 gfx::Rect target_bounds_; | 141 gfx::Rect target_bounds_; |
| 131 | 142 |
| 132 // Are we in the process of mutating the grid? This is used to avoid changing | 143 // Are we in the process of mutating the grid? This is used to avoid changing |
| 133 // bounds when we're responsible for the mutation. | 144 // bounds when we're responsible for the mutation. |
| 134 bool mutating_grid_; | 145 bool mutating_grid_; |
| 135 | 146 |
| 136 DISALLOW_COPY_AND_ASSIGN(TabOverviewController); | 147 DISALLOW_COPY_AND_ASSIGN(TabOverviewController); |
| 137 }; | 148 }; |
| 138 | 149 |
| 139 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_ | 150 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_ |
| OLD | NEW |