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

Side by Side Diff: chrome/browser/ui/views/ash/tab_scrubber.h

Issue 11881042: highlight intermediate tabs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable tests for win7_aura Created 7 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/ash/tab_scrubber.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_ASH_TAB_SCRUBBER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_
6 #define CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_
7 7
8 #include "base/timer.h"
9 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h"
8 #include "content/public/browser/notification_observer.h" 10 #include "content/public/browser/notification_observer.h"
9 #include "content/public/browser/notification_registrar.h" 11 #include "content/public/browser/notification_registrar.h"
12 #include "ui/base/animation/animation_delegate.h"
10 #include "ui/base/events/event_handler.h" 13 #include "ui/base/events/event_handler.h"
11 14
12 class Browser; 15 class Browser;
13 class Tab; 16 class TabStrip;
17
18 namespace gfx {
19 class Point;
20 }
14 21
15 // Class to enable quick tab switching via Ctrl-left-drag. 22 // Class to enable quick tab switching via Ctrl-left-drag.
16 // Notes: this is experimental, and disables ctrl-clicks. It should not be 23 // Notes: this is experimental, and disables ctrl-clicks. It should not be
17 // enabled other than through flags until we implement 3 finger drag as the 24 // enabled other than through flags until we implement 3 finger drag as the
18 // mechanism to invoke it. At that point we will add test coverage. 25 // mechanism to invoke it. At that point we will add test coverage.
19 class TabScrubber : public ui::EventHandler, 26 class TabScrubber : public ui::EventHandler,
20 public content::NotificationObserver { 27 public content::NotificationObserver,
28 public TabStripObserver {
21 public: 29 public:
30 enum Direction {LEFT, RIGHT};
31
32 // Returns a the single instance of a TabScrubber.
22 static TabScrubber* GetInstance(); 33 static TabScrubber* GetInstance();
23 34
35 // Returns the virtual position of a swipe starting in the tab at |index|,
36 // base on the |direction|.
37 static gfx::Point GetStartPoint(TabStrip* tab_strip,
38 int index,
39 TabScrubber::Direction direction);
40
41 void set_activation_delay(base::TimeDelta activation_delay) {
42 activation_delay_ = activation_delay;
43 }
44 base::TimeDelta activation_delay() const { return activation_delay_; }
45 int highlighted_tab() const { return highlighted_tab_; }
46 bool IsActivationPending();
47
24 private: 48 private:
25 TabScrubber(); 49 TabScrubber();
26 virtual ~TabScrubber(); 50 virtual ~TabScrubber();
27 51
28 // ui::EventHandler overrides: 52 // ui::EventHandler overrides:
29 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; 53 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
30 54
31 // content::NotificationObserver overrides: 55 // content::NotificationObserver overrides:
32 virtual void Observe(int type, 56 virtual void Observe(int type,
33 const content::NotificationSource& source, 57 const content::NotificationSource& source,
34 const content::NotificationDetails& details) OVERRIDE; 58 const content::NotificationDetails& details) OVERRIDE;
35 59
60 // TabStripObserver overrides.
61 virtual void TabStripAddedTabAt(TabStrip* tab_strip, int index) OVERRIDE;
62 virtual void TabStripMovedTab(TabStrip* tab_strip,
63 int from_index,
64 int to_index) OVERRIDE;
65 virtual void TabStripRemovedTabAt(TabStrip* tab_strip, int index) OVERRIDE;
66 virtual void TabStripDeleted(TabStrip* tab_strip) OVERRIDE;
67
36 Browser* GetActiveBrowser(); 68 Browser* GetActiveBrowser();
37 void StartScrubbing(); 69 void FinishScrub(bool activate);
38 void StopScrubbing(); 70 void CancelImmersiveReveal();
39 71
40 // Indicates that we are currently scrubbing. 72 // Are we currently scrubbing?.
41 bool scrubbing_; 73 bool scrubbing_;
42 // The browser that we are scrubbing. 74 // The last browser we used for scrubbing, NULL if |scrubbing_| is
75 // false and there is no pending work.
43 Browser* browser_; 76 Browser* browser_;
44 // The x value of the event that initiated scrubbing. 77 // The current accumulated x and y positions of a swipe, in
45 float scroll_x_; 78 // the coordinates of the TabStrip of |browser_|
46 float scroll_y_; 79 float swipe_x_;
80 float swipe_y_;
81 // The direction the current swipe is headed.
82 Direction swipe_direction_;
83 // The index of the tab that is currently highlighted.
84 int highlighted_tab_;
85 // Timer to control a delayed activation of the |highlighted_tab_|.
86 base::Timer activate_timer_;
87 // Time to wait before newly selected tab becomes active.
88 base::TimeDelta activation_delay_;
89 // Indicates if we were in immersive mode and forced the tabs to be
90 // revealed.
91 bool should_cancel_immersive_reveal_;
92 // Timer to control the cancel of an immersive reveal.
93 base::Timer cancel_immersive_reveal_timer_;
47 94
48 content::NotificationRegistrar registrar_; 95 content::NotificationRegistrar registrar_;
96 base::WeakPtrFactory<TabScrubber> weak_ptr_factory_;
49 97
50 DISALLOW_COPY_AND_ASSIGN(TabScrubber); 98 DISALLOW_COPY_AND_ASSIGN(TabScrubber);
51 }; 99 };
52 100
53 #endif // CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_ 101 #endif // CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/ash/tab_scrubber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698