mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
GUI: more mobile UI things
This commit is contained in:
parent
9a3c81d90a
commit
7e065e4cfe
5 changed files with 99 additions and 11 deletions
|
@ -104,13 +104,39 @@ void FurnaceGUI::drawMobileControls() {
|
|||
ImGui::SetNextWindowPos(portrait?ImVec2(0.0f,((1.0-mobileMenuPos*0.65)*scrH*dpiScale)):ImVec2(0.5*scrW*dpiScale*(mobileMenuPos-1.0),0.0f));
|
||||
ImGui::SetNextWindowSize(portrait?ImVec2(scrW*dpiScale,0.65*scrH*dpiScale):ImVec2(0.5*scrW*dpiScale,scrH*dpiScale));
|
||||
if (ImGui::Begin("Mobile Menu",NULL,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|globalWinFlags)) {
|
||||
ImGui::Button("Pattern");
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Ins");
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Wave");
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Sample");
|
||||
if (ImGui::BeginTable("SceneSel",5)) {
|
||||
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,1.0f);
|
||||
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,1.0f);
|
||||
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,1.0f);
|
||||
ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch,1.0f);
|
||||
ImGui::TableSetupColumn("c4",ImGuiTableColumnFlags_WidthStretch,1.0f);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImVec2 buttonSize=ImGui::GetContentRegionAvail();
|
||||
buttonSize.y=30.0f*dpiScale;
|
||||
|
||||
if (ImGui::Button("Pattern",buttonSize)) {
|
||||
mobScene=GUI_SCENE_PATTERN;
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button("Orders",buttonSize)) {
|
||||
mobScene=GUI_SCENE_ORDERS;
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button("Ins",buttonSize)) {
|
||||
mobScene=GUI_SCENE_INSTRUMENT;
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button("Wave",buttonSize)) {
|
||||
mobScene=GUI_SCENE_WAVETABLE;
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button("Sample",buttonSize)) {
|
||||
mobScene=GUI_SCENE_SAMPLE;
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::Text("Data list goes here...");
|
||||
|
||||
|
|
|
@ -3353,8 +3353,32 @@ bool FurnaceGUI::loop() {
|
|||
// scene handling goes here!
|
||||
pianoOpen=true;
|
||||
drawMobileControls();
|
||||
drawPattern();
|
||||
drawPiano();
|
||||
switch (mobScene) {
|
||||
case GUI_SCENE_PATTERN:
|
||||
patternOpen=true;
|
||||
drawPattern();
|
||||
drawPiano();
|
||||
break;
|
||||
case GUI_SCENE_ORDERS:
|
||||
ordersOpen=true;
|
||||
drawOrders();
|
||||
break;
|
||||
case GUI_SCENE_INSTRUMENT:
|
||||
insEditOpen=true;
|
||||
drawInsEdit();
|
||||
drawPiano();
|
||||
break;
|
||||
case GUI_SCENE_WAVETABLE:
|
||||
waveEditOpen=true;
|
||||
drawWaveEdit();
|
||||
drawPiano();
|
||||
break;
|
||||
case GUI_SCENE_SAMPLE:
|
||||
sampleEditOpen=true;
|
||||
drawSampleEdit();
|
||||
drawPiano();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
globalWinFlags=0;
|
||||
ImGui::DockSpaceOverViewport(NULL,lockLayout?(ImGuiDockNodeFlags_NoWindowMenuButton|ImGuiDockNodeFlags_NoMove|ImGuiDockNodeFlags_NoResize|ImGuiDockNodeFlags_NoCloseButton|ImGuiDockNodeFlags_NoDocking|ImGuiDockNodeFlags_NoDockingSplitMe|ImGuiDockNodeFlags_NoDockingSplitOther):0);
|
||||
|
@ -3397,6 +3421,13 @@ bool FurnaceGUI::loop() {
|
|||
|
||||
if (firstFrame) {
|
||||
firstFrame=false;
|
||||
#ifdef IS_MOBILE
|
||||
SDL_GetWindowSize(sdlWin,&scrW,&scrH);
|
||||
scrW/=dpiScale;
|
||||
scrH/=dpiScale;
|
||||
portrait=(scrW<scrH);
|
||||
logV("portrait: %d (%dx%d)",portrait,scrW,scrH);
|
||||
#endif
|
||||
if (patternOpen) nextWindow=GUI_WINDOW_PATTERN;
|
||||
#ifdef __APPLE__
|
||||
SDL_RaiseWindow(sdlWin);
|
||||
|
@ -4582,11 +4613,18 @@ bool FurnaceGUI::init() {
|
|||
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
||||
#endif
|
||||
|
||||
#ifdef IS_MOBILE
|
||||
scrW=960;
|
||||
scrH=540;
|
||||
scrX=0;
|
||||
scrY=0;
|
||||
#else
|
||||
scrW=scrConfW=e->getConfInt("lastWindowWidth",1280);
|
||||
scrH=scrConfH=e->getConfInt("lastWindowHeight",800);
|
||||
scrX=scrConfX=e->getConfInt("lastWindowX",SDL_WINDOWPOS_CENTERED);
|
||||
scrY=scrConfY=e->getConfInt("lastWindowY",SDL_WINDOWPOS_CENTERED);
|
||||
scrMax=e->getConfBool("lastWindowMax",false);
|
||||
#endif
|
||||
portrait=(scrW<scrH);
|
||||
logV("portrait: %d (%dx%d)",portrait,scrW,scrH);
|
||||
|
||||
|
@ -4604,12 +4642,14 @@ bool FurnaceGUI::init() {
|
|||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
#ifndef IS_MOBILE
|
||||
// if window would spawn out of bounds, force it to be get default position
|
||||
if (!detectOutOfBoundsWindow()) {
|
||||
scrMax=false;
|
||||
scrX=scrConfX=SDL_WINDOWPOS_CENTERED;
|
||||
scrY=scrConfY=SDL_WINDOWPOS_CENTERED;
|
||||
}
|
||||
#endif
|
||||
|
||||
sdlWin=SDL_CreateWindow("Furnace",scrX,scrY,scrW*dpiScale,scrH*dpiScale,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI|(scrMax?SDL_WINDOW_MAXIMIZED:0)|(fullScreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
||||
if (sdlWin==NULL) {
|
||||
|
@ -4623,11 +4663,13 @@ bool FurnaceGUI::init() {
|
|||
SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(sdlWin),&dpiScaleF,NULL,NULL);
|
||||
dpiScale=round(dpiScaleF/96.0f);
|
||||
if (dpiScale<1) dpiScale=1;
|
||||
#ifndef IS_MOBILE
|
||||
if (dpiScale!=1) {
|
||||
if (!fullScreen) {
|
||||
SDL_SetWindowSize(sdlWin,scrW*dpiScale,scrH*dpiScale);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(sdlWin),&displaySize)==0) {
|
||||
if (scrW>((displaySize.w/dpiScale)-48) && scrH>((displaySize.h/dpiScale)-64)) {
|
||||
|
|
|
@ -1560,7 +1560,14 @@ void FurnaceGUI::drawInsEdit() {
|
|||
nextWindow=GUI_WINDOW_NOTHING;
|
||||
}
|
||||
if (!insEditOpen) return;
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale));
|
||||
if (mobileUI) {
|
||||
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)));
|
||||
ImGui::SetNextWindowPos(patWindowPos);
|
||||
ImGui::SetNextWindowSize(patWindowSize);
|
||||
} else {
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale));
|
||||
}
|
||||
if (ImGui::Begin("Instrument Editor",&insEditOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking))) {
|
||||
if (curIns<0 || curIns>=(int)e->song.ins.size()) {
|
||||
ImGui::Text("no instrument selected");
|
||||
|
|
|
@ -35,6 +35,12 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
nextWindow=GUI_WINDOW_NOTHING;
|
||||
}
|
||||
if (!sampleEditOpen) return;
|
||||
if (mobileUI) {
|
||||
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)));
|
||||
ImGui::SetNextWindowPos(patWindowPos);
|
||||
ImGui::SetNextWindowSize(patWindowSize);
|
||||
}
|
||||
if (ImGui::Begin("Sample Editor",&sampleEditOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking))) {
|
||||
if (curSample<0 || curSample>=(int)e->song.sample.size()) {
|
||||
ImGui::Text("no sample selected");
|
||||
|
|
|
@ -164,7 +164,14 @@ void FurnaceGUI::drawWaveEdit() {
|
|||
}
|
||||
if (!waveEditOpen) return;
|
||||
float wavePreview[257];
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(300.0f*dpiScale,300.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale));
|
||||
if (mobileUI) {
|
||||
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)));
|
||||
ImGui::SetNextWindowPos(patWindowPos);
|
||||
ImGui::SetNextWindowSize(patWindowSize);
|
||||
} else {
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(300.0f*dpiScale,300.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale));
|
||||
}
|
||||
if (ImGui::Begin("Wavetable Editor",&waveEditOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking))) {
|
||||
if (curWave<0 || curWave>=(int)e->song.wave.size()) {
|
||||
ImGui::Text("no wavetable selected");
|
||||
|
|
Loading…
Reference in a new issue