| 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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "chrome/browser/ui/views/tabs/tab.h" | 13 #include "chrome/browser/ui/views/tabs/tab.h" |
| 14 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 14 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
| 15 #include "ui/gfx/animation/animation_container.h" | 15 #include "ui/gfx/animation/animation_container.h" |
| 16 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
| 17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 18 #include "ui/views/animation/bounds_animator.h" | 18 #include "ui/views/animation/bounds_animator.h" |
| 19 #include "ui/views/controls/button/image_button.h" | 19 #include "ui/views/controls/button/image_button.h" |
| 20 #include "ui/views/mouse_watcher.h" | 20 #include "ui/views/mouse_watcher.h" |
| 21 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 22 #include "ui/views/view_model.h" | 22 #include "ui/views/view_model.h" |
| 23 #include "ui/views/view_targeter_delegate.h" |
| 23 | 24 |
| 24 class NewTabButton; | 25 class NewTabButton; |
| 25 class StackedTabStripLayout; | 26 class StackedTabStripLayout; |
| 26 class Tab; | 27 class Tab; |
| 27 class TabDragController; | 28 class TabDragController; |
| 28 class TabStripController; | 29 class TabStripController; |
| 29 class TabStripObserver; | 30 class TabStripObserver; |
| 30 | 31 |
| 31 namespace ui { | 32 namespace ui { |
| 32 class ListSelectionModel; | 33 class ListSelectionModel; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 // - It implements the TabStripModelObserver interface, and acts as a | 46 // - It implements the TabStripModelObserver interface, and acts as a |
| 46 // container for Tabs, and is also responsible for creating them. | 47 // container for Tabs, and is also responsible for creating them. |
| 47 // - It takes part in Tab Drag & Drop with Tab, TabDragHelper and | 48 // - It takes part in Tab Drag & Drop with Tab, TabDragHelper and |
| 48 // DraggedTab, focusing on tasks that require reshuffling other tabs | 49 // DraggedTab, focusing on tasks that require reshuffling other tabs |
| 49 // in response to dragged tabs. | 50 // in response to dragged tabs. |
| 50 // | 51 // |
| 51 /////////////////////////////////////////////////////////////////////////////// | 52 /////////////////////////////////////////////////////////////////////////////// |
| 52 class TabStrip : public views::View, | 53 class TabStrip : public views::View, |
| 53 public views::ButtonListener, | 54 public views::ButtonListener, |
| 54 public views::MouseWatcherListener, | 55 public views::MouseWatcherListener, |
| 56 public views::ViewTargeterDelegate, |
| 55 public TabController { | 57 public TabController { |
| 56 public: | 58 public: |
| 57 static const char kViewClassName[]; | 59 static const char kViewClassName[]; |
| 58 | 60 |
| 59 // Horizontal offset for the new tab button to bring it closer to the | 61 // Horizontal offset for the new tab button to bring it closer to the |
| 60 // rightmost tab. | 62 // rightmost tab. |
| 61 static const int kNewTabButtonHorizontalOffset; | 63 static const int kNewTabButtonHorizontalOffset; |
| 62 | 64 |
| 63 // The vertical offset of the tab strip button. This offset applies only to | 65 // The vertical offset of the tab strip button. This offset applies only to |
| 64 // restored windows. | 66 // restored windows. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 const views::CullSet& cull_set) OVERRIDE; | 242 const views::CullSet& cull_set) OVERRIDE; |
| 241 virtual const char* GetClassName() const OVERRIDE; | 243 virtual const char* GetClassName() const OVERRIDE; |
| 242 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 244 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 243 // NOTE: the drag and drop methods are invoked from FrameView. This is done | 245 // NOTE: the drag and drop methods are invoked from FrameView. This is done |
| 244 // to allow for a drop region that extends outside the bounds of the TabStrip. | 246 // to allow for a drop region that extends outside the bounds of the TabStrip. |
| 245 virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE; | 247 virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE; |
| 246 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; | 248 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; |
| 247 virtual void OnDragExited() OVERRIDE; | 249 virtual void OnDragExited() OVERRIDE; |
| 248 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; | 250 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; |
| 249 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 251 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
| 250 virtual views::View* GetEventHandlerForRect(const gfx::Rect& rect) OVERRIDE; | |
| 251 virtual views::View* GetTooltipHandlerForPoint( | 252 virtual views::View* GetTooltipHandlerForPoint( |
| 252 const gfx::Point& point) OVERRIDE; | 253 const gfx::Point& point) OVERRIDE; |
| 253 | 254 |
| 254 // Returns preferred height in immersive style. | 255 // Returns preferred height in immersive style. |
| 255 static int GetImmersiveHeight(); | 256 static int GetImmersiveHeight(); |
| 256 | 257 |
| 257 private: | 258 private: |
| 258 typedef std::vector<Tab*> Tabs; | 259 typedef std::vector<Tab*> Tabs; |
| 259 typedef std::map<int, Tabs> TabsClosingMap; | 260 typedef std::map<int, Tabs> TabsClosingMap; |
| 260 typedef std::pair<TabsClosingMap::iterator, | 261 typedef std::pair<TabsClosingMap::iterator, |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 573 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 573 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 574 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
| 574 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 575 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 575 virtual void OnMouseCaptureLost() OVERRIDE; | 576 virtual void OnMouseCaptureLost() OVERRIDE; |
| 576 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; | 577 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; |
| 577 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 578 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| 578 | 579 |
| 579 // ui::EventHandler overrides. | 580 // ui::EventHandler overrides. |
| 580 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 581 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 581 | 582 |
| 583 // views::ViewTargeterDelegate: |
| 584 virtual views::View* TargetForRect(views::View* root, |
| 585 const gfx::Rect& rect) OVERRIDE; |
| 586 |
| 582 // -- Member Variables ------------------------------------------------------ | 587 // -- Member Variables ------------------------------------------------------ |
| 583 | 588 |
| 584 // There is a one-to-one mapping between each of the tabs in the | 589 // There is a one-to-one mapping between each of the tabs in the |
| 585 // TabStripController (TabStripModel) and |tabs_|. Because we animate tab | 590 // TabStripController (TabStripModel) and |tabs_|. Because we animate tab |
| 586 // removal there exists a period of time where a tab is displayed but not in | 591 // removal there exists a period of time where a tab is displayed but not in |
| 587 // the model. When this occurs the tab is removed from |tabs_| and placed in | 592 // the model. When this occurs the tab is removed from |tabs_| and placed in |
| 588 // |tabs_closing_map_|. When the animation completes the tab is removed from | 593 // |tabs_closing_map_|. When the animation completes the tab is removed from |
| 589 // |tabs_closing_map_|. The painting code ensures both sets of tabs are | 594 // |tabs_closing_map_|. The painting code ensures both sets of tabs are |
| 590 // painted, and the event handling code ensures only tabs in |tabs_| are used. | 595 // painted, and the event handling code ensures only tabs in |tabs_| are used. |
| 591 views::ViewModel tabs_; | 596 views::ViewModel tabs_; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 bool immersive_style_; | 676 bool immersive_style_; |
| 672 | 677 |
| 673 // Our observers. | 678 // Our observers. |
| 674 typedef ObserverList<TabStripObserver> TabStripObservers; | 679 typedef ObserverList<TabStripObserver> TabStripObservers; |
| 675 TabStripObservers observers_; | 680 TabStripObservers observers_; |
| 676 | 681 |
| 677 DISALLOW_COPY_AND_ASSIGN(TabStrip); | 682 DISALLOW_COPY_AND_ASSIGN(TabStrip); |
| 678 }; | 683 }; |
| 679 | 684 |
| 680 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ | 685 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ |
| OLD | NEW |