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 |
92 // views::View overrides: | 95 // views::View overrides: |
93 virtual void PaintChildren(gfx::Canvas* canvas); | 96 virtual void PaintChildren(gfx::Canvas* canvas); |
94 virtual views::View* GetViewByID(int id) const; | 97 virtual views::View* GetViewByID(int id) const; |
95 virtual void Layout(); | 98 virtual void Layout(); |
96 virtual gfx::Size GetPreferredSize(); | 99 virtual gfx::Size GetPreferredSize(); |
97 // NOTE: the drag and drop methods are invoked from FrameView. This is done to | 100 // NOTE: the drag and drop methods are invoked from FrameView. This is done to |
98 // allow for a drop region that extends outside the bounds of the TabStrip. | 101 // allow for a drop region that extends outside the bounds of the TabStrip. |
99 virtual void OnDragEntered(const views::DropTargetEvent& event); | 102 virtual void OnDragEntered(const views::DropTargetEvent& event); |
100 virtual int OnDragUpdated(const views::DropTargetEvent& event); | 103 virtual int OnDragUpdated(const views::DropTargetEvent& event); |
101 virtual void OnDragExited(); | 104 virtual void OnDragExited(); |
102 virtual int OnPerformDrop(const views::DropTargetEvent& event); | 105 virtual int OnPerformDrop(const views::DropTargetEvent& event); |
103 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | 106 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
104 virtual bool GetAccessibleName(std::wstring* name); | 107 virtual bool GetAccessibleName(std::wstring* name); |
105 virtual void SetAccessibleName(const std::wstring& name); | 108 virtual void SetAccessibleName(const std::wstring& name); |
106 virtual views::View* GetViewForPoint(const gfx::Point& point); | 109 virtual views::View* GetViewForPoint(const gfx::Point& point); |
| 110 virtual void ThemeChanged(); |
107 | 111 |
108 protected: | 112 protected: |
109 // TabStripModelObserver implementation: | 113 // TabStripModelObserver implementation: |
110 virtual void TabInsertedAt(TabContents* contents, | 114 virtual void TabInsertedAt(TabContents* contents, |
111 int index, | 115 int index, |
112 bool foreground); | 116 bool foreground); |
113 virtual void TabDetachedAt(TabContents* contents, int index); | 117 virtual void TabDetachedAt(TabContents* contents, int index); |
114 virtual void TabSelectedAt(TabContents* old_contents, | 118 virtual void TabSelectedAt(TabContents* old_contents, |
115 TabContents* contents, | 119 TabContents* contents, |
116 int index, | 120 int index, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 friend class DraggedTabController; | 163 friend class DraggedTabController; |
160 friend class InsertTabAnimation; | 164 friend class InsertTabAnimation; |
161 friend class MoveTabAnimation; | 165 friend class MoveTabAnimation; |
162 friend class RemoveTabAnimation; | 166 friend class RemoveTabAnimation; |
163 friend class ResizeLayoutAnimation; | 167 friend class ResizeLayoutAnimation; |
164 friend class TabAnimation; | 168 friend class TabAnimation; |
165 | 169 |
166 TabStrip(); | 170 TabStrip(); |
167 void Init(); | 171 void Init(); |
168 | 172 |
| 173 // Set the images for the new tab button. |
| 174 void LoadNewTabButtonImage(); |
| 175 |
169 // Retrieves the Tab at the specified index. Take care in using this, you may | 176 // Retrieves the Tab at the specified index. Take care in using this, you may |
170 // need to use GetTabAtAdjustForAnimation. | 177 // need to use GetTabAtAdjustForAnimation. |
171 Tab* GetTabAt(int index) const; | 178 Tab* GetTabAt(int index) const; |
172 | 179 |
173 // Returns the tab at the specified index. If a remove animation is on going | 180 // Returns the tab at the specified index. If a remove animation is on going |
174 // and the index is >= the index of the tab being removed, the index is | 181 // and the index is >= the index of the tab being removed, the index is |
175 // incremented. While a remove operation is on going the indices of the model | 182 // incremented. While a remove operation is on going the indices of the model |
176 // do not line up with the indices of the view. This method adjusts the index | 183 // do not line up with the indices of the view. This method adjusts the index |
177 // accordingly. | 184 // accordingly. |
178 // | 185 // |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 bool added_as_message_loop_observer_; | 303 bool added_as_message_loop_observer_; |
297 | 304 |
298 // True if a resize layout animation should be run a short delay after the | 305 // True if a resize layout animation should be run a short delay after the |
299 // mouse exits the TabStrip. | 306 // mouse exits the TabStrip. |
300 // TODO(beng): (Cleanup) this would be better named "needs_resize_layout_". | 307 // TODO(beng): (Cleanup) this would be better named "needs_resize_layout_". |
301 bool resize_layout_scheduled_; | 308 bool resize_layout_scheduled_; |
302 | 309 |
303 // The "New Tab" button. | 310 // The "New Tab" button. |
304 views::ImageButton* newtab_button_; | 311 views::ImageButton* newtab_button_; |
305 gfx::Size newtab_button_size_; | 312 gfx::Size newtab_button_size_; |
306 gfx::Size actual_newtab_button_size_; | |
307 | 313 |
308 // The current widths of various types of tabs. We save these so that, as | 314 // The current widths of various types of tabs. We save these so that, as |
309 // users close tabs while we're holding them at the same size, we can lay out | 315 // users close tabs while we're holding them at the same size, we can lay out |
310 // tabs exactly and eliminate the "pixel jitter" we'd get from just leaving | 316 // tabs exactly and eliminate the "pixel jitter" we'd get from just leaving |
311 // them all at their existing, rounded widths. | 317 // them all at their existing, rounded widths. |
312 double current_unselected_width_; | 318 double current_unselected_width_; |
313 double current_selected_width_; | 319 double current_selected_width_; |
314 | 320 |
315 // If this value is nonnegative, it is used in GetDesiredTabWidths() to | 321 // If this value is nonnegative, it is used in GetDesiredTabWidths() to |
316 // calculate how much space in the tab strip to use for tabs. Most of the | 322 // calculate how much space in the tab strip to use for tabs. Most of the |
317 // time this will be -1, but while we're handling closing a tab via the mouse, | 323 // time this will be -1, but while we're handling closing a tab via the mouse, |
318 // we'll set this to the edge of the last tab before closing, so that if we | 324 // we'll set this to the edge of the last tab before closing, so that if we |
319 // are closing the last tab and need to resize immediately, we'll resize only | 325 // are closing the last tab and need to resize immediately, we'll resize only |
320 // back to this width, thus once again placing the last tab under the mouse | 326 // back to this width, thus once again placing the last tab under the mouse |
321 // cursor. | 327 // cursor. |
322 int available_width_for_tabs_; | 328 int available_width_for_tabs_; |
323 | 329 |
324 // Storage of strings needed for accessibility. | 330 // Storage of strings needed for accessibility. |
325 std::wstring accessible_name_; | 331 std::wstring accessible_name_; |
326 | 332 |
| 333 // The size of the new tab button must be hardcoded because we need to be |
| 334 // able to lay it out before we are able to get its image from the |
| 335 // ThemeProvider. It also makes sense to do this, because the size of the |
| 336 // new tab button should not need to be calculated dynamically. |
| 337 static const int kNewTabButtonWidth = 28; |
| 338 static const int kNewTabButtonHeight = 18; |
| 339 |
327 // Used during a drop session of a url. Tracks the position of the drop as | 340 // Used during a drop session of a url. Tracks the position of the drop as |
328 // well as a window used to highlight where the drop occurs. | 341 // well as a window used to highlight where the drop occurs. |
329 struct DropInfo { | 342 struct DropInfo { |
330 DropInfo(int index, bool drop_before, bool paint_down); | 343 DropInfo(int index, bool drop_before, bool paint_down); |
331 ~DropInfo(); | 344 ~DropInfo(); |
332 | 345 |
333 // Index of the tab to drop on. If drop_before is true, the drop should | 346 // Index of the tab to drop on. If drop_before is true, the drop should |
334 // occur between the tab at drop_index - 1 and drop_index. | 347 // occur between the tab at drop_index - 1 and drop_index. |
335 // WARNING: if drop_before is true it is possible this will == tab_count, | 348 // WARNING: if drop_before is true it is possible this will == tab_count, |
336 // which indicates the drop should create a new tab at the end of the tabs. | 349 // which indicates the drop should create a new tab at the end of the tabs. |
(...skipping 30 matching lines...) Expand all Loading... |
367 }; | 380 }; |
368 std::vector<TabData> tab_data_; | 381 std::vector<TabData> tab_data_; |
369 | 382 |
370 // The currently running animation. | 383 // The currently running animation. |
371 scoped_ptr<TabAnimation> active_animation_; | 384 scoped_ptr<TabAnimation> active_animation_; |
372 | 385 |
373 DISALLOW_COPY_AND_ASSIGN(TabStrip); | 386 DISALLOW_COPY_AND_ASSIGN(TabStrip); |
374 }; | 387 }; |
375 | 388 |
376 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ | 389 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ |
OLD | NEW |