Ver Fonte

text-shadow: negative position

mattias há 1 ano atrás
pai
commit
c83fa61a22

+ 1 - 1
demo/Button/MainUnit.pas

@@ -68,13 +68,13 @@ end;
 
 procedure TMainForm.MainFormCreate(Sender: TObject);
 begin
-
   Div1.Style:=
      'background:#44c767;'
     +'border-width:7px;'
     +'border-color:#18ab29;'
     +'padding:16px 31px;'
     +'font-size:15px; font-family:Arial; font-weight:bold;'
+    +'text-shadow: 0 1 0 #333;'
     +'color:#fff;';
 end;
 

+ 2 - 2
demo/ButtonGenerator/MainUnit.lfm

@@ -1,7 +1,7 @@
 object FresnelForm1: TFresnelForm1
   FormLeft = 168
-  FormTop = 336
+  FormTop = 236
   FormWidth = 320
-  FormHeight = 340
+  FormHeight = 600
   OnCreate = FresnelForm1Create
 end

+ 104 - 21
demo/ButtonGenerator/MainUnit.pas

@@ -21,14 +21,19 @@ type
     ButtonDiv: TDiv;
     ButtonLabel: TLabel;
     FontSizeSlider: TDemoSlider;
+    PaddingVerticalSlider: TDemoSlider;
     BorderWidthSlider: TDemoSlider;
     BorderRadiusDiv: TDiv;
     BorderRadiusLabel: TLabel;
-    BorderRadiusTopLeft: TDemoCheckBox;
-    BorderRadiusTopRight: TDemoCheckBox;
-    BorderRadiusBottomLeft: TDemoCheckBox;
-    BorderRadiusBottomRight: TDemoCheckBox;
+    BorderRadiusTopLeftChkBox: TDemoCheckBox;
+    BorderRadiusTopRightChkBox: TDemoCheckBox;
+    BorderRadiusBottomLeftChkBox: TDemoCheckBox;
+    BorderRadiusBottomRightChkBox: TDemoCheckBox;
     BorderRadiusSlider: TDemoSlider;
+    TextShadowChkBox: TDemoCheckBox;
+    TextShadowVertPosSlider: TDemoSlider;
+    TextShadowHorzPosSlider: TDemoSlider;
+    TextShadowBlurRadiusSlider: TDemoSlider;
   end;
 
 var
@@ -76,6 +81,20 @@ begin
     OnChange:=@OnPropChange;
   end;
 
+  // padding vertical slider
+  PaddingVerticalSlider:=TDemoSlider.Create(Self);
+  with PaddingVerticalSlider do begin
+    Name:='PaddingVerticalSlider';
+    Caption:='Vertical Padding:';
+    Style:='width: 150px';
+    ValueFormat:='%.0fpx';
+    MinPosition:=0;
+    MaxPosition:=50;
+    Position:=16;
+    Parent:=Self;
+    OnChange:=@OnPropChange;
+  end;
+
   // border-width slider
   BorderWidthSlider:=TDemoSlider.Create(Self);
   with BorderWidthSlider do begin
@@ -105,36 +124,36 @@ begin
     Parent:=BorderRadiusDiv;
   end;
 
-  BorderRadiusTopLeft:=TDemoCheckBox.Create(Self);
-  with BorderRadiusTopLeft do begin
-    Name:='BorderRadiusTopLeft';
+  BorderRadiusTopLeftChkBox:=TDemoCheckBox.Create(Self);
+  with BorderRadiusTopLeftChkBox do begin
+    Name:='BorderRadiusTopLeftChkBox';
     Caption:='Top Left';
     Checked:=true;
     Parent:=BorderRadiusDiv;
     OnChange:=@OnPropChange;
   end;
 
-  BorderRadiusTopRight:=TDemoCheckBox.Create(Self);
-  with BorderRadiusTopRight do begin
-    Name:='BorderRadiusTopRight';
+  BorderRadiusTopRightChkBox:=TDemoCheckBox.Create(Self);
+  with BorderRadiusTopRightChkBox do begin
+    Name:='BorderRadiusTopRightChkBox';
     Caption:='Top Right';
     Checked:=true;
     Parent:=BorderRadiusDiv;
     OnChange:=@OnPropChange;
   end;
 
-  BorderRadiusBottomLeft:=TDemoCheckBox.Create(Self);
-  with BorderRadiusBottomLeft do begin
-    Name:='BorderRadiusBottomLeft';
+  BorderRadiusBottomLeftChkBox:=TDemoCheckBox.Create(Self);
+  with BorderRadiusBottomLeftChkBox do begin
+    Name:='BorderRadiusBottomLeftChkBox';
     Caption:='Bottom Left';
     Checked:=true;
     Parent:=BorderRadiusDiv;
     OnChange:=@OnPropChange;
   end;
 
-  BorderRadiusBottomRight:=TDemoCheckBox.Create(Self);
-  with BorderRadiusBottomRight do begin
-    Name:='BorderRadiusBottomRight';
+  BorderRadiusBottomRightChkBox:=TDemoCheckBox.Create(Self);
+  with BorderRadiusBottomRightChkBox do begin
+    Name:='BorderRadiusBottomRightChkBox';
     Caption:='Bottom Right';
     Checked:=true;
     Parent:=BorderRadiusDiv;
