From bc1e8a9946ccd3d7d7f7ea1db5ae08a2326ed80e Mon Sep 17 00:00:00 2001 From: juha Date: Mon, 17 Feb 2020 18:17:25 +0000 Subject: [PATCH] LCL: Update Images in BitBtn and SpeedButton from connected Action also when Glyph is not empty. Issue #22071. git-svn-id: trunk@62642 - --- designer/jitforms.pp | 4 ++-- lcl/include/bitbtn.inc | 25 +++++++++++++++---------- lcl/include/menuitem.inc | 2 +- lcl/include/speedbutton.inc | 26 ++++++++++++-------------- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/designer/jitforms.pp b/designer/jitforms.pp index 5d9d4c8fca..cad9873fd6 100644 --- a/designer/jitforms.pp +++ b/designer/jitforms.pp @@ -494,8 +494,8 @@ procedure TComponentWithOverrideValidateRename.ValidateRename( var Designer: TIDesigner; begin - debugln(['TComponentWithOverrideValidateRename.ValidateRename ',DbgSName(Self), - ' ',DbgSName(AComponent),' CurName=',CurName,' NewName=',NewName]); + //debugln(['TComponentWithOverrideValidateRename.ValidateRename ',DbgSName(Self), + // ' ',DbgSName(AComponent),' CurName=',CurName,' NewName=',NewName]); inherited ValidateRename(AComponent, CurName, NewName); Designer:=FindRootDesigner(Self); if Designer <> nil then diff --git a/lcl/include/bitbtn.inc b/lcl/include/bitbtn.inc index 5240353f9b..1a24b75a5e 100644 --- a/lcl/include/bitbtn.inc +++ b/lcl/include/bitbtn.inc @@ -201,20 +201,25 @@ end; procedure TCustomBitBtn.ActionChange(Sender: TObject; CheckDefaults: Boolean); var - ImagesRes: TScaledImageListResolution; + NewAct: TCustomAction; + Imgs: TCustomImageList; + ImgRes: TScaledImageListResolution; begin inherited ActionChange(Sender,CheckDefaults); if Sender is TCustomAction then begin - with TCustomAction(Sender) do - begin - if (Glyph.Empty) and (ActionList <> nil) and (ActionList.Images <> nil) and - (ImageIndex >= 0) and (ImageIndex < ActionList.Images.Count) then - begin - ImagesRes := ActionList.Images.ResolutionForPPI[ImageWidth, Font.PixelsPerInch, GetCanvasScaleFactor]; - ImagesRes.GetBitmap(ImageIndex, Glyph); - end; - end; + NewAct := TCustomAction(Sender); + //DebugLn(['TCustomBitBtn.ActionChange: Glyph.Empty=', Glyph.Empty, + // ', Action=', NewAct.Caption, + // ', ActionList=', NewAct.ActionList, + // ', Images=', NewAct.ActionList.Images, + // ', ImageIndex=', NewAct.ImageIndex ]); + if (NewAct.ActionList = nil) or (NewAct.ImageIndex < 0) then Exit; + Imgs := NewAct.ActionList.Images; + if (Imgs = nil) or (NewAct.ImageIndex >= Imgs.Count) then Exit; + //DebugLn([' TCustomBitBtn.ActionChange: Setting image, ImageWidth=', ImageWidth]); + ImgRes := Imgs.ResolutionForPPI[ImageWidth,Font.PixelsPerInch,GetCanvasScaleFactor]; + ImgRes.GetBitmap(NewAct.ImageIndex, Glyph); end; end; diff --git a/lcl/include/menuitem.inc b/lcl/include/menuitem.inc index ec06da0d32..bcc20afdb2 100644 --- a/lcl/include/menuitem.inc +++ b/lcl/include/menuitem.inc @@ -1553,7 +1553,7 @@ end; interface. This procedure just sets the private variables. //todo - MWE: ??? shouln'd we get checked from the interface in that case ??? + MWE: ??? shouldn't we get checked from the interface in that case ??? ------------------------------------------------------------------------------} procedure TMenuItem.TurnSiblingsOff; var diff --git a/lcl/include/speedbutton.inc b/lcl/include/speedbutton.inc index 39e73ef8c5..143431313c 100644 --- a/lcl/include/speedbutton.inc +++ b/lcl/include/speedbutton.inc @@ -417,25 +417,23 @@ begin Result := ThemeServices.GetElementDetails(ButtonPart) end; -procedure TCustomSpeedButton.ActionChange(Sender: TObject; - CheckDefaults: Boolean); +procedure TCustomSpeedButton.ActionChange(Sender: TObject; CheckDefaults: Boolean); var - ImagesRes: TScaledImageListResolution; + NewAct: TCustomAction; + Imgs: TCustomImageList; + ImgRes: TScaledImageListResolution; begin inherited ActionChange(Sender,CheckDefaults); if Sender is TCustomAction then begin - with TCustomAction(Sender) do - begin - if CheckDefaults or (Self.GroupIndex = 0) then - Self.GroupIndex := GroupIndex; - if (Glyph.Empty) and (ActionList <> nil) and (ActionList.Images <> nil) and - (ImageIndex >= 0) and (ImageIndex < ActionList.Images.Count) then - begin - ImagesRes := ActionList.Images.ResolutionForPPI[ImageWidth, Font.PixelsPerInch, GetCanvasScaleFactor]; - ImagesRes.GetBitmap(ImageIndex, Glyph); - end; - end; + NewAct := TCustomAction(Sender); + if (not CheckDefaults) or (GroupIndex = 0) then + GroupIndex := NewAct.GroupIndex; + if (NewAct.ActionList = nil) or (NewAct.ImageIndex < 0) then Exit; + Imgs := NewAct.ActionList.Images; + if (Imgs = nil) or (NewAct.ImageIndex >= Imgs.Count) then Exit; + ImgRes := Imgs.ResolutionForPPI[ImageWidth,Font.PixelsPerInch,GetCanvasScaleFactor]; + ImgRes.GetBitmap(NewAct.ImageIndex, Glyph); end; end;