Index: views/controls/scrollbar/bitmap_scroll_bar.cc |
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc |
index beef8c4552f3fe4c71df2b9aafe1432352a46643..17e549ca972183459f195001bc8caef921ec2aff 100644 |
--- a/views/controls/scrollbar/bitmap_scroll_bar.cc |
+++ b/views/controls/scrollbar/bitmap_scroll_bar.cc |
@@ -53,16 +53,20 @@ class AutorepeatButton : public ImageButton { |
} |
virtual ~AutorepeatButton() {} |
- protected: |
- virtual bool OnMousePressed(const MouseEvent& event) { |
+ virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE { |
Button::NotifyClick(event); |
repeater_.Start(); |
return true; |
} |
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) { |
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE { |
+ repeater_.Stop(); |
+ View::OnMouseReleased(event); |
+ } |
+ |
+ virtual void OnMouseCaptureLost() OVERRIDE { |
repeater_.Stop(); |
- View::OnMouseReleased(event, canceled); |
+ View::OnMouseCaptureLost(); |
} |
private: |
@@ -149,47 +153,29 @@ class BitmapScrollBarThumb : public View { |
} |
// View overrides: |
- virtual gfx::Size GetPreferredSize() { |
+ virtual gfx::Size GetPreferredSize() OVERRIDE { |
return gfx::Size(background_bitmap()->width(), |
start_cap_bitmap()->height() + |
end_cap_bitmap()->height() + |
grippy_bitmap()->height()); |
} |
- protected: |
- // View overrides: |
- virtual void Paint(gfx::Canvas* canvas) { |
- canvas->DrawBitmapInt(*start_cap_bitmap(), 0, 0); |
- int top_cap_height = start_cap_bitmap()->height(); |
- int bottom_cap_height = end_cap_bitmap()->height(); |
- int thumb_body_height = height() - top_cap_height - bottom_cap_height; |
- canvas->TileImageInt(*background_bitmap(), 0, top_cap_height, |
- background_bitmap()->width(), thumb_body_height); |
- canvas->DrawBitmapInt(*end_cap_bitmap(), 0, |
- height() - bottom_cap_height); |
- |
- // Paint the grippy over the track. |
- int grippy_x = (width() - grippy_bitmap()->width()) / 2; |
- int grippy_y = (thumb_body_height - grippy_bitmap()->height()) / 2; |
- canvas->DrawBitmapInt(*grippy_bitmap(), grippy_x, grippy_y); |
- } |
- |
- virtual void OnMouseEntered(const MouseEvent& event) { |
+ virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE { |
SetState(CustomButton::BS_HOT); |
} |
- virtual void OnMouseExited(const MouseEvent& event) { |
+ virtual void OnMouseExited(const MouseEvent& event) OVERRIDE { |
SetState(CustomButton::BS_NORMAL); |
} |
- virtual bool OnMousePressed(const MouseEvent& event) { |
+ virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE { |
mouse_offset_ = scroll_bar_->IsHorizontal() ? event.x() : event.y(); |
drag_start_position_ = GetPosition(); |
SetState(CustomButton::BS_PUSHED); |
return true; |
} |
- virtual bool OnMouseDragged(const MouseEvent& event) { |
+ virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE { |
// If the user moves the mouse more than |kScrollThumbDragOutSnap| outside |
// the bounds of the thumb, the scrollbar will snap the scroll back to the |
// point it was at before the drag began. |
@@ -216,10 +202,32 @@ class BitmapScrollBarThumb : public View { |
return true; |
} |
- virtual void OnMouseReleased(const MouseEvent& event, |
- bool canceled) { |
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE { |
SetState(CustomButton::BS_HOT); |
- View::OnMouseReleased(event, canceled); |
+ View::OnMouseReleased(event); |
+ } |
+ |
+ virtual void OnMouseCaptureLost() OVERRIDE { |
+ SetState(CustomButton::BS_HOT); |
+ View::OnMouseCaptureLost(); |
+ } |
+ |
+ protected: |
+ // View overrides: |
+ virtual void Paint(gfx::Canvas* canvas) OVERRIDE { |
+ canvas->DrawBitmapInt(*start_cap_bitmap(), 0, 0); |
+ int top_cap_height = start_cap_bitmap()->height(); |
+ int bottom_cap_height = end_cap_bitmap()->height(); |
+ int thumb_body_height = height() - top_cap_height - bottom_cap_height; |
+ canvas->TileImageInt(*background_bitmap(), 0, top_cap_height, |
+ background_bitmap()->width(), thumb_body_height); |
+ canvas->DrawBitmapInt(*end_cap_bitmap(), 0, |
+ height() - bottom_cap_height); |
+ |
+ // Paint the grippy over the track. |
+ int grippy_x = (width() - grippy_bitmap()->width()) / 2; |
+ int grippy_y = (thumb_body_height - grippy_bitmap()->height()) / 2; |
+ canvas->DrawBitmapInt(*grippy_bitmap(), grippy_x, grippy_y); |
} |
private: |
@@ -471,10 +479,16 @@ bool BitmapScrollBar::OnMousePressed(const MouseEvent& event) { |
return true; |
} |
-void BitmapScrollBar::OnMouseReleased(const MouseEvent& event, bool canceled) { |
+void BitmapScrollBar::OnMouseReleased(const MouseEvent& event) { |
+ SetThumbTrackState(CustomButton::BS_NORMAL); |
+ repeater_.Stop(); |
+ View::OnMouseReleased(event); |
+} |
+ |
+void BitmapScrollBar::OnMouseCaptureLost() { |
SetThumbTrackState(CustomButton::BS_NORMAL); |
repeater_.Stop(); |
- View::OnMouseReleased(event, canceled); |
+ View::OnMouseCaptureLost(); |
} |
bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) { |