Make ribbon tab active/hover label colour customizable

Allow changing the colour of the label in the active and hover states to
make it possible to improve its contrast with the tab background in
these states.

Closes #18406.
This commit is contained in:
Tomay 2019-06-04 23:23:04 +02:00 committed by Vadim Zeitlin
parent 4ad780d6d3
commit 1bb4404527
4 changed files with 38 additions and 1 deletions

View File

@ -73,6 +73,8 @@ enum wxRibbonArtSetting
wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR,
wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR,
wxRIBBON_ART_TAB_LABEL_COLOUR,
wxRIBBON_ART_TAB_ACTIVE_LABEL_COLOUR,
wxRIBBON_ART_TAB_HOVER_LABEL_COLOUR,
wxRIBBON_ART_TAB_SEPARATOR_COLOUR,
wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR,
wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR,
@ -668,6 +670,8 @@ protected:
wxColour m_button_bar_label_colour;
wxColour m_button_bar_label_disabled_colour;
wxColour m_tab_label_colour;
wxColour m_tab_active_label_colour;
wxColour m_tab_hover_label_colour;
wxColour m_tab_separator_colour;
wxColour m_tab_separator_gradient_colour;
wxColour m_tab_active_background_colour;

View File

@ -66,6 +66,10 @@ enum wxRibbonArtSetting
wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR,
wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR,
wxRIBBON_ART_TAB_LABEL_COLOUR,
/// @since 3.1.3
wxRIBBON_ART_TAB_ACTIVE_LABEL_COLOUR,
/// @since 3.1.3
wxRIBBON_ART_TAB_HOVER_LABEL_COLOUR,
wxRIBBON_ART_TAB_SEPARATOR_COLOUR,
wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR,
wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR,

View File

@ -255,6 +255,8 @@ void wxRibbonAUIArtProvider::SetColourScheme(
#else
m_tab_label_colour = LikePrimary(0.1);
#endif
m_tab_active_label_colour = m_tab_label_colour;
m_tab_hover_label_colour = m_tab_label_colour;
m_tab_hover_background_top_colour = primary_hsl.ToRGB();
#ifdef __WXMAC__
if ( wxPlatformInfo::Get().CheckOSVersion(10, 10 ) )

View File

@ -386,6 +386,8 @@ void wxRibbonMSWArtProvider::SetColourScheme(
m_tab_separator_gradient_colour = LikePrimary(1.7, -0.15, -0.18);
m_tab_hover_background_top_gradient_colour = LikePrimary(1.8, 0.34, 0.13);
m_tab_label_colour = LikePrimary(4.3, 0.13, -0.49);
m_tab_active_label_colour = m_tab_label_colour;
m_tab_hover_label_colour = m_tab_label_colour;
m_tab_hover_background_gradient_colour = LikeSecondary(-1.5, -0.34, 0.01);
m_panel_minimised_border_gradient_pen = LikePrimary(-6.9, -0.17, -0.09);
@ -528,6 +530,8 @@ void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const
copy->m_button_bar_label_colour = m_button_bar_label_colour;
copy->m_button_bar_label_disabled_colour = m_button_bar_label_disabled_colour;
copy->m_tab_label_colour = m_tab_label_colour;
copy->m_tab_active_label_colour = m_tab_active_label_colour;
copy->m_tab_hover_label_colour = m_tab_hover_label_colour;
copy->m_tab_separator_colour = m_tab_separator_colour;
copy->m_tab_separator_gradient_colour = m_tab_separator_gradient_colour;
copy->m_tab_active_background_colour = m_tab_hover_background_colour;
@ -849,6 +853,10 @@ wxColour wxRibbonMSWArtProvider::GetColour(int id) const
return m_tab_ctrl_background_brush.GetColour();
case wxRIBBON_ART_TAB_LABEL_COLOUR:
return m_tab_label_colour;
case wxRIBBON_ART_TAB_ACTIVE_LABEL_COLOUR:
return m_tab_active_label_colour;
case wxRIBBON_ART_TAB_HOVER_LABEL_COLOUR:
return m_tab_hover_label_colour;
case wxRIBBON_ART_TAB_SEPARATOR_COLOUR:
return m_tab_separator_colour;
case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR:
@ -1094,6 +1102,12 @@ void wxRibbonMSWArtProvider::SetColour(int id, const wxColor& colour)
case wxRIBBON_ART_TAB_LABEL_COLOUR:
m_tab_label_colour = colour;
break;
case wxRIBBON_ART_TAB_ACTIVE_LABEL_COLOUR:
m_tab_active_label_colour = colour;
break;
case wxRIBBON_ART_TAB_HOVER_LABEL_COLOUR:
m_tab_hover_label_colour = colour;
break;
case wxRIBBON_ART_TAB_SEPARATOR_COLOUR:
m_tab_separator_colour = colour;
m_cached_tab_separator_visibility = -1.0;
@ -1372,7 +1386,20 @@ void wxRibbonMSWArtProvider::DrawTab(
if(!label.IsEmpty())
{
dc.SetFont(m_tab_label_font);
dc.SetTextForeground(m_tab_label_colour);
if (tab.active)
{
dc.SetTextForeground(m_tab_active_label_colour);
}
else if (tab.hovered)
{
dc.SetTextForeground(m_tab_hover_label_colour);
}
else
{
dc.SetTextForeground(m_tab_label_colour);
}
dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
int text_height;