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