1// Aseprite UI Library
2// Copyright (C) 2001-2017 David Capello
3//
4// This file is released under the terms of the MIT license.
5// Read LICENSE.txt for more information.
6
7#ifndef UI_SCROLL_BAR_H_INCLUDED
8#define UI_SCROLL_BAR_H_INCLUDED
9#pragma once
10
11#include "ui/widget.h"
12
13namespace ui {
14
15 class ScrollableViewDelegate {
16 public:
17 virtual ~ScrollableViewDelegate() { }
18 virtual gfx::Size visibleSize() const = 0;
19 virtual gfx::Point viewScroll() const = 0;
20 virtual void setViewScroll(const gfx::Point& pt) = 0;
21 };
22
23 class ScrollBar : public Widget {
24 public:
25 ScrollBar(int align, ScrollableViewDelegate* delegate);
26
27 Style* thumbStyle() { return m_thumbStyle; }
28 void setThumbStyle(Style* style) { m_thumbStyle = style; }
29
30 int getBarWidth() const { return m_barWidth; }
31 void setBarWidth(int barWidth) { m_barWidth = barWidth; }
32
33 int getPos() const { return m_pos; }
34 void setPos(int pos);
35
36 int size() const { return m_size; }
37 void setSize(int size);
38
39 // For themes
40 void getScrollBarThemeInfo(int* pos, int* len);
41
42 protected:
43 // Events
44 bool onProcessMessage(Message* msg) override;
45 void onInitTheme(InitThemeEvent& ev) override;
46 void onPaint(PaintEvent& ev) override;
47
48 private:
49 void getScrollBarInfo(int* _pos, int* _len, int* _bar_size, int* _viewport_size);
50
51 ScrollableViewDelegate* m_delegate;
52 Style* m_thumbStyle;
53 int m_barWidth;
54 int m_pos;
55 int m_size;
56
57 static int m_wherepos;
58 static int m_whereclick;
59 };
60
61} // namespace ui
62
63#endif
64