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

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

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Further renaming Created 6 years, 11 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 | Annotate | Revision Log
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/insets.h" 7 #include "ui/gfx/insets.h"
8 #include "ui/views/controls/button/label_button_border.h" 8 #include "ui/views/controls/button/label_button_border.h"
9 #include "ui/views/painter.h" 9 #include "ui/views/painter.h"
10 10
11 BackButton::BackButton(views::ButtonListener* listener, 11 BackButton::BackButton(views::ButtonListener* listener,
12 ui::MenuModel* model) 12 ui::MenuModel* model)
13 : ToolbarButton(listener, model), 13 : ToolbarButton(listener, model),
14 margin_leading_(0) { 14 margin_leading_(0) {
15 } 15 }
16 16
17 BackButton::~BackButton() { 17 BackButton::~BackButton() {
18 } 18 }
19 19
20 gfx::Rect BackButton::GetThemePaintRect() const { 20 gfx::Rect BackButton::GetThemePaintRect() const {
21 gfx::Rect rect(LabelButton::GetThemePaintRect()); 21 gfx::Rect rect(LabelButton::GetThemePaintRect());
22 rect.Inset(margin_leading_, 0, 0, 0); 22 rect.Inset(margin_leading_, 0, 0, 0);
23 return rect; 23 return rect;
24 } 24 }
25 25
26 void BackButton::SetLeadingMargin(int margin) { 26 void BackButton::SetLeadingMargin(int margin) {
27 // Adjust border insets to follow the margin change, 27 // Adjust border insets to follow the margin change,
28 // which will be reflected in where the border is painted 28 // which will be reflected in where the border is painted
29 // through |GetThemePaintRect|. 29 // through |GetThemePaintRect|.
30 views::LabelButtonBorder* border = new views::LabelButtonBorder(style()); 30 scoped_ptr<views::LabelButtonBorder> border(
31 new views::LabelButtonBorder(style()));
31 const gfx::Insets insets(border->GetInsets()); 32 const gfx::Insets insets(border->GetInsets());
32 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin, 33 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin,
33 insets.bottom(), insets.right())); 34 insets.bottom(), insets.right()));
34 UpdateThemedBorder(border); 35 UpdateThemedBorder(border.PassAs<views::Border>());
35 36
36 // Similarly fiddle the focus border. Value consistent with LabelButton 37 // Similarly fiddle the focus border. Value consistent with LabelButton
37 // and TextButton. 38 // and TextButton.
38 // TODO(gbillock): Refactor this magic number somewhere global to views, 39 // TODO(gbillock): Refactor this magic number somewhere global to views,
39 // probably a FocusBorder constant. 40 // probably a FocusBorder constant.
40 const int kFocusRectInset = 3; 41 const int kFocusRectInset = 3;
41 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( 42 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
42 gfx::Insets(kFocusRectInset, kFocusRectInset + margin, 43 gfx::Insets(kFocusRectInset, kFocusRectInset + margin,
43 kFocusRectInset, kFocusRectInset))); 44 kFocusRectInset, kFocusRectInset)));
44 45
45 margin_leading_ = margin; 46 margin_leading_ = margin;
46 InvalidateLayout(); 47 InvalidateLayout();
47 } 48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698