Mercurial > hg > dmlib
annotate editor/edtlobj.cpp @ 1606:93d1050eac99
Rename dmf_create_*() functions to dmf_open_*().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 14 May 2018 11:20:05 +0300 |
parents | e2ac08228a0f |
children | b4992d9f72fe |
rev | line source |
---|---|
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 // |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
2 // Demo Editor -- Timeline state object |
397 | 3 // Wrapper class for DMTimeline data |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 // (C) Copyright 2012 Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 // |
379
05e85401480a
Rename eddemoobj to edtlobj, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
378
diff
changeset
|
6 #include "edtlobj.h" |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 #include "dmres.h" |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
10 EDTimelineObject::EDTimelineObject() |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 { |
397 | 12 dmTimelineNew(&tl, "Demo"); |
401 | 13 scrub(); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
17 EDTimelineObject::EDTimelineObject(EDTimelineObject *obj) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 { |
401 | 19 scrub(); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 filename = obj->filename; |
397 | 21 dmCopyTimeline(obj->tl, &tl); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
25 EDTimelineObject::~EDTimelineObject() |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 { |
379
05e85401480a
Rename eddemoobj to edtlobj, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
378
diff
changeset
|
27 dmFreeTimeline(tl); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 |
379
05e85401480a
Rename eddemoobj to edtlobj, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
378
diff
changeset
|
30 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
31 int EDTimelineObject::load(QString mfilename) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 QByteArray fnba = mfilename.toUtf8(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 DMResource *res; |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
35 DMTimeline *tmp; |
1606
93d1050eac99
Rename dmf_create_*() functions to dmf_open_*().
Matti Hamalainen <ccr@tnsp.org>
parents:
651
diff
changeset
|
36 if ((res = dmf_open_stdio(fnba.data(), "rb")) == NULL) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 return DMERR_FOPEN; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
39 int err = dmLoadTimeline(res, &tmp); |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
40 dmf_close(res); |
401 | 41 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
42 if (err == DMERR_OK) |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
43 { |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
44 dmFreeTimeline(tl); |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
45 tl = tmp; |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
46 scrub(); |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
47 if (tl->name != NULL) |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
48 filename = QString(tl->name); |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
49 else |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
50 filename = mfilename; |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
51 } |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
52 else |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
53 { |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
54 dmFreeTimeline(tmp); |
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
55 } |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 return err; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
60 int EDTimelineObject::save(QString mfilename) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 QByteArray fnba = mfilename.toUtf8(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 DMResource *res; |
1606
93d1050eac99
Rename dmf_create_*() functions to dmf_open_*().
Matti Hamalainen <ccr@tnsp.org>
parents:
651
diff
changeset
|
64 if ((res = dmf_open_stdio(fnba.data(), "wb")) == NULL) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 return DMERR_FOPEN; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 |
378 | 67 int err = dmSaveTimeline(res, tl); |
401 | 68 scrub(); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 dmf_close(res); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 return err; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 } |
401 | 73 |
74 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
75 void EDTimelineObject::touch() |
401 | 76 { |
77 ntouches++; | |
78 } | |
79 | |
80 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
81 void EDTimelineObject::scrub() |
401 | 82 { |
83 ntouches = 0; | |
84 } | |
85 | |
86 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
87 bool EDTimelineObject::touched() |
401 | 88 { |
89 return ntouches; | |
90 } | |
91 | |
92 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
93 void EDTimelineObject::setState(const QString &mstate) |
401 | 94 { |
95 cstate = mstate; | |
96 } | |
97 | |
98 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
99 QString EDTimelineObject::state() const |
401 | 100 { |
101 return cstate; | |
102 } |