[Libreoffice-commits] core.git: include/svx svx/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jan 10 17:38:07 UTC 2020
include/svx/colorwindow.hxx | 10 +++-
svx/source/tbxctrls/tbcontrl.cxx | 90 ++++++++++++++++++++++++++-------------
2 files changed, 71 insertions(+), 29 deletions(-)
New commits:
commit a164b140221d76cb3b0933d24846de4e1c8780ea
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jan 10 12:58:59 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jan 10 18:37:29 2020 +0100
use welded color window in unwelded toolbars
Change-Id: I024d352029722d67b423d2ebd92de7ce0e9f868b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86541
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx
index 67e5aebdb353..201b1e1dbe19 100644
--- a/include/svx/colorwindow.hxx
+++ b/include/svx/colorwindow.hxx
@@ -109,6 +109,8 @@ public:
void SetSelectedHdl( const Link<const NamedColor&, void>& rLink ) { maSelectedLink = rLink; }
};
+class SvxColorToolBoxControl;
+
class SVX_DLLPUBLIC MenuOrToolMenuButton
{
private:
@@ -117,12 +119,18 @@ private:
// or
weld::Toolbar* m_pToolbar;
OString m_aIdent;
+ // or
+ SvxColorToolBoxControl* m_pControl;
+ VclPtr<ToolBox> m_xToolBox;
+ sal_uInt16 m_nId;
public:
MenuOrToolMenuButton(weld::MenuButton* pMenuButton);
MenuOrToolMenuButton(weld::Toolbar* pToolbar, const OString& rIdent);
+ MenuOrToolMenuButton(SvxColorToolBoxControl* pControl, ToolBox* pToolbar, sal_uInt16 nId);
+ ~MenuOrToolMenuButton();
bool get_active() const;
- void set_active(bool bActive) const;
+ void set_inactive() const;
weld::Widget* get_widget() const;
};
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 2f11f9f34aa0..b891cd5427fd 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2017,12 +2017,11 @@ IMPL_LINK(ColorWindow, SelectHdl, SvtValueSet*, pColorSet, void)
mxPaletteManager->ReloadRecentColorSet(*mxRecentColorSet);
}
- if (maMenuButton.get_active())
- maMenuButton.set_active(false);
-
maSelectedLink.Call(aNamedColor);
maColorSelectFunction(maCommand, aNamedColor);
+
+ maMenuButton.set_inactive();
}
IMPL_LINK_NOARG(SvxColorWindow, SelectPaletteHdl, ListBox&, void)
@@ -2075,8 +2074,7 @@ IMPL_LINK(ColorWindow, AutoColorClickHdl, weld::Button&, rButton, void)
mxRecentColorSet->SetNoSelection();
mpDefaultButton = &rButton;
- if (maMenuButton.get_active())
- maMenuButton.set_active(false);
+ maMenuButton.set_inactive();
maSelectedLink.Call(aNamedColor);
@@ -2105,8 +2103,7 @@ IMPL_LINK_NOARG(SvxColorWindow, OpenPickerClickHdl, Button*, void)
IMPL_LINK_NOARG(ColorWindow, OpenPickerClickHdl, weld::Button&, void)
{
- if (maMenuButton.get_active())
- maMenuButton.set_active(false);
+ maMenuButton.set_inactive();
mxPaletteManager->PopupColorPicker(mpParentWindow, maCommand, GetSelectEntryColor().first);
}
@@ -3469,23 +3466,34 @@ VclPtr<vcl::Window> SvxColorToolBoxControl::createPopupWindow( vcl::Window* pPar
{
EnsurePaletteManager();
- VclPtrInstance<SvxColorWindow> pColorWin(
- m_aCommandURL,
- m_xPaletteManager,
- m_aColorStatus,
- m_nSlotId,
- m_xFrame,
- pParent,
- false,
- m_aColorSelectFunction);
-
- auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(m_aCommandURL, m_sModuleName);
- OUString aWindowTitle = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
- pColorWin->SetText( aWindowTitle );
- pColorWin->StartSelection();
+ const css::uno::Reference<css::awt::XWindow> xParent = m_xFrame->getContainerWindow();
+ weld::Window* pParentFrame = Application::GetFrameWeld(xParent);
+
+ ToolBox* pToolBox = nullptr;
+ sal_uInt16 nId = 0;
+ getToolboxId(nId, &pToolBox);
+
+ auto xPopover = std::make_unique<ColorWindow>(
+ m_aCommandURL,
+ m_xPaletteManager,
+ m_aColorStatus,
+ m_nSlotId,
+ m_xFrame,
+ pParentFrame,
+ MenuOrToolMenuButton(this, pToolBox, nId),
+ m_aColorSelectFunction);
+
if ( m_bSplitButton )
- pColorWin->SetSelectedHdl( LINK( this, SvxColorToolBoxControl, SelectedHdl ) );
- return pColorWin;
+ xPopover->SetSelectedHdl( LINK( this, SvxColorToolBoxControl, SelectedHdl ) );
+
+ EnsurePaletteManager();
+
+ mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
+ std::move(xPopover));
+
+ mxInterimPopover->Show();
+
+ return mxInterimPopover;
}
IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const NamedColor&, rColor, void)
@@ -4349,6 +4357,7 @@ void ColorListBox::ShowPreview(const NamedColor &rColor)
MenuOrToolMenuButton::MenuOrToolMenuButton(weld::MenuButton* pMenuButton)
: m_pMenuButton(pMenuButton)
, m_pToolbar(nullptr)
+ , m_pControl(nullptr)
{
}
@@ -4356,6 +4365,20 @@ MenuOrToolMenuButton::MenuOrToolMenuButton(weld::Toolbar* pToolbar, const OStrin
: m_pMenuButton(nullptr)
, m_pToolbar(pToolbar)
, m_aIdent(rIdent)
+ , m_pControl(nullptr)
+{
+}
+
+MenuOrToolMenuButton::MenuOrToolMenuButton(SvxColorToolBoxControl* pControl, ToolBox* pToolbar, sal_uInt16 nId)
+ : m_pMenuButton(nullptr)
+ , m_pToolbar(nullptr)
+ , m_pControl(pControl)
+ , m_xToolBox(pToolbar)
+ , m_nId(nId)
+{
+}
+
+MenuOrToolMenuButton::~MenuOrToolMenuButton()
{
}
@@ -4363,24 +4386,35 @@ bool MenuOrToolMenuButton::get_active() const
{
if (m_pMenuButton)
return m_pMenuButton->get_active();
- return m_pToolbar->get_menu_item_active(m_aIdent);
+ if (m_pToolbar)
+ return m_pToolbar->get_menu_item_active(m_aIdent);
+ return m_xToolBox->GetDownItemId() == m_nId;
}
-void MenuOrToolMenuButton::set_active(bool bActive) const
+void MenuOrToolMenuButton::set_inactive() const
{
if (m_pMenuButton)
{
- m_pMenuButton->set_active(bActive);
+ if (m_pMenuButton->get_active())
+ m_pMenuButton->set_active(false);
return;
}
- m_pToolbar->set_menu_item_active(m_aIdent, bActive);
+ if (m_pToolbar)
+ {
+ if (m_pToolbar->get_menu_item_active(m_aIdent))
+ m_pToolbar->set_menu_item_active(m_aIdent, false);
+ return;
+ }
+ m_pControl->EndPopupMode();
}
weld::Widget* MenuOrToolMenuButton::get_widget() const
{
if (m_pMenuButton)
return m_pMenuButton;
- return m_pToolbar;
+ if (m_pToolbar)
+ return m_pToolbar;
+ return m_xToolBox->GetFrameWeld();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list