LCL: Update Images in BitBtn and SpeedButton from connected Action also when Glyph is not empty. Issue #22071.

git-svn-id: trunk@62642 -
This commit is contained in:
juha 2020-02-17 18:17:25 +00:00
parent 72551f3c1e
commit bc1e8a9946
4 changed files with 30 additions and 27 deletions

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;