2014年9月25日 星期四

Firemonkey how to enable anti-aliasing

In Rad Studio XE2~XE7 canvas anti-aliasing seems to disable by default, while use controls have special shapes will case shape control has its border toothed like this one:



Set form property like Form1.Quality:= HighQuality can turn on anti-aliasing , the result UI will like this:



In some situation , this may now work properly , we need to add more code on Form Event : 

onCreate :


preocdure TForm1.onCreate(Sendor: TObject);

begin
Form1.RecreateCanvas;
Form1.Invalidate;
end; 


Firemonkey Drag and Drop problem when control is placed on layout

In Rad Studio XE5~XE7 when place control on TLayout component , the drag and drop functionality is not work properly . Someone have fix this problem by re-writing FMX.Forms.pas (Link) , I have tried and sure this is working for XE5~XE7.

the following fixed code is from here  (Link

...
function TCommonCustomForm.FindTarget(P: TPointF; const Data: TDragObject): IControl;
var
  i: Integer;
  NewObj: IControl;
begin
  Result := nil;
  for i := 0 to ChildrenCount - 1 do
    // add an exception for layouts
if Supports(Children[i], IControl, NewObj) and NewObj.Visible and (NewObj.HitTest or (NewObj is TLayout)) then
    begin
      NewObj := NewObj.FindTarget(P, Data);


      if Assigned(NewObj) then
        Exit(NewObj);
    end;
end
...
PS. you need to include FMX.Layouts in  FMX.Forms.pas like this:
...
implementation

uses
  System.Variants,
  System.Generics.Defaults,
  System.RTLConsts,
  System.Rtti, System.Actions,
  System.Math.Vectors,
  FMX.Consts,
  FMX.Dialogs,
  // fix drag and drop buf in tlayout , see "FindTarget"
  FMX.Layouts,
  FMX.Platform, FMX.Menus,
  FMX.TextLayout.GPU,
  FMX.Filter, FMX.Materials, FMX.Text,
  FMX.Gestures;
...