DougHennig / Ribbon

A Microsoft Office 365-like ribbon control for VFP forms
24 stars 11 forks source link

Control not aligned when the lower label is wider than the control #12

Closed VfpImaging closed 1 year ago

VfpImaging commented 1 year ago

πŸ“ Provide detailed reproduction steps (if any)

In class "sfRibbonToolbarSection", method "CalculateWidth" Added some few code to realign a unique control if the section width is bigger than the inside control width

βœ”οΈ Expected result

❌ Actual result

πŸ“· Screenshots

Are there any useful screenshots? WinKey+Shift+S and then just paste them directly into the form image

A simple fix below:

LOCAL lnWidth, ; lcType, ; loControl, ; llVertical, ; lnLeft, ; lnCaptionWidth

LOCAL lnTop m.lnWidth = 0

for each m.loControl in This.Controls foxobject m.lcType = iif(pemstatus(m.loControl, 'Type', 5), m.loControl.Type, '')

do case
    * Do nothing if this is the separator or section label or the control isn't
    * visible.
    case inlist(m.loControl.Name, 'linSeparator', 'lblSection') or ;
            (pemstatus(m.loControl, 'Visible', 5) and not m.loControl.Visible)
        && do nothing

        * Horizontal button: if we already have enough buttons in this column, move to
        * the next column. Set the Left property and if this isn't the first one, set
        * the Top property. Then increment the total width value.
        LOOP

    case m.lcType = 'HButton'
        if m.llVertical and m.lnTop + m.loControl.Height > This.Height
            m.llVertical = .F.
        endif m.llVertical ...

        if m.llVertical
            m.loControl.Top  = m.lnTop
            m.loControl.Left = m.lnLeft
        ELSE
            m.loControl.Left = max(m.lnWidth, This.Padding)
            m.lnLeft         = m.loControl.Left
        endif m.llVertical

        m.lnWidth    = max(m.lnWidth, m.loControl.Left + m.loControl.Width)
        m.lnTop      = m.loControl.Top + m.loControl.Height
        m.llVertical = .T.
        * For all other controls, move the control to the next Left position and
        * increment the total width value.

    CASE 1 = 2

    OTHERWISE 
        m.loControl.Left = max(m.lnWidth, This.Padding)
        m.lnWidth        = max(m.lnWidth, m.loControl.Left + m.loControl.Width)
        m.llVertical     = .F.

ENDCASE 

* 2023-07-07 VfpImaging
m.lnControls = m.lnControls + 1
m.loUnique = m.loControl
*

NEXT m.loControl

m.lnCaptionWidth = This.oGDI.GetWidth(This.Caption) This.linSeparator.Left = max(m.lnWidth, m.lnCaptionWidth) + This.Padding store This.linSeparator.Left to This.Width, This.lblSection.Width This.Parent.AdjustSections()

DougHennig commented 1 year ago

Fixed in the latest build.