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

Side by Side Diff: chrome/browser/ui/views/toolbar/back_button.cc

Issue 1761443003: [MD] simplify and unify some ink drop center calculations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: works in rtl Created 4 years, 9 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 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 11 matching lines...) Expand all
22 UpdateThemedBorder(); 22 UpdateThemedBorder();
23 23
24 const int inset = LabelButton::kFocusRectInset; 24 const int inset = LabelButton::kFocusRectInset;
25 const bool is_rtl = base::i18n::IsRTL(); 25 const bool is_rtl = base::i18n::IsRTL();
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 gfx::Point BackButton::GetInkDropCenter() const {
33 int visible_width = GetPreferredSize().width();
34 return gfx::Point(
35 GetMirroredXWithWidthInView(margin_leading_, visible_width) +
36 visible_width / 2,
37 height() / 2);
38 }
39
40 const char* BackButton::GetClassName() const { 32 const char* BackButton::GetClassName() const {
41 return "BackButton"; 33 return "BackButton";
42 } 34 }
43 35
44 scoped_ptr<views::LabelButtonBorder> BackButton::CreateDefaultBorder() const { 36 scoped_ptr<views::LabelButtonBorder> BackButton::CreateDefaultBorder() const {
45 scoped_ptr<views::LabelButtonBorder> border = 37 scoped_ptr<views::LabelButtonBorder> border =
46 ToolbarButton::CreateDefaultBorder(); 38 ToolbarButton::CreateDefaultBorder();
47 39
48 // Adjust border insets to follow the margin change, 40 // Adjust border insets to follow the margin change,
49 // which will be reflected in where the border is painted 41 // which will be reflected in where the border is painted
50 // through GetThemePaintRect(). 42 // through GetThemePaintRect().
51 const gfx::Insets insets(border->GetInsets()); 43 const gfx::Insets insets(border->GetInsets());
52 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin_leading_, 44 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin_leading_,
53 insets.bottom(), insets.right())); 45 insets.bottom(), insets.right()));
54 46
55 return border; 47 return border;
56 } 48 }
57 49
58 gfx::Rect BackButton::GetThemePaintRect() const { 50 gfx::Rect BackButton::GetThemePaintRect() const {
59 gfx::Rect rect(LabelButton::GetThemePaintRect()); 51 gfx::Rect rect(LabelButton::GetThemePaintRect());
60 const bool is_rtl = base::i18n::IsRTL(); 52 const bool is_rtl = base::i18n::IsRTL();
61 rect.Inset(is_rtl ? 0 : margin_leading_, 0, is_rtl ? margin_leading_ : 0, 0); 53 rect.Inset(is_rtl ? 0 : margin_leading_, 0, is_rtl ? margin_leading_ : 0, 0);
62 return rect; 54 return rect;
63 } 55 }
64 56
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698