summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2018-01-18 00:49:17 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2018-01-18 21:50:36 +0100
commitc5ecb2990123d666dde0d66ce38dc3b9f03802c4 (patch)
tree0e3a95dd3f206addfea5a74b5b7a3bca2f2875f4
parent829b0564959411d0cc64169fe69153a714050c0d (diff)
Move toolbars to the border window tearoff mechanism
and remove the one from ImplPopupFloatWin. Implemented using the FloatWinTitleType::TearOff case, which was unused otherwise. Change-Id: I82a86e5f5897ce1f2e76a2404bb382cbc007700c Reviewed-on: https://gerrit.libreoffice.org/48095 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
-rw-r--r--include/vcl/dockwin.hxx2
-rw-r--r--include/vcl/settings.hxx2
-rw-r--r--vcl/source/app/settings.cxx10
-rw-r--r--vcl/source/window/brdwin.cxx26
-rw-r--r--vcl/source/window/dockmgr.cxx226
5 files changed, 42 insertions, 224 deletions
diff --git a/include/vcl/dockwin.hxx b/include/vcl/dockwin.hxx
index 1378e07c1911..af10bceef5d5 100644
--- a/include/vcl/dockwin.hxx
+++ b/include/vcl/dockwin.hxx
@@ -112,7 +112,7 @@ private:
DECL_LINK( PopupModeEnd, FloatingWindow*, void );
void ImplEnableStartDocking() { mbStartDockingEnabled = true; }
bool ImplStartDockingEnabled() const { return mbStartDockingEnabled; }
- void ImplPreparePopupMode( FloatWinPopupFlags nFlags );
+ void ImplPreparePopupMode();
public:
ImplDockingWindowWrapper( const vcl::Window *pWindow );
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 9b6ab00f2029..6b061336f61d 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -483,8 +483,6 @@ public:
void SetFloatTitleHeight( long nSize );
long GetFloatTitleHeight() const;
- long GetTearOffTitleHeight() const;
-
void SetScrollBarSize( long nSize );
long GetScrollBarSize() const;
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 97723e7a21b5..5429c20a400c 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -156,7 +156,6 @@ struct ImplStyleData
long mnBorderSize;
long mnTitleHeight;
long mnFloatTitleHeight;
- long mnTearOffTitleHeight;
long mnScrollBarSize;
long mnSplitSize;
long mnSpinSize;
@@ -632,7 +631,6 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
mnBorderSize = rData.mnBorderSize;
mnTitleHeight = rData.mnTitleHeight;
mnFloatTitleHeight = rData.mnFloatTitleHeight;
- mnTearOffTitleHeight = rData.mnTearOffTitleHeight;
mnScrollBarSize = rData.mnScrollBarSize;
mnMinThumbSize = rData.mnMinThumbSize;
mnSplitSize = rData.mnSplitSize;
@@ -752,7 +750,6 @@ void ImplStyleData::SetStandardStyles()
mnBorderSize = 1;
mnTitleHeight = 18;
mnFloatTitleHeight = 13;
- mnTearOffTitleHeight = 8;
mbHighContrast = false;
mbUseSystemUIFonts = true;
mnUseFlatBorders = false;
@@ -1755,12 +1752,6 @@ StyleSettings::GetFloatTitleHeight() const
return mxData->mnFloatTitleHeight;
}
-long
-StyleSettings::GetTearOffTitleHeight() const
-{
- return mxData->mnTearOffTitleHeight;
-}
-
void
StyleSettings::SetScrollBarSize( long nSize )
{
@@ -2286,7 +2277,6 @@ bool StyleSettings::operator ==( const StyleSettings& rSet ) const
(mxData->mnBorderSize == rSet.mxData->mnBorderSize) &&
(mxData->mnTitleHeight == rSet.mxData->mnTitleHeight) &&
(mxData->mnFloatTitleHeight == rSet.mxData->mnFloatTitleHeight) &&
- (mxData->mnTearOffTitleHeight == rSet.mxData->mnTearOffTitleHeight) &&
(mxData->mnScrollBarSize == rSet.mxData->mnScrollBarSize) &&
(mxData->mnMinThumbSize == rSet.mxData->mnMinThumbSize) &&
(mxData->mnSplitSize == rSet.mxData->mnSplitSize) &&
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 5d8b14c7cde9..58914dd83fdc 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -36,6 +36,7 @@
#include <vcl/edit.hxx>
#include <vcl/metric.hxx>
#include <vcl/settings.hxx>
+#include <vcl/toolbox.hxx>
using namespace ::com::sun::star::uno;
@@ -153,7 +154,7 @@ void ImplBorderWindowView::ImplInitTitle(ImplBorderFrameData* pData)
{
const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
if (pData->mnTitleType == BorderWindowTitleType::Tearoff)
- pData->mnTitleHeight = rStyleSettings.GetTearOffTitleHeight();
+ pData->mnTitleHeight = ToolBox::ImplGetDragWidth(*pData->mpBorderWindow.get(), false) + 2;
else
{
if (pData->mnTitleType == BorderWindowTitleType::Small)
@@ -279,6 +280,9 @@ bool ImplBorderWindowView::ImplMouseMove( ImplBorderFrameData* pData, const Mous
pData->mnCloseState |= DrawButtonFlags::Highlight;
else if ( nHitTest & BorderWindowHitTest::Menu )
pData->mnMenuState |= DrawButtonFlags::Highlight;
+ else if ( nHitTest & BorderWindowHitTest::Title &&
+ pData->mnTitleType == BorderWindowTitleType::Tearoff && !rMEvt.IsLeaveWindow() )
+ ePtrStyle = PointerStyle::Move;
pData->mpBorderWindow->SetPointer( Pointer( ePtrStyle ) );
if( pData->mnCloseState != oldCloseState )
@@ -1310,7 +1314,8 @@ void ImplStdBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeigh
if (pData->mnTitleHeight)
{
// to improve symbol display force a minimum title height
- if( pData->mnTitleHeight < MIN_CAPTION_HEIGHT )
+ if (pData->mnTitleType != BorderWindowTitleType::Tearoff &&
+ pData->mnTitleHeight < MIN_CAPTION_HEIGHT)
pData->mnTitleHeight = MIN_CAPTION_HEIGHT;
// set a proper background for drawing
@@ -1418,7 +1423,7 @@ void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, con
vcl::Region oldClipRgn(rRenderContext.GetClipRegion());
// for popups, don't draw part of the frame
- if (pData->mnTitleType >= BorderWindowTitleType::Popup)
+ if (pData->mnTitleType >= BorderWindowTitleType::Tearoff)
{
FloatingWindow* pWin = dynamic_cast<FloatingWindow*>(pData->mpBorderWindow->GetWindow(GetWindowType::Client));
if (pWin)
@@ -1444,7 +1449,7 @@ void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, con
--aInRect.Bottom();
// restore
- if (pData->mnTitleType >= BorderWindowTitleType::Popup)
+ if (pData->mnTitleType >= BorderWindowTitleType::Tearoff)
rRenderContext.SetClipRegion(oldClipRgn);
// Draw Border
@@ -1469,10 +1474,12 @@ void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, con
aInRect = pData->maTitleRect;
// use no gradient anymore, just a static titlecolor
- if (pData->mnTitleType != BorderWindowTitleType::Popup)
- rRenderContext.SetFillColor(aFrameColor);
- else
+ if (pData->mnTitleType == BorderWindowTitleType::Tearoff)
+ rRenderContext.SetFillColor(rStyleSettings.GetFaceGradientColor());
+ else if (pData->mnTitleType == BorderWindowTitleType::Popup)
rRenderContext.SetFillColor(aFaceColor);
+ else
+ rRenderContext.SetFillColor(aFrameColor);
rRenderContext.SetTextColor(rStyleSettings.GetButtonTextColor());
tools::Rectangle aTitleRect(pData->maTitleRect);
@@ -1510,6 +1517,11 @@ void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, con
rRenderContext.DrawText(aInRect, pBorderWindow->GetText(), nTextStyle);
}
+ else
+ {
+ ToolBox::ImplDrawGrip(rRenderContext, aTitleRect, ToolBox::ImplGetDragWidth(rRenderContext, false),
+ WindowAlign::Left, false);
+ }
}
if (!pData->maCloseRect.IsEmpty())
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 57b83e568215..ed026a3fdf0d 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -408,42 +408,24 @@ tools::Rectangle DockingManager::GetPosSizePixel( const vcl::Window *pWindow )
class ImplPopupFloatWin : public FloatingWindow
{
private:
- bool mbMoving;
- bool mbTrackingEnabled;
- Point maDelta;
- bool mbHasGrip;
- void ImplSetBorder();
+ bool mbToolBox;
public:
- ImplPopupFloatWin( vcl::Window* pParent, bool bHasGrip );
+ ImplPopupFloatWin( vcl::Window* pParent, bool bToolBox );
virtual ~ImplPopupFloatWin() override;
-
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
- virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
- virtual void MouseMove( const MouseEvent& rMEvt ) override;
- virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
- virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
- virtual void Tracking( const TrackingEvent& rTEvt ) override;
- virtual void Resize() override;
-
- tools::Rectangle GetDragRect() const;
- Point GetToolboxPosition() const;
- void DrawGrip(vcl::RenderContext& rRenderContext);
- void DrawBorder(vcl::RenderContext& rRenderContext);
-
- bool hasGrip() const { return mbHasGrip; }
};
-ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, bool bHasGrip ) :
- FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW )
+ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, bool bToolBox ) :
+ FloatingWindow( pParent, bToolBox ? WB_BORDER | WB_POPUP | WB_SYSTEMWINDOW | WB_NOSHADOW : WB_STDPOPUP ),
+ mbToolBox( bToolBox )
{
- mpWindowImpl->mbToolbarFloatingWindow = true; // indicate window type, required for accessibility
- // which should not see this window as a toplevel window
- mbMoving = false;
- mbTrackingEnabled = false;
- mbHasGrip = bHasGrip;
-
- ImplSetBorder();
+ if ( bToolBox )
+ {
+ // indicate window type, required for accessibility
+ // which should not see this window as a toplevel window
+ mpWindowImpl->mbToolbarFloatingWindow = true;
+ }
}
ImplPopupFloatWin::~ImplPopupFloatWin()
@@ -453,6 +435,9 @@ ImplPopupFloatWin::~ImplPopupFloatWin()
css::uno::Reference< css::accessibility::XAccessible > ImplPopupFloatWin::CreateAccessible()
{
+ if ( !mbToolBox )
+ return FloatingWindow::CreateAccessible();
+
// switch off direct accessibility support for this window
// this is to avoid appearance of this window as standalone window in the accessibility hierarchy
@@ -462,166 +447,6 @@ css::uno::Reference< css::accessibility::XAccessible > ImplPopupFloatWin::Create
return css::uno::Reference< css::accessibility::XAccessible >();
}
-void ImplPopupFloatWin::ImplSetBorder()
-{
- // although we have no border in the sense of a borderwindow
- // we're using a special border for the grip
- // by setting those members the method SetOutputSizePixel() can
- // be used to set the proper window size
- mpWindowImpl->mnTopBorder = 1;
- if( hasGrip() )
- mpWindowImpl->mnTopBorder += 1 + ToolBox::ImplGetDragWidth( *this, false );
- mpWindowImpl->mnBottomBorder = 1;
- mpWindowImpl->mnLeftBorder = 1;
- mpWindowImpl->mnRightBorder = 1;
-}
-
-void ImplPopupFloatWin::Resize()
-{
- // the borderview overwrites the border during resize so restore it
- ImplSetBorder();
-}
-
-tools::Rectangle ImplPopupFloatWin::GetDragRect() const
-{
- if( !hasGrip() )
- return tools::Rectangle();
- return tools::Rectangle( 1, 1, GetOutputSizePixel().Width() - 1,
- 2 + ToolBox::ImplGetDragWidth( *this, false ) );
-}
-
-Point ImplPopupFloatWin::GetToolboxPosition() const
-{
- // return inner position where a toolbox could be placed
- return Point( 1, 1 + ( hasGrip() ? GetDragRect().getHeight() : 0 ) ); // grip + border
-}
-
-void ImplPopupFloatWin::DrawBorder(vcl::RenderContext& rRenderContext)
-{
- rRenderContext.SetFillColor();
- tools::Rectangle aRect( Point(), GetOutputSizePixel() );
-
- vcl::Region oldClipRgn( GetClipRegion( ) );
- vcl::Region aClipRgn( aRect );
- tools::Rectangle aItemClipRect( ImplGetItemEdgeClipRect() );
- if( !aItemClipRect.IsEmpty() )
- {
- aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
-
- // draw the excluded border part with the background color of a toolbox
- rRenderContext.SetClipRegion( vcl::Region( aItemClipRect ) );
- rRenderContext.SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
- rRenderContext.DrawRect( aRect );
-
- aClipRgn.Exclude( aItemClipRect );
- SetClipRegion( aClipRgn );
- }
- rRenderContext.SetLineColor( rRenderContext.GetSettings().GetStyleSettings().GetShadowColor() );
- rRenderContext.DrawRect( aRect );
- rRenderContext.SetClipRegion( oldClipRgn );
-}
-
-void ImplPopupFloatWin::DrawGrip(vcl::RenderContext& rRenderContext)
-{
- bool bLinecolor = rRenderContext.IsLineColor();
- Color aLinecolor = rRenderContext.GetLineColor();
- bool bFillcolor = rRenderContext.IsFillColor();
- Color aFillcolor = rRenderContext.GetFillColor();
-
- if (!ToolBox::AlwaysLocked()) // no grip if toolboxes are locked
- {
- ToolBox::ImplDrawGrip(rRenderContext, GetDragRect(),
- ToolBox::ImplGetDragWidth( *this, false ), WindowAlign::Left, false );
- }
-
- if (bLinecolor)
- rRenderContext.SetLineColor(aLinecolor);
- else
- rRenderContext.SetLineColor();
- if (bFillcolor)
- rRenderContext.SetFillColor(aFillcolor);
- else
- rRenderContext.SetFillColor();
-}
-
-void ImplPopupFloatWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
-{
- DrawBorder(rRenderContext);
- if (hasGrip())
- DrawGrip(rRenderContext);
-}
-
-void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
-{
- Point aMousePos = rMEvt.GetPosPixel();
-
- if( !ToolBox::AlwaysLocked() ) // no tear off if locking is enabled
- {
- if( mbTrackingEnabled && rMEvt.IsLeft() && GetDragRect().IsInside( aMousePos ) )
- {
- // start window move
- mbMoving = true;
- StartTracking( StartTrackingFlags::NoKeyCancel );
- return;
- }
- if( GetDragRect().IsInside( aMousePos ) )
- {
- if( GetPointer().GetStyle() != PointerStyle::Move )
- SetPointer( Pointer( PointerStyle::Move ) );
- }
- if( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) )
- {
- if( GetPointer().GetStyle() != PointerStyle::Arrow )
- SetPointer( Pointer( PointerStyle::Arrow ) );
- }
- }
-}
-
-void ImplPopupFloatWin::MouseButtonUp( const MouseEvent& rMEvt )
-{
- mbTrackingEnabled = false;
- FloatingWindow::MouseButtonUp( rMEvt );
-}
-
-void ImplPopupFloatWin::MouseButtonDown( const MouseEvent& rMEvt )
-{
- Point aMousePos = rMEvt.GetPosPixel();
- if( GetDragRect().IsInside( aMousePos ) )
- {
- // get mouse pos at a static window to have a fixed reference point
- PointerState aState = GetParent()->GetPointerState();
- if (HasMirroredGraphics() && IsRTLEnabled())
- ImplMirrorFramePos(aState.maPos);
- maDelta = aState.maPos - GetWindow( GetWindowType::Border )->GetPosPixel();
- mbTrackingEnabled = true;
- }
- else
- {
- mbTrackingEnabled = false;
- }
-}
-
-void ImplPopupFloatWin::Tracking( const TrackingEvent& rTEvt )
-{
- if( mbMoving )
- {
- if ( rTEvt.IsTrackingEnded() )
- {
- mbMoving = false;
- EndPopupMode( FloatWinPopupEndFlags::TearOff );
- }
- else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
- {
- // move the window according to mouse pos
- PointerState aState = GetParent()->GetPointerState();
- const OutputDevice *pOutDev = GetOutDev();
- if (pOutDev->HasMirroredGraphics() && IsRTLEnabled())
- ImplMirrorFramePos(aState.maPos);
- GetWindow( GetWindowType::Border )->SetPosPixel( aState.maPos - maDelta );
- }
- }
-}
-
ImplDockingWindowWrapper::ImplDockingWindowWrapper( const vcl::Window *pWindow )
: mpDockingWindow(const_cast<vcl::Window*>(pWindow))
, mpFloatWin(nullptr)
@@ -922,7 +747,7 @@ void ImplDockingWindowWrapper::ShowTitleButton( TitleButton nButton, bool bVisib
}
}
-void ImplDockingWindowWrapper::ImplPreparePopupMode( FloatWinPopupFlags nFlags )
+void ImplDockingWindowWrapper::ImplPreparePopupMode()
{
GetWindow()->Show( false, ShowFlags::NoFocusChange );
@@ -932,15 +757,8 @@ void ImplDockingWindowWrapper::ImplPreparePopupMode( FloatWinPopupFlags nFlags )
if( mpOldBorderWin.get() == GetWindow() )
mpOldBorderWin = nullptr; // no border window found
- bool bAllowTearOff = bool( nFlags & FloatWinPopupFlags::AllowTearOff );
- bool bUseStdPopup = GetWindow()->GetType() != WindowType::TOOLBOX;
-
// the new parent for popup mode
- VclPtr<FloatingWindow> pWin;
- if ( bUseStdPopup )
- pWin = VclPtr<FloatingWindow>::Create( mpParent, WB_STDPOPUP );
- else
- pWin = VclPtr<ImplPopupFloatWin>::Create( mpParent, bAllowTearOff );
+ VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, GetWindow()->GetType() == WindowType::TOOLBOX );
pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
// At least for DockingWindow, GetText() has a side effect of setting deferred
@@ -957,10 +775,6 @@ void ImplDockingWindowWrapper::ImplPreparePopupMode( FloatWinPopupFlags nFlags )
GetWindow()->mpWindowImpl->mnRightBorder = 0;
GetWindow()->mpWindowImpl->mnBottomBorder = 0;
- // position toolbox below the drag grip
- if ( !bUseStdPopup )
- GetWindow()->SetPosPixel( static_cast<ImplPopupFloatWin*>( pWin.get() )->GetToolboxPosition() );
-
// reparent borderwindow and window
if ( mpOldBorderWin )
mpOldBorderWin->SetParent( pWin );
@@ -982,7 +796,11 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, FloatWin
if( IsFloatingMode() )
return;
- ImplPreparePopupMode( nFlags );
+ ImplPreparePopupMode();
+
+ // don't allow tearoff, if globally disabled
+ if( GetWindow()->GetType() == WindowType::TOOLBOX && ToolBox::AlwaysLocked() )
+ nFlags &= ~FloatWinPopupFlags::AllowTearOff;
// if the subtoolbar was opened via keyboard make sure that key events
// will go into subtoolbar
@@ -1006,7 +824,7 @@ void ImplDockingWindowWrapper::StartPopupMode( const tools::Rectangle& rRect, Fl
if( IsFloatingMode() )
return;
- ImplPreparePopupMode( nFlags );
+ ImplPreparePopupMode();
mpFloatWin->StartPopupMode( rRect, nFlags );
GetWindow()->Show();
}