| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/profiles/win10_native_avatar_button.h" | 5 #include "chrome/browser/ui/views/profiles/win10_native_avatar_button.h" |
| 6 | 6 |
| 7 #include "chrome/app/vector_icons/vector_icons.h" | 7 #include "chrome/app/vector_icons/vector_icons.h" |
| 8 #include "chrome/browser/ui/views/frame/minimize_button_metrics_win.h" |
| 8 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 9 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 9 #include "ui/gfx/paint_vector_icon.h" | 10 #include "ui/gfx/paint_vector_icon.h" |
| 10 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 11 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 11 #include "ui/views/animation/ink_drop_impl.h" | 12 #include "ui/views/animation/ink_drop_impl.h" |
| 12 #include "ui/views/border.h" | 13 #include "ui/views/border.h" |
| 13 #include "ui/views/painter.h" | 14 #include "ui/views/painter.h" |
| 14 | 15 |
| 15 const int kButtonMinWidth = 48; | 16 const int kButtonMinWidth = 48; |
| 16 const int kButtonMaxWidth = 96; | 17 const int kButtonMaxWidth = 96; |
| 17 // Height of the "cozy" MD button that slides over the tabstrip | 18 // Height of the "cozy" MD button that slides over the tabstrip |
| (...skipping 26 matching lines...) Expand all Loading... |
| 44 set_ink_drop_base_color(SK_ColorBLACK); | 45 set_ink_drop_base_color(SK_ColorBLACK); |
| 45 set_ink_drop_visible_opacity(kRippleInkDropOpacity); | 46 set_ink_drop_visible_opacity(kRippleInkDropOpacity); |
| 46 } | 47 } |
| 47 | 48 |
| 48 Win10NativeAvatarButton::~Win10NativeAvatarButton() {} | 49 Win10NativeAvatarButton::~Win10NativeAvatarButton() {} |
| 49 | 50 |
| 50 gfx::Size Win10NativeAvatarButton::GetPreferredSize() const { | 51 gfx::Size Win10NativeAvatarButton::GetPreferredSize() const { |
| 51 gfx::Size ps = views::MenuButton::GetPreferredSize(); | 52 gfx::Size ps = views::MenuButton::GetPreferredSize(); |
| 52 ps.set_width( | 53 ps.set_width( |
| 53 std::min(std::max(ps.width(), kButtonMinWidth), kButtonMaxWidth)); | 54 std::min(std::max(ps.width(), kButtonMinWidth), kButtonMaxWidth)); |
| 54 // TODO(emx): get the proper height here - see http://crrev/2833363002 | 55 ps.set_height(MinimizeButtonMetrics::GetCaptionButtonHeightInDIPs()); |
| 55 ps.set_height(30); | |
| 56 return ps; | 56 return ps; |
| 57 } | 57 } |
| 58 | 58 |
| 59 std::unique_ptr<views::Border> Win10NativeAvatarButton::CreateBorder() const { | 59 std::unique_ptr<views::Border> Win10NativeAvatarButton::CreateBorder() const { |
| 60 // These insets look OK at 100%, 125%, 150%, 175% and 200% scaling. | 60 // These insets look OK at 100%, 125%, 150%, 175% and 200% scaling. |
| 61 const int kLeftRightInset = 8; | 61 const int kLeftRightInset = 8; |
| 62 const int kTopInset = 1; | 62 const int kTopInset = 1; |
| 63 const int kBottomInset = 3; | 63 const int kBottomInset = 3; |
| 64 return views::CreateEmptyBorder(kTopInset, kLeftRightInset, kBottomInset, | 64 return views::CreateEmptyBorder(kTopInset, kLeftRightInset, kBottomInset, |
| 65 kLeftRightInset); | 65 kLeftRightInset); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 95 // In RTL the new tab button is on the left, so it can never slide under the | 95 // In RTL the new tab button is on the left, so it can never slide under the |
| 96 // avatar button (which is still on the right). May as well use the space. | 96 // avatar button (which is still on the right). May as well use the space. |
| 97 if (base::i18n::IsRTL()) | 97 if (base::i18n::IsRTL()) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 // Use the "cozy" button if the tabstrip can slide under it | 100 // Use the "cozy" button if the tabstrip can slide under it |
| 101 if (tab_strip->max_x() >= button_x) { | 101 if (tab_strip->max_x() >= button_x) { |
| 102 *button_height = kButtonCozyHeight; | 102 *button_height = kButtonCozyHeight; |
| 103 } | 103 } |
| 104 } | 104 } |
| OLD | NEW |