Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Ribbon group tooltips Collapse All
Subject Author Date
Robert Webb Mar 18, 2010 - 7:24 PM

Hi,


When a ribbon bar group is small, sometimes the label at the bottom is truncated and can’t be fully read.  It would be nice if a tooltip appeared in this situation when the mouse was hovered over the truncated text, showing the full text.


Thanks,


Rob.

Technical Support Mar 22, 2010 - 1:29 PM

We would be very happy to leave the new behavior of ribbon button group captions because it meets the Microsoft Ribbon UI Design Guidelines document. If the caption text is lengthy, then it must be displayed completely and the ribbon button group content must be centered horizontally. We suspect you have too many ribbon buttons and elements on some/all ribbon tab pages in your application. Not all the elements should be placed directly on tab pages. You can organize some subset of commands into drop down or split buttons. You can have some ribbon galleries never displayed as in-pace gallery controls on ribbon tab pages and have them always displayed as drop-down buttons showing popup gallery menus. This is what you can see in any application from the Microsoft Office 2007 / 2010.
The never collapsed ribbon button groups are supported in the latest Prof-UIS 2.89. We added a new CExtRibbonNode::RibbonILE_SetCollapsedNever() method and it’s invoked in the CMainFrame::_InitRibbonNode_Insert_Table() methods of the RibbonBar and RibbonBarMDI sample applications:

CExtRibbonNodeGroup * pRibbonGroup =
                        new CExtRibbonNodeGroup( ID_RIBBON_PAGE_INSERT_TABLE );
            pRibbonGroup->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_LPCTSTR( _T("ZA") ) ), false );
            VERIFY( pRibbonGroup->m_iconBig.m_bmpNormal.LoadBMP_Resource( MAKEINTRESOURCE(ID_INSERT_TABLE_LARGE) ) );
            pRibbonGroup->m_iconBig.m_bmpNormal.Make32();
            pRibbonGroup->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );
            pRibbonGroup->SetTextInToolbar( _T("Table") );
            pRibbonGroup->RibbonILE_SetCollapsedNever();
If the button groups are collapsed into the text-less buttons, then you didn’t specify the caption text. The code above initializes a button group with the Table caption text.

Robert Webb Mar 22, 2010 - 10:09 PM

The new behaviour ruins our layout.  I’m not expecting you to remove the new behaviour, but some way to tell it to use the old behaviour instead would be nice.  Till then we will need to keep hacking any new Prof-UIS code back to the old way.


We don’t use any ribbon galleries.  Mostly just buttons and a few text fields.  And yes, some of our controls are hidden under drop-downs etc.  We do have a lot of controls though, and our users complain about how many mouse-clicks things take, so we don’t like to hide things too deep where possible.


We could always shorten our ribbon group names, but it’s better that they’re descriptive.  Wasn’t a problem before.


Oh, I wasn’t talking about the group-buttons losing text.  I meant that the buttons within the group lose their text when the ribbon bar is made small enough, even though the text would easily fit in now that the group is wider due to the group’s own caption.  That is, reducing to no-text doesn’t save any space, so it shouldn’t do it.


Thanks,


Rob.

Robert Webb Apr 1, 2010 - 1:10 AM

Any answer to this?


RibbonILE_SetCollapsedNever() looks useful since ProfUIS can’t automatically recognise which groups shouldn’t be collapsed (the ones that won’t save any space by doing so).  But with or without this, our layout is now terrible in a smaller window.  It was good before the change you made.  We just want an option to use the old method.  We like descriptive group labels when there’s room, and like them to be truncated when there isn’t.


Currently we will have to patch the ProfUIS code back to how it was whenever we get a new version.


Rob.

Technical Support Apr 15, 2010 - 2:09 PM

Most of the ribbon button groups in the RibbonBar sample application have approximately the same length short text in their captions. But this text is typically a bit wider than the minimal possible width of the collapsed ribbon group button. The user can see everything and read every collapsed caption. We can make everything even more thin and you will see a lot if ". . . " ellipsis text lines with a few letters before it. We are not sure this is good.
Looking from the other side, the last source code update allows you to assign rich ribbon cool tips to the collapsed ribbon button groups. Why not to start using short captions and display rich tooltips with a lot of text information?

