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

This commit is contained in:
Ondrej Pokorny 2022-08-17 23:46:50 +02:00
parent 44a40cb0ed
commit cea0e01fd4

View File

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