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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/toolbar/back_button.cc
diff --git a/chrome/browser/ui/views/toolbar/back_button.cc b/chrome/browser/ui/views/toolbar/back_button.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1e4c4a4ef975736846c6e96c34cc2680d5714a0c
--- /dev/null
+++ b/chrome/browser/ui/views/toolbar/back_button.cc
@@ -0,0 +1,45 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/toolbar/back_button.h"
+
+#include "ui/views/controls/button/label_button_border.h"
+#include "ui/views/focus_border.h"
+
+BackButton::BackButton(views::ButtonListener* listener,
+ ui::MenuModel* model)
+ : ToolbarButton(listener, model),
+ margin_leading_(0) {
+}
+
+BackButton::~BackButton() {
+}
+
+gfx::Rect BackButton::GetThemePaintRect() const {
+ gfx::Rect rect(LabelButton::GetThemePaintRect());
+ rect.Inset(margin_leading_, 0, 0, 0);
+ return rect;
+}
+
+void BackButton::SetLeadingMargin(int margin) {
+ // Adjust border insets to follow the margin change,
+ // which will be reflected in where the border is painted
+ // through |GetThemePaintRect|.
+ gfx::Insets insets(border()->GetInsets());
+ static_cast<views::LabelButtonBorder*>(border())->set_insets(
+ gfx::Insets(insets.top(), insets.left() + margin - margin_leading_,
+ insets.bottom(), insets.right()));
+
+ // Similarly fiddle the focus border. Value consistent with LabelButton
+ // and TextButton.
+ // TODO(gbillock): Refactor this magic number somewhere global to views,
+ // probably a FocusBorder constant.
+ const int kFocusRectInset = 3;
+ set_focus_border(views::FocusBorder::CreateDashedFocusBorder(
+ kFocusRectInset + margin, kFocusRectInset,
+ kFocusRectInset, kFocusRectInset));
+
+ margin_leading_ = margin;
+ InvalidateLayout();
+}
« 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