Browse Source

scroll: draw buttons

mattias 5 months ago
parent
commit
aa240405f7
2 changed files with 35 additions and 24 deletions
  1. 24 19
      src/base/fresnel.renderer.pas
  2. 11 5
      src/skia/fresnel.skiarenderer.pas

+ 24 - 19
src/base/fresnel.renderer.pas

@@ -626,9 +626,8 @@ begin
     end;
   end;
 
-  if Horizontal then
-    DrawButton(Renderer,true);
-  //DrawButton(Renderer,false);
+  DrawButton(Renderer,true);
+  DrawButton(Renderer,false);
 end;
 
 procedure TRendererScrollBar.DrawButton(Renderer: TFresnelRenderer; LT: boolean);
@@ -648,37 +647,37 @@ begin
     if Horizontal then
     begin
       // left arrow
-      p[0].X:=r.Left+w/4;
+      p[0].X:=r.Left+w/4-1;
       p[0].Y:=r.Top+h/2;
       p[1].X:=r.Right-w/4;
       p[1].Y:=r.Top;
       p[2].X:=p[1].X;
       p[2].Y:=r.Bottom;
     end else begin
-      // right arrow
-      p[0].X:=r.Right-w/4;
-      p[0].Y:=r.Top+h/2;
-      p[1].X:=r.Right-w/2;
-      p[1].Y:=r.Bottom;
-      p[2].X:=p[1].X;
-      p[2].Y:=r.Top;
-    end;
-  end
-  else begin
-    r:=ButtonRB;
-    if Horizontal then
-    begin
       // top arrow
       p[0].X:=r.Left+w/2;
-      p[0].Y:=r.Top+h/4;
+      p[0].Y:=r.Top+h/4-1;
       p[1].X:=r.Right;
       p[1].Y:=r.Bottom-h/4;
       p[2].X:=r.Left;
       p[2].Y:=p[1].Y;
+    end;
+  end
+  else begin
+    r:=ButtonRB;
+    if Horizontal then
+    begin
+      // right arrow
+      p[0].X:=r.Right-w/4+1;
+      p[0].Y:=r.Top+h/2;
+      p[1].X:=r.Left+w/4;
+      p[1].Y:=r.Bottom;
+      p[2].X:=p[1].X;
+      p[2].Y:=r.Top;
     end else begin
       // bottom arrow
       p[0].X:=r.Left+w/2;
-      p[0].Y:=r.Bottom-h/4;
+      p[0].Y:=r.Bottom-h/4+1;
       p[1].X:=r.Left;
       p[1].Y:=r.Top+h/4;
       p[2].X:=r.Right;
@@ -706,7 +705,10 @@ begin
     if (ButtonLT.Width>0) and (X<=ButtonLT.Right+Padding/2) then
       exit(TSBHit.hButtonLT);
     if (ButtonRB.Width>0) and (X>=ButtonRB.Left-Padding/2) then
+    begin
+      aPosition:=Size;
       exit(TSBHit.hButtonRB);
+    end;
     l:=TrackArea.Width;
     if l<=0 then exit;
     if l>=1 then
@@ -717,7 +719,10 @@ begin
     if (ButtonLT.Height>0) and (Y<=ButtonLT.Bottom+Padding/2) then
       exit(TSBHit.hButtonLT);
     if (ButtonRB.Height>0) and (Y>=ButtonRB.Top-Padding/2) then
+    begin
+      aPosition:=Size;
       exit(TSBHit.hButtonRB);
+    end;
     l:=TrackArea.Height;
     if l<=0 then exit;
     if l>=1 then

+ 11 - 5
src/skia/fresnel.skiarenderer.pas

@@ -689,6 +689,7 @@ begin
     else
       Color2:=FPColorToSkia(LinGrad.Colors[1].Color);
     SkPaint:=TSkPaint.Create(TSkPaintStyle.Fill);
+    SkPaint.SetAntiAlias(true);
     Shader:=TSkShader.MakeGradientLinear(StartP,EndP,Color1,Color2);
     SkPaint.Shader:=Shader;
 
@@ -744,6 +745,7 @@ begin
   begin
     if not Params.SameBorderWidth then ; // todo
     SkPaint:=TSkPaint.Create(TSkPaintStyle.Stroke);
+    SkPaint.SetAntiAlias(true);
     SkPaint.setColor(FPColorToSkia(Params.Color[ffsLeft]));
     SkPaint.SetStrokeWidth(Params.Width[ffsLeft]);
     SkPaint.SetAntiAlias(true);
@@ -800,6 +802,7 @@ var
   SkPaint: ISkPaint;
 begin
   SkPaint:=TSkPaint.Create(TSkPaintStyle.Stroke);
+  SkPaint.SetAntiAlias(true);
   SkPaint.setColor(FPColorToSkia(aColor));
   Canvas.DrawLine(Origin.X+x1,Origin.Y+y1,Origin.X+x2,Origin.Y+y2, SkPaint);
 end;
@@ -810,12 +813,14 @@ var
   a: TPolygon;
   SkPaint: ISkPaint;
   i: Integer;
-  //SkPath: ISkPath;
-  //SkPathBuilder: ISkPathBuilder;
+  SkPath: ISkPath;
+  SkPathBuilder: ISkPathBuilder;
 begin
   if Count<=2 then exit;
   SkPaint:=TSkPaint.Create(TSkPaintStyle.Stroke);
+  SkPaint.SetAntiAlias(true);
   SkPaint.setColor(FPColorToSkia(aColor));
+  SkPaint.SetStyle(TSkPaintStyle.Fill);
   SetLength(a{%H-},Count);
   for i:=0 to Count-1 do
   begin
@@ -823,10 +828,11 @@ begin
     a[i].y:=Origin.Y+p[i].Y;
     //writeln('TFresnelSkiaRenderer.Polygon ',i,' ',FloatToCSSStr(a[i].X),',',FloatToCSSStr(a[i].Y));
   end;
-  //SkPathBuilder:=TSkPathBuilder.Create;
-  //SkPathBuilder.AddPolygon(a,true);
+  SkPathBuilder:=TSkPathBuilder.Create;
+  SkPathBuilder.AddPolygon(a,true);
+  SkPath:=SkPathBuilder.Detach;
 
-  Canvas.DrawPoints(TSkDrawPointsMode.Polygon,a,SkPaint);
+  Canvas.DrawPath(SkPath,SkPaint);
 end;
 
 procedure TFresnelSkiaRenderer.Restore;