| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 static const int kNewTabButtonVerticalOffset; | 67 static const int kNewTabButtonVerticalOffset; |
| 68 | 68 |
| 69 // The size of the new tab button must be hardcoded because we need to be | 69 // The size of the new tab button must be hardcoded because we need to be |
| 70 // able to lay it out before we are able to get its image from the | 70 // able to lay it out before we are able to get its image from the |
| 71 // ui::ThemeProvider. It also makes sense to do this, because the size of the | 71 // ui::ThemeProvider. It also makes sense to do this, because the size of the |
| 72 // new tab button should not need to be calculated dynamically. | 72 // new tab button should not need to be calculated dynamically. |
| 73 static const int kNewTabButtonAssetWidth; | 73 static const int kNewTabButtonAssetWidth; |
| 74 static const int kNewTabButtonAssetHeight; | 74 static const int kNewTabButtonAssetHeight; |
| 75 | 75 |
| 76 explicit TabStrip(TabStripController* controller); | 76 explicit TabStrip(TabStripController* controller); |
| 77 virtual ~TabStrip(); | 77 ~TabStrip() override; |
| 78 | 78 |
| 79 // Add and remove observers to changes within this TabStrip. | 79 // Add and remove observers to changes within this TabStrip. |
| 80 void AddObserver(TabStripObserver* observer); | 80 void AddObserver(TabStripObserver* observer); |
| 81 void RemoveObserver(TabStripObserver* observer); | 81 void RemoveObserver(TabStripObserver* observer); |
| 82 | 82 |
| 83 // If |adjust_layout| is true the stacked layout changes based on whether the | 83 // If |adjust_layout| is true the stacked layout changes based on whether the |
| 84 // user uses a mouse or a touch device with the tabstrip. | 84 // user uses a mouse or a touch device with the tabstrip. |
| 85 void set_adjust_layout(bool adjust_layout) { adjust_layout_ = adjust_layout; } | 85 void set_adjust_layout(bool adjust_layout) { adjust_layout_ = adjust_layout; } |
| 86 | 86 |
| 87 // |stacked_layout_| defines what should happen when the tabs won't fit at | 87 // |stacked_layout_| defines what should happen when the tabs won't fit at |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 bool IsAnimating() const; | 204 bool IsAnimating() const; |
| 205 | 205 |
| 206 // Stops any ongoing animations. If |layout| is true and an animation is | 206 // Stops any ongoing animations. If |layout| is true and an animation is |
| 207 // ongoing this does a layout. | 207 // ongoing this does a layout. |
| 208 void StopAnimating(bool layout); | 208 void StopAnimating(bool layout); |
| 209 | 209 |
| 210 // Called to indicate whether the given URL is a supported file. | 210 // Called to indicate whether the given URL is a supported file. |
| 211 void FileSupported(const GURL& url, bool supported); | 211 void FileSupported(const GURL& url, bool supported); |
| 212 | 212 |
| 213 // TabController overrides: | 213 // TabController overrides: |
| 214 virtual const ui::ListSelectionModel& GetSelectionModel() override; | 214 const ui::ListSelectionModel& GetSelectionModel() override; |
| 215 virtual bool SupportsMultipleSelection() override; | 215 bool SupportsMultipleSelection() override; |
| 216 virtual void SelectTab(Tab* tab) override; | 216 void SelectTab(Tab* tab) override; |
| 217 virtual void ExtendSelectionTo(Tab* tab) override; | 217 void ExtendSelectionTo(Tab* tab) override; |
| 218 virtual void ToggleSelected(Tab* tab) override; | 218 void ToggleSelected(Tab* tab) override; |
| 219 virtual void AddSelectionFromAnchorTo(Tab* tab) override; | 219 void AddSelectionFromAnchorTo(Tab* tab) override; |
| 220 virtual void CloseTab(Tab* tab, CloseTabSource source) override; | 220 void CloseTab(Tab* tab, CloseTabSource source) override; |
| 221 virtual void ToggleTabAudioMute(Tab* tab) override; | 221 void ToggleTabAudioMute(Tab* tab) override; |
| 222 virtual void ShowContextMenuForTab(Tab* tab, | 222 void ShowContextMenuForTab(Tab* tab, |
| 223 const gfx::Point& p, | 223 const gfx::Point& p, |
| 224 ui::MenuSourceType source_type) override; | 224 ui::MenuSourceType source_type) override; |
| 225 virtual bool IsActiveTab(const Tab* tab) const override; | 225 bool IsActiveTab(const Tab* tab) const override; |
| 226 virtual bool IsTabSelected(const Tab* tab) const override; | 226 bool IsTabSelected(const Tab* tab) const override; |
| 227 virtual bool IsTabPinned(const Tab* tab) const override; | 227 bool IsTabPinned(const Tab* tab) const override; |
| 228 virtual void MaybeStartDrag( | 228 void MaybeStartDrag( |
| 229 Tab* tab, | 229 Tab* tab, |
| 230 const ui::LocatedEvent& event, | 230 const ui::LocatedEvent& event, |
| 231 const ui::ListSelectionModel& original_selection) override; | 231 const ui::ListSelectionModel& original_selection) override; |
| 232 virtual void ContinueDrag(views::View* view, | 232 void ContinueDrag(views::View* view, const ui::LocatedEvent& event) override; |
| 233 const ui::LocatedEvent& event) override; | 233 bool EndDrag(EndDragReason reason) override; |
| 234 virtual bool EndDrag(EndDragReason reason) override; | 234 Tab* GetTabAt(Tab* tab, const gfx::Point& tab_in_tab_coordinates) override; |
| 235 virtual Tab* GetTabAt(Tab* tab, | 235 void OnMouseEventInTab(views::View* source, |
| 236 const gfx::Point& tab_in_tab_coordinates) override; | 236 const ui::MouseEvent& event) override; |
| 237 virtual void OnMouseEventInTab(views::View* source, | 237 bool ShouldPaintTab(const Tab* tab, gfx::Rect* clip) override; |
| 238 const ui::MouseEvent& event) override; | 238 bool IsImmersiveStyle() const override; |
| 239 virtual bool ShouldPaintTab(const Tab* tab, gfx::Rect* clip) override; | 239 void UpdateTabAccessibilityState(const Tab* tab, |
| 240 virtual bool IsImmersiveStyle() const override; | 240 ui::AXViewState* state) override; |
| 241 virtual void UpdateTabAccessibilityState(const Tab* tab, | |
| 242 ui::AXViewState* state) override; | |
| 243 | 241 |
| 244 // MouseWatcherListener overrides: | 242 // MouseWatcherListener overrides: |
| 245 virtual void MouseMovedOutOfHost() override; | 243 void MouseMovedOutOfHost() override; |
| 246 | 244 |
| 247 // views::View overrides: | 245 // views::View overrides: |
| 248 virtual void Layout() override; | 246 void Layout() override; |
| 249 virtual void PaintChildren(gfx::Canvas* canvas, | 247 void PaintChildren(gfx::Canvas* canvas, |
| 250 const views::CullSet& cull_set) override; | 248 const views::CullSet& cull_set) override; |
| 251 virtual const char* GetClassName() const override; | 249 const char* GetClassName() const override; |
| 252 virtual gfx::Size GetPreferredSize() const override; | 250 gfx::Size GetPreferredSize() const override; |
| 253 // NOTE: the drag and drop methods are invoked from FrameView. This is done | 251 // NOTE: the drag and drop methods are invoked from FrameView. This is done |
| 254 // to allow for a drop region that extends outside the bounds of the TabStrip. | 252 // to allow for a drop region that extends outside the bounds of the TabStrip. |
| 255 virtual void OnDragEntered(const ui::DropTargetEvent& event) override; | 253 void OnDragEntered(const ui::DropTargetEvent& event) override; |
| 256 virtual int OnDragUpdated(const ui::DropTargetEvent& event) override; | 254 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
| 257 virtual void OnDragExited() override; | 255 void OnDragExited() override; |
| 258 virtual int OnPerformDrop(const ui::DropTargetEvent& event) override; | 256 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
| 259 virtual void GetAccessibleState(ui::AXViewState* state) override; | 257 void GetAccessibleState(ui::AXViewState* state) override; |
| 260 virtual views::View* GetTooltipHandlerForPoint( | 258 views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override; |
| 261 const gfx::Point& point) override; | |
| 262 | 259 |
| 263 // Returns preferred height in immersive style. | 260 // Returns preferred height in immersive style. |
| 264 static int GetImmersiveHeight(); | 261 static int GetImmersiveHeight(); |
| 265 | 262 |
| 266 private: | 263 private: |
| 267 typedef std::vector<Tab*> Tabs; | 264 typedef std::vector<Tab*> Tabs; |
| 268 typedef std::map<int, Tabs> TabsClosingMap; | 265 typedef std::map<int, Tabs> TabsClosingMap; |
| 269 typedef std::pair<TabsClosingMap::iterator, | 266 typedef std::pair<TabsClosingMap::iterator, |
| 270 Tabs::iterator> FindClosingTabResult; | 267 Tabs::iterator> FindClosingTabResult; |
| 271 | 268 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 | 556 |
| 560 // Returns true if |touch_layout_| is needed. | 557 // Returns true if |touch_layout_| is needed. |
| 561 bool NeedsTouchLayout() const; | 558 bool NeedsTouchLayout() const; |
| 562 | 559 |
| 563 // Sets the value of |reset_to_shrink_on_exit_|. If true |mouse_watcher_| is | 560 // Sets the value of |reset_to_shrink_on_exit_|. If true |mouse_watcher_| is |
| 564 // used to track when the mouse truly exits the tabstrip and the stacked | 561 // used to track when the mouse truly exits the tabstrip and the stacked |
| 565 // layout is reset. | 562 // layout is reset. |
| 566 void SetResetToShrinkOnExit(bool value); | 563 void SetResetToShrinkOnExit(bool value); |
| 567 | 564 |
| 568 // views::ButtonListener implementation: | 565 // views::ButtonListener implementation: |
| 569 virtual void ButtonPressed(views::Button* sender, | 566 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 570 const ui::Event& event) override; | |
| 571 | 567 |
| 572 // View overrides. | 568 // View overrides. |
| 573 virtual const views::View* GetViewByID(int id) const override; | 569 const views::View* GetViewByID(int id) const override; |
| 574 virtual bool OnMousePressed(const ui::MouseEvent& event) override; | 570 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 575 virtual bool OnMouseDragged(const ui::MouseEvent& event) override; | 571 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 576 virtual void OnMouseReleased(const ui::MouseEvent& event) override; | 572 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 577 virtual void OnMouseCaptureLost() override; | 573 void OnMouseCaptureLost() override; |
| 578 virtual void OnMouseMoved(const ui::MouseEvent& event) override; | 574 void OnMouseMoved(const ui::MouseEvent& event) override; |
| 579 virtual void OnMouseEntered(const ui::MouseEvent& event) override; | 575 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 580 | 576 |
| 581 // ui::EventHandler overrides. | 577 // ui::EventHandler overrides. |
| 582 virtual void OnGestureEvent(ui::GestureEvent* event) override; | 578 void OnGestureEvent(ui::GestureEvent* event) override; |
| 583 | 579 |
| 584 // views::ViewTargeterDelegate: | 580 // views::ViewTargeterDelegate: |
| 585 virtual views::View* TargetForRect(views::View* root, | 581 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; |
| 586 const gfx::Rect& rect) override; | |
| 587 | 582 |
| 588 // -- Member Variables ------------------------------------------------------ | 583 // -- Member Variables ------------------------------------------------------ |
| 589 | 584 |
| 590 // There is a one-to-one mapping between each of the tabs in the | 585 // There is a one-to-one mapping between each of the tabs in the |
| 591 // TabStripController (TabStripModel) and |tabs_|. Because we animate tab | 586 // TabStripController (TabStripModel) and |tabs_|. Because we animate tab |
| 592 // removal there exists a period of time where a tab is displayed but not in | 587 // removal there exists a period of time where a tab is displayed but not in |
| 593 // the model. When this occurs the tab is removed from |tabs_| and placed in | 588 // the model. When this occurs the tab is removed from |tabs_| and placed in |
| 594 // |tabs_closing_map_|. When the animation completes the tab is removed from | 589 // |tabs_closing_map_|. When the animation completes the tab is removed from |
| 595 // |tabs_closing_map_|. The painting code ensures both sets of tabs are | 590 // |tabs_closing_map_|. The painting code ensures both sets of tabs are |
| 596 // painted, and the event handling code ensures only tabs in |tabs_| are used. | 591 // painted, and the event handling code ensures only tabs in |tabs_| are used. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 bool immersive_style_; | 672 bool immersive_style_; |
| 678 | 673 |
| 679 // Our observers. | 674 // Our observers. |
| 680 typedef ObserverList<TabStripObserver> TabStripObservers; | 675 typedef ObserverList<TabStripObserver> TabStripObservers; |
| 681 TabStripObservers observers_; | 676 TabStripObservers observers_; |
| 682 | 677 |
| 683 DISALLOW_COPY_AND_ASSIGN(TabStrip); | 678 DISALLOW_COPY_AND_ASSIGN(TabStrip); |
| 684 }; | 679 }; |
| 685 | 680 |
| 686 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ | 681 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ |
| OLD | NEW |