leocad/common/lc_glwidget.h

97 lines
1.6 KiB
C
Raw Normal View History

#pragma once
2013-08-09 04:57:18 +00:00
2014-04-20 01:50:41 +00:00
#include "lc_context.h"
2020-02-15 11:36:06 -08:00
enum class lcCursor
2013-08-09 04:57:18 +00:00
{
2020-02-15 11:36:06 -08: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 04:57:18 +00:00
};
struct lcInputState
{
int x;
int y;
2016-04-23 00:17:33 +00:00
Qt::KeyboardModifiers Modifiers;
2013-08-09 04:57:18 +00:00
};
class lcGLWidget
{
public:
lcGLWidget()
{
2020-02-15 11:36:06 -08:00
mCursor = lcCursor::Default;
mWidget = nullptr;
2013-08-09 04:57:18 +00:00
mInputState.x = 0;
mInputState.y = 0;
2016-04-23 00:17:33 +00:00
mInputState.Modifiers = Qt::NoModifier;
mWidth = 1;
mHeight = 1;
2014-04-20 01:50:41 +00:00
mContext = new lcContext();
2014-04-20 19:09:46 +00:00
mDeleteContext = true;
2013-08-09 04:57:18 +00:00
}
virtual ~lcGLWidget()
{
2014-04-20 19:09:46 +00:00
if (mDeleteContext)
delete mContext;
2013-08-09 04:57:18 +00:00
}
2014-04-20 19:09:46 +00:00
void SetContext(lcContext* Context)
{
if (mDeleteContext)
delete mContext;
mContext = Context;
mDeleteContext = false;
}
2013-08-09 04:57:18 +00:00
void MakeCurrent();
void Redraw();
2020-02-15 11:36:06 -08:00
void SetCursor(lcCursor Cursor);
2013-08-09 04:57:18 +00: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 04:57:18 +00:00
virtual void OnMouseMove() { }
2016-02-16 23:11:52 +00:00
virtual void OnMouseWheel(float Direction) { Q_UNUSED(Direction); }
2013-08-09 04:57:18 +00:00
lcInputState mInputState;
int mWidth;
int mHeight;
2020-02-15 11:36:06 -08:00
lcCursor mCursor;
2013-08-09 04:57:18 +00:00
void* mWidget;
2014-04-14 03:20:16 +00:00
lcContext* mContext;
2014-04-20 19:09:46 +00:00
bool mDeleteContext;
2013-08-09 04:57:18 +00:00
};