SilverpointDev / sptbxlib

SpTBXLib is an expansion package for TB2K Delphi components that adds multiple features including support for styles and custom skins.
https://www.silverpointdevelopment.com
Other
73 stars 33 forks source link

Drop down arrow is drawn behind the image #86

Closed pyscripter closed 3 years ago

pyscripter commented 3 years ago

Commit https://github.com/SilverpointDev/sptbxlib/commit/4db3ebb80fe48d4a301383bb5e6d781d2fc353e4 broke the painting of dropdown arrows.

To reproduce drop a TSpTBXSubmenuItem on a Toolbar and set its Options to [tboDropdownArrow]. Keep DropDownCombo to False.

This is the part of the code in SpTBXItem.pas that is to blame:

  R := ClientAreaRect;
  if ItemInfo.ToolbarStyle then begin
    if ItemInfo.HasArrow then begin
      ItemInfo.ComboRect := R;
      if ItemInfo.IsSplit then begin
        Dec(R.Right, SplitBtnArrowSize);
        ItemInfo.ComboRect.Left := R.Right;
      end
      else
        if not IsSpecialDropDown then begin
          // If the caption is shown calculate the right margin, if the caption
          // is not visible center the arrow
          if TextInfo.IsCaptionShown then
            if View.Orientation <> tbvoVertical then
              ItemInfo.ComboRect := Rect(R.Right - Self.tbDropdownArrowWidth - Self.tbDropdownArrowMargin, 0,
                R.Right - Self.tbDropdownArrowMargin, R.Bottom)
            else
              ItemInfo.ComboRect := Rect(0, R.Bottom - Self.tbDropdownArrowWidth - Self.tbDropdownArrowMargin,
                R.Right, R.Bottom - Self.tbDropdownArrowMargin);
        end
        else begin

ItemInfo.ComboRect is initialized with the ClientAreRect.
If

then Item.ComboRect still points to the ClientRect and the arrow is centered in that area. And if SpTBXItem has an image the arrow is painted behind the image.

The commit added the
if TextInfo.IsCaptionShown then statement but did not provide the else part. Before the commit the code was working fine when there is an image but no label.

MShark67 commented 3 years ago

Just a note that this is a dupe of #84. I've been running this fix for a month with no issues that I've seen.

pyscripter commented 3 years ago

@MShark67 Yes indeed. I am really sorry I missed that. And my fix is the same as yours.

MShark67 commented 3 years ago

No worries! Your report may get more attention (and deservedly so, your contributions are always top notch!)

SilverpointDev commented 3 years ago

Fixed