-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreimplemen.h
166 lines (142 loc) · 3.72 KB
/
reimplemen.h
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//-----本文件所声明用于引擎的其它类型-----
#pragma once
#include "basics.h"
#include "gesture.h"
#include "configure.h"
class Widget;
class SC;
const Pos defaultPos(0,0);
class JSParStru
{
public:
void add(QObject *pointer,QString name);
QVector<QObject*>pointerVec;
QVector<QString>nameVec;
bool operator !=(const JSParStru &par);
};
const JSParStru _NULLJSParStru;
class VideoPlayer : public QWidget //视频类
{
Q_OBJECT
public:
VideoPlayer(String Path,int Volume, int x, int y,int width,int heigh,bool cycle,String signfun,ParametersStru par,GraphicsScene *scene);
~VideoPlayer();
void start();
QMediaPlayer *mediaPlayer;
private:
QGraphicsVideoItem *videoItem;
bool cycle;
String Path;
String signfun;
ParametersStru par;
private slots:
void playFinished(QMediaPlayer::State state);
};
class MusicPlayer : public QMediaPlayer//音乐类
{
Q_OBJECT
public:
void singleplay(String name,int volume);
void multipleplay(String name,int volume);
QMediaPlaylist *cyclelist=nullptr;
String slotfun;
ParametersStru par;
~MusicPlayer();
private slots:
void playFinished(QMediaPlayer::State state);
};
class PixmapItem : public QGraphicsPixmapItem //图像图元类
{
public:
PixmapItem(const QPixmap &pixmap,Widget *s=nullptr, QGraphicsItem *parent=nullptr)
:QGraphicsPixmapItem::QGraphicsPixmapItem(pixmap,parent),s(s){}
void SetButton(Pixmap up, Pixmap down, String Music, int volume);
void SetEvent(String PressFun, ParametersStru PressPar, String ReleaseFun, ParametersStru ReleasePar);
protected:
Widget *s;
//Button
bool isbutton=false;
Pixmap up;
Pixmap down;
String Music;
int volume;
//slotfun
String PressFun;
ParametersStru PressPar;
String ReleaseFun;
ParametersStru ReleasePar;
//Event
void mousePressEvent(QGraphicsSceneMouseEvent *e);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e);
//允许在此添加更多类型的事件,或许你需要添加一些公有成员变量来记录其所对应的槽函数
bool IsRegion();
};
class GraphicsView : public QGraphicsView//视图类
{
public:
GraphicsView(QWidget *parent,Widget *s,int x,int y,int width,int height);
void Scale(int sX, int sY);
void Rotate(float set);
void SetCenter(int x,int y);
void SetCenter(QGraphicsItem *item);
int viewX;
int viewY;
protected:
Widget *s;
void wheelEvent(QWheelEvent *e)
{
e->ignore();
//不对滚轮事件做任何处理,防止滚动view(如果忽略还会向下层机制传递消息)
}
void keyPressEvent(QKeyEvent *e)
{
switch(e->key())
{
//防止未定义按键滚动view
case Qt::Key_Left:{}
case Qt::Key_Right:{}
case Qt::Key_Down:{}
case Qt::Key_Up:{}
default:
{e->ignore();}
}
}
//void mouseReleaseEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
};
class Item //通用图元类
{
public:
Item(PixmapItem* pixmapitem=nullptr,QGraphicsItem *graphicsitem=nullptr);
~Item();
QGraphicsItem *ItemPointer;
PixmapItem *PixmapItemPoniter;
QGraphicsBlurEffect *Blur=nullptr;
QGraphicsColorizeEffect *Color=nullptr;
float ShearX=0;
float ShearY=0;
float FreeScaleX=1;
float FreeScaleY=1;
SC* scPointer[9];
};
struct InputEvent
{
Qt::Key key;
int mouseX;
int mouseY;
int fmouseX;
int fmouseY;
ParametersStru PressPar;
String PressFun;
ParametersStru ReleasePar;
String ReleaseFun;
};
#ifdef AutoIsColliding
struct Collision
{
Item *item1;
Item *item2;
String slot;
ParametersStru par;
};
#endif