OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/back_button.h" | 5 #include "chrome/browser/ui/views/toolbar/back_button.h" |
6 | 6 |
7 #include "ui/gfx/geometry/insets.h" | 7 #include "ui/gfx/geometry/insets.h" |
8 #include "ui/views/animation/ink_drop_animation_controller.h" | 8 #include "ui/views/animation/ink_drop_animation_controller.h" |
9 #include "ui/views/controls/button/label_button_border.h" | 9 #include "ui/views/controls/button/label_button_border.h" |
10 #include "ui/views/painter.h" | 10 #include "ui/views/painter.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 const gfx::Insets insets(inset, inset + (is_rtl ? 0 : margin), | 26 const gfx::Insets insets(inset, inset + (is_rtl ? 0 : margin), |
27 inset, inset + (is_rtl ? margin : 0)); | 27 inset, inset + (is_rtl ? margin : 0)); |
28 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(insets)); | 28 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(insets)); |
29 InvalidateLayout(); | 29 InvalidateLayout(); |
30 } | 30 } |
31 | 31 |
32 const char* BackButton::GetClassName() const { | 32 const char* BackButton::GetClassName() const { |
33 return "BackButton"; | 33 return "BackButton"; |
34 } | 34 } |
35 | 35 |
36 scoped_ptr<views::LabelButtonBorder> BackButton::CreateDefaultBorder() const { | 36 std::unique_ptr<views::LabelButtonBorder> BackButton::CreateDefaultBorder() |
37 scoped_ptr<views::LabelButtonBorder> border = | 37 const { |
| 38 std::unique_ptr<views::LabelButtonBorder> border = |
38 ToolbarButton::CreateDefaultBorder(); | 39 ToolbarButton::CreateDefaultBorder(); |
39 | 40 |
40 // Adjust border insets to follow the margin change, | 41 // Adjust border insets to follow the margin change, |
41 // which will be reflected in where the border is painted | 42 // which will be reflected in where the border is painted |
42 // through GetThemePaintRect(). | 43 // through GetThemePaintRect(). |
43 const gfx::Insets insets(border->GetInsets()); | 44 const gfx::Insets insets(border->GetInsets()); |
44 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin_leading_, | 45 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin_leading_, |
45 insets.bottom(), insets.right())); | 46 insets.bottom(), insets.right())); |
46 | 47 |
47 return border; | 48 return border; |
48 } | 49 } |
49 | 50 |
50 gfx::Rect BackButton::GetThemePaintRect() const { | 51 gfx::Rect BackButton::GetThemePaintRect() const { |
51 gfx::Rect rect(LabelButton::GetThemePaintRect()); | 52 gfx::Rect rect(LabelButton::GetThemePaintRect()); |
52 const bool is_rtl = base::i18n::IsRTL(); | 53 const bool is_rtl = base::i18n::IsRTL(); |
53 rect.Inset(is_rtl ? 0 : margin_leading_, 0, is_rtl ? margin_leading_ : 0, 0); | 54 rect.Inset(is_rtl ? 0 : margin_leading_, 0, is_rtl ? margin_leading_ : 0, 0); |
54 return rect; | 55 return rect; |
55 } | 56 } |
56 | 57 |
OLD | NEW |