Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 1406613002: For some vector icons, get the size from the vector definition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const SkColor kImmersiveInactiveTabColor = SkColorSetRGB(190, 190, 190); 111 const SkColor kImmersiveInactiveTabColor = SkColorSetRGB(190, 190, 190);
112 112
113 // The minimum opacity (out of 1) when a tab (either active or inactive) is 113 // The minimum opacity (out of 1) when a tab (either active or inactive) is
114 // throbbing in the immersive mode light strip. 114 // throbbing in the immersive mode light strip.
115 const double kImmersiveTabMinThrobOpacity = 0.66; 115 const double kImmersiveTabMinThrobOpacity = 0.66;
116 116
117 // Number of steps in the immersive mode loading animation. 117 // Number of steps in the immersive mode loading animation.
118 const int kImmersiveLoadingStepCount = 32; 118 const int kImmersiveLoadingStepCount = 32;
119 119
120 const char kTabCloseButtonName[] = "TabCloseButton"; 120 const char kTabCloseButtonName[] = "TabCloseButton";
121 const int kTabCloseButtonSize = 16;
122 121
123 // Returns the width of the tab endcap at scale 1. More precisely, this is the 122 // Returns the width of the tab endcap at scale 1. More precisely, this is the
124 // width of the curve making up either the outer or inner edge of the stroke; 123 // width of the curve making up either the outer or inner edge of the stroke;
125 // since these two curves are horizontally offset by 1 px (regardless of scale), 124 // since these two curves are horizontally offset by 1 px (regardless of scale),
126 // the total width of the endcap from tab outer edge to the inside end of the 125 // the total width of the endcap from tab outer edge to the inside end of the
127 // stroke inner edge is (GetUnscaledEndcapWidth() * scale) + 1. 126 // stroke inner edge is (GetUnscaledEndcapWidth() * scale) + 1.
128 float GetUnscaledEndcapWidth() { 127 float GetUnscaledEndcapWidth() {
129 return GetLayoutInsets(TAB).left() - 0.5f; 128 return GetLayoutInsets(TAB).left() - 0.5f;
130 } 129 }
131 130
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 alert_indicator_button_ = new AlertIndicatorButton(this); 530 alert_indicator_button_ = new AlertIndicatorButton(this);
532 AddChildView(alert_indicator_button_); 531 AddChildView(alert_indicator_button_);
533 532
534 close_button_ = new TabCloseButton(this); 533 close_button_ = new TabCloseButton(this);
535 close_button_->SetAccessibleName( 534 close_button_->SetAccessibleName(
536 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 535 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
537 // The normal image is set by OnButtonColorMaybeChanged() because it depends 536 // The normal image is set by OnButtonColorMaybeChanged() because it depends
538 // on the current theme and active state. The hovered and pressed images 537 // on the current theme and active state. The hovered and pressed images
539 // don't depend on the these, so we can set them here. 538 // don't depend on the these, so we can set them here.
540 const gfx::ImageSkia& hovered = gfx::CreateVectorIcon( 539 const gfx::ImageSkia& hovered = gfx::CreateVectorIcon(
541 gfx::VectorIconId::TAB_CLOSE_HOVERED_PRESSED, kTabCloseButtonSize, 540 gfx::VectorIconId::TAB_CLOSE_HOVERED_PRESSED,
542 SkColorSetRGB(0xDB, 0x44, 0x37)); 541 SkColorSetRGB(0xDB, 0x44, 0x37));
543 const gfx::ImageSkia& pressed = gfx::CreateVectorIcon( 542 const gfx::ImageSkia& pressed = gfx::CreateVectorIcon(
544 gfx::VectorIconId::TAB_CLOSE_HOVERED_PRESSED, kTabCloseButtonSize, 543 gfx::VectorIconId::TAB_CLOSE_HOVERED_PRESSED,
545 SkColorSetRGB(0xA8, 0x35, 0x2A)); 544 SkColorSetRGB(0xA8, 0x35, 0x2A));
546 close_button_->SetImage(views::CustomButton::STATE_HOVERED, &hovered); 545 close_button_->SetImage(views::CustomButton::STATE_HOVERED, &hovered);
547 close_button_->SetImage(views::CustomButton::STATE_PRESSED, &pressed); 546 close_button_->SetImage(views::CustomButton::STATE_PRESSED, &pressed);
548 547
549 // Disable animation so that the red danger sign shows up immediately 548 // Disable animation so that the red danger sign shows up immediately
550 // to help avoid mis-clicks. 549 // to help avoid mis-clicks.
551 close_button_->SetAnimationDuration(0); 550 close_button_->SetAnimationDuration(0);
552 AddChildView(close_button_); 551 AddChildView(close_button_);
553 552
554 set_context_menu_controller(this); 553 set_context_menu_controller(this);
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 1630
1632 const SkColor title_color = theme_provider->GetColor(IsActive() ? 1631 const SkColor title_color = theme_provider->GetColor(IsActive() ?
1633 ThemeProperties::COLOR_TAB_TEXT : 1632 ThemeProperties::COLOR_TAB_TEXT :
1634 ThemeProperties::COLOR_BACKGROUND_TAB_TEXT); 1633 ThemeProperties::COLOR_BACKGROUND_TAB_TEXT);
1635 const SkColor new_button_color = SkColorSetA(title_color, 0xA0); 1634 const SkColor new_button_color = SkColorSetA(title_color, 0xA0);
1636 if (button_color_ != new_button_color) { 1635 if (button_color_ != new_button_color) {
1637 button_color_ = new_button_color; 1636 button_color_ = new_button_color;
1638 title_->SetEnabledColor(title_color); 1637 title_->SetEnabledColor(title_color);
1639 alert_indicator_button_->OnParentTabButtonColorChanged(); 1638 alert_indicator_button_->OnParentTabButtonColorChanged();
1640 const gfx::ImageSkia& close_button_normal_image = gfx::CreateVectorIcon( 1639 const gfx::ImageSkia& close_button_normal_image = gfx::CreateVectorIcon(
1641 gfx::VectorIconId::TAB_CLOSE_NORMAL, kTabCloseButtonSize, 1640 gfx::VectorIconId::TAB_CLOSE_NORMAL, button_color_);
1642 button_color_);
1643 close_button_->SetImage(views::CustomButton::STATE_NORMAL, 1641 close_button_->SetImage(views::CustomButton::STATE_NORMAL,
1644 &close_button_normal_image); 1642 &close_button_normal_image);
1645 } 1643 }
1646 } 1644 }
1647 1645
1648 void Tab::ScheduleIconPaint() { 1646 void Tab::ScheduleIconPaint() {
1649 gfx::Rect bounds = favicon_bounds_; 1647 gfx::Rect bounds = favicon_bounds_;
1650 if (bounds.IsEmpty()) 1648 if (bounds.IsEmpty())
1651 return; 1649 return;
1652 1650
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 inactive_images_.image_c = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_CENTER); 1761 inactive_images_.image_c = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_CENTER);
1764 inactive_images_.image_r = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_RIGHT); 1762 inactive_images_.image_r = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_RIGHT);
1765 inactive_images_.l_width = inactive_images_.image_l->width(); 1763 inactive_images_.l_width = inactive_images_.image_l->width();
1766 inactive_images_.r_width = inactive_images_.image_r->width(); 1764 inactive_images_.r_width = inactive_images_.image_r->width();
1767 1765
1768 mask_images_.image_l = rb.GetImageSkiaNamed(IDR_TAB_ALPHA_LEFT); 1766 mask_images_.image_l = rb.GetImageSkiaNamed(IDR_TAB_ALPHA_LEFT);
1769 mask_images_.image_r = rb.GetImageSkiaNamed(IDR_TAB_ALPHA_RIGHT); 1767 mask_images_.image_r = rb.GetImageSkiaNamed(IDR_TAB_ALPHA_RIGHT);
1770 mask_images_.l_width = mask_images_.image_l->width(); 1768 mask_images_.l_width = mask_images_.image_l->width();
1771 mask_images_.r_width = mask_images_.image_r->width(); 1769 mask_images_.r_width = mask_images_.image_r->width();
1772 } 1770 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698