Sequencer: Implement simple undo.
This commit is contained in:
parent
451e948a17
commit
04c8e908e8
|
@ -977,6 +977,24 @@ Grid::mode ( void ) const
|
||||||
return _mode;
|
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 */
|
/** return a pointer to a copy of grid's event list in raw form */
|
||||||
event_list *
|
event_list *
|
||||||
|
|
|
@ -28,7 +28,7 @@ class smf;
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
const int MAX_UNDO = 10;
|
const int MAX_UNDO = 50;
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
@ -248,6 +248,8 @@ public:
|
||||||
void copy ( void );
|
void copy ( void );
|
||||||
void paste ( int offset );
|
void paste ( int offset );
|
||||||
|
|
||||||
|
void undo ( void );
|
||||||
|
|
||||||
virtual tick_t default_length ( void ) const
|
virtual tick_t default_length ( void ) const
|
||||||
{
|
{
|
||||||
return PPQN;
|
return PPQN;
|
||||||
|
|
|
@ -109,7 +109,7 @@ Function {init_colors()} {open private C return_type {static void}
|
||||||
}
|
}
|
||||||
|
|
||||||
widget_class Visual_Metronome {open
|
widget_class Visual_Metronome {open
|
||||||
xywh {1242 936 100 100} type Double visible
|
xywh {1244 936 100 100} type Double visible
|
||||||
} {
|
} {
|
||||||
Fl_Slider progress {
|
Fl_Slider progress {
|
||||||
private xywh {139 115 1149 23} type Horizontal box FLAT_BOX color 7 selection_color 54
|
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() )
|
if ( maybe_save_song() )
|
||||||
quit();} open
|
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 );}
|
code0 {o->color( FL_BACKGROUND_COLOR );}
|
||||||
code1 {o->draw_overlay_callback( &UI::draw_overlay, this );}
|
code1 {o->draw_overlay_callback( &UI::draw_overlay, this );}
|
||||||
code2 {o->xclass( APP_NAME );}
|
code2 {o->xclass( APP_NAME );}
|
||||||
|
@ -1311,7 +1311,7 @@ ab.run();}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Submenu edit_menu {
|
Submenu edit_menu {
|
||||||
label {&Edit} open selected
|
label {&Edit} open
|
||||||
xywh {0 0 68 18}
|
xywh {0 0 68 18}
|
||||||
} {
|
} {
|
||||||
MenuItem {} {
|
MenuItem {} {
|
||||||
|
@ -1424,6 +1424,13 @@ w->copy();}
|
||||||
w->paste();}
|
w->paste();}
|
||||||
xywh {120 120 34 18} shortcut 0x40076
|
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 {
|
Fl_Button sm_indicator {
|
||||||
|
|
Loading…
Reference in New Issue