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

Unified Diff: ui/views/controls/button/blue_button.cc

Issue 14631022: Add support for blue buttons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment updated Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/blue_button.cc
diff --git a/ui/views/controls/button/blue_button.cc b/ui/views/controls/button/blue_button.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5777424ddef98898884f2d4ab88bd4b0a8a57272
--- /dev/null
+++ b/ui/views/controls/button/blue_button.cc
@@ -0,0 +1,84 @@
+// 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 "ui/views/controls/button/blue_button.h"
+
+#include "grit/ui_resources.h"
+#include "ui/base/accessibility/accessible_view_state.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/controls/button/label_button_border.h"
+
+namespace {
+
+const int kBlueNormalImages[] = IMAGE_GRID(IDR_BLUE_BUTTON_NORMAL);
+const int kBlueHoveredImages[] = IMAGE_GRID(IDR_BLUE_BUTTON_HOVER);
+const int kBluePressedImages[] = IMAGE_GRID(IDR_BLUE_BUTTON_PRESSED);
+const int kBlueFocusedNormalImages[] = IMAGE_GRID(
+ IDR_BLUE_BUTTON_FOCUSED_NORMAL);
+const int kBlueFocusedHoveredImages[] = IMAGE_GRID(
+ IDR_BLUE_BUTTON_FOCUSED_HOVER);
+const int kBlueFocusedPressedImages[] = IMAGE_GRID(
+ IDR_BLUE_BUTTON_FOCUSED_PRESSED);
+
+// Blue button style default font color.
+const SkColor kBlueButtonTextColor = SK_ColorWHITE;
+
+// Blue button style shadow color.
+const SkColor kBlueButtonShadowColor = SkColorSetRGB(0x53, 0x8C, 0xEA);
+
+} // namespace
+
+namespace views {
+
+// static
+const char BlueButton::kViewClassName[] = "views/BlueButton";
+
+BlueButton::BlueButton(ButtonListener* listener, const string16& text)
+ : LabelButton(listener, text) {
+ LabelButtonBorder* button_border = static_cast<LabelButtonBorder*>(border());
+
+ button_border->set_insets(gfx::Insets(9, 13, 9, 13));
+
+ button_border->SetPainter(false, Button::STATE_NORMAL,
msw 2013/05/24 16:14:28 nit: i suppose you don't need to specify Button::
benwells 2013/05/27 06:53:59 Done.
+ Painter::CreateImageGridPainter(kBlueNormalImages));
+ button_border->SetPainter(
msw 2013/05/24 16:14:28 nit: match the arg placement across all these call
benwells 2013/05/27 06:53:59 Done.
+ false, Button::STATE_HOVERED,
+ Painter::CreateImageGridPainter(kBlueHoveredImages));
+ button_border->SetPainter(
+ false, Button::STATE_PRESSED,
+ Painter::CreateImageGridPainter(kBluePressedImages));
+ button_border->SetPainter(false, Button::STATE_DISABLED,
+ Painter::CreateImageGridPainter(kBlueNormalImages));
+ button_border->SetPainter(
+ true, Button::STATE_NORMAL,
+ Painter::CreateImageGridPainter(kBlueFocusedNormalImages));
+ button_border->SetPainter(
+ true, Button::STATE_HOVERED,
+ Painter::CreateImageGridPainter(kBlueFocusedHoveredImages));
+ button_border->SetPainter(
+ true, Button::STATE_PRESSED,
+ Painter::CreateImageGridPainter(kBlueFocusedPressedImages));
+ button_border->SetPainter(
+ true, Button::STATE_DISABLED,
+ Painter::CreateImageGridPainter(kBlueNormalImages));
+
+ for (size_t state = STATE_NORMAL; state < STATE_COUNT; ++state)
+ SetTextColor(static_cast<ButtonState>(state), kBlueButtonTextColor);
+ label()->SetShadowColors(kBlueButtonShadowColor, kBlueButtonShadowColor);
+ label()->SetShadowOffset(0, 1);
+}
+
+BlueButton::~BlueButton() {}
+
+const char* BlueButton::GetClassName() const {
+ return BlueButton::kViewClassName;
+}
+
+// TODO(msw): Re-enable animations for blue buttons. It's disabled now due
+// to crbug.com/239121.
+const ui::Animation* BlueButton::GetThemeAnimation() const {
+ return NULL;
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698