Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / back_button.cc
blob33a07e7086a0a902cbcf1c84d492ee5310808031
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/toolbar/back_button.h"
7 #include "ui/gfx/insets.h"
8 #include "ui/views/controls/button/label_button_border.h"
9 #include "ui/views/painter.h"
11 BackButton::BackButton(views::ButtonListener* listener,
12 ui::MenuModel* model)
13 : ToolbarButton(listener, model),
14 margin_leading_(0) {
17 BackButton::~BackButton() {
20 gfx::Rect BackButton::GetThemePaintRect() const {
21 gfx::Rect rect(LabelButton::GetThemePaintRect());
22 rect.Inset(margin_leading_, 0, 0, 0);
23 return rect;
26 void BackButton::SetLeadingMargin(int margin) {
27 // Adjust border insets to follow the margin change,
28 // which will be reflected in where the border is painted
29 // through |GetThemePaintRect|.
30 views::LabelButtonBorder* border = new views::LabelButtonBorder(style());
31 const gfx::Insets insets(border->GetInsets());
32 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin,
33 insets.bottom(), insets.right()));
34 set_border(border);
36 // Similarly fiddle the focus border. Value consistent with LabelButton
37 // and TextButton.
38 // TODO(gbillock): Refactor this magic number somewhere global to views,
39 // probably a FocusBorder constant.
40 const int kFocusRectInset = 3;
41 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
42 gfx::Insets(kFocusRectInset, kFocusRectInset + margin,
43 kFocusRectInset, kFocusRectInset)));
45 margin_leading_ = margin;
46 InvalidateLayout();