* Allow resize of elements relative to parent

git-svn-id: trunk@57471 -
This commit is contained in:
michael 2018-03-08 17:31:08 +00:00
parent f2b05a03f8
commit 25b06d4f2e
4 changed files with 57 additions and 13 deletions

View File

@ -31,7 +31,7 @@ Type
TSelectionSort = (ssNone,ssHorz,ssvert); TSelectionSort = (ssNone,ssHorz,ssvert);
THAlignAction = (haNone,haLeft,haCenter,haRight,haSpace,haCentB); THAlignAction = (haNone,haLeft,haCenter,haRight,haSpace,haCentB);
TVAlignAction = (vaNone,vaTop,vaCenter,vaBottom,vaSpace,vaCentB); TVAlignAction = (vaNone,vaTop,vaCenter,vaBottom,vaSpace,vaCentB);
TSizeAdjust = (saNone,saLargest,saSmallest,saValue); TSizeAdjust = (saNone,saLargest,saSmallest,saValue,saParent);
TFrameAction = (faNone,faAll,faTop,faBottom,faLeft,faRight); TFrameAction = (faNone,faAll,faTop,faBottom,faLeft,faRight);
TResizeHandlePosition = (rhNone,rhTopLeft,rhTop,rhTopRight,rhLeft,rhRight,rhBottomLeft, rhBottom,rhBottomRight); TResizeHandlePosition = (rhNone,rhTopLeft,rhTop,rhTopRight,rhLeft,rhRight,rhBottomLeft, rhBottom,rhBottomRight);
TResizeHandlePositions = set of TResizeHandlePosition; TResizeHandlePositions = set of TResizeHandlePosition;
@ -515,6 +515,24 @@ begin
For I:=0 to Length(Arr)-1 do For I:=0 to Length(Arr)-1 do
With Arr[i].Element.Layout do With Arr[i].Element.Layout do
begin begin
// For saParent, we determine the actual height/width here
// The parent can be different..
if AHeight=saParent then
begin
Top:=0.0;
if Assigned(Arr[i].Element.Parent) then
HSize:=Arr[i].Element.Parent.Layout.Height
else
HSize:=Arr[i].Element.Layout.Height
end;
if AWidth=saParent then
begin
Left:=0.0;
if Assigned(Arr[i].Element.Parent) then
WSize:=Arr[i].Element.Parent.Layout.Width
else
WSize:=Arr[i].Element.Layout.Width
end;
If (aHeight<>saNone) then If (aHeight<>saNone) then
Height:=HSize; Height:=HSize;
If aWidth<>saNone then If aWidth<>saNone then

View File

@ -1,17 +1,17 @@
object ResizeElementsForm: TResizeElementsForm object ResizeElementsForm: TResizeElementsForm
Left = 728 Left = 728
Height = 280 Height = 328
Top = 319 Top = 319
Width = 455 Width = 455
Caption = 'Resize selected elements' Caption = 'Resize selected elements'
ClientHeight = 280 ClientHeight = 328
ClientWidth = 455 ClientWidth = 455
Position = poOwnerFormCenter Position = poOwnerFormCenter
LCLVersion = '1.9.0.0' LCLVersion = '1.9.0.0'
object BPResize: TButtonPanel object BPResize: TButtonPanel
Left = 6 Left = 6
Height = 42 Height = 42
Top = 232 Top = 280
Width = 443 Width = 443
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
@ -26,11 +26,11 @@ object ResizeElementsForm: TResizeElementsForm
end end
object GBHorizontal: TGroupBox object GBHorizontal: TGroupBox
Left = 8 Left = 8
Height = 219 Height = 256
Top = 8 Top = 8
Width = 184 Width = 184
Caption = 'Horizontal' Caption = 'Horizontal'
ClientHeight = 201 ClientHeight = 238
ClientWidth = 182 ClientWidth = 182
TabOrder = 1 TabOrder = 1
object RBHNone: TRadioButton object RBHNone: TRadioButton
@ -39,10 +39,8 @@ object ResizeElementsForm: TResizeElementsForm
Top = 12 Top = 12
Width = 54 Width = 54
Caption = 'None' Caption = 'None'
Checked = True
OnClick = RBHFixedClick OnClick = RBHFixedClick
TabOrder = 0 TabOrder = 0
TabStop = True
end end
object RBHSmallest: TRadioButton object RBHSmallest: TRadioButton
Left = 18 Left = 18
@ -82,14 +80,25 @@ object ResizeElementsForm: TResizeElementsForm
TabOrder = 4 TabOrder = 4
Value = 1 Value = 1
end end
object RBHParentSize: TRadioButton
Left = 18
Height = 22
Top = 208
Width = 86
Caption = 'Parent size'
Checked = True
OnClick = RBHFixedClick
TabOrder = 5
TabStop = True
end
end end
object GBVertical: TGroupBox object GBVertical: TGroupBox
Left = 208 Left = 208
Height = 219 Height = 248
Top = 8 Top = 8
Width = 176 Width = 176
Caption = 'Vertical' Caption = 'Vertical'
ClientHeight = 201 ClientHeight = 230
ClientWidth = 174 ClientWidth = 174
TabOrder = 2 TabOrder = 2
object RBVNone: TRadioButton object RBVNone: TRadioButton
@ -98,10 +107,8 @@ object ResizeElementsForm: TResizeElementsForm
Top = 12 Top = 12
Width = 54 Width = 54
Caption = 'None' Caption = 'None'
Checked = True
OnClick = RBVNoneClick OnClick = RBVNoneClick
TabOrder = 0 TabOrder = 0
TabStop = True
end end
object RBVSmallest: TRadioButton object RBVSmallest: TRadioButton
Left = 18 Left = 18
@ -141,5 +148,16 @@ object ResizeElementsForm: TResizeElementsForm
TabOrder = 4 TabOrder = 4
Value = 1 Value = 1
end end
object RBVParentSize: TRadioButton
Left = 18
Height = 22
Top = 208
Width = 86
Caption = 'Parent size'
Checked = True
OnClick = RBHFixedClick
TabOrder = 5
TabStop = True
end
end end
end end

