Only allow operations that do make sense.

This commit is contained in:
Valentin Boettcher 2018-04-05 18:59:26 +02:00
parent 07a76ef9e0
commit b1d0c9f050
2 changed files with 16 additions and 13 deletions

View file

@ -24,8 +24,8 @@
#pragma GCC diagnostic ignored "-Wmissing-field-initializers" #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#include "../gui.hxx" #include "../gui.hxx"
#define RECORD_BARS_MENU_ITEM(num) { #num, 0, setRecordBarsCb, (void*)num, FL_MENU_RADIO | ((clips[clipNum].getBeatsToRecord() == num*4) ? FL_ACTIVATE : 0) } #define RECORD_BARS_MENU_ITEM(num) { #num, 0, setRecordBarsCb, (void*)num, FL_MENU_RADIO | ((clips[clipNum].getBeatsToRecord() == num*4) ? FL_ACTIVATE : 0 | empty ? 0 : FL_MENU_INACTIVE) }
#define RECORD_LENGTH_MENU_ITEM(num) {#num, 0, setLengthCb, (void*)num} #define RECORD_LENGTH_MENU_ITEM(num) {#num, 0, setLengthCb, (void*)num, empty ? FL_MENU_INACTIVE : 0}
extern Gui* gui; extern Gui* gui;
@ -337,6 +337,7 @@ int ClipSelector::handle(int event)
} }
bool empty = clips[clipNum].getState() == GridLogic::STATE_EMPTY;
Fl_Menu_Item rclick_menu[] = { Fl_Menu_Item rclick_menu[] = {
{ "Load" }, { "Load" },
{ "Save" }, { "Save" },

View file

@ -189,9 +189,11 @@ void LooperClip::setPlayHead(float ph)
void LooperClip::setBarsToRecord(int bars) void LooperClip::setBarsToRecord(int bars)
{ {
if(!(_playing || _queuePlay || _queueStop || _loaded)) {
_wantedBeats = bars * 4; // we set beats _wantedBeats = bars * 4; // we set beats
EventClipBeatsChanged e( track, scene, _wantedBeats, true); EventClipBeatsChanged e( track, scene, _wantedBeats, true);
writeToGuiRingbuffer(&e); writeToGuiRingbuffer(&e);
}
} }
int LooperClip::getBeatsToRecord() int LooperClip::getBeatsToRecord()
@ -253,13 +255,13 @@ size_t LooperClip::audioBufferSize()
void LooperClip::setBeats(int beats) void LooperClip::setBeats(int beats)
{ {
if ( _buffer ) { if (_loaded || _playing || _queuePlay || _queueStop || beats == 0) {
if(_buffer)
_buffer->setBeats( beats ); _buffer->setBeats( beats );
}
// Even on Reset!
EventClipBeatsChanged e(track, scene, beats, false); EventClipBeatsChanged e(track, scene, beats, false);
writeToGuiRingbuffer(&e); writeToGuiRingbuffer(&e);
}
} }
int LooperClip::getBeats() int LooperClip::getBeats()