Chromium Code Reviews| 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 // probably a FocusBorder constant. | 26 // probably a FocusBorder constant. |
| 27 const int kFocusRectInset = 3; | 27 const int kFocusRectInset = 3; |
| 28 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( | 28 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( |
| 29 gfx::Insets(kFocusRectInset, kFocusRectInset + margin, | 29 gfx::Insets(kFocusRectInset, kFocusRectInset + margin, |
| 30 kFocusRectInset, kFocusRectInset))); | 30 kFocusRectInset, kFocusRectInset))); |
| 31 | 31 |
| 32 InvalidateLayout(); | 32 InvalidateLayout(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void BackButton::LayoutInkDrop() { | 35 void BackButton::LayoutInkDrop() { |
| 36 ink_drop_animation_controller()->SetInkDropBounds( | 36 ToolbarButton::LayoutInkDrop(); |
|
Peter Kasting
2015/09/03 21:53:06
As a reader I'm unsure whether this line has to be
bruthig
2015/09/09 18:00:35
I've re-worked this a little bit. FTR the ordering
| |
| 37 gfx::Rect(margin_leading_, 0, width() - margin_leading_, height())); | 37 ink_drop_animation_controller()->SetInkDropCenter(gfx::Point( |
| 38 (width() - margin_leading_) / 2 + margin_leading_, height() / 2)); | |
|
Peter Kasting
2015/09/03 21:53:06
Nit: Seems like you can just do (width() + margin_
bruthig
2015/09/09 18:00:35
Done.
| |
| 38 } | 39 } |
| 39 | 40 |
| 40 const char* BackButton::GetClassName() const { | 41 const char* BackButton::GetClassName() const { |
| 41 return "BackButton"; | 42 return "BackButton"; |
| 42 } | 43 } |
| 43 | 44 |
| 44 scoped_ptr<views::LabelButtonBorder> BackButton::CreateDefaultBorder() const { | 45 scoped_ptr<views::LabelButtonBorder> BackButton::CreateDefaultBorder() const { |
| 45 scoped_ptr<views::LabelButtonBorder> border = | 46 scoped_ptr<views::LabelButtonBorder> border = |
| 46 ToolbarButton::CreateDefaultBorder(); | 47 ToolbarButton::CreateDefaultBorder(); |
| 47 | 48 |
| 48 // Adjust border insets to follow the margin change, | 49 // Adjust border insets to follow the margin change, |
| 49 // which will be reflected in where the border is painted | 50 // which will be reflected in where the border is painted |
| 50 // through |GetThemePaintRect|. | 51 // through |GetThemePaintRect|. |
| 51 const gfx::Insets insets(border->GetInsets()); | 52 const gfx::Insets insets(border->GetInsets()); |
| 52 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin_leading_, | 53 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin_leading_, |
| 53 insets.bottom(), insets.right())); | 54 insets.bottom(), insets.right())); |
| 54 | 55 |
| 55 return border.Pass(); | 56 return border.Pass(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 gfx::Rect BackButton::GetThemePaintRect() const { | 59 gfx::Rect BackButton::GetThemePaintRect() const { |
| 59 gfx::Rect rect(LabelButton::GetThemePaintRect()); | 60 gfx::Rect rect(LabelButton::GetThemePaintRect()); |
| 60 rect.Inset(margin_leading_, 0, 0, 0); | 61 rect.Inset(margin_leading_, 0, 0, 0); |
| 61 return rect; | 62 return rect; |
| 62 } | 63 } |
| 63 | 64 |
| OLD | NEW |