Merge branch 'generic-tree-icon-fixes'
Generic tree icon fixes, notably fixing regression in icons position in high DPI for the legacy code using wxImageList. See #24127.
This commit is contained in:
commit
188b5b8942
3 changed files with 90 additions and 52 deletions
|
|
@ -243,7 +243,7 @@ protected:
|
|||
*m_key_current,
|
||||
// A hint to select a parent item after deleting a child
|
||||
*m_select_me;
|
||||
unsigned short m_indent;
|
||||
unsigned int m_indent;
|
||||
int m_lineHeight;
|
||||
wxPen m_dottedPen;
|
||||
wxBrush m_hilightBrush,
|
||||
|
|
@ -357,6 +357,8 @@ protected:
|
|||
virtual wxSize DoGetBestSize() const override;
|
||||
|
||||
private:
|
||||
void OnDPIChanged(wxDPIChangedEvent& event);
|
||||
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
|
||||
{
|
||||
InitVisualAttributes();
|
||||
|
|
|
|||
|
|
@ -145,14 +145,32 @@ public:
|
|||
{
|
||||
wxSize size;
|
||||
|
||||
// Prefer to use the image list here if we have it because we must have
|
||||
// already decided for the best size to use when creating it.
|
||||
//
|
||||
// Otherwise we need to compute the best size here ourselves.
|
||||
if ( m_imageList )
|
||||
size = m_imageList->GetSize();
|
||||
else if ( !m_images.empty() )
|
||||
size = wxBitmapBundle::GetConsensusSizeFor(window, m_images);
|
||||
if ( !m_images.empty() )
|
||||
{
|
||||
// This is a micro-optimization: if we have an image list here, we
|
||||
// must have created it ourselves, as e.g. wxGenericTreeCtrl does,
|
||||
// and then we must already have determined the correct size to use
|
||||
// for the current window DPI and can just return it.
|
||||
if ( m_imageList )
|
||||
{
|
||||
// Note that we shouldn't scale it by DPI factor here because
|
||||
// we had already taken it into account when (re)creating it.
|
||||
size = m_imageList->GetSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise we need to compute the best size here ourselves.
|
||||
size = wxBitmapBundle::GetConsensusSizeFor(window, m_images);
|
||||
}
|
||||
}
|
||||
else if ( m_imageList )
|
||||
{
|
||||
// But if we have just the user-provided image list, we need to
|
||||
// scale its size by the DPI scale because the bitmaps from it will
|
||||
// be scaled when they are drawn (they should have scaling factor
|
||||
// of 1, as for anything else wxBitmapBundle must be used).
|
||||
size = m_imageList->GetSize() * window->GetDPIScaleFactor();
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue