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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_SIDE_TAB_STRIP_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TABS_SIDE_TAB_STRIP_H_ 7 #pragma once 8 9 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" 10 #include "views/controls/button/button.h" 11 12 struct TabRendererData; 13 14 class SideTabStrip : public BaseTabStrip, public views::ButtonListener { 15 public: 16 // The tabs are inset by this much along all axis. 17 static const int kTabStripInset; 18 19 explicit SideTabStrip(TabStripController* controller); 20 virtual ~SideTabStrip(); 21 22 // AbstractTabStripView implementation: 23 virtual bool IsPositionInWindowCaption(const gfx::Point& point) OVERRIDE; 24 virtual void SetBackgroundOffset(const gfx::Point& offset) OVERRIDE; 25 26 // BaseTabStrip implementation: 27 virtual void StartHighlight(int model_index) OVERRIDE; 28 virtual void StopAllHighlighting() OVERRIDE; 29 virtual BaseTab* CreateTabForDragging() OVERRIDE; 30 virtual void RemoveTabAt(int model_index) OVERRIDE; 31 virtual void SelectTabAt(int old_model_index, int new_model_index) OVERRIDE; 32 virtual void TabTitleChangedNotLoading(int model_index) OVERRIDE; 33 34 // views::View overrides: 35 virtual gfx::Size GetPreferredSize() OVERRIDE; 36 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; 37 virtual views::View* GetEventHandlerForPoint( 38 const gfx::Point& point) OVERRIDE; 39 40 // views::ButtonListener overrides: 41 virtual void ButtonPressed(views::Button* sender, 42 const views::Event& event) OVERRIDE; 43 44 protected: 45 // BaseTabStrip overrides: 46 virtual BaseTab* CreateTab() OVERRIDE; 47 virtual void GenerateIdealBounds() OVERRIDE; 48 virtual void StartInsertTabAnimation(int model_index) OVERRIDE; 49 virtual void AnimateToIdealBounds() OVERRIDE; 50 virtual void DoLayout() OVERRIDE; 51 virtual void LayoutDraggedTabsAt(const std::vector<BaseTab*>& tabs, 52 BaseTab* active_tab, 53 const gfx::Point& location, 54 bool initial_drag) OVERRIDE; 55 virtual void CalculateBoundsForDraggedTabs( 56 const std::vector<BaseTab*>& tabs, 57 std::vector<gfx::Rect>* bounds) OVERRIDE; 58 virtual int GetSizeNeededForTabs(const std::vector<BaseTab*>& tabs) OVERRIDE; 59 60 // views::View protected overrides: 61 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 62 63 private: 64 // Sets |first_tab_y_offset_|. This ensures |new_offset| is legal. 65 void SetFirstTabYOffset(int new_offset); 66 67 // Returns the max y offset. 68 int GetMaxOffset() const; 69 70 // Returns the max visible y-coordinate for tabs. 71 int GetMaxTabY() const; 72 73 // Make sure the tab at |tab_index| is visible. 74 void MakeTabVisible(int tab_index); 75 76 // The "New Tab" button. 77 views::View* newtab_button_; 78 79 // Ideal bounds of the new tab button. 80 gfx::Rect newtab_button_bounds_; 81 82 // Scroll buttons. 83 views::View* scroll_up_button_; 84 views::View* scroll_down_button_; 85 86 // Separator between mini-tabs and the new tab button. The separator is 87 // positioned above the visible area if there are no mini-tabs. 88 views::View* separator_; 89 90 // Bounds of the sepatator. 91 gfx::Rect separator_bounds_; 92 93 // Offset the first tab (or new tab button) is positioned at. If the user has 94 // scrolled the tabs this is non-zero. 95 int first_tab_y_offset_; 96 97 // Height needed to display the tabs, separator and new tab button. Doesn't 98 // include any padding. 99 int ideal_height_; 100 101 DISALLOW_COPY_AND_ASSIGN(SideTabStrip); 102 }; 103 104 #endif // CHROME_BROWSER_UI_VIEWS_TABS_SIDE_TAB_STRIP_H_ 105