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

Unified Diff: views/controls/button/image_button.cc

Issue 119025: Add ability to theme our buttons.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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: views/controls/button/image_button.cc
===================================================================
--- views/controls/button/image_button.cc (revision 17327)
+++ views/controls/button/image_button.cc (working copy)
@@ -19,7 +19,8 @@
ImageButton::ImageButton(ButtonListener* listener)
: CustomButton(listener),
h_alignment_(ALIGN_LEFT),
- v_alignment_(ALIGN_TOP) {
+ v_alignment_(ALIGN_TOP),
+ background_image_(NULL) {
// By default, we request that the gfx::Canvas passed to our View::Paint()
// implementation is flipped horizontally so that the button's bitmaps are
// mirrored when the UI directionality is right-to-left.
@@ -33,6 +34,16 @@
images_[aState] = anImage ? *anImage : SkBitmap();
}
+void ImageButton::SetBackground(SkColor color,
+ SkBitmap* image,
+ SkBitmap* mask) {
+ if (!color && !image)
+ background_image_ = NULL;
+
+ background_image_ = new SkBitmap(
+ skia::ImageOperations::CreateButtonBackground(color, *image, *mask));
+}
+
void ImageButton::SetImageAlignment(HorizontalAlignment h_align,
VerticalAlignment v_align) {
h_alignment_ = h_align;
@@ -68,6 +79,8 @@
else if (v_alignment_ == ALIGN_BOTTOM)
y = height() - img.height();
+ if (background_image_)
+ canvas->DrawBitmapInt(*background_image_, x, y);
canvas->DrawBitmapInt(img, x, y);
}
PaintFocusBorder(canvas);
« chrome/common/extensions/extension.cc ('K') | « views/controls/button/image_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698