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

Side by Side Diff: chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.h

Issue 6250141: Sidebar mini tabs UI (views version).... Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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_SIDEBAR_SIDEBAR_BASE_TAB_STRIP_H_
6 #define CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_STRIP_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/scoped_ptr.h"
13 #include "chrome/browser/ui/views/sidebar/sidebar_tab_controller.h"
14 #include "chrome/browser/ui/views/sidebar/sidebar_tab_renderer_data.h"
15 #include "views/animation/bounds_animator.h"
16 #include "views/view.h"
17
18 class SidebarBaseTab;
19 class SidebarTabStripController;
20
21 // Base class for the view tab strip implementations.
22 class SidebarBaseTabStrip : public views::View,
23 public SidebarTabController,
24 private views::BoundsAnimatorObserver {
25 public:
26 explicit SidebarBaseTabStrip(SidebarTabStripController* controller);
27 virtual ~SidebarBaseTabStrip();
28
29 // views::View overrides:
30 virtual void OnBoundsChanged() OVERRIDE;
31
32 // SidebarTabController overrides:
33 virtual void SelectTab(SidebarBaseTab* tab);
34 virtual bool IsTabSelected(const SidebarBaseTab* tab);
35 virtual bool IsSidebarExpanded();
36
37 // Gets the number of Tabs in the tab strip.
38 // WARNING: this is the number of tabs displayed by the tab strip, which if
39 // an animation is ongoing is not necessarily the same as the number of tabs
40 // in the model.
41 int tab_count() const { return static_cast<int>(tab_data_.size()); }
42
43 // Returns the tab at the specified tab index.
44 SidebarBaseTab* base_tab_at_tab_index(int tab_index) const {
45 return tab_data_[tab_index].tab;
46 }
47
48 SidebarTabStripController* controller() const { return controller_.get(); }
49
50 // Returns true if Tabs in this SidebarTabStrip are currently changing size
51 // or position.
52 bool IsAnimating() const;
53
54 // Adds a tab at the specified index.
55 virtual void AddTabAt(int model_index,
56 bool animate,
57 const SidebarTabRendererData& data);
58
59 // Removes a tab at the specified index.
60 virtual void RemoveTabAt(int model_index, bool animate);
61
62 // Selects a tab at the specified index.
63 virtual void SelectTabAt(int new_model_index);
64
65 // Sets the tab data at the specified model index.
66 virtual void SetTabData(int model_index, const SidebarTabRendererData& data);
67
68 // Returns the tab at the specified model index.
69 SidebarBaseTab* GetBaseTabAtModelIndex(int model_index) const;
70
71 // Returns the index of the specified tab in the model coordiate system, or
72 // -1 if tab is closing or not valid.
73 int GetModelIndexOfBaseTab(const SidebarBaseTab* tab) const;
74
75 // Returns the index into |tab_data_| corresponding to the index from the
76 // TabStripModel, or |tab_data_.size()| if there is no tab representing
77 // |model_index|.
78 int ModelIndexToTabIndex(int model_index) const;
79
80 // Move all the views to their ideal bounds.
81 virtual void SetToIdealBounds();
82
83 protected:
84 // Creates and returns a new tab. The caller owns the returned tab.
85 virtual SidebarBaseTab* CreateTab() = 0;
86
87 // Invoked from |AddTabAt| after the newly created tab has been inserted.
88 virtual void StartInsertTabAnimation(int model_index) = 0;
89
90 // Starts the remove tab animation.
91 virtual void StartRemoveTabAnimation(int model_index) = 0;
92
93 // Resets the bounds of all tabs.
94 virtual void GenerateIdealBounds() = 0;
95
96 // Animates all the views to their ideal bounds.
97 // NOTE: this does *not* invoke GenerateIdealBounds, it uses the bounds
98 // currently set in ideal_bounds.
99 void AnimateToIdealBounds();
100
101 // Stops any ongoing animations.
102 void StopAnimating();
103
104 // Retrieves the ideal bounds for the tab at the specified index.
105 const gfx::Rect& ideal_bounds(int tab_data_index) {
106 return tab_data_[tab_data_index].ideal_bounds;
107 }
108 void set_ideal_bounds(int index, const gfx::Rect& bounds) {
109 tab_data_[index].ideal_bounds = bounds;
110 }
111
112 // Updates tab strip size to match the current size and position of all tabs.
113 void UpdateViewBounds();
114
115 private:
116 // The tabs we contain, and their last generated "good" bounds.
117 struct TabData {
118 SidebarBaseTab* tab;
119 gfx::Rect ideal_bounds;
120 };
121
122 // BoundsAnimatorObserver overrides:
123 virtual void OnBoundsAnimatorProgressed(
124 views::BoundsAnimator* animator) OVERRIDE;
125 virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) OVERRIDE;
126
127 // Cleans up the tab at tab_data_index from the SidebarTabStrip.
128 void RemoveAndDeleteTab(int tab_data_index);
129
130 // Removes all tabs which are marked as closing.
131 void RemoveClosingTabs();
132
133 const scoped_ptr<SidebarTabStripController> controller_;
134
135 std::vector<TabData> tab_data_;
136
137 views::BoundsAnimator bounds_animator_;
138
139 DISALLOW_COPY_AND_ASSIGN(SidebarBaseTabStrip);
140 };
141
142 #endif // CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_STRIP_H_
143
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/sidebar/sidebar_base_tab.cc ('k') | chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698