|
@@ -1239,33 +1239,6 @@ type
|
|
|
Procedure Render(aRenderer : IFresnelRenderer);
|
|
|
end;
|
|
|
|
|
|
- { TFresnelScrollBar }
|
|
|
-
|
|
|
- TFresnelScrollBar = class
|
|
|
- private
|
|
|
- FElement: TFresnelElement;
|
|
|
- FHorizontal: boolean;
|
|
|
- public type
|
|
|
- {$ScopedEnums on}
|
|
|
- THit = (hNone, hButtonLT, hButtonRB, hThumb, hTrackLT, hTrackRB);
|
|
|
- {$ScopedEnums off}
|
|
|
- public
|
|
|
- Position: TFresnelLength; // ScrollLeft/Top, When direction=rtl: Position=Size-Page+ScrollLeft
|
|
|
- // can be negative or bigger than Size
|
|
|
- Size: TFresnelLength; // ScrollWidth/Height
|
|
|
- Page: TFresnelLength; // ClientWidth/Height
|
|
|
- Color: TFPColor;
|
|
|
- Box: TFresnelRect; // relative to layoutnode parent's RenderedContentBox
|
|
|
- MouseDownHit: THit;
|
|
|
- MouseDownPos: TFresnelLength;
|
|
|
- constructor Create(TheElement: TFresnelElement; aHorizontal: boolean);
|
|
|
- destructor Destroy; override;
|
|
|
- function GetHit(const X, Y: TFresnelLength; out aPosition: TFresnelLength): THit; virtual; abstract;
|
|
|
- procedure MouseHandler(WSData: TFresnelMouseEventInit; MouseEventId: TEventID); virtual; abstract;
|
|
|
- property Element: TFresnelElement read FElement;
|
|
|
- property Horizontal: boolean read FHorizontal;
|
|
|
- end;
|
|
|
-
|
|
|
{ TFresnelFontDesc - font descriptor }
|
|
|
|
|
|
TFresnelFontDesc = record
|
|
@@ -1306,6 +1279,7 @@ type
|
|
|
end;
|
|
|
|
|
|
TPseudoElement = class;
|
|
|
+ TFresnelScrollBar = class;
|
|
|
|
|
|
{ TFresnelElement }
|
|
|
|
|
@@ -1357,10 +1331,10 @@ type
|
|
|
function GetViewportConnected: boolean;
|
|
|
function GetEventHandler(AIndex: Integer): TFresnelEventHandler;
|
|
|
function GetFocusEventHandler(AIndex: Integer): TFresnelFocusEventHandler;
|
|
|
- function GetMouseEventHandler(AIndex: Integer): TFresnelMouseEventHandler;
|
|
|
+ function GetPointerEventHandler(AIndex: Integer): TFresnelPointerEventHandler;
|
|
|
procedure SetEventHandler(AIndex: Integer; const AValue: TFresnelEventHandler);
|
|
|
procedure SetFocusEventHandler(AIndex: Integer; AValue: TFresnelFocusEventHandler);
|
|
|
- procedure SetMouseEventHandler(AIndex: Integer; const AValue: TFresnelMouseEventHandler);
|
|
|
+ procedure SetPointerEventHandler(AIndex: Integer; const AValue: TFresnelPointerEventHandler);
|
|
|
procedure SetScrollLeft(const AValue: TFresnelLength);
|
|
|
procedure SetScrollTop(const AValue: TFresnelLength);
|
|
|
protected
|
|
@@ -1553,6 +1527,8 @@ type
|
|
|
function AddEventListener(aID : TEventID; aHandler : TFresnelEventHandler) : Integer;
|
|
|
function AddEventListener(Const aName: TEventName; aHandler : TFresnelEventHandler) : Integer;
|
|
|
Function DispatchEvent(aEvent : TAbstractEvent) : Integer;
|
|
|
+ procedure SetPointerCapture(const aPointerId: TFreHandle); virtual;
|
|
|
+ procedure ReleasePointerCapture(const aPointerId: TFreHandle); virtual;
|
|
|
property EventDispatcher: TFresnelEventDispatcher Read FEventDispatcher;
|
|
|
// Font
|
|
|
property Font: IFresnelFont read GetFont write FFont;
|
|
@@ -1564,11 +1540,11 @@ type
|
|
|
property CSSClasses: TStrings read FCSSClasses write SetCSSClasses;
|
|
|
property Style: string read FStyle write SetStyle;
|
|
|
property OnClick: TFresnelEventHandler Index evtClick Read GetEventHandler Write SetEventHandler;
|
|
|
- property OnMouseDown: TFresnelMouseEventHandler Index evtMouseDown Read GetMouseEventHandler Write SetMouseEventHandler;
|
|
|
- property OnMouseMove: TFresnelMouseEventHandler Index evtMouseMove Read GetMouseEventHandler Write SetMouseEventHandler;
|
|
|
- property OnMouseEnter: TFresnelMouseEventHandler Index evtMouseEnter Read GetMouseEventHandler Write SetMouseEventHandler;
|
|
|
- property OnMouseLeave: TFresnelMouseEventHandler Index evtMouseLeave Read GetMouseEventHandler Write SetMouseEventHandler;
|
|
|
- property OnMouseUp: TFresnelMouseEventHandler Index evtMouseUp Read GetMouseEventHandler Write SetMouseEventHandler;
|
|
|
+ property OnMouseDown: TFresnelPointerEventHandler Index evtMouseDown Read GetPointerEventHandler Write SetPointerEventHandler;
|
|
|
+ property OnMouseMove: TFresnelPointerEventHandler Index evtMouseMove Read GetPointerEventHandler Write SetPointerEventHandler;
|
|
|
+ property OnMouseEnter: TFresnelPointerEventHandler Index evtMouseEnter Read GetPointerEventHandler Write SetPointerEventHandler;
|
|
|
+ property OnMouseLeave: TFresnelPointerEventHandler Index evtMouseLeave Read GetPointerEventHandler Write SetPointerEventHandler;
|
|
|
+ property OnMouseUp: TFresnelPointerEventHandler Index evtMouseUp Read GetPointerEventHandler Write SetPointerEventHandler;
|
|
|
property OnFocus: TFresnelFocusEventHandler Index evtFocus Read GetFocusEventHandler Write SetFocusEventHandler;
|
|
|
property OnEnter: TFresnelFocusEventHandler Index evtFocusIn Read GetFocusEventHandler Write SetFocusEventHandler;
|
|
|
property OnLeave: TFresnelFocusEventHandler Index evtFocusOut Read GetFocusEventHandler Write SetFocusEventHandler;
|
|
@@ -1609,6 +1585,33 @@ type
|
|
|
function GetCSSPseudoElementName: TCSSString; override;
|
|
|
end;
|
|
|
|
|
|
+ { TFresnelScrollBar }
|
|
|
+
|
|
|
+ TFresnelScrollBar = class(TPseudoElement)
|
|
|
+ private
|
|
|
+ FHorizontal: boolean;
|
|
|
+ protected
|
|
|
+ procedure SetParent(const AValue: TFresnelElement); override;
|
|
|
+ public type
|
|
|
+ {$ScopedEnums on}
|
|
|
+ THit = (hNone, hButtonLT, hButtonRB, hThumb, hTrackLT, hTrackRB);
|
|
|
+ {$ScopedEnums off}
|
|
|
+ public
|
|
|
+ Position: TFresnelLength; // ScrollLeft/Top, When direction=rtl: Position=Size-Page+ScrollLeft
|
|
|
+ // can be negative or bigger than Size
|
|
|
+ Size: TFresnelLength; // ScrollWidth/Height
|
|
|
+ Page: TFresnelLength; // ClientWidth/Height
|
|
|
+ Color: TFPColor;
|
|
|
+ Box: TFresnelRect; // relative to layoutnode parent's RenderedContentBox
|
|
|
+ MouseDownHit: THit;
|
|
|
+ MouseDownPos: TFresnelLength;
|
|
|
+ constructor Create(TheElement: TFresnelElement; aHorizontal: boolean);
|
|
|
+ function GetHit(const X, Y: TFresnelLength; out aPosition: TFresnelLength): THit; virtual; abstract;
|
|
|
+ procedure MouseHandler(WSData: TFresnelMouseEventInit; MouseEventId: TEventID); virtual; abstract;
|
|
|
+ property Horizontal: boolean read FHorizontal;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
{ TReplacedElement - base class for elements with special content and no child elements, e.g. label, video }
|
|
|
|
|
|
TReplacedElement = class(TFresnelElement)
|
|
@@ -1643,6 +1646,11 @@ type
|
|
|
procedure SetMouseDownElement(El: TFresnelElement; const PageXY: TFresnelPoint);
|
|
|
end;
|
|
|
|
|
|
+ TFresnelVPPointerCapture = record
|
|
|
+ Id: TFreHandle;
|
|
|
+ Element: TFresnelElement;
|
|
|
+ end;
|
|
|
+
|
|
|
{ TFresnelViewport }
|
|
|
|
|
|
TFresnelViewport = class(TFresnelElement)
|
|
@@ -1661,6 +1669,7 @@ type
|
|
|
FStylesheetResolverStamp: TCSSNumericalID;
|
|
|
FStylesheetStamp: TCSSNumericalID;
|
|
|
FWidth: TFresnelLength;
|
|
|
+ FPointerCaptures: array of TFresnelVPPointerCapture;
|
|
|
procedure CSSResolverLog(Sender: TObject; Entry: TCSSResolverLogEntry);
|
|
|
function GetFocusedElement: TFresnelElement;
|
|
|
procedure SetFocusedElement(const aValue: TFresnelElement);
|
|
@@ -1774,6 +1783,8 @@ type
|
|
|
function ContentToPagePos(El: TFresnelElement; const p: TFresnelPoint): TFresnelPoint; overload; // content box of El to content of viewport
|
|
|
function PageToContentPos(El: TFresnelElement; const x, y: TFresnelLength): TFresnelPoint; virtual; overload; // content of viewport to content box of El
|
|
|
function PageToContentPos(El: TFresnelElement; const p: TFresnelPoint): TFresnelPoint; virtual; overload; // content of viewport to content box of El
|
|
|
+ procedure SetPointerCapture(El: TFresnelElement; const aPointerId: TFreHandle); virtual; overload;
|
|
|
+ procedure ReleasePointerCapture(El: TFresnelElement; const aPointerId: TFreHandle); virtual; overload;
|
|
|
procedure WSMouseXY(WSData: TFresnelMouseEventInit; MouseEventId: TEventID); virtual;
|
|
|
// Return true if default was prevented
|
|
|
function WSKey(WSData: TFresnelKeyEventInit; KeyEventId: TEventID) : boolean; virtual;
|
|
@@ -6586,26 +6597,27 @@ end;
|
|
|
|
|
|
{ TFresnelScrollBar }
|
|
|
|
|
|
-constructor TFresnelScrollBar.Create(TheElement: TFresnelElement; aHorizontal: boolean);
|
|
|
+procedure TFresnelScrollBar.SetParent(const AValue: TFresnelElement);
|
|
|
begin
|
|
|
- FElement:=TheElement;
|
|
|
- FHorizontal:=aHorizontal;
|
|
|
- if Horizontal then
|
|
|
- FElement.FScrollBarHorizontal:=Self
|
|
|
- else
|
|
|
- FElement.FScrollBarVertical:=Self;
|
|
|
-end;
|
|
|
-
|
|
|
-destructor TFresnelScrollBar.Destroy;
|
|
|
-begin
|
|
|
- if FElement<>nil then
|
|
|
+ if Parent<>nil then
|
|
|
begin
|
|
|
if FHorizontal then
|
|
|
- FElement.FScrollBarHorizontal:=nil
|
|
|
+ Parent.FScrollBarHorizontal:=nil
|
|
|
else
|
|
|
- FElement.FScrollBarVertical:=nil;
|
|
|
+ Parent.FScrollBarVertical:=nil;
|
|
|
end;
|
|
|
- inherited Destroy;
|
|
|
+ inherited SetParent(AValue);
|
|
|
+end;
|
|
|
+
|
|
|
+constructor TFresnelScrollBar.Create(TheElement: TFresnelElement; aHorizontal: boolean);
|
|
|
+begin
|
|
|
+ inherited Create(TheElement);
|
|
|
+ FHorizontal:=aHorizontal;
|
|
|
+ Parent:=TheElement;
|
|
|
+ if Horizontal then
|
|
|
+ Parent.FScrollBarHorizontal:=Self
|
|
|
+ else
|
|
|
+ Parent.FScrollBarVertical:=Self;
|
|
|
end;
|
|
|
|
|
|
{ TFresnelFontDesc }
|
|
@@ -7191,6 +7203,47 @@ begin
|
|
|
Result:=PageToContentPos(El,p.X,p.Y);
|
|
|
end;
|
|
|
|
|
|
+procedure TFresnelViewport.SetPointerCapture(El: TFresnelElement; const aPointerId: TFreHandle);
|
|
|
+var
|
|
|
+ i: Integer;
|
|
|
+ Item: TFresnelVPPointerCapture;
|
|
|
+begin
|
|
|
+ if El=nil then
|
|
|
+ raise Exception.Create('20250324190651');
|
|
|
+ if (El=Self) or (El.Viewport=Self) then
|
|
|
+ else
|
|
|
+ raise Exception.Create('20250324191044');
|
|
|
+ if aPointerId=nil then
|
|
|
+ raise Exception.Create('20250324190659');
|
|
|
+ for i:=0 to length(FPointerCaptures)-1 do
|
|
|
+ if FPointerCaptures[i].Id=aPointerId then
|
|
|
+ begin
|
|
|
+ // already capturing
|
|
|
+ if FPointerCaptures[i].Element=El then exit;
|
|
|
+ FPointerCaptures[i].Element:=El;
|
|
|
+ // todo: tell element is has lost the capture
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ SetPointerCapture(aPointerId);
|
|
|
+ Item.Id:=aPointerId;
|
|
|
+ Item.Element:=El;
|
|
|
+ Insert(Item,FPointerCaptures,length(FPointerCaptures));
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TFresnelViewport.ReleasePointerCapture(El: TFresnelElement; const aPointerId: TFreHandle);
|
|
|
+var
|
|
|
+ i: Integer;
|
|
|
+begin
|
|
|
+ for i:=0 to length(FPointerCaptures)-1 do
|
|
|
+ if FPointerCaptures[i].Id=aPointerId then
|
|
|
+ begin
|
|
|
+ if FPointerCaptures[i].Element<>El then exit;
|
|
|
+ System.Delete(FPointerCaptures,i,1);
|
|
|
+ ReleasePointerCapture(aPointerId);
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TFresnelViewport.WSMouseXY(WSData: TFresnelMouseEventInit; MouseEventId: TEventID);
|
|
|
var
|
|
|
El, BubbleEl, OldMouseDownEl: TFresnelElement;
|
|
@@ -7573,12 +7626,11 @@ begin
|
|
|
Result:=TFresnelFocusEventHandler(GetEventHandler(AIndex));
|
|
|
end;
|
|
|
|
|
|
-function TFresnelElement.GetMouseEventHandler(AIndex: Integer
|
|
|
- ): TFresnelMouseEventHandler;
|
|
|
+function TFresnelElement.GetPointerEventHandler(AIndex: Integer): TFresnelPointerEventHandler;
|
|
|
begin
|
|
|
Result:=nil;
|
|
|
if AIndex in evtAllMouse then
|
|
|
- Result:=TFresnelMouseEventHandler(GetEventHandler(AIndex));
|
|
|
+ Result:=TFresnelPointerEventHandler(GetEventHandler(AIndex));
|
|
|
end;
|
|
|
|
|
|
procedure TFresnelElement.SetEventHandler(AIndex: Integer;
|
|
@@ -7596,8 +7648,8 @@ begin
|
|
|
SetEventHandler(AIndex,TFresnelEventHandler(AValue));
|
|
|
end;
|
|
|
|
|
|
-procedure TFresnelElement.SetMouseEventHandler(AIndex: Integer;
|
|
|
- const AValue: TFresnelMouseEventHandler);
|
|
|
+procedure TFresnelElement.SetPointerEventHandler(AIndex: Integer;
|
|
|
+ const AValue: TFresnelPointerEventHandler);
|
|
|
begin
|
|
|
if AIndex in evtAllMouse then
|
|
|
SetEventHandler(AIndex,TFresnelEventHandler(AValue));
|
|
@@ -8930,6 +8982,16 @@ begin
|
|
|
Result:=DoDispatchEvent(aEvent);
|
|
|
end;
|
|
|
|
|
|
+procedure TFresnelElement.SetPointerCapture(const aPointerId: TFreHandle);
|
|
|
+begin
|
|
|
+ Viewport.SetPointerCapture(Self,aPointerId);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TFresnelElement.ReleasePointerCapture(const aPointerId: TFreHandle);
|
|
|
+begin
|
|
|
+ Viewport.ReleasePointerCapture(Self,aPointerId);
|
|
|
+end;
|
|
|
+
|
|
|
function TFresnelElement.GetFont: IFresnelFont;
|
|
|
|
|
|
function GetViewportFontSize: TFresnelLength;
|