36#include <osl/diagnose.h>
41using namespace css::uno;
48 const Reference<frame::XFrame>& rxFrame,
49 std::function<
void (
const OUString&)> aDeckActivationFunctor,
50 PopupMenuProvider aPopupMenuProvider,
51 SidebarController* rParentSidebarController
56 , mxTempToplevel(mxAuxBuilder->weld_box(
"toplevel"))
57 , mxContents(mxAuxBuilder->weld_widget(
"TabBarContents"))
58 , mxMeasureBox(mxAuxBuilder->weld_widget(
"measure"))
59 , maDeckActivationFunctor(std::move(aDeckActivationFunctor))
60 , maPopupMenuProvider(std::move(aPopupMenuProvider))
61 , pParentSidebarController(rParentSidebarController)
65 InitControlBase(mxMenuButton.get());
67 mxTempToplevel->move(mxContents.get(),
m_xContainer.get());
72 mxMenuButton = mxAuxBuilder->weld_menu_button(
"menubutton");
73 mxMainMenu = mxAuxBuilder->weld_menu(
"mainmenu");
74 mxSubMenu = mxAuxBuilder->weld_menu(
"submenu");
83 mxMenuButton->connect_toggled(
LINK(
this,
TabBar, OnToolboxClicked));
114 std::unique_ptr<weld::Widget> xContainer(xBuilder->weld_widget(
"TabBarContents"));
128 for (
auto const& deck : rDecks)
131 if (xDescriptor ==
nullptr)
133 OSL_ASSERT(xDescriptor!=
nullptr);
137 maItems.emplace_back(std::make_unique<Item>(*
this));
139 xItem->msDeckId = xDescriptor->msId;
141 xItem->mxButton->connect_clicked(
LINK(xItem.get(),
TabBar::Item, HandleClick));
143 xItem->mbIsHidden = !xDescriptor->mbIsEnabled;
144 xItem->mbIsHiddenByDefault = xItem->mbIsHidden;
146 xItem->mxButton->set_sensitive(deck.mbIsEnabled);
154 for (
auto const& item :
maItems)
157 if (!xDeckDescriptor)
159 item->mxButton->set_item_image(
"toggle",
GetItemImage(*xDeckDescriptor));
165 for (
auto const& item :
maItems)
166 item->mxButton->set_item_active(
"toggle", item->msDeckId == rsDeckId);
171 for (
auto const& item :
maItems)
172 item->mxButton->set_item_active(
"toggle",
false);
186 if(NotifyEventType::KEYINPUT ==
nType)
200 else if(NotifyEventType::COMMAND ==
nType)
203 if(rCommandEvent.
GetCommand() == CommandEventId::Wheel)
206 if(!
pData->GetModifier() && (
pData->GetMode() == CommandWheelMode::SCROLL))
209 [] (
const auto& item) { return item->mxButton->get_item_active(
"toggle"); });
212 if(
pData->GetNotchDelta()<0)
226 (*pItem)->maDeckActivationFunctor((*pItem)->msDeckId);
228 catch(
const css::uno::Exception&) {};
241 const OUString sCommand =
".uno:SidebarDeck." + rDeckDescriptor.
msId;
243 if (!sShortcut.isEmpty())
244 sShortcut =
u" (" + sShortcut +
u")";
258 , mxBuilder(
Application::CreateBuilder(rTabBar.GetContainer(),
"sfx/ui/tabbutton.ui"))
259 , mxButton(mxBuilder->weld_toolbar(
"button"))
261 , mbIsHiddenByDefault(false)
267 mrTabBar.GetContainer()->move(mxButton.get(),
nullptr);
275 auto sDeckId = msDeckId;
277 mrTabBar.GrabFocusToDocument();
280 aDeckActivationFunctor(sDeckId);
282 catch(
const css::uno::Exception&)
303 xDeckDescriptor->mbIsEnabled = !
maItems[
nIndex]->mbIsHidden;
310 xDeckDescriptor->maContextList.ToggleVisibilityForContext(
311 aContext, xDeckDescriptor->mbIsEnabled );
319 if (item->mbIsHidden != item->mbIsHiddenByDefault)
321 item->mbIsHidden = item->mbIsHiddenByDefault;
324 xDeckDescriptor->mbIsEnabled = !item->mbIsHidden;
332 std::vector<weld::Widget*> aButtons;
333 aButtons.reserve(
maItems.size()+1);
335 for (
auto const& item :
maItems)
337 aButtons.push_back(item->mxButton.get());
347 std::vector<DeckMenuData> aMenuData;
349 for (
auto const& item :
maItems)
353 if (!xDeckDescriptor)
357 aData.msDisplayName = xDeckDescriptor->msTitle;
358 aData.mbIsCurrentDeck = item->mxButton->get_item_active(
"toggle");
359 aData.mbIsActive = !item->mbIsHidden;
360 aData.mbIsEnabled = item->mxButton->get_sensitive();
361 aMenuData.push_back(
aData);
367 if (sIdent.startsWith(
"select"))
373 if (sIdent.indexOf(
"customize") != -1)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
virtual bool EventNotify(NotifyEvent &rNEvt) override
virtual void dispose() override
std::unique_ptr< weld::Container > m_xContainer
const vcl::KeyCode & GetKeyCode() const
const KeyEvent * GetKeyEvent() const
const CommandEvent * GetCommandEvent() const
NotifyEventType GetType() const
static css::awt::KeyEvent st_VCLKey2AWTKey(const vcl::KeyCode &aKey)
static std::unique_ptr< AcceleratorExecute > createAcceleratorHelper()
sal_uInt16 GetCode() const
virtual void DataChanged(const DataChangedEvent &rDCEvt)
virtual void SetText(const OUString &rStr) override
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
constexpr sal_uInt16 KEY_F10
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
Reference< XComponentContext > getProcessComponentContext()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OUString GetCommandShortcut(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame)
Reference< XNameAccess > m_xContainer