case ABody.FStyle of bbsClear, bbsColor: { Solid background color } FBGRA.RoundRectAntialias(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,FRoundX,FRoundY, borcolor, FBorderWidth, backcolor); bbsGradient: begin { Using multishape filler to merge background gradient and border } multi := TBGRAMultishapeFiller.Create; multi.PolygonOrder := poFirstOnTop; { Border will replace background } if borcolor.alpha <> 0 then { Let the background be wider with transparent border } multi.AddRoundRectangleBorder(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,FRoundX,FRoundY, FBorderWidth, borcolor); { Gradients } back := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRAPixelTransparent); grect1 := ARect; grect2 := ARect; { Gradient 1 } if ABody.FGradient1EndPercent>0 then begin grect1.Bottom := Round((grect1.Bottom/100)*ABody.FGradient1EndPercent); gra := CreateGradient(ABody.FGradient1, grect1); back.FillRect(grect1.Left,grect1.Top,grect1.Right,grect1.Bottom, gra,dmSet ); gra.Free; end; { Gradient 2 } if ABody.FGradient1EndPercent<100 then begin if grect1.Bottom<ARect.Bottom then grect2.Top := grect1.Bottom-1; gra := CreateGradient(ABody.FGradient2, grect2); back.FillRect(grect2.Left,grect2.Top,grect2.Right,grect2.Bottom, gra,dmSet ); gra.Free; end; multi.AddRoundRectangle(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,FRoundX,FRoundY, back); multi.Draw(FBGRA); multi.Free; back.Free; end; end;
{*** BGRA Drawing *** } case ADrawEffect of gdeDisabled: begin GetBitmap(AIndex, FBmp, gdeNormal); FBGRA.Assign(FBmp); BGRAReplace(FBGRA, FBGRA.FilterGrayscale); end; else begin GetBitmap(AIndex, FBmp, ADrawEffect); FBGRA.Assign(FBmp); end; end; if ADrawingStyle in[dsFocus, dsSelected] then FBGRA.ApplyGlobalOpacity(128); FBGRA.Draw(ACanvas, AX, AY, False);
New version 1.0.8.0
procedure TForm1.FormCreate(Sender: TObject);begin // Panel with BGRAPanel1 do begin Gradient.StartColor:=RGBToColor(245,250,255); Gradient.EndColor:=RGBToColor(221,233,247); end; // Button with BGRAButton1 do begin TextShadow:=False; RoundX:=2; RoundY:=2; // Normal with BodyNormal do begin Font.Color:=clBlack; BorderStyle:=bboNone; Style:=bbsClear; end; // Hover with BodyHover do begin Font.Color:=clBlack; Gradient1EndPercent:=50; BorderColor:=RGBToColor(187,202,219); Gradient1.StartColor:=RGBToColor(248,251,254); Gradient1.EndColor:=RGBToColor(237,242,250); Gradient2.StartColor:=RGBToColor(215,228,244); Gradient2.EndColor:=RGBToColor(193,210,232); end; // Clicked with BodyClicked do begin Font.Color:=clBlack; Gradient1EndPercent:=55; BorderColor:=RGBToColor(187,202,219); Gradient1.StartColor:=RGBToColor(226,236,245); Gradient1.EndColor:=RGBToColor(216,228,241); Gradient2.StartColor:=RGBToColor(207,219,236); Gradient2.EndColor:=RGBToColor(207,220,237); end; end;end;
Nice . I see it is worth developing further
procedure TForm.OnCreate(Sender: TObject); procedure _DefaultPropertys(AButton: TBGRAButton); begin AButton.BodyHover.Gradien1.StartColor := clred; // etc... end;begin _DefaultPropertys(BGRAButton1); _DefaultPropertys(BGRAButton2); _DefaultPropertys(BGRAButton3);end;
BGRAButton2.Assign(BGRAButton1);BGRAButton3.Assign(BGRAButton1);
...for i := 0 to Form1.ComponantCount -1 do if Form1.Components[i] is TBGRAButton then Form1.Components[i].BodyHover.Gradien1.StartColor := clred; ...