mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-02 09:17:26 +00:00
GUI: add macro right click menu
This commit is contained in:
parent
3963f93aa4
commit
580d982f1e
4 changed files with 135 additions and 16 deletions
1
TODO.md
1
TODO.md
|
@ -17,7 +17,6 @@
|
||||||
- scroll instrument/wave/sample list when selecting item
|
- scroll instrument/wave/sample list when selecting item
|
||||||
- unified data view
|
- unified data view
|
||||||
- volume commands should work on Game Boy
|
- volume commands should work on Game Boy
|
||||||
- macro editor menu
|
|
||||||
- add another FM editor layout
|
- add another FM editor layout
|
||||||
- try to find out why does VSlider not accept keyboard input
|
- try to find out why does VSlider not accept keyboard input
|
||||||
- finish lock layout
|
- finish lock layout
|
||||||
|
|
|
@ -1717,7 +1717,11 @@ void FurnaceGUI::showError(String what) {
|
||||||
if (!macroDragInitialValueSet) { \
|
if (!macroDragInitialValueSet) { \
|
||||||
macroDragLineInitial=ImVec2(x,y); \
|
macroDragLineInitial=ImVec2(x,y); \
|
||||||
macroDragInitialValueSet=true; \
|
macroDragInitialValueSet=true; \
|
||||||
|
macroDragMouseMoved=false; \
|
||||||
|
} else if (!macroDragMouseMoved) { \
|
||||||
|
macroDragMouseMoved=true; \
|
||||||
} \
|
} \
|
||||||
|
if (macroDragMouseMoved) { \
|
||||||
if ((int)round(x-macroDragLineInitial.x)==0) { \
|
if ((int)round(x-macroDragLineInitial.x)==0) { \
|
||||||
t[x]=macroDragLineInitial.y; \
|
t[x]=macroDragLineInitial.y; \
|
||||||
} else { \
|
} else { \
|
||||||
|
@ -1735,6 +1739,7 @@ void FurnaceGUI::showError(String what) {
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
t[x]=y; \
|
t[x]=y; \
|
||||||
} \
|
} \
|
||||||
|
@ -2342,6 +2347,9 @@ bool FurnaceGUI::loop() {
|
||||||
if (macroDragActive || macroLoopDragActive || waveDragActive || (sampleDragActive && sampleDragMode)) {
|
if (macroDragActive || macroLoopDragActive || waveDragActive || (sampleDragActive && sampleDragMode)) {
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
}
|
}
|
||||||
|
if (macroDragActive && macroDragLineMode && !macroDragMouseMoved) {
|
||||||
|
displayMacroMenu=true;
|
||||||
|
}
|
||||||
macroDragActive=false;
|
macroDragActive=false;
|
||||||
macroDragBitMode=false;
|
macroDragBitMode=false;
|
||||||
macroDragInitialValue=false;
|
macroDragInitialValue=false;
|
||||||
|
@ -3851,6 +3859,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
displayExporting(false),
|
displayExporting(false),
|
||||||
vgmExportLoop(true),
|
vgmExportLoop(true),
|
||||||
wantCaptureKeyboard(false),
|
wantCaptureKeyboard(false),
|
||||||
|
displayMacroMenu(false),
|
||||||
displayNew(false),
|
displayNew(false),
|
||||||
fullScreen(false),
|
fullScreen(false),
|
||||||
preserveChanPos(false),
|
preserveChanPos(false),
|
||||||
|
@ -4004,8 +4013,14 @@ FurnaceGUI::FurnaceGUI():
|
||||||
macroDragInitialValue(false),
|
macroDragInitialValue(false),
|
||||||
macroDragChar(false),
|
macroDragChar(false),
|
||||||
macroDragLineMode(false),
|
macroDragLineMode(false),
|
||||||
|
macroDragMouseMoved(false),
|
||||||
macroDragLineInitial(0,0),
|
macroDragLineInitial(0,0),
|
||||||
macroDragActive(false),
|
macroDragActive(false),
|
||||||
|
lastMacroDesc(NULL,NULL,0,0,0.0f),
|
||||||
|
macroOffX(0),
|
||||||
|
macroOffY(0),
|
||||||
|
macroScaleX(100.0f),
|
||||||
|
macroScaleY(100.0f),
|
||||||
macroLoopDragStart(0,0),
|
macroLoopDragStart(0,0),
|
||||||
macroLoopDragAreaSize(0,0),
|
macroLoopDragAreaSize(0,0),
|
||||||
macroLoopDragTarget(NULL),
|
macroLoopDragTarget(NULL),
|
||||||
|
|
|
@ -768,7 +768,7 @@ class FurnaceGUI {
|
||||||
String mmlString[17];
|
String mmlString[17];
|
||||||
String mmlStringW;
|
String mmlStringW;
|
||||||
|
|
||||||
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, wantCaptureKeyboard;
|
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, wantCaptureKeyboard, displayMacroMenu;
|
||||||
bool displayNew, fullScreen, preserveChanPos;
|
bool displayNew, fullScreen, preserveChanPos;
|
||||||
bool willExport[32];
|
bool willExport[32];
|
||||||
int vgmExportVersion;
|
int vgmExportVersion;
|
||||||
|
@ -1080,8 +1080,12 @@ class FurnaceGUI {
|
||||||
bool macroDragInitialValue;
|
bool macroDragInitialValue;
|
||||||
bool macroDragChar;
|
bool macroDragChar;
|
||||||
bool macroDragLineMode;
|
bool macroDragLineMode;
|
||||||
|
bool macroDragMouseMoved;
|
||||||
ImVec2 macroDragLineInitial;
|
ImVec2 macroDragLineInitial;
|
||||||
bool macroDragActive;
|
bool macroDragActive;
|
||||||
|
FurnaceGUIMacroDesc lastMacroDesc;
|
||||||
|
int macroOffX, macroOffY;
|
||||||
|
float macroScaleX, macroScaleY;
|
||||||
|
|
||||||
ImVec2 macroLoopDragStart;
|
ImVec2 macroLoopDragStart;
|
||||||
ImVec2 macroLoopDragAreaSize;
|
ImVec2 macroLoopDragAreaSize;
|
||||||
|
|
|
@ -1192,6 +1192,7 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros) {
|
||||||
macroDragChar=false;
|
macroDragChar=false;
|
||||||
macroDragLineMode=(i.isBitfield)?false:ImGui::IsItemClicked(ImGuiMouseButton_Right);
|
macroDragLineMode=(i.isBitfield)?false:ImGui::IsItemClicked(ImGuiMouseButton_Right);
|
||||||
macroDragLineInitial=ImVec2(0,0);
|
macroDragLineInitial=ImVec2(0,0);
|
||||||
|
lastMacroDesc=i;
|
||||||
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
||||||
}
|
}
|
||||||
if (i.macro->open) {
|
if (i.macro->open) {
|
||||||
|
@ -3123,8 +3124,108 @@ void FurnaceGUI::drawInsEdit() {
|
||||||
popAccentColors();
|
popAccentColors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (displayMacroMenu) {
|
||||||
|
displayMacroMenu=false;
|
||||||
|
if (lastMacroDesc.macro!=NULL) {
|
||||||
|
ImGui::OpenPopup("macroMenu");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ImGui::BeginPopup("macroMenu",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) {
|
if (ImGui::BeginPopup("macroMenu",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) {
|
||||||
ImGui::Text("Macro menu here...");
|
if (ImGui::MenuItem("copy")) {
|
||||||
|
String mmlStr;
|
||||||
|
encodeMMLStr(mmlStr,lastMacroDesc.macro->val,lastMacroDesc.macro->len,lastMacroDesc.macro->loop,lastMacroDesc.macro->rel);
|
||||||
|
SDL_SetClipboardText(mmlStr.c_str());
|
||||||
|
}
|
||||||
|
if (ImGui::MenuItem("paste")) {
|
||||||
|
String mmlStr;
|
||||||
|
char* clipText=SDL_GetClipboardText();
|
||||||
|
if (clipText!=NULL) {
|
||||||
|
if (clipText[0]) {
|
||||||
|
mmlStr=clipText;
|
||||||
|
}
|
||||||
|
SDL_free(clipText);
|
||||||
|
}
|
||||||
|
if (!mmlStr.empty()) {
|
||||||
|
decodeMMLStr(mmlStr,lastMacroDesc.macro->val,lastMacroDesc.macro->len,lastMacroDesc.macro->loop,lastMacroDesc.min,(lastMacroDesc.isBitfield)?((1<<(lastMacroDesc.isBitfield?lastMacroDesc.max:0))-1):lastMacroDesc.max,lastMacroDesc.macro->rel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::MenuItem("clear")) {
|
||||||
|
lastMacroDesc.macro->len=0;
|
||||||
|
lastMacroDesc.macro->loop=-1;
|
||||||
|
lastMacroDesc.macro->rel=-1;
|
||||||
|
for (int i=0; i<256; i++) {
|
||||||
|
lastMacroDesc.macro->val[i]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ImGui::MenuItem("clear contents")) {
|
||||||
|
for (int i=0; i<256; i++) {
|
||||||
|
lastMacroDesc.macro->val[i]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::BeginMenu("offset...")) {
|
||||||
|
ImGui::InputInt("X",¯oOffX,1,10);
|
||||||
|
ImGui::InputInt("Y",¯oOffY,1,10);
|
||||||
|
if (ImGui::Button("offset")) {
|
||||||
|
int oldData[256];
|
||||||
|
memset(oldData,0,256*sizeof(int));
|
||||||
|
memcpy(oldData,lastMacroDesc.macro->val,lastMacroDesc.macro->len*sizeof(int));
|
||||||
|
|
||||||
|
for (int i=0; i<lastMacroDesc.macro->len; i++) {
|
||||||
|
int val=0;
|
||||||
|
if ((i-macroOffX)>=0 && (i-macroOffX)<lastMacroDesc.macro->len) {
|
||||||
|
val=oldData[i-macroOffX]+macroOffY;
|
||||||
|
if (val<lastMacroDesc.min) val=lastMacroDesc.min;
|
||||||
|
if (val>lastMacroDesc.max) val=lastMacroDesc.max;
|
||||||
|
}
|
||||||
|
lastMacroDesc.macro->val[i]=val;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastMacroDesc.macro->loop>=0 && lastMacroDesc.macro->loop<lastMacroDesc.macro->len) {
|
||||||
|
lastMacroDesc.macro->loop+=macroOffX;
|
||||||
|
} else {
|
||||||
|
lastMacroDesc.macro->loop=-1;
|
||||||
|
}
|
||||||
|
if ((lastMacroDesc.macro->rel+macroOffX)>=0 && (lastMacroDesc.macro->rel+macroOffX)<lastMacroDesc.macro->len) {
|
||||||
|
lastMacroDesc.macro->rel+=macroOffX;
|
||||||
|
} else {
|
||||||
|
lastMacroDesc.macro->rel=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
if (ImGui::BeginMenu("scale...")) {
|
||||||
|
if (ImGui::InputFloat("X",¯oScaleX,1.0f,10.0f,"%.2f%%")) {
|
||||||
|
if (macroScaleX<0.1) macroScaleX=0.1;
|
||||||
|
if (macroScaleX>12800.0) macroScaleX=12800.0;
|
||||||
|
}
|
||||||
|
ImGui::InputFloat("Y",¯oScaleY,1.0f,10.0f,"%.2f%%");
|
||||||
|
if (ImGui::Button("scale")) {
|
||||||
|
int oldData[256];
|
||||||
|
memset(oldData,0,256*sizeof(int));
|
||||||
|
memcpy(oldData,lastMacroDesc.macro->val,lastMacroDesc.macro->len*sizeof(int));
|
||||||
|
|
||||||
|
lastMacroDesc.macro->len=MIN(128,((double)lastMacroDesc.macro->len*(macroScaleX/100.0)));
|
||||||
|
|
||||||
|
for (int i=0; i<lastMacroDesc.macro->len; i++) {
|
||||||
|
int val=0;
|
||||||
|
double posX=round((double)i*(100.0/macroScaleX)-0.01);
|
||||||
|
if (posX>=0 && posX<lastMacroDesc.macro->len) {
|
||||||
|
val=round((double)oldData[(int)posX]*(macroScaleY/100.0));
|
||||||
|
if (val<lastMacroDesc.min) val=lastMacroDesc.min;
|
||||||
|
if (val>lastMacroDesc.max) val=lastMacroDesc.max;
|
||||||
|
}
|
||||||
|
lastMacroDesc.macro->val[i]=val;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue