GSoC notebookbar: BigToolBox

+ New container: sfxlo-BigToolBox
+ Writer: Paste button with dropdown menu

Change-Id: I8fa9ff2cbf594078cc2347bef790b8647ce4e6ea
Reviewed-on: https://gerrit.libreoffice.org/28156
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>
This commit is contained in:
Szymon Kłos 2016-08-16 09:40:27 +02:00 committed by Samuel Mehrbrodt
parent 9a3457b1be
commit ce59d3be31
8 changed files with 201 additions and 44 deletions

View File

@ -831,5 +831,8 @@
<glade-widget-class title="Box which can move own content to the popup" name="sfxlo-DropdownBox"
generic-name="DropdownBox" parent="GtkBox"
icon-name="widget-gtk-box"/>
<glade-widget-class title="Big ToolBox" name="sfxlo-BigToolBox"
generic-name="Big ToolBox" parent="GtkToolbar"
icon-name="widget-gtk-toolbar"/>
</glade-widget-classes>
</glade-catalog>

View File

@ -59,7 +59,7 @@ public:
css::uno::Reference<css::frame::XToolbarController> GetFirstController();
private:
protected:
typedef std::map<sal_uInt16, css::uno::Reference<css::frame::XToolbarController>> ControllerContainer;
ControllerContainer maControllers;
bool mbAreHandlersRegistered;

View File

@ -68,6 +68,9 @@ enum ToolBoxButtonSize { TOOLBOX_BUTTONSIZE_DONTCARE, TOOLBOX_BUTTONSIZE_SMALL,
// toolbox is prevented from centering the items
enum class ToolBoxLayoutMode { Normal, LockVert };
// Position of the text when icon and text are painted
enum ToolBoxTextPosition { Right, Bottom };
struct ImplToolSize
{
long mnWidth;
@ -146,6 +149,7 @@ private:
PointerStyle meLastStyle;
WinBits mnWinStyle;
ToolBoxLayoutMode meLayoutMode;
ToolBoxTextPosition meTextPosition;
Link<ToolBox *, void> maClickHdl;
Link<ToolBox *, void> maDoubleClickHdl;
Link<ToolBox *, void> maActivateHdl;
@ -511,6 +515,8 @@ public:
void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout );
void statusChanged(const css::frame::FeatureStateEvent& rEvent);
void SetToolBoxTextPosition( ToolBoxTextPosition ePosition );
};
inline void ToolBox::CheckItem( sal_uInt16 nItemId, bool bCheck )

View File

@ -240,6 +240,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/doc/saveastemplatedlg \
sfx2/source/explorer/nochaos \
sfx2/source/inet/inettbc \
sfx2/source/notebookbar/BigToolBox \
sfx2/source/notebookbar/DropdownBox \
sfx2/source/notebookbar/NotebookBarPopupMenu \
sfx2/source/notebookbar/NotebookbarToolBox \

View File

@ -0,0 +1,53 @@
/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "BigToolBox.hxx"
#include <sfx2/sidebar/ControllerFactory.hxx>
#include <sfx2/sidebar/Theme.hxx>
#include <sfx2/sidebar/Tools.hxx>
#include <sfx2/viewfrm.hxx>
#include <vcl/builderfactory.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/gradient.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <svtools/miscopt.hxx>
#include <com/sun/star/frame/XSubToolbarController.hpp>
#include <framework/addonsoptions.hxx>
namespace sfx2 { namespace notebookbar {
BigToolBox::BigToolBox(vcl::Window* pParent)
: SidebarToolBox(pParent)
{
SvtMiscOptions aMiscOptions;
aMiscOptions.RemoveListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
SetToolboxButtonSize(TOOLBOX_BUTTONSIZE_LARGE);
SetButtonType(ButtonType::SYMBOLTEXT);
SetToolBoxTextPosition(ToolBoxTextPosition::Bottom);
}
VCL_BUILDER_FACTORY(BigToolBox)
} } // end of namespace sfx2::notebookbar
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -0,0 +1,48 @@
/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SFX2_SOURCE_NOTEBOOKBAR_BIGTOOLBOX_HXX
#define INCLUDED_SFX2_SOURCE_NOTEBOOKBAR_BIGTOOLBOX_HXX
#include <sfx2/sidebar/SidebarToolBox.hxx>
#include <sfx2/dllapi.h>
#include <vcl/toolbox.hxx>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XToolbarController.hpp>
#include <com/sun/star/util/URL.hpp>
#include <map>
namespace sfx2 { namespace notebookbar {
/** BigToolBox
*/
class SFX2_DLLPUBLIC BigToolBox : public sfx2::sidebar::SidebarToolBox
{
public:
BigToolBox(vcl::Window* pParent);
};
} } // end of namespace sfx2::notebookbar
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -199,11 +199,6 @@
<property name="can_focus">False</property>
<property name="pixbuf">cmd/lc_zoomoptimal.png</property>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">cmd/lc_paste.png</property>
</object>
<object class="GtkImage" id="inserttableimg">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -421,15 +416,25 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="vcllo-SmallButton" id="button5">
<object class="sfxlo-BigToolBox" id="pastebox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="action_name">.uno:Paste</property>
<property name="image">image1</property>
<property name="relief">none</property>
<property name="image_position">top</property>
<property name="always_show_image">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="show_arrow">False</property>
<child>
<object class="GtkMenuToolButton" id="Paste">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="is_important">True</property>
<property name="action_name">.uno:Paste</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -441,8 +446,8 @@
<object class="GtkBox" id="box6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="sfxlo-NotebookbarToolBox" id="cutbox">
<property name="visible">True</property>
@ -666,11 +671,11 @@
</child>
<child>
<object class="GtkSeparator" id="separator30">
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="height_request">20</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
@ -720,11 +725,11 @@
</child>
<child>
<object class="GtkSeparator" id="separator32">
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="height_request">20</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
@ -735,11 +740,11 @@
</child>
<child>
<object class="GtkSeparator" id="separator31">
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="height_request">20</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
@ -814,8 +819,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Font</property>
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box77">
<property name="visible">True</property>
@ -945,8 +950,8 @@
<object class="GtkBox" id="box19">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="sfxlo-NotebookbarToolBox" id="numberbullet">
<property name="visible">True</property>
@ -1113,8 +1118,8 @@
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="column_spacing">6</property>
<property name="valign">center</property>
<property name="column_spacing">6</property>
<child>
<object class="sfxlo-NotebookbarToolBox" id="verticalalignment1">
<property name="visible">True</property>
@ -1348,8 +1353,8 @@
<object class="GtkBox" id="box32">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box66">
<property name="visible">True</property>

View File

