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 #include "chrome/browser/ui/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
11 #include "chrome/browser/themes/theme_service.h" | 11 #include "chrome/browser/themes/theme_service.h" |
12 #include "chrome/browser/ui/tabs/tab_resources.h" | 12 #include "chrome/browser/ui/tabs/tab_resources.h" |
13 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 13 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
16 #include "grit/theme_resources_standard.h" | 16 #include "grit/theme_resources_standard.h" |
17 #include "grit/ui_resources.h" | 17 #include "grit/ui_resources.h" |
18 #include "third_party/skia/include/effects/SkGradientShader.h" | 18 #include "third_party/skia/include/effects/SkGradientShader.h" |
19 #include "ui/base/animation/multi_animation.h" | 19 #include "ui/base/animation/multi_animation.h" |
20 #include "ui/base/animation/throb_animation.h" | 20 #include "ui/base/animation/throb_animation.h" |
21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/base/touch/touch_mode_support.h" | |
23 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
24 #include "ui/gfx/favicon_size.h" | 23 #include "ui/gfx/favicon_size.h" |
25 #include "ui/gfx/font.h" | 24 #include "ui/gfx/font.h" |
26 #include "ui/gfx/path.h" | 25 #include "ui/gfx/path.h" |
27 #include "ui/gfx/skbitmap_operations.h" | 26 #include "ui/gfx/skbitmap_operations.h" |
28 #include "ui/views/controls/button/image_button.h" | 27 #include "ui/views/controls/button/image_button.h" |
29 #include "ui/views/widget/tooltip_manager.h" | 28 #include "ui/views/widget/tooltip_manager.h" |
30 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
31 #include "ui/views/window/non_client_view.h" | 30 #include "ui/views/window/non_client_view.h" |
32 | 31 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #else | 64 #else |
66 static const int kCloseButtonVertFuzz = 0; | 65 static const int kCloseButtonVertFuzz = 0; |
67 #endif | 66 #endif |
68 static const int kTabIconSize = gfx::kFaviconSize; | 67 static const int kTabIconSize = gfx::kFaviconSize; |
69 // Additional horizontal offset for close button relative to title text. | 68 // Additional horizontal offset for close button relative to title text. |
70 #if defined(USE_ASH) | 69 #if defined(USE_ASH) |
71 static const int kCloseButtonHorzFuzz = 7; | 70 static const int kCloseButtonHorzFuzz = 7; |
72 #else | 71 #else |
73 static const int kCloseButtonHorzFuzz = 5; | 72 static const int kCloseButtonHorzFuzz = 5; |
74 #endif | 73 #endif |
75 static const int kTouchModeMinimumWidth = 160; | |
76 | 74 |
77 // When a non-mini-tab becomes a mini-tab the width of the tab animates. If | 75 // When a non-mini-tab becomes a mini-tab the width of the tab animates. If |
78 // the width of a mini-tab is >= kMiniTabRendererAsNormalTabWidth then the tab | 76 // the width of a mini-tab is >= kMiniTabRendererAsNormalTabWidth then the tab |
79 // is rendered as a normal tab. This is done to avoid having the title | 77 // is rendered as a normal tab. This is done to avoid having the title |
80 // immediately disappear when transitioning a tab from normal to mini-tab. | 78 // immediately disappear when transitioning a tab from normal to mini-tab. |
81 static const int kMiniTabRendererAsNormalTabWidth = | 79 static const int kMiniTabRendererAsNormalTabWidth = |
82 browser_defaults::kMiniTabWidth + 30; | 80 browser_defaults::kMiniTabWidth + 30; |
83 | 81 |
84 // How opaque to make the hover state (out of 1). | 82 // How opaque to make the hover state (out of 1). |
85 static const double kHoverOpacity = 0.33; | 83 static const double kHoverOpacity = 0.33; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 163 |
166 gfx::Size minimum_size; | 164 gfx::Size minimum_size; |
167 minimum_size.set_width(kLeftPadding + kRightPadding); | 165 minimum_size.set_width(kLeftPadding + kRightPadding); |
168 // Since we use bitmap images, the real minimum height of the image is | 166 // Since we use bitmap images, the real minimum height of the image is |
169 // defined most accurately by the height of the end cap images. | 167 // defined most accurately by the height of the end cap images. |
170 minimum_size.set_height(tab_active_.image_l->height()); | 168 minimum_size.set_height(tab_active_.image_l->height()); |
171 return minimum_size; | 169 return minimum_size; |
172 } | 170 } |
173 | 171 |
174 gfx::Size Tab::GetMinimumUnselectedSize() { | 172 gfx::Size Tab::GetMinimumUnselectedSize() { |
175 if (TouchModeSupport::IsTouchOptimized()) | |
176 return GetTouchModeMinimumSize(); | |
177 return GetBasicMinimumUnselectedSize(); | 173 return GetBasicMinimumUnselectedSize(); |
178 } | 174 } |
179 | 175 |
180 // static | 176 // static |
181 gfx::Size Tab::GetMinimumSelectedSize() { | 177 gfx::Size Tab::GetMinimumSelectedSize() { |
182 if (TouchModeSupport::IsTouchOptimized()) | |
183 return GetTouchModeMinimumSize(); | |
184 gfx::Size minimum_size = GetBasicMinimumUnselectedSize(); | 178 gfx::Size minimum_size = GetBasicMinimumUnselectedSize(); |
185 minimum_size.set_width(kLeftPadding + gfx::kFaviconSize + kRightPadding); | 179 minimum_size.set_width(kLeftPadding + gfx::kFaviconSize + kRightPadding); |
186 return minimum_size; | 180 return minimum_size; |
187 } | 181 } |
188 | 182 |
189 // static | 183 // static |
190 gfx::Size Tab::GetStandardSize() { | 184 gfx::Size Tab::GetStandardSize() { |
191 gfx::Size standard_size = GetBasicMinimumUnselectedSize(); | 185 gfx::Size standard_size = GetBasicMinimumUnselectedSize(); |
192 standard_size.set_width( | 186 standard_size.set_width( |
193 standard_size.width() + kFaviconTitleSpacing + kStandardTitleWidth); | 187 standard_size.width() + kFaviconTitleSpacing + kStandardTitleWidth); |
194 return standard_size; | 188 return standard_size; |
195 } | 189 } |
196 | 190 |
197 // static | 191 // static |
198 int Tab::GetMiniWidth() { | 192 int Tab::GetMiniWidth() { |
199 return browser_defaults::kMiniTabWidth; | 193 return browser_defaults::kMiniTabWidth; |
200 } | 194 } |
201 | 195 |
202 // static | |
203 gfx::Size Tab::GetTouchModeMinimumSize() { | |
204 InitTabResources(); | |
205 gfx::Size size; | |
206 size.set_width(kTouchModeMinimumWidth); | |
207 size.set_height(tab_active_.image_l->height()); | |
208 return size; | |
209 } | |
210 | |
211 //////////////////////////////////////////////////////////////////////////////// | 196 //////////////////////////////////////////////////////////////////////////////// |
212 // Tab, protected: | 197 // Tab, protected: |
213 | 198 |
214 const gfx::Rect& Tab::GetTitleBounds() const { | 199 const gfx::Rect& Tab::GetTitleBounds() const { |
215 return title_bounds_; | 200 return title_bounds_; |
216 } | 201 } |
217 | 202 |
218 const gfx::Rect& Tab::GetIconBounds() const { | 203 const gfx::Rect& Tab::GetIconBounds() const { |
219 return favicon_bounds_; | 204 return favicon_bounds_; |
220 } | 205 } |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); | 630 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); |
646 tab_active_.l_width = tab_active_.image_l->width(); | 631 tab_active_.l_width = tab_active_.image_l->width(); |
647 tab_active_.r_width = tab_active_.image_r->width(); | 632 tab_active_.r_width = tab_active_.image_r->width(); |
648 | 633 |
649 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); | 634 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); |
650 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); | 635 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); |
651 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); | 636 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); |
652 tab_inactive_.l_width = tab_inactive_.image_l->width(); | 637 tab_inactive_.l_width = tab_inactive_.image_l->width(); |
653 tab_inactive_.r_width = tab_inactive_.image_r->width(); | 638 tab_inactive_.r_width = tab_inactive_.image_r->width(); |
654 } | 639 } |
OLD | NEW |