|
@@ -10,6 +10,15 @@ uses
|
|
|
|
|
|
type
|
|
type
|
|
|
|
|
|
|
|
+ { TFresnelLCLCtlViewport }
|
|
|
|
+
|
|
|
|
+ TFresnelLCLCtlViewport = class(TFresnelViewport)
|
|
|
|
+ protected
|
|
|
|
+ FIsDrawing: boolean;
|
|
|
|
+ public
|
|
|
|
+ function IsDrawing: boolean; override;
|
|
|
|
+ end;
|
|
|
|
+
|
|
{ TFresnelLCLControl }
|
|
{ TFresnelLCLControl }
|
|
|
|
|
|
TFresnelLCLControl = class(TCustomControl)
|
|
TFresnelLCLControl = class(TCustomControl)
|
|
@@ -19,7 +28,7 @@ type
|
|
FLayouter: TViewportLayouter;
|
|
FLayouter: TViewportLayouter;
|
|
FLayoutQueued: boolean;
|
|
FLayoutQueued: boolean;
|
|
FRenderer: TFresnelLCLRenderer;
|
|
FRenderer: TFresnelLCLRenderer;
|
|
- FViewport: TFresnelViewport;
|
|
|
|
|
|
+ FViewport: TFresnelLCLCtlViewport;
|
|
FLCLEvents: TFresnelLCLEventControl;
|
|
FLCLEvents: TFresnelLCLEventControl;
|
|
procedure OnDomChanged(Sender: TObject);
|
|
procedure OnDomChanged(Sender: TObject);
|
|
procedure OnQueuedLayout({%H-}Data: PtrInt);
|
|
procedure OnQueuedLayout({%H-}Data: PtrInt);
|
|
@@ -31,7 +40,7 @@ type
|
|
public
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
- property Viewport: TFresnelViewport read FViewport;
|
|
|
|
|
|
+ property Viewport: TFresnelLCLCtlViewport read FViewport;
|
|
property Layouter: TViewportLayouter read FLayouter;
|
|
property Layouter: TViewportLayouter read FLayouter;
|
|
property FontEngine: TFresnelLCLFontEngine read FFontEngine;
|
|
property FontEngine: TFresnelLCLFontEngine read FFontEngine;
|
|
property Renderer: TFresnelLCLRenderer read FRenderer;
|
|
property Renderer: TFresnelLCLRenderer read FRenderer;
|
|
@@ -42,6 +51,13 @@ implementation
|
|
|
|
|
|
uses Dialogs;
|
|
uses Dialogs;
|
|
|
|
|
|
|
|
+{ TFresnelLCLCtlViewport }
|
|
|
|
+
|
|
|
|
+function TFresnelLCLCtlViewport.IsDrawing: boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=FIsDrawing;
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TFresnelLCLControl }
|
|
{ TFresnelLCLControl }
|
|
|
|
|
|
procedure TFresnelLCLControl.SetLayoutQueued(const AValue: boolean);
|
|
procedure TFresnelLCLControl.SetLayoutQueued(const AValue: boolean);
|
|
@@ -84,15 +100,26 @@ end;
|
|
|
|
|
|
procedure TFresnelLCLControl.Paint;
|
|
procedure TFresnelLCLControl.Paint;
|
|
begin
|
|
begin
|
|
- inherited Paint;
|
|
|
|
|
|
+ if Viewport.FIsDrawing then
|
|
|
|
+ raise Exception.Create('20250303212620 already drawing');
|
|
|
|
+ Viewport.FIsDrawing:=true;
|
|
|
|
+ try
|
|
|
|
+ inherited Paint;
|
|
|
|
|
|
- Renderer.Draw(Viewport);
|
|
|
|
|
|
+ if Viewport.DomModified then
|
|
|
|
+ begin
|
|
|
|
+ Viewport.ApplyCSS;
|
|
|
|
+ end;
|
|
|
|
+ Renderer.Draw(Viewport);
|
|
|
|
+ finally
|
|
|
|
+ Viewport.FIsDrawing:=false;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor TFresnelLCLControl.Create(AOwner: TComponent);
|
|
constructor TFresnelLCLControl.Create(AOwner: TComponent);
|
|
begin
|
|
begin
|
|
inherited Create(AOwner);
|
|
inherited Create(AOwner);
|
|
- FViewport:=TFresnelViewport.Create(nil);
|
|
|
|
|
|
+ FViewport:=TFresnelLCLCtlViewport.Create(nil);
|
|
FViewport.OnDomChanged:=@OnDomChanged;
|
|
FViewport.OnDomChanged:=@OnDomChanged;
|
|
FFontEngine:=TFresnelLCLFontEngine.Create(nil);
|
|
FFontEngine:=TFresnelLCLFontEngine.Create(nil);
|
|
FViewport.FontEngine:=FontEngine;
|
|
FViewport.FontEngine:=FontEngine;
|
|
@@ -117,124 +144,5 @@ begin
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
-{ TOldFresnelCustomForm }
|
|
|
|
-(*
|
|
|
|
-function TOldFresnelCustomForm.GetStylesheet: TStrings;
|
|
|
|
-begin
|
|
|
|
- Result:=Viewport.Stylesheet;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-procedure TOldFresnelCustomForm.OnDomChanged(Sender: TObject);
|
|
|
|
-begin
|
|
|
|
- LayoutQueued:=true;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-procedure TOldFresnelCustomForm.OnQueuedLayout(Data: PtrInt);
|
|
|
|
-begin
|
|
|
|
- ViewPort.ApplyCSS;
|
|
|
|
- //Layouter.WriteLayoutTree;
|
|
|
|
- Layouter.Apply(ViewPort);
|
|
|
|
- Invalidate;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-procedure TOldFresnelCustomForm.SetLayoutQueued(const AValue: boolean);
|
|
|
|
-begin
|
|
|
|
- if FLayoutQueued=AValue then Exit;
|
|
|
|
- if FClearing then exit;
|
|
|
|
- if csDestroyingHandle in ControlState then exit;
|
|
|
|
- if csDestroying in ComponentState then exit;
|
|
|
|
- FLayoutQueued:=AValue;
|
|
|
|
- if FLayoutQueued then
|
|
|
|
- Application.QueueAsyncCall(@OnQueuedLayout,0);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-procedure TOldFresnelCustomForm.SetStylesheet(const AValue: TStrings);
|
|
|
|
-begin
|
|
|
|
- Viewport.Stylesheet:=AValue;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-procedure TOldFresnelCustomForm.Notification(AComponent: TComponent;
|
|
|
|
- Operation: TOperation);
|
|
|
|
-begin
|
|
|
|
- inherited Notification(AComponent, Operation);
|
|
|
|
- if Operation=opRemove then
|
|
|
|
- begin
|
|
|
|
- if AComponent=FViewport then
|
|
|
|
- FViewport:=nil;
|
|
|
|
- if AComponent=FFontEngine then
|
|
|
|
- FFontEngine:=nil;
|
|
|
|
- if AComponent=FLayouter then
|
|
|
|
- begin
|
|
|
|
- FLayouter:=nil;
|
|
|
|
- if FViewport<>nil then
|
|
|
|
- FViewport.Layouter:=nil;
|
|
|
|
- end;
|
|
|
|
- if AComponent=FRenderer then
|
|
|
|
- FRenderer:=nil;
|
|
|
|
- end;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-procedure TOldFresnelCustomForm.Paint;
|
|
|
|
-begin
|
|
|
|
- inherited Paint;
|
|
|
|
- Renderer.Draw(Viewport);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TOldFresnelCustomForm.GetViewport: TFresnelViewport;
|
|
|
|
-begin
|
|
|
|
- Result:=FViewport;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-constructor TOldFresnelCustomForm.Create(AOwner: TComponent);
|
|
|
|
-begin
|
|
|
|
- inherited Create(AOwner);
|
|
|
|
- FViewport:=TFresnelViewport.Create(nil);
|
|
|
|
- FViewport.Name:='Viewport';
|
|
|
|
- FViewport.OnDomChanged:=@OnDomChanged;
|
|
|
|
- FFontEngine:=TFresnelLCLFontEngine.Create(nil);
|
|
|
|
- FViewport.FontEngine:=FontEngine;
|
|
|
|
- FontEngine.Canvas:=Canvas;
|
|
|
|
- FLayouter:=TSimpleFresnelLayouter.Create(nil);
|
|
|
|
- Layouter.Viewport:=ViewPort;
|
|
|
|
- FRenderer:=TFresnelLCLRenderer.Create(nil);
|
|
|
|
- FRenderer.Canvas:=Canvas;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-destructor TOldFresnelCustomForm.Destroy;
|
|
|
|
-begin
|
|
|
|
- FClearing:=true;
|
|
|
|
- FreeAndNil(FRenderer);
|
|
|
|
- FreeAndNil(FLayouter);
|
|
|
|
- FreeAndNil(FViewport);
|
|
|
|
- FreeAndNil(FFontEngine);
|
|
|
|
- Application.RemoveAllHandlersOfObject(Self);
|
|
|
|
- inherited Destroy;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-procedure TOldFresnelCustomForm.GetChildren(Proc: TGetChildProc; Root: TComponent);
|
|
|
|
-var
|
|
|
|
- i: Integer;
|
|
|
|
- OwnedComponent: TComponent;
|
|
|
|
- ChildEl: TFresnelElement;
|
|
|
|
-begin
|
|
|
|
- if Root=Self then
|
|
|
|
- begin
|
|
|
|
- // first all children of Viewport
|
|
|
|
- for i:=0 to Viewport.NodeCount-1 do
|
|
|
|
- begin
|
|
|
|
- ChildEl:=Viewport.Nodes[i];
|
|
|
|
- if ChildEl.Owner=Root then
|
|
|
|
- Proc(ChildEl);
|
|
|
|
- end;
|
|
|
|
- // then all non visual components
|
|
|
|
- for i := 0 to ComponentCount - 1 do
|
|
|
|
- begin
|
|
|
|
- OwnedComponent := Components[i];
|
|
|
|
- if not OwnedComponent.HasParent then
|
|
|
|
- Proc(OwnedComponent);
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
-end;
|
|
|
|
- *)
|
|
|
|
end.
|
|
end.
|
|
|
|
|