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..3d6c8369fd764c12a6e2bc1701f27cdc9a728438 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); |
msw
2013/05/13 18:27:20
nit: consider dropping 'Images' from these constan
benwells
2013/05/14 11:30:44
I think I prefer it being consistent with the norm
msw
2013/05/14 16:20:02
Ok, feel free to leave/change both.
|
+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)); |
} |
} |
@@ -105,18 +132,21 @@ void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) { |
if (animation && animation->is_animating()) { |
// Composite the background and foreground painters during state animations. |
- int alpha = animation->CurrentValueBetween(0, 0xff); |
+ // The alpha is how much of the foreground state to use. To get this, |
msw
2013/05/13 18:27:20
Hmm, I don't think this is correct, because the im
benwells
2013/05/14 11:30:44
Ah, I think I now understand the intent of that ch
msw
2013/05/14 16:20:02
Ah, you're right, we must blend the images before
|
+ // composite (using SOURCE_OVER) alpha of the foreground over the |
+ // background. This is equivalent to compositing (1 - alpha) of the |
+ // background over the foreground. |
state = native_theme_delegate->GetBackgroundThemeState(&extra); |
- canvas->SaveLayerAlpha(static_cast<uint8>(0xff - alpha)); |
PaintHelper(this, canvas, theme, part, state, rect, extra); |
- canvas->Restore(); |
+ int alpha = animation->CurrentValueBetween(0, 0xff); |
state = native_theme_delegate->GetForegroundThemeState(&extra); |
canvas->SaveLayerAlpha(static_cast<uint8>(alpha)); |
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(); |
@@ -138,6 +168,8 @@ gfx::Insets LabelButtonBorder::GetInsets() const { |
return gfx::Insets(5, 6, 5, 6); |
if (style() == Button::STYLE_NATIVE_TEXTBUTTON) |
return gfx::Insets(5, 12, 5, 12); |
+ if (style() == Button::STYLE_BLUE_BUTTON) |
+ return gfx::Insets(9, 13, 9, 13); |
NOTREACHED(); |
return gfx::Insets(); |
} |