forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scroll_bar.h
63 lines (47 loc) · 1.52 KB
/
scroll_bar.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
// Aseprite UI Library
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef UI_SCROLL_BAR_H_INCLUDED
#define UI_SCROLL_BAR_H_INCLUDED
#pragma once
#include "ui/widget.h"
namespace ui {
class ScrollableViewDelegate {
public:
virtual ~ScrollableViewDelegate() { }
virtual gfx::Size visibleSize() const = 0;
virtual gfx::Point viewScroll() const = 0;
virtual void setViewScroll(const gfx::Point& pt) = 0;
};
class ScrollBar : public Widget {
public:
ScrollBar(int align, ScrollableViewDelegate* delegate);
Style* thumbStyle() { return m_thumbStyle; }
void setThumbStyle(Style* style) { m_thumbStyle = style; }
int getBarWidth() const { return m_barWidth; }
void setBarWidth(int barWidth) { m_barWidth = barWidth; }
int getPos() const { return m_pos; }
void setPos(int pos);
int size() const { return m_size; }
void setSize(int size);
// For themes
void getScrollBarThemeInfo(int* pos, int* len);
protected:
// Events
bool onProcessMessage(Message* msg) override;
void onInitTheme(InitThemeEvent& ev) override;
void onPaint(PaintEvent& ev) override;
private:
void getScrollBarInfo(int* _pos, int* _len, int* _bar_size, int* _viewport_size);
ScrollableViewDelegate* m_delegate;
Style* m_thumbStyle;
int m_barWidth;
int m_pos;
int m_size;
static int m_wherepos;
static int m_whereclick;
};
} // namespace ui
#endif