GUI: half working mobile edit options

This commit is contained in:
tildearrow 2022-12-11 12:36:41 -05:00
parent f331e50041
commit 6349ebbfad
5 changed files with 159 additions and 7 deletions

View file

@ -174,6 +174,9 @@ void FurnaceGUI::doAction(int what) {
case GUI_ACTION_PANIC: case GUI_ACTION_PANIC:
e->syncReset(); e->syncReset();
break; break;
case GUI_ACTION_CLEAR:
showWarning("Are you sure you want to clear... (cannot be undone!)",GUI_WARN_CLEAR);
break;
case GUI_ACTION_WINDOW_EDIT_CONTROLS: case GUI_ACTION_WINDOW_EDIT_CONTROLS:
nextWindow=GUI_WINDOW_EDIT_CONTROLS; nextWindow=GUI_WINDOW_EDIT_CONTROLS;
@ -554,6 +557,10 @@ void FurnaceGUI::doAction(int what) {
break; break;
case GUI_ACTION_PAT_LATCH: // TODO case GUI_ACTION_PAT_LATCH: // TODO
break; break;
case GUI_ACTION_PAT_SCROLL_MODE: // TODO
break;
case GUI_ACTION_PAT_CLEAR_LATCH: // TODO
break;
case GUI_ACTION_INS_LIST_ADD: case GUI_ACTION_INS_LIST_ADD:
curIns=e->addInstrument(cursor.xCoarse); curIns=e->addInstrument(cursor.xCoarse);

View file

@ -25,20 +25,146 @@
// 1: half // 1: half
// 2: half // 2: half
// 3: quarter // 3: quarter
float mobileButtonAngles[4][8]={ const float mobileButtonAngles[4][8]={
{0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875}, {0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875},
{0.8333, 0.0, 0.1667, 0.8, 0.9, 0.0, 0.1, 0.2}, {0.8333, 0.0, 0.1667, 0.8, 0.9, 0.0, 0.1, 0.2},
{0.0833, 0.25, 0.4167, 0.45, 0.35, 0.25, 0.15, 0.05}, {0.0833, 0.25, 0.4167, 0.45, 0.35, 0.25, 0.15, 0.05},
{0.25, 0.125, 0.0, 0.25, 0.1875, 0.125, 0.0625, 0.0} {0.25, 0.125, 0.0, 0.25, 0.1875, 0.125, 0.0625, 0.0}
}; };
float mobileButtonDistances[4][8]={ const float mobileButtonDistances[4][8]={
{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0},
{0.8, 0.75, 0.8, 1.5, 1.5, 1.5, 1.5, 1.5}, {0.8, 0.75, 0.8, 1.5, 1.5, 1.5, 1.5, 1.5},
{0.8, 0.75, 0.8, 1.5, 1.5, 1.5, 1.5, 1.5}, {0.8, 0.75, 0.8, 1.5, 1.5, 1.5, 1.5, 1.5},
{0.9, 1.0, 0.9, 1.78, 1.82, 1.95, 1.82, 1.78} {0.9, 1.0, 0.9, 1.78, 1.82, 1.95, 1.82, 1.78}
}; };
const char* mobileButtonLabels[32]={
// page 1
"cut",
"copy",
"paste",
"delete",
"select\nall",
"piano",
"undo",
"redo",
// page 2
"paste\nmix",
"paste\nmix bg",
"paste\nins",
"paste\nins bg",
"paste\nflood",
"paste\noverflow",
"transpose\nnotes",
"transpose\nvalues",
// page 3
"change\nins",
"find/\nreplace",
"collapse",
"expand",
"flip",
"invert",
"interpolate",
"scale",
// page 4
"fade",
"randomize",
"opmask",
"scroll\nmode",
"input\nlatch",
"set\nlatch",
"clear\nlatch",
"clear"
};
const int mobileButtonActions[32]={
// page 1
GUI_ACTION_PAT_CUT,
GUI_ACTION_PAT_COPY,
GUI_ACTION_PAT_PASTE,
GUI_ACTION_PAT_DELETE,
GUI_ACTION_PAT_SELECT_ALL,
0,
GUI_ACTION_UNDO,
GUI_ACTION_REDO,
// page 2
GUI_ACTION_PAT_PASTE_MIX,
GUI_ACTION_PAT_PASTE_MIX_BG,
0,
0,
GUI_ACTION_PAT_PASTE_FLOOD,
GUI_ACTION_PAT_PASTE_OVERFLOW,
0,
0,
// page 3
0,
GUI_ACTION_WINDOW_FIND,
GUI_ACTION_PAT_COLLAPSE_ROWS,
GUI_ACTION_PAT_EXPAND_ROWS,
GUI_ACTION_PAT_FLIP_SELECTION,
GUI_ACTION_PAT_INVERT_VALUES,
GUI_ACTION_PAT_INTERPOLATE,
0,
// page 4
GUI_ACTION_PAT_FADE,
0,
0,
GUI_ACTION_PAT_SCROLL_MODE,
0,
GUI_ACTION_PAT_LATCH,
GUI_ACTION_PAT_CLEAR_LATCH,
GUI_ACTION_CLEAR
};
const bool mobileButtonPersist[32]={
// page 1
false,
false,
false,
false,
true,
true,
true,
true,
// page 2
false,
false,
false,
false,
false,
false,
false,
false,
// page 3
false,
false,
false,
false,
false,
false,
false,
false,
// page 4
false,
false,
false,
true,
false,
false,
false,
false,
};
void FurnaceGUI::drawMobileControls() { void FurnaceGUI::drawMobileControls() {
float timeScale=1.0f/(60.0f*ImGui::GetIO().DeltaTime); float timeScale=1.0f/(60.0f*ImGui::GetIO().DeltaTime);
if (dragMobileMenu) { if (dragMobileMenu) {
@ -106,6 +232,7 @@ void FurnaceGUI::drawMobileControls() {
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0.0f,0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0.0f,0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding,mobileEditButtonSize.x); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding,mobileEditButtonSize.x);
if (ImGui::Begin("MobileEdit",NULL,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoBackground|ImGuiWindowFlags_NoDecoration)) { if (ImGui::Begin("MobileEdit",NULL,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoBackground|ImGuiWindowFlags_NoDecoration)) {
bool mobileEditWas=mobileEdit;
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left) && mobileEdit) { if (ImGui::IsMouseReleased(ImGuiMouseButton_Left) && mobileEdit) {
mobileEdit=false; mobileEdit=false;
} }
@ -162,7 +289,14 @@ void FurnaceGUI::drawMobileControls() {
(mobileEditButtonPos.x*canvasW)+cos(buttonDir*2.0*M_PI)*buttonDist*buttonMirrorX*anim, (mobileEditButtonPos.x*canvasW)+cos(buttonDir*2.0*M_PI)*buttonDist*buttonMirrorX*anim,
(mobileEditButtonPos.y*canvasH)+sin(buttonDir*2.0*M_PI)*buttonDist*buttonMirrorY*anim (mobileEditButtonPos.y*canvasH)+sin(buttonDir*2.0*M_PI)*buttonDist*buttonMirrorY*anim
)); ));
ImGui::Button(fmt::sprintf("%d",i+1).c_str(),mobileEditButtonSize); if (ImGui::Button(mobileButtonLabels[i+mobileEditPage*8],mobileEditButtonSize)) {
if (mobileButtonActions[i+mobileEditPage*8]) {
doAction(mobileButtonActions[i+mobileEditPage*8]);
}
if (mobileButtonPersist[i+mobileEditPage*8]) {
mobileEdit=true;
}
}
curButtonPos++; curButtonPos++;
} }
@ -173,8 +307,11 @@ void FurnaceGUI::drawMobileControls() {
mobileEditButtonSize=ImVec2(avail,avail); mobileEditButtonSize=ImVec2(avail,avail);
} }
if (ImGui::Button("Edit",mobileEditButtonSize)) { if (ImGui::Button(ICON_FA_PENCIL "##Edit",mobileEditButtonSize)) {
// click // click
if (mobileEditWas) {
if (++mobileEditPage>3) mobileEditPage=0;
}
if (ImGui::GetIO().MouseDragMaxDistanceSqr[ImGuiMouseButton_Left]<=ImGui::GetIO().ConfigInertialScrollToleranceSqr) { if (ImGui::GetIO().MouseDragMaxDistanceSqr[ImGuiMouseButton_Left]<=ImGui::GetIO().ConfigInertialScrollToleranceSqr) {
mobileEdit=true; mobileEdit=true;
} }

View file

@ -3627,7 +3627,7 @@ bool FurnaceGUI::loop() {
editOptions(true); editOptions(true);
ImGui::Separator(); ImGui::Separator();
if (ImGui::MenuItem("clear...")) { if (ImGui::MenuItem("clear...")) {
showWarning("Are you sure you want to clear... (cannot be undone!)",GUI_WARN_CLEAR); doAction(GUI_ACTION_CLEAR);
} }
ImGui::EndMenu(); ImGui::EndMenu();
} }
@ -3782,7 +3782,6 @@ bool FurnaceGUI::loop() {
globalWinFlags=ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoBringToFrontOnFocus; globalWinFlags=ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoBringToFrontOnFocus;
//globalWinFlags=ImGuiWindowFlags_NoTitleBar; //globalWinFlags=ImGuiWindowFlags_NoTitleBar;
// scene handling goes here! // scene handling goes here!
pianoOpen=true;
drawMobileControls(); drawMobileControls();
switch (mobScene) { switch (mobScene) {
case GUI_SCENE_ORDERS: case GUI_SCENE_ORDERS:
@ -3823,6 +3822,7 @@ bool FurnaceGUI::loop() {
curWindow=GUI_WINDOW_PATTERN; curWindow=GUI_WINDOW_PATTERN;
drawPattern(); drawPattern();
drawPiano(); drawPiano();
drawFindReplace();
drawMobileOrderSel(); drawMobileOrderSel();
break; break;
} }
@ -5150,7 +5150,7 @@ bool FurnaceGUI::init() {
volMeterOpen=e->getConfBool("volMeterOpen",true); volMeterOpen=e->getConfBool("volMeterOpen",true);
statsOpen=e->getConfBool("statsOpen",false); statsOpen=e->getConfBool("statsOpen",false);
compatFlagsOpen=e->getConfBool("compatFlagsOpen",false); compatFlagsOpen=e->getConfBool("compatFlagsOpen",false);
pianoOpen=e->getConfBool("pianoOpen",false); pianoOpen=e->getConfBool("pianoOpen",IS_MOBILE?true:false);
notesOpen=e->getConfBool("notesOpen",false); notesOpen=e->getConfBool("notesOpen",false);
channelsOpen=e->getConfBool("channelsOpen",false); channelsOpen=e->getConfBool("channelsOpen",false);
patManagerOpen=e->getConfBool("patManagerOpen",false); patManagerOpen=e->getConfBool("patManagerOpen",false);
@ -5666,6 +5666,7 @@ FurnaceGUI::FurnaceGUI():
macroPointSize(16), macroPointSize(16),
waveEditStyle(0), waveEditStyle(0),
displayInsTypeListMakeInsSample(-1), displayInsTypeListMakeInsSample(-1),
mobileEditPage(0),
mobileMenuPos(0.0f), mobileMenuPos(0.0f),
autoButtonSize(0.0f), autoButtonSize(0.0f),
mobileEditAnim(0.0f), mobileEditAnim(0.0f),

View file

@ -421,6 +421,7 @@ enum FurnaceGUIActions {
GUI_ACTION_FULLSCREEN, GUI_ACTION_FULLSCREEN,
GUI_ACTION_TX81Z_REQUEST, GUI_ACTION_TX81Z_REQUEST,
GUI_ACTION_PANIC, GUI_ACTION_PANIC,
GUI_ACTION_CLEAR,
GUI_ACTION_WINDOW_EDIT_CONTROLS, GUI_ACTION_WINDOW_EDIT_CONTROLS,
GUI_ACTION_WINDOW_ORDERS, GUI_ACTION_WINDOW_ORDERS,
@ -520,6 +521,8 @@ enum FurnaceGUIActions {
GUI_ACTION_PAT_COLLAPSE_SONG, GUI_ACTION_PAT_COLLAPSE_SONG,
GUI_ACTION_PAT_EXPAND_SONG, GUI_ACTION_PAT_EXPAND_SONG,
GUI_ACTION_PAT_LATCH, GUI_ACTION_PAT_LATCH,
GUI_ACTION_PAT_SCROLL_MODE,
GUI_ACTION_PAT_CLEAR_LATCH,
GUI_ACTION_PAT_MAX, GUI_ACTION_PAT_MAX,
GUI_ACTION_INS_LIST_MIN, GUI_ACTION_INS_LIST_MIN,
@ -1102,6 +1105,7 @@ class FurnaceGUI {
int macroPointSize; int macroPointSize;
int waveEditStyle; int waveEditStyle;
int displayInsTypeListMakeInsSample; int displayInsTypeListMakeInsSample;
int mobileEditPage;
float mobileMenuPos, autoButtonSize, mobileEditAnim; float mobileMenuPos, autoButtonSize, mobileEditAnim;
ImVec2 mobileEditButtonPos, mobileEditButtonSize; ImVec2 mobileEditButtonPos, mobileEditButtonSize;
const int* curSysSection; const int* curSysSection;

View file

@ -483,6 +483,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
D("FULLSCREEN", "Toggle full-screen", SDLK_F11), D("FULLSCREEN", "Toggle full-screen", SDLK_F11),
D("TX81Z_REQUEST", "Request voice from TX81Z", 0), D("TX81Z_REQUEST", "Request voice from TX81Z", 0),
D("PANIC", "Panic", SDLK_F12), D("PANIC", "Panic", SDLK_F12),
D("CLEAR", "Clear song data", 0),
D("WINDOW_EDIT_CONTROLS", "Edit Controls", 0), D("WINDOW_EDIT_CONTROLS", "Edit Controls", 0),
D("WINDOW_ORDERS", "Orders", 0), D("WINDOW_ORDERS", "Orders", 0),
@ -582,6 +583,8 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
D("PAT_COLLAPSE_SONG", "Collapse song", 0), D("PAT_COLLAPSE_SONG", "Collapse song", 0),
D("PAT_EXPAND_SONG", "Expand song", 0), D("PAT_EXPAND_SONG", "Expand song", 0),
D("PAT_LATCH", "Set note input latch", 0), D("PAT_LATCH", "Set note input latch", 0),
D("PAT_SCROLL_MODE", "Change mobile scroll mode", 0),
D("PAT_CLEAR_LATCH", "Clear note input latch", 0),
D("PAT_MAX", "", NOT_AN_ACTION), D("PAT_MAX", "", NOT_AN_ACTION),
D("INS_LIST_MIN", "---Instrument list", NOT_AN_ACTION), D("INS_LIST_MIN", "---Instrument list", NOT_AN_ACTION),