aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/src-glwidgets/glw-widget.h
blob: 69d3515d9457365660b9c2514c9ed29af65bf669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//===========================================
//  Lumina-desktop source code
//  Copyright (c) 2017, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
#ifndef _LUMINA_OPENGL_WIDGETS_WIDGET_H
#define _LUMINA_OPENGL_WIDGETS_WIDGET_H

#include <QWidget>
#include <QPaintEvent>
#include <QStylePainter>
#include <QResizeEvent>
#include <QStylePainter>

#include "glw-base.h"

class GLW_Widget : public QWidget{
	Q_OBJECT
private:
	GLW_Base *glw_base;
	QPoint drag_offset;
	bool draggable;

public:
	GLW_Widget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
	~GLW_Widget();

	QRect widgetRect(); //converts to the coordinate scheme of the base widget
	bool mouseOverWidget();

	void setGLBase(GLW_Base *base);

	virtual void paintYourself(QStylePainter *painter, const QRect *prect);
	void paintChildren(QStylePainter *painter, const QRect *prect);

	//Properties
	bool isDraggable(){ return draggable; }

private slots:

public slots:
	void setDraggable(bool drag){ draggable = drag; }


protected:
	virtual void enterEvent(QEvent*);
	virtual void leaveEvent(QEvent*);

	virtual void mousePressEvent(QMouseEvent *ev);
	virtual void mouseReleaseEvent(QMouseEvent *ev);
	virtual void mouseMoveEvent(QMouseEvent *ev);
	virtual void moveEvent(QMoveEvent *ev);
	virtual void resizeEvent(QResizeEvent *ev);
	virtual void paintEvent(QPaintEvent *ev);

signals:
	void repaintArea(QRect);
	void doneDragging();
};

Q_DECLARE_INTERFACE(GLW_Widget, "GLW_Widget");
#endif
bgstack15