Fri, 02 Aug 2013 16:33:30 +0300
style cleanup - it should be all unified now
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
4 | * |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
9 | * |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
14 | * |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
351 | 19 | #ifndef MESSAGELOG_H |
20 | #define MESSAGELOG_H | |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QObject> |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QDate> |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "common.h" |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "types.h" |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | class GLRenderer; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | class QTimer; |
405 | 29 | |
30 | /* The message manager is an object which keeps track of messages that appear | |
31 | * on the renderer's screen. Each line is contained in a separate object which | |
32 | * contains the text, expiry time and alpha. The message manager is doubly | |
33 | * linked to its corresponding renderer. | |
34 | * | |
35 | * Message manager calls its tick() function regularly to update the messages, | |
36 | * where each line's expiry is checked for. Lines begin to fade out when nearing | |
37 | * their expiry. If the message manager's lines change, the renderer undergoes | |
38 | * repainting. | |
39 | */ | |
40 | class MessageManager : public QObject { | |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | Q_OBJECT |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
42 | PROPERTY (GLRenderer*, renderer, setRenderer) |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | public: |
405 | 45 | // Single line of the message log. |
46 | class Line { | |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | public: |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
48 | Line (str text); |
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
49 | bool update (bool& changed); |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | str text; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | float alpha; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | QDateTime expiry; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | }; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
351
diff
changeset
|
56 | typedef List<Line>::it it; |
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
351
diff
changeset
|
57 | typedef List<Line>::c_it c_it; |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
59 | explicit MessageManager (QObject* parent = 0); |
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
60 | void addLine (str line); |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | c_it begin() const; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | c_it end() const; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
405
diff
changeset
|
64 | MessageManager& operator<< (str line); |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | private: |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
351
diff
changeset
|
67 | List<Line> m_lines; |
349
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | QTimer* m_ticker; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | private slots: |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | void tick(); |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | }; |
8e2630044a48
rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | |
351 | 74 | #endif // MESSAGELOG_H |