Merge pull request #773 from LeviathaninWaves/furnace-testing

Add hovering mobile edit button
This commit is contained in:
tildearrow 2022-12-08 15:27:44 -05:00 committed by GitHub
commit d05819ba99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 3 deletions

26
src/gui/editControls.cpp Normal file → Executable file
View File

@ -48,12 +48,36 @@ void FurnaceGUI::drawMobileControls() {
} }
} }
} }
if (dragMobileEditButton) {
mobileEditButtonPos.x=((ImGui::GetMousePos().x/canvasW)-((portrait?0.16*canvasW:0.16*canvasH)/2)/canvasW);
mobileEditButtonPos.y=((ImGui::GetMousePos().y/canvasH)-((portrait?0.16*canvasW:0.16*canvasH)/2)/canvasH);
}
if (mobileEditButtonPos.x<0) mobileEditButtonPos.x=0;
if (mobileEditButtonPos.x>1) mobileEditButtonPos.x=1;
if (mobileEditButtonPos.y<0) mobileEditButtonPos.y=0;
if (mobileEditButtonPos.y>1) mobileEditButtonPos.y=1;
ImGui::SetNextWindowPos(ImVec2(mobileEditButtonPos.x*canvasW, mobileEditButtonPos.y*canvasH));
ImGui::SetNextWindowSize(portrait?ImVec2(0.16*canvasW,0.16*canvasW):ImVec2(0.16*canvasH,0.16*canvasH));
if (ImGui::Begin("MobileEdit",NULL,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoBackground|ImGuiWindowFlags_NoDecoration|globalWinFlags)) {
float avail=portrait?ImGui::GetContentRegionAvail().y:ImGui::GetContentRegionAvail().x;
mobileEditButtonSize=ImVec2(avail,avail);
if (ImGui::Button("Edit", mobileEditButtonSize)) {
//click
}
if (ImGui::IsItemActive()) {
if (CHECK_BUTTON_LONG_HOLD) {
//drag
if (!dragMobileEditButton) dragMobileEditButton=!dragMobileEditButton;
}
}
}
ImGui::End();
ImGui::SetNextWindowPos(portrait?ImVec2(0.0f,((1.0-mobileMenuPos*0.65)*canvasH)-(0.16*canvasW)):ImVec2(0.5*canvasW*mobileMenuPos,0.0f)); ImGui::SetNextWindowPos(portrait?ImVec2(0.0f,((1.0-mobileMenuPos*0.65)*canvasH)-(0.16*canvasW)):ImVec2(0.5*canvasW*mobileMenuPos,0.0f));
ImGui::SetNextWindowSize(portrait?ImVec2(canvasW,0.16*canvasW):ImVec2(0.16*canvasH,canvasH)); ImGui::SetNextWindowSize(portrait?ImVec2(canvasW,0.16*canvasW):ImVec2(0.16*canvasH,canvasH));
if (ImGui::Begin("Mobile Controls",NULL,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|globalWinFlags)) { if (ImGui::Begin("Mobile Controls",NULL,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|globalWinFlags)) {
float avail=portrait?ImGui::GetContentRegionAvail().y:ImGui::GetContentRegionAvail().x; float avail=portrait?ImGui::GetContentRegionAvail().y:ImGui::GetContentRegionAvail().x;
ImVec2 buttonSize=ImVec2(avail,avail); ImVec2 buttonSize=ImVec2(avail,avail);
const char* mobButtonName=ICON_FA_CHEVRON_RIGHT "##MobileMenu"; const char* mobButtonName=ICON_FA_CHEVRON_RIGHT "##MobileMenu";
if (portrait) mobButtonName=ICON_FA_CHEVRON_UP "##MobileMenu"; if (portrait) mobButtonName=ICON_FA_CHEVRON_UP "##MobileMenu";
if (mobileMenuOpen) { if (mobileMenuOpen) {

7
src/gui/gui.cpp Normal file → Executable file
View File

@ -2939,6 +2939,9 @@ void FurnaceGUI::pointUp(int x, int y, int button) {
mobileMenuOpen=(mobileMenuPos>=0.15f); mobileMenuOpen=(mobileMenuPos>=0.15f);
} }
} }
if (dragMobileEditButton) {
dragMobileEditButton=false;
}
if (selecting) { if (selecting) {
if (!selectingFull) cursor=selEnd; if (!selectingFull) cursor=selEnd;
finishSelection(); finishSelection();
@ -5663,6 +5666,8 @@ FurnaceGUI::FurnaceGUI():
waveEditStyle(0), waveEditStyle(0),
displayInsTypeListMakeInsSample(-1), displayInsTypeListMakeInsSample(-1),
mobileMenuPos(0.0f), mobileMenuPos(0.0f),
mobileEditButtonPos(0.0f,0.0f),
mobileEditButtonSize(0.0f,0.0f),
autoButtonSize(0.0f), autoButtonSize(0.0f),
curSysSection(NULL), curSysSection(NULL),
pendingRawSampleDepth(8), pendingRawSampleDepth(8),
@ -5794,12 +5799,14 @@ FurnaceGUI::FurnaceGUI():
orderScrollLocked(false), orderScrollLocked(false),
orderScrollTolerance(false), orderScrollTolerance(false),
dragMobileMenu(false), dragMobileMenu(false),
dragMobileEditButton(false),
curWindow(GUI_WINDOW_NOTHING), curWindow(GUI_WINDOW_NOTHING),
nextWindow(GUI_WINDOW_NOTHING), nextWindow(GUI_WINDOW_NOTHING),
curWindowLast(GUI_WINDOW_NOTHING), curWindowLast(GUI_WINDOW_NOTHING),
curWindowThreadSafe(GUI_WINDOW_NOTHING), curWindowThreadSafe(GUI_WINDOW_NOTHING),
lastPatternWidth(0.0f), lastPatternWidth(0.0f),
longThreshold(0.48f), longThreshold(0.48f),
buttonLongThreshold(0.20f),
latchNote(-1), latchNote(-1),
latchIns(-2), latchIns(-2),
latchVol(-1), latchVol(-1),

7
src/gui/gui.h Normal file → Executable file
View File

@ -54,7 +54,7 @@
} }
#define CHECK_LONG_HOLD (mobileUI && ImGui::GetIO().MouseDown[ImGuiMouseButton_Left] && ImGui::GetIO().MouseDownDuration[ImGuiMouseButton_Left]>=longThreshold && ImGui::GetIO().MouseDownDurationPrev[ImGuiMouseButton_Left]<longThreshold && ImGui::GetIO().MouseDragMaxDistanceSqr[ImGuiMouseButton_Left]<=ImGui::GetIO().ConfigInertialScrollToleranceSqr) #define CHECK_LONG_HOLD (mobileUI && ImGui::GetIO().MouseDown[ImGuiMouseButton_Left] && ImGui::GetIO().MouseDownDuration[ImGuiMouseButton_Left]>=longThreshold && ImGui::GetIO().MouseDownDurationPrev[ImGuiMouseButton_Left]<longThreshold && ImGui::GetIO().MouseDragMaxDistanceSqr[ImGuiMouseButton_Left]<=ImGui::GetIO().ConfigInertialScrollToleranceSqr)
#define CHECK_BUTTON_LONG_HOLD (mobileUI && ImGui::GetIO().MouseDown[ImGuiMouseButton_Left] && ImGui::GetIO().MouseDownDuration[ImGuiMouseButton_Left]>=buttonLongThreshold && ImGui::GetIO().MouseDownDurationPrev[ImGuiMouseButton_Left]<buttonLongThreshold)
// for now // for now
#define NOTIFY_LONG_HOLD \ #define NOTIFY_LONG_HOLD \
if (vibrator && vibratorAvailable) { \ if (vibrator && vibratorAvailable) { \
@ -1096,6 +1096,8 @@ class FurnaceGUI {
int waveEditStyle; int waveEditStyle;
int displayInsTypeListMakeInsSample; int displayInsTypeListMakeInsSample;
float mobileMenuPos, autoButtonSize; float mobileMenuPos, autoButtonSize;
ImVec2 mobileEditButtonPos;
ImVec2 mobileEditButtonSize;
const int* curSysSection; const int* curSysSection;
DivInstrumentFM opllPreview; DivInstrumentFM opllPreview;
@ -1435,13 +1437,14 @@ class FurnaceGUI {
SelectionPoint selStart, selEnd, cursor, cursorDrag, dragStart, dragEnd; SelectionPoint selStart, selEnd, cursor, cursorDrag, dragStart, dragEnd;
bool selecting, selectingFull, dragging, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI; bool selecting, selectingFull, dragging, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI;
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, waveSigned, waveGenVisible, lockLayout, editOptsVisible, latchNibble, nonLatchNibble; bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, waveSigned, waveGenVisible, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
bool keepLoopAlive, orderScrollLocked, orderScrollTolerance, dragMobileMenu; bool keepLoopAlive, orderScrollLocked, orderScrollTolerance, dragMobileMenu, dragMobileEditButton;
FurnaceGUIWindows curWindow, nextWindow, curWindowLast; FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
std::atomic<FurnaceGUIWindows> curWindowThreadSafe; std::atomic<FurnaceGUIWindows> curWindowThreadSafe;
float peak[2]; float peak[2];
float patChanX[DIV_MAX_CHANS+1]; float patChanX[DIV_MAX_CHANS+1];
float patChanSlideY[DIV_MAX_CHANS+1]; float patChanSlideY[DIV_MAX_CHANS+1];
float lastPatternWidth, longThreshold; float lastPatternWidth, longThreshold;
float buttonLongThreshold;
String nextDesc; String nextDesc;
String nextDescName; String nextDescName;