From dbf9664d16e7f80d269532d369d71c57322ac5ca Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Thu, 11 Sep 2014 14:10:21 +0200 Subject: vcl: Proof-of-concept NotebookBar implementation. Change-Id: I91535c13d68261f7195989ec78bd305cf572c87c --- framework/source/layoutmanager/layoutmanager.cxx | 7 + include/vcl/syswin.hxx | 3 + vcl/Library_vcl.mk | 1 + vcl/UIConfig_vcl.mk | 1 + vcl/inc/brdwin.hxx | 6 + vcl/source/window/brdwin.cxx | 53 +++- vcl/source/window/notebookbarwindow.cxx | 69 +++++ vcl/source/window/notebookbarwindow.hxx | 32 ++ vcl/source/window/syswin.cxx | 7 + vcl/uiconfig/ui/notebookbar.ui | 355 +++++++++++++++++++++++ 10 files changed, 520 insertions(+), 14 deletions(-) create mode 100644 vcl/source/window/notebookbarwindow.cxx create mode 100644 vcl/source/window/notebookbarwindow.hxx create mode 100644 vcl/uiconfig/ui/notebookbar.ui diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index a662ce8d970c..45fe8c58e8e3 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -782,7 +782,14 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible ) if ( pSysWindow ) { if ( bSetVisible ) + { pSysWindow->SetMenuBar(pMenuBar); + if (getenv("LO_USE_NOTEBOOKBAR")) + { + pSysWindow->CreateNotebookBar("vcl/ui/notebookbar.ui", m_xFrame); + pSysWindow->SetMenuBarMode(MenuBarMode::Hide); + } + } else pSysWindow->SetMenuBar( 0 ); } diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx index fe4eaf42ecd6..6692e7bf4656 100644 --- a/include/vcl/syswin.hxx +++ b/include/vcl/syswin.hxx @@ -28,6 +28,7 @@ class ModalDialog; class MenuBar; +class NotebookBarWindow; class TaskPaneList; class VclContainer; @@ -237,6 +238,8 @@ public: MenuBar* GetMenuBar() const { return mpMenuBar; } void SetMenuBarMode( MenuBarMode nMode ); + void CreateNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference& rFrame); + TaskPaneList* GetTaskPaneList(); void GetWindowStateData( WindowStateData& rData ) const; diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 6ec09591b0a2..ef8f7e9b773b 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -179,6 +179,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/window/mouse \ vcl/source/window/mouseevent \ vcl/source/window/msgbox \ + vcl/source/window/notebookbarwindow \ vcl/source/window/popupmenuwindow \ vcl/source/window/printdlg \ vcl/source/window/scrwnd \ diff --git a/vcl/UIConfig_vcl.mk b/vcl/UIConfig_vcl.mk index a81b30ed497a..f30252cd5868 100644 --- a/vcl/UIConfig_vcl.mk +++ b/vcl/UIConfig_vcl.mk @@ -13,6 +13,7 @@ $(eval $(call gb_UIConfig_add_uifiles,vcl,\ vcl/uiconfig/ui/cupspassworddialog \ vcl/uiconfig/ui/errornocontentdialog \ vcl/uiconfig/ui/errornoprinterdialog \ + vcl/uiconfig/ui/notebookbar \ vcl/uiconfig/ui/printdialog \ vcl/uiconfig/ui/printerdevicepage \ vcl/uiconfig/ui/printerpaperpage \ diff --git a/vcl/inc/brdwin.hxx b/vcl/inc/brdwin.hxx index 5811c052b419..f0962b33406f 100644 --- a/vcl/inc/brdwin.hxx +++ b/vcl/inc/brdwin.hxx @@ -22,8 +22,11 @@ #include +#include + class ImplBorderWindowView; enum class DrawButtonFlags; +class NotebookBarWindow; #define BORDERWINDOW_STYLE_OVERLAP ((sal_uInt16)0x0001) #define BORDERWINDOW_STYLE_BORDER ((sal_uInt16)0x0002) @@ -85,6 +88,7 @@ class ImplBorderWindow : public vcl::Window private: ImplBorderWindowView* mpBorderView; VclPtr mpMenuBarWindow; + VclPtr mpNotebookBarWindow; long mnMinWidth; long mnMinHeight; long mnMaxWidth; @@ -158,6 +162,8 @@ public: void SetMenuBarWindow( vcl::Window* pWindow ); void SetMenuBarMode( bool bHide ); + void SetNotebookBarWindow(const OUString& rUIXMLDescription, const css::uno::Reference& rFrame); + void SetMinOutputSize( long nWidth, long nHeight ) { mnMinWidth = nWidth; mnMinHeight = nHeight; } void SetMaxOutputSize( long nWidth, long nHeight ) diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx index cdc45bc068fe..f5395337f1c2 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -36,6 +36,8 @@ #include #include +#include "notebookbarwindow.hxx" + using namespace ::com::sun::star::uno; // useful caption height for title bar buttons @@ -1846,6 +1848,7 @@ void ImplBorderWindow::dispose() delete mpBorderView; mpBorderView = NULL; mpMenuBarWindow.clear(); + mpNotebookBarWindow.disposeAndClear(); vcl::Window::dispose(); } @@ -1926,12 +1929,14 @@ void ImplBorderWindow::Resize() { vcl::Window* pClientWindow = ImplGetClientWindow(); - if ( mpMenuBarWindow ) + sal_Int32 nLeftBorder; + sal_Int32 nTopBorder; + sal_Int32 nRightBorder; + sal_Int32 nBottomBorder; + mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder ); + + if (mpMenuBarWindow) { - sal_Int32 nLeftBorder; - sal_Int32 nTopBorder; - sal_Int32 nRightBorder; - sal_Int32 nBottomBorder; long nMenuHeight = mpMenuBarWindow->GetSizePixel().Height(); if ( mbMenuHide ) { @@ -1944,13 +1949,22 @@ void ImplBorderWindow::Resize() if ( !nMenuHeight ) nMenuHeight = mnOrgMenuHeight; } - mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder ); - mpMenuBarWindow->setPosSizePixel( nLeftBorder, - nTopBorder, - aSize.Width()-nLeftBorder-nRightBorder, - nMenuHeight, - PosSizeFlags::Pos | - PosSizeFlags::Width | PosSizeFlags::Height ); + mpMenuBarWindow->setPosSizePixel( + nLeftBorder, nTopBorder, + aSize.Width()-nLeftBorder-nRightBorder, nMenuHeight, + PosSizeFlags::Pos | PosSizeFlags::Width | PosSizeFlags::Height); + + // shift the notebookbar down accordingly + nTopBorder += nMenuHeight; + } + + if (mpNotebookBarWindow) + { + long nNotebookBarHeight = mpNotebookBarWindow->GetSizePixel().Height(); + mpNotebookBarWindow->setPosSizePixel( + nLeftBorder, nTopBorder, + aSize.Width() - nLeftBorder - nRightBorder, nNotebookBarHeight, + PosSizeFlags::Pos | PosSizeFlags::Width | PosSizeFlags::Height); } GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder, @@ -2177,12 +2191,23 @@ void ImplBorderWindow::SetMenuBarMode( bool bHide ) UpdateMenuHeight(); } +void ImplBorderWindow::SetNotebookBarWindow(const OUString& rUIXMLDescription, const css::uno::Reference& rFrame) +{ + mpNotebookBarWindow.reset(new NotebookBarWindow(this, "NotebookBar", rUIXMLDescription, rFrame)); + Resize(); + mpNotebookBarWindow->Show(); +} + void ImplBorderWindow::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const { - mpBorderView->GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder ); - if ( mpMenuBarWindow && !mbMenuHide ) + mpBorderView->GetBorder(rLeftBorder, rTopBorder, rRightBorder, rBottomBorder); + + if (mpMenuBarWindow && !mbMenuHide) rTopBorder += mpMenuBarWindow->GetSizePixel().Height(); + + if (mpNotebookBarWindow) + rTopBorder += mpNotebookBarWindow->GetSizePixel().Height(); } long ImplBorderWindow::CalcTitleWidth() const diff --git a/vcl/source/window/notebookbarwindow.cxx b/vcl/source/window/notebookbarwindow.cxx new file mode 100644 index 000000000000..09fc0677ce38 --- /dev/null +++ b/vcl/source/window/notebookbarwindow.cxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "notebookbarwindow.hxx" + +#include + +NotebookBarWindow::NotebookBarWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference &rFrame) + : Control(pParent) +{ + SetStyle(GetStyle() | WB_DIALOGCONTROL); + m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame); +} + +NotebookBarWindow::~NotebookBarWindow() +{ + disposeOnce(); +} + +void NotebookBarWindow::dispose() +{ + disposeBuilder(); + Control::dispose(); +} + +Size NotebookBarWindow::GetOptimalSize() const +{ + if (isLayoutEnabled(this)) + return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild)); + + return Control::GetOptimalSize(); +} + +void NotebookBarWindow::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags) +{ + bool bCanHandleSmallerWidth = false; + bool bCanHandleSmallerHeight = false; + + bool bIsLayoutEnabled = isLayoutEnabled(this); + Window *pChild = GetWindow(GetWindowType::FirstChild); + + if (bIsLayoutEnabled && pChild->GetType() == WINDOW_SCROLLWINDOW) + { + WinBits nStyle = pChild->GetStyle(); + if (nStyle & (WB_AUTOHSCROLL | WB_HSCROLL)) + bCanHandleSmallerWidth = true; + if (nStyle & (WB_AUTOVSCROLL | WB_VSCROLL)) + bCanHandleSmallerHeight = true; + } + + Size aSize(GetOptimalSize()); + if (!bCanHandleSmallerWidth) + nWidth = std::max(nWidth, aSize.Width()); + if (!bCanHandleSmallerHeight) + nHeight = std::max(nHeight, aSize.Height()); + + Control::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags); + + if (bIsLayoutEnabled && (nFlags & PosSizeFlags::Size)) + VclContainer::setLayoutAllocation(*pChild, Point(0, 0), Size(nWidth, nHeight)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/notebookbarwindow.hxx b/vcl/source/window/notebookbarwindow.hxx new file mode 100644 index 000000000000..0fc64a6399ce --- /dev/null +++ b/vcl/source/window/notebookbarwindow.hxx @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef VCL_SOURCE_WINDOW_NOTEBOOKBARWINDOW_HXX +#define VCL_SOURCE_WINDOW_NOTEBOOKBARWINDOW_HXX + +#include "menuwindow.hxx" + +#include +#include + +/// This implements Widget Layout-based notebook-like menu bar. +class NotebookBarWindow : public Control, public VclBuilderContainer +{ +public: + NotebookBarWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference &rFrame); + virtual ~NotebookBarWindow(); + virtual void dispose() SAL_OVERRIDE; + + virtual Size GetOptimalSize() const SAL_OVERRIDE; + virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All) SAL_OVERRIDE; +}; + +#endif // VCL_SOURCE_WINDOW_NOTEBOOKBARWINDOW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index cac6542649a9..7690197c6d2b 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -39,6 +39,8 @@ #include #include +#include "notebookbarwindow.hxx" + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -967,6 +969,11 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar) } } +void SystemWindow::CreateNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference& rFrame) +{ + static_cast(mpWindowImpl->mpBorderWindow.get())->SetNotebookBarWindow(rUIXMLDescription, rFrame); +} + void SystemWindow::SetMenuBarMode( MenuBarMode nMode ) { if ( mnMenuBarMode != nMode ) diff --git a/vcl/uiconfig/ui/notebookbar.ui b/vcl/uiconfig/ui/notebookbar.ui new file mode 100644 index 000000000000..8177e7aa6d29 --- /dev/null +++ b/vcl/uiconfig/ui/notebookbar.ui @@ -0,0 +1,355 @@ + + + + + True + False + + + True + False + True + True + + + True + True + True + True + + + True + False + 6 + + + True + False + vertical + 6 + + + True + True + True + .uno:Open + + + False + True + 0 + + + + + True + False + label + + + False + True + 1 + + + + + False + True + 0 + + + + + + + + + + + + + + + + True + False + File + True + + + False + + + + + True + False + 6 + + + True + False + vertical + 6 + + + True + False + + + True + True + True + .uno:Paste + image1 + none + top + True + + + False + True + 0 + + + + + True + False + vertical + + + True + True + True + .uno:Cut + none + 0 + True + + + False + True + 0 + + + + + True + True + True + .uno:Copy + none + 0 + True + + + False + True + 1 + + + + + True + True + True + .uno:FormatPaintbrush + none + 0 + True + + + False + True + 2 + + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + Clipboard + + + False + True + 1 + + + + + False + True + 0 + + + + + + + + + + + + + + 1 + + + + + True + False + Edit + True + + + 1 + False + + + + + + + + True + False + View + True + + + 2 + False + + + + + + + + True + False + Insert + True + + + 3 + False + + + + + + + + True + False + Format + True + + + 4 + False + + + + + + + + True + False + Table + True + + + 5 + False + + + + + + + + True + False + Tools + True + + + 6 + False + + + + + + + + True + False + Window + True + + + 7 + False + + + + + + + + True + False + Help + True + + + 8 + False + + + + + 0 + 0 + 1 + 1 + + + + + 0 + 0 + 1 + 1 + + + + + True + False + cmd/lc_paste.png + + -- cgit