GUI: some mobile view work

This commit is contained in:
tildearrow 2022-09-08 17:04:38 -05:00
parent 773b63b810
commit ae6e956f06
3 changed files with 23 additions and 15 deletions

View file

@ -23,12 +23,16 @@
void FurnaceGUI::drawMobileControls() {
if (ImGui::Begin("Mobile Controls",NULL,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|globalWinFlags)) {
ImGui::SetWindowPos(ImVec2(0.0f,0.0f));
ImGui::SetWindowSize(portrait?ImVec2(scrW*dpiScale,0.1*scrW*dpiScale):ImVec2(0.1*scrH*dpiScale,scrH*dpiScale));
float availX=ImGui::GetContentRegionAvail().x;
ImVec2 buttonSize=ImVec2(availX,availX);
if (ImGui::Button(ICON_FA_CHEVRON_RIGHT "##MobileMenu",buttonSize)) {
}
ImGui::Text("I put here");
ImGui::Separator();
ImGui::PushStyleColor(ImGuiCol_Button,TOGGLE_COLOR(e->isPlaying()));

View file

@ -2595,24 +2595,24 @@ void FurnaceGUI::processPoint(SDL_Event& ev) {
#define OOB_PIXELS_SAFETY 25
bool FurnaceGUI::detectOutOfBoundsWindow() {
int count = SDL_GetNumVideoDisplays();
if(count < 1) {
logW("bounds check: error %s", SDL_GetError());
int count=SDL_GetNumVideoDisplays();
if (count<1) {
logW("bounds check: error %s",SDL_GetError());
return false;
}
SDL_Rect rect;
for(int i = 0;i < count;i ++) {
if(SDL_GetDisplayUsableBounds(i, &rect) != 0) {
logW("bounds check: error %s", SDL_GetError());
for (int i=0; i<count; i++) {
if (SDL_GetDisplayUsableBounds(i,&rect)!=0) {
logW("bounds check: error %s",SDL_GetError());
return false;
}
bool xbound = (rect.x + OOB_PIXELS_SAFETY) <= (scrX + scrW) && (rect.x + rect.w - OOB_PIXELS_SAFETY) >= scrX;
bool ybound = (rect.y + OOB_PIXELS_SAFETY) <= (scrY + scrH) && (rect.y + rect.h - OOB_PIXELS_SAFETY) >= scrY;
logD("bounds check: display %d is at %dx%dx%dx%d: %s%s", i, rect.x + OOB_PIXELS_SAFETY, rect.y + OOB_PIXELS_SAFETY, rect.x + rect.w - OOB_PIXELS_SAFETY, rect.y + rect.h - OOB_PIXELS_SAFETY, xbound ? "x" : "", ybound ? "y" : "");
bool xbound=((rect.x+OOB_PIXELS_SAFETY)<=(scrX+scrW)) && ((rect.x+rect.w-OOB_PIXELS_SAFETY)>=scrX);
bool ybound=((rect.y+OOB_PIXELS_SAFETY)<=(scrY+scrH)) && ((rect.y+rect.h-OOB_PIXELS_SAFETY)>=scrY);
logD("bounds check: display %d is at %dx%dx%dx%d: %s%s",i,rect.x+OOB_PIXELS_SAFETY,rect.y+OOB_PIXELS_SAFETY,rect.x+rect.w-OOB_PIXELS_SAFETY,rect.y+rect.h-OOB_PIXELS_SAFETY,xbound?"x":"",ybound?"y":"");
if(xbound && ybound) {
if (xbound && ybound) {
return true;
}
}
@ -2746,6 +2746,7 @@ bool FurnaceGUI::loop() {
scrW=ev.window.data1/dpiScale;
scrH=ev.window.data2/dpiScale;
#endif
portrait=(scrW<scrH);
updateWindow=true;
break;
case SDL_WINDOWEVENT_MOVED:
@ -2816,8 +2817,8 @@ bool FurnaceGUI::loop() {
}
// update config x/y/w/h values based on scrMax state
if(updateWindow) {
if(!scrMax) {
if (updateWindow) {
if (!scrMax) {
scrConfX=scrX;
scrConfY=scrY;
scrConfW=scrW;
@ -4581,6 +4582,7 @@ bool FurnaceGUI::init() {
scrX=scrConfX=e->getConfInt("lastWindowX",SDL_WINDOWPOS_CENTERED);
scrY=scrConfY=e->getConfInt("lastWindowY",SDL_WINDOWPOS_CENTERED);
scrMax=e->getConfBool("lastWindowMax",false);
portrait=(scrW<scrH);
#ifndef __APPLE__
SDL_Rect displaySize;
@ -4597,8 +4599,8 @@ bool FurnaceGUI::init() {
SDL_Init(SDL_INIT_VIDEO);
// if window would spawn out of bounds, force it to be get default position
if(!detectOutOfBoundsWindow()) {
scrMax = false;
if (!detectOutOfBoundsWindow()) {
scrMax=false;
scrX=scrConfX=SDL_WINDOWPOS_CENTERED;
scrY=scrConfY=SDL_WINDOWPOS_CENTERED;
}
@ -4628,6 +4630,7 @@ bool FurnaceGUI::init() {
}
if (scrW>displaySize.w/dpiScale) scrW=(displaySize.w/dpiScale)-32;
if (scrH>displaySize.h/dpiScale) scrH=(displaySize.h/dpiScale)-32;
portrait=(scrW<scrH);
if (!fullScreen) {
SDL_SetWindowSize(sdlWin,scrW*dpiScale,scrH*dpiScale);
}
@ -4846,6 +4849,7 @@ FurnaceGUI::FurnaceGUI():
displayExporting(false),
vgmExportLoop(true),
vgmExportPatternHints(false),
portrait(false),
wantCaptureKeyboard(false),
oldWantCaptureKeyboard(false),
displayMacroMenu(false),

View file

@ -987,7 +987,7 @@ class FurnaceGUI {
std::vector<DivSystem> sysSearchResults;
std::vector<FurnaceGUISysDef> newSongSearchResults;
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, vgmExportPatternHints;
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, vgmExportPatternHints, portrait;
bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu;
bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly;
bool displayPendingIns, pendingInsSingle, displayPendingRawSample;