コード例 #1
0
ファイル: UndoManager.cpp プロジェクト: tuanmasterit/audacity
void UndoManager::RemoveStates(int num)
{
   for (int i = 0; i < num; i++) {
      RemoveStateAt(0);

      current -= 1;
      saved -= 1;
   }
}
コード例 #2
0
ファイル: UndoManager.cpp プロジェクト: tuanmasterit/audacity
void UndoManager::PushState(TrackList * l, double sel0, double sel1,
                            wxString longDescription,
                            wxString shortDescription,
                            int flags)
{
   unsigned int i;

   // If consolidate is set to true, group up to 3 identical operations.
   if (((flags&PUSH_CONSOLIDATE)!=0) && lastAction == longDescription &&
       consolidationCount < 2) {
      consolidationCount++;
      ModifyState(l, sel0, sel1);
      // MB: If the "saved" state was modified by ModifyState, reset
      //  it so that UnsavedChanges returns true.
      if (current == saved) {
         saved = -1;
      }
      return;
   }

   consolidationCount = 0;

   i = current + 1;
   while (i < stack.Count()) {
      RemoveStateAt(i);
   }
             
   TrackList *tracksCopy = new TrackList();
   TrackListIterator iter(l);
   Track *t = iter.First();
   while (t) {
      tracksCopy->Add(t->Duplicate());
      t = iter.Next();
   }

   UndoStackElem *push = new UndoStackElem();
   push->tracks = tracksCopy;
   push->sel0 = sel0;
   push->sel1 = sel1;
   push->description = longDescription;
   push->shortDescription = shortDescription;
   push->spaceUsage = 0; // Calculate actual value after it's on the stack.

   stack.Add(push);
   current++;
   if( (flags&PUSH_CALC_SPACE)!=0)
      push->spaceUsage = this->CalculateSpaceUsage(current);

   if (saved >= current) {
      saved = -1;
   }

   lastAction = longDescription;
}
コード例 #3
0
ファイル: UndoManager.cpp プロジェクト: aeve/audacity
void UndoManager::PushState(const TrackList * l,
                            const SelectedRegion &selectedRegion,
                            const std::shared_ptr<Tags> &tags,
                            const wxString &longDescription,
                            const wxString &shortDescription,
                            UndoPush flags)
{
   unsigned int i;

   // If consolidate is set to true, group up to 3 identical operations.
   if (((flags & UndoPush::CONSOLIDATE) != UndoPush::MINIMAL) && lastAction == longDescription &&
       consolidationCount < 2) {
      consolidationCount++;
      ModifyState(l, selectedRegion, tags);
      // MB: If the "saved" state was modified by ModifyState, reset
      //  it so that UnsavedChanges returns true.
      if (current == saved) {
         saved = -1;
      }
      return;
   }

   consolidationCount = 0;

   i = current + 1;
   while (i < stack.size()) {
      RemoveStateAt(i);
   }

   auto tracksCopy = std::make_unique<TrackList>();
   TrackListConstIterator iter(l);
   const Track *t = iter.First();
   while (t) {
      tracksCopy->Add(t->Duplicate());
      t = iter.Next();
   }

   // Assume tags was duplicted before any changes.
   // Just save a new shared_ptr to it.
   stack.push_back(
      make_movable<UndoStackElem>
         (std::move(tracksCopy),
            longDescription, shortDescription, selectedRegion, tags)
   );

   current++;

   if (saved >= current) {
      saved = -1;
   }

   lastAction = longDescription;
}
コード例 #4
0
void UndoManager::PushState(TrackList * l,
                            const SelectedRegion &selectedRegion,
                            const wxString &longDescription,
                            const wxString &shortDescription,
                            int flags)
{
   unsigned int i;

   // If consolidate is set to true, group up to 3 identical operations.
   if (((flags&PUSH_CONSOLIDATE)!=0) && lastAction == longDescription &&
       consolidationCount < 2) {
      consolidationCount++;
      ModifyState(l, selectedRegion);
      // MB: If the "saved" state was modified by ModifyState, reset
      //  it so that UnsavedChanges returns true.
      if (current == saved) {
         saved = -1;
      }
      return;
   }

   consolidationCount = 0;

   i = current + 1;
   while (i < stack.Count()) {
      RemoveStateAt(i);
   }

   TrackList *tracksCopy = new TrackList();
   TrackListIterator iter(l);
   Track *t = iter.First();
   while (t) {
      tracksCopy->Add(t->Duplicate());
      t = iter.Next();
   }

   UndoStackElem *push = new UndoStackElem();
   push->tracks = tracksCopy;
   push->selectedRegion = selectedRegion;
   push->description = longDescription;
   push->shortDescription = shortDescription;

   stack.Add(push);
   current++;

   if (saved >= current) {
      saved = -1;
   }

   lastAction = longDescription;
}
コード例 #5
0
ファイル: UndoManager.cpp プロジェクト: ruthmagnus/audacity
void UndoManager::RemoveStates(int num)
{
   for (int i = 0; i < num; i++)
      RemoveStateAt(0);
}