OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_STRIP_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ |
6 #define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ | 6 #define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ |
7 | 7 |
8 #include "base/gfx/point.h" | 8 #include "base/gfx/point.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/tabs/tab_strip_model.h" | 10 #include "chrome/browser/tabs/tab_strip_model.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 // Retrieve the ideal bounds for the Tab at the specified index. | 83 // Retrieve the ideal bounds for the Tab at the specified index. |
84 gfx::Rect GetIdealBounds(int index); | 84 gfx::Rect GetIdealBounds(int index); |
85 | 85 |
86 // Updates loading animations for the TabStrip. | 86 // Updates loading animations for the TabStrip. |
87 void UpdateLoadingAnimations(); | 87 void UpdateLoadingAnimations(); |
88 | 88 |
89 // Set the background offset used by inactive tabs to match the frame image. | 89 // Set the background offset used by inactive tabs to match the frame image. |
90 void SetBackgroundOffset(gfx::Point offset); | 90 void SetBackgroundOffset(gfx::Point offset); |
91 | 91 |
92 // Create the new tab button. | |
93 void InitTabStripButtons(); | |
94 | |
95 // views::View overrides: | 92 // views::View overrides: |
96 virtual void PaintChildren(gfx::Canvas* canvas); | 93 virtual void PaintChildren(gfx::Canvas* canvas); |
97 virtual views::View* GetViewByID(int id) const; | 94 virtual views::View* GetViewByID(int id) const; |
98 virtual void Layout(); | 95 virtual void Layout(); |
99 virtual gfx::Size GetPreferredSize(); | 96 virtual gfx::Size GetPreferredSize(); |
100 // NOTE: the drag and drop methods are invoked from FrameView. This is done to | 97 // NOTE: the drag and drop methods are invoked from FrameView. This is done to |
101 // allow for a drop region that extends outside the bounds of the TabStrip. | 98 // allow for a drop region that extends outside the bounds of the TabStrip. |
102 virtual void OnDragEntered(const views::DropTargetEvent& event); | 99 virtual void OnDragEntered(const views::DropTargetEvent& event); |
103 virtual int OnDragUpdated(const views::DropTargetEvent& event); | 100 virtual int OnDragUpdated(const views::DropTargetEvent& event); |
104 virtual void OnDragExited(); | 101 virtual void OnDragExited(); |
105 virtual int OnPerformDrop(const views::DropTargetEvent& event); | 102 virtual int OnPerformDrop(const views::DropTargetEvent& event); |
106 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | 103 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
107 virtual bool GetAccessibleName(std::wstring* name); | 104 virtual bool GetAccessibleName(std::wstring* name); |
108 virtual void SetAccessibleName(const std::wstring& name); | 105 virtual void SetAccessibleName(const std::wstring& name); |
109 virtual views::View* GetViewForPoint(const gfx::Point& point); | 106 virtual views::View* GetViewForPoint(const gfx::Point& point); |
110 virtual void ThemeChanged(); | |
111 | 107 |
112 protected: | 108 protected: |
113 // TabStripModelObserver implementation: | 109 // TabStripModelObserver implementation: |
114 virtual void TabInsertedAt(TabContents* contents, | 110 virtual void TabInsertedAt(TabContents* contents, |
115 int index, | 111 int index, |
116 bool foreground); | 112 bool foreground); |
117 virtual void TabDetachedAt(TabContents* contents, int index); | 113 virtual void TabDetachedAt(TabContents* contents, int index); |
118 virtual void TabSelectedAt(TabContents* old_contents, | 114 virtual void TabSelectedAt(TabContents* old_contents, |
119 TabContents* contents, | 115 TabContents* contents, |
120 int index, | 116 int index, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 friend class DraggedTabController; | 159 friend class DraggedTabController; |
164 friend class InsertTabAnimation; | 160 friend class InsertTabAnimation; |
165 friend class MoveTabAnimation; | 161 friend class MoveTabAnimation; |
166 friend class RemoveTabAnimation; | 162 friend class RemoveTabAnimation; |
167 friend class ResizeLayoutAnimation; | 163 friend class ResizeLayoutAnimation; |
168 friend class TabAnimation; | 164 friend class TabAnimation; |
169 | 165 |
170 TabStrip(); | 166 TabStrip(); |
171 void Init(); | 167 void Init(); |
172 | 168 |
173 // Set the images for the new tab button. | |
174 void LoadNewTabButtonImage(); | |
175 | |
176 // Retrieves the Tab at the specified index. Take care in using this, you may | 169 // Retrieves the Tab at the specified index. Take care in using this, you may |
177 // need to use GetTabAtAdjustForAnimation. | 170 // need to use GetTabAtAdjustForAnimation. |
178 Tab* GetTabAt(int index) const; | 171 Tab* GetTabAt(int index) const; |
179 | 172 |
180 // Returns the tab at the specified index. If a remove animation is on going | 173 // Returns the tab at the specified index. If a remove animation is on going |
181 // and the index is >= the index of the tab being removed, the index is | 174 // and the index is >= the index of the tab being removed, the index is |
182 // incremented. While a remove operation is on going the indices of the model | 175 // incremented. While a remove operation is on going the indices of the model |
183 // do not line up with the indices of the view. This method adjusts the index | 176 // do not line up with the indices of the view. This method adjusts the index |
184 // accordingly. | 177 // accordingly. |
185 // | 178 // |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 bool added_as_message_loop_observer_; | 296 bool added_as_message_loop_observer_; |
304 | 297 |
305 // True if a resize layout animation should be run a short delay after the | 298 // True if a resize layout animation should be run a short delay after the |
306 // mouse exits the TabStrip. | 299 // mouse exits the TabStrip. |
307 // TODO(beng): (Cleanup) this would be better named "needs_resize_layout_". | 300 // TODO(beng): (Cleanup) this would be better named "needs_resize_layout_". |
308 bool resize_layout_scheduled_; | 301 bool resize_layout_scheduled_; |
309 | 302 |
310 // The "New Tab" button. | 303 // The "New Tab" button. |
311 views::ImageButton* newtab_button_; | 304 views::ImageButton* newtab_button_; |
312 gfx::Size newtab_button_size_; | 305 gfx::Size newtab_button_size_; |
| 306 gfx::Size actual_newtab_button_size_; |
313 | 307 |
314 // The current widths of various types of tabs. We save these so that, as | 308 // The current widths of various types of tabs. We save these so that, as |
315 // users close tabs while we're holding them at the same size, we can lay out | 309 // users close tabs while we're holding them at the same size, we can lay out |
316 // tabs exactly and eliminate the "pixel jitter" we'd get from just leaving | 310 // tabs exactly and eliminate the "pixel jitter" we'd get from just leaving |
317 // them all at their existing, rounded widths. | 311 // them all at their existing, rounded widths. |
318 double current_unselected_width_; | 312 double current_unselected_width_; |
319 double current_selected_width_; | 313 double current_selected_width_; |
320 | 314 |
321 // If this value is nonnegative, it is used in GetDesiredTabWidths() to | 315 // If this value is nonnegative, it is used in GetDesiredTabWidths() to |
322 // calculate how much space in the tab strip to use for tabs. Most of the | 316 // calculate how much space in the tab strip to use for tabs. Most of the |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 }; | 367 }; |
374 std::vector<TabData> tab_data_; | 368 std::vector<TabData> tab_data_; |
375 | 369 |
376 // The currently running animation. | 370 // The currently running animation. |
377 scoped_ptr<TabAnimation> active_animation_; | 371 scoped_ptr<TabAnimation> active_animation_; |
378 | 372 |
379 DISALLOW_COPY_AND_ASSIGN(TabStrip); | 373 DISALLOW_COPY_AND_ASSIGN(TabStrip); |
380 }; | 374 }; |
381 | 375 |
382 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ | 376 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ |
OLD | NEW |