OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_GTK_TABS_TAB_RENDERER_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
6 #define CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ | 6 #define CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "app/animation.h" | 10 #include "app/animation.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 std::wstring GetTitle() const; | 138 std::wstring GetTitle() const; |
139 | 139 |
140 // Called by TabGtk to notify the renderer that the tab is being hovered. | 140 // Called by TabGtk to notify the renderer that the tab is being hovered. |
141 void OnMouseEntered(); | 141 void OnMouseEntered(); |
142 | 142 |
143 // Called by TabGtk to notify the renderer that the tab is no longer being | 143 // Called by TabGtk to notify the renderer that the tab is no longer being |
144 // hovered. | 144 // hovered. |
145 void OnMouseExited(); | 145 void OnMouseExited(); |
146 | 146 |
147 private: | 147 private: |
| 148 class FavIconCrashAnimation; |
| 149 |
148 // Model data. We store this here so that we don't need to ask the underlying | 150 // Model data. We store this here so that we don't need to ask the underlying |
149 // model, which is tricky since instances of this object can outlive the | 151 // model, which is tricky since instances of this object can outlive the |
150 // corresponding objects in the underlying model. | 152 // corresponding objects in the underlying model. |
151 struct TabData { | 153 struct TabData { |
152 SkBitmap favicon; | 154 SkBitmap favicon; |
153 std::wstring title; | 155 std::wstring title; |
154 bool loading; | 156 bool loading; |
155 bool crashed; | 157 bool crashed; |
156 bool off_the_record; | 158 bool off_the_record; |
157 bool show_icon; | 159 bool show_icon; |
158 bool show_download_icon; | 160 bool show_download_icon; |
159 }; | 161 }; |
160 | 162 |
161 // TODO(jhawkins): Move into TabResources class. | 163 // TODO(jhawkins): Move into TabResources class. |
162 struct TabImage { | 164 struct TabImage { |
163 SkBitmap* image_l; | 165 SkBitmap* image_l; |
164 SkBitmap* image_c; | 166 SkBitmap* image_c; |
165 SkBitmap* image_r; | 167 SkBitmap* image_r; |
166 int l_width; | 168 int l_width; |
167 int r_width; | 169 int r_width; |
168 }; | 170 }; |
169 | 171 |
170 // Overridden from AnimationDelegate: | 172 // Overridden from AnimationDelegate: |
171 virtual void AnimationProgressed(const Animation* animation); | 173 virtual void AnimationProgressed(const Animation* animation); |
172 virtual void AnimationCanceled(const Animation* animation); | 174 virtual void AnimationCanceled(const Animation* animation); |
173 virtual void AnimationEnded(const Animation* animation); | 175 virtual void AnimationEnded(const Animation* animation); |
174 | 176 |
| 177 // Starts/Stops the crash animation. |
| 178 void StartCrashAnimation(); |
| 179 void StopCrashAnimation(); |
| 180 |
| 181 // Return true if the crash animation is currently running. |
| 182 bool IsPerformingCrashAnimation() const; |
| 183 |
| 184 // Set the temporary offset for the favicon. This is used during animation. |
| 185 void SetFavIconHidingOffset(int offset); |
| 186 |
| 187 void DisplayCrashedFavIcon(); |
| 188 void ResetCrashedFavIcon(); |
| 189 |
175 // Generates the bounds for the interior items of the tab. | 190 // Generates the bounds for the interior items of the tab. |
176 void Layout(); | 191 void Layout(); |
177 | 192 |
178 // Returns the largest of the favicon, title text, and the close button. | 193 // Returns the largest of the favicon, title text, and the close button. |
179 static int GetContentHeight(); | 194 static int GetContentHeight(); |
180 | 195 |
181 // Paint various portions of the Tab | 196 // Paint various portions of the Tab |
182 void PaintTabBackground(gfx::CanvasPaint* canvas); | 197 void PaintTabBackground(gfx::CanvasPaint* canvas); |
183 void PaintInactiveTabBackground(gfx::CanvasPaint* canvas); | 198 void PaintInactiveTabBackground(gfx::CanvasPaint* canvas); |
184 void PaintActiveTabBackground(gfx::CanvasPaint* canvas); | 199 void PaintActiveTabBackground(gfx::CanvasPaint* canvas); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Whether we are showing the download icon. Comes from the model. | 250 // Whether we are showing the download icon. Comes from the model. |
236 bool showing_download_icon_; | 251 bool showing_download_icon_; |
237 | 252 |
238 // Whether we are showing the close button. It is cached so that we can | 253 // Whether we are showing the close button. It is cached so that we can |
239 // detect when it changes and layout appropriately. | 254 // detect when it changes and layout appropriately. |
240 bool showing_close_button_; | 255 bool showing_close_button_; |
241 | 256 |
242 // The offset used to animate the favicon location. | 257 // The offset used to animate the favicon location. |
243 int fav_icon_hiding_offset_; | 258 int fav_icon_hiding_offset_; |
244 | 259 |
| 260 // The animation object used to swap the favicon with the sad tab icon. |
| 261 scoped_ptr<FavIconCrashAnimation> crash_animation_; |
| 262 |
245 // Set when the crashed favicon should be displayed. | 263 // Set when the crashed favicon should be displayed. |
246 bool should_display_crashed_favicon_; | 264 bool should_display_crashed_favicon_; |
247 | 265 |
248 // The bounds of this Tab. | 266 // The bounds of this Tab. |
249 gfx::Rect bounds_; | 267 gfx::Rect bounds_; |
250 | 268 |
251 // Hover animation. | 269 // Hover animation. |
252 scoped_ptr<SlideAnimation> hover_animation_; | 270 scoped_ptr<SlideAnimation> hover_animation_; |
253 | 271 |
254 // Contains the loading animation state. | 272 // Contains the loading animation state. |
255 LoadingAnimation loading_animation_; | 273 LoadingAnimation loading_animation_; |
256 | 274 |
257 // TODO(jhawkins): If the theme is changed after the tab is created, we'll | 275 // TODO(jhawkins): If the theme is changed after the tab is created, we'll |
258 // still render the old theme for this tab. | 276 // still render the old theme for this tab. |
259 ThemeProvider* theme_provider_; | 277 ThemeProvider* theme_provider_; |
260 | 278 |
261 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); | 279 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); |
262 }; | 280 }; |
263 | 281 |
264 #endif // CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ | 282 #endif // CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
OLD | NEW |