Honestly, for how many versions now has the following got through?
unit FMX.Types; //... type TGradientPoint = class(TCollectionItem) private FColor: TAlphaColor; FOffset: Single; function GetColor: TAlphaColor; procedure SetColor(const Value: TAlphaColor); public procedure Assign(Source: TPersistent); override; property IntColor: TAlphaColor read FColor write FColor; published property Color: TAlphaColor read GetColor write SetColor; property Offset: Single read FOffset write FOffset nodefault; end; //... procedure TGradientPoint.Assign(Source: TPersistent); begin if Source is TGradientPoint then begin FColor := TGradientPoint(Source).FColor; FOffset := TGradientPoint(Source).FOffset; end else inherited; end; function TGradientPoint.GetColor: TAlphaColor; begin Result := FColor; end; procedure TGradientPoint.SetColor(const Value: TAlphaColor); begin FColor := Value; end;
What am I whinging about you say? This:
- What’s with the weird IntColor/Color duplication? Probably an historical thing… but why wasn’t the IntColor version taken out when the Color version was refactored?
- Why does Color have a getter that just directly returns the value of the backing field?
- Why doesn’t its setter (and Assign) call the Changed method?
- Where’s the Add method for TGradientPoints to cast the TCollection implementation’s result to TGradientPoint?
- Where’s the Update override for TGradientPoints? We want a property change to make a visible difference, right?
Oh, and don’t get me started on how the TGradient property editor is both horrible to use and set up to replace (not complement) what would have been perfectly reasonable default Object Inspector behaviour…