@ -1383,6 +1383,7 @@ void ToolBox::ImplInitToolBoxData()
meLastStyle = PointerStyle::Arrow;
mnWinStyle = 0;
meLayoutMode = ToolBoxLayoutMode::Normal;
meTextPosition = ToolBoxTextPosition::Right;
mnLastFocusItemId = 0;
mnKeyModifier = 0;
mnActivateCount = 0;
@ -1854,14 +1855,28 @@ bool ToolBox::ImplCalcItem()
it->maItemSize.Width() = bText ? GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET : 0;
it->maItemSize.Height() = bText ? GetTextHeight() : 0;
// leave space between image and text
if( bText )
it->maItemSize.Width() += TB_IMAGETEXTOFFSET;
if ( meTextPosition == ToolBoxTextPosition::Right )
{
// leave space between image and text
if( bText )
it->maItemSize.Width() += TB_IMAGETEXTOFFSET;
// image and text side by side
it->maItemSize.Width() += it->maImage.GetSizePixel().Width();
if ( it->maImage.GetSizePixel().Height() > it->maItemSize.Height() )
it->maItemSize.Height() = it->maImage.GetSizePixel().Height();
// image and text side by side
it->maItemSize.Width() += it->maImage.GetSizePixel().Width();
if ( it->maImage.GetSizePixel().Height() > it->maItemSize.Height() )
it->maItemSize.Height() = it->maImage.GetSizePixel().Height();
}
else
{
// leave space between image and text
if( bText )
it->maItemSize.Height() += TB_IMAGETEXTOFFSET;
// text below image
it->maItemSize.Height() += it->maImage.GetSizePixel().Height();
if ( it->maImage.GetSizePixel().Width() > it->maItemSize.Width() )
it->maItemSize.Width() = it->maImage.GetSizePixel().Width();
}
it->mbVisibleText = bText;
}
@ -1886,8 +1901,16 @@ bool ToolBox::ImplCalcItem()
// add in drop down arrow
if( it->mnBits & ToolBoxItemBits::DROPDOWN )
{
it->maItemSize.Width() += nDropDownArrowWidth;
it->mnDropDownArrowWidth = nDropDownArrowWidth;
if ( meTextPosition == ToolBoxTextPosition::Right )
{
it->maItemSize.Width() += nDropDownArrowWidth;
it->mnDropDownArrowWidth = nDropDownArrowWidth;
}
else
{
it->maItemSize.Height() += nDropDownArrowWidth;
it->mnDropDownArrowWidth = nDropDownArrowWidth;
}
}
// text items will be rotated in vertical mode
@ -1956,7 +1979,8 @@ bool ToolBox::ImplCalcItem()
ImplAddButtonBorder( nMaxWidth, nMaxHeight, mpData->mbNativeButtons );
}
if( !ImplIsFloatingMode() && GetToolboxButtonSize() != TOOLBOX_BUTTONSIZE_DONTCARE )
if( !ImplIsFloatingMode() && GetToolboxButtonSize() != TOOLBOX_BUTTONSIZE_DONTCARE
&& ( meTextPosition == ToolBoxTextPosition::Right ) )
{
// make sure all vertical toolbars have the same width and horizontal have the same height
// this depends on the used button sizes
@ -3164,7 +3188,8 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos,
// draw the image
nImageOffX = nOffX;
nImageOffY = nOffY;
if ( (pItem->mnBits & (ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWN)) || bText )
if ( ( (pItem->mnBits & (ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWN)) || bText )
&& ( meTextPosition == ToolBoxTextPosition::Right ) )
{
// left align also to leave space for drop down arrow
// and when drawing text+image
@ -3175,7 +3200,8 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos,
else
{
nImageOffX += (nBtnWidth-aImageSize.Width())/2;
nImageOffY += (nBtnHeight-aImageSize.Height())/2;
if ( meTextPosition == ToolBoxTextPosition::Right )
nImageOffY += (nBtnHeight-aImageSize.Height())/2;
}
if ( nHighlight != 0 || (pItem->meState == TRISTATE_TRUE) )
{
@ -3223,12 +3249,21 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos,
}
else
{
// center vertically
nTextOffY += (nBtnHeight-aTxtSize.Height())/2;
if ( meTextPosition == ToolBoxTextPosition::Right )
{
// center vertically
nTextOffY += (nBtnHeight-aTxtSize.Height())/2;
// add in image offset
if( bImage )
nTextOffX = nImageOffX + aImageSize.Width() + TB_IMAGETEXTOFFSET;
// add in image offset
if( bImage )
nTextOffX = nImageOffX + aImageSize.Width() + TB_IMAGETEXTOFFSET;
}
else
{
long nArrowHeight = ( pItem->mnBits & ToolBoxItemBits::DROPDOWN )
? TB_DROPDOWNARROWWIDTH : 0;
nTextOffY += nBtnHeight - aTxtSize.Height() - nArrowHeight;
}
}
// draw selection only if not already drawn during image output (see above)
@ -3253,7 +3288,7 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos,
// paint optional drop down arrow
if ( pItem->mnBits & ToolBoxItemBits::DROPDOWN )
{
Rectangle aDropDownRect( pItem->GetDropDownRect( mbHorz ) );
Rectangle aDropDownRect( pItem->GetDropDownRect( mbHorz && ( meTextPosition == ToolBoxTextPosition::Right ) ) );
bool bSetColor = true;
if ( !pItem->mbEnabled || !IsEnabled() )
{
@ -3887,7 +3922,8 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
// was dropdown arrow pressed
if( (it->mnBits & ToolBoxItemBits::DROPDOWN) )
{
if( ( (it->mnBits & ToolBoxItemBits::DROPDOWNONLY) == ToolBoxItemBits::DROPDOWNONLY) || it->GetDropDownRect( mbHorz ).IsInside( aMousePos ))
if( ( (it->mnBits & ToolBoxItemBits::DROPDOWNONLY) == ToolBoxItemBits::DROPDOWNONLY)
|| it->GetDropDownRect( mbHorz && ( meTextPosition == ToolBoxTextPosition::Right ) ).IsInside( aMousePos ))
{
// dropdownonly always triggers the dropdown handler, over the whole button area
@ -5658,4 +5694,9 @@ void ToolBox::SetToolbarLayoutMode( ToolBoxLayoutMode eLayout )
meLayoutMode = eLayout;
}
void ToolBox::SetToolBoxTextPosition( ToolBoxTextPosition ePosition )
{
meTextPosition = ePosition;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */