summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-04-27 12:08:33 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-04-27 17:22:07 +0200
commit1d7349476b98dff8038ad44f7806fd404b68c993 (patch)
tree6e6cb54aba13abaf6972219abc4c011dffa4c2c0
parenteb0524839521e563ed8f9fc17a8117a0cf74da34 (diff)
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 <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--compilerplugins/clang/unusedenumconstants.writeonly.results2
-rw-r--r--include/vcl/button.hxx3
-rw-r--r--include/vcl/window.hxx3
-rw-r--r--vcl/source/control/button.cxx26
4 files changed, 22 insertions, 12 deletions
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();
}