mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 10:00:13 +00:00
Grab GTK default colors for infobar
This implements the wxWidgets fix for KiCad. We can't wait for distros to update their wx libs so until then, we'll roll our own. Nicely, this also implements the MacOS setting that was an ifdef previously Fixes https://gitlab.com/kicad/code/kicad/-/issues/19506
This commit is contained in:
parent
8d25a4c09d
commit
e8167f33d7
common/widgets
libs/kiplatform
@ -58,12 +58,11 @@ WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr, wxWindowID aWinid
|
||||
{
|
||||
m_showTimer = new wxTimer( this, ID_CLOSE_INFOBAR );
|
||||
|
||||
wxColour fg, bg;
|
||||
KIPLATFORM::UI::GetInfoBarColours( bg, fg );
|
||||
SetBackgroundColour( bg );
|
||||
SetForegroundColour( fg );
|
||||
#ifdef __WXMAC__
|
||||
// wxWidgets hard-codes wxSYS_COLOUR_INFOBK to { 0xFF, 0xFF, 0xD3 } on Mac.
|
||||
if( KIPLATFORM::UI::IsDarkTheme() )
|
||||
SetBackgroundColour( wxColour( 28, 27, 20 ) );
|
||||
else
|
||||
SetBackgroundColour( wxColour( 255, 249, 189 ) );
|
||||
|
||||
// Infobar is broken on Mac without the effects
|
||||
SetShowHideEffects( wxSHOW_EFFECT_ROLL_TO_BOTTOM, wxSHOW_EFFECT_ROLL_TO_TOP );
|
||||
|
@ -119,6 +119,11 @@ namespace KIPLATFORM
|
||||
*/
|
||||
double GetContentScaleFactor( const wxWindow* aWindow );
|
||||
|
||||
/**
|
||||
* Return the background and foreground colors for info bars in the current scheme
|
||||
*/
|
||||
void GetInfoBarColours( wxColour& aFGColour, wxColour& aBGColour );
|
||||
|
||||
/**
|
||||
* Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl, wxGrid)
|
||||
* that won't be obscured by scrollbars.
|
||||
|
@ -64,6 +64,45 @@ wxColour KIPLATFORM::UI::GetDialogBGColour()
|
||||
}
|
||||
|
||||
|
||||
void KIPLATFORM::UI::GetInfoBarColours( wxColour& aBgColour, wxColour& aFgColour )
|
||||
{
|
||||
// The GTK3.24 way of getting the colours is to use the style context
|
||||
// Earlier GTKs should be able to use the system settings
|
||||
#if( GTK_CHECK_VERSION( 3, 24, 0 ) )
|
||||
GdkRGBA* rgba;
|
||||
GtkWidgetPath* path = gtk_widget_path_new();
|
||||
GtkStyleContext* sc = gtk_style_context_new();
|
||||
gtk_widget_path_append_type( path, GTK_TYPE_WINDOW );
|
||||
gtk_widget_path_iter_set_object_name( path, -1, "infobar" );
|
||||
gtk_widget_path_iter_add_class( path, -1, "background" );
|
||||
gtk_widget_path_iter_add_class( path, -1, "info" );
|
||||
gtk_widget_path_append_type( path, G_TYPE_NONE );
|
||||
gtk_widget_path_iter_set_object_name( path, -1, "revealer" );
|
||||
gtk_widget_path_append_type( path, G_TYPE_NONE );
|
||||
gtk_widget_path_iter_set_object_name( path, -1, "box" );
|
||||
|
||||
gtk_style_context_set_path( sc, path );
|
||||
gtk_style_context_set_state( sc, GTK_STATE_FLAG_NORMAL );
|
||||
|
||||
gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL, "background-color", &rgba, NULL );
|
||||
aBgColour = wxColour(*rgba);
|
||||
gdk_rgba_free(rgba);
|
||||
|
||||
gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL, "color", &rgba, NULL );
|
||||
aFgColour = wxColour(*rgba);
|
||||
gdk_rgba_free(rgba);
|
||||
|
||||
gtk_widget_path_free( path );
|
||||
g_object_unref( sc );
|
||||
|
||||
#else
|
||||
aBgColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOBK );
|
||||
aFgColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOTEXT );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void KIPLATFORM::UI::ForceFocus( wxWindow* aWindow )
|
||||
{
|
||||
aWindow->SetFocus();
|
||||
|
@ -73,6 +73,13 @@ wxColour KIPLATFORM::UI::GetDialogBGColour()
|
||||
}
|
||||
|
||||
|
||||
wxColour KIPLATFORM::UI::GetInfoBarColours( wxColour& aFGColour, wxColour& aBGColour )
|
||||
{
|
||||
aBGColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOBK );
|
||||
aFGColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOTEXT );
|
||||
}
|
||||
|
||||
|
||||
void KIPLATFORM::UI::ForceFocus( wxWindow* aWindow )
|
||||
{
|
||||
aWindow->SetFocus();
|
||||
|
@ -62,6 +62,18 @@ wxColour KIPLATFORM::UI::GetDialogBGColour()
|
||||
}
|
||||
|
||||
|
||||
void KIPLATFORM::UI::GetInfoBarColours( wxColour& aFGColour, wxColour& aBGColour )
|
||||
{
|
||||
aFGColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOTEXT );
|
||||
|
||||
// wxWidgets hard-codes wxSYS_COLOUR_INFOBK to { 0xFF, 0xFF, 0xD3 } on Mac.
|
||||
if( KIPLATFORM::UI::IsDarkTheme() )
|
||||
aBGColour = wxColour( 28, 27, 20 );
|
||||
else
|
||||
aBGColour = wxColour( 255, 249, 189 );
|
||||
}
|
||||
|
||||
|
||||
void KIPLATFORM::UI::ForceFocus( wxWindow* aWindow )
|
||||
{
|
||||
// On OSX we need to forcefully give the focus to the window
|
||||
|
Loading…
Reference in New Issue
Block a user