Fix window placement on DPI changes
This commit is contained in:
parent
974d6bd827
commit
75941da5a7
@ -40,6 +40,7 @@
|
|||||||
#include <wxex/persist/toplevel.h>
|
#include <wxex/persist/toplevel.h>
|
||||||
|
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
|
#include <wx/dcclient.h>
|
||||||
#include <wx/ffile.h>
|
#include <wx/ffile.h>
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
#include <wx/persist.h>
|
#include <wx/persist.h>
|
||||||
|
@ -411,8 +411,9 @@ wxString wxPersistentZRColaComposerPanel::GetKind() const
|
|||||||
|
|
||||||
void wxPersistentZRColaComposerPanel::Save() const
|
void wxPersistentZRColaComposerPanel::Save() const
|
||||||
{
|
{
|
||||||
auto const wnd = static_cast<const wxZRColaComposerPanel*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
|
auto wnd = static_cast<wxZRColaComposerPanel*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
|
||||||
|
|
||||||
|
SaveValue(wxT("dpiX" ), wxClientDC(wnd).GetPPI().x);
|
||||||
SaveValue(wxT("splitDecomposed"), wnd->m_splitterSource ->GetSashPosition());
|
SaveValue(wxT("splitDecomposed"), wnd->m_splitterSource ->GetSashPosition());
|
||||||
SaveValue(wxT("splitComposed" ), wnd->m_splitterDestination->GetSashPosition());
|
SaveValue(wxT("splitComposed" ), wnd->m_splitterDestination->GetSashPosition());
|
||||||
}
|
}
|
||||||
@ -422,18 +423,23 @@ bool wxPersistentZRColaComposerPanel::Restore()
|
|||||||
{
|
{
|
||||||
auto wnd = dynamic_cast<wxZRColaComposerPanel*>(GetWindow());
|
auto wnd = dynamic_cast<wxZRColaComposerPanel*>(GetWindow());
|
||||||
|
|
||||||
|
int dpiHorz = wxClientDC(wnd).GetPPI().x;
|
||||||
|
int dpiHorzVal;
|
||||||
int sashVal;
|
int sashVal;
|
||||||
|
|
||||||
|
if (!RestoreValue(wxT("dpiX"), &dpiHorzVal))
|
||||||
|
dpiHorzVal = 96;
|
||||||
|
|
||||||
if (RestoreValue(wxT("splitDecomposed"), &sashVal)) {
|
if (RestoreValue(wxT("splitDecomposed"), &sashVal)) {
|
||||||
// wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler.
|
// wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler.
|
||||||
wnd->m_splitterSource->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, wnd );
|
wnd->m_splitterSource->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, wnd );
|
||||||
wnd->m_splitterSource->SetSashPosition(sashVal);
|
wnd->m_splitterSource->SetSashPosition(wxMulDivInt32(sashVal, dpiHorz, dpiHorzVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RestoreValue(wxT("splitComposed"), &sashVal)) {
|
if (RestoreValue(wxT("splitComposed"), &sashVal)) {
|
||||||
// wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler.
|
// wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler.
|
||||||
wnd->m_splitterDestination->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, wnd );
|
wnd->m_splitterDestination->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, wnd );
|
||||||
wnd->m_splitterDestination->SetSashPosition(sashVal);
|
wnd->m_splitterDestination->SetSashPosition(wxMulDivInt32(sashVal, dpiHorz, dpiHorzVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 5a912ebcc6d5d2887628387eae7fc5c8105d7938
|
Subproject commit 704b97944d41ca8e1dbcdc45a87bff58bc746caf
|
Loading…
x
Reference in New Issue
Block a user