|
@@ -89,7 +89,7 @@ type
|
|
// Draw the border of the element. This is called after drawing the background. Not called if PrepareBackgroundBorder returned False.
|
|
// Draw the border of the element. This is called after drawing the background. Not called if PrepareBackgroundBorder returned False.
|
|
procedure DrawElBorder(El: TFresnelElement; Params: TBorderAndBackground); virtual;
|
|
procedure DrawElBorder(El: TFresnelElement; Params: TBorderAndBackground); virtual;
|
|
function CreateScrollBar : TScrollBar; virtual;
|
|
function CreateScrollBar : TScrollBar; virtual;
|
|
- // Draw the scrollbars of the element. Called after drawing borders.
|
|
|
|
|
|
+ // Draw the scrollbars of the element. Called after drawing content.
|
|
procedure DrawScrollBar(El: TFresnelElement; aBar: TScrollBar); virtual;
|
|
procedure DrawScrollBar(El: TFresnelElement; aBar: TScrollBar); virtual;
|
|
procedure DrawScrollBarCorner(El: TFresnelElement; const r: TFresnelRect); virtual;
|
|
procedure DrawScrollBarCorner(El: TFresnelElement; const r: TFresnelRect); virtual;
|
|
procedure DrawScrollBars(El: TFresnelElement); virtual;
|
|
procedure DrawScrollBars(El: TFresnelElement); virtual;
|
|
@@ -121,24 +121,29 @@ type
|
|
{ IFresnelRenderer }
|
|
{ IFresnelRenderer }
|
|
// Add 1 Shadow text to
|
|
// Add 1 Shadow text to
|
|
procedure AddTextShadow(const aX, aY: TFresnelLength; const aColor: TFPColor; const aRadius: TFresnelLength);
|
|
procedure AddTextShadow(const aX, aY: TFresnelLength; const aColor: TFPColor; const aRadius: TFresnelLength);
|
|
|
|
+ // Draw an elliptic arc with with given center and radii, from start to stop angle in rad (0=right), using specified color.
|
|
|
|
+ procedure Arc(const aColor : TFPColor; const aCenter, aRadii : TFresnelPoint; aStartAngle : TFresnelLength = 0; aStopAngle : TFresnelLength = DoublePi); virtual; abstract;
|
|
// Clear all text shadows
|
|
// Clear all text shadows
|
|
procedure ClearTextShadows;
|
|
procedure ClearTextShadows;
|
|
|
|
+ procedure ClipRect(const aRect: TFresnelRect); virtual; abstract;
|
|
|
|
+ // Draw an image
|
|
|
|
+ procedure DrawImage(const aLeft, aTop, aWidth, aHeight: TFresnelLength; const aImage: TFPCustomImage); virtual; abstract;
|
|
// Get reference to TFresnelTextShadow. Index between 0 and GetTextShadowCount-1
|
|
// Get reference to TFresnelTextShadow. Index between 0 and GetTextShadowCount-1
|
|
function GetTextShadow(aIndex : Integer): PFresnelTextShadow;
|
|
function GetTextShadow(aIndex : Integer): PFresnelTextShadow;
|
|
// Number of TextShadows that will be applied
|
|
// Number of TextShadows that will be applied
|
|
function GetTextShadowCount: Integer;
|
|
function GetTextShadowCount: Integer;
|
|
// Draw and fill a rectangle with given boundaries and color.
|
|
// Draw and fill a rectangle with given boundaries and color.
|
|
procedure FillRect(const aColor: TFPColor; const aRect: TFresnelRect); virtual; abstract;
|
|
procedure FillRect(const aColor: TFPColor; const aRect: TFresnelRect); virtual; abstract;
|
|
- // Draw an elliptic arc with with given center and radii, from start to stop angle in rad (0=right), using specified color.
|
|
|
|
- procedure Arc(const aColor : TFPColor; const aCenter, aRadii : TFresnelPoint; aStartAngle : TFresnelLength = 0; aStopAngle : TFresnelLength = DoublePi); virtual; abstract;
|
|
|
|
- // Draw (and optionally fill) a rounded rectangle with given boundaries and color.
|
|
|
|
- procedure RoundRect(const aColor: TFPColor; const aRect: TFresnelRoundRect; Fill : Boolean); virtual; abstract;
|
|
|
|
// Draw a line from point A (x1,y1) to B (x2,y2) using given color.
|
|
// Draw a line from point A (x1,y1) to B (x2,y2) using given color.
|
|
procedure Line(const aColor: TFPColor; const x1, y1, x2, y2: TFresnelLength); virtual; abstract;
|
|
procedure Line(const aColor: TFPColor; const x1, y1, x2, y2: TFresnelLength); virtual; abstract;
|
|
|
|
+ // Restores a saved state of clipping and matrix.
|
|
|
|
+ procedure Restore; virtual; abstract;
|
|
|
|
+ // Draw (and optionally fill) a rounded rectangle with given boundaries and color.
|
|
|
|
+ procedure RoundRect(const aColor: TFPColor; const aRect: TFresnelRoundRect; Fill : Boolean); virtual; abstract;
|
|
|
|
+ // Save clipping and matrix, must be balanced with Restore
|
|
|
|
+ procedure Save; virtual; abstract;
|
|
// Draw a text (aText) at aTop,aLeft using given color and font.
|
|
// Draw a text (aText) at aTop,aLeft using given color and font.
|
|
procedure TextOut(const aLeft, aTop: TFresnelLength; const aFont: IFresnelFont; const aColor: TFPColor; const aText: string); virtual; abstract;
|
|
procedure TextOut(const aLeft, aTop: TFresnelLength; const aFont: IFresnelFont; const aColor: TFPColor; const aText: string); virtual; abstract;
|
|
- // Draw an image
|
|
|
|
- procedure DrawImage(const aLeft, aTop, aWidth, aHeight: TFresnelLength; const aImage: TFPCustomImage); virtual; abstract;
|
|
|
|
// Origin of the currently drawn
|
|
// Origin of the currently drawn
|
|
property Origin: TFresnelPoint read GetOrigin write SetOrigin;
|
|
property Origin: TFresnelPoint read GetOrigin write SetOrigin;
|
|
// Number of TextShadows that will be applied
|
|
// Number of TextShadows that will be applied
|
|
@@ -593,8 +598,8 @@ var
|
|
IsLeft, HasVertBar, HasHorzBar: Boolean;
|
|
IsLeft, HasVertBar, HasHorzBar: Boolean;
|
|
begin
|
|
begin
|
|
LNode:=TUsedLayoutNode(El.LayoutNode);
|
|
LNode:=TUsedLayoutNode(El.LayoutNode);
|
|
- HasVertBar:=flfVerticalScrollbar in LNode.Flags;
|
|
|
|
- HasHorzBar:=flfHorizontalScrollbar in LNode.Flags;
|
|
|
|
|
|
+ HasVertBar:=flfScrollbarVertical in LNode.Flags;
|
|
|
|
+ HasHorzBar:=flfScrollbarHorizontal in LNode.Flags;
|
|
if (not HasVertBar) and (not HasHorzBar) then exit;
|
|
if (not HasVertBar) and (not HasHorzBar) then exit;
|
|
|
|
|
|
if HasVertBar then
|
|
if HasVertBar then
|
|
@@ -612,6 +617,7 @@ begin
|
|
else BarHeight:=El.Viewport.ScrollbarsWidth[true];
|
|
else BarHeight:=El.Viewport.ScrollbarsWidth[true];
|
|
end;
|
|
end;
|
|
aPaddingBox:=El.GetRenderedPaddingBox;
|
|
aPaddingBox:=El.GetRenderedPaddingBox;
|
|
|
|
+ //writeln('TFresnelRenderer.DrawScrollBars ',El.Name,' PaddingBox=',aPaddingBox.ToString);
|
|
|
|
|
|
if HasVertBar then
|
|
if HasVertBar then
|
|
begin
|
|
begin
|
|
@@ -635,7 +641,7 @@ begin
|
|
aScrollbar.Color:=El.GetComputedColor(fcaScrollbarColor,colGray);
|
|
aScrollbar.Color:=El.GetComputedColor(fcaScrollbarColor,colGray);
|
|
|
|
|
|
{$IFDEF VerboseFresnelScrolling}
|
|
{$IFDEF VerboseFresnelScrolling}
|
|
- writeln('TFresnelRenderer.DrawScrollBars ',El.Name,' ScrollHeight=',FloatToCSSStr(El.ScrollHeight),' ClientHeight',FloatToCSSStr(El.ClientHeight),' ScrollTop=',FloatToCSSStr(El.ScrollTop)+' BarWidth='+FloatToCSSStr(BarWidth));
|
|
|
|
|
|
+ writeln('TFresnelRenderer.DrawScrollBars ',El.Name,' ScrollHeight=',FloatToCSSStr(El.ScrollHeight),' ClientHeight',FloatToCSSStr(El.ClientHeight),' ScrollTop=',FloatToCSSStr(El.ScrollTop)+' BarWidth='+FloatToCSSStr(BarWidth)+' r='+r.ToString);
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
DrawScrollBar(El,aScrollbar);
|
|
DrawScrollBar(El,aScrollbar);
|
|
finally
|
|
finally
|
|
@@ -696,11 +702,13 @@ end;
|
|
procedure TFresnelRenderer.DrawElement(El: TFresnelElement);
|
|
procedure TFresnelRenderer.DrawElement(El: TFresnelElement);
|
|
var
|
|
var
|
|
LNode: TUsedLayoutNode;
|
|
LNode: TUsedLayoutNode;
|
|
- aBorderBox, aContentBox: TFresnelRect;
|
|
|
|
|
|
+ aBorderBox, aContentBox, r: TFresnelRect;
|
|
BorderParams: TBorderAndBackground;
|
|
BorderParams: TBorderAndBackground;
|
|
aRenderable : IFresnelRenderable;
|
|
aRenderable : IFresnelRenderable;
|
|
s: TFresnelCSSSide;
|
|
s: TFresnelCSSSide;
|
|
Corner: TFresnelCSSCorner;
|
|
Corner: TFresnelCSSCorner;
|
|
|
|
+ aClientWidth, aClientHeight: TFresnelLength;
|
|
|
|
+ NeedClipHorizontal, NeedClipVertical, NeedRestore: Boolean;
|
|
begin
|
|
begin
|
|
FLLog(etDebug,'TFresnelRenderer.DrawElement %s Origin=%s',[El.GetPath,Origin.ToString]);
|
|
FLLog(etDebug,'TFresnelRenderer.DrawElement %s Origin=%s',[El.GetPath,Origin.ToString]);
|
|
LNode:=TUsedLayoutNode(El.LayoutNode);
|
|
LNode:=TUsedLayoutNode(El.LayoutNode);
|
|
@@ -757,14 +765,39 @@ begin
|
|
BorderParams.Free;
|
|
BorderParams.Free;
|
|
end;
|
|
end;
|
|
|
|
|
|
- // draw scrollbars
|
|
|
|
- DrawScrollBars(El);
|
|
|
|
|
|
+ NeedRestore:=false;
|
|
|
|
+ NeedClipHorizontal:=flfClipHorizontal in LNode.Flags;
|
|
|
|
+ NeedClipVertical:=flfClipVertical in LNode.Flags;
|
|
|
|
+ if NeedClipHorizontal or NeedClipVertical then
|
|
|
|
+ begin
|
|
|
|
+ //writeln('TFresnelRenderer.DrawElement ',El.Name,' ',NeedClipHorizontal,' ',NeedClipVertical);
|
|
|
|
+ r:=El.GetRenderedPaddingBox;
|
|
|
|
+ if not NeedClipHorizontal then
|
|
|
|
+ begin
|
|
|
|
+ r.Left:=-Origin.X;
|
|
|
|
+ r.Right:=El.Viewport.Width-Origin.X;
|
|
|
|
+ end else if not NeedClipVertical then
|
|
|
|
+ begin
|
|
|
|
+ r.Top:=-Origin.Y;
|
|
|
|
+ r.Bottom:=El.Viewport.Height-Origin.Y;
|
|
|
|
+ end;
|
|
|
|
|
|
- // Give element a chance to draw itself (on top of background and border)
|
|
|
|
- aRenderable.Render(Self as IFresnelRenderer);
|
|
|
|
|
|
+ Save;
|
|
|
|
+ NeedRestore:=true;
|
|
|
|
+ ClipRect(r);
|
|
|
|
+ end;
|
|
|
|
+ try
|
|
|
|
+ // Give element a chance to draw itself (on top of background and border)
|
|
|
|
+ aRenderable.Render(Self as IFresnelRenderer);
|
|
|
|
|
|
- DrawChildren(El);
|
|
|
|
|
|
+ DrawChildren(El);
|
|
|
|
|
|
|
|
+ // draw scrollbars
|
|
|
|
+ DrawScrollBars(El);
|
|
|
|
+ finally
|
|
|
|
+ if NeedRestore then
|
|
|
|
+ Restore;
|
|
|
|
+ end;
|
|
aRenderable.AfterRender;
|
|
aRenderable.AfterRender;
|
|
end;
|
|
end;
|
|
|
|
|