fpicker/source/office/RemoteFilesDialog.cxx | 4 +++- fpicker/source/office/iodlgimp.cxx | 4 ++-- include/vcl/button.hxx | 3 ++- include/vcl/menubtn.hxx | 12 ++++++++---- sfx2/source/dialog/backingwindow.cxx | 6 ++++-- vcl/source/control/button.cxx | 8 +++++--- vcl/source/control/menubtn.cxx | 8 ++++---- 7 files changed, 28 insertions(+), 17 deletions(-)
New commits: commit 624ff6633c40ab678573a7a38fa3c83c41e0af17 Author: Caolán McNamara <[email protected]> Date: Fri Oct 28 12:37:05 2016 +0100 only draw menubutton separator when two sides do something different Change-Id: If6e3b72eacef2325f9f30770bbed32c627bc035c diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index ef5ca8c..0453bfc 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -279,7 +279,9 @@ RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, PickerFlags nBits ) m_pName_ed->SetGetFocusHdl( LINK( this, RemoteFilesDialog, FileNameGetFocusHdl ) ); m_pName_ed->SetModifyHdl( LINK( this, RemoteFilesDialog, FileNameModifyHdl ) ); - m_pAddService_btn->SetDelayMenu( true ); + m_pAddService_btn->SetDelayMenu(true); + m_pAddService_btn->SetDropDown(PushButtonDropdownStyle::SplitMenuButton); + m_pAddMenu = m_pAddService_btn->GetPopupMenu(); m_pAddService_btn->SetClickHdl( LINK( this, RemoteFilesDialog, AddServiceHdl ) ); m_pAddService_btn->SetSelectHdl( LINK( this, RemoteFilesDialog, EditServiceMenuHdl ) ); diff --git a/fpicker/source/office/iodlgimp.cxx b/fpicker/source/office/iodlgimp.cxx index 0f3623f..43539fd 100644 --- a/fpicker/source/office/iodlgimp.cxx +++ b/fpicker/source/office/iodlgimp.cxx @@ -95,8 +95,8 @@ SvtFileDialogURLSelector::SvtFileDialogURLSelector( vcl::Window* _pParent, SvtFi { SetStyle( GetStyle() | WB_NOPOINTERFOCUS | WB_RECTSTYLE | WB_SMALLSTYLE ); SetModeImage( _pDlg->GetButtonImage( _nButtonId ) ); - SetDelayMenu( true ); - SetDropDown( PushButtonDropdownStyle::Toolbox ); + SetDelayMenu(true); + SetDropDown(PushButtonDropdownStyle::Toolbox); } diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx index 9d83d00..78df45e 100644 --- a/include/vcl/button.hxx +++ b/include/vcl/button.hxx @@ -108,7 +108,8 @@ enum class PushButtonDropdownStyle { NONE = 0x0000, Toolbox = 0x0001, - MenuButton = 0x0002, + MenuButton = 0x0002, //visual down arrow + SplitMenuButton = 0x0003, //visual down arrow and seperator line }; class VCL_DLLPUBLIC PushButton : public Button diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 5ba3641..15fa225 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -263,7 +263,9 @@ void BackingWindow::initControls() mpLocalView->Hide(); mpTemplateButton->SetDelayMenu(true); + mpTemplateButton->SetDropDown(PushButtonDropdownStyle::SplitMenuButton); mpRecentButton->SetDelayMenu(true); + mpRecentButton->SetDropDown(PushButtonDropdownStyle::SplitMenuButton); //set handlers mpLocalView->setCreateContextMenuHdl(LINK(this, BackingWindow, CreateContextMenuHdl)); diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index e094ad4..cb0cb8b 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -868,7 +868,8 @@ void PushButton::ImplDrawPushButtonContent(OutputDevice* pDev, DrawFlags nDrawFl sal_uLong nImageSep = 1 + (pDev->GetTextHeight()-10)/2; if( nImageSep < 1 ) nImageSep = 1; - if ( mnDDStyle == PushButtonDropdownStyle::MenuButton ) + if ( mnDDStyle == PushButtonDropdownStyle::MenuButton || + mnDDStyle == PushButtonDropdownStyle::SplitMenuButton ) { long nSeparatorX = 0; Rectangle aSymbolRect = aInRect; @@ -1034,7 +1035,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) return; bool bRollOver = (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel())); - bool bDrawMenuSep = true; + bool bDrawMenuSep = mnDDStyle == PushButtonDropdownStyle::SplitMenuButton; if (GetStyle() & WB_FLATBUTTON) { if (!bRollOver && !HasFocus()) @@ -1642,7 +1643,8 @@ Size PushButton::CalcMinimumSize() const } else if ( Button::HasImage() && ! (ImplGetButtonState() & DrawButtonFlags::NoImage) ) aSize = GetModeImage().GetSizePixel(); - if( mnDDStyle == PushButtonDropdownStyle::MenuButton ) + if( mnDDStyle == PushButtonDropdownStyle::MenuButton || + mnDDStyle == PushButtonDropdownStyle::SplitMenuButton ) { long nSymbolSize = GetTextHeight() / 2 + 1; aSize.Width() += 2*nSymbolSize; commit b1271fc9baecc5098b9308fb26868bf3637a6293 Author: Caolán McNamara <[email protected]> Date: Fri Oct 28 12:26:12 2016 +0100 the case without a separator is as a Toolbox item Change-Id: I948a63ab9741aa89738b5e44b0ec0e078d0faaa0 diff --git a/vcl/source/control/menubtn.cxx b/vcl/source/control/menubtn.cxx index 26241a2..6d1c677 100644 --- a/vcl/source/control/menubtn.cxx +++ b/vcl/source/control/menubtn.cxx @@ -108,7 +108,7 @@ void MenuButton::MouseButtonDown( const MouseEvent& rMEvt ) if (mbDelayMenu) { // If the separated dropdown symbol is not hit, delay the popup execution - if( mnDDStyle != PushButtonDropdownStyle::MenuButton || // no separator at all + if( mnDDStyle == PushButtonDropdownStyle::Toolbox || // no separator at all rMEvt.GetPosPixel().X() <= ImplGetSeparatorX() ) { if ( !mpMenuTimer ) commit 94af3da7e11e82c4ed2d59655e246b5201c18709 Author: Caolán McNamara <[email protected]> Date: Fri Oct 28 11:48:38 2016 +0100 rename and explain the MENUBUTTON_MENUMODE_TIMED stuff Change-Id: Ifc6ddfb0cc249e537c01f28bab84b42c6b1577d9 diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index 49b576d..ef5ca8c 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -279,7 +279,7 @@ RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, PickerFlags nBits ) m_pName_ed->SetGetFocusHdl( LINK( this, RemoteFilesDialog, FileNameGetFocusHdl ) ); m_pName_ed->SetModifyHdl( LINK( this, RemoteFilesDialog, FileNameModifyHdl ) ); - m_pAddService_btn->SetMenuMode( MENUBUTTON_MENUMODE_TIMED ); + m_pAddService_btn->SetDelayMenu( true ); m_pAddMenu = m_pAddService_btn->GetPopupMenu(); m_pAddService_btn->SetClickHdl( LINK( this, RemoteFilesDialog, AddServiceHdl ) ); m_pAddService_btn->SetSelectHdl( LINK( this, RemoteFilesDialog, EditServiceMenuHdl ) ); diff --git a/fpicker/source/office/iodlgimp.cxx b/fpicker/source/office/iodlgimp.cxx index cd4542c..0f3623f 100644 --- a/fpicker/source/office/iodlgimp.cxx +++ b/fpicker/source/office/iodlgimp.cxx @@ -95,7 +95,7 @@ SvtFileDialogURLSelector::SvtFileDialogURLSelector( vcl::Window* _pParent, SvtFi { SetStyle( GetStyle() | WB_NOPOINTERFOCUS | WB_RECTSTYLE | WB_SMALLSTYLE ); SetModeImage( _pDlg->GetButtonImage( _nButtonId ) ); - SetMenuMode( MENUBUTTON_MENUMODE_TIMED ); + SetDelayMenu( true ); SetDropDown( PushButtonDropdownStyle::Toolbox ); } diff --git a/include/vcl/menubtn.hxx b/include/vcl/menubtn.hxx index 6063c5a..f5056c1 100644 --- a/include/vcl/menubtn.hxx +++ b/include/vcl/menubtn.hxx @@ -28,8 +28,6 @@ class PopupMenu; class VclBuilder; class VclSimpleEvent; -#define MENUBUTTON_MENUMODE_TIMED ((sal_uInt16)0x0001) - class VCL_DLLPUBLIC MenuButton : public PushButton { private: @@ -38,7 +36,7 @@ private: Timer* mpMenuTimer; VclPtr<PopupMenu> mpMenu; sal_uInt16 mnCurItemId; - sal_uInt16 mnMenuMode; + bool mbDelayMenu; Link<MenuButton*,void> maActivateHdl; Link<MenuButton*,void> maSelectHdl; @@ -65,7 +63,13 @@ public: void ExecuteMenu(); - void SetMenuMode(sal_uInt16 nMode) { mnMenuMode = nMode; } + //if false then the whole button launches the menu + //if true, then the button has a separator + //where the right portion launches the menu immediately + //where the left portion activates the underlying Button handlers + //before launching the menu in an idle, allowing it to be cancelled + //before being shown + void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; } void SetPopupMenu( PopupMenu* pNewMenu ); PopupMenu* GetPopupMenu() const { return mpMenu; } diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 67738f4..5ba3641 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -262,8 +262,8 @@ void BackingWindow::initControls() mpLocalView->SetStyle( mpLocalView->GetStyle() | WB_VSCROLL); mpLocalView->Hide(); - mpTemplateButton->SetMenuMode( MENUBUTTON_MENUMODE_TIMED ); - mpRecentButton->SetMenuMode( MENUBUTTON_MENUMODE_TIMED ); + mpTemplateButton->SetDelayMenu(true); + mpRecentButton->SetDelayMenu(true); //set handlers mpLocalView->setCreateContextMenuHdl(LINK(this, BackingWindow, CreateContextMenuHdl)); diff --git a/vcl/source/control/menubtn.cxx b/vcl/source/control/menubtn.cxx index c2c099c..26241a2 100644 --- a/vcl/source/control/menubtn.cxx +++ b/vcl/source/control/menubtn.cxx @@ -33,7 +33,7 @@ void MenuButton::ImplInitMenuButtonData() mpMenuTimer = nullptr; mpMenu = nullptr; mnCurItemId = 0; - mnMenuMode = 0; + mbDelayMenu = false; } void MenuButton::ImplInit( vcl::Window* pParent, WinBits nStyle ) @@ -105,7 +105,7 @@ IMPL_LINK_NOARG(MenuButton, ImplMenuTimeoutHdl, Timer *, void) void MenuButton::MouseButtonDown( const MouseEvent& rMEvt ) { bool bExecute = true; - if ( mnMenuMode & MENUBUTTON_MENUMODE_TIMED ) + if (mbDelayMenu) { // If the separated dropdown symbol is not hit, delay the popup execution if( mnDDStyle != PushButtonDropdownStyle::MenuButton || // no separator at all @@ -141,7 +141,7 @@ void MenuButton::KeyInput( const KeyEvent& rKEvt ) sal_uInt16 nCode = aKeyCode.GetCode(); if ( (nCode == KEY_DOWN) && aKeyCode.IsMod2() ) ExecuteMenu(); - else if ( !(mnMenuMode & MENUBUTTON_MENUMODE_TIMED) && + else if ( !mbDelayMenu && !aKeyCode.GetModifier() && ((nCode == KEY_RETURN) || (nCode == KEY_SPACE)) ) ExecuteMenu();
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
