OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | |
13 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
14 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
15 #include "grit/theme_resources_standard.h" | 14 #include "grit/theme_resources_standard.h" |
16 #include "grit/ui_resources.h" | 15 #include "grit/ui_resources.h" |
17 #include "third_party/skia/include/effects/SkGradientShader.h" | 16 #include "third_party/skia/include/effects/SkGradientShader.h" |
18 #include "ui/base/animation/multi_animation.h" | 17 #include "ui/base/animation/multi_animation.h" |
19 #include "ui/base/animation/slide_animation.h" | 18 #include "ui/base/animation/slide_animation.h" |
20 #include "ui/base/animation/throb_animation.h" | 19 #include "ui/base/animation/throb_animation.h" |
21 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/gfx/canvas_skia.h" | 21 #include "ui/gfx/canvas_skia.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 static const int kMiniTitleChangeInitialXOffset = 6; | 77 static const int kMiniTitleChangeInitialXOffset = 6; |
79 | 78 |
80 // Radius of the radial gradient used for mini title change animation. | 79 // Radius of the radial gradient used for mini title change animation. |
81 static const int kMiniTitleChangeGradientRadius = 20; | 80 static const int kMiniTitleChangeGradientRadius = 20; |
82 | 81 |
83 // Colors of the gradient used during the mini title change animation. | 82 // Colors of the gradient used during the mini title change animation. |
84 static const SkColor kMiniTitleChangeGradientColor1 = SK_ColorWHITE; | 83 static const SkColor kMiniTitleChangeGradientColor1 = SK_ColorWHITE; |
85 static const SkColor kMiniTitleChangeGradientColor2 = | 84 static const SkColor kMiniTitleChangeGradientColor2 = |
86 SkColorSetARGB(0, 255, 255, 255); | 85 SkColorSetARGB(0, 255, 255, 255); |
87 | 86 |
| 87 // Hit mask constants. |
| 88 static const SkScalar kTabCapWidth = 15; |
| 89 static const SkScalar kTabTopCurveWidth = 4; |
| 90 static const SkScalar kTabBottomCurveWidth = 3; |
| 91 |
88 // static | 92 // static |
89 const char Tab::kViewClassName[] = "browser/tabs/Tab"; | 93 const char Tab::kViewClassName[] = "browser/tabs/Tab"; |
90 | 94 |
91 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
92 // Tab, public: | 96 // Tab, public: |
93 | 97 |
94 Tab::Tab(TabController* controller) | 98 Tab::Tab(TabController* controller) |
95 : BaseTab(controller), | 99 : BaseTab(controller), |
96 showing_icon_(false), | 100 showing_icon_(false), |
97 showing_close_button_(false), | 101 showing_close_button_(false), |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 318 |
315 std::string Tab::GetClassName() const { | 319 std::string Tab::GetClassName() const { |
316 return kViewClassName; | 320 return kViewClassName; |
317 } | 321 } |
318 | 322 |
319 bool Tab::HasHitTestMask() const { | 323 bool Tab::HasHitTestMask() const { |
320 return true; | 324 return true; |
321 } | 325 } |
322 | 326 |
323 void Tab::GetHitTestMask(gfx::Path* path) const { | 327 void Tab::GetHitTestMask(gfx::Path* path) const { |
324 TabResources::GetHitTestMask(width(), height(), path); | 328 DCHECK(path); |
| 329 |
| 330 SkScalar h = SkIntToScalar(height()); |
| 331 SkScalar w = SkIntToScalar(width()); |
| 332 |
| 333 path->moveTo(0, h); |
| 334 |
| 335 // Left end cap. |
| 336 path->lineTo(kTabBottomCurveWidth, h - kTabBottomCurveWidth); |
| 337 path->lineTo(kTabCapWidth - kTabTopCurveWidth, kTabTopCurveWidth); |
| 338 path->lineTo(kTabCapWidth, 0); |
| 339 |
| 340 // Connect to the right cap. |
| 341 path->lineTo(w - kTabCapWidth, 0); |
| 342 |
| 343 // Right end cap. |
| 344 path->lineTo(w - kTabCapWidth + kTabTopCurveWidth, kTabTopCurveWidth); |
| 345 path->lineTo(w - kTabBottomCurveWidth, h - kTabBottomCurveWidth); |
| 346 path->lineTo(w, h); |
| 347 |
| 348 // Close out the path. |
| 349 path->lineTo(0, h); |
| 350 path->close(); |
325 } | 351 } |
326 | 352 |
327 bool Tab::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin) { | 353 bool Tab::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin) { |
328 origin->set_x(title_bounds_.x() + 10); | 354 origin->set_x(title_bounds_.x() + 10); |
329 origin->set_y(-views::TooltipManager::GetTooltipHeight() - 4); | 355 origin->set_y(-views::TooltipManager::GetTooltipHeight() - 4); |
330 return true; | 356 return true; |
331 } | 357 } |
332 | 358 |
333 void Tab::OnMouseMoved(const views::MouseEvent& event) { | 359 void Tab::OnMouseMoved(const views::MouseEvent& event) { |
334 hover_point_ = event.location(); | 360 hover_point_ = event.location(); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); | 675 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); |
650 tab_active_.l_width = tab_active_.image_l->width(); | 676 tab_active_.l_width = tab_active_.image_l->width(); |
651 tab_active_.r_width = tab_active_.image_r->width(); | 677 tab_active_.r_width = tab_active_.image_r->width(); |
652 | 678 |
653 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); | 679 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); |
654 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); | 680 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); |
655 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); | 681 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); |
656 tab_inactive_.l_width = tab_inactive_.image_l->width(); | 682 tab_inactive_.l_width = tab_inactive_.image_l->width(); |
657 tab_inactive_.r_width = tab_inactive_.image_r->width(); | 683 tab_inactive_.r_width = tab_inactive_.image_r->width(); |
658 } | 684 } |
OLD | NEW |