| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/frame/caption_buttons/frame_caption_button.h" | 5 #include "ash/frame/caption_buttons/frame_caption_button.h" |
| 6 | 6 |
| 7 #include "ui/base/resource/resource_bundle.h" | 7 #include "ui/base/resource/resource_bundle.h" |
| 8 #include "ui/gfx/animation/slide_animation.h" | 8 #include "ui/gfx/animation/slide_animation.h" |
| 9 #include "ui/gfx/animation/throb_animation.h" | 9 #include "ui/gfx/animation/throb_animation.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 PaintCentered(canvas, icon_image, icon_alpha); | 135 PaintCentered(canvas, icon_image, icon_alpha); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 void FrameCaptionButton::OnGestureEvent(ui::GestureEvent* event) { | 139 void FrameCaptionButton::OnGestureEvent(ui::GestureEvent* event) { |
| 140 // CustomButton does not become pressed when the user drags off and then back | 140 // CustomButton does not become pressed when the user drags off and then back |
| 141 // onto the button. Make FrameCaptionButton pressed in this case because this | 141 // onto the button. Make FrameCaptionButton pressed in this case because this |
| 142 // behavior is more consistent with AlternateFrameSizeButton. | 142 // behavior is more consistent with AlternateFrameSizeButton. |
| 143 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 143 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 144 event->type() == ui::ET_GESTURE_SCROLL_UPDATE) { | 144 event->type() == ui::ET_GESTURE_SCROLL_UPDATE) { |
| 145 if (HitTestPoint(event->location())) { | 145 if (HitTestPoint(gfx::ToFlooredPoint(event->location()))) { |
| 146 SetState(STATE_PRESSED); | 146 SetState(STATE_PRESSED); |
| 147 RequestFocus(); | 147 RequestFocus(); |
| 148 event->StopPropagation(); | 148 event->StopPropagation(); |
| 149 } else { | 149 } else { |
| 150 SetState(STATE_NORMAL); | 150 SetState(STATE_NORMAL); |
| 151 } | 151 } |
| 152 } else if (event->type() == ui::ET_GESTURE_SCROLL_END) { | 152 } else if (event->type() == ui::ET_GESTURE_SCROLL_END) { |
| 153 if (HitTestPoint(event->location())) { | 153 if (HitTestPoint(gfx::ToFlooredPoint(event->location()))) { |
| 154 SetState(STATE_HOVERED); | 154 SetState(STATE_HOVERED); |
| 155 NotifyClick(*event); | 155 NotifyClick(*event); |
| 156 event->StopPropagation(); | 156 event->StopPropagation(); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 CustomButton::OnGestureEvent(event); | 159 CustomButton::OnGestureEvent(event); |
| 160 } | 160 } |
| 161 | 161 |
| 162 const gfx::ImageSkia& FrameCaptionButton::GetIconImageToPaint() const { | 162 const gfx::ImageSkia& FrameCaptionButton::GetIconImageToPaint() const { |
| 163 return paint_as_active_ ? icon_image_ : inactive_icon_image_; | 163 return paint_as_active_ ? icon_image_ : inactive_icon_image_; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void FrameCaptionButton::PaintCentered(gfx::Canvas* canvas, | 166 void FrameCaptionButton::PaintCentered(gfx::Canvas* canvas, |
| 167 const gfx::ImageSkia& to_center, | 167 const gfx::ImageSkia& to_center, |
| 168 int alpha) { | 168 int alpha) { |
| 169 SkPaint paint; | 169 SkPaint paint; |
| 170 paint.setAlpha(alpha); | 170 paint.setAlpha(alpha); |
| 171 canvas->DrawImageInt(to_center, | 171 canvas->DrawImageInt(to_center, |
| 172 (width() - to_center.width()) / 2, | 172 (width() - to_center.width()) / 2, |
| 173 (height() - to_center.height()) / 2, | 173 (height() - to_center.height()) / 2, |
| 174 paint); | 174 paint); |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace ash | 177 } // namespace ash |
| OLD | NEW |