|
@@ -6,7 +6,7 @@ interface
|
|
|
|
|
|
uses
|
|
|
Classes, SysUtils, Math, CustApp, fpCSSResolver, fpCSSTree, LazLogger,
|
|
|
- LazMethodList, Fresnel.StrConsts, Fresnel.Classes, Fresnel.Resources,
|
|
|
+ Fresnel.StrConsts, Fresnel.Classes, Fresnel.Resources,
|
|
|
Fresnel.DOM, Fresnel.Renderer, Fresnel.Layouter, Fresnel.WidgetSet,
|
|
|
Fresnel.Events, fcl.events;
|
|
|
|
|
@@ -41,10 +41,10 @@ type
|
|
|
FCaption: TFresnelCaption;
|
|
|
FFormStates: TFormStates;
|
|
|
FFormStyle: TFormStyle;
|
|
|
+ fMouseDownElement: TFresnelElement;
|
|
|
FVisible: boolean;
|
|
|
FWSForm: TFresnelWSForm;
|
|
|
function GetCaption: TFresnelCaption;
|
|
|
- function GetFormBounds: TFresnelRect;
|
|
|
function GetFormHeight: TFresnelLength;
|
|
|
function GetFormLeft: TFresnelLength;
|
|
|
function GetFormTop: TFresnelLength;
|
|
@@ -94,7 +94,7 @@ type
|
|
|
property LayoutQueued: boolean read GetLayoutQueued write SetLayoutQueued;
|
|
|
property Renderer: TFresnelRenderer read GetRenderer;
|
|
|
property FormStyle: TFormStyle read FFormStyle write SetFormStyle default fsNormal;
|
|
|
- property FormBounds: TFresnelRect read GetFormBounds write SetFormBounds;
|
|
|
+ property FormBounds: TFresnelRect read FFormBounds write SetFormBounds;
|
|
|
property FormLeft: TFresnelLength read GetFormLeft write SetFormLeft;
|
|
|
property FormTop: TFresnelLength read GetFormTop write SetFormTop;
|
|
|
property FormWidth: TFresnelLength read GetFormWidth write SetFormWidth;
|
|
@@ -157,11 +157,6 @@ begin
|
|
|
Result:=nil;
|
|
|
end;
|
|
|
|
|
|
-function TCustomFresnelForm.GetFormBounds: TFresnelRect;
|
|
|
-begin
|
|
|
- Result:=FFormBounds;
|
|
|
-end;
|
|
|
-
|
|
|
function TCustomFresnelForm.GetCaption: TFresnelCaption;
|
|
|
begin
|
|
|
if WSFormAllocated then
|
|
@@ -219,7 +214,7 @@ begin
|
|
|
if AValue.Bottom<AValue.Top then
|
|
|
AValue.Bottom:=AValue.Top;
|
|
|
if FFormBounds=AValue then exit;
|
|
|
- debugln(['TCustomFresnelForm.SetFormBoundsRect ',DbgSName(Self),' ',dbgs(AValue)]);
|
|
|
+ debugln(['TCustomFresnelForm.SetFormBounds ',DbgSName(Self),' ',dbgs(AValue)]);
|
|
|
FFormBounds:=AValue;
|
|
|
if Designer<>nil then
|
|
|
Designer.SetDesignerFormBounds(Self,FFormBounds.GetRect)
|
|
@@ -291,16 +286,20 @@ begin
|
|
|
begin
|
|
|
if FWSForm=AComponent then
|
|
|
FWSForm:=nil;
|
|
|
+ if fMouseDownElement=AComponent then
|
|
|
+ fMouseDownElement:=nil;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure TCustomFresnelForm.OnQueuedLayout(Data: Pointer);
|
|
|
begin
|
|
|
+ //debugln(['TCustomFresnelForm.OnQueuedLayout ',DbgSName(Self),' ',LayoutQueued]);
|
|
|
if not LayoutQueued then exit;
|
|
|
try
|
|
|
ApplyCSS;
|
|
|
//Layouter.WriteLayoutTree;
|
|
|
Layouter.Apply(Self);
|
|
|
+ //debugln(['TCustomFresnelForm.OnQueuedLayout ',DbgSName(Self),' After Layouter.Apply, Invalidate...']);
|
|
|
Invalidate;
|
|
|
finally
|
|
|
Exclude(FFormStates,fsLayoutQueued);
|
|
@@ -366,8 +365,10 @@ end;
|
|
|
|
|
|
procedure TCustomFresnelForm.Hide;
|
|
|
begin
|
|
|
- writeln('TCustomFresnelForm.Hide ',DbgSName(Self));
|
|
|
- if Designer<>nil then
|
|
|
+ debugln('TCustomFresnelForm.Hide ',DbgSName(Self));
|
|
|
+ if (Designer<>nil)
|
|
|
+ or ([csLoading,csDesigning]*ComponentState<>[])
|
|
|
+ or not WSFormAllocated then
|
|
|
FVisible:=false
|
|
|
else
|
|
|
WSForm.Visible:=false;
|
|
@@ -375,8 +376,8 @@ end;
|
|
|
|
|
|
procedure TCustomFresnelForm.Show;
|
|
|
begin
|
|
|
- writeln('TCustomFresnelForm.Show ',DbgSName(Self));
|
|
|
- if Designer<>nil then
|
|
|
+ debugln('TCustomFresnelForm.Show ',DbgSName(Self));
|
|
|
+ if (Designer<>nil) or ([csLoading,csDesigning,csDestroying]*ComponentState<>[]) then
|
|
|
FVisible:=true
|
|
|
else
|
|
|
WSForm.Visible:=true;
|
|
@@ -384,6 +385,8 @@ end;
|
|
|
|
|
|
procedure TCustomFresnelForm.Invalidate;
|
|
|
begin
|
|
|
+ if ([csLoading,csDestroying]*ComponentState<>[]) then
|
|
|
+ exit;
|
|
|
if Designer<>nil then
|
|
|
Designer.InvalidateRect(Self,Rect(0,0,Ceil(Width),Ceil(Height)),false)
|
|
|
else if WSFormAllocated then
|
|
@@ -392,6 +395,8 @@ end;
|
|
|
|
|
|
procedure TCustomFresnelForm.InvalidateRect(const aRect: TFresnelRect);
|
|
|
begin
|
|
|
+ if ([csLoading,csDestroying]*ComponentState<>[]) then
|
|
|
+ exit;
|
|
|
if Designer<>nil then
|
|
|
Designer.InvalidateRect(Self,aRect.GetRect,false)
|
|
|
else if WSFormAllocated then
|
|
@@ -460,22 +465,50 @@ procedure TCustomFresnelForm.WSMouseXY(WSData: TFresnelMouseEventInit;
|
|
|
MouseEventId: TEventID);
|
|
|
var
|
|
|
El: TFresnelElement;
|
|
|
- Evt: TFresnelMouseEvent;
|
|
|
+ MouseEvt: TFresnelMouseEvent;
|
|
|
+ X, Y: TFresnelLength;
|
|
|
+ ClickEvt: TFresnelMouseClickEvent;
|
|
|
begin
|
|
|
- El:=GetElementAt(WSData.PagePos.X,WSData.PagePos.Y);
|
|
|
- WSData.ControlPos:=WSData.PagePos;
|
|
|
+ X:=WSData.PagePos.X;
|
|
|
+ Y:=WSData.PagePos.Y;
|
|
|
+ El:=GetElementAt(X,Y);
|
|
|
if El=Nil then
|
|
|
begin
|
|
|
El:=Self;
|
|
|
+ WSData.ControlPos:=WSData.PagePos;
|
|
|
end else begin
|
|
|
- // todo: translate ControlPos
|
|
|
+ WSData.ControlPos:=PageToContentPos(El,X,Y);
|
|
|
+ end;
|
|
|
+ case MouseEventId of
|
|
|
+ evtMouseDown:
|
|
|
+ fMouseDownElement:=El;
|
|
|
end;
|
|
|
- Evt:=El.EventDispatcher.CreateEvent(El,MouseEventId) as TFresnelMouseEvent;
|
|
|
+
|
|
|
+ MouseEvt:=nil;
|
|
|
+ ClickEvt:=nil;
|
|
|
try
|
|
|
- Evt.InitEvent(WSData);
|
|
|
- El.EventDispatcher.DispatchEvent(Evt);
|
|
|
+ // dispatch mouse down/move/up event
|
|
|
+ MouseEvt:=El.EventDispatcher.CreateEvent(El,MouseEventId) as TFresnelMouseEvent;
|
|
|
+ MouseEvt.InitEvent(WSData);
|
|
|
+ El.EventDispatcher.DispatchEvent(MouseEvt);
|
|
|
+ FreeAndNil(MouseEvt);
|
|
|
+
|
|
|
+ case MouseEventId of
|
|
|
+ evtMouseUp:
|
|
|
+ begin
|
|
|
+ if fMouseDownElement=El then
|
|
|
+ begin
|
|
|
+ // dispatch click event
|
|
|
+ ClickEvt:=El.EventDispatcher.CreateEvent(El,evtClick) as TFresnelMouseClickEvent;
|
|
|
+ ClickEvt.InitEvent(WSData);
|
|
|
+ El.EventDispatcher.DispatchEvent(ClickEvt);
|
|
|
+ end;
|
|
|
+ fMouseDownElement:=nil;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
finally
|
|
|
- Evt.Free;
|
|
|
+ MouseEvt.Free;
|
|
|
+ ClickEvt.Free;
|
|
|
end;
|
|
|
end;
|
|
|
|