| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // DraggedTab, focusing on tasks that require reshuffling other tabs | 50 // DraggedTab, focusing on tasks that require reshuffling other tabs |
| 51 // in response to dragged tabs. | 51 // in response to dragged tabs. |
| 52 // | 52 // |
| 53 /////////////////////////////////////////////////////////////////////////////// | 53 /////////////////////////////////////////////////////////////////////////////// |
| 54 class TabStrip : public views::View, | 54 class TabStrip : public views::View, |
| 55 public views::ButtonListener, | 55 public views::ButtonListener, |
| 56 public views::MouseWatcherListener, | 56 public views::MouseWatcherListener, |
| 57 public views::ViewTargeterDelegate, | 57 public views::ViewTargeterDelegate, |
| 58 public TabController { | 58 public TabController { |
| 59 public: | 59 public: |
| 60 static const char kViewClassName[]; | |
| 61 | |
| 62 // Horizontal offset for the new tab button to bring it closer to the | |
| 63 // rightmost tab. | |
| 64 static const int kNewTabButtonHorizontalOffset; | |
| 65 | |
| 66 // The vertical offset of the tab strip button. This offset applies only to | 60 // The vertical offset of the tab strip button. This offset applies only to |
| 67 // restored windows. | 61 // restored windows. |
| 68 static const int kNewTabButtonVerticalOffset; | 62 static const int kNewTabButtonVerticalOffset; |
| 69 | 63 |
| 70 // The size of the new tab button must be hardcoded because we need to be | 64 // The size of the new tab button must be hardcoded because we need to be |
| 71 // able to lay it out before we are able to get its image from the | 65 // able to lay it out before we are able to get its image from the |
| 72 // ui::ThemeProvider. It also makes sense to do this, because the size of the | 66 // ui::ThemeProvider. It also makes sense to do this, because the size of the |
| 73 // new tab button should not need to be calculated dynamically. | 67 // new tab button should not need to be calculated dynamically. |
| 74 static const int kNewTabButtonAssetWidth; | 68 static const int kNewTabButtonAssetWidth; |
| 75 static const int kNewTabButtonAssetHeight; | |
| 76 | 69 |
| 77 explicit TabStrip(TabStripController* controller); | 70 explicit TabStrip(TabStripController* controller); |
| 78 ~TabStrip() override; | 71 ~TabStrip() override; |
| 79 | 72 |
| 80 // Add and remove observers to changes within this TabStrip. | 73 // Add and remove observers to changes within this TabStrip. |
| 81 void AddObserver(TabStripObserver* observer); | 74 void AddObserver(TabStripObserver* observer); |
| 82 void RemoveObserver(TabStripObserver* observer); | 75 void RemoveObserver(TabStripObserver* observer); |
| 83 | 76 |
| 84 // If |adjust_layout| is true the stacked layout changes based on whether the | 77 // If |adjust_layout| is true the stacked layout changes based on whether the |
| 85 // user uses a mouse or a touch device with the tabstrip. | 78 // user uses a mouse or a touch device with the tabstrip. |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 483 |
| 491 // Generates the ideal bounds for each of the tabs as well as the new tab | 484 // Generates the ideal bounds for each of the tabs as well as the new tab |
| 492 // button. | 485 // button. |
| 493 void GenerateIdealBounds(); | 486 void GenerateIdealBounds(); |
| 494 | 487 |
| 495 // Generates the ideal bounds for the pinned tabs. Returns the index to | 488 // Generates the ideal bounds for the pinned tabs. Returns the index to |
| 496 // position the first non-pinned tab and sets |first_non_pinned_index| to the | 489 // position the first non-pinned tab and sets |first_non_pinned_index| to the |
| 497 // index of the first non-pinned tab. | 490 // index of the first non-pinned tab. |
| 498 int GenerateIdealBoundsForPinnedTabs(int* first_non_pinned_index); | 491 int GenerateIdealBoundsForPinnedTabs(int* first_non_pinned_index); |
| 499 | 492 |
| 500 // Returns the width needed for the new tab button (and padding). | |
| 501 static int new_tab_button_width() { | |
| 502 return kNewTabButtonAssetWidth + kNewTabButtonHorizontalOffset; | |
| 503 } | |
| 504 | |
| 505 // Returns the width of the area that contains tabs. This does not include | 493 // Returns the width of the area that contains tabs. This does not include |
| 506 // the width of the new tab button. | 494 // the width of the new tab button. |
| 507 int tab_area_width() const { return width() - new_tab_button_width(); } | 495 int GetTabAreaWidth() const; |
| 508 | 496 |
| 509 // Starts various types of TabStrip animations. | 497 // Starts various types of TabStrip animations. |
| 510 void StartResizeLayoutAnimation(); | 498 void StartResizeLayoutAnimation(); |
| 511 void StartPinnedTabAnimation(); | 499 void StartPinnedTabAnimation(); |
| 512 void StartMouseInitiatedRemoveTabAnimation(int model_index); | 500 void StartMouseInitiatedRemoveTabAnimation(int model_index); |
| 513 | 501 |
| 514 // Returns true if the specified point in TabStrip coords is within the | 502 // Returns true if the specified point in TabStrip coords is within the |
| 515 // hit-test region of the specified Tab. | 503 // hit-test region of the specified Tab. |
| 516 bool IsPointInTab(Tab* tab, const gfx::Point& point_in_tabstrip_coords); | 504 bool IsPointInTab(Tab* tab, const gfx::Point& point_in_tabstrip_coords); |
| 517 | 505 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 bool immersive_style_; | 645 bool immersive_style_; |
| 658 | 646 |
| 659 // Our observers. | 647 // Our observers. |
| 660 typedef base::ObserverList<TabStripObserver> TabStripObservers; | 648 typedef base::ObserverList<TabStripObserver> TabStripObservers; |
| 661 TabStripObservers observers_; | 649 TabStripObservers observers_; |
| 662 | 650 |
| 663 DISALLOW_COPY_AND_ASSIGN(TabStrip); | 651 DISALLOW_COPY_AND_ASSIGN(TabStrip); |
| 664 }; | 652 }; |
| 665 | 653 |
| 666 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ | 654 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ |
| OLD | NEW |