Anonymous avatar Anonymous committed a6be754

dockingwindows2: #ii115802# Added fixes, first docked title design and other enhancements

Comments (0)

Files changed (5)

framework/inc/uielement/panelwindow.hxx

         int             ImplGetDragWidth() const;
         void            ImplDrawGrip( const ::Size& rTitleSize );
         void            ImplDrawCloser( bool bHighlight );
+        Rectangle       ImplGetDragAreaRect() const;
 
         BitmapEx        m_aCloserImage;
         BitmapEx        m_aCloserImageHC;
         Link	        m_aStateChangedHandler;
         Link            m_aDataChangedHandler;
         bool            m_bCloserHighlight;
+        bool            m_bDragAreaHighlight;
         Window*         m_pContentWindow;
        ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener > m_xDockableWindowListener;
 };

framework/source/layoutmanager/panelmanager.cxx

 
     if ( bDockingInProgress )
         aDockingData.TrackingRectangle = e.TrackingRectangle;
+    aDockingData.bFloating = true;
 
     if ( bDockingInProgress && xDockWindow.is() )
     {
             {
                 ::Size aStoredDockSize( aUIDockingElement.m_aDockedData.m_aSize );
                 
-                if ( aStoredDockSize.getWidth() > 0 && aStoredDockSize.getHeight() )
+                if ( aStoredDockSize.getWidth() > 0 && aStoredDockSize.getHeight() > 0 )
                 {
                     aNewTrackingRect.Width  = aStoredDockSize.getWidth();
                     aNewTrackingRect.Height = aStoredDockSize.getHeight();
                     if ( pMgr )
                     {
                         awt::Point aMousePos( aOutPos.X(), aOutPos.Y() );
-                        aInfo = pMgr->getDockingInfo( aMousePos, aNewTrackingRect );
+                        aInfo = pMgr->getDockingInfo( aMousePos, aNewTrackingRect, xDockWindow );
                         if ( aInfo.bCanDock )
                             break;
                     }
                 {
                     ::Size aSize = pDockWindow->GetSizePixel();
                     aUIDockingElement.m_bFloating             = true;
-                    aUIDockingElement.m_aFloatingData.m_aPos  = pDockWindow->GetPosPixel();
+                    aUIDockingElement.m_aFloatingData.m_aPos  = ::Point( e.TrackingRectangle.X, e.TrackingRectangle.Y );//pDockWindow->GetPosPixel();
                     aUIDockingElement.m_aFloatingData.m_aSize = aSize;
                     
+                    aDockingData.TrackingRectangle.X      = e.MousePos.X;
+                    aDockingData.TrackingRectangle.Y      = e.MousePos.Y;
                     aDockingData.TrackingRectangle.Height = aSize.Height();
                     aDockingData.TrackingRectangle.Width  = aSize.Width();
                 }
 
 //    implts_writeWindowStateData( aUIDockingElement );
 
-    if ( bDockingInProgress && !aUIDockingElement.m_bFloating && xWindow.is() )
+    if ( bDockingInProgress && xWindow.is() )
     {
-        sal_Int16 eDockArea( aUIDockingElement.m_aDockedData.m_nDockedArea );
-        ::Point   aVirtPos( aUIDockingElement.m_aDockedData.m_aPos );
-        ::Size    aVirtSize( aUIDockingElement.m_aDockedData.m_aSize );
-        
         if ( !bLastFloating )
             implts_undockWindow( aLastDockedData.m_nDockedArea, xWindow );
-        implts_dockWindow( eDockArea, awt::Rectangle( aVirtPos.X(), aVirtPos.Y(), aVirtSize.Width(), aVirtSize.Height() ), xWindow );
+        
+        if ( !aUIDockingElement.m_bFloating )
+        {
+            sal_Int16 eDockArea( aUIDockingElement.m_aDockedData.m_nDockedArea );
+            ::Point   aVirtPos( aUIDockingElement.m_aDockedData.m_aPos );
+            ::Size    aVirtSize( aUIDockingElement.m_aDockedData.m_aSize );
+            
+            implts_dockWindow( eDockArea, awt::Rectangle( aVirtPos.X(), aVirtPos.Y(), aVirtSize.Width(), aVirtSize.Height() ), xWindow );
+        }
+        else
+        {
+            DockingWindow* pDockWindow = dynamic_cast< DockingWindow* >( VCLUnoHelper::GetWindow( xWindow ));
+            if ( pDockWindow && !pDockWindow->IsFloatingMode() )
+            {
+                pDockWindow->SetFloatingMode( true );
+                pDockWindow->SetPosPixel( aUIDockingElement.m_aFloatingData.m_aPos );
+                pDockWindow->SetSizePixel( aUIDockingElement.m_aFloatingData.m_aSize );
+                pDockWindow->Show( true );
+            }
+        }
     }
 
     aWriteLock.lock();

framework/source/layoutmanager/splitpanelmanager.cxx

     sal_Int32 nDecoSize = m_pSplitWindow->GetFadeInSize();
     if ( bHorz )
     {
+        sal_Int32 nLeft, nRight, nTop, nBottom;
+        m_pSplitWindow->GetBorder( nLeft, nTop, nRight, nBottom );
+        sal_Int32 nOffset = ( m_eSplitPos == SPLITPANEL_TOP ) ? nTop : nDecoSize;
+        
         aDockMousePos.X() = ::std::min( ::std::max( nPosX, sal_Int32( 2 )), sal_Int32( aOutSize.getWidth() ));
-        aDockMousePos.Y() = ::std::min( ::std::max( nPosY, nDecoSize ), sal_Int32( aOutSize.getHeight() - nDecoSize ));
+        aDockMousePos.Y() = ::std::max( ::std::min( nPosY, sal_Int32( aOutSize.getHeight() / 2 )), nOffset );
     }
     else
     {
-        aDockMousePos.X() = ::std::min( ::std::max( nPosX, nDecoSize ), sal_Int32( aOutSize.getWidth() - nDecoSize ));
+        sal_Int32 nLeft, nRight, nTop, nBottom;
+        m_pSplitWindow->GetBorder( nLeft, nTop, nRight, nBottom );
+        sal_Int32 nOffset = ( m_eSplitPos == SPLITPANEL_LEFT ) ? nLeft : nDecoSize;
+        
+        aDockMousePos.X() = ::std::max( ::std::min( nPosX, sal_Int32( aOutSize.getWidth() / 2 )), nOffset );
         aDockMousePos.Y() = ::std::min( ::std::max( nPosY, sal_Int32( 2 )), sal_Int32( aOutSize.getHeight() ));
     }
     
     return aDockMousePos;
 }
 
-SplitPanelManager::DockingInfo SplitPanelManager::getDockingInfo( const awt::Point& rMousePos, const awt::Rectangle& rDockRect )
+SplitPanelManager::DockingInfo SplitPanelManager::getDockingInfo( 
+    const awt::Point& rMousePos, 
+    const awt::Rectangle& rDockRect, 
+    const uno::Reference< awt::XWindow >& xWindow )
 {
     const sal_Int32 MAGNETIC_DISTANCE_UNDOCK = 25;
     const sal_Int32 MAGNETIC_DISTANCE_DOCK   = 20;
     
     if ( pParentInfo )
         aWorkspaceRect = VCLRectangle( pParentInfo->getWorkspaceArea());
-        
-    bool         bEmpty( isEmpty() );
-    bool         bHorz( isHorizontal() );
-    ::Rectangle  aWinRect;
     
     if ( m_pSplitWindow )
     {
         // Retrieve size from split window
+         bool       bHorz( isHorizontal() );
+        ::Point     aMousePos( rMousePos.X, rMousePos.Y );
         ::Rectangle aWinRect( m_pSplitWindow->GetPosPixel(), m_pSplitWindow->GetSizePixel() );
-    
         ::Rectangle aHotZoneRect( calcHotZoneRect( aWinRect, MAGNETIC_DISTANCE_DOCK ));
-        ::Point     aMousePos( rMousePos.X, rMousePos.Y );
         
         if ( aHotZoneRect.IsInside( aMousePos ))
         {
             aDockingInfo.bCanDock = true;
             aDockingInfo.eSplitPanelPos = m_eSplitPos;
             
+            sal_Int32 nLeftBorder, nTopBorder, nRightBorder, nBottomBorder;
+            m_pSplitWindow->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
+            
+            ::Size      aOutSize( m_pSplitWindow->GetOutputSizePixel() );
+            ::Rectangle aInnerRect( ::Point( aWinRect.Left() + nLeftBorder, aWinRect.Top() + nTopBorder ),
+                                    ::Size( aOutSize.getWidth() - nLeftBorder - nRightBorder, 
+                                            aOutSize.getHeight() - nBottomBorder - nTopBorder ));
+            
+            ::Point aOutMousePos = m_pSplitWindow->ScreenToOutputPixel( aMousePos );
+            
+            bool    bInside( false );
+            ::Point aVirtMousePos;
+            if ( aInnerRect.IsInside( aOutMousePos ))
+            {
+                bInside       = true;
+                aVirtMousePos = aOutMousePos;
+            }
+            else
+                aVirtMousePos = impl_calcDockingMousePos( aOutMousePos );
+            
             sal_uInt16 nCount( m_pSplitWindow->GetItemCount( nRowColId ));
-            ::Size aOutSize( m_pSplitWindow->GetOutputSizePixel() );
-            ::Point aVirtMousePos( impl_calcDockingMousePos( m_pSplitWindow->ScreenToOutputPixel( aMousePos )));
             sal_uInt16 nId( m_pSplitWindow->GetItemId( aVirtMousePos ));
+            Rectangle  aDockRect( Point( rDockRect.X, rDockRect.Y ), Size( rDockRect.Width, rDockRect.Height ));
             
             if ( nCount == 0 || nId == SPLITWINDOW_ITEM_NOTFOUND || nId < nStartID )
             {
-                if ( isHorizontal() )
-                {
-                    sal_Int32 nMaxHeight = sal_Int32( aWorkspaceRect.GetHeight() * 80 / 100 );
-                    sal_Int32 nHeight = std::max( std::min( rDockRect.Height, nMaxHeight ), sal_Int32( 1 ));
-                    
-                    aDockingRect.X      = aWinRect.Left();
-                    aDockingRect.Width  = aOutSize.getWidth();
-                    aDockingRect.Height = nHeight;
-                    
-                    if ( m_eSplitPos == SPLITPANEL_TOP )
-                        aDockingRect.Y = aWinRect.Top();
-                    else
-                        aDockingRect.Y = std::max( sal_Int32( aWinRect.Top() - nHeight ), sal_Int32( 0 ));
-                }
-                else
-                {
-                    sal_Int32 nMaxWidth = sal_Int32( aWorkspaceRect.GetWidth() * 80 / 100 );
-                    sal_Int32 nWidth = std::max( std::min( rDockRect.Width, nMaxWidth ), sal_Int32( 1 ));
-                    
-                    aDockingRect.Y      = aWinRect.Top();
-                    aDockingRect.Height = aOutSize.getHeight();
-                    aDockingRect.Width  = nWidth;
-                    
-                    if ( m_eSplitPos == SPLITPANEL_LEFT )
-                        aDockingRect.X = aWinRect.Left();
-                    else
-                        aDockingRect.X = std::max( sal_Int32( aWinRect.Left() - nWidth ), sal_Int32( 0 ));
-                }
+                return implts_getDockingInfoForEmptyContainer( aDockRect );
             }
             else
             {
+                Window*        pDockWindow( VCLUnoHelper::GetWindow( xWindow ));
                 sal_uInt16     nCount = m_pSplitWindow->GetItemCount( nRowColId );
                 long           nSize = m_pSplitWindow->GetItemSize( nId, SWIB_FIXED );
                 long           nRowColSize = m_pSplitWindow->GetItemSize( nRowColId, SWIB_FIXED );
                 Window*        pWindow = m_pSplitWindow->GetItemWindow( nId );
                 sal_Int32      nItemsSize = implts_getItemsSize();
                 
-                if ( pWindow )
+                if ( pWindow && pDockWindow == pWindow )
+                {
+                    return implts_getDockingInfoForEmptyContainer( aDockRect );
+                }
+                else if ( pWindow )
                 {
                     sal_uInt16 nDockPos(0);
                     ::Point aPos = pWindow->GetPosPixel();
                     ::Size  aSize = pWindow->GetSizePixel();
-                    if ( isHorizontal() )
+                    if ( bHorz )
                     {
                         if ( aVirtMousePos.X() < ( aPos.X() + ( aSize.Width() / 2 )))
                             nDockPos = nPos;
                         sal_Int32 nOffset( 0 );
                         if ( m_eSplitPos == SPLITPANEL_RIGHT )
                             nOffset = m_pSplitWindow->GetFadeInSize();
+                        else
+                        {
+                            sal_Int32 nRight, nTop, nBottom;
+                            m_pSplitWindow->GetBorder( nOffset, nTop, nRight, nBottom );
+                        }
                         
                         aDockingRect.X = aWinRect.Left() + nOffset;
                         aDockingRect.Y = aWinRect.Top() + nPosY;
                         aDockingRect.Width = nRowColSize;
                     }
                 }
+                aDockingInfo.aDockingRect = aDockingRect;
+            }            
+        }
+    }
+    
+    return aDockingInfo;
+}
+
+SplitPanelManager::DockingInfo SplitPanelManager::implts_getDockingInfoForEmptyContainer( const Rectangle& rDockRect )
+{
+    vos::OGuard aGuard( Application::GetSolarMutex() );
+    
+    DockingInfo aDockingInfo;
+    
+    if ( m_pSplitWindow )
+    {
+        ::Rectangle         aWorkspaceRect;
+        ILayoutInformation* pParentInfo = dynamic_cast< ILayoutInformation* >( m_pParentListener );
+        
+        // Retrieve size of the workspace area. We want to limit the size of the docking areas.
+        if ( pParentInfo )
+            aWorkspaceRect = VCLRectangle( pParentInfo->getWorkspaceArea());
+        
+        ::Size         aOutSize( m_pSplitWindow->GetOutputSizePixel() );
+        ::Rectangle    aWinRect( m_pSplitWindow->GetPosPixel(), m_pSplitWindow->GetSizePixel() );
+        awt::Rectangle aDockingRect;
+        
+        aDockingInfo.bCanDock = true;
+        aDockingInfo.eSplitPanelPos = m_eSplitPos;
+        
+        if ( isHorizontal() )
+        {
+            sal_Int32 nMaxHeight = sal_Int32( aWorkspaceRect.GetHeight() * 80 / 100 );
+            sal_Int32 nHeight = std::max( std::min( rDockRect.GetHeight(), nMaxHeight ), sal_Int32( 1 ));
+            
+            aDockingRect.X      = aWinRect.Left();
+            aDockingRect.Width  = aOutSize.getWidth();
+            aDockingRect.Height = nHeight;
+            
+            if ( m_eSplitPos == SPLITPANEL_TOP )
+                aDockingRect.Y = aWinRect.Top();
+            else
+            {
+                sal_Int32 nBottom = ( aWinRect.GetHeight() == 0 ) ? aWinRect.Top() : aWinRect.Bottom();
+                aDockingRect.Y = std::max( sal_Int32( aWinRect.Bottom() - nHeight ), sal_Int32( 0 ));
             }
+        }
+        else
+        {
+            sal_Int32 nMaxWidth = sal_Int32( aWorkspaceRect.GetWidth() * 80 / 100 );
+            sal_Int32 nWidth = std::max( std::min( rDockRect.GetWidth(), nMaxWidth ), sal_Int32( 1 ));
             
-            aDockingInfo.aDockingRect = aDockingRect;
+            aDockingRect.Y      = aWinRect.Top();
+            aDockingRect.Height = aOutSize.getHeight();
+            aDockingRect.Width  = nWidth;
+            
+            if ( m_eSplitPos == SPLITPANEL_LEFT )
+                aDockingRect.X = aWinRect.Left();
+            else
+            {
+                sal_Int32 nRight = ( aWinRect.GetWidth() == 0 ) ? aWinRect.Left() : aWinRect.Right();
+                aDockingRect.X = std::max( sal_Int32( nRight - nWidth ), sal_Int32( 0 ));
+            }
         }
+        
+        aDockingInfo.aDockingRect = aDockingRect;
     }
     
     return aDockingInfo;
     ::Rectangle aWinRect( VCLRectangle( rDockRect ));
     
     DockingWindow* pDockWindow = dynamic_cast< DockingWindow* >( VCLUnoHelper::GetWindow( xWindow ));
-    DockingInfo aDockInfo = getDockingInfo( awt::Point( rDockRect.X, rDockRect.Y ), rDockRect );
+    DockingInfo aDockInfo = getDockingInfo( awt::Point( rDockRect.X, rDockRect.Y ), rDockRect, xWindow );
     
     if ( m_pSplitWindow && pDockWindow )
     {

framework/source/layoutmanager/splitpanelmanager.hxx

         void                setSize( sal_Int32 nNewSize );
         sal_Int32           getSize() const;
         
-        DockingInfo getDockingInfo( const css::awt::Point& rMousePos, const css::awt::Rectangle& rDockRect );
+        DockingInfo getDockingInfo( const css::awt::Point& rMousePos, const css::awt::Rectangle& rDockRect, const css::uno::Reference< css::awt::XWindow >& xWindow );
         bool addDockWindow( const css::awt::Rectangle& rDockRect, const css::uno::Reference< css::awt::XWindow >& xWindow );
         bool removeDockWindow( const css::uno::Reference< css::awt::XWindow >& xWindow );
         
         ::Point        impl_calcDockingMousePos( const ::Point& aOutputMousePos );
         bool           implts_removeDockedWindowInfo( sal_uInt16 nId );
         void           implts_setLayoutDirty();
+        DockingInfo    implts_getDockingInfoForEmptyContainer( const Rectangle& rDockRect );
 
         typedef std::vector< DockedWinInfo > DockedWindows;
         

framework/source/uielement/panelwindow.cxx

     return DRAGWIDTH; // the default width of the grip
 }
 
+Rectangle PanelWindow::ImplGetDragAreaRect() const
+{
+    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+    sal_Int32 nHeight = rStyleSettings.GetTitleHeight();
+    
+    int height = (int) (0.6 * nHeight + 0.5);
+    int x = ImplGetDragWidth() / 2;
+    int y = (nHeight - height) / 2;
+    
+    return Rectangle( ::Point( x, y ), ::Size( ImplGetDragWidth(), height ));
+}
+
 void PanelWindow::ImplDrawGrip( const ::Size& rTitleSize )
 {
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
         ImplDrawCloser( false );
         m_bCloserHighlight = false;
     }
+    
+    Rectangle aDragRect = ImplGetDragAreaRect(); 
+    if ( aDragRect.IsInside( rMEvt.GetPosPixel() ))
+    {
+        SetPointer( POINTER_MOVE );
+        m_bDragAreaHighlight = true;
+    }
+    else
+    {
+        SetPointer( POINTER_ARROW );
+        m_bDragAreaHighlight = false;
+    }
 }
 
 void PanelWindow::MouseButtonDown( const MouseEvent& rMEvt )
 {
-    DockingWindow::MouseButtonDown( rMEvt );
+    if ( m_bDragAreaHighlight )
+        DockingWindow::MouseButtonDown( rMEvt );
+    else
+        Window::MouseButtonDown( rMEvt );
 }
 
 void PanelWindow::MouseButtonUp( const MouseEvent& rMEvt )
 {
     if ( m_bCloserHighlight )
         Close();
+    else if ( m_bDragAreaHighlight )
+        DockingWindow::MouseButtonUp( rMEvt );
     else
-        DockingWindow::MouseButtonUp( rMEvt );
+        Window::MouseButtonUp( rMEvt );
 }
 
 void PanelWindow::Paint( const Rectangle& rRect )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.