| Index: ash/wm/caption_buttons/frame_caption_button.cc
|
| diff --git a/ash/wm/caption_buttons/frame_caption_button.cc b/ash/wm/caption_buttons/frame_caption_button.cc
|
| index 68174978af181a1759e37975fbb22e2eb777d4a7..3309c03ff62aed935e8c3aff31b19b89f371b05d 100644
|
| --- a/ash/wm/caption_buttons/frame_caption_button.cc
|
| +++ b/ash/wm/caption_buttons/frame_caption_button.cc
|
| @@ -27,10 +27,12 @@ FrameCaptionButton::FrameCaptionButton(views::ButtonListener* listener,
|
| CaptionButtonIcon icon)
|
| : CustomButton(listener),
|
| icon_(icon),
|
| + paint_as_active_(false),
|
| last_paint_scale_(1.0f),
|
| - normal_image_id_(-1),
|
| - hovered_image_id_(-1),
|
| - pressed_image_id_(-1),
|
| + icon_image_id_(-1),
|
| + inactive_icon_image_id_(-1),
|
| + hovered_background_image_id_(-1),
|
| + pressed_background_image_id_(-1),
|
| swap_images_animation_(new gfx::SlideAnimation(this)) {
|
| swap_images_animation_->Reset(1);
|
| EnableCanvasFlippingForRTLUI(true);
|
| @@ -41,14 +43,16 @@ FrameCaptionButton::~FrameCaptionButton() {
|
|
|
| void FrameCaptionButton::SetImages(CaptionButtonIcon icon,
|
| Animate animate,
|
| - int normal_image_id,
|
| - int hovered_image_id,
|
| - int pressed_image_id) {
|
| + int icon_image_id,
|
| + int inactive_icon_image_id,
|
| + int hovered_background_image_id,
|
| + int pressed_background_image_id) {
|
| if (icon == icon_ &&
|
| (animate == ANIMATE_YES || !swap_images_animation_->is_animating()) &&
|
| - normal_image_id == normal_image_id_ &&
|
| - hovered_image_id == hovered_image_id_ &&
|
| - pressed_image_id == pressed_image_id_) {
|
| + icon_image_id == icon_image_id_ &&
|
| + inactive_icon_image_id == inactive_icon_image_id_ &&
|
| + hovered_background_image_id == hovered_background_image_id_ &&
|
| + pressed_background_image_id == pressed_background_image_id_) {
|
| return;
|
| }
|
|
|
| @@ -59,14 +63,18 @@ void FrameCaptionButton::SetImages(CaptionButtonIcon icon,
|
| }
|
|
|
| icon_ = icon;
|
| - normal_image_id_ = normal_image_id;
|
| - hovered_image_id_ = hovered_image_id;
|
| - pressed_image_id_ = pressed_image_id;
|
| + icon_image_id_ = icon_image_id;
|
| + inactive_icon_image_id_ = inactive_icon_image_id;
|
| + hovered_background_image_id_ = hovered_background_image_id;
|
| + pressed_background_image_id_ = pressed_background_image_id;
|
|
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| - normal_image_ = *rb.GetImageSkiaNamed(normal_image_id);
|
| - hovered_image_ = *rb.GetImageSkiaNamed(hovered_image_id);
|
| - pressed_image_ = *rb.GetImageSkiaNamed(pressed_image_id);
|
| + icon_image_ = *rb.GetImageSkiaNamed(icon_image_id);
|
| + inactive_icon_image_ = *rb.GetImageSkiaNamed(inactive_icon_image_id);
|
| + hovered_background_image_ = *rb.GetImageSkiaNamed(
|
| + hovered_background_image_id);
|
| + pressed_background_image_ = *rb.GetImageSkiaNamed(
|
| + pressed_background_image_id);
|
|
|
| if (animate == ANIMATE_YES) {
|
| swap_images_animation_->Reset(0);
|
| @@ -80,7 +88,8 @@ void FrameCaptionButton::SetImages(CaptionButtonIcon icon,
|
| }
|
|
|
| gfx::Size FrameCaptionButton::GetPreferredSize() {
|
| - return normal_image_.isNull() ? gfx::Size() : normal_image_.size();
|
| + return hovered_background_image_.isNull() ?
|
| + gfx::Size() : hovered_background_image_.size();
|
| }
|
|
|
| const char* FrameCaptionButton::GetClassName() const {
|
| @@ -143,23 +152,23 @@ void FrameCaptionButton::StateChanged() {
|
| swap_images_animation_->Reset(1);
|
| }
|
|
|
| -void FrameCaptionButton::PaintWithAnimationEndState(
|
| - gfx::Canvas* canvas,
|
| - int opacity) {
|
| - gfx::ImageSkia img;
|
| - if (state() == STATE_HOVERED) {
|
| - img = hovered_image_;
|
| - } else if (state() == STATE_PRESSED) {
|
| - img = pressed_image_;
|
| - } else {
|
| - img = normal_image_;
|
| - }
|
| -
|
| - if (!img.isNull()) {
|
| - SkPaint paint;
|
| - paint.setAlpha(opacity);
|
| - canvas->DrawImageInt(img, 0, 0, paint);
|
| - }
|
| +void FrameCaptionButton::PaintWithAnimationEndState(gfx::Canvas* canvas,
|
| + int opacity) {
|
| + SkPaint paint;
|
| + paint.setAlpha(opacity);
|
| +
|
| + if (state() == STATE_HOVERED)
|
| + canvas->DrawImageInt(hovered_background_image_, 0, 0, paint);
|
| + else if (state() == STATE_PRESSED)
|
| + canvas->DrawImageInt(pressed_background_image_, 0, 0, paint);
|
| +
|
| + paint.setAlpha(opacity);
|
| + gfx::ImageSkia icon_image = paint_as_active_ ?
|
| + icon_image_ : inactive_icon_image_;
|
| + canvas->DrawImageInt(icon_image,
|
| + (width() - icon_image.width()) / 2,
|
| + (height() - icon_image.height()) / 2,
|
| + paint);
|
| }
|
|
|
| } // namespace ash
|
|
|