-
Notifications
You must be signed in to change notification settings - Fork 5
/
scroll_bar_view.h
67 lines (54 loc) · 1.71 KB
/
scroll_bar_view.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright...
#ifndef PDFSKETCH_SCROLL_BAR_VIEW_H__
#define PDFSKETCH_SCROLL_BAR_VIEW_H__
#include "view.h"
namespace pdfsketch {
class ScrollBarView;
class ScrollBarDelegate {
public:
virtual void ScrollBarMovedTo(ScrollBarView* scroll_bar, double show_min) = 0;
};
class ScrollBarView : public View {
public:
static const double kThickness;
ScrollBarView(bool vertical)
: vertical_(vertical),
doc_min_(0.0),
doc_max_(0.0),
show_size_(0.0),
show_min_(0.0),
delegate_(NULL),
drag_start_pos_(0.0),
drag_start_show_min_(0.0) {}
virtual std::string Name() const { return "ScrollBarView"; }
virtual void DrawRect(cairo_t* cr, const Rect& rect);
void SetDocSize(double min, double max) {
doc_min_ = min;
doc_max_ = max;
}
void SetShowSize(double size) { show_size_ = size; }
double show_min() { return show_min_; }
void SetShowMin(double min) { show_min_ = min; }
void SetDelegate(ScrollBarDelegate* delegate) {
delegate_ = delegate;
}
virtual View* OnMouseDown(const MouseInputEvent& event);
virtual void OnMouseDrag(const MouseInputEvent& event);
virtual void OnMouseUp(const MouseInputEvent& event);
void ScrollBy(double delta);
void CenterDocValue(double value);
private:
bool vertical_;
// the doc min/max are the size of the document that's being scrolled.
// A subset (show_min_ to show_min_+show_size_) is visible.
// When scrolled, show_min_ is reported to the delegate.
double doc_min_;
double doc_max_;
double show_size_;
double show_min_;
ScrollBarDelegate* delegate_;
double drag_start_pos_;
double drag_start_show_min_;
};
} // namespace pdfsketch
#endif // PDFSKETCH_SCROLL_BAR_VIEW_H__