GUI: even more mobile work
This commit is contained in:
parent
d021005f26
commit
0ac92209d0
|
@ -22,7 +22,7 @@ bug fixes, improvements and several other things accepted.
|
||||||
|
|
||||||
the coding style is described here:
|
the coding style is described here:
|
||||||
|
|
||||||
- indentation: two spaces
|
- indentation: two spaces. **strictly** spaces. do NOT use tabs.
|
||||||
- modified 1TBS style:
|
- modified 1TBS style:
|
||||||
- no spaces in function calls
|
- no spaces in function calls
|
||||||
- spaces between arguments in function declarations
|
- spaces between arguments in function declarations
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.tildearrow.furnace"
|
package="org.tildearrow.furnace"
|
||||||
android:versionCode="93"
|
android:versionCode="112"
|
||||||
android:versionName="0.6pre1"
|
android:versionName="dev112"
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
|
|
||||||
<!-- OpenGL ES 2.0 -->
|
<!-- OpenGL ES 2.0 -->
|
||||||
|
@ -83,13 +83,17 @@
|
||||||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!-- Drop file event -->
|
<!-- Drop file event -->
|
||||||
<!--
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<data android:mimeType="*/*" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
|
<data android:scheme="file"/>
|
||||||
|
<data android:scheme="content"/>
|
||||||
|
<data android:host="*"/>
|
||||||
|
<data android:mimeType="*/*"/>
|
||||||
|
<data android:pathPattern=".*\\.fur"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
-->
|
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -29,14 +29,20 @@ const char* sampleNote[12]={
|
||||||
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
|
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
|
||||||
};
|
};
|
||||||
|
|
||||||
void FurnaceGUI::drawInsList() {
|
void FurnaceGUI::drawInsList(bool asChild) {
|
||||||
if (nextWindow==GUI_WINDOW_INS_LIST) {
|
if (nextWindow==GUI_WINDOW_INS_LIST) {
|
||||||
insListOpen=true;
|
insListOpen=true;
|
||||||
ImGui::SetNextWindowFocus();
|
ImGui::SetNextWindowFocus();
|
||||||
nextWindow=GUI_WINDOW_NOTHING;
|
nextWindow=GUI_WINDOW_NOTHING;
|
||||||
}
|
}
|
||||||
if (!insListOpen) return;
|
if (!insListOpen && !asChild) return;
|
||||||
if (ImGui::Begin("Instruments",&insListOpen,globalWinFlags)) {
|
bool began=false;
|
||||||
|
if (asChild) {
|
||||||
|
began=ImGui::BeginChild("Instruments");
|
||||||
|
} else {
|
||||||
|
began=ImGui::Begin("Instruments",&insListOpen,globalWinFlags);
|
||||||
|
}
|
||||||
|
if (began) {
|
||||||
if (settings.unifiedDataView) settings.horizontalDataView=0;
|
if (settings.unifiedDataView) settings.horizontalDataView=0;
|
||||||
if (ImGui::Button(ICON_FA_PLUS "##InsAdd")) {
|
if (ImGui::Button(ICON_FA_PLUS "##InsAdd")) {
|
||||||
if (!settings.unifiedDataView) doAction(GUI_ACTION_INS_LIST_ADD);
|
if (!settings.unifiedDataView) doAction(GUI_ACTION_INS_LIST_ADD);
|
||||||
|
@ -409,11 +415,15 @@ void FurnaceGUI::drawInsList() {
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_INS_LIST;
|
if (asChild) {
|
||||||
ImGui::End();
|
ImGui::EndChild();
|
||||||
|
} else {
|
||||||
|
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_INS_LIST;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUI::drawWaveList() {
|
void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
if (nextWindow==GUI_WINDOW_WAVE_LIST) {
|
if (nextWindow==GUI_WINDOW_WAVE_LIST) {
|
||||||
waveListOpen=true;
|
waveListOpen=true;
|
||||||
if (settings.unifiedDataView) {
|
if (settings.unifiedDataView) {
|
||||||
|
@ -424,8 +434,14 @@ void FurnaceGUI::drawWaveList() {
|
||||||
nextWindow=GUI_WINDOW_NOTHING;
|
nextWindow=GUI_WINDOW_NOTHING;
|
||||||
}
|
}
|
||||||
if (settings.unifiedDataView) return;
|
if (settings.unifiedDataView) return;
|
||||||
if (!waveListOpen) return;
|
if (!waveListOpen && !asChild) return;
|
||||||
if (ImGui::Begin("Wavetables",&waveListOpen,globalWinFlags)) {
|
bool began=false;
|
||||||
|
if (asChild) {
|
||||||
|
began=ImGui::BeginChild("Wavetables");
|
||||||
|
} else {
|
||||||
|
began=ImGui::Begin("Wavetables",&waveListOpen,globalWinFlags);
|
||||||
|
}
|
||||||
|
if (began) {
|
||||||
if (ImGui::Button(ICON_FA_PLUS "##WaveAdd")) {
|
if (ImGui::Button(ICON_FA_PLUS "##WaveAdd")) {
|
||||||
doAction(GUI_ACTION_WAVE_LIST_ADD);
|
doAction(GUI_ACTION_WAVE_LIST_ADD);
|
||||||
}
|
}
|
||||||
|
@ -476,11 +492,15 @@ void FurnaceGUI::drawWaveList() {
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_WAVE_LIST;
|
if (asChild) {
|
||||||
ImGui::End();
|
ImGui::EndChild();
|
||||||
|
} else {
|
||||||
|
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_WAVE_LIST;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUI::drawSampleList() {
|
void FurnaceGUI::drawSampleList(bool asChild) {
|
||||||
if (nextWindow==GUI_WINDOW_SAMPLE_LIST) {
|
if (nextWindow==GUI_WINDOW_SAMPLE_LIST) {
|
||||||
sampleListOpen=true;
|
sampleListOpen=true;
|
||||||
if (settings.unifiedDataView) {
|
if (settings.unifiedDataView) {
|
||||||
|
@ -491,8 +511,14 @@ void FurnaceGUI::drawSampleList() {
|
||||||
nextWindow=GUI_WINDOW_NOTHING;
|
nextWindow=GUI_WINDOW_NOTHING;
|
||||||
}
|
}
|
||||||
if (settings.unifiedDataView) return;
|
if (settings.unifiedDataView) return;
|
||||||
if (!sampleListOpen) return;
|
if (!sampleListOpen && !asChild) return;
|
||||||
if (ImGui::Begin("Samples",&sampleListOpen,globalWinFlags)) {
|
bool began=false;
|
||||||
|
if (asChild) {
|
||||||
|
began=ImGui::BeginChild("Samples");
|
||||||
|
} else {
|
||||||
|
began=ImGui::Begin("Samples",&sampleListOpen,globalWinFlags);
|
||||||
|
}
|
||||||
|
if (began) {
|
||||||
if (ImGui::Button(ICON_FA_FILE "##SampleAdd")) {
|
if (ImGui::Button(ICON_FA_FILE "##SampleAdd")) {
|
||||||
doAction(GUI_ACTION_SAMPLE_LIST_ADD);
|
doAction(GUI_ACTION_SAMPLE_LIST_ADD);
|
||||||
}
|
}
|
||||||
|
@ -548,8 +574,12 @@ void FurnaceGUI::drawSampleList() {
|
||||||
}
|
}
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
}
|
}
|
||||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_SAMPLE_LIST;
|
if (asChild) {
|
||||||
ImGui::End();
|
ImGui::EndChild();
|
||||||
|
} else {
|
||||||
|
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_SAMPLE_LIST;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUI::actualWaveList() {
|
void FurnaceGUI::actualWaveList() {
|
||||||
|
|
|
@ -138,12 +138,22 @@ void FurnaceGUI::drawMobileControls() {
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Button("Create Ins")) {
|
if (settings.unifiedDataView) {
|
||||||
doAction(GUI_ACTION_INS_LIST_ADD);
|
drawInsList(true);
|
||||||
|
} else {
|
||||||
|
switch (mobScene) {
|
||||||
|
case GUI_SCENE_WAVETABLE:
|
||||||
|
drawWaveList(true);
|
||||||
|
break;
|
||||||
|
case GUI_SCENE_SAMPLE:
|
||||||
|
drawSampleList(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
drawInsList(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("Data list goes here...");
|
|
||||||
|
|
||||||
if (ImGui::Button("New")) {
|
if (ImGui::Button("New")) {
|
||||||
mobileMenuOpen=false;
|
mobileMenuOpen=false;
|
||||||
//doAction(GUI_ACTION_NEW);
|
//doAction(GUI_ACTION_NEW);
|
||||||
|
|
171
src/gui/gui.cpp
171
src/gui/gui.cpp
|
@ -2544,12 +2544,15 @@ void FurnaceGUI::processPoint(SDL_Event& ev) {
|
||||||
TouchPoint* point=NULL;
|
TouchPoint* point=NULL;
|
||||||
FIND_POINT(point,ev.tfinger.fingerId);
|
FIND_POINT(point,ev.tfinger.fingerId);
|
||||||
if (point!=NULL) {
|
if (point!=NULL) {
|
||||||
|
float prevX=point->x;
|
||||||
|
float prevY=point->y;
|
||||||
point->x=ev.tfinger.x*scrW*dpiScale;
|
point->x=ev.tfinger.x*scrW*dpiScale;
|
||||||
point->y=ev.tfinger.y*scrH*dpiScale;
|
point->y=ev.tfinger.y*scrH*dpiScale;
|
||||||
point->z=ev.tfinger.pressure;
|
point->z=ev.tfinger.pressure;
|
||||||
|
|
||||||
if (point->id==0) {
|
if (point->id==0) {
|
||||||
ImGui::GetIO().AddMousePosEvent(point->x,point->y);
|
ImGui::GetIO().AddMousePosEvent(point->x,point->y);
|
||||||
|
pointMotion(point->x,point->y,point->x-prevX,point->y-prevY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2570,6 +2573,7 @@ void FurnaceGUI::processPoint(SDL_Event& ev) {
|
||||||
if (newPoint.id==0) {
|
if (newPoint.id==0) {
|
||||||
ImGui::GetIO().AddMousePosEvent(newPoint.x,newPoint.y);
|
ImGui::GetIO().AddMousePosEvent(newPoint.x,newPoint.y);
|
||||||
ImGui::GetIO().AddMouseButtonEvent(ImGuiMouseButton_Left,true);
|
ImGui::GetIO().AddMouseButtonEvent(ImGuiMouseButton_Left,true);
|
||||||
|
pointDown(newPoint.x,newPoint.y,0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2577,13 +2581,15 @@ void FurnaceGUI::processPoint(SDL_Event& ev) {
|
||||||
for (size_t i=0; i<activePoints.size(); i++) {
|
for (size_t i=0; i<activePoints.size(); i++) {
|
||||||
TouchPoint& point=activePoints[i];
|
TouchPoint& point=activePoints[i];
|
||||||
if (point.id==ev.tfinger.fingerId) {
|
if (point.id==ev.tfinger.fingerId) {
|
||||||
releasedPoints.push_back(point);
|
|
||||||
activePoints.erase(activePoints.begin()+i);
|
|
||||||
|
|
||||||
if (point.id==0) {
|
if (point.id==0) {
|
||||||
ImGui::GetIO().AddMouseButtonEvent(ImGuiMouseButton_Left,false);
|
ImGui::GetIO().AddMouseButtonEvent(ImGuiMouseButton_Left,false);
|
||||||
//ImGui::GetIO().AddMousePosEvent(-FLT_MAX,-FLT_MAX);
|
//ImGui::GetIO().AddMousePosEvent(-FLT_MAX,-FLT_MAX);
|
||||||
|
pointUp(point.x,point.y,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
releasedPoints.push_back(point);
|
||||||
|
activePoints.erase(activePoints.begin()+i);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2592,6 +2598,84 @@ void FurnaceGUI::processPoint(SDL_Event& ev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FurnaceGUI::pointDown(int x, int y, int button) {
|
||||||
|
aboutOpen=false;
|
||||||
|
if (bindSetActive) {
|
||||||
|
bindSetActive=false;
|
||||||
|
bindSetPending=false;
|
||||||
|
actionKeys[bindSetTarget]=bindSetPrevValue;
|
||||||
|
bindSetTarget=0;
|
||||||
|
bindSetPrevValue=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FurnaceGUI::pointUp(int x, int y, int button) {
|
||||||
|
if (macroDragActive || macroLoopDragActive || waveDragActive || (sampleDragActive && sampleDragMode)) {
|
||||||
|
MARK_MODIFIED;
|
||||||
|
}
|
||||||
|
if (macroDragActive && macroDragLineMode && !macroDragMouseMoved) {
|
||||||
|
displayMacroMenu=true;
|
||||||
|
}
|
||||||
|
macroDragActive=false;
|
||||||
|
macroDragBitMode=false;
|
||||||
|
macroDragInitialValue=false;
|
||||||
|
macroDragInitialValueSet=false;
|
||||||
|
macroDragLastX=-1;
|
||||||
|
macroDragLastY=-1;
|
||||||
|
macroLoopDragActive=false;
|
||||||
|
waveDragActive=false;
|
||||||
|
if (sampleDragActive) {
|
||||||
|
logD("stopping sample drag");
|
||||||
|
if (sampleDragMode) {
|
||||||
|
e->renderSamplesP();
|
||||||
|
} else {
|
||||||
|
if (sampleSelStart>sampleSelEnd) {
|
||||||
|
sampleSelStart^=sampleSelEnd;
|
||||||
|
sampleSelEnd^=sampleSelStart;
|
||||||
|
sampleSelStart^=sampleSelEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sampleDragActive=false;
|
||||||
|
if (selecting) {
|
||||||
|
if (!selectingFull) cursor=selEnd;
|
||||||
|
finishSelection();
|
||||||
|
demandScrollX=true;
|
||||||
|
if (cursor.xCoarse==selStart.xCoarse && cursor.xFine==selStart.xFine && cursor.y==selStart.y &&
|
||||||
|
cursor.xCoarse==selEnd.xCoarse && cursor.xFine==selEnd.xFine && cursor.y==selEnd.y) {
|
||||||
|
if (!settings.cursorMoveNoScroll) {
|
||||||
|
updateScroll(cursor.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FurnaceGUI::pointMotion(int x, int y, int xrel, int yrel) {
|
||||||
|
if (selecting) {
|
||||||
|
// detect whether we have to scroll
|
||||||
|
if (y<patWindowPos.y+2.0f*dpiScale) {
|
||||||
|
addScroll(-1);
|
||||||
|
}
|
||||||
|
if (y>patWindowPos.y+patWindowSize.y-2.0f*dpiScale) {
|
||||||
|
addScroll(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (macroDragActive || macroLoopDragActive || waveDragActive || sampleDragActive) {
|
||||||
|
int distance=fabs((double)xrel);
|
||||||
|
if (distance<1) distance=1;
|
||||||
|
float start=x-xrel;
|
||||||
|
float end=x;
|
||||||
|
float startY=y-yrel;
|
||||||
|
float endY=y;
|
||||||
|
for (int i=0; i<=distance; i++) {
|
||||||
|
float fraction=(float)i/(float)distance;
|
||||||
|
float x=start+(end-start)*fraction;
|
||||||
|
float y=startY+(endY-startY)*fraction;
|
||||||
|
processDrags(x,y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// how many pixels should be visible at least at x/y dir
|
// how many pixels should be visible at least at x/y dir
|
||||||
#define OOB_PIXELS_SAFETY 25
|
#define OOB_PIXELS_SAFETY 25
|
||||||
|
|
||||||
|
@ -2640,7 +2724,7 @@ bool FurnaceGUI::loop() {
|
||||||
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
|
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
|
||||||
}
|
}
|
||||||
eventTimeBegin=SDL_GetPerformanceCounter();
|
eventTimeBegin=SDL_GetPerformanceCounter();
|
||||||
bool updateWindow = false;
|
bool updateWindow=false;
|
||||||
while (SDL_PollEvent(&ev)) {
|
while (SDL_PollEvent(&ev)) {
|
||||||
WAKE_UP;
|
WAKE_UP;
|
||||||
ImGui_ImplSDL2_ProcessEvent(&ev);
|
ImGui_ImplSDL2_ProcessEvent(&ev);
|
||||||
|
@ -2658,80 +2742,14 @@ bool FurnaceGUI::loop() {
|
||||||
motionXrel*=dpiScale;
|
motionXrel*=dpiScale;
|
||||||
motionYrel*=dpiScale;
|
motionYrel*=dpiScale;
|
||||||
#endif
|
#endif
|
||||||
if (selecting) {
|
pointMotion(motionX,motionY,motionXrel,motionYrel);
|
||||||
// detect whether we have to scroll
|
|
||||||
if (motionY<patWindowPos.y+2.0f*dpiScale) {
|
|
||||||
addScroll(-1);
|
|
||||||
}
|
|
||||||
if (motionY>patWindowPos.y+patWindowSize.y-2.0f*dpiScale) {
|
|
||||||
addScroll(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (macroDragActive || macroLoopDragActive || waveDragActive || sampleDragActive) {
|
|
||||||
int distance=fabs((double)motionXrel);
|
|
||||||
if (distance<1) distance=1;
|
|
||||||
float start=motionX-motionXrel;
|
|
||||||
float end=motionX;
|
|
||||||
float startY=motionY-motionYrel;
|
|
||||||
float endY=motionY;
|
|
||||||
for (int i=0; i<=distance; i++) {
|
|
||||||
float fraction=(float)i/(float)distance;
|
|
||||||
float x=start+(end-start)*fraction;
|
|
||||||
float y=startY+(endY-startY)*fraction;
|
|
||||||
processDrags(x,y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
if (macroDragActive || macroLoopDragActive || waveDragActive || (sampleDragActive && sampleDragMode)) {
|
pointUp(ev.button.x,ev.button.y,ev.button.button);
|
||||||
MARK_MODIFIED;
|
|
||||||
}
|
|
||||||
if (macroDragActive && macroDragLineMode && !macroDragMouseMoved) {
|
|
||||||
displayMacroMenu=true;
|
|
||||||
}
|
|
||||||
macroDragActive=false;
|
|
||||||
macroDragBitMode=false;
|
|
||||||
macroDragInitialValue=false;
|
|
||||||
macroDragInitialValueSet=false;
|
|
||||||
macroDragLastX=-1;
|
|
||||||
macroDragLastY=-1;
|
|
||||||
macroLoopDragActive=false;
|
|
||||||
waveDragActive=false;
|
|
||||||
if (sampleDragActive) {
|
|
||||||
logD("stopping sample drag");
|
|
||||||
if (sampleDragMode) {
|
|
||||||
e->renderSamplesP();
|
|
||||||
} else {
|
|
||||||
if (sampleSelStart>sampleSelEnd) {
|
|
||||||
sampleSelStart^=sampleSelEnd;
|
|
||||||
sampleSelEnd^=sampleSelStart;
|
|
||||||
sampleSelStart^=sampleSelEnd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sampleDragActive=false;
|
|
||||||
if (selecting) {
|
|
||||||
if (!selectingFull) cursor=selEnd;
|
|
||||||
finishSelection();
|
|
||||||
demandScrollX=true;
|
|
||||||
if (cursor.xCoarse==selStart.xCoarse && cursor.xFine==selStart.xFine && cursor.y==selStart.y &&
|
|
||||||
cursor.xCoarse==selEnd.xCoarse && cursor.xFine==selEnd.xFine && cursor.y==selEnd.y) {
|
|
||||||
if (!settings.cursorMoveNoScroll) {
|
|
||||||
updateScroll(cursor.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
aboutOpen=false;
|
pointDown(ev.button.x,ev.button.y,ev.button.button);
|
||||||
if (bindSetActive) {
|
|
||||||
bindSetActive=false;
|
|
||||||
bindSetPending=false;
|
|
||||||
actionKeys[bindSetTarget]=bindSetPrevValue;
|
|
||||||
bindSetTarget=0;
|
|
||||||
bindSetPrevValue=0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
wheelX+=ev.wheel.x;
|
wheelX+=ev.wheel.x;
|
||||||
|
@ -3356,25 +3374,30 @@ bool FurnaceGUI::loop() {
|
||||||
switch (mobScene) {
|
switch (mobScene) {
|
||||||
case GUI_SCENE_PATTERN:
|
case GUI_SCENE_PATTERN:
|
||||||
patternOpen=true;
|
patternOpen=true;
|
||||||
|
curWindow=GUI_WINDOW_PATTERN;
|
||||||
drawPattern();
|
drawPattern();
|
||||||
drawPiano();
|
drawPiano();
|
||||||
break;
|
break;
|
||||||
case GUI_SCENE_ORDERS:
|
case GUI_SCENE_ORDERS:
|
||||||
ordersOpen=true;
|
ordersOpen=true;
|
||||||
|
curWindow=GUI_WINDOW_ORDERS;
|
||||||
drawOrders();
|
drawOrders();
|
||||||
break;
|
break;
|
||||||
case GUI_SCENE_INSTRUMENT:
|
case GUI_SCENE_INSTRUMENT:
|
||||||
insEditOpen=true;
|
insEditOpen=true;
|
||||||
|
curWindow=GUI_WINDOW_INS_EDIT;
|
||||||
drawInsEdit();
|
drawInsEdit();
|
||||||
drawPiano();
|
drawPiano();
|
||||||
break;
|
break;
|
||||||
case GUI_SCENE_WAVETABLE:
|
case GUI_SCENE_WAVETABLE:
|
||||||
waveEditOpen=true;
|
waveEditOpen=true;
|
||||||
|
curWindow=GUI_WINDOW_WAVE_EDIT;
|
||||||
drawWaveEdit();
|
drawWaveEdit();
|
||||||
drawPiano();
|
drawPiano();
|
||||||
break;
|
break;
|
||||||
case GUI_SCENE_SAMPLE:
|
case GUI_SCENE_SAMPLE:
|
||||||
sampleEditOpen=true;
|
sampleEditOpen=true;
|
||||||
|
curWindow=GUI_WINDOW_SAMPLE_EDIT;
|
||||||
drawSampleEdit();
|
drawSampleEdit();
|
||||||
drawPiano();
|
drawPiano();
|
||||||
break;
|
break;
|
||||||
|
@ -4628,7 +4651,7 @@ bool FurnaceGUI::init() {
|
||||||
portrait=(scrW<scrH);
|
portrait=(scrW<scrH);
|
||||||
logV("portrait: %d (%dx%d)",portrait,scrW,scrH);
|
logV("portrait: %d (%dx%d)",portrait,scrW,scrH);
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#if !defined(__APPLE__) && !defined(IS_MOBILE)
|
||||||
SDL_Rect displaySize;
|
SDL_Rect displaySize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1612,11 +1612,11 @@ class FurnaceGUI {
|
||||||
void drawSongInfo();
|
void drawSongInfo();
|
||||||
void drawOrders();
|
void drawOrders();
|
||||||
void drawPattern();
|
void drawPattern();
|
||||||
void drawInsList();
|
void drawInsList(bool asChild=false);
|
||||||
void drawInsEdit();
|
void drawInsEdit();
|
||||||
void drawWaveList();
|
void drawWaveList(bool asChild=false);
|
||||||
void drawWaveEdit();
|
void drawWaveEdit();
|
||||||
void drawSampleList();
|
void drawSampleList(bool asChild=false);
|
||||||
void drawSampleEdit();
|
void drawSampleEdit();
|
||||||
void drawMixer();
|
void drawMixer();
|
||||||
void drawOsc();
|
void drawOsc();
|
||||||
|
@ -1715,6 +1715,10 @@ class FurnaceGUI {
|
||||||
void keyDown(SDL_Event& ev);
|
void keyDown(SDL_Event& ev);
|
||||||
void keyUp(SDL_Event& ev);
|
void keyUp(SDL_Event& ev);
|
||||||
|
|
||||||
|
void pointDown(int x, int y, int button);
|
||||||
|
void pointUp(int x, int y, int button);
|
||||||
|
void pointMotion(int x, int y, int xrel, int yrel);
|
||||||
|
|
||||||
void openFileDialog(FurnaceGUIFileDialogs type);
|
void openFileDialog(FurnaceGUIFileDialogs type);
|
||||||
int save(String path, int dmfVersion);
|
int save(String path, int dmfVersion);
|
||||||
int load(String path);
|
int load(String path);
|
||||||
|
|
|
@ -1566,7 +1566,7 @@ void FurnaceGUI::drawInsEdit() {
|
||||||
if (!insEditOpen) return;
|
if (!insEditOpen) return;
|
||||||
if (mobileUI) {
|
if (mobileUI) {
|
||||||
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*scrH*dpiScale)):ImVec2((0.16*scrH*dpiScale)+0.5*scrW*dpiScale*mobileMenuPos,0.0f));
|
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*scrH*dpiScale)):ImVec2((0.16*scrH*dpiScale)+0.5*scrW*dpiScale*mobileMenuPos,0.0f));
|
||||||
patWindowSize=(portrait?ImVec2(scrW*dpiScale,scrH*dpiScale-(0.16*scrW*dpiScale)-(pianoOpen?(0.3*scrW*dpiScale):0.0f)):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),scrH*dpiScale-(pianoOpen?(0.3*scrH*dpiScale):0.0f)));
|
patWindowSize=(portrait?ImVec2(scrW*dpiScale,scrH*dpiScale-(0.16*scrW*dpiScale)-(pianoOpen?(0.4*scrW*dpiScale):0.0f)):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),scrH*dpiScale-(pianoOpen?(0.3*scrH*dpiScale):0.0f)));
|
||||||
ImGui::SetNextWindowPos(patWindowPos);
|
ImGui::SetNextWindowPos(patWindowPos);
|
||||||
ImGui::SetNextWindowSize(patWindowSize);
|
ImGui::SetNextWindowSize(patWindowSize);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -374,7 +374,7 @@ void FurnaceGUI::drawPattern() {
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0.0f,0.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0.0f,0.0f));
|
||||||
if (mobileUI) {
|
if (mobileUI) {
|
||||||
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*scrH*dpiScale)):ImVec2((0.16*scrH*dpiScale)+0.5*scrW*dpiScale*mobileMenuPos,0.0f));
|
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*scrH*dpiScale)):ImVec2((0.16*scrH*dpiScale)+0.5*scrW*dpiScale*mobileMenuPos,0.0f));
|
||||||
patWindowSize=(portrait?ImVec2(scrW*dpiScale,scrH*dpiScale-(0.16*scrW*dpiScale)-(pianoOpen?(0.3*scrW*dpiScale):0.0f)):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),scrH*dpiScale-(pianoOpen?(0.3*scrH*dpiScale):0.0f)));
|
patWindowSize=(portrait?ImVec2(scrW*dpiScale,scrH*dpiScale-(0.16*scrW*dpiScale)-(pianoOpen?(0.4*scrW*dpiScale):0.0f)):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),scrH*dpiScale-(pianoOpen?(0.3*scrH*dpiScale):0.0f)));
|
||||||
ImGui::SetNextWindowPos(patWindowPos);
|
ImGui::SetNextWindowPos(patWindowPos);
|
||||||
ImGui::SetNextWindowSize(patWindowSize);
|
ImGui::SetNextWindowSize(patWindowSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,29 +54,26 @@ void FurnaceGUI::drawPiano() {
|
||||||
if (!pianoOpen) return;
|
if (!pianoOpen) return;
|
||||||
if (mobileUI) {
|
if (mobileUI) {
|
||||||
ImGui::SetNextWindowPos(ImVec2(patWindowPos.x,patWindowPos.y+patWindowSize.y));
|
ImGui::SetNextWindowPos(ImVec2(patWindowPos.x,patWindowPos.y+patWindowSize.y));
|
||||||
ImGui::SetNextWindowSize(portrait?ImVec2(scrW*dpiScale,0.5*scrW*dpiScale):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),0.3*scrH*dpiScale));
|
ImGui::SetNextWindowSize(portrait?ImVec2(scrW*dpiScale,0.4*scrW*dpiScale):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),0.3*scrH*dpiScale));
|
||||||
}
|
}
|
||||||
if (ImGui::Begin("Piano",&pianoOpen,((pianoOptions)?0:ImGuiWindowFlags_NoTitleBar)|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|globalWinFlags)) {
|
if (ImGui::Begin("Piano",&pianoOpen,((pianoOptions)?0:ImGuiWindowFlags_NoTitleBar)|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|globalWinFlags)) {
|
||||||
bool oldPianoKeyPressed[180];
|
bool oldPianoKeyPressed[180];
|
||||||
memcpy(oldPianoKeyPressed,pianoKeyPressed,180*sizeof(bool));
|
memcpy(oldPianoKeyPressed,pianoKeyPressed,180*sizeof(bool));
|
||||||
memset(pianoKeyPressed,0,180*sizeof(bool));
|
memset(pianoKeyPressed,0,180*sizeof(bool));
|
||||||
if (ImGui::BeginTable("PianoLayout",(pianoOptions?2:1)+((pianoInputPadMode==1 && cursor.xFine>0)?1:0),ImGuiTableFlags_BordersInnerV)) {
|
if (ImGui::BeginTable("PianoLayout",((pianoOptions && (!mobileUI || !portrait))?2:1),ImGuiTableFlags_BordersInnerV)) {
|
||||||
int& off=(e->isPlaying() || pianoSharePosition)?pianoOffset:pianoOffsetEdit;
|
int& off=(e->isPlaying() || pianoSharePosition)?pianoOffset:pianoOffsetEdit;
|
||||||
int& oct=(e->isPlaying() || pianoSharePosition)?pianoOctaves:pianoOctavesEdit;
|
int& oct=(e->isPlaying() || pianoSharePosition)?pianoOctaves:pianoOctavesEdit;
|
||||||
bool view=(pianoView==2)?(!e->isPlaying()):pianoView;
|
bool view=(pianoView==2)?(!e->isPlaying()):pianoView;
|
||||||
if (pianoOptions) {
|
if (pianoOptions && (!mobileUI || !portrait)) {
|
||||||
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
|
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
|
||||||
}
|
}
|
||||||
if (pianoInputPadMode==1 && cursor.xFine>0) {
|
|
||||||
ImGui::TableSetupColumn("c0s",ImGuiTableColumnFlags_WidthStretch,2.0f);
|
|
||||||
}
|
|
||||||
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,1.0f);
|
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,1.0f);
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
if (pianoOptions) {
|
if (pianoOptions) {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
float optionSizeY=ImGui::GetContentRegionAvail().y*0.5-ImGui::GetStyle().ItemSpacing.y;
|
float optionSizeY=ImGui::GetContentRegionAvail().y*((mobileUI && portrait)?0.3:0.5)-ImGui::GetStyle().ItemSpacing.y;
|
||||||
ImVec2 optionSize=ImVec2(1.2f*optionSizeY,optionSizeY);
|
ImVec2 optionSize=ImVec2((mobileUI && portrait)?((ImGui::GetContentRegionAvail().x-ImGui::GetStyle().ItemSpacing.x*5.0f)/6.0f):(1.2f*optionSizeY),optionSizeY);
|
||||||
if (pianoOptionsSet) {
|
if (pianoOptionsSet) {
|
||||||
if (ImGui::Button("OFF##PianoNOff",optionSize)) {
|
if (ImGui::Button("OFF##PianoNOff",optionSize)) {
|
||||||
if (edit) noteInput(0,100);
|
if (edit) noteInput(0,100);
|
||||||
|
@ -126,6 +123,10 @@ void FurnaceGUI::drawPiano() {
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mobileUI && portrait) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
if (pianoOptionsSet) {
|
if (pianoOptionsSet) {
|
||||||
if (ImGui::Button("REL##PianoNMRel",optionSize)) {
|
if (ImGui::Button("REL##PianoNMRel",optionSize)) {
|
||||||
if (edit) noteInput(0,102);
|
if (edit) noteInput(0,102);
|
||||||
|
@ -152,6 +153,10 @@ void FurnaceGUI::drawPiano() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mobileUI && portrait) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (pianoInputPadMode==1 && cursor.xFine>0) {
|
if (pianoInputPadMode==1 && cursor.xFine>0) {
|
||||||
ImVec2 buttonSize=ImGui::GetContentRegionAvail();
|
ImVec2 buttonSize=ImGui::GetContentRegionAvail();
|
||||||
|
@ -199,192 +204,192 @@ void FurnaceGUI::drawPiano() {
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
} else {
|
||||||
}
|
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
||||||
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
ImVec2 size=ImGui::GetContentRegionAvail();
|
||||||
ImVec2 size=ImGui::GetContentRegionAvail();
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
||||||
ImDrawList* dl=ImGui::GetWindowDrawList();
|
|
||||||
|
|
||||||
ImVec2 minArea=window->DC.CursorPos;
|
ImVec2 minArea=window->DC.CursorPos;
|
||||||
ImVec2 maxArea=ImVec2(
|
ImVec2 maxArea=ImVec2(
|
||||||
minArea.x+size.x,
|
minArea.x+size.x,
|
||||||
minArea.y+size.y
|
minArea.y+size.y
|
||||||
);
|
);
|
||||||
ImRect rect=ImRect(minArea,maxArea);
|
ImRect rect=ImRect(minArea,maxArea);
|
||||||
|
|
||||||
// render piano
|
// render piano
|
||||||
//ImGui::ItemSize(size,ImGui::GetStyle().FramePadding.y);
|
//ImGui::ItemSize(size,ImGui::GetStyle().FramePadding.y);
|
||||||
if (ImGui::ItemAdd(rect,ImGui::GetID("pianoDisplay"))) {
|
if (ImGui::ItemAdd(rect,ImGui::GetID("pianoDisplay"))) {
|
||||||
ImGui::ItemHoverable(rect,ImGui::GetID("pianoDisplay"));
|
ImGui::ItemHoverable(rect,ImGui::GetID("pianoDisplay"));
|
||||||
if (view) {
|
if (view) {
|
||||||
int notes=oct*12;
|
int notes=oct*12;
|
||||||
// evaluate input
|
// evaluate input
|
||||||
for (TouchPoint& i: activePoints) {
|
for (TouchPoint& i: activePoints) {
|
||||||
if (rect.Contains(ImVec2(i.x,i.y))) {
|
if (rect.Contains(ImVec2(i.x,i.y))) {
|
||||||
int note=(((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*notes)+12*off;
|
int note=(((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*notes)+12*off;
|
||||||
if (note<0) continue;
|
|
||||||
if (note>=180) continue;
|
|
||||||
pianoKeyPressed[note]=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<notes; i++) {
|
|
||||||
int note=i+12*off;
|
|
||||||
if (note<0) continue;
|
|
||||||
if (note>=180) continue;
|
|
||||||
float pkh=pianoKeyHit[note];
|
|
||||||
ImVec4 color=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM];
|
|
||||||
if (pianoKeyPressed[note]) {
|
|
||||||
color=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_ACTIVE]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_ACTIVE];
|
|
||||||
} else {
|
|
||||||
ImVec4 colorHit=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT];
|
|
||||||
color.x+=(colorHit.x-color.x)*pkh;
|
|
||||||
color.y+=(colorHit.y-color.y)*pkh;
|
|
||||||
color.z+=(colorHit.z-color.z)*pkh;
|
|
||||||
color.w+=(colorHit.w-color.w)*pkh;
|
|
||||||
}
|
|
||||||
ImVec2 p0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/notes,0.0f));
|
|
||||||
ImVec2 p1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/notes,1.0f));
|
|
||||||
p1.x-=dpiScale;
|
|
||||||
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color));
|
|
||||||
if ((i%12)==0) {
|
|
||||||
String label=fmt::sprintf("%d",(note-60)/12);
|
|
||||||
ImVec2 pText=ImLerp(p0,p1,ImVec2(0.5f,1.0f));
|
|
||||||
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str());
|
|
||||||
pText.x-=labelSize.x*0.5f;
|
|
||||||
pText.y-=labelSize.y+ImGui::GetStyle().ItemSpacing.y;
|
|
||||||
dl->AddText(pText,0xff404040,label.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int bottomNotes=7*oct;
|
|
||||||
// evaluate input
|
|
||||||
for (TouchPoint& i: activePoints) {
|
|
||||||
if (rect.Contains(ImVec2(i.x,i.y))) {
|
|
||||||
// top
|
|
||||||
int o=((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*oct;
|
|
||||||
ImVec2 op0=ImLerp(rect.Min,rect.Max,ImVec2((float)o/oct,0.0f));
|
|
||||||
ImVec2 op1=ImLerp(rect.Min,rect.Max,ImVec2((float)(o+1)/oct,1.0f));
|
|
||||||
bool foundTopKey=false;
|
|
||||||
|
|
||||||
for (int j=0; j<5; j++) {
|
|
||||||
int note=topKeyNotes[j]+12*(o+off);
|
|
||||||
if (note<0) continue;
|
if (note<0) continue;
|
||||||
if (note>=180) continue;
|
if (note>=180) continue;
|
||||||
ImRect keyRect=ImRect(
|
pianoKeyPressed[note]=true;
|
||||||
ImLerp(op0,op1,ImVec2(topKeyStarts[j]-0.05f,0.0f)),
|
|
||||||
ImLerp(op0,op1,ImVec2(topKeyStarts[j]+0.05f,0.64f))
|
|
||||||
);
|
|
||||||
if (keyRect.Contains(ImVec2(i.x,i.y))) {
|
|
||||||
pianoKeyPressed[note]=true;
|
|
||||||
foundTopKey=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (foundTopKey) continue;
|
|
||||||
|
|
||||||
// bottom
|
|
||||||
int n=((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*bottomNotes;
|
|
||||||
int note=bottomKeyNotes[n%7]+12*((n/7)+off);
|
|
||||||
if (note<0) continue;
|
|
||||||
if (note>=180) continue;
|
|
||||||
pianoKeyPressed[note]=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<bottomNotes; i++) {
|
|
||||||
int note=bottomKeyNotes[i%7]+12*((i/7)+off);
|
|
||||||
if (note<0) continue;
|
|
||||||
if (note>=180) continue;
|
|
||||||
|
|
||||||
float pkh=pianoKeyHit[note];
|
|
||||||
ImVec4 color=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM];
|
|
||||||
if (pianoKeyPressed[note]) {
|
|
||||||
color=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_ACTIVE];
|
|
||||||
} else {
|
|
||||||
ImVec4 colorHit=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT];
|
|
||||||
color.x+=(colorHit.x-color.x)*pkh;
|
|
||||||
color.y+=(colorHit.y-color.y)*pkh;
|
|
||||||
color.z+=(colorHit.z-color.z)*pkh;
|
|
||||||
color.w+=(colorHit.w-color.w)*pkh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 p0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/bottomNotes,0.0f));
|
for (int i=0; i<notes; i++) {
|
||||||
ImVec2 p1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/bottomNotes,1.0f));
|
int note=i+12*off;
|
||||||
p1.x-=dpiScale;
|
|
||||||
|
|
||||||
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color));
|
|
||||||
if ((i%7)==0) {
|
|
||||||
String label=fmt::sprintf("%d",(note-60)/12);
|
|
||||||
ImVec2 pText=ImLerp(p0,p1,ImVec2(0.5f,1.0f));
|
|
||||||
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str());
|
|
||||||
pText.x-=labelSize.x*0.5f;
|
|
||||||
pText.y-=labelSize.y+ImGui::GetStyle().ItemSpacing.y;
|
|
||||||
dl->AddText(pText,0xff404040,label.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<oct; i++) {
|
|
||||||
ImVec2 op0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/oct,0.0f));
|
|
||||||
ImVec2 op1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/oct,1.0f));
|
|
||||||
|
|
||||||
for (int j=0; j<5; j++) {
|
|
||||||
int note=topKeyNotes[j]+12*(i+off);
|
|
||||||
if (note<0) continue;
|
if (note<0) continue;
|
||||||
if (note>=180) continue;
|
if (note>=180) continue;
|
||||||
float pkh=pianoKeyHit[note];
|
float pkh=pianoKeyHit[note];
|
||||||
ImVec4 color=uiColors[GUI_COLOR_PIANO_KEY_TOP];
|
ImVec4 color=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM];
|
||||||
if (pianoKeyPressed[note]) {
|
if (pianoKeyPressed[note]) {
|
||||||
color=uiColors[GUI_COLOR_PIANO_KEY_TOP_ACTIVE];
|
color=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_ACTIVE]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_ACTIVE];
|
||||||
} else {
|
} else {
|
||||||
ImVec4 colorHit=uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT];
|
ImVec4 colorHit=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT];
|
||||||
color.x+=(colorHit.x-color.x)*pkh;
|
color.x+=(colorHit.x-color.x)*pkh;
|
||||||
color.y+=(colorHit.y-color.y)*pkh;
|
color.y+=(colorHit.y-color.y)*pkh;
|
||||||
color.z+=(colorHit.z-color.z)*pkh;
|
color.z+=(colorHit.z-color.z)*pkh;
|
||||||
color.w+=(colorHit.w-color.w)*pkh;
|
color.w+=(colorHit.w-color.w)*pkh;
|
||||||
}
|
}
|
||||||
ImVec2 p0=ImLerp(op0,op1,ImVec2(topKeyStarts[j]-0.05f,0.0f));
|
ImVec2 p0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/notes,0.0f));
|
||||||
ImVec2 p1=ImLerp(op0,op1,ImVec2(topKeyStarts[j]+0.05f,0.64f));
|
ImVec2 p1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/notes,1.0f));
|
||||||
dl->AddRectFilled(p0,p1,ImGui::GetColorU32(uiColors[GUI_COLOR_PIANO_BACKGROUND]));
|
|
||||||
p0.x+=dpiScale;
|
|
||||||
p1.x-=dpiScale;
|
p1.x-=dpiScale;
|
||||||
p1.y-=dpiScale;
|
|
||||||
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color));
|
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color));
|
||||||
|
if ((i%12)==0) {
|
||||||
|
String label=fmt::sprintf("%d",(note-60)/12);
|
||||||
|
ImVec2 pText=ImLerp(p0,p1,ImVec2(0.5f,1.0f));
|
||||||
|
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str());
|
||||||
|
pText.x-=labelSize.x*0.5f;
|
||||||
|
pText.y-=labelSize.y+ImGui::GetStyle().ItemSpacing.y;
|
||||||
|
dl->AddText(pText,0xff404040,label.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int bottomNotes=7*oct;
|
||||||
|
// evaluate input
|
||||||
|
for (TouchPoint& i: activePoints) {
|
||||||
|
if (rect.Contains(ImVec2(i.x,i.y))) {
|
||||||
|
// top
|
||||||
|
int o=((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*oct;
|
||||||
|
ImVec2 op0=ImLerp(rect.Min,rect.Max,ImVec2((float)o/oct,0.0f));
|
||||||
|
ImVec2 op1=ImLerp(rect.Min,rect.Max,ImVec2((float)(o+1)/oct,1.0f));
|
||||||
|
bool foundTopKey=false;
|
||||||
|
|
||||||
|
for (int j=0; j<5; j++) {
|
||||||
|
int note=topKeyNotes[j]+12*(o+off);
|
||||||
|
if (note<0) continue;
|
||||||
|
if (note>=180) continue;
|
||||||
|
ImRect keyRect=ImRect(
|
||||||
|
ImLerp(op0,op1,ImVec2(topKeyStarts[j]-0.05f,0.0f)),
|
||||||
|
ImLerp(op0,op1,ImVec2(topKeyStarts[j]+0.05f,0.64f))
|
||||||
|
);
|
||||||
|
if (keyRect.Contains(ImVec2(i.x,i.y))) {
|
||||||
|
pianoKeyPressed[note]=true;
|
||||||
|
foundTopKey=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (foundTopKey) continue;
|
||||||
|
|
||||||
|
// bottom
|
||||||
|
int n=((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*bottomNotes;
|
||||||
|
int note=bottomKeyNotes[n%7]+12*((n/7)+off);
|
||||||
|
if (note<0) continue;
|
||||||
|
if (note>=180) continue;
|
||||||
|
pianoKeyPressed[note]=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<bottomNotes; i++) {
|
||||||
|
int note=bottomKeyNotes[i%7]+12*((i/7)+off);
|
||||||
|
if (note<0) continue;
|
||||||
|
if (note>=180) continue;
|
||||||
|
|
||||||
|
float pkh=pianoKeyHit[note];
|
||||||
|
ImVec4 color=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM];
|
||||||
|
if (pianoKeyPressed[note]) {
|
||||||
|
color=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_ACTIVE];
|
||||||
|
} else {
|
||||||
|
ImVec4 colorHit=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT];
|
||||||
|
color.x+=(colorHit.x-color.x)*pkh;
|
||||||
|
color.y+=(colorHit.y-color.y)*pkh;
|
||||||
|
color.z+=(colorHit.z-color.z)*pkh;
|
||||||
|
color.w+=(colorHit.w-color.w)*pkh;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImVec2 p0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/bottomNotes,0.0f));
|
||||||
|
ImVec2 p1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/bottomNotes,1.0f));
|
||||||
|
p1.x-=dpiScale;
|
||||||
|
|
||||||
|
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color));
|
||||||
|
if ((i%7)==0) {
|
||||||
|
String label=fmt::sprintf("%d",(note-60)/12);
|
||||||
|
ImVec2 pText=ImLerp(p0,p1,ImVec2(0.5f,1.0f));
|
||||||
|
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str());
|
||||||
|
pText.x-=labelSize.x*0.5f;
|
||||||
|
pText.y-=labelSize.y+ImGui::GetStyle().ItemSpacing.y;
|
||||||
|
dl->AddText(pText,0xff404040,label.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<oct; i++) {
|
||||||
|
ImVec2 op0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/oct,0.0f));
|
||||||
|
ImVec2 op1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/oct,1.0f));
|
||||||
|
|
||||||
|
for (int j=0; j<5; j++) {
|
||||||
|
int note=topKeyNotes[j]+12*(i+off);
|
||||||
|
if (note<0) continue;
|
||||||
|
if (note>=180) continue;
|
||||||
|
float pkh=pianoKeyHit[note];
|
||||||
|
ImVec4 color=uiColors[GUI_COLOR_PIANO_KEY_TOP];
|
||||||
|
if (pianoKeyPressed[note]) {
|
||||||
|
color=uiColors[GUI_COLOR_PIANO_KEY_TOP_ACTIVE];
|
||||||
|
} else {
|
||||||
|
ImVec4 colorHit=uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT];
|
||||||
|
color.x+=(colorHit.x-color.x)*pkh;
|
||||||
|
color.y+=(colorHit.y-color.y)*pkh;
|
||||||
|
color.z+=(colorHit.z-color.z)*pkh;
|
||||||
|
color.w+=(colorHit.w-color.w)*pkh;
|
||||||
|
}
|
||||||
|
ImVec2 p0=ImLerp(op0,op1,ImVec2(topKeyStarts[j]-0.05f,0.0f));
|
||||||
|
ImVec2 p1=ImLerp(op0,op1,ImVec2(topKeyStarts[j]+0.05f,0.64f));
|
||||||
|
dl->AddRectFilled(p0,p1,ImGui::GetColorU32(uiColors[GUI_COLOR_PIANO_BACKGROUND]));
|
||||||
|
p0.x+=dpiScale;
|
||||||
|
p1.x-=dpiScale;
|
||||||
|
p1.y-=dpiScale;
|
||||||
|
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const float reduction=ImGui::GetIO().DeltaTime*60.0f*0.12;
|
||||||
|
for (int i=0; i<180; i++) {
|
||||||
|
pianoKeyHit[i]-=reduction;
|
||||||
|
if (pianoKeyHit[i]<0) pianoKeyHit[i]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
||||||
|
pianoOptions=!pianoOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// first check released keys
|
||||||
|
for (int i=0; i<180; i++) {
|
||||||
|
int note=i-60;
|
||||||
|
if (!pianoKeyPressed[i]) {
|
||||||
|
if (pianoKeyPressed[i]!=oldPianoKeyPressed[i]) {
|
||||||
|
e->synchronized([this,note]() {
|
||||||
|
e->autoNoteOff(-1,note);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// then pressed ones
|
||||||
const float reduction=ImGui::GetIO().DeltaTime*60.0f*0.12;
|
|
||||||
for (int i=0; i<180; i++) {
|
for (int i=0; i<180; i++) {
|
||||||
pianoKeyHit[i]-=reduction;
|
int note=i-60;
|
||||||
if (pianoKeyHit[i]<0) pianoKeyHit[i]=0;
|
if (pianoKeyPressed[i]) {
|
||||||
}
|
if (pianoKeyPressed[i]!=oldPianoKeyPressed[i]) {
|
||||||
}
|
e->synchronized([this,note]() {
|
||||||
|
e->autoNoteOn(-1,curIns,note);
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
});
|
||||||
pianoOptions=!pianoOptions;
|
if (edit) noteInput(note,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// first check released keys
|
|
||||||
for (int i=0; i<180; i++) {
|
|
||||||
int note=i-60;
|
|
||||||
if (!pianoKeyPressed[i]) {
|
|
||||||
if (pianoKeyPressed[i]!=oldPianoKeyPressed[i]) {
|
|
||||||
e->synchronized([this,note]() {
|
|
||||||
e->autoNoteOff(-1,note);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// then pressed ones
|
|
||||||
for (int i=0; i<180; i++) {
|
|
||||||
int note=i-60;
|
|
||||||
if (pianoKeyPressed[i]) {
|
|
||||||
if (pianoKeyPressed[i]!=oldPianoKeyPressed[i]) {
|
|
||||||
e->synchronized([this,note]() {
|
|
||||||
e->autoNoteOn(-1,curIns,note);
|
|
||||||
});
|
|
||||||
if (edit) noteInput(note,0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
if (!sampleEditOpen) return;
|
if (!sampleEditOpen) return;
|
||||||
if (mobileUI) {
|
if (mobileUI) {
|
||||||
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*scrH*dpiScale)):ImVec2((0.16*scrH*dpiScale)+0.5*scrW*dpiScale*mobileMenuPos,0.0f));
|
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*scrH*dpiScale)):ImVec2((0.16*scrH*dpiScale)+0.5*scrW*dpiScale*mobileMenuPos,0.0f));
|
||||||
patWindowSize=(portrait?ImVec2(scrW*dpiScale,scrH*dpiScale-(0.16*scrW*dpiScale)-(pianoOpen?(0.3*scrW*dpiScale):0.0f)):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),scrH*dpiScale-(pianoOpen?(0.3*scrH*dpiScale):0.0f)));
|
patWindowSize=(portrait?ImVec2(scrW*dpiScale,scrH*dpiScale-(0.16*scrW*dpiScale)-(pianoOpen?(0.4*scrW*dpiScale):0.0f)):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),scrH*dpiScale-(pianoOpen?(0.3*scrH*dpiScale):0.0f)));
|
||||||
ImGui::SetNextWindowPos(patWindowPos);
|
ImGui::SetNextWindowPos(patWindowPos);
|
||||||
ImGui::SetNextWindowSize(patWindowSize);
|
ImGui::SetNextWindowSize(patWindowSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ void FurnaceGUI::drawWaveEdit() {
|
||||||
float wavePreview[257];
|
float wavePreview[257];
|
||||||
if (mobileUI) {
|
if (mobileUI) {
|
||||||
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*scrH*dpiScale)):ImVec2((0.16*scrH*dpiScale)+0.5*scrW*dpiScale*mobileMenuPos,0.0f));
|
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*scrH*dpiScale)):ImVec2((0.16*scrH*dpiScale)+0.5*scrW*dpiScale*mobileMenuPos,0.0f));
|
||||||
patWindowSize=(portrait?ImVec2(scrW*dpiScale,scrH*dpiScale-(0.16*scrW*dpiScale)-(pianoOpen?(0.3*scrW*dpiScale):0.0f)):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),scrH*dpiScale-(pianoOpen?(0.3*scrH*dpiScale):0.0f)));
|
patWindowSize=(portrait?ImVec2(scrW*dpiScale,scrH*dpiScale-(0.16*scrW*dpiScale)-(pianoOpen?(0.4*scrW*dpiScale):0.0f)):ImVec2(scrW*dpiScale-(0.16*scrH*dpiScale),scrH*dpiScale-(pianoOpen?(0.3*scrH*dpiScale):0.0f)));
|
||||||
ImGui::SetNextWindowPos(patWindowPos);
|
ImGui::SetNextWindowPos(patWindowPos);
|
||||||
ImGui::SetNextWindowSize(patWindowSize);
|
ImGui::SetNextWindowSize(patWindowSize);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue