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
Centered controls in section
β Actual result
Uncentered control
π· Screenshots
Are there any useful screenshots? WinKey+Shift+S and then just paste them directly into the form
2023-07-07 VfpImaging
LOCAL lnControls, loUnique as Control
m.lnControls = 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()
2023-07-07 VfpImaging
Realign if we are dealing with a single control, in case the lower lable width is bigger than the control width
If we have just one control, center it
IF m.lnControls = 1
m.loUnique.Left = CEILING((This.Width - m.loUnique.Width) / 2)
ENDIF
π 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
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, '')
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()