Jump to content


Photo

TW3MovableControl.SetAlpha / Opacity inconsistency


  • Please log in to reply
No replies to this topic

#1 field

field
  • Members
  • 10 posts

Posted 02 January 2017 - 04:39 PM

Hi,

 

SMS 2.2.2.4543:

 

the opacity-property of every TW3MovableControl is behaving inconsistently: 

 

 TW3MovableControl.SetAlpha has the following code:

 

procedure TW3MovableControl.SetAlpha(const aValue: Integer);
begin
  // make sure alpha-range is OK
  FAlpha := ClampInt(aValue, 0, 255);
 
  // apply alpha
  if FUseAlpha then
    Handle.style['opacity'] := FAlpha * 0.01;
end;
 

 

So on the one hand the acceptable value is limited to 0-255, on the other hand it is multiplied with 0.01 (which is / 100) - since  valid CSS-values are between [0.0-1.0] not both can be correct...

 

Since TW3MovableControl.InitializeObject puts the default value FAlpha := 255 and using opacity with colors also requires the [0..255] range I've changed 

 
procedure TW3MovableControl.SetUseAlpha(const aValue: Boolean);
var
  mBlend: Float;
begin
  if aValue = FUseAlpha then exit;
 
  FUseAlpha := aValue;
  if aValue then
     mBlend := FAlpha / 255;//* 0.01; //FLD
  else
    mBlend := 1;
  Handle.style['opacity'] := mBlend;
end;
 
 
and 
 
 
procedure TW3MovableControl.SetAlpha(const aValue: Integer);
begin
  // make sure alpha-range is OK
  FAlpha := ClampInt(aValue, 0, 255);
 
  // apply alpha
  if FUseAlpha then
    Handle.style['opacity'] := FAlpha / 255;//* 0.01; //FLD
end;
 

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users