Handle DPI change in wxSplitterWindow
Adjust the minimum pane size to the new DPI. Keep the sash in the same relative position.
This commit is contained in:
@@ -201,6 +201,8 @@ public:
|
|||||||
// Adjusts the panes
|
// Adjusts the panes
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
|
|
||||||
|
void OnDPIChanged(wxDPIChangedEvent& event);
|
||||||
|
|
||||||
// In live mode, resize child windows in idle time
|
// In live mode, resize child windows in idle time
|
||||||
void OnInternalIdle() wxOVERRIDE;
|
void OnInternalIdle() wxOVERRIDE;
|
||||||
|
|
||||||
@@ -295,6 +297,7 @@ protected:
|
|||||||
bool m_needUpdating:1;
|
bool m_needUpdating:1;
|
||||||
bool m_permitUnsplitAlways:1;
|
bool m_permitUnsplitAlways:1;
|
||||||
bool m_isHot:1;
|
bool m_isHot:1;
|
||||||
|
bool m_sizeAfterDPIChange:1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxSplitterWindow);
|
wxDECLARE_DYNAMIC_CLASS(wxSplitterWindow);
|
||||||
|
|||||||
@@ -35,6 +35,11 @@
|
|||||||
#include "wx/osx/private/available.h"
|
#include "wx/osx/private/available.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
// We only need it to get ::MulDiv() declaration, used by wxMulDivInt32().
|
||||||
|
#include "wx/msw/wrapwin.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/renderer.h"
|
#include "wx/renderer.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -61,6 +66,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent, wxNotifyEvent);
|
|||||||
wxBEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
|
wxBEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
|
||||||
EVT_PAINT(wxSplitterWindow::OnPaint)
|
EVT_PAINT(wxSplitterWindow::OnPaint)
|
||||||
EVT_SIZE(wxSplitterWindow::OnSize)
|
EVT_SIZE(wxSplitterWindow::OnSize)
|
||||||
|
EVT_DPI_CHANGED(wxSplitterWindow::OnDPIChanged)
|
||||||
EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent)
|
EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent)
|
||||||
EVT_MOUSE_CAPTURE_LOST(wxSplitterWindow::OnMouseCaptureLost)
|
EVT_MOUSE_CAPTURE_LOST(wxSplitterWindow::OnMouseCaptureLost)
|
||||||
|
|
||||||
@@ -140,6 +146,7 @@ void wxSplitterWindow::Init()
|
|||||||
|
|
||||||
m_needUpdating = false;
|
m_needUpdating = false;
|
||||||
m_isHot = false;
|
m_isHot = false;
|
||||||
|
m_sizeAfterDPIChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSplitterWindow::~wxSplitterWindow()
|
wxSplitterWindow::~wxSplitterWindow()
|
||||||
@@ -473,6 +480,13 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event)
|
|||||||
// Apply gravity if we use it.
|
// Apply gravity if we use it.
|
||||||
int delta = (int) ( (size - old_size)*m_sashGravity );
|
int delta = (int) ( (size - old_size)*m_sashGravity );
|
||||||
|
|
||||||
|
if ( m_sizeAfterDPIChange )
|
||||||
|
{
|
||||||
|
// Keep the same relative position.
|
||||||
|
delta = wxMulDivInt32(size, m_sashPosition, old_size) - m_sashPosition;
|
||||||
|
m_sizeAfterDPIChange = false;
|
||||||
|
}
|
||||||
|
|
||||||
// If delta == 0 then sash will be set according to the windows min size.
|
// If delta == 0 then sash will be set according to the windows min size.
|
||||||
if ( delta != 0 )
|
if ( delta != 0 )
|
||||||
{
|
{
|
||||||
@@ -520,6 +534,14 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event)
|
|||||||
SizeWindows();
|
SizeWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxSplitterWindow::OnDPIChanged(wxDPIChangedEvent& event)
|
||||||
|
{
|
||||||
|
m_minimumPaneSize = event.ScaleX(m_minimumPaneSize);
|
||||||
|
m_sizeAfterDPIChange = true;
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
void wxSplitterWindow::SetSashGravity(double gravity)
|
void wxSplitterWindow::SetSashGravity(double gravity)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( gravity >= 0. && gravity <= 1.,
|
wxCHECK_RET( gravity >= 0. && gravity <= 1.,
|
||||||
|
|||||||
Reference in New Issue
Block a user