summaryrefslogtreecommitdiff
path: root/vcl/source/window/dockwin.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 00:04:11 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 01:41:02 +0200
commitce47b1a9c68a27fc37594148f6be2661f27120ea (patch)
tree4c9b5c3da29b76c7c8eb23cdbf85c496b0efd87e /vcl/source/window/dockwin.cxx
parent6fc2a300ad8b1c6936b513eff94fd527ea74b469 (diff)
loplugin:flatten in vcl/window
Change-Id: I94e69e988f038e85b1fb78985211d478bb5ed9b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100033 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/window/dockwin.cxx')
-rw-r--r--vcl/source/window/dockwin.cxx388
1 files changed, 194 insertions, 194 deletions
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
index 7c0daa54bc18..bae44f7bdaac 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -328,19 +328,19 @@ void DockingWindow::ImplInitSettings()
{
// Hack: to be able to build DockingWindows w/o background before switching
// TODO: Hack
- if ( IsBackground() )
- {
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if ( !IsBackground() )
+ return;
- Color aColor;
- if ( IsControlBackground() )
- aColor = GetControlBackground();
- else if ( Window::GetStyle() & WB_3DLOOK )
- aColor = rStyleSettings.GetFaceColor();
- else
- aColor = rStyleSettings.GetWindowColor();
- SetBackground( aColor );
- }
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ Color aColor;
+ if ( IsControlBackground() )
+ aColor = GetControlBackground();
+ else if ( Window::GetStyle() & WB_3DLOOK )
+ aColor = rStyleSettings.GetFaceColor();
+ else
+ aColor = rStyleSettings.GetWindowColor();
+ SetBackground( aColor );
}
DockingWindow::DockingWindow( WindowType nType ) :
@@ -407,113 +407,113 @@ void DockingWindow::Tracking( const TrackingEvent& rTEvt )
if( GetDockingManager()->IsDockable( this ) ) // new docking interface
return Window::Tracking( rTEvt );
- if ( mbDocking )
+ if ( !mbDocking )
+ return;
+
+ if ( rTEvt.IsTrackingEnded() )
{
- if ( rTEvt.IsTrackingEnded() )
+ mbDocking = false;
+ if ( mbDragFull )
{
- mbDocking = false;
- if ( mbDragFull )
+ // reset old state on Cancel
+ if ( rTEvt.IsTrackingCanceled() )
{
- // reset old state on Cancel
- if ( rTEvt.IsTrackingCanceled() )
- {
- StartDocking();
- tools::Rectangle aRect( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) );
- EndDocking( aRect, mbStartFloat );
- }
+ StartDocking();
+ tools::Rectangle aRect( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) );
+ EndDocking( aRect, mbStartFloat );
}
- else
+ }
+ else
+ {
+ HideTracking();
+ if ( rTEvt.IsTrackingCanceled() )
{
- HideTracking();
- if ( rTEvt.IsTrackingCanceled() )
- {
- mbDockCanceled = true;
- EndDocking( tools::Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
- mbDockCanceled = false;
- }
- else
- EndDocking( tools::Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
+ mbDockCanceled = true;
+ EndDocking( tools::Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
+ mbDockCanceled = false;
}
+ else
+ EndDocking( tools::Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
}
- // dock only for non-synthetic MouseEvents
- else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
+ }
+ // dock only for non-synthetic MouseEvents
+ else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
+ {
+ Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
+ Point aFrameMousePos = ImplOutputToFrame( aMousePos );
+ Size aFrameSize = mpWindowImpl->mpFrameWindow->GetOutputSizePixel();
+ if ( aFrameMousePos.X() < 0 )
+ aFrameMousePos.setX( 0 );
+ if ( aFrameMousePos.Y() < 0 )
+ aFrameMousePos.setY( 0 );
+ if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
+ aFrameMousePos.setX( aFrameSize.Width()-1 );
+ if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
+ aFrameMousePos.setY( aFrameSize.Height()-1 );
+ aMousePos = ImplFrameToOutput( aFrameMousePos );
+ aMousePos.AdjustX( -(maMouseOff.X()) );
+ aMousePos.AdjustY( -(maMouseOff.Y()) );
+ Point aFramePos = ImplOutputToFrame( aMousePos );
+ tools::Rectangle aTrackRect( aFramePos, Size( mnTrackWidth, mnTrackHeight ) );
+ tools::Rectangle aCompRect = aTrackRect;
+ aFramePos.AdjustX(maMouseOff.X() );
+ aFramePos.AdjustY(maMouseOff.Y() );
+ if ( mbDragFull )
+ StartDocking();
+ bool bFloatMode = Docking( aFramePos, aTrackRect );
+ if ( mbLastFloatMode != bFloatMode )
{
- Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
- Point aFrameMousePos = ImplOutputToFrame( aMousePos );
- Size aFrameSize = mpWindowImpl->mpFrameWindow->GetOutputSizePixel();
- if ( aFrameMousePos.X() < 0 )
- aFrameMousePos.setX( 0 );
- if ( aFrameMousePos.Y() < 0 )
- aFrameMousePos.setY( 0 );
- if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
- aFrameMousePos.setX( aFrameSize.Width()-1 );
- if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
- aFrameMousePos.setY( aFrameSize.Height()-1 );
- aMousePos = ImplFrameToOutput( aFrameMousePos );
- aMousePos.AdjustX( -(maMouseOff.X()) );
- aMousePos.AdjustY( -(maMouseOff.Y()) );
- Point aFramePos = ImplOutputToFrame( aMousePos );
- tools::Rectangle aTrackRect( aFramePos, Size( mnTrackWidth, mnTrackHeight ) );
- tools::Rectangle aCompRect = aTrackRect;
- aFramePos.AdjustX(maMouseOff.X() );
- aFramePos.AdjustY(maMouseOff.Y() );
- if ( mbDragFull )
- StartDocking();
- bool bFloatMode = Docking( aFramePos, aTrackRect );
- if ( mbLastFloatMode != bFloatMode )
+ if ( bFloatMode )
{
- if ( bFloatMode )
- {
- aTrackRect.AdjustLeft( -mnDockLeft );
- aTrackRect.AdjustTop( -mnDockTop );
- aTrackRect.AdjustRight(mnDockRight );
- aTrackRect.AdjustBottom(mnDockBottom );
- }
- else
- {
- if ( aCompRect == aTrackRect )
- {
- aTrackRect.AdjustLeft(mnDockLeft );
- aTrackRect.AdjustTop(mnDockTop );
- aTrackRect.AdjustRight( -mnDockRight );
- aTrackRect.AdjustBottom( -mnDockBottom );
- }
- }
- mbLastFloatMode = bFloatMode;
+ aTrackRect.AdjustLeft( -mnDockLeft );
+ aTrackRect.AdjustTop( -mnDockTop );
+ aTrackRect.AdjustRight(mnDockRight );
+ aTrackRect.AdjustBottom(mnDockBottom );
}
- if ( mbDragFull )
+ else
{
- Point aOldPos = OutputToScreenPixel( Point() );
- EndDocking( aTrackRect, mbLastFloatMode );
- // repaint if state or position has changed
- if ( aOldPos != OutputToScreenPixel( Point() ) )
+ if ( aCompRect == aTrackRect )
{
- ImplUpdateAll();
- ImplGetFrameWindow()->ImplUpdateAll();
+ aTrackRect.AdjustLeft(mnDockLeft );
+ aTrackRect.AdjustTop(mnDockTop );
+ aTrackRect.AdjustRight( -mnDockRight );
+ aTrackRect.AdjustBottom( -mnDockBottom );
}
-// EndDocking( aTrackRect, mbLastFloatMode );
}
- else
+ mbLastFloatMode = bFloatMode;
+ }
+ if ( mbDragFull )
+ {
+ Point aOldPos = OutputToScreenPixel( Point() );
+ EndDocking( aTrackRect, mbLastFloatMode );
+ // repaint if state or position has changed
+ if ( aOldPos != OutputToScreenPixel( Point() ) )
{
- ShowTrackFlags nTrackStyle;
- if ( bFloatMode )
- nTrackStyle = ShowTrackFlags::Big;
- else
- nTrackStyle = ShowTrackFlags::Object;
- tools::Rectangle aShowTrackRect = aTrackRect;
- aShowTrackRect.SetPos( ImplFrameToOutput( aShowTrackRect.TopLeft() ) );
- ShowTracking( aShowTrackRect, nTrackStyle );
-
- // recalculate mouse offset, as the rectangle was changed
- maMouseOff.setX( aFramePos.X() - aTrackRect.Left() );
- maMouseOff.setY( aFramePos.Y() - aTrackRect.Top() );
+ ImplUpdateAll();
+ ImplGetFrameWindow()->ImplUpdateAll();
}
-
- mnTrackX = aTrackRect.Left();
- mnTrackY = aTrackRect.Top();
- mnTrackWidth = aTrackRect.GetWidth();
- mnTrackHeight = aTrackRect.GetHeight();
+// EndDocking( aTrackRect, mbLastFloatMode );
}
+ else
+ {
+ ShowTrackFlags nTrackStyle;
+ if ( bFloatMode )
+ nTrackStyle = ShowTrackFlags::Big;
+ else
+ nTrackStyle = ShowTrackFlags::Object;
+ tools::Rectangle aShowTrackRect = aTrackRect;
+ aShowTrackRect.SetPos( ImplFrameToOutput( aShowTrackRect.TopLeft() ) );
+ ShowTracking( aShowTrackRect, nTrackStyle );
+
+ // recalculate mouse offset, as the rectangle was changed
+ maMouseOff.setX( aFramePos.X() - aTrackRect.Left() );
+ maMouseOff.setY( aFramePos.Y() - aTrackRect.Top() );
+ }
+
+ mnTrackX = aTrackRect.Left();
+ mnTrackY = aTrackRect.Top();
+ mnTrackWidth = aTrackRect.GetWidth();
+ mnTrackHeight = aTrackRect.GetHeight();
}
}
@@ -698,103 +698,103 @@ void DockingWindow::SetFloatingMode( bool bFloatMode )
pWrapper->SetFloatingMode( bFloatMode );
return;
}
- if ( IsFloatingMode() != bFloatMode )
+ if ( IsFloatingMode() == bFloatMode )
+ return;
+
+ if ( !PrepareToggleFloatingMode() ) // changes to floating mode can be vetoed
+ return;
+
+ bool bVisible = IsVisible();
+
+ if ( bFloatMode )
{
- if ( PrepareToggleFloatingMode() ) // changes to floating mode can be vetoed
- {
- bool bVisible = IsVisible();
+ // set deferred properties early, so border width will end up
+ // in our mpWindowImpl->mnBorderWidth, not in mpBorderWindow.
+ // (see its usage in setPosSizeOnContainee and GetOptimalSize.)
+ setDeferredProperties();
- if ( bFloatMode )
- {
- // set deferred properties early, so border width will end up
- // in our mpWindowImpl->mnBorderWidth, not in mpBorderWindow.
- // (see its usage in setPosSizeOnContainee and GetOptimalSize.)
- setDeferredProperties();
-
- Show( false, ShowFlags::NoFocusChange );
-
- maDockPos = Window::GetPosPixel();
-
- vcl::Window* pRealParent = mpWindowImpl->mpRealParent;
- mpOldBorderWin = mpWindowImpl->mpBorderWindow;
-
- VclPtrInstance<ImplDockFloatWin> pWin(
- mpImplData->mpParent,
- mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ? mnFloatBits | WB_SYSTEMWINDOW : mnFloatBits,
- this );
- mpFloatWin = pWin;
- mpWindowImpl->mpBorderWindow = nullptr;
- mpWindowImpl->mnLeftBorder = 0;
- mpWindowImpl->mnTopBorder = 0;
- mpWindowImpl->mnRightBorder = 0;
- mpWindowImpl->mnBottomBorder = 0;
- // if the parent gets destroyed, we also have to reset the parent of the BorderWindow
- if ( mpOldBorderWin )
- mpOldBorderWin->SetParent( pWin );
-
- // #i123765# reset the buffered DropTargets when undocking, else it may not
- // be correctly initialized
- mpWindowImpl->mxDNDListenerContainer.clear();
-
- SetParent( pWin );
- SetPosPixel( Point() );
- mpWindowImpl->mpBorderWindow = pWin;
- pWin->mpWindowImpl->mpClientWindow = this;
- mpWindowImpl->mpRealParent = pRealParent;
- pWin->SetText( Window::GetText() );
- Size aSize(Window::GetSizePixel());
- pWin->SetOutputSizePixel(aSize);
- pWin->SetPosPixel( maFloatPos );
- // pass on DockingData to FloatingWindow
- pWin->ShowTitleButton( TitleButton::Docking, mbDockBtn );
- pWin->ShowTitleButton( TitleButton::Hide, mbHideBtn );
- if ( mbRollUp )
- pWin->RollUp();
- else
- pWin->RollDown();
- pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
- pWin->SetMinOutputSizePixel( maMinOutSize );
-
- pWin->SetMaxOutputSizePixel( mpImplData->maMaxOutSize );
-
- ToggleFloatingMode();
-
- if ( bVisible )
- Show();
- }
- else
- {
- Show( false, ShowFlags::NoFocusChange );
-
- // store FloatingData in FloatingWindow
- maFloatPos = mpFloatWin->GetPosPixel();
- mbDockBtn = mpFloatWin->IsTitleButtonVisible( TitleButton::Docking );
- mbHideBtn = mpFloatWin->IsTitleButtonVisible( TitleButton::Hide );
- mbRollUp = mpFloatWin->IsRollUp();
- maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
- maMinOutSize = mpFloatWin->GetMinOutputSizePixel();
- mpImplData->maMaxOutSize = mpFloatWin->GetMaxOutputSizePixel();
-
- vcl::Window* pRealParent = mpWindowImpl->mpRealParent;
- mpWindowImpl->mpBorderWindow = nullptr;
- if ( mpOldBorderWin )
- {
- SetParent( mpOldBorderWin );
- static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
- mpOldBorderWin->Resize();
- }
- mpWindowImpl->mpBorderWindow = mpOldBorderWin;
- SetParent( pRealParent );
- mpWindowImpl->mpRealParent = pRealParent;
- mpFloatWin.disposeAndClear();
- SetPosPixel( maDockPos );
+ Show( false, ShowFlags::NoFocusChange );
- ToggleFloatingMode();
+ maDockPos = Window::GetPosPixel();
+
+ vcl::Window* pRealParent = mpWindowImpl->mpRealParent;
+ mpOldBorderWin = mpWindowImpl->mpBorderWindow;
+
+ VclPtrInstance<ImplDockFloatWin> pWin(
+ mpImplData->mpParent,
+ mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ? mnFloatBits | WB_SYSTEMWINDOW : mnFloatBits,
+ this );
+ mpFloatWin = pWin;
+ mpWindowImpl->mpBorderWindow = nullptr;
+ mpWindowImpl->mnLeftBorder = 0;
+ mpWindowImpl->mnTopBorder = 0;
+ mpWindowImpl->mnRightBorder = 0;
+ mpWindowImpl->mnBottomBorder = 0;
+ // if the parent gets destroyed, we also have to reset the parent of the BorderWindow
+ if ( mpOldBorderWin )
+ mpOldBorderWin->SetParent( pWin );
+
+ // #i123765# reset the buffered DropTargets when undocking, else it may not
+ // be correctly initialized
+ mpWindowImpl->mxDNDListenerContainer.clear();
+
+ SetParent( pWin );
+ SetPosPixel( Point() );
+ mpWindowImpl->mpBorderWindow = pWin;
+ pWin->mpWindowImpl->mpClientWindow = this;
+ mpWindowImpl->mpRealParent = pRealParent;
+ pWin->SetText( Window::GetText() );
+ Size aSize(Window::GetSizePixel());
+ pWin->SetOutputSizePixel(aSize);
+ pWin->SetPosPixel( maFloatPos );
+ // pass on DockingData to FloatingWindow
+ pWin->ShowTitleButton( TitleButton::Docking, mbDockBtn );
+ pWin->ShowTitleButton( TitleButton::Hide, mbHideBtn );
+ if ( mbRollUp )
+ pWin->RollUp();
+ else
+ pWin->RollDown();
+ pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
+ pWin->SetMinOutputSizePixel( maMinOutSize );
- if ( bVisible )
- Show();
- }
+ pWin->SetMaxOutputSizePixel( mpImplData->maMaxOutSize );
+
+ ToggleFloatingMode();
+
+ if ( bVisible )
+ Show();
+ }
+ else
+ {
+ Show( false, ShowFlags::NoFocusChange );
+
+ // store FloatingData in FloatingWindow
+ maFloatPos = mpFloatWin->GetPosPixel();
+ mbDockBtn = mpFloatWin->IsTitleButtonVisible( TitleButton::Docking );
+ mbHideBtn = mpFloatWin->IsTitleButtonVisible( TitleButton::Hide );
+ mbRollUp = mpFloatWin->IsRollUp();
+ maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
+ maMinOutSize = mpFloatWin->GetMinOutputSizePixel();
+ mpImplData->maMaxOutSize = mpFloatWin->GetMaxOutputSizePixel();
+
+ vcl::Window* pRealParent = mpWindowImpl->mpRealParent;
+ mpWindowImpl->mpBorderWindow = nullptr;
+ if ( mpOldBorderWin )
+ {
+ SetParent( mpOldBorderWin );
+ static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
+ mpOldBorderWin->Resize();
}
+ mpWindowImpl->mpBorderWindow = mpOldBorderWin;
+ SetParent( pRealParent );
+ mpWindowImpl->mpRealParent = pRealParent;
+ mpFloatWin.disposeAndClear();
+ SetPosPixel( maDockPos );
+
+ ToggleFloatingMode();
+
+ if ( bVisible )
+ Show();
}
}