gui:windows: Fix memory card dialogs at high DPI

Specifying a minimum size for the filename text controls seems to mess
up the size calculations at higher DPIs and causes usability issues.
Use sizers and proportions instead.

Also scale the dialog widths with the DPI.
This commit is contained in:
Jonathan Li 2015-10-05 16:44:58 +01:00
parent f11596fabc
commit 31b1e34ae8
2 changed files with 18 additions and 13 deletions

View File

@ -17,6 +17,8 @@
#include "ConfigurationDialog.h" #include "ConfigurationDialog.h"
#include "System.h" #include "System.h"
#include "MSWstuff.h"
#include "MemoryCardFile.h" #include "MemoryCardFile.h"
#include "MemoryCardFolder.h" #include "MemoryCardFolder.h"
#include <wx/ffile.h> #include <wx/ffile.h>
@ -35,7 +37,7 @@ Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, con
, m_mcdPath( mcdPath ) , m_mcdPath( mcdPath )
, m_mcdSourceFilename( mcdSourceConfig.Filename.GetFullName() ) , m_mcdSourceFilename( mcdSourceConfig.Filename.GetFullName() )
{ {
SetMinWidth( 472 ); SetMinWidth( 472 * MSW_GetDPIScale());
CreateControls( mcdSourceConfig.Type ); CreateControls( mcdSourceConfig.Type );
@ -51,13 +53,12 @@ Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, con
s_padding += Heading( wxString( _( "Convert: " ) ) + ( mcdPath + m_mcdSourceFilename ).GetFullPath() ).Unwrapped() | pxSizerFlags::StdExpand(); s_padding += Heading( wxString( _( "Convert: " ) ) + ( mcdPath + m_mcdSourceFilename ).GetFullPath() ).Unwrapped() | pxSizerFlags::StdExpand();
wxBoxSizer& s_filename( *new wxBoxSizer( wxHORIZONTAL ) ); wxBoxSizer& s_filename( *new wxBoxSizer( wxHORIZONTAL ) );
s_filename += Heading( _( "To: " ) ).SetMinWidth( 50 ); s_filename += Heading( _( "To: " ) ).Unwrapped().Align(wxALIGN_RIGHT) | pxProportion(1);
m_text_filenameInput->SetMinSize( wxSize( 250, 20 ) );
m_text_filenameInput->SetValue( wxFileName( m_mcdSourceFilename ).GetName() + L"_converted" ); m_text_filenameInput->SetValue( wxFileName( m_mcdSourceFilename ).GetName() + L"_converted" );
s_filename += m_text_filenameInput; s_filename += m_text_filenameInput | pxProportion(2);
s_filename += Heading( L".ps2" ); s_filename += Heading( L".ps2" ).Align(wxALIGN_LEFT) | pxProportion(1);
s_padding += s_filename | wxALIGN_LEFT; s_padding += s_filename | pxSizerFlags::StdExpand();
s_padding += m_radio_CardType | pxSizerFlags::StdExpand(); s_padding += m_radio_CardType | pxSizerFlags::StdExpand();
@ -74,6 +75,8 @@ Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, con
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConvertMemoryCardDialog::OnOk_Click ) ); Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConvertMemoryCardDialog::OnOk_Click ) );
Connect( m_text_filenameInput->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( ConvertMemoryCardDialog::OnOk_Click ) ); Connect( m_text_filenameInput->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( ConvertMemoryCardDialog::OnOk_Click ) );
SetSizerAndFit(GetSizer());
m_text_filenameInput->SetFocus(); m_text_filenameInput->SetFocus();
m_text_filenameInput->SelectAll(); m_text_filenameInput->SelectAll();
} }

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "ConfigurationDialog.h" #include "ConfigurationDialog.h"
#include "System.h" #include "System.h"
#include "MSWstuff.h"
#include "MemoryCardFile.h" #include "MemoryCardFile.h"
//#include <wx/filepicker.h> //#include <wx/filepicker.h>
@ -41,8 +42,7 @@ Dialogs::CreateMemoryCardDialog::CreateMemoryCardDialog( wxWindow* parent, const
, m_mcdpath( mcdpath ) , m_mcdpath( mcdpath )
, m_mcdfile( suggested_mcdfileName )//suggested_and_result_mcdfileName.IsEmpty() ? g_Conf->Mcd[slot].Filename.GetFullName() , m_mcdfile( suggested_mcdfileName )//suggested_and_result_mcdfileName.IsEmpty() ? g_Conf->Mcd[slot].Filename.GetFullName()
{ {
SetMinWidth( 472 * MSW_GetDPIScale());
SetMinWidth( 472 );
//m_filepicker = NULL; //m_filepicker = NULL;
CreateControls(); CreateControls();
@ -72,13 +72,12 @@ Dialogs::CreateMemoryCardDialog::CreateMemoryCardDialog( wxWindow* parent, const
s_padding += Heading( wxString(_("At folder: ")) + (m_mcdpath + m_mcdfile).GetPath() ).Unwrapped() | StdExpand(); s_padding += Heading( wxString(_("At folder: ")) + (m_mcdpath + m_mcdfile).GetPath() ).Unwrapped() | StdExpand();
wxBoxSizer& s_filename( *new wxBoxSizer(wxHORIZONTAL) ); wxBoxSizer& s_filename( *new wxBoxSizer(wxHORIZONTAL) );
s_filename += Heading( _("Select file name: ")).SetMinWidth(150); s_filename += Heading( _("Select file name: ")).Unwrapped().Align(wxALIGN_RIGHT) | pxProportion(1);
m_text_filenameInput->SetMinSize(wxSize(150,20));
m_text_filenameInput->SetValue ((m_mcdpath + m_mcdfile).GetName()); m_text_filenameInput->SetValue ((m_mcdpath + m_mcdfile).GetName());
s_filename += m_text_filenameInput; s_filename += m_text_filenameInput | pxProportion(2);
s_filename += Heading( L".ps2" ); s_filename += Heading( L".ps2" ).Align(wxALIGN_LEFT) | pxProportion(1);
s_padding += s_filename | wxALIGN_LEFT; s_padding += s_filename | StdExpand();
} }
@ -96,6 +95,9 @@ Dialogs::CreateMemoryCardDialog::CreateMemoryCardDialog( wxWindow* parent, const
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CreateMemoryCardDialog::OnOk_Click ) ); Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CreateMemoryCardDialog::OnOk_Click ) );
Connect( m_text_filenameInput->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( CreateMemoryCardDialog::OnOk_Click ) ); Connect( m_text_filenameInput->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( CreateMemoryCardDialog::OnOk_Click ) );
// ...Typical solution to everything? Or are we doing something weird?
SetSizerAndFit(GetSizer());
m_text_filenameInput->SetFocus(); m_text_filenameInput->SetFocus();
m_text_filenameInput->SelectAll(); m_text_filenameInput->SelectAll();
} }