| 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_VIEWS_TABS_TAB_RENDERER_H__ | 5 #ifndef CHROME_BROWSER_VIEWS_TABS_TAB_RENDERER_H__ |
| 6 #define CHROME_BROWSER_VIEWS_TABS_TAB_RENDERER_H__ | 6 #define CHROME_BROWSER_VIEWS_TABS_TAB_RENDERER_H__ |
| 7 | 7 |
| 8 #include "app/animation.h" | 8 #include "app/animation.h" |
| 9 #include "app/slide_animation.h" | |
| 10 #include "app/throb_animation.h" | |
| 11 #include "base/gfx/point.h" | 9 #include "base/gfx/point.h" |
| 10 #include "base/scoped_ptr.h" |
| 12 #include "base/string16.h" | 11 #include "base/string16.h" |
| 13 #include "views/controls/button/image_button.h" | 12 #include "views/controls/button/image_button.h" |
| 14 #include "views/view.h" | 13 #include "views/view.h" |
| 15 | 14 |
| 15 class SlideAnimation; |
| 16 class TabContents; | 16 class TabContents; |
| 17 class ThrobAnimation; |
| 17 | 18 |
| 18 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
| 19 // | 20 // |
| 20 // TabRenderer | 21 // TabRenderer |
| 21 // | 22 // |
| 22 // A View that renders a Tab, either in a TabStrip or in a DraggedTabView. | 23 // A View that renders a Tab, either in a TabStrip or in a DraggedTabView. |
| 23 // | 24 // |
| 24 /////////////////////////////////////////////////////////////////////////////// | 25 /////////////////////////////////////////////////////////////////////////////// |
| 25 class TabRenderer : public views::View, | 26 class TabRenderer : public views::View, |
| 26 public views::ButtonListener, | 27 public views::ButtonListener, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 virtual bool IsSelected() const; | 61 virtual bool IsSelected() const; |
| 61 | 62 |
| 62 // Advance the Loading Animation to the next frame, or hide the animation if | 63 // Advance the Loading Animation to the next frame, or hide the animation if |
| 63 // the tab isn't loading. | 64 // the tab isn't loading. |
| 64 void ValidateLoadingAnimation(AnimationState animation_state); | 65 void ValidateLoadingAnimation(AnimationState animation_state); |
| 65 | 66 |
| 66 // Starts/Stops a pulse animation. | 67 // Starts/Stops a pulse animation. |
| 67 void StartPulse(); | 68 void StartPulse(); |
| 68 void StopPulse(); | 69 void StopPulse(); |
| 69 | 70 |
| 71 // Start/stop the pinned tab title animation. |
| 72 void StartPinnedTabTitleAnimation(); |
| 73 void StopPinnedTabTitleAnimation(); |
| 74 |
| 70 // Set the background offset used to match the image in the inactive tab | 75 // Set the background offset used to match the image in the inactive tab |
| 71 // to the frame image. | 76 // to the frame image. |
| 72 void SetBackgroundOffset(const gfx::Point& offset) { | 77 void SetBackgroundOffset(const gfx::Point& offset) { |
| 73 background_offset_ = offset; | 78 background_offset_ = offset; |
| 74 } | 79 } |
| 75 | 80 |
| 76 // Set the theme provider - because we get detached, we are frequently | 81 // Set the theme provider - because we get detached, we are frequently |
| 77 // outside of a hierarchy with a theme provider at the top. This should be | 82 // outside of a hierarchy with a theme provider at the top. This should be |
| 78 // called whenever we're detached or attached to a hierarchy. | 83 // called whenever we're detached or attached to a hierarchy. |
| 79 void SetThemeProvider(ThemeProvider* provider) { | 84 void SetThemeProvider(ThemeProvider* provider) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // Returns the number of favicon-size elements that can fit in the tab's | 151 // Returns the number of favicon-size elements that can fit in the tab's |
| 147 // current size. | 152 // current size. |
| 148 int IconCapacity() const; | 153 int IconCapacity() const; |
| 149 | 154 |
| 150 // Returns whether the Tab should display a favicon. | 155 // Returns whether the Tab should display a favicon. |
| 151 bool ShouldShowIcon() const; | 156 bool ShouldShowIcon() const; |
| 152 | 157 |
| 153 // Returns whether the Tab should display a close button. | 158 // Returns whether the Tab should display a close button. |
| 154 bool ShouldShowCloseBox() const; | 159 bool ShouldShowCloseBox() const; |
| 155 | 160 |
| 161 // Gets the throb value for the tab. When a tab is not selected the |
| 162 // active background is drawn at |GetThrobValue()|%. This is used for hover, |
| 163 // pinned tab title change and pulsing. |
| 164 double GetThrobValue(); |
| 165 |
| 156 // The bounds of various sections of the display. | 166 // The bounds of various sections of the display. |
| 157 gfx::Rect favicon_bounds_; | 167 gfx::Rect favicon_bounds_; |
| 158 gfx::Rect title_bounds_; | 168 gfx::Rect title_bounds_; |
| 159 | 169 |
| 160 // The offset used to paint the inactive background image. | 170 // The offset used to paint the inactive background image. |
| 161 gfx::Point background_offset_; | 171 gfx::Point background_offset_; |
| 162 | 172 |
| 163 // Current state of the animation. | 173 // Current state of the animation. |
| 164 AnimationState animation_state_; | 174 AnimationState animation_state_; |
| 165 | 175 |
| 166 // The current index into the Animation image strip. | 176 // The current index into the Animation image strip. |
| 167 int animation_frame_; | 177 int animation_frame_; |
| 168 | 178 |
| 169 // Close Button. | 179 // Close Button. |
| 170 views::ImageButton* close_button_; | 180 views::ImageButton* close_button_; |
| 171 | 181 |
| 172 // Hover animation. | 182 // Hover animation. |
| 173 scoped_ptr<SlideAnimation> hover_animation_; | 183 scoped_ptr<SlideAnimation> hover_animation_; |
| 174 | 184 |
| 175 // Pulse animation. | 185 // Pulse animation. |
| 176 scoped_ptr<ThrobAnimation> pulse_animation_; | 186 scoped_ptr<ThrobAnimation> pulse_animation_; |
| 177 | 187 |
| 188 // Animation used when the title of an inactive pinned tab changes. |
| 189 scoped_ptr<ThrobAnimation> pinned_title_animation_; |
| 190 |
| 178 // Model data. We store this here so that we don't need to ask the underlying | 191 // Model data. We store this here so that we don't need to ask the underlying |
| 179 // model, which is tricky since instances of this object can outlive the | 192 // model, which is tricky since instances of this object can outlive the |
| 180 // corresponding objects in the underlying model. | 193 // corresponding objects in the underlying model. |
| 181 struct TabData { | 194 struct TabData { |
| 182 SkBitmap favicon; | 195 SkBitmap favicon; |
| 183 string16 title; | 196 string16 title; |
| 184 bool loading; | 197 bool loading; |
| 185 bool crashed; | 198 bool crashed; |
| 186 bool off_the_record; | 199 bool off_the_record; |
| 187 bool show_icon; | 200 bool show_icon; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 236 |
| 224 ThemeProvider* theme_provider_; | 237 ThemeProvider* theme_provider_; |
| 225 | 238 |
| 226 static void InitClass(); | 239 static void InitClass(); |
| 227 static bool initialized_; | 240 static bool initialized_; |
| 228 | 241 |
| 229 DISALLOW_EVIL_CONSTRUCTORS(TabRenderer); | 242 DISALLOW_EVIL_CONSTRUCTORS(TabRenderer); |
| 230 }; | 243 }; |
| 231 | 244 |
| 232 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_RENDERER_H__ | 245 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_RENDERER_H__ |
| OLD | NEW |