leocad/common/lc_glwidget.h

84 lines
1.6 KiB
C
Raw Normal View History

#pragma once
2013-08-09 06:57:18 +02:00
2020-11-14 21:47:55 +01:00
enum class lcDragState
{
None,
Piece,
Color
};
2020-02-15 20:36:06 +01:00
enum class lcCursor
2013-08-09 06:57:18 +02:00
{
2020-02-15 20:36:06 +01:00
Default,
Brick,
Light,
Spotlight,
Camera,
Select,
SelectAdd,
SelectRemove,
Move,
Rotate,
RotateX,
RotateY,
Delete,
Paint,
ColorPicker,
Zoom,
ZoomRegion,
Pan,
Roll,
RotateView,
Count
2013-08-09 06:57:18 +02:00
};
struct lcInputState
{
2020-12-04 20:40:53 +01:00
int x = 0;
int y = 0;
Qt::KeyboardModifiers Modifiers = Qt::NoModifier;
2013-08-09 06:57:18 +02:00
};
class lcGLWidget
{
public:
2020-12-04 20:40:53 +01:00
lcGLWidget();
virtual ~lcGLWidget();
2013-08-09 06:57:18 +02:00
2020-12-04 20:40:53 +01:00
lcGLWidget(const lcGLWidget&) = delete;
lcGLWidget& operator=(const lcGLWidget&) = delete;
2014-04-20 21:09:46 +02:00
2020-12-04 20:40:53 +01:00
void SetContext(lcContext* Context);
2013-08-09 06:57:18 +02:00
void MakeCurrent();
void Redraw();
2020-02-15 20:36:06 +01:00
void SetCursor(lcCursor Cursor);
2020-11-26 21:07:41 +01:00
void DrawBackground() const;
2013-08-09 06:57:18 +02:00
virtual void OnDraw() { }
virtual void OnInitialUpdate() { }
virtual void OnUpdateCursor() { }
virtual void OnLeftButtonDown() { }
virtual void OnLeftButtonUp() { }
virtual void OnLeftButtonDoubleClick() { }
virtual void OnMiddleButtonDown() { }
virtual void OnMiddleButtonUp() { }
virtual void OnRightButtonDown() { }
virtual void OnRightButtonUp() { }
virtual void OnBackButtonDown() { }
virtual void OnBackButtonUp() { }
virtual void OnForwardButtonDown() { }
virtual void OnForwardButtonUp() { }
2013-08-09 06:57:18 +02:00
virtual void OnMouseMove() { }
2016-02-17 00:11:52 +01:00
virtual void OnMouseWheel(float Direction) { Q_UNUSED(Direction); }
2020-12-04 20:40:53 +01:00
virtual void BeginDrag(lcDragState DragState) { Q_UNUSED(DragState); }
virtual void EndDrag(bool Accept) { Q_UNUSED(Accept); }
2013-08-09 06:57:18 +02:00
lcInputState mInputState;
2020-12-04 20:40:53 +01:00
int mWidth = 1;
int mHeight = 1;
lcCursor mCursor = lcCursor::Default;
QGLWidget* mWidget = nullptr;
lcContext* mContext = nullptr;
bool mDeleteContext = true;
2013-08-09 06:57:18 +02:00
};