Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/views/tabs/tab_strip.h

Issue 155242: Add temporary TabStripWrapper interface that is implemented by both TabStrip ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_VIEWS_TABS_TAB_STRIP_H_ 5 #ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
6 #define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ 6 #define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
7 7
8 #include "base/gfx/point.h" 8 #include "base/gfx/point.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/tabs/tab_strip_model.h" 10 #include "chrome/browser/tabs/tab_strip_model.h"
11 #include "chrome/browser/views/tabs/tab.h" 11 #include "chrome/browser/views/tabs/tab.h"
12 #include "chrome/browser/views/tabs/tab_strip_wrapper.h"
12 #include "views/controls/button/image_button.h" 13 #include "views/controls/button/image_button.h"
13 #include "views/view.h" 14 #include "views/view.h"
14 #if defined(OS_WIN) 15 #if defined(OS_WIN)
15 #include "views/widget/widget_win.h" 16 #include "views/widget/widget_win.h"
16 #endif 17 #endif
17 18
18 class DraggedTabController; 19 class DraggedTabController;
19 class ScopedMouseCloseWidthCalculator; 20 class ScopedMouseCloseWidthCalculator;
20 class TabStripModel; 21 class TabStripModel;
21 22
(...skipping 11 matching lines...) Expand all
33 // container for Tabs, and is also responsible for creating them. 34 // container for Tabs, and is also responsible for creating them.
34 // - It takes part in Tab Drag & Drop with Tab, TabDragHelper and 35 // - It takes part in Tab Drag & Drop with Tab, TabDragHelper and
35 // DraggedTab, focusing on tasks that require reshuffling other tabs 36 // DraggedTab, focusing on tasks that require reshuffling other tabs
36 // in response to dragged tabs. 37 // in response to dragged tabs.
37 // 38 //
38 /////////////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////////////
39 class TabStrip : public views::View, 40 class TabStrip : public views::View,
40 public TabStripModelObserver, 41 public TabStripModelObserver,
41 public Tab::TabDelegate, 42 public Tab::TabDelegate,
42 public views::ButtonListener, 43 public views::ButtonListener,
43 public MessageLoopForUI::Observer { 44 public MessageLoopForUI::Observer,
45 public TabStripWrapper {
44 public: 46 public:
45 TabStrip(TabStripModel* model); 47 TabStrip(TabStripModel* model);
46 virtual ~TabStrip(); 48 virtual ~TabStrip();
47 49
48 // Returns the preferred height of this TabStrip. This is based on the
49 // typical height of its constituent tabs.
50 int GetPreferredHeight();
51
52 // Returns true if the TabStrip can accept input events. This returns false 50 // Returns true if the TabStrip can accept input events. This returns false
53 // when the TabStrip is animating to a new state and as such the user should 51 // when the TabStrip is animating to a new state and as such the user should
54 // not be allowed to interact with the TabStrip. 52 // not be allowed to interact with the TabStrip.
55 bool CanProcessInputEvents() const; 53 bool CanProcessInputEvents() const;
56 54
57 // Returns true if the specified point (in TabStrip coordinates) is within a
58 // portion of the TabStrip that should be treated as the containing Window's
59 // titlebar for dragging purposes.
60 // TODO(beng): (Cleanup) should be const, but GetViewForPoint isn't, so fie!
61 bool PointIsWithinWindowCaption(const gfx::Point& point);
62
63 // Return true if this tab strip is compatible with the provided tab strip.
64 // Compatible tab strips can transfer tabs during drag and drop.
65 bool IsCompatibleWith(TabStrip* other);
66
67 // Returns true if Tabs in this TabStrip are currently changing size or
68 // position.
69 bool IsAnimating() const;
70
71 // Accessors for the model and individual Tabs. 55 // Accessors for the model and individual Tabs.
72 TabStripModel* model() { return model_; } 56 TabStripModel* model() { return model_; }
73 57
74 // Returns true if there is an active drag session.
75 bool IsDragSessionActive() const { return drag_controller_.get() != NULL; }
76
77 // Destroys the active drag controller. 58 // Destroys the active drag controller.
78 void DestroyDragController(); 59 void DestroyDragController();
79 60
80 // Removes the drag source Tab from this TabStrip, and deletes it. 61 // Removes the drag source Tab from this TabStrip, and deletes it.
81 void DestroyDraggedSourceTab(Tab* tab); 62 void DestroyDraggedSourceTab(Tab* tab);
82 63
83 // Retrieve the ideal bounds for the Tab at the specified index. 64 // Retrieve the ideal bounds for the Tab at the specified index.
84 gfx::Rect GetIdealBounds(int index); 65 gfx::Rect GetIdealBounds(int index);
85 66
86 // Updates loading animations for the TabStrip.
87 void UpdateLoadingAnimations();
88
89 // Set the background offset used by inactive tabs to match the frame image.
90 void SetBackgroundOffset(gfx::Point offset);
91
92 // Create the new tab button. 67 // Create the new tab button.
93 void InitTabStripButtons(); 68 void InitTabStripButtons();
94 69
95 // views::View overrides: 70 // views::View overrides:
96 virtual void PaintChildren(gfx::Canvas* canvas); 71 virtual void PaintChildren(gfx::Canvas* canvas);
97 virtual views::View* GetViewByID(int id) const; 72 virtual views::View* GetViewByID(int id) const;
98 virtual void Layout(); 73 virtual void Layout();
99 virtual gfx::Size GetPreferredSize(); 74 virtual gfx::Size GetPreferredSize();
100 // NOTE: the drag and drop methods are invoked from FrameView. This is done to 75 // NOTE: the drag and drop methods are invoked from FrameView. This is done to
101 // allow for a drop region that extends outside the bounds of the TabStrip. 76 // allow for a drop region that extends outside the bounds of the TabStrip.
102 virtual void OnDragEntered(const views::DropTargetEvent& event); 77 virtual void OnDragEntered(const views::DropTargetEvent& event);
103 virtual int OnDragUpdated(const views::DropTargetEvent& event); 78 virtual int OnDragUpdated(const views::DropTargetEvent& event);
104 virtual void OnDragExited(); 79 virtual void OnDragExited();
105 virtual int OnPerformDrop(const views::DropTargetEvent& event); 80 virtual int OnPerformDrop(const views::DropTargetEvent& event);
106 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); 81 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
107 virtual bool GetAccessibleName(std::wstring* name); 82 virtual bool GetAccessibleName(std::wstring* name);
108 virtual void SetAccessibleName(const std::wstring& name); 83 virtual void SetAccessibleName(const std::wstring& name);
109 virtual views::View* GetViewForPoint(const gfx::Point& point); 84 virtual views::View* GetViewForPoint(const gfx::Point& point);
110 virtual void ThemeChanged(); 85 virtual void ThemeChanged();
86 protected:
87 virtual void ViewHierarchyChanged(bool is_add,
88 views::View* parent,
89 views::View* child);
111 90
112 protected:
113 // TabStripModelObserver implementation: 91 // TabStripModelObserver implementation:
114 virtual void TabInsertedAt(TabContents* contents, 92 virtual void TabInsertedAt(TabContents* contents,
115 int index, 93 int index,
116 bool foreground); 94 bool foreground);
117 virtual void TabDetachedAt(TabContents* contents, int index); 95 virtual void TabDetachedAt(TabContents* contents, int index);
118 virtual void TabSelectedAt(TabContents* old_contents, 96 virtual void TabSelectedAt(TabContents* old_contents,
119 TabContents* contents, 97 TabContents* contents,
120 int index, 98 int index,
121 bool user_gesture); 99 bool user_gesture);
122 virtual void TabMoved(TabContents* contents, int from_index, int to_index); 100 virtual void TabMoved(TabContents* contents, int from_index, int to_index);
(...skipping 23 matching lines...) Expand all
146 124
147 // MessageLoop::Observer implementation: 125 // MessageLoop::Observer implementation:
148 #if defined(OS_WIN) 126 #if defined(OS_WIN)
149 virtual void WillProcessMessage(const MSG& msg); 127 virtual void WillProcessMessage(const MSG& msg);
150 virtual void DidProcessMessage(const MSG& msg); 128 virtual void DidProcessMessage(const MSG& msg);
151 #else 129 #else
152 virtual void WillProcessEvent(GdkEvent* event); 130 virtual void WillProcessEvent(GdkEvent* event);
153 virtual void DidProcessEvent(GdkEvent* event); 131 virtual void DidProcessEvent(GdkEvent* event);
154 #endif 132 #endif
155 133
134 // TabStripWrapper implementation:
135 virtual int GetPreferredHeight();
136 virtual bool IsAnimating() const;
137 virtual void SetBackgroundOffset(gfx::Point offset);
138 virtual bool PointIsWithinWindowCaption(const gfx::Point& point);
139 virtual bool IsDragSessionActive() const;
140 virtual bool IsCompatibleWith(TabStripWrapper* other) const;
141 virtual void SetDraggedTabBounds(int tab_index,
142 const gfx::Rect& tab_bounds);
143 virtual void UpdateLoadingAnimations();
144 virtual views::View* GetView();
145 virtual BrowserTabStrip* AsBrowserTabStrip();
146 virtual TabStrip* AsTabStrip();
147
156 private: 148 private:
157 class InsertTabAnimation; 149 class InsertTabAnimation;
158 class MoveTabAnimation; 150 class MoveTabAnimation;
159 class RemoveTabAnimation; 151 class RemoveTabAnimation;
160 class ResizeLayoutAnimation; 152 class ResizeLayoutAnimation;
161 class TabAnimation; 153 class TabAnimation;
162 154
163 friend class DraggedTabController; 155 friend class DraggedTabController;
164 friend class InsertTabAnimation; 156 friend class InsertTabAnimation;
165 friend class MoveTabAnimation; 157 friend class MoveTabAnimation;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 }; 372 };
381 std::vector<TabData> tab_data_; 373 std::vector<TabData> tab_data_;
382 374
383 // The currently running animation. 375 // The currently running animation.
384 scoped_ptr<TabAnimation> active_animation_; 376 scoped_ptr<TabAnimation> active_animation_;
385 377
386 DISALLOW_COPY_AND_ASSIGN(TabStrip); 378 DISALLOW_COPY_AND_ASSIGN(TabStrip);
387 }; 379 };
388 380
389 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ 381 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/dragged_tab_controller.cc ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698