mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 06:53:01 +00:00
Merge pull request #773 from LeviathaninWaves/furnace-testing
Add hovering mobile edit button
This commit is contained in:
commit
d05819ba99
3 changed files with 37 additions and 3 deletions
26
src/gui/editControls.cpp
Normal file → Executable file
26
src/gui/editControls.cpp
Normal file → Executable 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::SetNextWindowSize(portrait?ImVec2(canvasW,0.16*canvasW):ImVec2(0.16*canvasH,canvasH));
|
||||
if (ImGui::Begin("Mobile Controls",NULL,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|globalWinFlags)) {
|
||||
float avail=portrait?ImGui::GetContentRegionAvail().y:ImGui::GetContentRegionAvail().x;
|
||||
ImVec2 buttonSize=ImVec2(avail,avail);
|
||||
|
||||
const char* mobButtonName=ICON_FA_CHEVRON_RIGHT "##MobileMenu";
|
||||
if (portrait) mobButtonName=ICON_FA_CHEVRON_UP "##MobileMenu";
|
||||
if (mobileMenuOpen) {
|
||||
|
|
7
src/gui/gui.cpp
Normal file → Executable file
7
src/gui/gui.cpp
Normal file → Executable file
|
@ -2939,6 +2939,9 @@ void FurnaceGUI::pointUp(int x, int y, int button) {
|
|||
mobileMenuOpen=(mobileMenuPos>=0.15f);
|
||||
}
|
||||
}
|
||||
if (dragMobileEditButton) {
|
||||
dragMobileEditButton=false;
|
||||
}
|
||||
if (selecting) {
|
||||
if (!selectingFull) cursor=selEnd;
|
||||
finishSelection();
|
||||
|
@ -5663,6 +5666,8 @@ FurnaceGUI::FurnaceGUI():
|
|||
waveEditStyle(0),
|
||||
displayInsTypeListMakeInsSample(-1),
|
||||
mobileMenuPos(0.0f),
|
||||
mobileEditButtonPos(0.0f,0.0f),
|
||||
mobileEditButtonSize(0.0f,0.0f),
|
||||
autoButtonSize(0.0f),
|
||||
curSysSection(NULL),
|
||||
pendingRawSampleDepth(8),
|
||||
|
@ -5794,12 +5799,14 @@ FurnaceGUI::FurnaceGUI():
|
|||
orderScrollLocked(false),
|
||||
orderScrollTolerance(false),
|
||||
dragMobileMenu(false),
|
||||
dragMobileEditButton(false),
|
||||
curWindow(GUI_WINDOW_NOTHING),
|
||||
nextWindow(GUI_WINDOW_NOTHING),
|
||||
curWindowLast(GUI_WINDOW_NOTHING),
|
||||
curWindowThreadSafe(GUI_WINDOW_NOTHING),
|
||||
lastPatternWidth(0.0f),
|
||||
longThreshold(0.48f),
|
||||
buttonLongThreshold(0.20f),
|
||||
latchNote(-1),
|
||||
latchIns(-2),
|
||||
latchVol(-1),
|
||||
|
|
7
src/gui/gui.h
Normal file → Executable file
7
src/gui/gui.h
Normal file → Executable 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_BUTTON_LONG_HOLD (mobileUI && ImGui::GetIO().MouseDown[ImGuiMouseButton_Left] && ImGui::GetIO().MouseDownDuration[ImGuiMouseButton_Left]>=buttonLongThreshold && ImGui::GetIO().MouseDownDurationPrev[ImGuiMouseButton_Left]<buttonLongThreshold)
|
||||
// for now
|
||||
#define NOTIFY_LONG_HOLD \
|
||||
if (vibrator && vibratorAvailable) { \
|
||||
|
@ -1096,6 +1096,8 @@ class FurnaceGUI {
|
|||
int waveEditStyle;
|
||||
int displayInsTypeListMakeInsSample;
|
||||
float mobileMenuPos, autoButtonSize;
|
||||
ImVec2 mobileEditButtonPos;
|
||||
ImVec2 mobileEditButtonSize;
|
||||
const int* curSysSection;
|
||||
DivInstrumentFM opllPreview;
|
||||
|
||||
|
@ -1435,13 +1437,14 @@ class FurnaceGUI {
|
|||
SelectionPoint selStart, selEnd, cursor, cursorDrag, dragStart, dragEnd;
|
||||
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 keepLoopAlive, orderScrollLocked, orderScrollTolerance, dragMobileMenu;
|
||||
bool keepLoopAlive, orderScrollLocked, orderScrollTolerance, dragMobileMenu, dragMobileEditButton;
|
||||
FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
|
||||
std::atomic<FurnaceGUIWindows> curWindowThreadSafe;
|
||||
float peak[2];
|
||||
float patChanX[DIV_MAX_CHANS+1];
|
||||
float patChanSlideY[DIV_MAX_CHANS+1];
|
||||
float lastPatternWidth, longThreshold;
|
||||
float buttonLongThreshold;
|
||||
String nextDesc;
|
||||
String nextDescName;
|
||||
|
||||
|
|
Loading…
Reference in a new issue