mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-21 18:29:34 +01:00
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:
parent
72551f3c1e
commit
bc1e8a9946
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user