src/messagelog.h

Fri, 06 Dec 2013 00:29:44 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 06 Dec 2013 00:29:44 +0200
changeset 541
0e38beeb050a
parent 540
0334789cb4d7
child 600
209e3f1f7b2c
permissions
-rw-r--r--

- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h

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
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
19 #ifndef LDFORGE_MESSAGELOG_H
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
20 #define LDFORGE_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>
541
0e38beeb050a - Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 540
diff changeset
24 #include "main.h"
349
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
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
29
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
30 /* The message manager is an object which keeps track of messages that appear
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
31 * on the renderer's screen. Each line is contained in a separate object which
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
32 * contains the text, expiry time and alpha. The message manager is doubly
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
33 * linked to its corresponding renderer.
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
34 *
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
35 * Message manager calls its tick() function regularly to update the messages,
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
36 * where each line's expiry is checked for. Lines begin to fade out when nearing
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
37 * their expiry. If the message manager's lines change, the renderer undergoes
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
38 * repainting.
b8c813906ac0 commentary++
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
39 */
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
40 class MessageManager : public QObject
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
41 { Q_OBJECT
540
0334789cb4d7 - Changed the callback parm of PROPERTY to a stock/custom write method argument.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 539
diff changeset
42 PROPERTY (public, GLRenderer*, Renderer, NO_OPS, STOCK_WRITE)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
43
349
8e2630044a48 rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 public:
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
45 // Single line of the message log.
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
46 class Line
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
47 { public:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
48 Line (str text);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
49 bool update (bool& changed);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
50
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
51 str text;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
52 float alpha;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
53 QDateTime expiry;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
54 };
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
55
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
56 explicit MessageManager (QObject* parent = 0);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
57 void addLine (str line);
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
58 const QList<Line>& getLines() const;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
59
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
60 private:
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
61 QList<Line> m_lines;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
62 QTimer* m_ticker;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
63
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
64 private slots:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
65 void tick();
349
8e2630044a48 rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 };
8e2630044a48 rename: msglog.cpp/h -> messagelog.cpp/h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
68 #endif // LDFORGE_MESSAGELOG_H

mercurial