~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to undo.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//=========================================================
2
2
//  MusE
3
3
//  Linux Music Editor
4
 
//  $Id: undo.cpp,v 1.1 2002/01/30 14:54:03 muse Exp $
 
4
//  $Id: undo.cpp,v 1.2 2003/11/18 18:45:31 lunar_shuttle Exp $
5
5
//
6
6
//  (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
7
7
//=========================================================
11
11
#include "globals.h"
12
12
#include "event.h"
13
13
 
14
 
// iundo zeigt auf letztes Undo() in Undo-Liste
 
14
// iundo points to last Undo() in Undo-list
15
15
 
16
16
//---------------------------------------------------------
17
17
//    startUndo
19
19
 
20
20
void Song::startUndo()
21
21
      {
22
 
// printf("start undo\n");
23
22
      undoList->push_back(Undo());
24
23
      updateFlags = 0;
25
24
      }
26
25
 
27
26
//---------------------------------------------------------
 
27
//   endUndo
 
28
//---------------------------------------------------------
 
29
 
 
30
void Song::endUndo(int flags)
 
31
      {
 
32
      updateFlags = flags;
 
33
      endMsgCmd();
 
34
      }
 
35
 
 
36
//---------------------------------------------------------
28
37
//   undo
29
38
//---------------------------------------------------------
30
39
 
31
40
void Song::doUndo()
32
41
      {
 
42
      if (undoList->empty())
 
43
            return;
33
44
      Undo& u = undoList->back();
34
45
      for (riUndoOp i = u.rbegin(); i != u.rend(); ++i) {
35
 
// printf("doUndo %d\n", i->type);
36
46
            switch(i->type) {
37
47
                  case UndoOp::AddTrack:
38
48
                        {
39
49
                        iTrack it = _tracks.find(i->xxx.t.trackno);
40
50
                        _tracks.erase(it);
41
51
                        updateFlags |= SC_TRACK_REMOVED;
 
52
                        if ((*it)->type() == Track::WAVE)
 
53
                              updateFlags |= SC_AUDIO_MIXER;
42
54
                        }
43
55
                        break;
44
56
                  case UndoOp::DeleteTrack:
47
59
                        iTrack it = _tracks.find(i->xxx.t.trackno);
48
60
                        _tracks.insert(it, i->xxx.t.track);
49
61
                        updateFlags |= SC_TRACK_INSERTED;
 
62
                        if (i->xxx.t.track->type() == Track::WAVE)
 
63
                              updateFlags |= SC_AUDIO_MIXER;
50
64
                        }
51
65
                        break;
52
66
                  case UndoOp::ModifyTrack:
56
70
                        *it = i->xxx.t.track;
57
71
                        i->xxx.t.track = track;
58
72
                        updateFlags |= SC_TRACK_MODIFIED;
 
73
                        if (i->xxx.t.track->type() == Track::WAVE)
 
74
                              updateFlags |= SC_AUDIO_MIXER;
59
75
                        }
60
76
                        break;
61
77
                  case UndoOp::SwapTrack:
69
85
                        }
70
86
                        break;
71
87
                  case UndoOp::AddPart:
72
 
                        removePart(i->xxx.p.oPart);
 
88
                        {
 
89
                        Part* part = i->xxx.p.oPart;
 
90
                        part->track()->parts()->remove(part);
73
91
                        updateFlags |= SC_PART_REMOVED;
 
92
                        i->xxx.p.oPart->events()->incARef(-1);
 
93
                        }
74
94
                        break;
75
95
                  case UndoOp::DeletePart:
76
96
                        addPart(i->xxx.p.oPart);
77
97
                        updateFlags |= SC_PART_INSERTED;
 
98
                        i->xxx.p.oPart->events()->incARef(1);
78
99
                        break;
79
100
                  case UndoOp::ModifyPart:
80
101
                        changePart(i->xxx.p.oPart, i->xxx.p.nPart);
 
102
                        i->xxx.p.oPart->events()->incARef(-1);
 
103
                        i->xxx.p.nPart->events()->incARef(1);
81
104
                        updateFlags |= SC_PART_MODIFIED;
82
105
                        break;
83
106
                  case UndoOp::AddEvent:
121
144
 
122
145
void Song::doRedo()
123
146
      {
 
147
      if (redoList->empty())
 
148
            return;
124
149
      Undo& u = redoList->back();
125
150
      for (iUndoOp i = u.begin(); i != u.end(); ++i) {
126
151
            switch(i->type) {
130
155
                        iTrack it = _tracks.find(i->xxx.t.trackno);
131
156
                        _tracks.insert(it, i->xxx.t.track);
132
157
                        updateFlags |= SC_TRACK_INSERTED;
 
158
                        if (i->xxx.t.track->type() == Track::WAVE)
 
159
                              updateFlags |= SC_AUDIO_MIXER;
133
160
                        }
134
161
                        break;
135
162
                  case UndoOp::DeleteTrack:
137
164
                        iTrack it = _tracks.find(i->xxx.t.trackno);
138
165
                        _tracks.erase(it);
139
166
                        updateFlags |= SC_TRACK_REMOVED;
 
167
                        if ((*it)->type() == Track::WAVE)
 
168
                              updateFlags |= SC_AUDIO_MIXER;
140
169
                        }
141
170
                        break;
142
171
                  case UndoOp::ModifyTrack:
146
175
                        *it = i->xxx.t.track;
147
176
                        i->xxx.t.track = track;
148
177
                        updateFlags |= SC_TRACK_MODIFIED;
 
178
                        if ((*it)->type() == Track::WAVE)
 
179
                              updateFlags |= SC_AUDIO_MIXER;
149
180
                        }
150
181
                        break;
151
182
                  case UndoOp::SwapTrack:
161
192
                  case UndoOp::AddPart:
162
193
                        addPart(i->xxx.p.oPart);
163
194
                        updateFlags |= SC_PART_INSERTED;
 
195
                        i->xxx.p.oPart->events()->incARef(1);
164
196
                        break;
165
197
                  case UndoOp::DeletePart:
166
 
                        removePart(i->xxx.p.oPart);
 
198
                        {
 
199
                        Part* part = i->xxx.p.oPart;
 
200
                        part->track()->parts()->remove(part);
167
201
                        updateFlags |= SC_PART_REMOVED;
 
202
                        i->xxx.p.oPart->events()->incARef(-1);
 
203
                        }
168
204
                        break;
169
205
                  case UndoOp::ModifyPart:
170
206
                        changePart(i->xxx.p.nPart, i->xxx.p.oPart);
171
207
                        updateFlags |= SC_PART_MODIFIED;
 
208
                        i->xxx.p.oPart->events()->incARef(1);
 
209
                        i->xxx.p.nPart->events()->incARef(-1);
172
210
                        break;
173
211
                  case UndoOp::AddEvent:
174
212
                        addEvent((MidiEvent*)i->xxx.e.nEvent, (MidiPart*)(i->xxx.e.part));
205
243
      dirty = true;
206
244
      }
207
245
 
208
 
void Song::undoOp(UndoOp::UndoType type, int a, int b, int c = 0)
 
246
void Song::undoOp(UndoOp::UndoType type, int a, int b, int c)
209
247
      {
210
248
      UndoOp i;
211
249
      i.type = type;
246
284
            oev->incRefs(1);
247
285
      if (nev)
248
286
            nev->incRefs(1);
 
287
      // Check if undoList is empty. Might happen if first operation doesn't have undo flag set
 
288
      if (undoList->empty())
 
289
            undoList->push_back(Undo());
 
290
 
249
291
      undoList->back().push_back(i);
250
292
      dirty = true;
251
293
      }