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

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

Issue 14631022: Add support for blue buttons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More feedback 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/label_button_border.cc
diff --git a/ui/views/controls/button/label_button_border.cc b/ui/views/controls/button/label_button_border.cc
index 9b7b13afb69827301f0a9148f75507d726546737..cdafef11cd64d9a1714c1ef2bfd67fe0739c73d8 100644
--- a/ui/views/controls/button/label_button_border.cc
+++ b/ui/views/controls/button/label_button_border.cc
@@ -25,6 +25,16 @@ const int kFocusedNormalImages[] = IMAGE_GRID(IDR_BUTTON_FOCUSED_NORMAL);
const int kFocusedHoveredImages[] = IMAGE_GRID(IDR_BUTTON_FOCUSED_HOVER);
const int kFocusedPressedImages[] = IMAGE_GRID(IDR_BUTTON_FOCUSED_PRESSED);
+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);
+
// The text-button hot and pushed image IDs; normal is unadorned by default.
const int kTextHoveredImages[] = IMAGE_GRID(IDR_TEXTBUTTON_HOVER);
const int kTextPressedImages[] = IMAGE_GRID(IDR_TEXTBUTTON_PRESSED);
@@ -87,6 +97,23 @@ LabelButtonBorder::LabelButtonBorder(Button::ButtonStyle style)
Painter::CreateImageGridPainter(kTextHoveredImages));
SetPainter(false, Button::STATE_PRESSED,
Painter::CreateImageGridPainter(kTextPressedImages));
+ } else if (style == Button::STYLE_BLUE_BUTTON) {
+ SetPainter(false, Button::STATE_NORMAL,
+ Painter::CreateImageGridPainter(kBlueNormalImages));
+ SetPainter(false, Button::STATE_HOVERED,
+ Painter::CreateImageGridPainter(kBlueHoveredImages));
+ SetPainter(false, Button::STATE_PRESSED,
+ Painter::CreateImageGridPainter(kBluePressedImages));
+ SetPainter(false, Button::STATE_DISABLED,
+ Painter::CreateImageGridPainter(kBlueNormalImages));
+ SetPainter(true, Button::STATE_NORMAL,
+ Painter::CreateImageGridPainter(kBlueFocusedNormalImages));
+ SetPainter(true, Button::STATE_HOVERED,
+ Painter::CreateImageGridPainter(kBlueFocusedHoveredImages));
+ SetPainter(true, Button::STATE_PRESSED,
+ Painter::CreateImageGridPainter(kBlueFocusedPressedImages));
+ SetPainter(true, Button::STATE_DISABLED,
+ Painter::CreateImageGridPainter(kBlueNormalImages));
}
}
@@ -103,7 +130,10 @@ void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) {
const ui::Animation* animation = native_theme_delegate->GetThemeAnimation();
ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra);
- if (animation && animation->is_animating()) {
+ // TODO(msw): re-enable animation is for blue buttons. It's disabled now due
msw 2013/05/18 20:07:24 nit: capitalization and s/animation is/animations/
benwells 2013/05/24 07:44:22 Done.
+ // to crbug.com/239121.
+ if (animation && animation->is_animating() &&
+ style() != Button::STYLE_BLUE_BUTTON) {
// Composite the background and foreground painters during state animations.
int alpha = animation->CurrentValueBetween(0, 0xff);
state = native_theme_delegate->GetBackgroundThemeState(&extra);
@@ -116,7 +146,8 @@ void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) {
PaintHelper(this, canvas, theme, part, state, rect, extra);
canvas->Restore();
} else if (state == ui::NativeTheme::kDisabled &&
- style() == Button::STYLE_BUTTON) {
+ (style() == Button::STYLE_BUTTON ||
+ style() == Button::STYLE_BLUE_BUTTON)) {
canvas->SaveLayerAlpha(static_cast<uint8>(0xff / 2));
PaintHelper(this, canvas, theme, part, state, rect, extra);
canvas->Restore();
@@ -132,7 +163,7 @@ void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) {
gfx::Insets LabelButtonBorder::GetInsets() const {
// Return the style-specific insets between button contents and edges.
- if (style() == Button::STYLE_BUTTON)
+ if (style() == Button::STYLE_BUTTON || style() == Button::STYLE_BLUE_BUTTON)
return gfx::Insets(9, 13, 9, 13);
if (style() == Button::STYLE_TEXTBUTTON)
return gfx::Insets(5, 6, 5, 6);
« ui/views/controls/button/label_button.cc ('K') | « ui/views/controls/button/label_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698