You've already forked lazarus-ccr
NiceSideBar: Fix crash when an image list used several times in the component is deleted in the form designer. Beginning to support high-dpi.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8856 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -9,7 +9,7 @@ object Form1: TForm1
|
|||||||
ClientWidth = 623
|
ClientWidth = 623
|
||||||
Color = clWhite
|
Color = clWhite
|
||||||
Position = poDesktopCenter
|
Position = poDesktopCenter
|
||||||
LCLVersion = '2.3.0.0'
|
LCLVersion = '3.99.0.0'
|
||||||
object Shape1: TShape
|
object Shape1: TShape
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 113
|
Height = 113
|
||||||
@ -271,6 +271,7 @@ object Form1: TForm1
|
|||||||
TabOrder = 8
|
TabOrder = 8
|
||||||
end
|
end
|
||||||
object ImageList1: TImageList
|
object ImageList1: TImageList
|
||||||
|
Scaled = True
|
||||||
Left = 240
|
Left = 240
|
||||||
Top = 136
|
Top = 136
|
||||||
Bitmap = {
|
Bitmap = {
|
||||||
@ -297,6 +298,7 @@ object Form1: TForm1
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
object ImageList2: TImageList
|
object ImageList2: TImageList
|
||||||
|
Scaled = True
|
||||||
Left = 320
|
Left = 320
|
||||||
Top = 136
|
Top = 136
|
||||||
Bitmap = {
|
Bitmap = {
|
||||||
|
@ -39,7 +39,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
LCLIntf, LCLType, LMessages,
|
LCLIntf, LCLType, LMessages, LazLoggerBase,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Windows, Messages,
|
Windows, Messages,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -322,11 +322,19 @@ type
|
|||||||
procedure DrawNonItem(ACanvas: TCanvas; Rc: TRect); virtual;
|
procedure DrawNonItem(ACanvas: TCanvas; Rc: TRect); virtual;
|
||||||
procedure DrawScroller(ACanvas: TCanvas; Rc: TRect; Up: Boolean; Hover: Boolean); virtual;
|
procedure DrawScroller(ACanvas: TCanvas; Rc: TRect; Up: Boolean; Hover: Boolean); virtual;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
|
{$IFDEF FPC}
|
||||||
|
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double); override;
|
||||||
|
{$ENDIF}
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure BeginUpdate;
|
procedure BeginUpdate;
|
||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
|
{$IFDEF FPC}
|
||||||
|
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
|
||||||
|
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
published
|
published
|
||||||
property ItemStyle: TSideBarItemStyle read FItemStyle write SetItemStyle;
|
property ItemStyle: TSideBarItemStyle read FItemStyle write SetItemStyle;
|
||||||
property SubItemStyle: TSideBarItemStyle read FSubItemStyle write SetSubItemStyle;
|
property SubItemStyle: TSideBarItemStyle read FSubItemStyle write SetSubItemStyle;
|
||||||
@ -701,6 +709,53 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF FPC}
|
||||||
|
// Handle Lazarus' High-DPI scaling
|
||||||
|
procedure TNiceSidebar.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||||
|
const AXProportion, AYProportion: Double);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
||||||
|
begin
|
||||||
|
FItemHeight := round(FItemHeight * AYProportion);
|
||||||
|
FSubItemHeight := round(FSubItemHeight * AYProportion);
|
||||||
|
FMargin := round(FMargin * AXProportion);
|
||||||
|
FIndent := round(FIndent * AXProportion);
|
||||||
|
FGroupSeparator := round(FGroupSeparator * AYProportion);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TNiceSidebar.FixDesignFontsPPI(const ADesignTimePPI: Integer);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
|
||||||
|
DoFixDesignFontPPI(FItemStyle.NormalFont, ADesignTimePPI);
|
||||||
|
DoFixDesignFontPPI(FItemStyle.HoverFont, ADesignTimePPI);
|
||||||
|
DoFixDesignFontPPI(FItemStyle.SelectedFont, ADesignTimePPI);
|
||||||
|
DoFixDesignFontPPI(FItemStyle.DisabledFont, ADesignTimePPI);
|
||||||
|
|
||||||
|
DoFixDesignFontPPI(FSubItemStyle.NormalFont, ADesignTimePPI);
|
||||||
|
DoFixDesignFontPPI(FSubItemStyle.HoverFont, ADesignTimePPI);
|
||||||
|
DoFixDesignFontPPI(FSubItemStyle.SelectedFont, ADesignTimePPI);
|
||||||
|
DoFixDesignFontPPI(FSubItemStyle.DisabledFont, ADesignTimePPI);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TNiceSidebar.ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
|
||||||
|
DoScaleFontPPI(FItemStyle.NormalFont, AToPPI, AProportion);
|
||||||
|
DoScaleFontPPI(FItemStyle.HoverFont, AToPPI, AProportion);
|
||||||
|
DoScaleFontPPI(FItemStyle.SelectedFont, AToPPI, AProportion);
|
||||||
|
DoScaleFontPPI(FItemStyle.DisabledFont, AToPPI, AProportion);
|
||||||
|
|
||||||
|
DoScaleFontPPI(FSubItemStyle.NormalFont, AToPPI, AProportion);
|
||||||
|
DoScaleFontPPI(FSubItemStyle.HoverFont, AToPPI, AProportion);
|
||||||
|
DoScaleFontPPI(FSubItemStyle.SelectedFont, AToPPI, AProportion);
|
||||||
|
DoScaleFontPPI(FSubItemStyle.DisabledFont, AToPPI, AProportion);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
procedure TNiceSidebar.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
procedure TNiceSidebar.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
var
|
var
|
||||||
@ -708,9 +763,7 @@ var
|
|||||||
P: PSBInfo;
|
P: PSBInfo;
|
||||||
Str: string;
|
Str: string;
|
||||||
Changed: Boolean;
|
Changed: Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
LCLIntf.SetFocus(Handle);
|
LCLIntf.SetFocus(Handle);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -1466,33 +1519,24 @@ procedure TNiceSideBar.Notification(AComponent: TComponent;
|
|||||||
Operation: TOperation);
|
Operation: TOperation);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
if (AComponent = FImages) then
|
if (Operation = opRemove) then
|
||||||
begin
|
begin
|
||||||
if (Operation = opRemove) then
|
if (AComponent = FImages) then
|
||||||
begin
|
begin
|
||||||
FImages := nil;
|
FImages := nil;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end else
|
if (AComponent = FHoverImages) then
|
||||||
if (AComponent = FHoverImages) then
|
|
||||||
begin
|
|
||||||
if (Operation = opRemove) then
|
|
||||||
begin
|
begin
|
||||||
FHoverImages := nil;
|
FHoverImages := nil;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end else
|
if (AComponent = FSelectedImages) then
|
||||||
if (AComponent = FSelectedImages) then
|
|
||||||
begin
|
|
||||||
if (Operation = opRemove) then
|
|
||||||
begin
|
begin
|
||||||
FSelectedImages := nil;
|
FSelectedImages := nil;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end else
|
if (AComponent = FDisabledImages) then
|
||||||
if (AComponent = FDisabledImages) then
|
|
||||||
begin
|
|
||||||
if (Operation = opRemove) then
|
|
||||||
begin
|
begin
|
||||||
FDisabledImages := nil;
|
FDisabledImages := nil;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
Reference in New Issue
Block a user