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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.h

Issue 327273005: Revert of Use labels to display views tab titles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/tabs/tab.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_TABS_TAB_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" 13 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h"
14 #include "ui/base/layout.h" 14 #include "ui/base/layout.h"
15 #include "ui/gfx/animation/animation_delegate.h" 15 #include "ui/gfx/animation/animation_delegate.h"
16 #include "ui/gfx/point.h" 16 #include "ui/gfx/point.h"
17 #include "ui/views/context_menu_controller.h" 17 #include "ui/views/context_menu_controller.h"
18 #include "ui/views/controls/button/button.h" 18 #include "ui/views/controls/button/button.h"
19 #include "ui/views/controls/glow_hover_controller.h" 19 #include "ui/views/controls/glow_hover_controller.h"
20 #include "ui/views/view.h" 20 #include "ui/views/view.h"
21 21
22 class TabController; 22 class TabController;
23 23
24 namespace gfx { 24 namespace gfx {
25 class Animation; 25 class Animation;
26 class AnimationContainer; 26 class AnimationContainer;
27 class Font;
27 class LinearAnimation; 28 class LinearAnimation;
28 class MultiAnimation; 29 class MultiAnimation;
29 } 30 }
30 namespace views { 31 namespace views {
31 class ImageButton; 32 class ImageButton;
32 class Label;
33 } 33 }
34 34
35 /////////////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////////////
36 // 36 //
37 // A View that renders a Tab in a TabStrip. 37 // A View that renders a Tab in a TabStrip.
38 // 38 //
39 /////////////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////////////
40 class Tab : public gfx::AnimationDelegate, 40 class Tab : public gfx::AnimationDelegate,
41 public views::ButtonListener, 41 public views::ButtonListener,
42 public views::ContextMenuController, 42 public views::ContextMenuController,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; 178 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
179 virtual void OnMouseCaptureLost() OVERRIDE; 179 virtual void OnMouseCaptureLost() OVERRIDE;
180 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; 180 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
181 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; 181 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE;
182 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; 182 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
183 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; 183 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
184 184
185 // Overridden from ui::EventHandler: 185 // Overridden from ui::EventHandler:
186 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; 186 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
187 187
188 // Returns the bounds of the title and icon.
189 const gfx::Rect& GetTitleBounds() const;
190 const gfx::Rect& GetIconBounds() const;
191
188 // Invoked from Layout to adjust the position of the favicon or media 192 // Invoked from Layout to adjust the position of the favicon or media
189 // indicator for mini tabs. 193 // indicator for mini tabs.
190 void MaybeAdjustLeftForMiniTab(gfx::Rect* bounds) const; 194 void MaybeAdjustLeftForMiniTab(gfx::Rect* bounds) const;
191 195
192 // Invoked from SetData after |data_| has been updated to the new data. 196 // Invoked from SetData after |data_| has been updated to the new data.
193 void DataChanged(const TabRendererData& old); 197 void DataChanged(const TabRendererData& old);
194 198
195 // Paint with the normal tab style. 199 // Paint with the normal tab style.
196 void PaintTab(gfx::Canvas* canvas); 200 void PaintTab(gfx::Canvas* canvas);
197 201
198 // Paint with the "immersive mode" light-bar style. 202 // Paint with the "immersive mode" light-bar style.
199 void PaintImmersiveTab(gfx::Canvas* canvas); 203 void PaintImmersiveTab(gfx::Canvas* canvas);
200 204
201 // Paint various portions of the Tab 205 // Paint various portions of the Tab
202 void PaintTabBackground(gfx::Canvas* canvas); 206 void PaintTabBackground(gfx::Canvas* canvas);
203 void PaintInactiveTabBackgroundWithTitleChange( 207 void PaintInactiveTabBackgroundWithTitleChange(
204 gfx::Canvas* canvas, 208 gfx::Canvas* canvas,
205 gfx::MultiAnimation* animation); 209 gfx::MultiAnimation* animation);
206 void PaintInactiveTabBackground(gfx::Canvas* canvas); 210 void PaintInactiveTabBackground(gfx::Canvas* canvas);
207 void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, 211 void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas,
208 int tab_id); 212 int tab_id);
209 void PaintActiveTabBackground(gfx::Canvas* canvas); 213 void PaintActiveTabBackground(gfx::Canvas* canvas);
210 214
211 // Paints the favicon and media indicator icon, mirrored for RTL if needed. 215 // Paints the favicon, media indicator icon, etc., mirrored for RTL if needed.
212 void PaintIcon(gfx::Canvas* canvas); 216 void PaintIcon(gfx::Canvas* canvas);
213 void PaintMediaIndicator(gfx::Canvas* canvas); 217 void PaintMediaIndicator(gfx::Canvas* canvas);
218 void PaintTitle(gfx::Canvas* canvas, SkColor title_color);
214 219
215 // Invoked if data_.network_state changes, or the network_state is not none. 220 // Invoked if data_.network_state changes, or the network_state is not none.
216 void AdvanceLoadingAnimation(TabRendererData::NetworkState old_state, 221 void AdvanceLoadingAnimation(TabRendererData::NetworkState old_state,
217 TabRendererData::NetworkState state); 222 TabRendererData::NetworkState state);
218 223
219 // Returns the number of favicon-size elements that can fit in the tab's 224 // Returns the number of favicon-size elements that can fit in the tab's
220 // current size. 225 // current size.
221 int IconCapacity() const; 226 int IconCapacity() const;
222 227
223 // Returns whether the Tab should display a favicon. 228 // Returns whether the Tab should display a favicon.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 scoped_ptr<gfx::LinearAnimation> crash_icon_animation_; 319 scoped_ptr<gfx::LinearAnimation> crash_icon_animation_;
315 320
316 // Media indicator fade-in/out animation (i.e., only on show/hide, not a 321 // Media indicator fade-in/out animation (i.e., only on show/hide, not a
317 // continuous animation). 322 // continuous animation).
318 scoped_ptr<gfx::Animation> media_indicator_animation_; 323 scoped_ptr<gfx::Animation> media_indicator_animation_;
319 TabMediaState animating_media_state_; 324 TabMediaState animating_media_state_;
320 325
321 scoped_refptr<gfx::AnimationContainer> animation_container_; 326 scoped_refptr<gfx::AnimationContainer> animation_container_;
322 327
323 views::ImageButton* close_button_; 328 views::ImageButton* close_button_;
324 views::Label* title_;
325 329
326 bool tab_activated_with_last_gesture_begin_; 330 bool tab_activated_with_last_gesture_begin_;
327 331
328 views::GlowHoverController hover_controller_; 332 views::GlowHoverController hover_controller_;
329 333
330 // The bounds of various sections of the display. 334 // The bounds of various sections of the display.
331 gfx::Rect favicon_bounds_; 335 gfx::Rect favicon_bounds_;
336 gfx::Rect title_bounds_;
332 gfx::Rect media_indicator_bounds_; 337 gfx::Rect media_indicator_bounds_;
333 338
334 // The offset used to paint the inactive background image. 339 // The offset used to paint the inactive background image.
335 gfx::Point background_offset_; 340 gfx::Point background_offset_;
336 341
337 struct TabImage { 342 struct TabImage {
338 gfx::ImageSkia* image_l; 343 gfx::ImageSkia* image_l;
339 gfx::ImageSkia* image_c; 344 gfx::ImageSkia* image_c;
340 gfx::ImageSkia* image_r; 345 gfx::ImageSkia* image_r;
341 int l_width; 346 int l_width;
(...skipping 11 matching lines...) Expand all
353 // detect when it changes and layout appropriately. 358 // detect when it changes and layout appropriately.
354 bool showing_media_indicator_; 359 bool showing_media_indicator_;
355 360
356 // Whether we are showing the close button. It is cached so that we can 361 // Whether we are showing the close button. It is cached so that we can
357 // detect when it changes and layout appropriately. 362 // detect when it changes and layout appropriately.
358 bool showing_close_button_; 363 bool showing_close_button_;
359 364
360 // The current color of the close button. 365 // The current color of the close button.
361 SkColor close_button_color_; 366 SkColor close_button_color_;
362 367
368 static gfx::Font* font_;
369 static int font_height_;
370
363 // As the majority of the tabs are inactive, and painting tabs is slowish, 371 // As the majority of the tabs are inactive, and painting tabs is slowish,
364 // we cache a handful of the inactive tab backgrounds here. 372 // we cache a handful of the inactive tab backgrounds here.
365 static ImageCache* image_cache_; 373 static ImageCache* image_cache_;
366 374
367 DISALLOW_COPY_AND_ASSIGN(Tab); 375 DISALLOW_COPY_AND_ASSIGN(Tab);
368 }; 376 };
369 377
370 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ 378 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698