| OLD | NEW |
| 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/masked_targeter_delegate.h" |
| 20 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 21 | 22 |
| 22 class TabController; | 23 class TabController; |
| 23 | 24 |
| 24 namespace gfx { | 25 namespace gfx { |
| 25 class Animation; | 26 class Animation; |
| 26 class AnimationContainer; | 27 class AnimationContainer; |
| 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 class Label; |
| 33 } | 34 } |
| 34 | 35 |
| 35 /////////////////////////////////////////////////////////////////////////////// | 36 /////////////////////////////////////////////////////////////////////////////// |
| 36 // | 37 // |
| 37 // A View that renders a Tab in a TabStrip. | 38 // A View that renders a Tab in a TabStrip. |
| 38 // | 39 // |
| 39 /////////////////////////////////////////////////////////////////////////////// | 40 /////////////////////////////////////////////////////////////////////////////// |
| 40 class Tab : public gfx::AnimationDelegate, | 41 class Tab : public gfx::AnimationDelegate, |
| 41 public views::ButtonListener, | 42 public views::ButtonListener, |
| 42 public views::ContextMenuController, | 43 public views::ContextMenuController, |
| 44 public views::MaskedTargeterDelegate, |
| 43 public views::View { | 45 public views::View { |
| 44 public: | 46 public: |
| 45 // The menu button's class name. | 47 // The menu button's class name. |
| 46 static const char kViewClassName[]; | 48 static const char kViewClassName[]; |
| 47 | 49 |
| 48 explicit Tab(TabController* controller); | 50 explicit Tab(TabController* controller); |
| 49 virtual ~Tab(); | 51 virtual ~Tab(); |
| 50 | 52 |
| 51 // Used to set/check whether this Tab is being animated closed. | 53 // Used to set/check whether this Tab is being animated closed. |
| 52 void set_closing(bool closing) { closing_ = closing; } | 54 void set_closing(bool closing) { closing_ = closing; } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 158 |
| 157 // Scale factor we're drawing it. | 159 // Scale factor we're drawing it. |
| 158 ui::ScaleFactor scale_factor; | 160 ui::ScaleFactor scale_factor; |
| 159 | 161 |
| 160 // The image. | 162 // The image. |
| 161 gfx::ImageSkia image; | 163 gfx::ImageSkia image; |
| 162 }; | 164 }; |
| 163 | 165 |
| 164 typedef std::list<ImageCacheEntry> ImageCache; | 166 typedef std::list<ImageCacheEntry> ImageCache; |
| 165 | 167 |
| 166 // Overridden from gfx::AnimationDelegate: | 168 // gfx::AnimationDelegate: |
| 167 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 169 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 168 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; | 170 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; |
| 169 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | 171 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 170 | 172 |
| 171 // Overridden from views::ButtonListener: | 173 // views::ButtonListener: |
| 172 virtual void ButtonPressed(views::Button* sender, | 174 virtual void ButtonPressed(views::Button* sender, |
| 173 const ui::Event& event) OVERRIDE; | 175 const ui::Event& event) OVERRIDE; |
| 174 | 176 |
| 175 // Overridden from views::ContextMenuController: | 177 // views::ContextMenuController: |
| 176 virtual void ShowContextMenuForView(views::View* source, | 178 virtual void ShowContextMenuForView(views::View* source, |
| 177 const gfx::Point& point, | 179 const gfx::Point& point, |
| 178 ui::MenuSourceType source_type) OVERRIDE; | 180 ui::MenuSourceType source_type) OVERRIDE; |
| 179 | 181 |
| 180 // Overridden from views::View: | 182 // views::MaskedTargeterDelegate: |
| 183 virtual bool GetHitTestMask(gfx::Path* mask) const OVERRIDE; |
| 184 |
| 185 // views::View: |
| 181 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 186 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 182 virtual void Layout() OVERRIDE; | 187 virtual void Layout() OVERRIDE; |
| 183 virtual void OnThemeChanged() OVERRIDE; | 188 virtual void OnThemeChanged() OVERRIDE; |
| 184 virtual const char* GetClassName() const OVERRIDE; | 189 virtual const char* GetClassName() const OVERRIDE; |
| 185 virtual bool HasHitTestMask() const OVERRIDE; | |
| 186 virtual void GetHitTestMaskDeprecated(HitTestSource source, | |
| 187 gfx::Path* path) const OVERRIDE; | |
| 188 virtual bool GetTooltipText(const gfx::Point& p, | 190 virtual bool GetTooltipText(const gfx::Point& p, |
| 189 base::string16* tooltip) const OVERRIDE; | 191 base::string16* tooltip) const OVERRIDE; |
| 190 virtual bool GetTooltipTextOrigin(const gfx::Point& p, | 192 virtual bool GetTooltipTextOrigin(const gfx::Point& p, |
| 191 gfx::Point* origin) const OVERRIDE; | 193 gfx::Point* origin) const OVERRIDE; |
| 192 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 194 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 193 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 195 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
| 194 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 196 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 195 virtual void OnMouseCaptureLost() OVERRIDE; | 197 virtual void OnMouseCaptureLost() OVERRIDE; |
| 196 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 198 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| 197 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; | 199 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; |
| 198 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 200 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
| 199 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 201 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
| 200 | 202 |
| 201 // Overridden from ui::EventHandler: | 203 // ui::EventHandler: |
| 202 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 204 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 203 | 205 |
| 204 // Invoked from Layout to adjust the position of the favicon or media | 206 // Invoked from Layout to adjust the position of the favicon or media |
| 205 // indicator for mini tabs. | 207 // indicator for mini tabs. |
| 206 void MaybeAdjustLeftForMiniTab(gfx::Rect* bounds) const; | 208 void MaybeAdjustLeftForMiniTab(gfx::Rect* bounds) const; |
| 207 | 209 |
| 208 // Invoked from SetData after |data_| has been updated to the new data. | 210 // Invoked from SetData after |data_| has been updated to the new data. |
| 209 void DataChanged(const TabRendererData& old); | 211 void DataChanged(const TabRendererData& old); |
| 210 | 212 |
| 211 // Paint with the normal tab style. | 213 // Paint with the normal tab style. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 SkColor close_button_color_; | 382 SkColor close_button_color_; |
| 381 | 383 |
| 382 // As the majority of the tabs are inactive, and painting tabs is slowish, | 384 // As the majority of the tabs are inactive, and painting tabs is slowish, |
| 383 // we cache a handful of the inactive tab backgrounds here. | 385 // we cache a handful of the inactive tab backgrounds here. |
| 384 static ImageCache* image_cache_; | 386 static ImageCache* image_cache_; |
| 385 | 387 |
| 386 DISALLOW_COPY_AND_ASSIGN(Tab); | 388 DISALLOW_COPY_AND_ASSIGN(Tab); |
| 387 }; | 389 }; |
| 388 | 390 |
| 389 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 391 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| OLD | NEW |