summaryrefslogtreecommitdiffstats
path: root/views/controls/scrollbar/base_scroll_bar_button.h
blob: 422ebfa44c86ddc31824436f5fb96918e8c01420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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.

#ifndef VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_BUTTON_H_
#define VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_BUTTON_H_
#pragma once

#include "views/controls/button/custom_button.h"

#include "views/repeat_controller.h"

#if defined(OS_LINUX)
#include "ui/gfx/screen.h"
#endif

namespace views {

///////////////////////////////////////////////////////////////////////////////
//
// ScrollBarButton
//
//  A button that activates on mouse pressed rather than released, and that
//  continues to fire the clicked action as the mouse button remains pressed
//  down on the button.
//
///////////////////////////////////////////////////////////////////////////////
class VIEWS_EXPORT BaseScrollBarButton : public CustomButton {
 public:
  explicit BaseScrollBarButton(ButtonListener* listener);
  virtual ~BaseScrollBarButton();

 protected:
  virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
  virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
  virtual void OnMouseCaptureLost() OVERRIDE;

 private:
  void NotifyClick();

  // The repeat controller that we use to repeatedly click the button when the
  // mouse button is down.
  RepeatController repeater_;

  DISALLOW_COPY_AND_ASSIGN(BaseScrollBarButton);
};

}  // namespace views

#endif  // VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_BUTTON_H_