[Libreoffice-commits] .: 2 commits - vcl/inc vcl/source

Jan Holesovsky kendy at kemper.freedesktop.org
Fri Jun 10 09:22:26 PDT 2011


 vcl/inc/vcl/toolbox.hxx        |    2 +-
 vcl/source/window/toolbox.cxx  |   35 +++++++++++++++++++++++++----------
 vcl/source/window/toolbox2.cxx |    4 ++--
 3 files changed, 28 insertions(+), 13 deletions(-)

New commits:
commit 0723c026cbb139b0e2c653c07ec6928521a7dc52
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Fri Jun 10 18:20:19 2011 +0200

    Update the toolbar's popup menu hidden items.

diff --git a/vcl/inc/vcl/toolbox.hxx b/vcl/inc/vcl/toolbox.hxx
index c1f40b2..915ef18 100644
--- a/vcl/inc/vcl/toolbox.hxx
+++ b/vcl/inc/vcl/toolbox.hxx
@@ -281,7 +281,6 @@ private:
     SAL_DLLPRIVATE void            ImplHideFocus();
     SAL_DLLPRIVATE void			   ImplUpdateInputEnable();
     SAL_DLLPRIVATE void			   ImplFillLayoutData() const;
-    SAL_DLLPRIVATE void            ImplUpdateCustomMenu();
     SAL_DLLPRIVATE sal_Bool            ImplHasClippedItems();
     SAL_DLLPRIVATE Point           ImplGetPopupPosition( const Rectangle& rRect, const Size& rSize ) const;
     SAL_DLLPRIVATE void            ImplExecuteCustomMenu();
@@ -599,6 +598,7 @@ public:
     sal_uInt16              GetMenuType() const;
     sal_Bool                IsMenuEnabled() const;
     PopupMenu*          GetMenu() const;
+    void                UpdateCustomMenu();
     void                SetMenuButtonHdl( const Link& rLink );
     const Link&         GetMenuButtonHdl() const;
 
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 1966d05..272e166 100755
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -5729,7 +5729,7 @@ sal_Bool ToolBox::ImplOpenItem( KeyCode aKeyCode )
         if( ImplCloseLastPopup( GetParent() ) )
             return bRet;
 
-        ImplUpdateCustomMenu();
+        UpdateCustomMenu();
         Application::PostUserEvent( mpData->mnEventId, LINK( this, ToolBox, ImplCallExecuteCustomMenu ) );
     }
     else if( mnHighItemId &&  ImplGetItem( mnHighItemId ) &&
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index f4c5fa2..c06056b 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -2175,7 +2175,7 @@ sal_Bool ToolBox::ImplHasClippedItems()
     return sal_False;
 }
 
-void ToolBox::ImplUpdateCustomMenu()
+void ToolBox::UpdateCustomMenu()
 {
     // fill clipped items into menu
     if( !IsMenuEnabled() )
@@ -2296,7 +2296,7 @@ void ToolBox::ExecuteCustomMenu()
     {
         // handle custom menu asynchronously
         // to avoid problems if the toolbox is closed during menu execute
-        ImplUpdateCustomMenu();
+        UpdateCustomMenu();
         Application::PostUserEvent( mpData->mnEventId, LINK( this, ToolBox, ImplCallExecuteCustomMenu ) );
     }
 }
commit 25dd5dae1d19376be5325929abf447b614b88d79
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Fri Jun 10 16:17:47 2011 +0200

    Show the toolbar's menu only when there are hidden items.
    
    We get the same functionality when we right-click the toolbar handle, so no
    need to make this extra visible.

diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 4eb2b39..1966d05 100755
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -2166,13 +2166,22 @@ sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, sal_Bool b
     sal_Bool            bWindow;
     sal_Bool            bBreak = sal_False;
     long            nWidthTotal = nWidth;
+    long nMenuWidth = 0;
 
     // when docked the menubutton will be in the first line
-    // ->initialize first linewidth with button
     if( IsMenuEnabled() && !ImplIsFloatingMode() )
-        nLineWidth = mpData->maMenubuttonItem.maItemSize.Width();
+        nMenuWidth = mpData->maMenubuttonItem.maItemSize.Width();
 
-    std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
+    // we need to know which item is the last visible one to be able to add
+    // the menu width in case we are unable to show all the items
+    std::vector< ImplToolItem >::iterator it, lastVisible;
+    for ( it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it )
+    {
+        if ( it->mbVisible )
+            lastVisible = it;
+    }
+
+    it = mpData->m_aItems.begin();
     while ( it != mpData->m_aItems.end() )
     {
         it->mbBreak = bBreak;
@@ -2208,12 +2217,18 @@ sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, sal_Bool b
                     }
                 }
 
-                // check for line break
-                if ( (nLineWidth+nCurWidth > nWidthTotal) && mbScroll )
+                // in case we are able to show all the items, we do not want
+                // to show the toolbar's menu; otherwise yes
+                if ( ( ( it == lastVisible ) && (nLineWidth+nCurWidth > nWidthTotal) && mbScroll ) ||
+                     ( ( it != lastVisible ) && (nLineWidth+nCurWidth+nMenuWidth > nWidthTotal) && mbScroll ) )
                     bBreak = sal_True;
             }
             else if ( it->meType == TOOLBOXITEM_SEPARATOR )
+            {
                 nCurWidth = it->mnSepSize;
+                if ( ( it != lastVisible ) && (nLineWidth+nCurWidth+nMenuWidth > nWidthTotal) )
+                    bBreak = sal_True;
+            }
             // treat breaks as separators, except when using old style toolbars (ie. no menu button)
             else if ( (it->meType == TOOLBOXITEM_BREAK) && !IsMenuEnabled() )
                 bBreak = sal_True;
@@ -3224,7 +3239,7 @@ void ToolBox::ImplDrawMenubutton( ToolBox *pThis, sal_Bool bHighlight )
     if( !pThis->mpData->maMenubuttonItem.maRect.IsEmpty() )
     {
         // #i53937# paint menu button only if necessary
-        if( !(pThis->GetMenuType() & TOOLBOX_MENUTYPE_CUSTOMIZE) && !pThis->ImplHasClippedItems() )
+        if( !pThis->ImplHasClippedItems() )
             return;
 
         // execute pending paint requests
@@ -3278,7 +3293,7 @@ void ToolBox::ImplDrawMenubutton( ToolBox *pThis, sal_Bool bHighlight )
             else
                 pThis->DrawSelectionBackground( aInnerRect, 2, sal_False, sal_False, sal_False );
         }
-        else
+        else if( !bNativeButtons )
         {
             // improve visibility by using a dark gradient
             Gradient g;
@@ -4406,7 +4421,7 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
         }
 
         // only clear highlight when focus is not in toolbar
-        sal_Bool bMenuButtonHit = mpData->maMenubuttonItem.maRect.IsInside( aMousePos );
+        sal_Bool bMenuButtonHit = mpData->maMenubuttonItem.maRect.IsInside( aMousePos ) && ImplHasClippedItems();
         if ( bClearHigh || bMenuButtonHit )
         {
             if ( !bMenuButtonHit && mpData->mbMenubuttonSelected )
@@ -4607,7 +4622,7 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
         Deactivate();
 
         // menu button hit ?
-        if( mpData->maMenubuttonItem.maRect.IsInside( aMousePos ) )
+        if( mpData->maMenubuttonItem.maRect.IsInside( aMousePos ) && ImplHasClippedItems() )
         {
             ExecuteCustomMenu();
             return;


More information about the Libreoffice-commits mailing list