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

Unified Diff: views/controls/scrollbar/base_scroll_bar_button.cc

Issue 7669028: Adding a Views scrollbar implementation. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added missing virtual destructor to unit test Created 9 years, 4 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
« no previous file with comments | « views/controls/scrollbar/base_scroll_bar_button.h ('k') | views/controls/scrollbar/base_scroll_bar_thumb.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/scrollbar/base_scroll_bar_button.cc
diff --git a/views/controls/scrollbar/base_scroll_bar_button.cc b/views/controls/scrollbar/base_scroll_bar_button.cc
new file mode 100644
index 0000000000000000000000000000000000000000..14f086b65cd2f23e256beaf4289d9658a911d035
--- /dev/null
+++ b/views/controls/scrollbar/base_scroll_bar_button.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "views/controls/scrollbar/base_scroll_bar_button.h"
+
+namespace views {
+
+BaseScrollBarButton::BaseScrollBarButton(ButtonListener* listener)
+ : CustomButton(listener),
+ ALLOW_THIS_IN_INITIALIZER_LIST(repeater_(
+ NewCallback<BaseScrollBarButton>(this,
+ &BaseScrollBarButton::RepeaterNotifyClick))) {
+}
+
+BaseScrollBarButton::~BaseScrollBarButton() {
+}
+
+bool BaseScrollBarButton::OnMousePressed(const MouseEvent& event) {
+ Button::NotifyClick(event);
+ repeater_.Start();
+ return true;
+}
+
+void BaseScrollBarButton::OnMouseReleased(const MouseEvent& event) {
+ OnMouseCaptureLost();
+}
+
+void BaseScrollBarButton::OnMouseCaptureLost() {
+ repeater_.Stop();
+}
+
+void BaseScrollBarButton::RepeaterNotifyClick() {
+#if defined(OS_WIN)
+ DWORD pos = GetMessagePos();
+ POINTS points = MAKEPOINTS(pos);
+ gfx::Point cursor_point(points.x, points.y);
+#elif defined(OS_LINUX)
+ gfx::Point cursor_point = gfx::Screen::GetCursorScreenPoint();
+#endif
+ views::MouseEvent event(ui::ET_MOUSE_RELEASED,
+ cursor_point.x(), cursor_point.y(),
+ ui::EF_LEFT_BUTTON_DOWN);
+ Button::NotifyClick(event);
+}
+
+} // namespace views
« no previous file with comments | « views/controls/scrollbar/base_scroll_bar_button.h ('k') | views/controls/scrollbar/base_scroll_bar_thumb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698