Chromium Code Reviews| 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 |
| 73 // Paints the icon. Most of the time you'll want to invoke Paint directly, but | |
| 74 // in certain situations this invoked outside of Paint. | |
| 75 void PaintIcon(gfx::Canvas* canvas); | |
|
sky
2011/01/04 20:01:01
Move this between 81 and 82. Also, no need to have
wyck
2011/01/11 20:23:49
Done.
| |
| 76 | |
| 80 // Paint various portions of the Tab | 77 // Paint various portions of the Tab |
| 81 void PaintTabBackground(gfx::Canvas* canvas); | 78 void PaintTabBackground(gfx::Canvas* canvas); |
| 82 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas); | 79 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas); |
| 83 void PaintInactiveTabBackground(gfx::Canvas* canvas); | 80 void PaintInactiveTabBackground(gfx::Canvas* canvas); |
| 84 void PaintActiveTabBackground(gfx::Canvas* canvas); | 81 void PaintActiveTabBackground(gfx::Canvas* canvas); |
| 85 SkBitmap DrawHoverGlowBitmap(int width, int height); | 82 SkBitmap DrawHoverGlowBitmap(int width, int height); |
| 86 | 83 |
| 87 // Returns the number of favicon-size elements that can fit in the tab's | 84 // Returns the number of favicon-size elements that can fit in the tab's |
| 88 // current size. | 85 // current size. |
| 89 int IconCapacity() const; | 86 int IconCapacity() const; |
| 90 | 87 |
| 91 // Returns whether the Tab should display a favicon. | 88 // Returns whether the Tab should display a favicon. |
| 92 bool ShouldShowIcon() const; | 89 bool ShouldShowIcon() const; |
| 93 | 90 |
| 94 // Returns whether the Tab should display a close button. | 91 // Returns whether the Tab should display a close button. |
| 95 bool ShouldShowCloseBox() const; | 92 bool ShouldShowCloseBox() const; |
| 96 | 93 |
| 97 // Gets the throb value for the tab. When a tab is not selected the | 94 // 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, | 95 // active background is drawn at |GetThrobValue()|%. This is used for hover, |
| 99 // mini tab title change and pulsing. | 96 // mini tab title change and pulsing. |
| 100 double GetThrobValue(); | 97 double GetThrobValue(); |
| 101 | 98 |
| 99 // Performs a one-time initialization of static resources such as tab images. | |
| 100 static void InitTabResources(); | |
| 101 | |
| 102 // Loads the images to be used for the tab background. | |
| 103 static void LoadTabImages(); | |
| 104 | |
| 102 // The bounds of various sections of the display. | 105 // The bounds of various sections of the display. |
| 103 gfx::Rect favicon_bounds_; | 106 gfx::Rect favicon_bounds_; |
| 104 gfx::Rect title_bounds_; | 107 gfx::Rect title_bounds_; |
| 105 | 108 |
| 106 // The offset used to paint the inactive background image. | 109 // The offset used to paint the inactive background image. |
| 107 gfx::Point background_offset_; | 110 gfx::Point background_offset_; |
| 108 | 111 |
| 109 // The center point for the radial hover glow. | 112 // The center point for the radial hover glow. |
| 110 gfx::Point hover_point_; | 113 gfx::Point hover_point_; |
| 111 | 114 |
| 112 // Animation used when the title of an inactive mini tab changes. | 115 // Animation used when the title of an inactive mini tab changes. |
| 113 scoped_ptr<MultiAnimation> mini_title_animation_; | 116 scoped_ptr<MultiAnimation> mini_title_animation_; |
| 114 | 117 |
| 115 struct TabImage { | 118 struct TabImage { |
| 116 SkBitmap* image_l; | 119 SkBitmap* image_l; |
| 117 SkBitmap* image_c; | 120 SkBitmap* image_c; |
| 118 SkBitmap* image_r; | 121 SkBitmap* image_r; |
| 119 int l_width; | 122 int l_width; |
| 120 int r_width; | 123 int r_width; |
| 121 int y_offset; | 124 int y_offset; |
| 122 }; | 125 }; |
| 123 static TabImage tab_active; | 126 static TabImage tab_active_; |
| 124 static TabImage tab_inactive; | 127 static TabImage tab_inactive_; |
| 125 static TabImage tab_alpha; | 128 static TabImage tab_alpha_; |
| 126 | 129 |
| 127 // Whether we're showing the icon. It is cached so that we can detect when it | 130 // Whether we're showing the icon. It is cached so that we can detect when it |
| 128 // changes and layout appropriately. | 131 // changes and layout appropriately. |
| 129 bool showing_icon_; | 132 bool showing_icon_; |
| 130 | 133 |
| 131 // Whether we are showing the close button. It is cached so that we can | 134 // Whether we are showing the close button. It is cached so that we can |
| 132 // detect when it changes and layout appropriately. | 135 // detect when it changes and layout appropriately. |
| 133 bool showing_close_button_; | 136 bool showing_close_button_; |
| 134 | 137 |
| 135 // The current color of the close button. | 138 // The current color of the close button. |
| 136 SkColor close_button_color_; | 139 SkColor close_button_color_; |
| 137 | 140 |
| 138 static bool initialized_; | 141 static bool initialized_; |
| 139 | 142 |
| 140 DISALLOW_COPY_AND_ASSIGN(Tab); | 143 DISALLOW_COPY_AND_ASSIGN(Tab); |
| 141 }; | 144 }; |
| 142 | 145 |
| 143 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 146 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| OLD | NEW |