compilerplugins/clang/unusedenumconstants.writeonly.results | 2 include/vcl/button.hxx | 3 include/vcl/settings.hxx | 3 include/vcl/window.hxx | 3 vcl/source/app/settings.cxx | 16 ++++ vcl/source/control/button.cxx | 40 +++++++++--- vcl/unx/gtk/salnativewidgets-gtk.cxx | 1 vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 15 ++++ vcl/unx/kde4/KDESalFrame.cxx | 1 vcl/unx/kde5/KDE5SalFrame.cxx | 1 vcl/win/window/salframe.cxx | 1 11 files changed, 71 insertions(+), 15 deletions(-)
New commits: commit 42494bfdd029c69cca7f0979a0ed3ab920efe45e Author: Caolán McNamara <caol...@redhat.com> Date: Fri Apr 27 14:04:13 2018 +0100 Resolves: tdf#117178 distinguish between pressed vs unpressed rollover Change-Id: If7964c6584d83609ad08dca7e669b85dfadf036e Reviewed-on: https://gerrit.libreoffice.org/53563 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx index b8cc012414ce..491831e147d9 100644 --- a/include/vcl/settings.hxx +++ b/include/vcl/settings.hxx @@ -276,6 +276,9 @@ public: void SetButtonRolloverTextColor( const Color& rColor ); const Color& GetButtonRolloverTextColor() const; + void SetButtonPressedRolloverTextColor( const Color& rColor ); + const Color& GetButtonPressedRolloverTextColor() const; + void SetRadioCheckTextColor( const Color& rColor ); const Color& GetRadioCheckTextColor() const; diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index f9eaf47ce645..3c5d150df79c 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -94,6 +94,7 @@ struct ImplStyleData Color maAlternatingRowColor; Color maButtonTextColor; Color maButtonRolloverTextColor; + Color maButtonPressedRolloverTextColor; Color maCheckedColor; Color maDarkShadowColor; Color maDeactiveBorderColor; @@ -562,6 +563,7 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) : maAlternatingRowColor( rData.maAlternatingRowColor ), maButtonTextColor( rData.maButtonTextColor ), maButtonRolloverTextColor( rData.maButtonRolloverTextColor ), + maButtonPressedRolloverTextColor( rData.maButtonPressedRolloverTextColor ), maCheckedColor( rData.maCheckedColor ), maDarkShadowColor( rData.maDarkShadowColor ), maDeactiveBorderColor( rData.maDeactiveBorderColor ), @@ -703,6 +705,7 @@ void ImplStyleData::SetStandardStyles() maDarkShadowColor = COL_BLACK; maButtonTextColor = COL_BLACK; maButtonRolloverTextColor = COL_BLACK; + maButtonPressedRolloverTextColor = COL_BLACK; maRadioCheckTextColor = COL_BLACK; maGroupTextColor = COL_BLACK; maLabelTextColor = COL_BLACK; @@ -876,6 +879,19 @@ StyleSettings::GetButtonRolloverTextColor() const } void +StyleSettings::SetButtonPressedRolloverTextColor( const Color& rColor ) +{ + CopyData(); + mxData->maButtonPressedRolloverTextColor = rColor; +} + +const Color& +StyleSettings::GetButtonPressedRolloverTextColor() const +{ + return mxData->maButtonPressedRolloverTextColor; +} + +void StyleSettings::SetRadioCheckTextColor( const Color& rColor ) { CopyData(); diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 4bdc10f40010..ebd5aaee80a9 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -836,11 +836,21 @@ void PushButton::ImplDrawPushButtonContent(OutputDevice* pDev, DrawFlags nDrawFl if ( nDrawFlags & DrawFlags::Mono ) aColor = COL_BLACK; else if( (nButtonFlags & DrawButtonFlags::Highlight) && IsNativeControlSupported(ControlType::Pushbutton, ControlPart::Entire) ) - aColor = rStyleSettings.GetButtonRolloverTextColor(); + { + if (nButtonFlags & DrawButtonFlags::Pressed) + aColor = rStyleSettings.GetButtonPressedRolloverTextColor(); + else + aColor = rStyleSettings.GetButtonRolloverTextColor(); + } else if ( IsControlForeground() ) aColor = GetControlForeground(); else if( nButtonFlags & DrawButtonFlags::Highlight ) - aColor = rStyleSettings.GetButtonRolloverTextColor(); + { + if (nButtonFlags & DrawButtonFlags::Pressed) + aColor = rStyleSettings.GetButtonPressedRolloverTextColor(); + else + aColor = rStyleSettings.GetButtonRolloverTextColor(); + } else aColor = rStyleSettings.GetButtonTextColor(); diff --git a/vcl/unx/gtk/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx index 11e67cbd3ae2..2bd434c862b0 100644 --- a/vcl/unx/gtk/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/salnativewidgets-gtk.cxx @@ -3815,6 +3815,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) // mouse over text colors aTextColor = getColor( pStyle->fg[ GTK_STATE_PRELIGHT ] ); aStyleSet.SetButtonRolloverTextColor( aTextColor ); + aStyleSet.SetButtonPressedRolloverTextColor( aTextColor ); aStyleSet.SetFieldRolloverTextColor( aTextColor ); // background colors diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index 04f5ac181c05..9ed8d7c96dc3 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -2889,9 +2889,22 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) style_context_set_state(pStyle, GTK_STATE_FLAG_PRELIGHT); gtk_style_context_get_color(pStyle, gtk_style_context_get_state(pStyle), &text_color); aTextColor = getColor( text_color ); - aStyleSet.SetButtonRolloverTextColor( aTextColor ); aStyleSet.SetFieldRolloverTextColor( aTextColor ); + // button mouse over colors + { + GdkRGBA normal_button_rollover_text_color, pressed_button_rollover_text_color; + style_context_set_state(mpButtonStyle, GTK_STATE_FLAG_PRELIGHT); + gtk_style_context_get_color(mpButtonStyle, gtk_style_context_get_state(mpButtonStyle), &normal_button_rollover_text_color); + aTextColor = getColor(normal_button_rollover_text_color); + aStyleSet.SetButtonRolloverTextColor( aTextColor ); + style_context_set_state(mpButtonStyle, static_cast<GtkStateFlags>(GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE)); + gtk_style_context_get_color(mpButtonStyle, gtk_style_context_get_state(mpButtonStyle), &pressed_button_rollover_text_color); + aTextColor = getColor(pressed_button_rollover_text_color); + style_context_set_state(mpButtonStyle, GTK_STATE_FLAG_NORMAL); + aStyleSet.SetButtonPressedRolloverTextColor( aTextColor ); + } + // tooltip colors { GtkStyleContext *pCStyle = gtk_style_context_new(); diff --git a/vcl/unx/kde4/KDESalFrame.cxx b/vcl/unx/kde4/KDESalFrame.cxx index 769e456e8738..7dde568a23b1 100644 --- a/vcl/unx/kde4/KDESalFrame.cxx +++ b/vcl/unx/kde4/KDESalFrame.cxx @@ -258,6 +258,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings ) // Buttons style.SetButtonTextColor( aButn ); style.SetButtonRolloverTextColor( aButn ); + style.SetButtonPressedRolloverTextColor( aButn ); // Tabs style.SetTabTextColor( aButn ); diff --git a/vcl/unx/kde5/KDE5SalFrame.cxx b/vcl/unx/kde5/KDE5SalFrame.cxx index 61b4113fa9d2..ab1fc1f67763 100644 --- a/vcl/unx/kde5/KDE5SalFrame.cxx +++ b/vcl/unx/kde5/KDE5SalFrame.cxx @@ -231,6 +231,7 @@ void KDE5SalFrame::UpdateSettings( AllSettings& rSettings ) // Buttons style.SetButtonTextColor( aButn ); style.SetButtonRolloverTextColor( aButn ); + style.SetButtonPressedRolloverTextColor( aButn ); // Tabs style.SetTabTextColor( aButn ); diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 7186fc2953e9..7dfe3c0a573d 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -2607,6 +2607,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetDialogTextColor( aStyleSettings.GetButtonTextColor() ); aStyleSettings.SetButtonTextColor( ImplWinColorToSal( GetSysColor( COLOR_BTNTEXT ) ) ); aStyleSettings.SetButtonRolloverTextColor( aStyleSettings.GetButtonTextColor() ); + aStyleSettings.SetButtonPressedRolloverTextColor( aStyleSettings.GetButtonTextColor() ); aStyleSettings.SetTabTextColor( aStyleSettings.GetButtonTextColor() ); aStyleSettings.SetTabRolloverTextColor( aStyleSettings.GetButtonTextColor() ); aStyleSettings.SetTabHighlightTextColor( aStyleSettings.GetButtonTextColor() ); commit 1d7349476b98dff8038ad44f7806fd404b68c993 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Apr 27 12:08:33 2018 +0100 Related: tdf#117178 rollover is always done in visually released button mode a quirk of the menutogglebutton is that in rollover it always gets drawn as if its released, so refactor confusing stuff to take visual mode from a DrawButtonFlags, allowing the dropping of DrawFlags::NoRollover Change-Id: I14225bd0d2fbc8276a2b0a26c20673df0105891c Reviewed-on: https://gerrit.libreoffice.org/53562 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/compilerplugins/clang/unusedenumconstants.writeonly.results b/compilerplugins/clang/unusedenumconstants.writeonly.results index d817a7801fef..41c4befbf588 100644 --- a/compilerplugins/clang/unusedenumconstants.writeonly.results +++ b/compilerplugins/clang/unusedenumconstants.writeonly.results @@ -4586,8 +4586,6 @@ include/vcl/window.hxx:373 enum DrawFlags NoSelection include/vcl/window.hxx:374 enum DrawFlags NoBackground -include/vcl/window.hxx:375 - enum DrawFlags NoRollover include/vcl/window.hxx:386 enum DialogControlFlags Return include/vcl/window.hxx:387 diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx index dbc80437bcee..85f798af5c90 100644 --- a/include/vcl/button.hxx +++ b/include/vcl/button.hxx @@ -171,7 +171,8 @@ protected: SAL_DLLPRIVATE static WinBits ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle ); SAL_DLLPRIVATE void ImplInitSettings( bool bBackground ); SAL_DLLPRIVATE void ImplDrawPushButtonContent(OutputDevice* pDev, DrawFlags nDrawFlags, - const tools::Rectangle& rRect, bool bMenuBtnSep); + const tools::Rectangle& rRect, bool bMenuBtnSep, + DrawButtonFlags nButtonFlags); SAL_DLLPRIVATE void ImplDrawPushButton(vcl::RenderContext& rRenderContext); using Button::ImplGetTextStyle; SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle( DrawFlags nDrawFlags ) const; diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 6b5dd1b8ab7c..1c27a8737f42 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -376,11 +376,10 @@ enum class DrawFlags NoMnemonic = 0x0010, NoSelection = 0x0020, NoBackground = 0x0040, - NoRollover = 0x0080, }; namespace o3tl { - template<> struct typed_flags<DrawFlags> : is_typed_flags<DrawFlags, 0x00ff> {}; + template<> struct typed_flags<DrawFlags> : is_typed_flags<DrawFlags, 0x007f> {}; } // DialogControl-Flags diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 35400b70ed8a..4bdc10f40010 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -817,7 +817,8 @@ static void ImplDrawBtnDropDownArrow( OutputDevice* pDev, } void PushButton::ImplDrawPushButtonContent(OutputDevice* pDev, DrawFlags nDrawFlags, - const tools::Rectangle& rRect, bool bMenuBtnSep) + const tools::Rectangle& rRect, bool bMenuBtnSep, + DrawButtonFlags nButtonFlags) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); tools::Rectangle aInRect = rRect; @@ -834,11 +835,11 @@ void PushButton::ImplDrawPushButtonContent(OutputDevice* pDev, DrawFlags nDrawFl if ( nDrawFlags & DrawFlags::Mono ) aColor = COL_BLACK; - else if( (nDrawFlags & DrawFlags::NoRollover) && IsNativeControlSupported(ControlType::Pushbutton, ControlPart::Entire) ) + else if( (nButtonFlags & DrawButtonFlags::Highlight) && IsNativeControlSupported(ControlType::Pushbutton, ControlPart::Entire) ) aColor = rStyleSettings.GetButtonRolloverTextColor(); else if ( IsControlForeground() ) aColor = GetControlForeground(); - else if( nDrawFlags & DrawFlags::NoRollover ) + else if( nButtonFlags & DrawButtonFlags::Highlight ) aColor = rStyleSettings.GetButtonRolloverTextColor(); else aColor = rStyleSettings.GetButtonTextColor(); @@ -1022,6 +1023,8 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) return; bool bRollOver = (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel())); + if (bRollOver) + nButtonStyle |= DrawButtonFlags::Highlight; bool bDrawMenuSep = mnDDStyle == PushButtonDropdownStyle::SplitMenuButton; if (GetStyle() & WB_FLATBUTTON) { @@ -1036,7 +1039,10 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) ControlState nState = ControlState::NONE; if (mbPressed || IsChecked() || mbIsActive) + { nState |= ControlState::PRESSED; + nButtonStyle |= DrawButtonFlags::Pressed; + } if (ImplGetButtonState() & DrawButtonFlags::Pressed) nState |= ControlState::PRESSED; if (HasFocus()) @@ -1047,10 +1053,16 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) nState |= ControlState::ENABLED; if (bRollOver || mbIsActive) + { + nButtonStyle |= DrawButtonFlags::Highlight; nState |= ControlState::ROLLOVER; + } if (mbIsActive && bRollOver) + { nState &= ~ControlState::PRESSED; + nButtonStyle &= ~DrawButtonFlags::Pressed; + } if (GetStyle() & WB_BEVELBUTTON) aControlValue.mbBevelButton = true; @@ -1085,8 +1097,8 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) } // draw content using the same aInRect as non-native VCL would do - ImplDrawPushButtonContent(&rRenderContext, (nState&ControlState::ROLLOVER) ? DrawFlags::NoRollover : DrawFlags::NONE, - aInRect, bDrawMenuSep); + ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE, + aInRect, bDrawMenuSep, nButtonStyle); if (HasFocus()) ShowFocus(ImplGetFocusRect()); @@ -1111,7 +1123,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) } // draw content - ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE, aInRect, bDrawMenuSep); + ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE, aInRect, bDrawMenuSep, nButtonStyle); if (HasFocus()) { @@ -1387,7 +1399,7 @@ void PushButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, nButtonStyle |= DrawButtonFlags::Checked; aRect = aDecoView.DrawButton( aRect, nButtonStyle ); - ImplDrawPushButtonContent( pDev, nFlags, aRect, true ); + ImplDrawPushButtonContent( pDev, nFlags, aRect, true, nButtonStyle ); pDev->Pop(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits