Skip to content

Instantly share code, notes, and snippets.

@ortuagustin
Created August 21, 2016 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ortuagustin/aa823d6a1f4ff6c36d59e67c36488b89 to your computer and use it in GitHub Desktop.
Save ortuagustin/aa823d6a1f4ff6c36d59e67c36488b89 to your computer and use it in GitHub Desktop.
Firemonkey constraint
// Source: http://delphiaccess.com/foros/index.php/topic/12206-alguien-conoce-algo-análogo-a-constraint-de-vcl/
// Author: @genriquez
unit FMX.Layout.Constraint;
type
TLayout = class(FMX.Layouts.TLayout)
private
FConstraint: TPoint;
procedure SetConstraint(const Value: TPoint);
protected
procedure HandleSizeChanged; Override;
public
Property Constraint: TPoint read FConstraint write SetConstraint;
end;
implementation
{ TLayout }
procedure TLayout.HandleSizeChanged;
begin
If (FConstraint.X > 0) and (Width < FConstraint.X) then
Width := FConstraint.X;
If (FConstraint.Y > 0) and (Height < FConstraint.Y) then
Height := FConstraint.Y;
inherited;
end;
procedure TLayout.SetConstraint(const Value: TPoint);
begin
FConstraint := Value;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment