mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Widget cleanup.
This commit is contained in:
parent
9e12b480ce
commit
194e02c74c
2 changed files with 37 additions and 40 deletions
|
@ -1,6 +1,27 @@
|
|||
#include "lc_global.h"
|
||||
#include "lc_glwidget.h"
|
||||
#include "lc_application.h"
|
||||
#include "lc_context.h"
|
||||
|
||||
lcGLWidget::lcGLWidget()
|
||||
{
|
||||
mContext = new lcContext();
|
||||
}
|
||||
|
||||
lcGLWidget::~lcGLWidget()
|
||||
{
|
||||
if (mDeleteContext)
|
||||
delete mContext;
|
||||
}
|
||||
|
||||
void lcGLWidget::SetContext(lcContext* Context)
|
||||
{
|
||||
if (mDeleteContext)
|
||||
delete mContext;
|
||||
|
||||
mContext = Context;
|
||||
mDeleteContext = false;
|
||||
}
|
||||
|
||||
void lcGLWidget::MakeCurrent()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "lc_context.h"
|
||||
|
||||
enum class lcDragState
|
||||
{
|
||||
None,
|
||||
|
@ -36,42 +34,21 @@ enum class lcCursor
|
|||
|
||||
struct lcInputState
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
Qt::KeyboardModifiers Modifiers;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
Qt::KeyboardModifiers Modifiers = Qt::NoModifier;
|
||||
};
|
||||
|
||||
class lcGLWidget
|
||||
{
|
||||
public:
|
||||
lcGLWidget()
|
||||
{
|
||||
mCursor = lcCursor::Default;
|
||||
mWidget = nullptr;
|
||||
mInputState.x = 0;
|
||||
mInputState.y = 0;
|
||||
mInputState.Modifiers = Qt::NoModifier;
|
||||
mWidth = 1;
|
||||
mHeight = 1;
|
||||
mContext = new lcContext();
|
||||
mDeleteContext = true;
|
||||
}
|
||||
lcGLWidget();
|
||||
virtual ~lcGLWidget();
|
||||
|
||||
virtual ~lcGLWidget()
|
||||
{
|
||||
if (mDeleteContext)
|
||||
delete mContext;
|
||||
}
|
||||
|
||||
void SetContext(lcContext* Context)
|
||||
{
|
||||
if (mDeleteContext)
|
||||
delete mContext;
|
||||
|
||||
mContext = Context;
|
||||
mDeleteContext = false;
|
||||
}
|
||||
lcGLWidget(const lcGLWidget&) = delete;
|
||||
lcGLWidget& operator=(const lcGLWidget&) = delete;
|
||||
|
||||
void SetContext(lcContext* Context);
|
||||
void MakeCurrent();
|
||||
void Redraw();
|
||||
void SetCursor(lcCursor Cursor);
|
||||
|
@ -93,15 +70,14 @@ public:
|
|||
virtual void OnForwardButtonUp() { }
|
||||
virtual void OnMouseMove() { }
|
||||
virtual void OnMouseWheel(float Direction) { Q_UNUSED(Direction); }
|
||||
virtual void BeginDrag(lcDragState DragState) { Q_UNUSED(DragState); };
|
||||
virtual void EndDrag(bool Accept) { Q_UNUSED(Accept); };
|
||||
|
||||
virtual void BeginDrag(lcDragState DragState) { Q_UNUSED(DragState); }
|
||||
virtual void EndDrag(bool Accept) { Q_UNUSED(Accept); }
|
||||
|
||||
lcInputState mInputState;
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
lcCursor mCursor;
|
||||
QGLWidget* mWidget;
|
||||
lcContext* mContext;
|
||||
bool mDeleteContext;
|
||||
int mWidth = 1;
|
||||
int mHeight = 1;
|
||||
lcCursor mCursor = lcCursor::Default;
|
||||
QGLWidget* mWidget = nullptr;
|
||||
lcContext* mContext = nullptr;
|
||||
bool mDeleteContext = true;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue