summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-11-12 20:48:50 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-11-20 21:07:56 +0100
commit75b9109a2da35cf0f0914504145d84cf918c6af2 (patch)
treece444db75d6f2282e86d86c89c0cce66ab937c8d /include
parent94ea1c89e959069aa7c735317470712012df2362 (diff)
weld TabBar
Change-Id: I698f4dfc64bfa9bc4896111757616b4051b10293 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105797 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/sfx2/sidebar/FocusManager.hxx24
-rw-r--r--include/sfx2/sidebar/SidebarController.hxx10
-rw-r--r--include/sfx2/sidebar/TabBar.hxx43
-rw-r--r--include/sfx2/sidebar/Theme.hxx12
-rw-r--r--include/sfx2/strings.hrc6
5 files changed, 48 insertions, 47 deletions
diff --git a/include/sfx2/sidebar/FocusManager.hxx b/include/sfx2/sidebar/FocusManager.hxx
index a51f4502ec97..0bebe247e634 100644
--- a/include/sfx2/sidebar/FocusManager.hxx
+++ b/include/sfx2/sidebar/FocusManager.hxx
@@ -22,7 +22,9 @@
#include <tools/link.hxx>
#include <vcl/keycod.hxx>
-class Button;
+namespace weld {
+class Widget;
+}
namespace sfx2::sidebar {
@@ -48,8 +50,7 @@ class DeckTitleBar;
class FocusManager
{
public:
- FocusManager(const std::function<void(const Panel&)>& rShowPanelFunctor,
- const std::function<bool(const sal_Int32)> &rIsDeckOpenFunctor);
+ FocusManager(const std::function<void(const Panel&)>& rShowPanelFunctor);
~FocusManager();
/** Forget all panels and buttons. Remove all window listeners.
@@ -65,18 +66,16 @@ public:
void SetDeckTitle(DeckTitleBar* pDeckTitleBar);
void SetPanels(const SharedPanelContainer& rPanels);
- void SetButtons(const ::std::vector<Button*>& rButtons);
+ void SetButtons(const std::vector<weld::Widget*>& rButtons);
private:
VclPtr<DeckTitleBar> mpDeckTitleBar;
std::vector<VclPtr<Panel> > maPanels;
- std::vector<VclPtr<Button> > maButtons;
+ std::vector<weld::Widget*> maButtons;
const std::function<void(const Panel&)> maShowPanelFunctor;
- const std::function<bool(const sal_Int32)> mbIsDeckOpenFunctor;
enum PanelComponent
{
- PC_DeckTitle,
PC_DeckToolBox,
PC_PanelTitle,
PC_PanelToolBox,
@@ -94,7 +93,7 @@ private:
/** Listen for key events for panels and buttons.
*/
- DECL_LINK( WindowEventListener, VclWindowEvent&, void);
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
DECL_LINK(ChildEventListener, VclWindowEvent&, void);
void ClearPanels();
@@ -103,8 +102,8 @@ private:
/** Let the focus manager listen for window events for the given
window.
*/
- void RegisterWindow(vcl::Window& rWindow);
- void UnregisterWindow(vcl::Window& rWindow);
+ void RegisterWindow(weld::Widget& rWidget);
+ static void UnregisterWindow(weld::Widget& rWidget);
/** Remove the window from the panel or the button container.
*/
@@ -134,10 +133,11 @@ private:
void MoveFocusInsideDeckTitle(const FocusLocation& rLocation,
const sal_Int32 nDirection);
- void HandleKeyEvent(const vcl::KeyCode& rKeyCode,
- const vcl::Window& rWindow);
+ bool HandleKeyEvent(const vcl::KeyCode& rKeyCode,
+ const FocusLocation& rLocation);
FocusLocation GetFocusLocation(const vcl::Window& rWindow) const;
+ FocusLocation GetFocusLocation() const;
};
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index 3fe1e9a26c9e..cd4f329e99d9 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -246,11 +246,15 @@ private:
const Context& rContext);
void ShowPopupMenu (
- const tools::Rectangle& rButtonBox,
+ weld::Menu& rMainMenu,
+ weld::Menu& rSubMenu,
const ::std::vector<TabBar::DeckMenuData>& rMenuData) const;
- VclPtr<PopupMenu> CreatePopupMenu (
+ void PopulatePopupMenus(
+ weld::Menu& rMainButton,
+ weld::Menu& rSubMenu,
const ::std::vector<TabBar::DeckMenuData>& rMenuData) const;
- DECL_LINK(OnMenuItemSelected, Menu*, bool);
+ DECL_LINK(OnMenuItemSelected, const OString&, void);
+ DECL_LINK(OnSubMenuItemSelected, const OString&, void);
void BroadcastPropertyChange();
/** The close of the deck changes the width of the child window.
diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx
index 4eda225a29a1..53135697230d 100644
--- a/include/sfx2/sidebar/TabBar.hxx
+++ b/include/sfx2/sidebar/TabBar.hxx
@@ -22,18 +22,16 @@
#include <sfx2//dllapi.h>
#include <sfx2/sidebar/ResourceManager.hxx>
-#include <vcl/button.hxx>
+#include <vcl/InterimItemWindow.hxx>
#include <vcl/menu.hxx>
#include <vcl/window.hxx>
#include <functional>
-class Button;
-class CheckBox;
-class RadioButton;
-
namespace svt { class AcceleratorExecute; }
+namespace weld { class Toolbar; }
+
namespace sfx2::sidebar {
class FocusManager;
@@ -41,7 +39,7 @@ class SidebarController;
/** The tab bar is the container for the individual tabs.
*/
-class TabBar final : public vcl::Window
+class TabBar final : public InterimItemWindow
{
public:
/** DeckMenuData has entries for display name, and a flag:
@@ -57,7 +55,7 @@ public:
bool mbIsEnabled;
};
typedef ::std::function<void (
- const tools::Rectangle&,
+ weld::Menu& rMainMenu, weld::Menu& rSubMenu,
const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider;
TabBar (
vcl::Window* pParentWindow,
@@ -66,6 +64,8 @@ public:
const PopupMenuProvider& rPopupMenuProvider,
SidebarController* rParentSidebarController);
+ weld::Container* GetContainer() { return m_xContainer.get(); }
+
virtual ~TabBar() override;
virtual void dispose() override;
@@ -90,29 +90,44 @@ public:
private:
css::uno::Reference<css::frame::XFrame> mxFrame;
- VclPtr<RadioButton> mpMenuButton;
+
+ // This unusual auxillary builder is because without a toplevel GtkWindow
+ // gtk will warn on loading a .ui with an accelerator defined, so use a
+ // temporary toplevel to suppress that and move the contents after load
+ std::unique_ptr<weld::Builder> mxAuxBuilder;
+ std::unique_ptr<weld::Container> mxTempToplevel;
+ std::unique_ptr<weld::Widget> mxContents;
+
+ std::unique_ptr<weld::MenuButton> mxMenuButton;
+ std::unique_ptr<weld::Menu> mxMainMenu;
+ std::unique_ptr<weld::Menu> mxSubMenu;
+ std::unique_ptr<weld::Widget> mxMeasureBox;
class Item
{
+ private:
+ TabBar& mrTabBar;
+ std::unique_ptr<weld::Builder> mxBuilder;
public:
- DECL_LINK(HandleClick, Button*, void);
- VclPtr<RadioButton> mpButton;
+ Item(TabBar& rTabBar);
+ ~Item();
+ DECL_LINK(HandleClick, const OString&, void);
+ std::unique_ptr<weld::Toolbar> mxButton;
OUString msDeckId;
::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor;
bool mbIsHidden;
bool mbIsHiddenByDefault;
};
- typedef ::std::vector<Item> ItemContainer;
+ typedef ::std::vector<std::unique_ptr<Item>> ItemContainer;
ItemContainer maItems;
const ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor;
sal_Int32 mnMenuSeparatorY;
PopupMenuProvider maPopupMenuProvider;
- VclPtr<RadioButton> CreateTabItem (const DeckDescriptor& rDeckDescriptor);
+ static void CreateTabItem(weld::Toolbar& rButton, const DeckDescriptor& rDeckDescriptor);
css::uno::Reference<css::graphic::XGraphic> GetItemImage(const DeckDescriptor& rDeskDescriptor) const;
- void Layout();
void UpdateButtonIcons();
- DECL_LINK(OnToolboxClicked, Button*, void);
+ DECL_LINK(OnToolboxClicked, weld::ToggleButton&, void);
SidebarController* pParentSidebarController;
std::unique_ptr<svt::AcceleratorExecute> mpAccel;
diff --git a/include/sfx2/sidebar/Theme.hxx b/include/sfx2/sidebar/Theme.hxx
index 247d339958b1..9b35ce7aa6dd 100644
--- a/include/sfx2/sidebar/Theme.hxx
+++ b/include/sfx2/sidebar/Theme.hxx
@@ -55,7 +55,6 @@ public:
AnyItem_ = Pre_Image_,
- Image_TabBarMenu,
Image_CloseIndicator,
Image_Color_,
@@ -63,8 +62,6 @@ public:
Color_DeckTitleFont,
Color_PanelTitleFont,
Color_TabMenuSeparator,
- Color_TabItemBorder,
- Color_DropDownBorder,
Color_Highlight,
Color_HighlightText,
Color_DeckBackground,
@@ -72,8 +69,6 @@ public:
Color_PanelBackground,
Color_PanelTitleBarBackground,
Color_TabBarBackground,
- Color_TabItemBackgroundNormal,
- Color_TabItemBackgroundHighlight,
Color_HorizontalBorder,
Color_VerticalBorder,
Color_DropDownBackground,
@@ -86,17 +81,10 @@ public:
Int_PanelTitleBarHeight,
Int_TabMenuPadding,
Int_TabMenuSeparatorPadding,
- Int_TabItemWidth,
- Int_TabItemHeight,
Int_DeckLeftPadding,
Int_DeckTopPadding,
Int_DeckRightPadding,
Int_DeckBottomPadding,
- Int_TabBarLeftPadding,
- Int_TabBarTopPadding,
- Int_TabBarRightPadding,
- Int_TabBarBottomPadding,
- Int_ButtonCornerRadius,
Int_Bool_,
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 7930e5bbe24e..cb627807d8c8 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -294,15 +294,9 @@
#define STR_SIGNATURE_SHOW NC_("STR_SIGNATURE_SHOW", "Show Signatures")
#define STR_CLOSE_PANE NC_("STR_CLOSE_PANE", "Close Pane")
-#define STR_SFX_DOCK NC_("STR_SFX_DOCK", "Dock")
-#define STR_SFX_UNDOCK NC_("STR_SFX_UNDOCK", "Undock")
#define SFX_STR_SIDEBAR_MORE_OPTIONS NC_("SFX_STR_SIDEBAR_MORE_OPTIONS", "More Options")
#define SFX_STR_SIDEBAR_CLOSE_DECK NC_("SFX_STR_SIDEBAR_CLOSE_DECK", "Close Sidebar Deck")
-#define SFX_STR_SIDEBAR_SETTINGS NC_("SFX_STR_SIDEBAR_SETTINGS", "Sidebar Settings")
-#define SFX_STR_SIDEBAR_CUSTOMIZATION NC_("SFX_STR_SIDEBAR_CUSTOMIZATION", "Customization")
-#define SFX_STR_SIDEBAR_RESTORE NC_("SFX_STR_SIDEBAR_RESTORE", "Restore Default")
-#define SFX_STR_SIDEBAR_HIDE_SIDEBAR NC_("SFX_STR_SIDEBAR_HIDE_SIDEBAR", "Close Sidebar")
// Translators: default Impress template names
#define STR_TEMPLATE_NAME1 NC_("STR_TEMPLATE_NAME1", "Alizarin")