tahoma2d/toonz/sources/include/tw/scrollview.h

70 lines
1.6 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TNZ_SCROLLVIEW_INCLUDED
#define TNZ_SCROLLVIEW_INCLUDED
#include "tw/tw.h"
#undef DVAPI
#undef DVVAR
#ifdef TWIN_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
class TScrollbar;
2016-06-15 18:43:10 +12:00
class DVAPI TScrollView : public TWidget {
TPoint m_delta;
TScrollbar *m_vsb, *m_hsb;
TDimension m_contentSize;
bool m_autopanning;
TPoint m_autopanningPos;
int m_autopanningOldT;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TScrollView(TWidget *parent, std::string name = "scrollview");
~TScrollView();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void middleButtonDown(const TMouseEvent &e);
void middleButtonDrag(const TMouseEvent &e);
void middleButtonUp(const TMouseEvent &e);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void configureNotify(const TDimension &d);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void doScrollTo(const TPoint &p);
inline void doScrollTo(int x, int y) { doScrollTo(TPoint(x, y)); }
inline void doScrollTo_x(int x) { doScrollTo(TPoint(x, m_yoff)); }
inline void doScrollTo_y(int y) { doScrollTo(TPoint(m_xoff, y)); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void scrollTo(const TPoint &p) { doScrollTo(p); }
inline void scrollTo(int x, int y) { scrollTo(TPoint(x, y)); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
inline TPoint getScrollPosition() const { return TPoint(m_xoff, m_yoff); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setScrollbars(TScrollbar *hsb, TScrollbar *vsb);
void setContentSize(const TDimension &d);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TDimension getContentSize() const { return m_contentSize; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void onVsbChange(int value);
void onHsbChange(int value);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void onTimer(int t);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void startAutopanning();
void stopAutopanning();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool isAutopanning() const { return m_autopanning; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void autopanningDrag(const TPoint &pos){};
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// provvisorio
void updateScrollbars();
2016-03-19 06:57:51 +13:00
};
#endif