OLD | NEW |
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 #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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 explicit Tab(TabController* controller); | 30 explicit Tab(TabController* controller); |
31 virtual ~Tab(); | 31 virtual ~Tab(); |
32 | 32 |
33 // Start/stop the mini-tab title animation. | 33 // Start/stop the mini-tab title animation. |
34 void StartMiniTabTitleAnimation(); | 34 void StartMiniTabTitleAnimation(); |
35 void StopMiniTabTitleAnimation(); | 35 void StopMiniTabTitleAnimation(); |
36 | 36 |
37 // Set the background offset used to match the image in the inactive tab | 37 // Set the background offset used to match the image in the inactive tab |
38 // to the frame image. | 38 // to the frame image. |
39 void SetBackgroundOffset(const gfx::Point& offset) { | 39 void set_background_offset(const gfx::Point& offset) { |
40 background_offset_ = offset; | 40 background_offset_ = offset; |
41 } | 41 } |
42 | 42 |
43 // Paints the icon. Most of the time you'll want to invoke Paint directly, but | |
44 // in certain situations this invoked outside of Paint. | |
45 void PaintIcon(gfx::Canvas* canvas); | |
46 | |
47 // Returns the minimum possible size of a single unselected Tab. | 43 // Returns the minimum possible size of a single unselected Tab. |
48 static gfx::Size GetMinimumUnselectedSize(); | 44 static gfx::Size GetMinimumUnselectedSize(); |
49 // Returns the minimum possible size of a selected Tab. Selected tabs must | 45 // Returns the minimum possible size of a selected Tab. Selected tabs must |
50 // always show a close button and have a larger minimum size than unselected | 46 // always show a close button and have a larger minimum size than unselected |
51 // tabs. | 47 // tabs. |
52 static gfx::Size GetMinimumSelectedSize(); | 48 static gfx::Size GetMinimumSelectedSize(); |
53 // Returns the preferred size of a single Tab, assuming space is | 49 // Returns the preferred size of a single Tab, assuming space is |
54 // available. | 50 // available. |
55 static gfx::Size GetStandardSize(); | 51 static gfx::Size GetStandardSize(); |
56 | 52 |
57 // Returns the width for mini-tabs. Mini-tabs always have this width. | 53 // Returns the width for mini-tabs. Mini-tabs always have this width. |
58 static int GetMiniWidth(); | 54 static int GetMiniWidth(); |
59 | 55 |
60 // Loads the images to be used for the tab background. | |
61 static void LoadTabImages(); | |
62 | |
63 protected: | 56 protected: |
64 virtual const gfx::Rect& title_bounds() const { return title_bounds_; } | 57 virtual const gfx::Rect& title_bounds() const { return title_bounds_; } |
65 | 58 |
66 // BaseTab overrides: | 59 // BaseTab overrides: |
67 virtual void DataChanged(const TabRendererData& old); | 60 virtual void DataChanged(const TabRendererData& old); |
68 | 61 |
69 private: | 62 private: |
70 // Overridden from views::View: | 63 // Overridden from views::View: |
71 virtual void Paint(gfx::Canvas* canvas); | 64 virtual void Paint(gfx::Canvas* canvas); |
72 virtual void Layout(); | 65 virtual void Layout(); |
73 virtual void OnThemeChanged(); | 66 virtual void OnThemeChanged(); |
74 virtual std::string GetClassName() const { return kViewClassName; } | 67 virtual std::string GetClassName() const { return kViewClassName; } |
75 virtual bool HasHitTestMask() const; | 68 virtual bool HasHitTestMask() const; |
76 virtual void GetHitTestMask(gfx::Path* path) const; | 69 virtual void GetHitTestMask(gfx::Path* path) const; |
77 virtual bool GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin); | 70 virtual bool GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin); |
78 virtual void OnMouseMoved(const views::MouseEvent& event); | 71 virtual void OnMouseMoved(const views::MouseEvent& event); |
79 | 72 |
80 // Paint various portions of the Tab | 73 // Paint various portions of the Tab |
81 void PaintTabBackground(gfx::Canvas* canvas); | 74 void PaintTabBackground(gfx::Canvas* canvas); |
82 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas); | 75 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas); |
83 void PaintInactiveTabBackground(gfx::Canvas* canvas); | 76 void PaintInactiveTabBackground(gfx::Canvas* canvas); |
84 void PaintActiveTabBackground(gfx::Canvas* canvas); | 77 void PaintActiveTabBackground(gfx::Canvas* canvas); |
| 78 void PaintIcon(gfx::Canvas* canvas); |
85 SkBitmap DrawHoverGlowBitmap(int width, int height); | 79 SkBitmap DrawHoverGlowBitmap(int width, int height); |
86 | 80 |
87 // Returns the number of favicon-size elements that can fit in the tab's | 81 // Returns the number of favicon-size elements that can fit in the tab's |
88 // current size. | 82 // current size. |
89 int IconCapacity() const; | 83 int IconCapacity() const; |
90 | 84 |
91 // Returns whether the Tab should display a favicon. | 85 // Returns whether the Tab should display a favicon. |
92 bool ShouldShowIcon() const; | 86 bool ShouldShowIcon() const; |
93 | 87 |
94 // Returns whether the Tab should display a close button. | 88 // Returns whether the Tab should display a close button. |
95 bool ShouldShowCloseBox() const; | 89 bool ShouldShowCloseBox() const; |
96 | 90 |
97 // Gets the throb value for the tab. When a tab is not selected the | 91 // Gets the throb value for the tab. When a tab is not selected the |
98 // active background is drawn at |GetThrobValue()|%. This is used for hover, | 92 // active background is drawn at |GetThrobValue()|%. This is used for hover, |
99 // mini tab title change and pulsing. | 93 // mini tab title change and pulsing. |
100 double GetThrobValue(); | 94 double GetThrobValue(); |
101 | 95 |
| 96 // Performs a one-time initialization of static resources such as tab images. |
| 97 static void InitTabResources(); |
| 98 |
| 99 // Loads the images to be used for the tab background. |
| 100 static void LoadTabImages(); |
| 101 |
102 // The bounds of various sections of the display. | 102 // The bounds of various sections of the display. |
103 gfx::Rect favicon_bounds_; | 103 gfx::Rect favicon_bounds_; |
104 gfx::Rect title_bounds_; | 104 gfx::Rect title_bounds_; |
105 | 105 |
106 // The offset used to paint the inactive background image. | 106 // The offset used to paint the inactive background image. |
107 gfx::Point background_offset_; | 107 gfx::Point background_offset_; |
108 | 108 |
109 // The center point for the radial hover glow. | 109 // The center point for the radial hover glow. |
110 gfx::Point hover_point_; | 110 gfx::Point hover_point_; |
111 | 111 |
112 // Animation used when the title of an inactive mini tab changes. | 112 // Animation used when the title of an inactive mini tab changes. |
113 scoped_ptr<MultiAnimation> mini_title_animation_; | 113 scoped_ptr<MultiAnimation> mini_title_animation_; |
114 | 114 |
115 struct TabImage { | 115 struct TabImage { |
116 SkBitmap* image_l; | 116 SkBitmap* image_l; |
117 SkBitmap* image_c; | 117 SkBitmap* image_c; |
118 SkBitmap* image_r; | 118 SkBitmap* image_r; |
119 int l_width; | 119 int l_width; |
120 int r_width; | 120 int r_width; |
121 int y_offset; | 121 int y_offset; |
122 }; | 122 }; |
123 static TabImage tab_active; | 123 static TabImage tab_active_; |
124 static TabImage tab_inactive; | 124 static TabImage tab_inactive_; |
125 static TabImage tab_alpha; | 125 static TabImage tab_alpha_; |
126 | 126 |
127 // Whether we're showing the icon. It is cached so that we can detect when it | 127 // Whether we're showing the icon. It is cached so that we can detect when it |
128 // changes and layout appropriately. | 128 // changes and layout appropriately. |
129 bool showing_icon_; | 129 bool showing_icon_; |
130 | 130 |
131 // Whether we are showing the close button. It is cached so that we can | 131 // Whether we are showing the close button. It is cached so that we can |
132 // detect when it changes and layout appropriately. | 132 // detect when it changes and layout appropriately. |
133 bool showing_close_button_; | 133 bool showing_close_button_; |
134 | 134 |
135 // The current color of the close button. | 135 // The current color of the close button. |
136 SkColor close_button_color_; | 136 SkColor close_button_color_; |
137 | 137 |
138 static bool initialized_; | 138 static bool initialized_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(Tab); | 140 DISALLOW_COPY_AND_ASSIGN(Tab); |
141 }; | 141 }; |
142 | 142 |
143 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 143 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
OLD | NEW |