| 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_VIEWS_TABS_BASE_TAB_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_TABS_BASE_TAB_H_ |
| 6 #define CHROME_BROWSER_VIEWS_TABS_BASE_TAB_H_ | 6 #define CHROME_BROWSER_VIEWS_TABS_BASE_TAB_H_ |
| 7 | 7 |
| 8 #include "app/animation.h" | 8 #include "app/animation.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace views { | 25 namespace views { |
| 26 class ImageButton; | 26 class ImageButton; |
| 27 } // namespace views | 27 } // namespace views |
| 28 | 28 |
| 29 // Base class for tab renderers. | 29 // Base class for tab renderers. |
| 30 class BaseTab : public AnimationDelegate, | 30 class BaseTab : public AnimationDelegate, |
| 31 public views::ButtonListener, | 31 public views::ButtonListener, |
| 32 public views::ContextMenuController, | 32 public views::ContextMenuController, |
| 33 public views::View { | 33 public views::View { |
| 34 public: | 34 public: |
| 35 explicit BaseTab(TabController* controller); | 35 BaseTab(TabController* controller, bool show_mini_dot); |
| 36 ~BaseTab(); | 36 ~BaseTab(); |
| 37 | 37 |
| 38 // Sets the data this tabs displays. Invokes DataChanged for subclasses to | 38 // Sets the data this tabs displays. Invokes DataChanged for subclasses to |
| 39 // update themselves appropriately. | 39 // update themselves appropriately. |
| 40 void SetData(const TabRendererData& data); | 40 void SetData(const TabRendererData& data); |
| 41 const TabRendererData& data() const { return data_; } | 41 const TabRendererData& data() const { return data_; } |
| 42 | 42 |
| 43 // Sets the network state. If the network state changes NetworkStateChanged is | 43 // Sets the network state. If the network state changes NetworkStateChanged is |
| 44 // invoked. | 44 // invoked. |
| 45 virtual void UpdateLoadingAnimation(TabRendererData::NetworkState state); | 45 virtual void UpdateLoadingAnimation(TabRendererData::NetworkState state); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 64 return animation_container_.get(); | 64 return animation_container_.get(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Set the theme provider - because we get detached, we are frequently | 67 // Set the theme provider - because we get detached, we are frequently |
| 68 // outside of a hierarchy with a theme provider at the top. This should be | 68 // outside of a hierarchy with a theme provider at the top. This should be |
| 69 // called whenever we're detached or attached to a hierarchy. | 69 // called whenever we're detached or attached to a hierarchy. |
| 70 void set_theme_provider(ThemeProvider* provider) { | 70 void set_theme_provider(ThemeProvider* provider) { |
| 71 theme_provider_ = provider; | 71 theme_provider_ = provider; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Invoked when the selected state changes. Resets the image of the close |
| 75 // button. |
| 76 void SelectedChanged(); |
| 77 |
| 74 // Returns true if the tab is selected. | 78 // Returns true if the tab is selected. |
| 75 virtual bool IsSelected() const; | 79 virtual bool IsSelected() const; |
| 76 | 80 |
| 77 // views::View overrides: | 81 // views::View overrides: |
| 78 virtual void OnMouseEntered(const views::MouseEvent& event); | 82 virtual void OnMouseEntered(const views::MouseEvent& event); |
| 79 virtual void OnMouseExited(const views::MouseEvent& event); | 83 virtual void OnMouseExited(const views::MouseEvent& event); |
| 80 virtual bool OnMousePressed(const views::MouseEvent& event); | 84 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 81 virtual bool OnMouseDragged(const views::MouseEvent& event); | 85 virtual bool OnMouseDragged(const views::MouseEvent& event); |
| 82 virtual void OnMouseReleased(const views::MouseEvent& event, | 86 virtual void OnMouseReleased(const views::MouseEvent& event, |
| 83 bool canceled); | 87 bool canceled); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 97 | 101 |
| 98 // Returns the pulse animation. The pulse animation is non-null if StartPulse | 102 // Returns the pulse animation. The pulse animation is non-null if StartPulse |
| 99 // has been invoked. | 103 // has been invoked. |
| 100 ThrobAnimation* pulse_animation() const { return pulse_animation_.get(); } | 104 ThrobAnimation* pulse_animation() const { return pulse_animation_.get(); } |
| 101 | 105 |
| 102 // Returns the hover animation. This may return null. | 106 // Returns the hover animation. This may return null. |
| 103 const SlideAnimation* hover_animation() const { | 107 const SlideAnimation* hover_animation() const { |
| 104 return hover_animation_.get(); | 108 return hover_animation_.get(); |
| 105 } | 109 } |
| 106 | 110 |
| 107 views::ImageButton* close_button() const { return close_button_; } | 111 views::ImageButton* close_button() const; |
| 112 |
| 113 // Sets the color used to derive the close button images. |
| 114 void SetCloseButtonColor(SkColor color); |
| 108 | 115 |
| 109 // Paints the icon at the specified x-coordinate. | 116 // Paints the icon at the specified x-coordinate. |
| 110 void PaintIcon(gfx::Canvas* canvas, int x, int y); | 117 void PaintIcon(gfx::Canvas* canvas, int x, int y); |
| 111 void PaintTitle(gfx::Canvas* canvas, SkColor title_color); | 118 void PaintTitle(gfx::Canvas* canvas, SkColor title_color); |
| 112 | 119 |
| 113 // Overridden from AnimationDelegate: | 120 // Overridden from AnimationDelegate: |
| 114 virtual void AnimationProgressed(const Animation* animation); | 121 virtual void AnimationProgressed(const Animation* animation); |
| 115 virtual void AnimationCanceled(const Animation* animation); | 122 virtual void AnimationCanceled(const Animation* animation); |
| 116 virtual void AnimationEnded(const Animation* animation); | 123 virtual void AnimationEnded(const Animation* animation); |
| 117 | 124 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 136 | 143 |
| 137 // Size (width/height) of the loading animation. | 144 // Size (width/height) of the loading animation. |
| 138 static int loading_animation_size() { return loading_animation_size_; } | 145 static int loading_animation_size() { return loading_animation_size_; } |
| 139 | 146 |
| 140 static gfx::Font* font() { return font_; } | 147 static gfx::Font* font() { return font_; } |
| 141 static int font_height() { return font_height_; } | 148 static int font_height() { return font_height_; } |
| 142 | 149 |
| 143 private: | 150 private: |
| 144 // The animation object used to swap the favicon with the sad tab icon. | 151 // The animation object used to swap the favicon with the sad tab icon. |
| 145 class FavIconCrashAnimation; | 152 class FavIconCrashAnimation; |
| 153 class TabCloseButton; |
| 146 | 154 |
| 147 // Set the temporary offset for the favicon. This is used during the crash | 155 // Set the temporary offset for the favicon. This is used during the crash |
| 148 // animation. | 156 // animation. |
| 149 void SetFavIconHidingOffset(int offset); | 157 void SetFavIconHidingOffset(int offset); |
| 150 | 158 |
| 151 void DisplayCrashedFavIcon(); | 159 void DisplayCrashedFavIcon(); |
| 152 void ResetCrashedFavIcon(); | 160 void ResetCrashedFavIcon(); |
| 153 | 161 |
| 154 // Starts/Stops the crash animation. | 162 // Starts/Stops the crash animation. |
| 155 void StartCrashAnimation(); | 163 void StartCrashAnimation(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 179 scoped_ptr<ThrobAnimation> pulse_animation_; | 187 scoped_ptr<ThrobAnimation> pulse_animation_; |
| 180 | 188 |
| 181 // Hover animation. | 189 // Hover animation. |
| 182 scoped_ptr<SlideAnimation> hover_animation_; | 190 scoped_ptr<SlideAnimation> hover_animation_; |
| 183 | 191 |
| 184 // Crash animation. | 192 // Crash animation. |
| 185 scoped_ptr<FavIconCrashAnimation> crash_animation_; | 193 scoped_ptr<FavIconCrashAnimation> crash_animation_; |
| 186 | 194 |
| 187 scoped_refptr<AnimationContainer> animation_container_; | 195 scoped_refptr<AnimationContainer> animation_container_; |
| 188 | 196 |
| 189 views::ImageButton* close_button_; | 197 TabCloseButton* close_button_; |
| 190 | 198 |
| 191 // The current index of the loading animation. | 199 // The current index of the loading animation. |
| 192 int loading_animation_frame_; | 200 int loading_animation_frame_; |
| 193 | 201 |
| 194 // Whether to disable throbber animations. Only true if this is a nano tab | 202 // Whether to disable throbber animations. Only true if this is a nano tab |
| 195 // renderer and a command line flag has been passed in to disable the | 203 // renderer and a command line flag has been passed in to disable the |
| 196 // animations. | 204 // animations. |
| 197 bool throbber_disabled_; | 205 bool throbber_disabled_; |
| 198 | 206 |
| 199 ThemeProvider* theme_provider_; | 207 ThemeProvider* theme_provider_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 211 // Size of the loading animation frames. | 219 // Size of the loading animation frames. |
| 212 static int loading_animation_size_; | 220 static int loading_animation_size_; |
| 213 | 221 |
| 214 static gfx::Font* font_; | 222 static gfx::Font* font_; |
| 215 static int font_height_; | 223 static int font_height_; |
| 216 | 224 |
| 217 DISALLOW_COPY_AND_ASSIGN(BaseTab); | 225 DISALLOW_COPY_AND_ASSIGN(BaseTab); |
| 218 }; | 226 }; |
| 219 | 227 |
| 220 #endif // CHROME_BROWSER_VIEWS_TABS_BASE_TAB_H_ | 228 #endif // CHROME_BROWSER_VIEWS_TABS_BASE_TAB_H_ |
| OLD | NEW |