Update wxSlider thumb before processing wxEVT_DPI_CHANGED
This changes of 4713301cf5 (Fix font and thumb size of wxSlider after
DPI change, 2019-08-27) fixed updating the slider thumb length on DPI
change, but this happened too late because it was done after executing
the user-defined handler for this event which could have updated the
slider size, which led to a call to its overridden DoMoveWindow() which
would use the old thumb length, resulting in the size remaining too big
when switching from higher to lower DPI and, worse, too small (and not
showing the thumb entirely) when switching in the other direction.
Fix this by updating the thumb length earlier, by using the just added
MSWBeforeDPIChangedEvent() for doing it instead of doing it in the event
handler.
This commit is contained in:
parent
0f19c0a074
commit
0329dfecd8
2 changed files with 5 additions and 6 deletions
|
|
@ -123,8 +123,8 @@ protected:
|
|||
WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) override;
|
||||
|
||||
virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) override;
|
||||
virtual void MSWBeforeDPIChangedEvent(const wxDPIChangedEvent& event) override;
|
||||
|
||||
void OnDPIChanged(wxDPIChangedEvent& event);
|
||||
|
||||
// the labels windows, if any
|
||||
wxSubwindows *m_labels;
|
||||
|
|
|
|||
|
|
@ -184,8 +184,6 @@ bool wxSlider::Create(wxWindow *parent,
|
|||
SetSize(size);
|
||||
}
|
||||
|
||||
Bind(wxEVT_DPI_CHANGED, &wxSlider::OnDPIChanged, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -649,13 +647,14 @@ void wxSlider::MSWUpdateFontOnDPIChange(const wxSize& newDPI)
|
|||
}
|
||||
}
|
||||
|
||||
void wxSlider::OnDPIChanged(wxDPIChangedEvent& event)
|
||||
void wxSlider::MSWBeforeDPIChangedEvent(const wxDPIChangedEvent& event)
|
||||
{
|
||||
// We need to update the thumb before processing wxEVT_DPI_CHANGED in the
|
||||
// user code, as it may update the slider size, which wouldn't work
|
||||
// correctly if it still used the old thumb length.
|
||||
int thumbLen = GetThumbLength();
|
||||
|
||||
SetThumbLength(event.ScaleX(thumbLen));
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue