Einzelnen Beitrag anzeigen

Benutzerbild von luisk
luisk

Registriert seit: 18. Mär 2009
402 Beiträge
 
#22

AW: FMX TButton Hintergrundfarbe

  Alt 29. Dez 2015, 15:14
CL_Button mit Farbverlauf
on_MouseEnter/Leave schaltet die Farben um. (Farben werden noch dynamisch gestaltet)
Delphi-Quellcode:
//-------------------------------------------------------------------------
constructor CL_Button.create(in_Owner:TComponent);
begin
    inherited create(in_Owner);
    
    onMouseEnter:=self.on_MouseEnter;
    onMouseLeave:=self.on_MouseLeave;


    lbl_Text := TLabel.Create(self);
    lbl_Text.Parent:=self;
    lbl_Text.Align := lbl_Text.Align.alClient;

     Fill.Kind:= Fill.Kind.bkGradient;
     Fill.Gradient.Points[0].Color:= $FF4FEB2E ;
     Fill.Gradient.Points[0].Offset:= 0 ;
     Fill.Gradient.Points[1].Color:= claWhite ;
     Fill.Gradient.Points[1].Offset:= 1.0 ;
     Fill.Gradient.StartPosition.X := 0.5;
     Fill.Gradient.StartPosition.Y := 1.0;
     Fill.Gradient.StopPosition.X := 0.5;
     Fill.Gradient.StopPosition.Y := 0.0;
     GradientAnimation1:= TGradientAnimation.create(self);
     GradientAnimation1.Duration := 0.2;
     GradientAnimation1.PropertyName := 'Stroke.Gradient';
     GradientAnimation1.StartValue.Points[0].Color:=$FF90E959;
     GradientAnimation1.StartValue.Points[0]. Offset := 0.0;
     GradientAnimation1.StartValue.Points[1].Color:= claWhite;
     GradientAnimation1.StartValue.Points[1].Offset:= 1.0;
     GradientAnimation1.StartValue.StartPosition.X := 0.5;
     GradientAnimation1.StartValue.StartPosition.Y := 1.0;
     GradientAnimation1.StartValue.StopPosition.X := 0.5;
     GradientAnimation1.StartValue.StopPosition.Y := 0.0;
     GradientAnimation1.StopValue.Points[0].Color := claBlack;
     GradientAnimation1.StopValue.Points[0].Offset := 0.0;
     GradientAnimation1.StopValue.Points[1].Color := claWhite ;
     GradientAnimation1.StopValue.Points[1].Offset:= 1.0;
end;
//-------------------------------------------------------------------------
Vorlage:
Code:
 object Rectangle2: TRectangle
          Align = Client
          Fill.Kind = Gradient
          Fill.Gradient.Points = <
            item
              Color = xFF4FEB2E
              Offset = 0.000000000000000000
            end
            item
              Color = claWhite
              Offset = 1.000000000000000000
            end>
          Fill.Gradient.StartPosition.X = 0.500000000000000000
          Fill.Gradient.StartPosition.Y = 1.000000000000000000
          Fill.Gradient.StopPosition.X = 0.499999970197677600
          Fill.Gradient.StopPosition.Y = 0.000000000000000000
          Size.Width = 136.000000000000000000
          Size.Height = 49.000000000000000000
          Size.PlatformDefault = False
          OnClick = Rectangle2Click
          OnMouseEnter = Rectangle2MouseEnter
          object GradientAnimation1: TGradientAnimation
            Duration = 0.200000002980232200
            PropertyName = 'Stroke.Gradient'
            StartValue.Points = <
              item
                Color = xFF90E959
                Offset = 0.000000000000000000
              end
              item
                Color = claWhite
                Offset = 1.000000000000000000
              end>
            StartValue.StartPosition.X = 0.500000000000000000
            StartValue.StartPosition.Y = 1.000000000000000000
            StartValue.StopPosition.X = 0.499999970197677600
            StartValue.StopPosition.Y = 0.000000000000000000
            StopValue.Points = <
              item
                Color = claBlack
                Offset = 0.000000000000000000
              end
              item
                Color = claWhite
                Offset = 1.000000000000000000
              end>
          end
        end

Geändert von luisk (29. Dez 2015 um 16:39 Uhr)
  Mit Zitat antworten Zitat