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

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

Issue 62873007: [Toolbar] Base toolbar button class with background images for button states (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: overriding Created 7 years 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
(Empty)
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.
4
5 #include "chrome/browser/ui/views/toolbar/back_button.h"
6
7 #include "ui/views/controls/button/label_button_border.h"
8 #include "ui/views/focus_border.h"
9
10 BackButton::BackButton(views::ButtonListener* listener,
11 ui::MenuModel* model)
12 : ToolbarButton(listener, model),
13 margin_leading_(0) {
14 }
15
16 BackButton::~BackButton() {
17 }
18
19 gfx::Rect BackButton::GetThemePaintRect() const {
20 gfx::Rect rect(LabelButton::GetThemePaintRect());
21 rect.Inset(margin_leading_, 0, 0, 0);
22 return rect;
23 }
24
25 void BackButton::SetLeadingMargin(int margin) {
26 // Adjust border insets to follow the margin change,
27 // which will be reflected in where the border is painted
28 // through |GetThemePaintRect|.
29 gfx::Insets insets(border()->GetInsets());
30 static_cast<views::LabelButtonBorder*>(border())->set_insets(
31 gfx::Insets(insets.top(), insets.left() + margin - margin_leading_,
32 insets.bottom(), insets.right()));
33
34 // Similarly fiddle the focus border. Value consistent with LabelButton
35 // and TextButton.
36 // TODO(gbillock): Refactor this magic number somewhere global to views,
37 // probably a FocusBorder constant.
38 const int kFocusRectInset = 3;
39 set_focus_border(views::FocusBorder::CreateDashedFocusBorder(
40 kFocusRectInset + margin, kFocusRectInset,
41 kFocusRectInset, kFocusRectInset));
42
43 margin_leading_ = margin;
44 InvalidateLayout();
45 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/back_button.h ('k') | chrome/browser/ui/views/toolbar/button_dropdown.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698