View File

@ -33,8 +33,10 @@ type
FSEVertical: TFloatSpinEdit; FSEVertical: TFloatSpinEdit;
GBHorizontal: TGroupBox; GBHorizontal: TGroupBox;
GBVertical: TGroupBox; GBVertical: TGroupBox;
RBHParentSize: TRadioButton;
RBHNone: TRadioButton; RBHNone: TRadioButton;
RBHFixed: TRadioButton; RBHFixed: TRadioButton;
RBVParentSize: TRadioButton;
RBVNone: TRadioButton; RBVNone: TRadioButton;
RBVFixed: TRadioButton; RBVFixed: TRadioButton;
RBVLargest: TRadioButton; RBVLargest: TRadioButton;
@ -84,6 +86,8 @@ begin
Result:=saLargest Result:=saLargest
else if RBHFixed.Checked then else if RBHFixed.Checked then
Result:=saValue Result:=saValue
else if RBHParentSize.Checked then
Result:=saParent
else else
Result:=saNone; Result:=saNone;
end; end;
@ -101,6 +105,8 @@ begin
Result:=saLargest Result:=saLargest
else if RBVFixed.Checked then else if RBVFixed.Checked then
Result:=saValue Result:=saValue
else if RBVParentSize.Checked then
Result:=saParent
else else
Result:=saNone; Result:=saNone;
end; end;
@ -116,6 +122,7 @@ begin
saLargest : RBHLargest.Checked:=True; saLargest : RBHLargest.Checked:=True;
saSmallest : RBHSmallest.Checked:=True; saSmallest : RBHSmallest.Checked:=True;
saValue : RBHFixed.Checked:=True; saValue : RBHFixed.Checked:=True;
saParent : RBHParentSize.Checked:=True;
else else
RBHNone.Checked:=True; RBHNone.Checked:=True;
end; end;
@ -132,6 +139,7 @@ begin
saLargest : RBVLargest.Checked:=True; saLargest : RBVLargest.Checked:=True;
saSmallest : RBVSmallest.Checked:=True; saSmallest : RBVSmallest.Checked:=True;
saValue : RBVFixed.Checked:=True; saValue : RBVFixed.Checked:=True;
saParent : RBVParentSize.Checked:=True;
else else
RBVNone.Checked:=True; RBVNone.Checked:=True;
end; end;

View File

@ -1255,7 +1255,7 @@ end;
procedure TFPReportDesignerForm.AResizeUpdate(Sender: TObject); procedure TFPReportDesignerForm.AResizeUpdate(Sender: TObject);
begin begin
(Sender as TAction).Enabled:=Assigned(ReportResizeFormClass) and Assigned(CurrentDesigner) and CurrentDesigner.Objects.IsMultiSelect; (Sender as TAction).Enabled:=Assigned(ReportResizeFormClass) and Assigned(CurrentDesigner);
end; end;
procedure TFPReportDesignerForm.HResizeAllow(Sender: TObject); procedure TFPReportDesignerForm.HResizeAllow(Sender: TObject);