Jump to content
Sign in to follow this  
field

TW3MovableControl.SetAlpha / Opacity inconsistency

Recommended Posts

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;
 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×