TAChart: More user-friendly zoom-in by ZoomDragTool with fixed RatioLimit

This commit is contained in:
wp_xyz 2024-12-25 23:41:12 +01:00
parent 6dd342cef1
commit 345460427e

View File

@ -1304,6 +1304,7 @@ var
ScaleX, ScaleY: Double; ScaleX, ScaleY: Double;
AllowProportionalAdjustmentX, AllowProportionalAdjustmentY: Boolean; AllowProportionalAdjustmentX, AllowProportionalAdjustmentY: Boolean;
begin begin
// Allow user to adjust the calculated new extent
DoCalculateNewExtent(ANewExtent); DoCalculateNewExtent(ANewExtent);
if not AFull then if not AFull then
@ -1511,6 +1512,7 @@ const
(zreDragTopLeft, zreClick, zreDragBottomLeft), (zreDragTopLeft, zreClick, zreDragBottomLeft),
(zreClick, zreClick, zreClick), (zreClick, zreClick, zreClick),
(zreDragTopRight, zreClick, zreDragBottomRight)); (zreDragTopRight, zreClick, zreDragBottomRight));
// Means: "direction relative to mouse-down point"
var var
dragDir: TRestoreExtentOn; dragDir: TRestoreExtentOn;
begin begin
@ -1522,6 +1524,18 @@ begin
with FSelectionRect do with FSelectionRect do
dragDir := DRAG_DIR[Sign(Right - Left), Sign(Bottom - Top)]; dragDir := DRAG_DIR[Sign(Right - Left), Sign(Bottom - Top)];
// More user-friendly drag direction for zoom-in in case of fixed RatioLimit
case RatioLimit of
zrlNone, zrlProportional: ;
zrlFixedX:
// drag down (not necessarily right)
if dragDir = zreDragBottomLeft then dragdir := zreDragBottomRight;
zrlFixedY:
// drag right (not necessarily down)
if dragDir = zreDragTopRight then dragdir := zreDragBottomRight;
end;
if if
(dragDir in RestoreExtentOn) or (dragDir in RestoreExtentOn) or
(zreDifferentDrag in RestoreExtentOn) and (zreDifferentDrag in RestoreExtentOn) and