Move save dialog to top of screen when using OSK.

This commit is contained in:
elasota
2020-11-03 18:37:08 -05:00
parent 47e23fbc71
commit e727e462d8
3 changed files with 80 additions and 2 deletions

View File

@@ -0,0 +1,53 @@
{
"items" :
[
{
"name" : "Okay",
"itemType" : "Button",
"pos" : [ 376, 208 ],
"size" : [ 58, 20 ],
"id" : 1,
"enabled" : true
},
{
"name" : "Cancel",
"itemType" : "Button",
"pos" : [ 302, 208 ],
"size" : [ 58, 20 ],
"id" : 2,
"enabled" : true
},
{
"name" : "",
"itemType" : "CustomControl",
"pos" : [ 17, 33 ],
"size" : [ 401, 154 ],
"id" : 2,
"enabled" : true
},
{
"name" : "",
"itemType" : "CustomControl",
"pos" : [ 418, 32 ],
"size" : [ 16, 156 ],
"id" : 3,
"enabled" : true
},
{
"name" : "",
"itemType" : "EditBox",
"pos" : [ 16, 208 ],
"size" : [ 270, 16 ],
"id" : 4,
"enabled" : true
},
{
"name" : "^0",
"itemType" : "Label",
"pos" : [ 16, 16 ],
"size" : [ 418, 16 ],
"id" : 10,
"enabled" : true
}
]
}

View File

@@ -9,6 +9,7 @@
"DITL/2004.json" : "ApplicationResourcePatches/DITL/2004.json",
"DITL/2005.json" : "ApplicationResourcePatches/DITL/2005.json",
"DITL/2006.json" : "ApplicationResourcePatches/DITL/2006.json",
"DITL/2007.json" : "ApplicationResourcePatches/DITL/2007.json",
"PICT/1300.bmp" : "ApplicationResourcePatches/PICT/1300.bmp",
"PICT/1301.bmp" : "ApplicationResourcePatches/PICT/1301.bmp",
"PICT/1302.bmp" : "ApplicationResourcePatches/PICT/1302.bmp",

View File

@@ -41,6 +41,8 @@ static const int kFileBrowserUIOpenDialogTemplateID = 2001;
static const int kFileBrowserUISaveDialogTemplateID = 2002;
static const int kFileBrowserUIOverwriteDialogTemplateID = 2003;
static const int kFileBrowserUIBadNameDialogTemplateID = 2004;
static const int kFileBrowserUISaveDialogUnobstructiveTemplateID = 2007;
static const int kOverwriteNoButton = 1;
static const int kOverwriteYesButton = 2;
@@ -472,6 +474,12 @@ namespace PortabilityLayer
int16_t FileBrowserUIImpl::PopUpAlert(const Rect &rect, int dialogResID, const DialogTextSubstitutions *substitutions)
{
PortabilityLayer::HostSystemServices *sysServices = PortabilityLayer::HostSystemServices::GetInstance();
// Disable text input temporarily and restore it after
const bool wasTextInput = sysServices->IsTextInputEnabled();
sysServices->SetTextInputEnabled(false);
PortabilityLayer::DialogManager *dialogManager = PortabilityLayer::DialogManager::GetInstance();
Dialog *dialog = dialogManager->LoadDialogFromTemplate(dialogResID, rect, true, false, 0, 0, PL_GetPutInFrontWindowPtr(), PSTR(""), substitutions);
@@ -488,16 +496,29 @@ namespace PortabilityLayer
dialog->Destroy();
sysServices->SetTextInputEnabled(wasTextInput);
return hit;
}
bool FileBrowserUI::Prompt(Mode mode, VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText)
{
int dialogID = 0;
bool isObstructive = false;
int windowHeight = 272;
if (mode == Mode_Open)
dialogID = kFileBrowserUIOpenDialogTemplateID;
else if (mode == Mode_Save)
dialogID = kFileBrowserUISaveDialogTemplateID;
{
if (PortabilityLayer::HostSystemServices::GetInstance()->IsTextInputObstructive())
{
dialogID = kFileBrowserUISaveDialogUnobstructiveTemplateID;
windowHeight = 240;
isObstructive = true;
}
else
dialogID = kFileBrowserUISaveDialogTemplateID;
}
else
{
assert(false);
@@ -538,7 +559,7 @@ namespace PortabilityLayer
dirCursor->Destroy();
const int scrollBarWidth = 16;
const Rect windowRect = Rect::Create(0, 0, 272, 450);
const Rect windowRect = Rect::Create(0, 0, windowHeight, 450);
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR(""));
@@ -557,6 +578,9 @@ namespace PortabilityLayer
Window *window = dialog->GetWindow();
if (isObstructive)
window->SetPosition(PortabilityLayer::Vec2i(window->GetPosition().m_x, 6));
DrawSurface *surface = window->GetDrawSurface();
const PortabilityLayer::DialogItem &firstItem = *dialog->GetItems().begin();