LCL buttonpanel: fix hiding glyphs with ShowGlyphs. issue #37455

(cherry picked from commit cea0e01fd4)
This commit is contained in:
Ondrej Pokorny 2022-08-17 23:46:50 +02:00 committed by Maxim Ganetsky
parent cc48d6c1d7
commit ed085d959f

View File

@ -15,7 +15,7 @@ interface
uses
Math, Types, SysUtils, Classes,
// LCL
LCLType, LMessages, Controls, ExtCtrls, StdCtrls, Buttons, Forms, Graphics, Themes,
LCLType, LMessages, Controls, ExtCtrls, StdCtrls, Buttons, Forms, Graphics, Themes, Menus,
// LazUtils
GraphType;
@ -60,7 +60,6 @@ type
FShowButtons: TPanelButtons;
FShowGlyphs: TPanelButtons;
FBevel: TBevel;
FGlyphs: array[TPanelButton] of TBitmap;
FButtons: array[TPanelButton] of TPanelBitBtn;
FButtonsWidth: Integer;
FButtonsHeight: Integer;
@ -97,7 +96,6 @@ type
procedure CMShowingChanged(var Message: TLMessage); message CM_SHOWINGCHANGED;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Align default alBottom;
property AutoSize default True;
@ -234,13 +232,10 @@ begin
begin
if FButtons[btn] = nil then Continue;
if btn in FShowGlyphs
then begin
FButtons[btn].Glyph.Assign(FGlyphs[btn]);
end
else begin
FButtons[btn].Glyph.Assign(nil);
end;
if btn in FShowGlyphs then
FButtons[btn].GlyphShowMode := gsmApplication
else
FButtons[btn].GlyphShowMode := gsmNever;
end;
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomButtonPanel.DoShowGlyphs'){$ENDIF};
end;
@ -547,16 +542,10 @@ begin
AutoSize := true;
TabOrder := Ord(AButton); //initial order
Align := alCustom;
if FGlyphs[AButton] = nil
then begin
// first time
FGlyphs[AButton] := TBitmap.Create;
FGlyphs[AButton].Assign(Glyph);
end;
// (re)set the glyph if needed
if (AButton in FShowGlyphs)
then Glyph.Assign(FGlyphs[AButton])
else Glyph.Assign(nil);
if AButton in FShowGlyphs then
GlyphShowMode := gsmApplication
else
GlyphShowMode := gsmNever;
// set default
Default := AButton = FDefaultButton;
@ -689,13 +678,4 @@ begin
//debugln(['TCustomButtonPanel.CalculatePreferredSize ',DbgSName(Self),' ',PreferredWidth,'x',PreferredHeight]);
end;
destructor TCustomButtonPanel.Destroy;
var
btn: TPanelButton;
begin
for btn := Low(btn) to High(btn) do
FreeAndNil(FGlyphs[btn]);
inherited Destroy;
end;
end.