Technical Support Apr 5, 2010 - 11:28 AM

Please re-download the latest Prof-UIS source code and add the following virtual method to your ribbon class:

bool C_YOUR_RibbonBar::OnRibbonQueryGroupCaptionTextCompletlyVisible( CExtRibbonButtonGroup * pTBB ) const
{
            ASSERT_VALID( this );
            ASSERT_VALID( pTBB );
            pTBB;
            return false;
}
Now the group buttons use the ellipsis effect for long text captions and display tooltips. You can also assign CExtCustomizeCmdScreenTip ribbon screen tips to the ribbon group nodes as it is demonstrated in the comments inside the CMainFrame::_InitRibbonNode_Insert_Table() method in the RibbonBar sample.

Robert Webb Apr 7, 2010 - 8:08 PM

Great!  Thank you.  One minor point, why OnRibbonQueryGroupCaptionTextCompletlyVisible() rather than OnRibbonQueryGroupCaptionTextCompletelyVisible()?  Seems odd to abbreviate such a long function by name just one letter, removing just one "e" from "Completely".  Looks like a typo rather than an abbreviation.


I haven’t checked out adding a tooltip to the group label yet, but I presume it will always appear once defined?  Is there a way to make it only appear when the label is being truncated?  Still seems like sensible automatic behaviour.


Thanks,


Rob.

Technical Support Apr 8, 2010 - 12:20 PM

Thank you for reporting the typo. We fixed it in the latest Prof-UIS 2.89 source code. You can re-download it.
If you define a ribbon super tooltip and assign it to a ribbon group button, the super tooltip is always displayed for the ribbon group. This is the default super tooltip behavior for all ribbon buttons.
If you does not define a super tooltip, the ribbon group displays a small tooltip with caption text. Yes, this small tooltip is displayed only if the caption text is painted with the ellipsis text effect.

Robert Webb Apr 8, 2010 - 9:23 PM

Thanks!  Yep, the ribbon group tooltips when the label is truncated look great.


Just one final thing I noticed.  Although the group names are now truncated, when the group is made small enough that it collapses to a single button, suddenly the full length text is back, making the groups wider than they were before they collapsed.  Significantly wider in some of our cases.  This means that several groups suddenly vanish off the end of the bar, even though all the groups just fit when the window was one pixel wider.  May I suggest that the group labels still be truncated when the group is collapsed to a single button?  Tooltips should again show the full label when truncated.


Thanks,


Rob.

Robert Webb Apr 13, 2010 - 7:14 PM

Any answer to this?  When using OnRibbonQueryGroupCaptionTextCompletelyVisible(), the group captions should also be truncated when the group is collapsed to a single button, but this does not happen, making the single button considerably wider than the expanded group in many cases.


Thanks,


Rob.

Robert Webb Apr 21, 2010 - 7:54 PM

Still waiting for a response.

Technical Support Mar 20, 2010 - 11:20 AM

It’s not correct to show a tooltip over the caption of a ribbon button painted with the ellipsis effect. It’s also not correct to use the ellipsis effect there. The ribbon UI recommendations require the caption text to be fully visible and the buttons to be centered if the caption is very lengthy. We fixed this issue. Please update the source code for the following two methods:

