|
@@ -1470,6 +1470,8 @@ type
|
|
|
function GetComputedBorderWidth(Attr: TFresnelCSSAttribute): TFresnelLength; virtual;
|
|
|
function GetComputedBorderRadius(Corner: TFresnelCSSCorner): TFresnelPoint; virtual; // on fail returns 0
|
|
|
function GetComputedColor(Attr: TFresnelCSSAttribute; const CurrentColor: TFPColor): TFPColor; virtual; // on fail returns transparent
|
|
|
+ function GetComputedColorValue(const s: string; const CurComp: TCSSResCompValue; out Col: TFPColor): boolean; virtual;
|
|
|
+ function GetComputedScrollbarColor(out aThumbColor, aTrackColor: TFPColor): boolean; virtual;
|
|
|
function GetComputedKeyword(Attr: TFresnelCSSAttribute; const AllowedKeywords: TCSSNumericalIDArray): TCSSNumericalID; virtual;
|
|
|
function GetComputedJustifyContent(out SubKW: TCSSNumericalID): TCSSNumericalID; virtual;
|
|
|
function GetComputedJustifyItems(out SubKW: TCSSNumericalID): TCSSNumericalID; virtual;
|
|
@@ -1604,12 +1606,14 @@ type
|
|
|
// can be negative or bigger than Size
|
|
|
Size: TFresnelLength; // ScrollWidth/Height
|
|
|
Page: TFresnelLength; // ClientWidth/Height
|
|
|
- Color: TFPColor;
|
|
|
+ HasColor: boolean;
|
|
|
+ ThumbColor, TrackColor: TFPColor;
|
|
|
Box: TFresnelRect; // same coord system as parent, e.g. parent.UsedBorderBox
|
|
|
MouseDownHit: THit;
|
|
|
MouseDownPosition, MouseDownGrabPos: TFresnelLength;
|
|
|
constructor Create(TheElement: TFresnelElement; aHorizontal: boolean); overload;
|
|
|
function GetHit(const X, Y: TFresnelLength; out aPosition: TFresnelLength): THit; virtual; abstract;
|
|
|
+ procedure GetColors(out CurThumbColor, CurTrackColor: TFPColor);
|
|
|
property Horizontal: boolean read FHorizontal;
|
|
|
end;
|
|
|
|
|
@@ -1652,6 +1656,14 @@ type
|
|
|
);
|
|
|
TFresnelViewportLengths = set of TFresnelViewportLength;
|
|
|
|
|
|
+ TFresnelScrollbarColor = (
|
|
|
+ vscThumbNormal,
|
|
|
+ vscThumbHover,
|
|
|
+ vscTrackNormal,
|
|
|
+ vscTrackHover
|
|
|
+ );
|
|
|
+ TFresnelScrollbarColors = set of TFresnelScrollbarColor;
|
|
|
+
|
|
|
{ TFresnelViewport }
|
|
|
|
|
|
TFresnelViewport = class(TFresnelElement)
|
|
@@ -1665,16 +1677,20 @@ type
|
|
|
FOnDomChanged: TNotifyEvent;
|
|
|
FScrollbarsAutoHide: boolean;
|
|
|
FScrollbarsOverlay: boolean;
|
|
|
- FScrollbarThinWidth: array[boolean] of TFresnelLength;
|
|
|
- FScrollbarWidth: array[boolean] of TFresnelLength;
|
|
|
+ FScrollbarsThinWidth: array[boolean] of TFresnelLength;
|
|
|
+ FScrollbarsWidth: array[boolean] of TFresnelLength;
|
|
|
+ FScrollbarsColor: array[TFresnelScrollbarColor] of TFPColor;
|
|
|
FStylesheet: TStrings;
|
|
|
FStylesheetResolverStamp: TCSSNumericalID;
|
|
|
FStylesheetStamp: TCSSNumericalID;
|
|
|
FWidth: TFresnelLength;
|
|
|
procedure CSSResolverLog(Sender: TObject; Entry: TCSSResolverLogEntry);
|
|
|
function GetFocusedElement: TFresnelElement;
|
|
|
+ function GetScrollbarsColors(Col: TFresnelScrollbarColor): TFPColor;
|
|
|
procedure SetFocusedElement(const aValue: TFresnelElement);
|
|
|
procedure SetScrollbarsAutoHide(AValue: boolean);
|
|
|
+ procedure SetScrollbarsColors(Col: TFresnelScrollbarColor; AValue: TFPColor
|
|
|
+ );
|
|
|
protected
|
|
|
class var FFresnelEventsRegistered: boolean;
|
|
|
protected
|
|
@@ -1802,10 +1818,13 @@ type
|
|
|
function WSInput(WSData: TFresnelInputEventInit) : boolean; virtual;
|
|
|
property VPApplication: IFresnelVPApplication read FVPApplication;
|
|
|
property DPI[IsHorizontal: boolean]: TFresnelLength read GetDPI write SetDPI;
|
|
|
+
|
|
|
property ScrollbarsAutoHide: boolean read FScrollbarsAutoHide write SetScrollbarsAutoHide;
|
|
|
property ScrollbarsOverlay: boolean read FScrollbarsOverlay write SetScrollbarsOverlay;
|
|
|
property ScrollbarsWidth[IsHorizontal: boolean]: TFresnelLength read GetScrollbarsWidth write SetScrollbarsWidth;
|
|
|
property ScrollbarsThinWidth[IsHorizontal: boolean]: TFresnelLength read GetScrollbarsThinWidth write SetScrollbarsThinWidth;
|
|
|
+ property ScrollbarsColors[Col: TFresnelScrollbarColor]: TFPColor read GetScrollbarsColors write SetScrollbarsColors;
|
|
|
+
|
|
|
property VPLength[l: TFresnelViewportLength]: TFresnelLength read GetVPLength write SetVPLength;
|
|
|
property Resolver: TCSSResolver read FResolver;
|
|
|
property Stylesheet: TStrings read FStylesheet write SetStylesheet; // CSS origin author
|
|
@@ -2855,7 +2874,7 @@ begin
|
|
|
Result:=Resolver.CurComp.Kind=rvkNone;
|
|
|
exit;
|
|
|
end;
|
|
|
- // check for two colors
|
|
|
+ // check for exactly two colors
|
|
|
for i:=1 to 2 do
|
|
|
begin
|
|
|
if IsColor(Resolver.CurComp) then
|
|
@@ -2865,6 +2884,7 @@ begin
|
|
|
exit(true)
|
|
|
else
|
|
|
exit; // todo warn
|
|
|
+ Resolver.ReadNext;
|
|
|
end;
|
|
|
Result:=Resolver.CurComp.Kind=rvkNone;
|
|
|
end;
|
|
@@ -6619,6 +6639,27 @@ begin
|
|
|
Parent.FScrollBarVertical:=Self;
|
|
|
end;
|
|
|
|
|
|
+procedure TPseudoElScrollBar.GetColors(out CurThumbColor,
|
|
|
+ CurTrackColor: TFPColor);
|
|
|
+var
|
|
|
+ ElHovered: Boolean;
|
|
|
+begin
|
|
|
+ ElHovered:=Parent.IsHovered;
|
|
|
+ if HasColor then
|
|
|
+ CurTrackColor:=TrackColor
|
|
|
+ else if ElHovered then
|
|
|
+ CurTrackColor:=Viewport.ScrollbarsColors[vscTrackHover]
|
|
|
+ else
|
|
|
+ CurTrackColor:=Viewport.ScrollbarsColors[vscTrackNormal];
|
|
|
+
|
|
|
+ if HasColor then
|
|
|
+ CurThumbColor:=ThumbColor
|
|
|
+ else if ElHovered then
|
|
|
+ CurThumbColor:=Viewport.ScrollbarsColors[vscThumbHover]
|
|
|
+ else
|
|
|
+ CurThumbColor:=Viewport.ScrollbarsColors[vscThumbNormal];
|
|
|
+end;
|
|
|
+
|
|
|
{ TFresnelFontDesc }
|
|
|
|
|
|
function TFresnelFontDesc.Compare(const Desc: TFresnelFontDesc): integer;
|
|
@@ -6671,6 +6712,12 @@ begin
|
|
|
Result:=FFocusedElement;
|
|
|
end;
|
|
|
|
|
|
+function TFresnelViewport.GetScrollbarsColors(Col: TFresnelScrollbarColor
|
|
|
+ ): TFPColor;
|
|
|
+begin
|
|
|
+ Result:=FScrollbarsColor[Col];
|
|
|
+end;
|
|
|
+
|
|
|
procedure TFresnelViewport.SetFocusedElement(const aValue: TFresnelElement);
|
|
|
begin
|
|
|
TrySetFocusControl(aValue);
|
|
@@ -6683,6 +6730,14 @@ begin
|
|
|
Invalidate;
|
|
|
end;
|
|
|
|
|
|
+procedure TFresnelViewport.SetScrollbarsColors(Col: TFresnelScrollbarColor;
|
|
|
+ AValue: TFPColor);
|
|
|
+begin
|
|
|
+ if FScrollbarsColor[Col]=AValue then exit;
|
|
|
+ FScrollbarsColor[Col]:=AValue;
|
|
|
+ Invalidate;
|
|
|
+end;
|
|
|
+
|
|
|
function TFresnelViewport.GetDPI(IsHorizontal: boolean): TFresnelLength;
|
|
|
begin
|
|
|
Result:=FDPI[IsHorizontal];
|
|
@@ -6691,12 +6746,12 @@ end;
|
|
|
function TFresnelViewport.GetScrollbarsWidth(IsHorizontal: boolean
|
|
|
): TFresnelLength;
|
|
|
begin
|
|
|
- Result:=FScrollbarWidth[IsHorizontal];
|
|
|
+ Result:=FScrollbarsWidth[IsHorizontal];
|
|
|
end;
|
|
|
|
|
|
function TFresnelViewport.GetScrollbarsThinWidth(IsHorizontal: boolean): TFresnelLength;
|
|
|
begin
|
|
|
- Result:=FScrollbarThinWidth[IsHorizontal];
|
|
|
+ Result:=FScrollbarsThinWidth[IsHorizontal];
|
|
|
end;
|
|
|
|
|
|
function TFresnelViewport.GetHeight: TFresnelLength;
|
|
@@ -6711,10 +6766,10 @@ begin
|
|
|
case l of
|
|
|
vlDPIHorizontal: Result:=FDPI[true];
|
|
|
vlDPIVertical: Result:=FDPI[false];
|
|
|
- vlHorizontalScrollbarWidth: Result:=FScrollbarWidth[true];
|
|
|
- vlVerticalScrollbarWidth: Result:=FScrollbarWidth[false];
|
|
|
- vlHorizontalScrollbarThinWidth: Result:=FScrollbarThinWidth[true];
|
|
|
- vlVerticalScrollbarThinWidth: Result:=FScrollbarThinWidth[false];
|
|
|
+ vlHorizontalScrollbarWidth: Result:=FScrollbarsWidth[true];
|
|
|
+ vlVerticalScrollbarWidth: Result:=FScrollbarsWidth[false];
|
|
|
+ vlHorizontalScrollbarThinWidth: Result:=FScrollbarsThinWidth[true];
|
|
|
+ vlVerticalScrollbarThinWidth: Result:=FScrollbarsThinWidth[false];
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -6881,16 +6936,16 @@ end;
|
|
|
procedure TFresnelViewport.SetScrollbarsWidth(IsHorizontal: boolean;
|
|
|
const AValue: TFresnelLength);
|
|
|
begin
|
|
|
- if FScrollbarWidth[IsHorizontal]=AValue then exit;
|
|
|
- FScrollbarWidth[IsHorizontal]:=AValue;
|
|
|
+ if FScrollbarsWidth[IsHorizontal]=AValue then exit;
|
|
|
+ FScrollbarsWidth[IsHorizontal]:=AValue;
|
|
|
DomChanged;
|
|
|
end;
|
|
|
|
|
|
procedure TFresnelViewport.SetScrollbarsThinWidth(IsHorizontal: boolean;
|
|
|
const AValue: TFresnelLength);
|
|
|
begin
|
|
|
- if FScrollbarThinWidth[IsHorizontal]=AValue then exit;
|
|
|
- FScrollbarThinWidth[IsHorizontal]:=AValue;
|
|
|
+ if FScrollbarsThinWidth[IsHorizontal]=AValue then exit;
|
|
|
+ FScrollbarsThinWidth[IsHorizontal]:=AValue;
|
|
|
DomChanged;
|
|
|
end;
|
|
|
|
|
@@ -7626,6 +7681,8 @@ constructor TFresnelViewport.Create(AOwner: TComponent);
|
|
|
TFresnelEventDispatcher.FresnelRegistry.RegisterEventWithID(aClass.FresnelEventID,aClass);
|
|
|
end;
|
|
|
|
|
|
+var
|
|
|
+ c: TFPColor;
|
|
|
begin
|
|
|
inherited Create(AOwner);
|
|
|
FViewPort:=Self;
|
|
@@ -7633,10 +7690,18 @@ begin
|
|
|
FHeight:=600;
|
|
|
FDPI[false]:=FresnelDefaultDPI;
|
|
|
FDPI[true]:=FresnelDefaultDPI;
|
|
|
- FScrollbarWidth[False]:=12;
|
|
|
- FScrollbarWidth[true]:=12;
|
|
|
- FScrollbarThinWidth[False]:=6;
|
|
|
- FScrollbarThinWidth[true]:=6;
|
|
|
+ FScrollbarsWidth[False]:=12;
|
|
|
+ FScrollbarsWidth[true]:=12;
|
|
|
+ FScrollbarsThinWidth[False]:=6;
|
|
|
+ FScrollbarsThinWidth[true]:=6;
|
|
|
+ c:=colDkGray;
|
|
|
+ FScrollbarsColor[vscThumbHover]:=c;
|
|
|
+ c.Alpha:=$8000;
|
|
|
+ FScrollbarsColor[vscThumbNormal]:=c;
|
|
|
+ c:=colLtGray;
|
|
|
+ FScrollbarsColor[vscTrackHover]:=c;
|
|
|
+ c.Alpha:=$8000;
|
|
|
+ FScrollbarsColor[vscTrackNormal]:=c;
|
|
|
|
|
|
FResolver:=TCSSResolver.Create(nil);
|
|
|
FResolver.OnLog:=@CSSResolverLog;
|
|
@@ -8754,7 +8819,7 @@ function TFresnelElement.GetComputedColor(Attr: TFresnelCSSAttribute; const Curr
|
|
|
var
|
|
|
Complete: boolean;
|
|
|
CurComp: TCSSResCompValue;
|
|
|
- AttrID, KW: TCSSNumericalID;
|
|
|
+ AttrID: TCSSNumericalID;
|
|
|
s: String;
|
|
|
begin
|
|
|
Result:=CurrentColor;
|
|
@@ -8763,6 +8828,20 @@ begin
|
|
|
CurComp.EndP:=PChar(s);
|
|
|
if not Resolver.ReadComp(CurComp) then exit;
|
|
|
|
|
|
+ if GetComputedColorValue(s,CurComp,Result) then
|
|
|
+ begin
|
|
|
+ if not Resolver.ReadNext then
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ Result:=CurrentColor;
|
|
|
+end;
|
|
|
+
|
|
|
+function TFresnelElement.GetComputedColorValue(const s: string;
|
|
|
+ const CurComp: TCSSResCompValue; out Col: TFPColor): boolean;
|
|
|
+var
|
|
|
+ KW: TCSSNumericalID;
|
|
|
+begin
|
|
|
+ Result:=false;
|
|
|
case CurComp.Kind of
|
|
|
rvkKeyword:
|
|
|
begin
|
|
@@ -8770,12 +8849,9 @@ begin
|
|
|
if (KW>=CSSRegistry.kwFirstColor)
|
|
|
and (KW<=CSSRegistry.kwLastColor)
|
|
|
then begin
|
|
|
- //writeln('TFresnelElement.GetComputedColor ',s,' KW=',KW,' ',CSSRegistry.kwFirstColor,' ',CSSRegistry.kwLastColor, ' ',CSSRegistry.GetKeywordColor(KW));
|
|
|
- Result:=FPColor(CSSRegistry.GetKeywordColor(KW));
|
|
|
- exit;
|
|
|
+ Col:=FPColor(CSSRegistry.GetKeywordColor(KW));
|
|
|
+ exit(true);
|
|
|
end;
|
|
|
- if KW=CSSRegistry.kwCurrentcolor then
|
|
|
- exit;
|
|
|
end;
|
|
|
rvkFunction:
|
|
|
begin
|
|
@@ -8783,13 +8859,34 @@ begin
|
|
|
end;
|
|
|
rvkHexColor:
|
|
|
begin
|
|
|
- if not CSSToFPColor(copy(s,CurComp.StartP-PChar(s),CurComp.EndP-CurComp.StartP),Result) then
|
|
|
- Result:=CurrentColor;
|
|
|
- exit;
|
|
|
+ Result:=CSSToFPColor(copy(s,CurComp.StartP-PChar(s)+1,CurComp.EndP-CurComp.StartP),Col);
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+function TFresnelElement.GetComputedScrollbarColor(out aThumbColor,
|
|
|
+ aTrackColor: TFPColor): boolean;
|
|
|
+var
|
|
|
+ AttrID: TCSSNumericalID;
|
|
|
+ s: String;
|
|
|
+ CurComp: TCSSResCompValue;
|
|
|
+ Complete: boolean;
|
|
|
+begin
|
|
|
+ Result:=false;
|
|
|
+ aThumbColor:=colLtGray;
|
|
|
+ aTrackColor:=colGray;
|
|
|
+ AttrID:=CSSRegistry.FresnelAttrs[fcaScrollbarColor].Index;
|
|
|
+ s:=GetCSSString(AttrID,false,Complete);
|
|
|
+ CurComp.EndP:=PChar(s);
|
|
|
+ if not Resolver.ReadComp(CurComp) then exit;
|
|
|
+
|
|
|
+ if not GetComputedColorValue(s,CurComp,aThumbColor) then exit;
|
|
|
+ if not Resolver.ReadComp(CurComp) then exit;
|
|
|
+ if not GetComputedColorValue(s,CurComp,aTrackColor) then exit;
|
|
|
+ if Resolver.ReadComp(CurComp) then exit;
|
|
|
+ Result:=true;
|
|
|
+end;
|
|
|
+
|
|
|
function TFresnelElement.GetComputedKeyword(Attr: TFresnelCSSAttribute;
|
|
|
const AllowedKeywords: TCSSNumericalIDArray): TCSSNumericalID;
|
|
|
begin
|