Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_UI_VIEWS_TABS_TAB_STRIP_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| 11 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" | 11 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" |
| 12 #include "ui/base/animation/animation_container.h" | 12 #include "ui/base/animation/animation_container.h" |
| 13 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 15 #include "views/controls/button/image_button.h" | 15 #include "views/controls/button/image_button.h" |
| 16 #include "views/mouse_watcher.h" | 16 #include "views/mouse_watcher.h" |
| 17 | 17 |
| 18 class Browser; | |
| 18 class Tab; | 19 class Tab; |
| 19 class TabStripSelectionModel; | 20 class TabStripSelectionModel; |
| 20 | 21 |
| 21 namespace views { | 22 namespace views { |
| 22 class ImageView; | 23 class ImageView; |
| 23 } | 24 } |
| 24 | 25 |
| 25 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 26 // | 27 // |
| 27 // TabStrip | 28 // TabStrip |
| 28 // | 29 // |
| 29 // A View that represents the TabStripModel. The TabStrip has the | 30 // A View that represents the TabStripModel. The TabStrip has the |
| 30 // following responsibilities: | 31 // following responsibilities: |
| 31 // - It implements the TabStripModelObserver interface, and acts as a | 32 // - It implements the TabStripModelObserver interface, and acts as a |
| 32 // container for Tabs, and is also responsible for creating them. | 33 // container for Tabs, and is also responsible for creating them. |
| 33 // - It takes part in Tab Drag & Drop with Tab, TabDragHelper and | 34 // - It takes part in Tab Drag & Drop with Tab, TabDragHelper and |
| 34 // DraggedTab, focusing on tasks that require reshuffling other tabs | 35 // DraggedTab, focusing on tasks that require reshuffling other tabs |
| 35 // in response to dragged tabs. | 36 // in response to dragged tabs. |
| 36 // | 37 // |
| 37 /////////////////////////////////////////////////////////////////////////////// | 38 /////////////////////////////////////////////////////////////////////////////// |
| 38 class TabStrip : public BaseTabStrip, | 39 class TabStrip : public BaseTabStrip, |
| 39 public views::ButtonListener, | 40 public views::ButtonListener, |
| 40 public views::MouseWatcherListener { | 41 public views::MouseWatcherListener { |
| 41 public: | 42 public: |
| 42 explicit TabStrip(TabStripController* controller); | 43 explicit TabStrip(Browser* browser, TabStripController* controller); |
|
sky
2011/07/14 19:51:08
TabStrip shouldn't depend on browser. Move the con
| |
| 43 virtual ~TabStrip(); | 44 virtual ~TabStrip(); |
| 44 | 45 |
| 45 // Creates the new tab button. | |
| 46 void InitTabStripButtons(); | |
| 47 | |
| 48 // Returns the bounds of the new tab button. | 46 // Returns the bounds of the new tab button. |
| 49 gfx::Rect GetNewTabButtonBounds(); | 47 gfx::Rect GetNewTabButtonBounds(); |
| 50 | 48 |
| 49 // Does he new tab button need to be sized to the top of the tab strip? | |
| 50 bool SizeTabButtonToTopOfTabStrip(); | |
| 51 | |
| 51 // MouseWatcherListener overrides: | 52 // MouseWatcherListener overrides: |
| 52 virtual void MouseMovedOutOfView() OVERRIDE; | 53 virtual void MouseMovedOutOfView() OVERRIDE; |
| 53 | 54 |
| 54 // AbstractTabStripView implementation: | 55 // AbstractTabStripView implementation: |
| 55 virtual bool IsPositionInWindowCaption(const gfx::Point& point) OVERRIDE; | 56 virtual bool IsPositionInWindowCaption(const gfx::Point& point) OVERRIDE; |
| 56 virtual void SetBackgroundOffset(const gfx::Point& offset) OVERRIDE; | 57 virtual void SetBackgroundOffset(const gfx::Point& offset) OVERRIDE; |
| 57 | 58 |
| 58 // BaseTabStrip implementation: | 59 // BaseTabStrip implementation: |
| 59 virtual void PrepareForCloseAt(int model_index) OVERRIDE; | 60 virtual void PrepareForCloseAt(int model_index) OVERRIDE; |
| 60 virtual void RemoveTabAt(int model_index) OVERRIDE; | 61 virtual void RemoveTabAt(int model_index) OVERRIDE; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 // Renders the drop indicator. | 133 // Renders the drop indicator. |
| 133 views::Widget* arrow_window; | 134 views::Widget* arrow_window; |
| 134 views::ImageView* arrow_view; | 135 views::ImageView* arrow_view; |
| 135 | 136 |
| 136 private: | 137 private: |
| 137 DISALLOW_COPY_AND_ASSIGN(DropInfo); | 138 DISALLOW_COPY_AND_ASSIGN(DropInfo); |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 void Init(); | 141 void Init(); |
| 141 | 142 |
| 143 // Creates the new tab button. | |
| 144 void InitTabStripButtons(); | |
| 145 | |
| 142 // Set the images for the new tab button. | 146 // Set the images for the new tab button. |
| 143 void LoadNewTabButtonImage(); | 147 void LoadNewTabButtonImage(); |
| 144 | 148 |
| 145 // Retrieves the Tab at the specified index. Remember, the specified index | 149 // Retrieves the Tab at the specified index. Remember, the specified index |
| 146 // is in terms of tab_data, *not* the model. | 150 // is in terms of tab_data, *not* the model. |
| 147 Tab* GetTabAtTabDataIndex(int tab_data_index) const; | 151 Tab* GetTabAtTabDataIndex(int tab_data_index) const; |
| 148 | 152 |
| 149 // Returns the tab at the specified index. If a remove animation is on going | 153 // Returns the tab at the specified index. If a remove animation is on going |
| 150 // and the index is >= the index of the tab being removed, the index is | 154 // and the index is >= the index of the tab being removed, the index is |
| 151 // incremented. While a remove operation is on going the indices of the model | 155 // incremented. While a remove operation is on going the indices of the model |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 | 265 |
| 262 // To ensure all tabs pulse at the same time they share the same animation | 266 // To ensure all tabs pulse at the same time they share the same animation |
| 263 // container. This is that animation container. | 267 // container. This is that animation container. |
| 264 scoped_refptr<ui::AnimationContainer> animation_container_; | 268 scoped_refptr<ui::AnimationContainer> animation_container_; |
| 265 | 269 |
| 266 // Used for stage 1 of new tab animation. | 270 // Used for stage 1 of new tab animation. |
| 267 base::OneShotTimer<TabStrip> new_tab_timer_; | 271 base::OneShotTimer<TabStrip> new_tab_timer_; |
| 268 | 272 |
| 269 scoped_ptr<views::MouseWatcher> mouse_watcher_; | 273 scoped_ptr<views::MouseWatcher> mouse_watcher_; |
| 270 | 274 |
| 275 // Pointer to the browser that holds this tab strip. | |
| 276 Browser* browser_; | |
| 277 | |
| 271 DISALLOW_COPY_AND_ASSIGN(TabStrip); | 278 DISALLOW_COPY_AND_ASSIGN(TabStrip); |
| 272 }; | 279 }; |
| 273 | 280 |
| 274 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ | 281 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ |
| OLD | NEW |