@@ -155,6 +174,58 @@ begin
     OnChange:=@OnPropChange;
   end;
 
+  // text-shadow checkbox
+  TextShadowChkBox:=TDemoCheckBox.Create(Self);
+  with TextShadowChkBox do begin
+    Name:='TextShadowChkBox';
+    Caption:='Text Shadow';
+    Checked:=true;
+    Parent:=Self;
+    OnChange:=@OnPropChange;
+  end;
+
+  // slider for text-shadow vertical position
+  TextShadowVertPosSlider:=TDemoSlider.Create(Self);
+  with TextShadowVertPosSlider do begin
+    Name:='TextShadowVertPosSlider';
+    Caption:='Vertical Position:';
+    Style:='width: 150px';
+    ValueFormat:='%.0fpx';
+    MinPosition:=-30;
+    MaxPosition:=30;
+    Position:=1;
+    Parent:=Self;
+    OnChange:=@OnPropChange;
+  end;
+
+  // slider for text-shadow horizontal position
+  TextShadowHorzPosSlider:=TDemoSlider.Create(Self);
+  with TextShadowHorzPosSlider do begin
+    Name:='TextShadowHorzPosSlider';
+    Caption:='Horizontal Position:';
+    Style:='width: 150px';
+    ValueFormat:='%.0fpx';
+    MinPosition:=-30;
+    MaxPosition:=30;
+    Position:=1;
+    Parent:=Self;
+    OnChange:=@OnPropChange;
+  end;
+
+  // slider for text-shadow horizontal position
+  TextShadowBlurRadiusSlider:=TDemoSlider.Create(Self);
+  with TextShadowBlurRadiusSlider do begin
+    Name:='TextShadowBlurRadiusSlider';
+    Caption:='Blur Radius:';
+    Style:='width: 150px';
+    ValueFormat:='%.0fpx';
+    MinPosition:=0;
+    MaxPosition:=30;
+    Position:=0;
+    Parent:=Self;
+    OnChange:=@OnPropChange;
+  end;
+
   // the Button
   ButtonDiv:=TDiv.Create(Self);
   with ButtonDiv do begin
@@ -181,29 +252,41 @@ var
   s, NewStyle, Radius: String;
 begin
   if ButtonDiv=nil then exit;
-  NewStyle:='font-size:'+FloatToStr(FontSizeSlider.Position)+'px;'
+  NewStyle:=
+     'font-size:'+FloatToStr(FontSizeSlider.Position)+'px;'
+    +'padding: '+FloatToStr(PaddingVerticalSlider.Position)+'px 31px;'
     +'border-width:'+FloatToStr(BorderWidthSlider.Position)+'px;';
 
   Radius:=FloatToStr(BorderRadiusSlider.Position)+'px';
   s:='';
-  if BorderRadiusTopLeft.Checked then
+  if BorderRadiusTopLeftChkBox.Checked then
     s:=Radius
   else
     s:='0';
-  if BorderRadiusTopRight.Checked then
+  if BorderRadiusTopRightChkBox.Checked then
     s+=' '+Radius
   else
     s+=' 0';
-  if BorderRadiusBottomLeft.Checked then
+  if BorderRadiusBottomLeftChkBox.Checked then
     s+=' '+Radius
   else
     s+=' 0';
-  if BorderRadiusBottomRight.Checked then
+  if BorderRadiusBottomRightChkBox.Checked then
     s+=' '+Radius
   else
     s+=' 0';
   NewStyle+='border-radius:'+s+';';
 
+  s:='';
+  if TextShadowChkBox.Checked then
+  begin
+    s:=FloatToStr(TextShadowHorzPosSlider.Position)
+      +' '+FloatToStr(TextShadowVertPosSlider.Position)
+      +' '+FloatToStr(TextShadowBlurRadiusSlider.Position)
+      +' #2f6627';
+  end;
+  NewStyle+='text-shadow:'+s+';';
+
   ButtonDiv.Style:=NewStyle;
 end;
 

+ 0 - 1
demo/CheckBox/DemoCheckBox.pas

@@ -52,7 +52,6 @@ type
     const
       cStyle = ''
         +'.CheckBox {'+LineEnding
-        +'  position: relative;'+LineEnding
         +'}'+LineEnding
         +TDemoCheckBoxButton.cStyle
         +'.CheckBoxButton {'+LineEnding

+ 3 - 2
src/base/fresnel.dom.pas

@@ -2586,6 +2586,7 @@ begin
   aOffsetX:='';
   aOffsetY:='';
   aRadius:='';
+  writeln('AAA1 TFresnelElement.CheckCSSTextShadow START ',AValue);
   for i:=1 to 4 do
   begin
     s:=CSSReadNextValue(AValue,p);
@@ -3408,7 +3409,7 @@ begin
       if i=1 then
         exit; // empty
       break;
-    end else if s[1] in ['0'..'9'] then
+    end else if s[1] in ['-','+','.','0'..'9'] then
     begin
       inc(NumberIndex);
       if not CSSStrToFloat(s,l) then
@@ -3783,7 +3784,7 @@ begin
     s:=CSSReadNextValue(Value,p);
     if s='' then
       break
-    else if s[1] in ['0'..'9'] then
+    else if s[1] in ['+','-','.','0'..'9'] then
     begin
       inc(NumberIndex);
       case NumberIndex of