Sequencer: Implement simple undo.

pull/116/head
Jonathan Moore Liles 2013-05-16 21:19:14 -07:00
parent 451e948a17
commit 04c8e908e8
3 changed files with 31 additions and 4 deletions

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 *

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;

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 {