SDL: Fix browse button not showing on hidpi displays

This commit is contained in:
Connor McLaughlin 2020-05-05 03:04:56 +10:00
parent 0f5bc7267f
commit 26e0177caa
1 changed files with 8 additions and 2 deletions

View File

@ -1305,7 +1305,7 @@ bool SDLHostInterface::DrawFileChooser(const char* label, std::string* path, con
{ {
const float framebuffer_scale = ImGui::GetIO().DisplayFramebufferScale.x; const float framebuffer_scale = ImGui::GetIO().DisplayFramebufferScale.x;
ImGui::SetNextItemWidth((ImGui::CalcItemWidth() - 50.0f) * framebuffer_scale); ImGui::SetNextItemWidth(ImGui::CalcItemWidth() - (50.0f * framebuffer_scale));
bool result = ImGui::InputText(label, path); bool result = ImGui::InputText(label, path);
ImGui::SameLine(); ImGui::SameLine();
@ -1313,7 +1313,13 @@ bool SDLHostInterface::DrawFileChooser(const char* label, std::string* path, con
if (ImGui::Button("...")) if (ImGui::Button("..."))
{ {
nfdchar_t* out_path = nullptr; nfdchar_t* out_path = nullptr;
if (NFD_OpenDialog(filter, path->c_str(), &out_path) == NFD_OKAY) nfdresult_t nfd_result = NFD_OpenDialog(filter, path->c_str(), &out_path);
if (nfd_result == NFD_ERROR)
{
// try without the path - it might not be valid
nfd_result = NFD_OpenDialog(filter, nullptr, &out_path);
}
if (nfd_result == NFD_OKAY)
{ {
path->assign(out_path); path->assign(out_path);
result = true; result = true;