CSize CExtRibbonButtonGroup::OnRibbonCalcLayout(
            CDC & dc,
            CPoint & ptCalcLayoutOffset,
            bool bSetupRects
            )
{
            ASSERT_VALID( this );
            ASSERT( dc.GetSafeHdc() != NULL );
            if( ! IsVisible() )
                        return CSize( 0, 0 );
            if( (GetStyle()&TBBS_HIDDEN) != 0 )
                        return CSize( 0, 0 );
CExtRibbonPage * pRibbonPage = GetRibbonPage();
            ASSERT_VALID( pRibbonPage );
INT nDistanceBefore = OnRibbonGetOuterGroupDistance( true );
INT nDistanceAfter = OnRibbonGetOuterGroupDistance( false );
CRect rcCP = OnRibbonGetContentPadding();
            if( pRibbonPage->RibbonLayout_GroupCaptionIsTopAligned( this ) )
                        rcCP.top += pRibbonPage->RibbonLayout_GroupCaptionGetHeight( this );
            else
                        rcCP.bottom += pRibbonPage->RibbonLayout_GroupCaptionGetHeight( this );
            if( TopCollapsedStateGet() )
            {
                        CSize _sizeLayout = OnRibbonCalcCollapsedGroupSize( dc );
                        if( bSetupRects )
                        {
                                    CRect rcTBB( ptCalcLayoutOffset, _sizeLayout );
                                    rcTBB.OffsetRect( nDistanceBefore, 0 );
                                    SetLayoutRect( dc, rcTBB );
                        }
                        _sizeLayout.cx += nDistanceBefore + nDistanceAfter;
                        ptCalcLayoutOffset.x += nDistanceBefore + nDistanceAfter;
                        return _sizeLayout;
            } // if( TopCollapsedStateGet() )
CPoint ptGroupLayout = ptCalcLayoutOffset;
            ptGroupLayout.x += rcCP.left + nDistanceBefore;
            ptGroupLayout.y += rcCP.top;
CSize _sizeLayout( 0, 0 );
INT nIndex, nCount = ChildButtonGetCount();
INT nLineWidth = 0, nLineHeight = 0, nMaxLineHeight = 0, nLineHeightSaved = 0,
                        nMaxAvailableLineHeight = pRibbonPage->RibbonLayout_GetGroupHeight( this ) - rcCP.top - rcCP.bottom;
INT nSizeMinCaptionArea = 0;
CExtBarButton * pLastVisibleTBB = NULL;
            for( nIndex = 0; nIndex < nCount; nIndex ++ )
            {
                        CExtBarButton * pTBB = ChildButtonGetAt( nIndex );
                        ASSERT_VALID( pTBB );
                        if( bSetupRects )
                                    pTBB->SetWrap( CExtBarButton::__EVT_FLOAT, false );
                        if( pTBB->IsKindOf( RUNTIME_CLASS(CExtRibbonButtonDialogLauncher) ) )
                        {
                                    pTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
                                    CSize _sizeTBB = pTBB->RibbonILV_CalcSize( dc, -1 );
                                    if( bSetupRects )
                                    {
                                                CRect rcTBB( 0, 0, _sizeTBB.cx, _sizeTBB.cy );
                                                pTBB->SetLayoutRect( dc, rcTBB );
                                                pTBB->Show( false );
                                    }
                                    nSizeMinCaptionArea += _sizeTBB.cx + 1;
                                    continue;
                        } // if( pTBB->IsKindOf( RUNTIME_CLASS(CExtRibbonButtonDialogLauncher) ) )
                        if( ! pTBB->IsVisible() )
                                    continue;
                        if( (pTBB->GetStyle()&TBBS_HIDDEN) != 0 )
                                    continue;
                        if( pTBB->IsSeparator() )
                        {
                                    INT nSeparatorWidth = pTBB->OnRibbonGetSeparatorExtent( true );
                                    CRect rcCpTBB = pTBB->OnRibbonGetContentPadding();
                                    nMaxLineHeight = max( nMaxLineHeight, nLineHeight );
                                    _sizeLayout.cx += nLineWidth + nSeparatorWidth + rcCpTBB.left + rcCpTBB.right;
                                    ptGroupLayout.x += nLineWidth;
                                    ptGroupLayout.y = ptCalcLayoutOffset.y + rcCP.top;
                                    nLineWidth = nLineHeight = 0;
                                    if( bSetupRects )
                                    {
                                                pTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
                                                if( pLastVisibleTBB != NULL )
                                                            pLastVisibleTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
                                                pLastVisibleTBB = pTBB;
                                                CRect rcTBB( ptGroupLayout + rcCpTBB.TopLeft(), CSize( nSeparatorWidth, 100 ) );
                                                rcTBB.OffsetRect( -nDistanceBefore, 0 );
                                                pTBB->SetLayoutRect( dc, rcTBB );
                                    }
                                    ptGroupLayout.x += nSeparatorWidth + rcCpTBB.left + rcCpTBB.right;
                                    continue;
                        } // if( pTBB->IsSeparator() )
                        CSize _sizeTBB = pTBB->RibbonILV_CalcSize( dc, -1 );
                        CRect rcCpTBB = pTBB->OnRibbonGetContentPadding();
                        nLineHeightSaved = nLineHeight;
                        nLineHeight += _sizeTBB.cy + rcCpTBB.top + rcCpTBB.bottom;
                        if( nLineHeight > nMaxAvailableLineHeight )
                        {
                                    nMaxLineHeight = max( nMaxLineHeight, nLineHeightSaved );
                                    _sizeLayout.cx += nLineWidth;
                                    ptGroupLayout.x += nLineWidth;
                                    ptGroupLayout.y = ptCalcLayoutOffset.y + rcCP.top;
                                    nLineWidth = _sizeTBB.cx + rcCpTBB.left + rcCpTBB.right;
                                    nLineHeight = _sizeTBB.cy + rcCpTBB.top + rcCpTBB.bottom;
                                    if( bSetupRects )
                                    {
                                                if( pLastVisibleTBB != NULL )
                                                            pLastVisibleTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
                                                else
                                                            pTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
                                                pLastVisibleTBB = pTBB;
                                                CRect rcTBB( ptGroupLayout + rcCpTBB.TopLeft(), _sizeTBB );
                                                rcTBB.OffsetRect( -nDistanceBefore, 0 );
                                                pTBB->SetLayoutRect( dc, rcTBB );
                                    }
                                    ptGroupLayout.y += nLineHeight;
                        } // if( nLineHeight > nMaxAvailableLineHeight )
                        else
                        {
                                    if( bSetupRects )
                                    {
                                                pLastVisibleTBB = pTBB;
                                                CRect rcTBB( ptGroupLayout + rcCpTBB.TopLeft(), _sizeTBB );
                                                rcTBB.OffsetRect( -nDistanceBefore, 0 );
                                                pTBB->SetLayoutRect( dc, rcTBB );
                                    }
                                    INT nWidthTBB = _sizeTBB.cx + rcCpTBB.left + rcCpTBB.right;
                                    nLineWidth = max( nLineWidth, nWidthTBB );
                                    nMaxLineHeight = max( nMaxLineHeight, nLineHeight );
                                    ptGroupLayout.y += _sizeTBB.cy + rcCpTBB.top + rcCpTBB.bottom;
                        } // else from if( nLineHeight > nMaxAvailableLineHeight )
            } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
            if( bSetupRects && pLastVisibleTBB != NULL )
                        pLastVisibleTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
            _sizeLayout.cx += nLineWidth;
            nMaxLineHeight = max( nMaxLineHeight, nLineHeightSaved );
CExtSafeString strCaptionText = GetText();
            if( ! strCaptionText.IsEmpty() )
            {
                        strCaptionText.Replace( _T("\r"), _T("") );
                        strCaptionText.Replace( _T("\n"), _T(" ") );
                        CFont * pFont = & ( pRibbonPage->PmBridge_GetPM()->m_FontRibbonGroupCaption );
                        if( pFont->GetSafeHandle() == NULL )
                                    pFont = pRibbonPage->OnGetToolbarFont( false, true, this );
                        nSizeMinCaptionArea += CExtPaintManager::stat_CalcTextDimension( dc, *pFont, strCaptionText, DT_SINGLELINE|DT_LEFT|DT_TOP|DT_CALCRECT ).Width() + 6;
            }
            if( nSizeMinCaptionArea > _sizeLayout.cx )
            {
                        INT nShift = ( nSizeMinCaptionArea - _sizeLayout.cx ) / 2;
                        _sizeLayout.cx = nSizeMinCaptionArea;
                        if( nShift > 0 && bSetupRects )
                        {
                                    for( nIndex = 0; nIndex < nCount; nIndex ++ )
                                    {
                                                CExtBarButton * pTBB = ChildButtonGetAt( nIndex );
                                                ASSERT_VALID( pTBB );
                                                if( ! pTBB->IsVisible() )
                                                            continue;
                                                if( (pTBB->GetStyle()&TBBS_HIDDEN) != 0 )
                                                            continue;
                                                if( pTBB->IsKindOf( RUNTIME_CLASS(CExtRibbonButtonDialogLauncher) ) )
                                                            continue;
                                                CRect rcTBB = *pTBB;
                                                rcTBB.OffsetRect( nShift, 0 );
                                                pTBB->SetLayoutRect( dc, rcTBB );
                                    }
                        }
            }
            _sizeLayout.cy += nMaxLineHeight;
            _sizeLayout.cx += rcCP.left + rcCP.right;
            _sizeLayout.cy += rcCP.top + rcCP.bottom;
            _sizeLayout.cy -= 2;
            if(                     ParentButtonGet() == NULL
                        &&        _sizeLayout.cx < 40
                        )
                        _sizeLayout.cx = 40;
            if( bSetupRects )
            {
                        CRect rcTBB( ptCalcLayoutOffset, _sizeLayout );
                       rcTBB.OffsetRect( nDistanceBefore, 0 );
                        SetLayoutRect( dc, rcTBB );
            }
            _sizeLayout.cx += nDistanceBefore + nDistanceAfter;
            return _sizeLayout;
}

