[Libreoffice-commits] core.git: 4 commits - vcl/source
Maxim Monastirsky
momonasmon at gmail.com
Sat Oct 8 21:54:59 UTC 2016
vcl/source/window/dockmgr.cxx | 108 +++++++++---------------------------------
1 file changed, 25 insertions(+), 83 deletions(-)
New commits:
commit 445f157a132ba977fc026746221f8e85daa289cb
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Sat Oct 8 22:34:13 2016 +0300
Add title-based tearoff to DockingManager, take 2
Change-Id: I2582756fd1fb6e823daa7336a7fb1ce5d752f83e
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 06cb139..0bc7ce2 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -1056,7 +1056,12 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, FloatWin
mpOldBorderWin = nullptr; // no border window found
// the new parent for popup mode
- VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, this, bool(nFlags & FloatWinPopupFlags::AllowTearOff) );
+ VclPtr<FloatingWindow> pWin;
+ bool bAllowTearOff = bool( nFlags & FloatWinPopupFlags::AllowTearOff );
+ if ( bAllowTearOff && !dynamic_cast< ToolBox* >( GetWindow() ) )
+ pWin = VclPtr<FloatingWindow>::Create( mpParent, WB_STDPOPUP );
+ else
+ pWin = VclPtr<ImplPopupFloatWin>::Create( mpParent, this, bAllowTearOff );
pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
pWin->SetText( GetWindow()->GetText() );
commit 23567618f0ee316aae080a7fa60e804282c0df07
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Sat Oct 8 22:32:22 2016 +0300
mbGripAtBottom is always true
Change-Id: I76db4c796933996cdf9d1782e9a6fb19ee7860a7
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index fcddef3..06cb139 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -462,7 +462,6 @@ private:
bool mbMoving;
bool mbTrackingEnabled;
Point maDelta;
- bool mbGripAtBottom;
bool mbHasGrip;
void ImplSetBorder();
@@ -480,7 +479,6 @@ public:
virtual void Resize() override;
Rectangle GetDragRect() const;
- Point GetToolboxPosition() const;
void DrawGrip(vcl::RenderContext& rRenderContext);
void DrawBorder(vcl::RenderContext& rRenderContext);
@@ -496,7 +494,6 @@ ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWra
mbHighlight = false;
mbMoving = false;
mbTrackingEnabled = false;
- mbGripAtBottom = true;
mbHasGrip = bHasGrip;
ImplSetBorder();
@@ -546,26 +543,11 @@ void ImplPopupFloatWin::Resize()
Rectangle ImplPopupFloatWin::GetDragRect() const
{
- Rectangle aRect;
- if( hasGrip() )
- {
- aRect = Rectangle( 1,1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
- if( mbGripAtBottom )
- {
- int height = GetOutputSizePixel().Height();
- aRect.Top() = height - 3 - POPUP_DRAGHEIGHT;
- aRect.Bottom() = aRect.Top() + 1 + POPUP_DRAGHEIGHT;
- }
- }
- return aRect;
-}
-
-Point ImplPopupFloatWin::GetToolboxPosition() const
-{
- // return inner position where a toolbox could be placed
- Point aPt( 1, 1 + ((mbGripAtBottom || !hasGrip()) ? 0 : GetDragRect().getHeight()) ); // grip + border
+ if( !hasGrip() )
+ return Rectangle();
- return aPt;
+ return Rectangle( 1, GetOutputSizePixel().Height() - 3 - POPUP_DRAGHEIGHT,
+ GetOutputSizePixel().Width() - 1, GetOutputSizePixel().Height() - 1 );
}
void ImplPopupFloatWin::DrawBorder(vcl::RenderContext& rRenderContext)
@@ -1087,8 +1069,8 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, FloatWin
GetWindow()->mpWindowImpl->mnRightBorder = 0;
GetWindow()->mpWindowImpl->mnBottomBorder = 0;
- // position toolbox below DragRect
- GetWindow()->SetPosPixel( pWin->GetToolboxPosition() );
+ // position toolbox above DragRect
+ GetWindow()->SetPosPixel( Point( 1, 1 ) );
// reparent borderwindow and window
if ( mpOldBorderWin )
commit 3e4e5717d470f4bdb3477da6a979184b363a07e5
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Sat Oct 8 22:10:32 2016 +0300
Just get the last window pos
Change-Id: I1cf0964d11e9045366697b75c2606df6f62aa438
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 984e5af..fcddef3 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -462,7 +462,6 @@ private:
bool mbMoving;
bool mbTrackingEnabled;
Point maDelta;
- Point maTearOffPosition;
bool mbGripAtBottom;
bool mbHasGrip;
void ImplSetBorder();
@@ -482,7 +481,6 @@ public:
Rectangle GetDragRect() const;
Point GetToolboxPosition() const;
- Point GetTearOffPosition() const;
void DrawGrip(vcl::RenderContext& rRenderContext);
void DrawBorder(vcl::RenderContext& rRenderContext);
@@ -570,13 +568,6 @@ Point ImplPopupFloatWin::GetToolboxPosition() const
return aPt;
}
-Point ImplPopupFloatWin::GetTearOffPosition() const
-{
- Point aPt( maTearOffPosition );
- //aPt += GetToolboxPosition(); // remove 'decoration'
- return aPt;
-}
-
void ImplPopupFloatWin::DrawBorder(vcl::RenderContext& rRenderContext)
{
rRenderContext.SetFillColor();
@@ -741,8 +732,7 @@ void ImplPopupFloatWin::MouseButtonDown( const MouseEvent& rMEvt )
PointerState aState = GetParent()->GetPointerState();
if (HasMirroredGraphics() && IsRTLEnabled())
ImplMirrorFramePos(aState.maPos);
- maTearOffPosition = GetWindow( GetWindowType::Border )->GetPosPixel();
- maDelta = aState.maPos - maTearOffPosition;
+ maDelta = aState.maPos - GetWindow( GetWindowType::Border )->GetPosPixel();
mbTrackingEnabled = true;
}
else
@@ -767,8 +757,7 @@ void ImplPopupFloatWin::Tracking( const TrackingEvent& rTEvt )
const OutputDevice *pOutDev = GetOutDev();
if (pOutDev->HasMirroredGraphics() && IsRTLEnabled())
ImplMirrorFramePos(aState.maPos);
- maTearOffPosition = aState.maPos - maDelta;
- GetWindow( GetWindowType::Border )->SetPosPixel( maTearOffPosition );
+ GetWindow( GetWindowType::Border )->SetPosPixel( aState.maPos - maDelta );
}
}
}
@@ -1136,8 +1125,7 @@ IMPL_LINK_NOARG(ImplDockingWindowWrapper, PopupModeEnd, FloatingWindow*, void)
GetWindow()->Show( false, ShowFlags::NoFocusChange );
// set parameter for handler before destroying floating window
- ImplPopupFloatWin *pPopupFloatWin = static_cast<ImplPopupFloatWin*>(mpFloatWin.get());
- EndPopupModeData aData( pPopupFloatWin->GetTearOffPosition(), mpFloatWin->IsPopupModeTearOff() );
+ EndPopupModeData aData( mpFloatWin->GetWindow( GetWindowType::Border )->GetPosPixel(), mpFloatWin->IsPopupModeTearOff() );
// before deleting change parent back, so we can delete the floating window alone
vcl::Window* pRealParent = GetWindow()->GetWindow( GetWindowType::Parent );
commit 9ffd74a37670f7c102595a460fb2c425eb58da62
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Sat Oct 8 21:59:02 2016 +0300
Revert "Add title-based tearoff to DockingManager"
Careful reading of the code reveals that WB_POPUP is what adds
the tearoff title, not WB_OWNERDRAWDECORATION, so we can use that
instead of introducing yet another title implementation into
ImplPopupFloatWin.
This reverts commit 6128a8311d37514c49c2fe3ba80f850a51de37d6.
Change-Id: I681686c9a0bd79d80f43ce213caeef77dcbab6b8
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 9caf5cc..984e5af 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -454,13 +454,6 @@ Rectangle DockingManager::GetPosSizePixel( const vcl::Window *pWindow )
#define POPUP_DRAGHEIGHT (POPUP_DRAGGRIP+POPUP_DRAGBORDER+POPUP_DRAGBORDER)
#define POPUP_DRAGWIDTH 20
-enum class TearOffStyle
-{
- Grip,
- Title,
- None
-};
-
class ImplPopupFloatWin : public FloatingWindow
{
private:
@@ -470,11 +463,12 @@ private:
bool mbTrackingEnabled;
Point maDelta;
Point maTearOffPosition;
- TearOffStyle meTearOffStyle;
+ bool mbGripAtBottom;
+ bool mbHasGrip;
void ImplSetBorder();
public:
- ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, TearOffStyle eStyle );
+ ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip );
virtual ~ImplPopupFloatWin() override;
virtual void dispose() override;
@@ -490,11 +484,12 @@ public:
Point GetToolboxPosition() const;
Point GetTearOffPosition() const;
void DrawGrip(vcl::RenderContext& rRenderContext);
- void DrawTitle(vcl::RenderContext& rRenderContext);
void DrawBorder(vcl::RenderContext& rRenderContext);
+
+ bool hasGrip() const { return mbHasGrip; }
};
-ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, TearOffStyle eStyle ) :
+ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ) :
FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW)
{
mpWindowImpl->mbToolbarFloatingWindow = true; // indicate window type, required for accessibility
@@ -503,7 +498,8 @@ ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWra
mbHighlight = false;
mbMoving = false;
mbTrackingEnabled = false;
- meTearOffStyle = eStyle;
+ mbGripAtBottom = true;
+ mbHasGrip = bHasGrip;
ImplSetBorder();
}
@@ -537,10 +533,8 @@ void ImplPopupFloatWin::ImplSetBorder()
// by setting those members the method SetOutputSizePixel() can
// be used to set the proper window size
mpWindowImpl->mnTopBorder = 1;
- if( meTearOffStyle == TearOffStyle::Grip )
+ if( hasGrip() )
mpWindowImpl->mnTopBorder += POPUP_DRAGHEIGHT+2;
- else if( meTearOffStyle == TearOffStyle::Title )
- mpWindowImpl->mnTopBorder += GetSettings().GetStyleSettings().GetTitleHeight()+2;
mpWindowImpl->mnBottomBorder = 1;
mpWindowImpl->mnLeftBorder = 1;
mpWindowImpl->mnRightBorder = 1;
@@ -554,23 +548,24 @@ void ImplPopupFloatWin::Resize()
Rectangle ImplPopupFloatWin::GetDragRect() const
{
- if( meTearOffStyle == TearOffStyle::Grip )
- {
- return Rectangle( 1, GetOutputSizePixel().Height() - 3 - POPUP_DRAGHEIGHT,
- GetOutputSizePixel().Width() - 1, GetOutputSizePixel().Height() - 1 );
- }
- else if( meTearOffStyle == TearOffStyle::Title )
+ Rectangle aRect;
+ if( hasGrip() )
{
- return Rectangle( 1, 1, GetOutputSizePixel().Width() - 1, GetSettings().GetStyleSettings().GetTitleHeight() + 2 );
+ aRect = Rectangle( 1,1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
+ if( mbGripAtBottom )
+ {
+ int height = GetOutputSizePixel().Height();
+ aRect.Top() = height - 3 - POPUP_DRAGHEIGHT;
+ aRect.Bottom() = aRect.Top() + 1 + POPUP_DRAGHEIGHT;
+ }
}
-
- return Rectangle();
+ return aRect;
}
Point ImplPopupFloatWin::GetToolboxPosition() const
{
// return inner position where a toolbox could be placed
- Point aPt( 1, 1 + ( meTearOffStyle != TearOffStyle::Title ? 0 : GetDragRect().getHeight()) ); // grip + border
+ Point aPt( 1, 1 + ((mbGripAtBottom || !hasGrip()) ? 0 : GetDragRect().getHeight()) ); // grip + border
return aPt;
}
@@ -696,33 +691,13 @@ void ImplPopupFloatWin::DrawGrip(vcl::RenderContext& rRenderContext)
rRenderContext.SetFillColor();
}
-void ImplPopupFloatWin::DrawTitle(vcl::RenderContext &rRenderContext)
-{
- Rectangle aRect(GetDragRect());
- aRect.Left() += 2;
- aRect.Right() -= 2;
-
- DrawTextFlags nTextStyle = DrawTextFlags::Left | DrawTextFlags::VCenter | DrawTextFlags::EndEllipsis | DrawTextFlags::Clip;
- rRenderContext.SetTextColor(GetSettings().GetStyleSettings().GetButtonTextColor());
- SetPointFont(rRenderContext, GetSettings().GetStyleSettings().GetTitleFont());
- rRenderContext.DrawText(aRect, GetText(), nTextStyle);
-}
-
void ImplPopupFloatWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
Rectangle aRect(Point(), GetOutputSizePixel());
-
- if (meTearOffStyle == TearOffStyle::Grip)
- {
- rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceGradientColor()));
- DrawGrip(rRenderContext);
- }
- else if ( meTearOffStyle == TearOffStyle::Title )
- {
- rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor()));
- DrawTitle(rRenderContext);
- }
+ rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceGradientColor()));
DrawBorder(rRenderContext);
+ if (hasGrip())
+ DrawGrip(rRenderContext);
}
void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
@@ -1110,15 +1085,7 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, FloatWin
mpOldBorderWin = nullptr; // no border window found
// the new parent for popup mode
- TearOffStyle eStyle = TearOffStyle::None;
- if ( nFlags & FloatWinPopupFlags::AllowTearOff )
- {
- if ( dynamic_cast< ToolBox* >( GetWindow() ) )
- eStyle = TearOffStyle::Grip;
- else
- eStyle = TearOffStyle::Title;
- }
- VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, this, eStyle );
+ VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, this, bool(nFlags & FloatWinPopupFlags::AllowTearOff) );
pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
pWin->SetText( GetWindow()->GetText() );
More information about the Libreoffice-commits
mailing list