LCL: Improved docking of coolbar/controlbar (more patches by Andrey Zubarev), Issue

git-svn-id: trunk@55426 -
This commit is contained in:
wp 2017-07-02 20:29:55 +00:00
parent f2bb18cf26
commit f06f1ef334
5 changed files with 26 additions and 12 deletions

View File

@ -543,6 +543,8 @@ type
procedure DragMove(APosition: TPoint); virtual;abstract;
procedure DragStop(ADrop: Boolean); virtual;abstract;
function IsCanBeStartDragging(Site: TWinControl; AThreshold: Integer; X,Y:Integer): boolean; virtual;abstract;
property DragImmediate: Boolean read FDragImmediate write FDragImmediate default True;
property DragThreshold: Integer read FDragThreshold write FDragThreshold default 5;
end;

View File

@ -508,9 +508,6 @@ procedure TCustomControlBar.MouseMove(Shift: TShiftState; X, Y: Integer);
var aBand: TCtrlBand;
aCursor: TCursorDesign;
bDragging, bGrabber: Boolean;
aRect: TRect;
const
cUserDragArea = 64;
begin
inherited MouseMove(Shift, X, Y);
if FBandMove <> bmMoving then begin
@ -528,9 +525,7 @@ begin
FHoveredBand := nil;
end;
end else begin
aRect := ClientRect;
InflateRect(aRect, cUserDragArea, cUserDragArea);
if PtInRect(aRect, Point(X, Y)) then begin
if not DragManager.IsCanBeStartDragging(self,-1,X,Y) then begin
MoveBand(FHoveredBand, X, Y, True);
end else begin
bDragging := False;

View File

@ -900,9 +900,6 @@ end;
procedure TCustomCoolBar.MouseMove(Shift: TShiftState; X, Y: Integer);
var aBand: Integer;
aGrabber: Boolean;
aRect: TRect;
const
cUserDragArea = 64;
begin
inherited MouseMove(Shift, X, Y);
if length(FVisiBands) > 0 then begin
@ -933,9 +930,7 @@ begin
dbMove: begin
if FDraggedBandIndex>-1 then begin
Cursor := crDrag;
aRect := ClientRect;
InflateRect(aRect, cUserDragArea, cUserDragArea);
if not PtInRect(aRect, Point(X, Y)) then
if DragManager.IsCanBeStartDragging(self,-1,X,Y) then
DragManager.DragStart(FVisiBands[FDraggedBandIndex].Control, True, -1, True);
end;
end;

View File

@ -99,6 +99,8 @@ type
procedure DragMove(APosition: TPoint); override;
procedure DragStop(ADropped: Boolean); override;
function IsCanBeStartDragging(Site: TWinControl; AThreshold: Integer; X,Y:Integer): boolean; override;
property StartPosition: TPoint read FStartPosition;
end;
@ -829,5 +831,21 @@ begin
DragStop(AIsDragging);
end;
function TDragManagerDefault.IsCanBeStartDragging(Site: TWinControl; AThreshold: Integer; X,Y:Integer): boolean;
var
Threshold:integer;
aRect:TRect;
begin
if AThreshold<=0 then
Threshold:=DragThreshold
else
Threshold:=AThreshold;
aRect := Site.ClientRect;
InflateRect(aRect, Threshold, Threshold);
if not PtInRect(aRect, Point(X, Y)) then
Result:=true
else
Result:=false;
end;
//included by controls.pp

View File

@ -244,6 +244,10 @@ end;
function TToolBar.IsVertical: Boolean;
begin
if Assigned(Parent) then begin
if (Parent is TCoolBar) then
exit((Parent as TCoolBar).Vertical);
end;
if Align in [alNone, alClient, alCustom] then
Result := Height > Width
else