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

Unified Diff: ash/wm/caption_buttons/frame_caption_button.cc

Issue 148003003: Use white header for app windows part #2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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: 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 2f468f80dbfb29a375943989775b52d1b1a37e48..cce6cc72202e84c5275330fc0aa4c4b7df2dcf66 100644
--- a/ash/wm/caption_buttons/frame_caption_button.cc
+++ b/ash/wm/caption_buttons/frame_caption_button.cc
@@ -28,10 +28,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);
@@ -42,16 +44,18 @@ 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) {
// The early return is dependant on |animate| because callers use SetImages()
// with ANIMATE_NO to progress the crossfade animation to the end.
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;
}
@@ -62,14 +66,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);
@@ -87,7 +95,8 @@ bool FrameCaptionButton::IsAnimatingImageSwap() const {
}
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 {
@@ -153,20 +162,19 @@ void FrameCaptionButton::StateChanged() {
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);
- }
+ 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);
+
+ 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
« no previous file with comments | « ash/wm/caption_buttons/frame_caption_button.h ('k') | ash/wm/caption_buttons/frame_caption_button_container_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698