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

Side by Side Diff: chrome/browser/views/tabs/side_tab.cc

Issue 1141005: Revert r42156, r42157, r42160. Allow dynamic switching in and out of sidetabs... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 9 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 | « chrome/browser/views/tabs/side_tab.h ('k') | chrome/browser/views/tabs/side_tab_strip.h » ('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) 2010 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/views/tabs/side_tab.h" 5 #include "chrome/browser/views/tabs/side_tab.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "app/theme_provider.h" 9 #include "app/theme_provider.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 views::ImageButton* close_button = new views::ImageButton(this); 50 views::ImageButton* close_button = new views::ImageButton(this);
51 close_button->SetImage(views::CustomButton::BS_NORMAL, close_button_n_); 51 close_button->SetImage(views::CustomButton::BS_NORMAL, close_button_n_);
52 close_button->SetImage(views::CustomButton::BS_HOT, close_button_h_); 52 close_button->SetImage(views::CustomButton::BS_HOT, close_button_h_);
53 close_button->SetImage(views::CustomButton::BS_PUSHED, close_button_p_); 53 close_button->SetImage(views::CustomButton::BS_PUSHED, close_button_p_);
54 close_button_ = close_button; 54 close_button_ = close_button;
55 AddChildView(close_button_); 55 AddChildView(close_button_);
56 56
57 hover_animation_.reset(new SlideAnimation(this)); 57 hover_animation_.reset(new SlideAnimation(this));
58 hover_animation_->SetSlideDuration(kHoverDurationMs); 58 hover_animation_->SetSlideDuration(kHoverDurationMs);
59
60 SetContextMenuController(this);
61 } 59 }
62 60
63 SideTab::~SideTab() { 61 SideTab::~SideTab() {
64 } 62 }
65 63
66 void SideTab::SetNetworkState(SideTabStripModel::NetworkState state) { 64 void SideTab::SetNetworkState(SideTabStripModel::NetworkState state) {
67 if (current_state_ != state) { 65 if (current_state_ != state) {
68 // The waiting animation is the reverse of the loading animation, but at a 66 // The waiting animation is the reverse of the loading animation, but at a
69 // different rate - the following reverses and scales the animation_frame_ 67 // different rate - the following reverses and scales the animation_frame_
70 // so that the frame is at an equivalent position when going from one 68 // so that the frame is at an equivalent position when going from one
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 103
106 //////////////////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////////////////
107 // SideTab, views::ButtonListener implementation: 105 // SideTab, views::ButtonListener implementation:
108 106
109 void SideTab::ButtonPressed(views::Button* sender, const views::Event& event) { 107 void SideTab::ButtonPressed(views::Button* sender, const views::Event& event) {
110 DCHECK(sender == close_button_); 108 DCHECK(sender == close_button_);
111 model_->CloseTab(this); 109 model_->CloseTab(this);
112 } 110 }
113 111
114 //////////////////////////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////////////////////////
115 // SideTab, views::ContextMenuController implementation:
116
117 void SideTab::ShowContextMenu(views::View* source,
118 const gfx::Point& p,
119 bool is_mouse_gesture) {
120 model_->ShowContextMenu(this, p);
121 }
122
123 ////////////////////////////////////////////////////////////////////////////////
124 // SideTab, views::View overrides: 113 // SideTab, views::View overrides:
125 114
126 void SideTab::Layout() { 115 void SideTab::Layout() {
127 int icon_y; 116 int icon_y;
128 int icon_x = icon_y = (height() - kIconSize) / 2; 117 int icon_x = icon_y = (height() - kIconSize) / 2;
129 icon_bounds_.SetRect(icon_x, icon_y, kIconSize, kIconSize); 118 icon_bounds_.SetRect(icon_x, icon_y, kIconSize, kIconSize);
130 119
131 gfx::Size ps = close_button_->GetPreferredSize(); 120 gfx::Size ps = close_button_->GetPreferredSize();
132 int close_y = (height() - ps.height()) / 2; 121 int close_y = (height() - ps.height()) / 2;
133 close_button_->SetBounds( 122 close_button_->SetBounds(width() - ps.width() - close_y, close_y, ps.width(),
134 std::max(0, width() - ps.width() - close_y), 123 ps.height());
135 close_y,
136 ps.width(),
137 ps.height());
138 124
139 int title_y = (height() - font_->height()) / 2; 125 int title_y = (height() - font_->height()) / 2;
140 int title_x = icon_bounds_.right() + kIconTitleSpacing; 126 int title_x = icon_bounds_.right() + kIconTitleSpacing;
141 title_bounds_.SetRect( 127 title_bounds_.SetRect(title_x, title_y,
142 title_x, 128 close_button_->x() - kTitleCloseSpacing - title_x,
143 title_y, 129 font_->height());
144 std::max(0, close_button_->x() - kTitleCloseSpacing - title_x),
145 font_->height());
146 } 130 }
147 131
148 void SideTab::Paint(gfx::Canvas* canvas) { 132 void SideTab::Paint(gfx::Canvas* canvas) {
149 SkPaint paint; 133 SkPaint paint;
150 paint.setColor(kTabBackgroundColor); 134 paint.setColor(kTabBackgroundColor);
151 paint.setAntiAlias(true); 135 paint.setAntiAlias(true);
152 gfx::Path tab_shape; 136 gfx::Path tab_shape;
153 FillTabShapePath(&tab_shape); 137 FillTabShapePath(&tab_shape);
154 canvas->drawPath(tab_shape, paint); 138 canvas->drawPath(tab_shape, paint);
155 139
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 waiting_animation_frame_count = 250 waiting_animation_frame_count =
267 waiting_animation_frames->width() / waiting_animation_frames->height(); 251 waiting_animation_frames->width() / waiting_animation_frames->height();
268 252
269 waiting_to_loading_frame_count_ratio = 253 waiting_to_loading_frame_count_ratio =
270 waiting_animation_frame_count / loading_animation_frame_count; 254 waiting_animation_frame_count / loading_animation_frame_count;
271 255
272 initialized = true; 256 initialized = true;
273 } 257 }
274 } 258 }
275 259
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/side_tab.h ('k') | chrome/browser/views/tabs/side_tab_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698