wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
5.77k stars 1.7k forks source link

wxPropertyGrid uses a very hard to read color for disabled properties in dark themes on Linux #24493

Closed StefanBattmer closed 3 weeks ago

StefanBattmer commented 3 weeks ago

Description

This most likely comes from the fact that the default text color for disabled properties is not necessarily a system color but something that comes out of the wxPGAdjustColour function when called from the void wxPropertyGrid::RegainColours() function:

wxColour capForeCol = wxPGAdjustColour(m_colCapBack,colDec,5000,5000,true);
if (wxPGGetColAvg(m_colCapBack) < 100)
    capForeCol = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );

m_colCapFore = capForeCol;
m_categoryDefaultCell.GetData()->SetFgCol(capForeCol);

The result is a very dark grey on a black background. We fixed this for our application by calling

pPropGridManager->GetGrid()->SetCellDisabledTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );

after creating the grid.

vadz commented 3 weeks ago

Strangely, I have a different problem: for me, with the default GNOME dark theme (i.e. dark variant of Adwaita), the disabled text colour is just the same white as for the normal cells. And this is not really surprising seeing that it is set to the same colour as the normal caption colour by default here:

https://github.com/wxWidgets/wxWidgets/blob/ee309e078a2294d59c754b79c0407184e7558738/src/propgrid/propgrid.cpp#L1486

I can fix this by applying

diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp
index 937d08e615..1ecfe88853 100644
--- a/src/propgrid/propgrid.cpp
+++ b/src/propgrid/propgrid.cpp
@@ -1499,7 +1499,7 @@ void wxPropertyGrid::RegainColours()
         m_colLine = m_colCapBack;

     if ( !(m_coloursCustomized & CustomColour_DisabledText) )
-        m_colDisPropFore = m_colCapFore;
+        m_colDisPropFore = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );

     m_colEmptySpace = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
 }

but I feel like I'm missing something here: how come the colour is grey even without this change in the light theme, as can be easily seen in the propgrid sample, which has a few disabled properties by default ("OS", "User Id", "User Name")?

StefanBattmer commented 3 weeks ago

@vadz: Many, many thanks! Fun fact: We just kind of met again: https://github.com/swig/swig/issues/2889 ;-)