Chromium Code Reviews| Index: chrome/browser/ui/views/tabs/tab_strip.h |
| diff --git a/chrome/browser/ui/views/tabs/tab_strip.h b/chrome/browser/ui/views/tabs/tab_strip.h |
| index b0756c103b4f695e0c9b73ea4fc76aea0b6cf323..9940d60c2b32c562a53b08348e055301ee61ba3e 100644 |
| --- a/chrome/browser/ui/views/tabs/tab_strip.h |
| +++ b/chrome/browser/ui/views/tabs/tab_strip.h |
| @@ -56,6 +56,14 @@ class TabStrip : public views::View, |
| public: |
| static const char kViewClassName[]; |
| + // Horizontal offset for the new tab button to bring it closer to the |
| + // rightmost tab. |
| + static const int kNewTabButtonHorizontalOffset; |
| + |
| + // The vertical offset of the tab strip button. This offset applies only to |
| + // restored windows. |
| + static const int kNewTabButtonVerticalOffset; |
| + |
| explicit TabStrip(TabStripController* controller); |
| virtual ~TabStrip(); |
| @@ -125,7 +133,9 @@ class TabStrip : public views::View, |
| } |
| // Returns the Tab at |index|. |
| - Tab* tab_at(int index) const; |
| + Tab* tab_at(int index) const { |
| + return static_cast<Tab*>(tabs_.view_at(index)); |
| + } |
| // Returns the index of the specified tab in the model coordinate system, or |
| // -1 if tab is closing or not valid. |
| @@ -172,9 +182,6 @@ class TabStrip : public views::View, |
| // Set the background offset used by inactive tabs to match the frame image. |
| void SetBackgroundOffset(const gfx::Point& offset); |
| - // Returns the new tab button. This is never NULL. |
| - views::View* newtab_button(); |
| - |
| // Sets a painting style with miniature "tab indicator" rectangles at the top. |
| void SetImmersiveStyle(bool enable); |
| @@ -240,35 +247,11 @@ class TabStrip : public views::View, |
| // Returns preferred height in immersive style. |
| static int GetImmersiveHeight(); |
| - protected: |
| - // Horizontal gap between mini and non-mini-tabs. |
| - static const int kMiniToNonMiniGap; |
| - |
| - void set_ideal_bounds(int index, const gfx::Rect& bounds) { |
| - tabs_.set_ideal_bounds(index, bounds); |
| - } |
| - |
| - // Returns the number of mini-tabs. |
| - int GetMiniTabCount() const; |
| - |
| - // views::ButtonListener implementation: |
| - virtual void ButtonPressed(views::Button* sender, |
| - const ui::Event& event) OVERRIDE; |
| - |
| - // View overrides. |
| - virtual const views::View* GetViewByID(int id) const OVERRIDE; |
| - virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| - virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
| - virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| - virtual void OnMouseCaptureLost() OVERRIDE; |
| - virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; |
| - virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| - |
| - // ui::EventHandler overrides. |
| - virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| - |
| private: |
| - typedef std::map<int, std::vector<Tab*> > TabsClosingMap; |
| + typedef std::vector<Tab*> Tabs; |
| + typedef std::map<int, Tabs> TabsClosingMap; |
| + typedef std::pair<TabsClosingMap::iterator, |
| + Tabs::iterator> FindClosingTabResult; |
| class RemoveTabDelegate; |
| @@ -314,6 +297,16 @@ class TabStrip : public views::View, |
| DISALLOW_COPY_AND_ASSIGN(DropInfo); |
| }; |
| + // Horizontal gap between mini and non-mini-tabs. |
| + static const int kMiniToNonMiniGap; |
| + |
| + // The size of the new tab button must be hardcoded because we need to be |
| + // able to lay it out before we are able to get its image from the |
| + // ui::ThemeProvider. It also makes sense to do this, because the size of the |
| + // new tab button should not need to be calculated dynamically. |
| + static const int kNewTabButtonAssetWidth; |
| + static const int kNewTabButtonAssetHeight; |
| + |
| void Init(); |
| // Creates and returns a new tab. The caller owners the returned tab. |
| @@ -352,7 +345,7 @@ class TabStrip : public views::View, |
| void SetIdealBoundsFromPositions(const std::vector<int>& positions); |
| // Stacks the dragged tabs. This is used if the drag operation is |
| - // MOVE_VISIBILE_TABS and the tabs don't fill the tabstrip. When this happens |
| + // MOVE_VISIBLE_TABS and the tabs don't fill the tabstrip. When this happens |
| // the active tab follows the mouse and the other tabs stack around it. |
| void StackDraggedTabs(int delta); |
| @@ -362,19 +355,25 @@ class TabStrip : public views::View, |
| // Invoked during drag to layout the tabs being dragged in |tabs| at |
| // |location|. If |initial_drag| is true, this is the initial layout after the |
| // user moved the mouse far enough to trigger a drag. |
| - void LayoutDraggedTabsAt(const std::vector<Tab*>& tabs, |
| + void LayoutDraggedTabsAt(const Tabs& tabs, |
| Tab* active_tab, |
| const gfx::Point& location, |
| bool initial_drag); |
| // Calculates the bounds needed for each of the tabs, placing the result in |
| // |bounds|. |
| - void CalculateBoundsForDraggedTabs(const std::vector<Tab*>& tabs, |
| + void CalculateBoundsForDraggedTabs(const Tabs& tabs, |
| std::vector<gfx::Rect>* bounds); |
| // Returns the size needed for the specified tabs. This is invoked during drag |
| // and drop to calculate offsets and positioning. |
| - int GetSizeNeededForTabs(const std::vector<Tab*>& tabs); |
| + int GetSizeNeededForTabs(const Tabs& tabs); |
| + |
| + // Returns the number of mini-tabs. |
| + int GetMiniTabCount() const; |
| + |
| + // Returns the last tab in the strip. |
| + const Tab* GetLastVisibleTab() const; |
|
Peter Kasting
2014/06/17 03:16:18
In the future, this function will also check tab v
|
| // Adds the tab at |index| to |tabs_closing_map_| and removes the tab from |
| // |tabs_|. |
| @@ -389,7 +388,7 @@ class TabStrip : public views::View, |
| void UpdateTabsClosingMap(int index, int delta); |
| // Used by TabDragController when the user starts or stops dragging tabs. |
| - void StartedDraggingTabs(const std::vector<Tab*>& tabs); |
| + void StartedDraggingTabs(const Tabs& tabs); |
| // Invoked when TabDragController detaches a set of tabs. |
| void DraggedTabsDetached(); |
| @@ -398,7 +397,7 @@ class TabStrip : public views::View, |
| // true if the move behavior is TabDragController::MOVE_VISIBILE_TABS. |
| // |completed| is true if the drag operation completed successfully, false if |
| // it was reverted. |
| - void StoppedDraggingTabs(const std::vector<Tab*>& tabs, |
| + void StoppedDraggingTabs(const Tabs& tabs, |
| const std::vector<int>& initial_positions, |
| bool move_only, |
| bool completed); |
| @@ -417,6 +416,10 @@ class TabStrip : public views::View, |
| // Releases ownership of the current TabDragController. |
| TabDragController* ReleaseDragController(); |
| + // Finds |tab| in the |tab_closing_map_| and returns a pair of iterators |
| + // indicating precisely where it is. |
| + FindClosingTabResult FindClosingTab(const Tab* tab); |
| + |
| // Paints all the tabs in |tabs_closing_map_[index]|. |
| void PaintClosingTabs(gfx::Canvas* canvas, |
| int index, |
| @@ -498,15 +501,13 @@ class TabStrip : public views::View, |
| int GenerateIdealBoundsForMiniTabs(int* first_non_mini_index); |
| // Returns the width needed for the new tab button (and padding). |
| - static int new_tab_button_width(); |
| - |
| - // Returns the vertical offset of the tab strip button. This offset applies |
| - // only to restored windows. |
| - static int button_v_offset(); |
| + static int new_tab_button_width() { |
| + return kNewTabButtonAssetWidth + kNewTabButtonHorizontalOffset; |
| + } |
| // Returns the width of the area that contains tabs. This does not include |
| // the width of the new tab button. |
| - int tab_area_width() const; |
| + int tab_area_width() const { return width() - new_tab_button_width(); } |
| // Starts various types of TabStrip animations. |
| void StartResizeLayoutAnimation(); |
| @@ -551,6 +552,22 @@ class TabStrip : public views::View, |
| // layout is reset. |
| void SetResetToShrinkOnExit(bool value); |
| + // views::ButtonListener implementation: |
| + virtual void ButtonPressed(views::Button* sender, |
| + const ui::Event& event) OVERRIDE; |
| + |
| + // View overrides. |
| + virtual const views::View* GetViewByID(int id) const OVERRIDE; |
| + virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| + virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
| + virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| + virtual void OnMouseCaptureLost() OVERRIDE; |
| + virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; |
| + virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| + |
| + // ui::EventHandler overrides. |
| + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| + |
| // -- Member Variables ------------------------------------------------------ |
| // There is a one-to-one mapping between each of the tabs in the |