LCL/PairSplitter: Fix Position parameter and panel widths being out of sync under some circumstances (https://forum.lazarus.freepascal.org/index.php/topic,46726.msg333773.html#msg333773).

git-svn-id: trunk@61909 -
This commit is contained in:
wp 2019-09-21 20:48:04 +00:00
parent b1e4249c0e
commit 028edb1573
2 changed files with 17 additions and 1 deletions

View File

@ -264,8 +264,11 @@ end;
procedure TCustomPairSplitter.SetPosition(const AValue: integer);
begin
if FPosition = AValue then
if (FPosition = AValue) and
(TWSCustomPairSplitterClass(WidgetSetClass).GetPosition(Self) = FPosition)
then
Exit;
FPosition := AValue;
if FPosition < 0 then
FPosition := 0;

View File

@ -53,6 +53,7 @@ type
published
class function AddSide(ASplitter: TCustomPairSplitter; ASide: TPairSplitterSide; Side: integer): Boolean; virtual;
class function RemoveSide(ASplitter: TCustomPairSplitter; ASide: TPairSplitterSide; Side: integer): Boolean; virtual;
class function GetPosition(ASplitter: TCustomPairSplitter): Integer; virtual;
class function SetPosition(ASplitter: TCustomPairSplitter; var NewPosition: integer): Boolean; virtual;
// special cursor handling
@ -133,6 +134,18 @@ begin
Result := False;
end;
class function TWSCustomPairSplitter.GetPosition(ASplitter: TCustomPairSplitter): Integer;
begin
if WSCheckHandleAllocated(ASplitter, 'GetPosition') then
begin
if ASplitter.SplitterType = pstHorizontal then
Result := ASplitter.Sides[0].Width
else
Result := ASplitter.Sides[0].Height;
end else
Result := ASplitter.Position;
end;
class function TWSCustomPairSplitter.SetPosition(
ASplitter: TCustomPairSplitter; var NewPosition: integer): Boolean;
var