More simulator buttons
This commit is contained in:
parent
c7aa020f67
commit
bdfd216b4a
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
noicesynth_linux
|
||||
miniaudio.h
|
||||
miniaudio.h
|
||||
noicesynth_patch*
|
||||
@ -1147,6 +1147,9 @@ int main(int argc, char* argv[]) {
|
||||
bool importButtonPressed = false;
|
||||
bool saveButtonPressed = false;
|
||||
bool loadButtonPressed = false;
|
||||
bool randomizeButtonPressed = false;
|
||||
bool clearButtonPressed = false;
|
||||
bool nextPresetButtonPressed = false;
|
||||
|
||||
while (!quit) {
|
||||
checkSerialInput(serialPort);
|
||||
@ -1260,6 +1263,24 @@ int main(int argc, char* argv[]) {
|
||||
my >= loadButtonRect.y && my <= loadButtonRect.y + loadButtonRect.h) {
|
||||
loadButtonPressed = true;
|
||||
}
|
||||
|
||||
SDL_Rect randomizeButtonRect = {250, 380, 100, 30};
|
||||
if (synthX >= randomizeButtonRect.x && synthX <= randomizeButtonRect.x + randomizeButtonRect.w &&
|
||||
my >= randomizeButtonRect.y && my <= randomizeButtonRect.y + randomizeButtonRect.h) {
|
||||
randomizeButtonPressed = true;
|
||||
}
|
||||
|
||||
SDL_Rect clearButtonRect = {360, 380, 80, 30};
|
||||
if (synthX >= clearButtonRect.x && synthX <= clearButtonRect.x + clearButtonRect.w &&
|
||||
my >= clearButtonRect.y && my <= clearButtonRect.y + clearButtonRect.h) {
|
||||
clearButtonPressed = true;
|
||||
}
|
||||
|
||||
SDL_Rect nextPresetButtonRect = {450, 380, 80, 30};
|
||||
if (synthX >= nextPresetButtonRect.x && synthX <= nextPresetButtonRect.x + nextPresetButtonRect.w &&
|
||||
my >= nextPresetButtonRect.y && my <= nextPresetButtonRect.y + nextPresetButtonRect.h) {
|
||||
nextPresetButtonPressed = true;
|
||||
}
|
||||
}
|
||||
} else if (e.type == SDL_MOUSEWHEEL) {
|
||||
SDL_Keymod modState = SDL_GetModState();
|
||||
@ -1416,6 +1437,43 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
loadButtonPressed = false;
|
||||
}
|
||||
if (randomizeButtonPressed) {
|
||||
int mx = e.button.x;
|
||||
int my = e.button.y;
|
||||
int synthX = mx - GRID_PANEL_WIDTH;
|
||||
SDL_Rect randomizeButtonRect = {250, 380, 100, 30};
|
||||
if (mx >= GRID_PANEL_WIDTH &&
|
||||
synthX >= randomizeButtonRect.x && synthX <= randomizeButtonRect.x + randomizeButtonRect.w &&
|
||||
my >= randomizeButtonRect.y && my <= randomizeButtonRect.y + randomizeButtonRect.h) {
|
||||
randomizeGrid();
|
||||
}
|
||||
randomizeButtonPressed = false;
|
||||
}
|
||||
if (clearButtonPressed) {
|
||||
int mx = e.button.x;
|
||||
int my = e.button.y;
|
||||
int synthX = mx - GRID_PANEL_WIDTH;
|
||||
SDL_Rect clearButtonRect = {360, 380, 80, 30};
|
||||
if (mx >= GRID_PANEL_WIDTH &&
|
||||
synthX >= clearButtonRect.x && synthX <= clearButtonRect.x + clearButtonRect.w &&
|
||||
my >= clearButtonRect.y && my <= clearButtonRect.y + clearButtonRect.h) {
|
||||
engine.clearGrid();
|
||||
}
|
||||
clearButtonPressed = false;
|
||||
}
|
||||
if (nextPresetButtonPressed) {
|
||||
int mx = e.button.x;
|
||||
int my = e.button.y;
|
||||
int synthX = mx - GRID_PANEL_WIDTH;
|
||||
SDL_Rect nextPresetButtonRect = {450, 380, 80, 30};
|
||||
if (mx >= GRID_PANEL_WIDTH &&
|
||||
synthX >= nextPresetButtonRect.x && synthX <= nextPresetButtonRect.x + nextPresetButtonRect.w &&
|
||||
my >= nextPresetButtonRect.y && my <= nextPresetButtonRect.y + nextPresetButtonRect.h) {
|
||||
current_preset = (current_preset + 1) % 6;
|
||||
engine.loadPreset(current_preset);
|
||||
}
|
||||
nextPresetButtonPressed = false;
|
||||
}
|
||||
} else if (e.type == SDL_KEYUP) {
|
||||
if (!auto_melody_enabled && e.key.keysym.scancode == current_key_scancode) {
|
||||
engine.setGate(false);
|
||||
@ -1498,6 +1556,10 @@ int main(int argc, char* argv[]) {
|
||||
drawButton(renderer, 300, 435, 100, 30, "EXPORT", exportButtonPressed);
|
||||
drawButton(renderer, 410, 435, 100, 30, "IMPORT", importButtonPressed);
|
||||
|
||||
drawButton(renderer, 250, 380, 100, 30, "RANDOM", randomizeButtonPressed);
|
||||
drawButton(renderer, 360, 380, 80, 30, "CLEAR", clearButtonPressed);
|
||||
drawButton(renderer, 450, 380, 80, 30, "PRESET+", nextPresetButtonPressed);
|
||||
|
||||
// Patch Slot Control
|
||||
float normalized_slot = (float)current_patch_slot / 7.0f;
|
||||
drawKnob(renderer, 400, 550, 40, normalized_slot);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user