Kaydet (Commit) 1d734947 authored tarafından Caolán McNamara's avatar Caolán McNamara

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/53562Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst eb052483
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment