summaryrefslogtreecommitdiffstats
path: root/views/controls/scrollbar
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-29 00:39:05 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-29 00:39:05 +0000
commit34338254f776be94d79ca184c4eb2ea5b3f62318 (patch)
treea20d913935cfe06590e6a39808234774e35e3ff8 /views/controls/scrollbar
parent7bd801611073a0e79a011a96ec72cb201656344a (diff)
downloadchromium_src-34338254f776be94d79ca184c4eb2ea5b3f62318.zip
chromium_src-34338254f776be94d79ca184c4eb2ea5b3f62318.tar.gz
chromium_src-34338254f776be94d79ca184c4eb2ea5b3f62318.tar.bz2
Disambiguate OnMouseCaptureLost from OnMouseReleased.
Nix RenderWidgetHostViewViews' OnMouseCaptureLost forwarding. Consolidate code, remove unnecessary overrides, etc. Fix up test, |event| args, OVERRIDEs, and (c) dates. BUG=72040 TEST=Views mouse button release, cancelling mouse down/drag. Review URL: http://codereview.chromium.org/6685069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79640 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/scrollbar')
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.cc36
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.h3
2 files changed, 24 insertions, 15 deletions
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc
index beef8c4..20a1a96 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.cc
+++ b/views/controls/scrollbar/bitmap_scroll_bar.cc
@@ -54,15 +54,18 @@ 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 {
+ OnMouseCaptureLost();
+ }
+
+ virtual void OnMouseCaptureLost() OVERRIDE {
repeater_.Stop();
- View::OnMouseReleased(event, canceled);
}
private:
@@ -149,7 +152,7 @@ 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() +
@@ -158,7 +161,7 @@ class BitmapScrollBarThumb : public View {
protected:
// View overrides:
- virtual void Paint(gfx::Canvas* canvas) {
+ 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();
@@ -174,22 +177,22 @@ class BitmapScrollBarThumb : public View {
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 +219,12 @@ class BitmapScrollBarThumb : public View {
return true;
}
- virtual void OnMouseReleased(const MouseEvent& event,
- bool canceled) {
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE {
+ OnMouseCaptureLost();
+ }
+
+ virtual void OnMouseCaptureLost() OVERRIDE {
SetState(CustomButton::BS_HOT);
- View::OnMouseReleased(event, canceled);
}
private:
@@ -471,10 +476,13 @@ bool BitmapScrollBar::OnMousePressed(const MouseEvent& event) {
return true;
}
-void BitmapScrollBar::OnMouseReleased(const MouseEvent& event, bool canceled) {
+void BitmapScrollBar::OnMouseReleased(const MouseEvent& event) {
+ OnMouseCaptureLost();
+}
+
+void BitmapScrollBar::OnMouseCaptureLost() {
SetThumbTrackState(CustomButton::BS_NORMAL);
repeater_.Stop();
- View::OnMouseReleased(event, canceled);
}
bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) {
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.h b/views/controls/scrollbar/bitmap_scroll_bar.h
index 8357fd1..833a045 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.h
+++ b/views/controls/scrollbar/bitmap_scroll_bar.h
@@ -98,7 +98,8 @@ class BitmapScrollBar : public ScrollBar,
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void Layout() OVERRIDE;
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE;
virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE;