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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ui/gfx/favicon_size.h" | 23 #include "ui/gfx/favicon_size.h" |
24 #include "ui/gfx/font.h" | 24 #include "ui/gfx/font.h" |
25 #include "ui/gfx/path.h" | 25 #include "ui/gfx/path.h" |
26 #include "ui/gfx/skbitmap_operations.h" | 26 #include "ui/gfx/skbitmap_operations.h" |
27 #include "ui/views/controls/button/image_button.h" | 27 #include "ui/views/controls/button/image_button.h" |
28 #include "ui/views/touchui/touch_mode_support.h" | 28 #include "ui/views/touchui/touch_mode_support.h" |
29 #include "ui/views/widget/tooltip_manager.h" | 29 #include "ui/views/widget/tooltip_manager.h" |
30 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
31 #include "ui/views/window/non_client_view.h" | 31 #include "ui/views/window/non_client_view.h" |
32 | 32 |
| 33 // Padding around the "content" of a tab, occupied by the tab border graphics. |
| 34 #if defined(USE_ASH) |
| 35 static const int kLeftPadding = 21; |
| 36 static const int kTopPadding = 8; |
| 37 static const int kRightPadding = 20; |
| 38 static const int kBottomPadding = 5; |
| 39 #else |
33 static const int kLeftPadding = 16; | 40 static const int kLeftPadding = 16; |
34 static const int kTopPadding = 6; | 41 static const int kTopPadding = 6; |
35 static const int kRightPadding = 15; | 42 static const int kRightPadding = 15; |
36 static const int kBottomPadding = 5; | 43 static const int kBottomPadding = 5; |
| 44 #endif |
| 45 |
| 46 // Height of the shadow at the top of the tab image assets. |
| 47 #if defined(USE_ASH) |
| 48 static const int kDropShadowHeight = 4; |
| 49 #else |
37 static const int kDropShadowHeight = 2; | 50 static const int kDropShadowHeight = 2; |
| 51 #endif |
38 static const int kToolbarOverlap = 1; | 52 static const int kToolbarOverlap = 1; |
39 static const int kFaviconTitleSpacing = 4; | 53 static const int kFaviconTitleSpacing = 4; |
| 54 // Additional vertical offset for title text relative to top of tab. |
| 55 #if defined(USE_ASH) |
| 56 static const int kTitleTextOffsetY = 2; |
| 57 #else |
| 58 static const int kTitleTextOffsetY = 0; |
| 59 #endif |
40 static const int kTitleCloseButtonSpacing = 3; | 60 static const int kTitleCloseButtonSpacing = 3; |
41 static const int kStandardTitleWidth = 175; | 61 static const int kStandardTitleWidth = 175; |
| 62 // Additional vertical offset for close button relative to top of tab. |
| 63 #if defined(USE_ASH) |
| 64 static const int kCloseButtonVertFuzz = 1; |
| 65 #else |
42 static const int kCloseButtonVertFuzz = 0; | 66 static const int kCloseButtonVertFuzz = 0; |
| 67 #endif |
43 static const int kTabIconSize = gfx::kFaviconSize; | 68 static const int kTabIconSize = gfx::kFaviconSize; |
44 static const int kCloseButtonHorzFuzz = 5; | 69 static const int kCloseButtonHorzFuzz = 5; |
45 static const int kTouchModeMinimumWidth = 160; | 70 static const int kTouchModeMinimumWidth = 160; |
46 | 71 |
47 // Vertical adjustment to the favicon when the tab has a large icon. | |
48 static const int kAppTapFaviconVerticalAdjustment = 2; | |
49 | |
50 // When a non-mini-tab becomes a mini-tab the width of the tab animates. If | 72 // When a non-mini-tab becomes a mini-tab the width of the tab animates. If |
51 // the width of a mini-tab is >= kMiniTabRendererAsNormalTabWidth then the tab | 73 // the width of a mini-tab is >= kMiniTabRendererAsNormalTabWidth then the tab |
52 // is rendered as a normal tab. This is done to avoid having the title | 74 // is rendered as a normal tab. This is done to avoid having the title |
53 // immediately disappear when transitioning a tab from normal to mini-tab. | 75 // immediately disappear when transitioning a tab from normal to mini-tab. |
54 static const int kMiniTabRendererAsNormalTabWidth = | 76 static const int kMiniTabRendererAsNormalTabWidth = |
55 browser_defaults::kMiniTabWidth + 30; | 77 browser_defaults::kMiniTabWidth + 30; |
56 | 78 |
57 // How opaque to make the hover state (out of 1). | 79 // How opaque to make the hover state (out of 1). |
58 static const double kHoverOpacity = 0.33; | 80 static const double kHoverOpacity = 0.33; |
59 static const double kHoverSlideOpacity = 0.5; | |
60 | 81 |
61 // Opacity for non-active selected tabs. | 82 // Opacity for non-active selected tabs. |
62 static const double kSelectedTabOpacity = .45; | 83 static const double kSelectedTabOpacity = .45; |
63 | 84 |
64 // Selected (but not active) tabs have their throb value scaled down by this. | 85 // Selected (but not active) tabs have their throb value scaled down by this. |
65 static const double kSelectedTabThrobScale = .5; | 86 static const double kSelectedTabThrobScale = .5; |
66 | 87 |
67 Tab::TabImage Tab::tab_alpha_ = {0}; | 88 Tab::TabImage Tab::tab_alpha_ = {0}; |
68 Tab::TabImage Tab::tab_active_ = {0}; | 89 Tab::TabImage Tab::tab_active_ = {0}; |
69 Tab::TabImage Tab::tab_inactive_ = {0}; | 90 Tab::TabImage Tab::tab_inactive_ = {0}; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 close_button()->SetBounds(lb.width() + kCloseButtonHorzFuzz, | 309 close_button()->SetBounds(lb.width() + kCloseButtonHorzFuzz, |
289 close_button_top, close_button_size.width(), | 310 close_button_top, close_button_size.width(), |
290 close_button_size.height()); | 311 close_button_size.height()); |
291 close_button()->SetVisible(true); | 312 close_button()->SetVisible(true); |
292 } else { | 313 } else { |
293 close_button()->SetBounds(0, 0, 0, 0); | 314 close_button()->SetBounds(0, 0, 0, 0); |
294 close_button()->SetVisible(false); | 315 close_button()->SetVisible(false); |
295 } | 316 } |
296 | 317 |
297 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; | 318 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; |
298 int title_top = kTopPadding + (content_height - font_height()) / 2; | 319 int title_top = |
| 320 kTopPadding + kTitleTextOffsetY + (content_height - font_height()) / 2; |
299 // Size the Title text to fill the remaining space. | 321 // Size the Title text to fill the remaining space. |
300 if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) { | 322 if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) { |
301 // If the user has big fonts, the title will appear rendered too far down | 323 // If the user has big fonts, the title will appear rendered too far down |
302 // on the y-axis if we use the regular top padding, so we need to adjust it | 324 // on the y-axis if we use the regular top padding, so we need to adjust it |
303 // so that the text appears centered. | 325 // so that the text appears centered. |
304 gfx::Size minimum_size = GetMinimumUnselectedSize(); | 326 gfx::Size minimum_size = GetMinimumUnselectedSize(); |
305 int text_height = title_top + font_height() + kBottomPadding; | 327 int text_height = title_top + font_height() + kBottomPadding; |
306 if (text_height > minimum_size.height()) | 328 if (text_height > minimum_size.height()) |
307 title_top -= (text_height - minimum_size.height()) / 2; | 329 title_top -= (text_height - minimum_size.height()) / 2; |
308 | 330 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); | 640 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); |
619 tab_active_.l_width = tab_active_.image_l->width(); | 641 tab_active_.l_width = tab_active_.image_l->width(); |
620 tab_active_.r_width = tab_active_.image_r->width(); | 642 tab_active_.r_width = tab_active_.image_r->width(); |
621 | 643 |
622 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); | 644 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); |
623 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); | 645 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); |
624 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); | 646 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); |
625 tab_inactive_.l_width = tab_inactive_.image_l->width(); | 647 tab_inactive_.l_width = tab_inactive_.image_l->width(); |
626 tab_inactive_.r_width = tab_inactive_.image_r->width(); | 648 tab_inactive_.r_width = tab_inactive_.image_r->width(); |
627 } | 649 } |
OLD | NEW |