OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/scrollbar/bitmap_scroll_bar.h" | 5 #include "ui/views/controls/scrollbar/bitmap_scroll_bar.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 public: | 50 public: |
51 explicit AutorepeatButton(ButtonListener* listener) | 51 explicit AutorepeatButton(ButtonListener* listener) |
52 : ImageButton(listener), | 52 : ImageButton(listener), |
53 ALLOW_THIS_IN_INITIALIZER_LIST(repeater_( | 53 ALLOW_THIS_IN_INITIALIZER_LIST(repeater_( |
54 base::Bind(&AutorepeatButton::NotifyClick, | 54 base::Bind(&AutorepeatButton::NotifyClick, |
55 base::Unretained(this)))) { | 55 base::Unretained(this)))) { |
56 } | 56 } |
57 virtual ~AutorepeatButton() {} | 57 virtual ~AutorepeatButton() {} |
58 | 58 |
59 protected: | 59 protected: |
60 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE { | 60 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { |
61 Button::NotifyClick(event); | 61 Button::NotifyClick(event); |
62 repeater_.Start(); | 62 repeater_.Start(); |
63 return true; | 63 return true; |
64 } | 64 } |
65 | 65 |
66 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE { | 66 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { |
67 OnMouseCaptureLost(); | 67 OnMouseCaptureLost(); |
68 } | 68 } |
69 | 69 |
70 virtual void OnMouseCaptureLost() OVERRIDE { | 70 virtual void OnMouseCaptureLost() OVERRIDE { |
71 repeater_.Stop(); | 71 repeater_.Stop(); |
72 } | 72 } |
73 | 73 |
74 private: | 74 private: |
75 void NotifyClick() { | 75 void NotifyClick() { |
76 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
77 gfx::Point cursor_point(GetMessagePos()); | 77 gfx::Point cursor_point(GetMessagePos()); |
78 #elif defined(OS_LINUX) | 78 #elif defined(OS_LINUX) |
79 gfx::Point cursor_point = gfx::Screen::GetCursorScreenPoint(); | 79 gfx::Point cursor_point = gfx::Screen::GetCursorScreenPoint(); |
80 #endif | 80 #endif |
81 views::MouseEvent event(ui::ET_MOUSE_RELEASED, | 81 ui::MouseEvent event(ui::ET_MOUSE_RELEASED, |
82 cursor_point.x(), cursor_point.y(), | 82 cursor_point, cursor_point, |
83 ui::EF_LEFT_MOUSE_BUTTON); | 83 ui::EF_LEFT_MOUSE_BUTTON); |
84 Button::NotifyClick(event); | 84 Button::NotifyClick(event); |
85 } | 85 } |
86 | 86 |
87 // The repeat controller that we use to repeatedly click the button when the | 87 // The repeat controller that we use to repeatedly click the button when the |
88 // mouse button is down. | 88 // mouse button is down. |
89 RepeatController repeater_; | 89 RepeatController repeater_; |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(AutorepeatButton); | 91 DISALLOW_COPY_AND_ASSIGN(AutorepeatButton); |
92 }; | 92 }; |
93 | 93 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 301 |
302 void BitmapScrollBar::ButtonPressed(Button* sender, const ui::Event& event) { | 302 void BitmapScrollBar::ButtonPressed(Button* sender, const ui::Event& event) { |
303 if (sender == prev_button_) { | 303 if (sender == prev_button_) { |
304 ScrollByAmount(SCROLL_PREV_LINE); | 304 ScrollByAmount(SCROLL_PREV_LINE); |
305 } else if (sender == next_button_) { | 305 } else if (sender == next_button_) { |
306 ScrollByAmount(SCROLL_NEXT_LINE); | 306 ScrollByAmount(SCROLL_NEXT_LINE); |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 } // namespace views | 310 } // namespace views |
OLD | NEW |