Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 2eb1a42866f08c42831ab32783055ec415618096 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
   entitywidget.h
   This file is part of the Project::OSiRiON world editor 
   and is distributed under the terms and conditions of 
   the GNU General Public License version 2
*/

#ifndef __INCLUDED_EDITOR_ENTITYWIDGET__
#define __INCLUDED_EDITOR_ENTITYWIDGET__

#include "entityproperties.h"

#include <QWidget>
#include <QList>
#include <QString>

namespace editor
{

/**
 * @brief a Widget resembling an entity on the map
 * */
class EntityWidget : public QWidget
{
	Q_OBJECT
	
public:
	EntityWidget(QWidget *parent = 0);
	
	/**
	 * @brief returns the entity propertie
	 * */
	inline EntityProperties *properties() {
		return &entitywidget_entityproperties;
	}
	
	inline const bool selected() const {
		return is_selected;
	}
	
signals:
	/**
	 * @brief this signal is emitted if the entity is clicked with the left mouse button
	 * */
	void clicked(EntityWidget *entity);
	
	/**
	 * @brief this signal is emitted when the entity is first dragged
	 * */
	void dragStart();
	
	/**
	 * @brief this signal is emitted when the entity stops being dragged
	 * */
	void dragStop();
	
	/**
	 * @brief this signal is emitted if the entity is dragged
	 * */
	void dragMove(EntityWidget *entity, int x, int y);
	
public slots:

	/**
	 * @brief set the selected state
	 * */
	void set_selected(const bool selected);

protected:
	/**
	 * @brief handle draw events
	 * */
	virtual void paintEvent(QPaintEvent *event);
	
	/**
	 * @brief handle mouse button press events
	 * */
	virtual void mousePressEvent(QMouseEvent *event);

	/**
	 * @brief handle mouse button press events
	 * */
	virtual void mouseReleaseEvent(QMouseEvent *event);

	/**
	 * @brief handle mouse move press events
	 * */
	virtual void mouseMoveEvent(QMouseEvent *event);
	
private:
	EntityProperties	entitywidget_entityproperties;
	
	bool			is_selected;
	bool			is_dragging;
	
};

}

#endif // __INCLUDED_EDITOR_ENTITYWIDGET__