Browse Source

Sequencer: Implement simple undo.

tags/non-daw-v1.2.0
Jonathan Moore Liles 10 years ago
parent
commit
04c8e908e8
3 changed files with 31 additions and 4 deletions
  1. +18
    -0
      sequencer/src/grid.C
  2. +3
    -1
      sequencer/src/grid.H
  3. +10
    -3
      sequencer/src/gui/ui.fl

+ 18
- 0
sequencer/src/grid.C View File

@@ -977,6 +977,24 @@ Grid::mode ( void ) const
return _mode;
}

void
Grid::undo ( void )
{
if ( ! _history.size() )
return;

data *d = _history.back();
_history.pop_back();

// swap the copy back in (atomically).
_rd = (const data *)d;
_rw = NULL;
if ( ! _suspend_update )
signal_events_change();
}

/** return a pointer to a copy of grid's event list in raw form */
event_list *


+ 3
- 1
sequencer/src/grid.H View File

@@ -28,7 +28,7 @@ class smf;

#include "debug.h"

const int MAX_UNDO = 10;
const int MAX_UNDO = 50;

#include <list>

@@ -248,6 +248,8 @@ public:
void copy ( void );
void paste ( int offset );

void undo ( void );

virtual tick_t default_length ( void ) const
{
return PPQN;


+ 10
- 3
sequencer/src/gui/ui.fl View File

@@ -109,7 +109,7 @@ Function {init_colors()} {open private C return_type {static void}
}

widget_class Visual_Metronome {open
xywh {1242 936 100 100} type Double visible
xywh {1244 936 100 100} type Double visible
} {
Fl_Slider progress {
private xywh {139 115 1149 23} type Horizontal box FLAT_BOX color 7 selection_color 54
@@ -414,7 +414,7 @@ if ( Fl::event() == FL_SHORTCUT && Fl::event_key() == FL_Escape )
if ( maybe_save_song() )
quit();} open
xywh {492 227 865 805} type Double color 47 resizable
xywh {494 231 865 805} type Double color 47 resizable
code0 {o->color( FL_BACKGROUND_COLOR );}
code1 {o->draw_overlay_callback( &UI::draw_overlay, this );}
code2 {o->xclass( APP_NAME );}
@@ -1311,7 +1311,7 @@ ab.run();}
}
}
Submenu edit_menu {
label {&Edit} open selected
label {&Edit} open
xywh {0 0 68 18}
} {
MenuItem {} {
@@ -1424,6 +1424,13 @@ w->copy();}
w->paste();}
xywh {120 120 34 18} shortcut 0x40076
}
MenuItem {} {
label Undo
callback {Canvas *w = current_canvas();

w->grid()->undo();} selected
xywh {110 110 34 18} shortcut 0x4007a
}
}
}
Fl_Button sm_indicator {


Loading…
Cancel
Save