CSize CExtRibbonButtonToolGroup::OnRibbonCalcLayout(
            CDC & dc,
            CPoint & ptCalcLayoutOffset,
            bool bSetupRects
            )
{
            ASSERT_VALID( this );
            ASSERT( dc.GetSafeHdc() != NULL );
            if( ! IsVisible() )
                        return CSize( 0, 0 );
            if( (GetStyle()&TBBS_HIDDEN) != 0 )
                        return CSize( 0, 0 );
CExtRibbonPage * pRibbonPage = GetRibbonPage();
            ASSERT_VALID( pRibbonPage );
INT nDistanceBefore = OnRibbonGetOuterGroupDistance( true );
INT nDistanceAfter = OnRibbonGetOuterGroupDistance( false );
CRect rcCP = OnRibbonGetContentPadding();
            if( pRibbonPage->RibbonLayout_GroupCaptionIsTopAligned( this ) )
                        rcCP.top += pRibbonPage->RibbonLayout_GroupCaptionGetHeight( this );
            if( TopCollapsedStateGet() )
            {
                        CSize _sizeLayout = OnRibbonCalcCollapsedGroupSize( dc );
                        if( bSetupRects )
                        {
                                    CRect rcTBB( ptCalcLayoutOffset, _sizeLayout );
                                    rcTBB.OffsetRect( nDistanceBefore, 0 );
                                    SetLayoutRect( dc, rcTBB );
                        }
                        _sizeLayout.cx += nDistanceBefore + nDistanceAfter;
                        ptCalcLayoutOffset.x += nDistanceBefore + nDistanceAfter;
                        return _sizeLayout;
            } // if( TopCollapsedStateGet() )
CPoint ptGroupLayout = ptCalcLayoutOffset;
            ptGroupLayout.x += rcCP.left + nDistanceBefore;
            ptGroupLayout.y += rcCP.top;
CSize _sizeLayout( 0, 0 );
INT nIndex, nCount = ChildButtonGetCount();
INT nLineWidth = 0, nLineHeight = 0, nMaxLineWidth = 0;
INT nSizeMinCaptionArea = 0;
bool bLastWrapPassed = false;
CExtBarButton * pLastVisibleTBB = NULL;
            for( nIndex = 0; nIndex < nCount; nIndex ++ )
            {
                        CExtBarButton * pTBB = ChildButtonGetAt( nIndex );
                        ASSERT_VALID( pTBB );
                        if( pTBB->IsKindOf( RUNTIME_CLASS(CExtRibbonButtonDialogLauncher) ) )
                        {
                                    pTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
                                    CSize _sizeTBB = pTBB->RibbonILV_CalcSize( dc, -1 );
                                    if( bSetupRects )
                                    {
                                                CRect rcTBB( 0, 0, _sizeTBB.cx, _sizeTBB.cy );
                                                pTBB->SetLayoutRect( dc, rcTBB );
                                                pTBB->Show( false );
                                    } 
                                    nSizeMinCaptionArea += _sizeTBB.cx + 1;
                                    continue;
                        } // if( pTBB->IsKindOf( RUNTIME_CLASS(CExtRibbonButtonDialogLauncher) ) )
                        if( ! pTBB->IsVisible() )
                                    continue;
                        if( (pTBB->GetStyle()&TBBS_HIDDEN) != 0 )
                                    continue;
                        if( pTBB->IsSeparator() )
                        {
                                    INT nSeparatorHeight = pTBB->OnRibbonGetSeparatorExtent( false );
                                    CRect rcCpTBB = pTBB->OnRibbonGetContentPadding();
                                    ptGroupLayout.x = ptCalcLayoutOffset.x + rcCP.left;
                                    ptGroupLayout.y += nLineHeight;
                                    _sizeLayout.cy += nLineHeight;
                                    nLineWidth = nLineHeight = 0;
                                    bLastWrapPassed = true;
                                    if( bSetupRects )
                                    {
                                                pTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
                                                if( pLastVisibleTBB != NULL )
                                                            pLastVisibleTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
                                                pLastVisibleTBB = pTBB;
                                                CRect rcTBB( ptGroupLayout + rcCpTBB.TopLeft(), CSize( 100, nSeparatorHeight ) );
                                                rcTBB.OffsetRect( -nDistanceBefore, 0 );
                                                pTBB->SetLayoutRect( dc, rcTBB );
                                    }
                                    ptGroupLayout.y += nSeparatorHeight + rcCpTBB.top + rcCpTBB.bottom;
                                    _sizeLayout.cy += nSeparatorHeight + rcCpTBB.top + rcCpTBB.bottom;
                                    continue;
                        } // if( pTBB->IsSeparator() )
                        CSize _sizeTBB = pTBB->RibbonILV_CalcSize( dc, -1 );
                        bool bRibbonWrap = pTBB->RibbonWrapFromILE( pTBB->RibbonILE_Get() );
                        CRect rcCpTBB = pTBB->OnRibbonGetContentPadding();
                        INT nWidthTBB = _sizeTBB.cx + rcCpTBB.left + rcCpTBB.right;
                        INT nHeightTBB = _sizeTBB.cy + rcCpTBB.top + rcCpTBB.bottom;
                        nLineWidth += nWidthTBB;
                        nMaxLineWidth = max( nMaxLineWidth, nLineWidth );
                        nLineHeight = max( nLineHeight, nHeightTBB );
                        if( bSetupRects )
                        {
                                    CRect rcTBB( ptGroupLayout + rcCpTBB.TopLeft(), _sizeTBB );
                                    pTBB->SetLayoutRect( dc, rcTBB );
                                    rcTBB.OffsetRect( -nDistanceBefore, 0 );
                                    pTBB->SetWrap( CExtBarButton::__EVT_FLOAT, bRibbonWrap );
                                    pLastVisibleTBB = pTBB;
                        }
                        if( bRibbonWrap )
                        {
                                    ptGroupLayout.x = ptCalcLayoutOffset.x + rcCP.left;
                                    ptGroupLayout.y += nLineHeight;
                                    _sizeLayout.cy += nLineHeight;
                                    nLineWidth = nLineHeight = 0;
                                    bLastWrapPassed = true;
                        } // if( bRibbonWrap )
                        else
                        {
                                    ptGroupLayout.x += nWidthTBB;
                                    bLastWrapPassed = false;
                        } // else from if( bRibbonWrap )
            } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
            if( bSetupRects && pLastVisibleTBB != NULL )
                        pLastVisibleTBB->SetWrap( CExtBarButton::__EVT_FLOAT, true );
            if( ! bLastWrapPassed )
                        _sizeLayout.cy += nLineHeight;
            _sizeLayout.cy --;
            _sizeLayout.cx += nMaxLineWidth;
CExtSafeString strCaptionText = GetText();
            if( ! strCaptionText.IsEmpty() )
            {
                        strCaptionText.Replace( _T("\r"), _T("") );
                        strCaptionText.Replace( _T("\n"), _T(" ") );
                        CFont * pFont = & ( pRibbonPage->PmBridge_GetPM()->m_FontRibbonGroupCaption );
                        if( pFont->GetSafeHandle() == NULL )
                                    pFont = pRibbonPage->OnGetToolbarFont( false, true, this );
                        nSizeMinCaptionArea += CExtPaintManager::stat_CalcTextDimension( dc, *pFont, strCaptionText, DT_SINGLELINE|DT_LEFT|DT_TOP|DT_CALCRECT ).Width() + 6;
            }
            if( nSizeMinCaptionArea > _sizeLayout.cx )
            {
                        INT nShift = ( nSizeMinCaptionArea - _sizeLayout.cx ) / 2;
                        _sizeLayout.cx = nSizeMinCaptionArea;
                        if( nShift > 0 && bSetupRects )
                        {
                                    for( nIndex = 0; nIndex < nCount; nIndex ++ )
                                    {
                                                CExtBarButton * pTBB = ChildButtonGetAt( nIndex );
                                                ASSERT_VALID( pTBB );
                                                if( ! pTBB->IsVisible() )
                                                            continue;
                                                if( (pTBB->GetStyle()&TBBS_HIDDEN) != 0 )
                                                            continue;
                                                if( pTBB->IsKindOf( RUNTIME_CLASS(CExtRibbonButtonDialogLauncher) ) )
                                                            continue;
                                                CRect rcTBB = *pTBB;
                                                rcTBB.OffsetRect( nShift, 0 );
                                                pTBB->SetLayoutRect( dc, rcTBB );
                                    }
                        }
            }
            _sizeLayout.cx += rcCP.left + rcCP.right;
            _sizeLayout.cy += rcCP.top + rcCP.bottom;
            if(                     ParentButtonGet() == NULL
                        &&        _sizeLayout.cx < 40
                        )
                        _sizeLayout.cx = 40;
            if( bSetupRects )
            {
                        CRect rcTBB( ptCalcLayoutOffset, _sizeLayout );
                        rcTBB.OffsetRect( nDistanceBefore, 0 );
                        SetLayoutRect( dc, rcTBB );
            }
            _sizeLayout.cx += nDistanceBefore + nDistanceAfter;
            return _sizeLayout;
}

Robert Webb Mar 21, 2010 - 8:22 PM

Hmm, that’s an interesting solution, but it creates new (worse) problems.


Now less groups fit in, so more of them collapse.  We have one ribbon page for example with 8 groups.  At a certain window size (first one I tried) all 8 groups now collapse to just a single button, with one of them being completely inaccessible off the edge of the ribbon bar, whereas previously all 8 were expanded with room to spare.


In fact, one of the groups contains only a single button, which would easily fit in the non-collapsed group, even with caption, without the group being any larger than it is in collapsed form.


Elsewhere I see buttons within groups reduced to small icon without text, even though there is plenty of room for the text now that the whole group is wider due to its own caption.  It stands out as an obvious poor use of space.


I think I regret asking for this now!  Is there a way to choose the old behaviour?  The old behaviour with a tooltip for the group name when truncated would be perfect.  Even better if the full text is displayed only when it would not cause other contractions within the page (ie apply all normal layout logic first, then if there’s room, make some groups wider to fit their full captions).


Thanks,


Rob.