How to change element symbol opacity?

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
11 posts • Page 1 of 2
flindecke
Posts:69
Joined: Wed Jun 24, 2015 1:54 pm

How to change element symbol opacity?

Post by flindecke »

I am currently developing a simple panel where buttons (which are implemented as panel references due to several reasons) will be shown and hidden depending on user interaction.
For hiding and showing a panel reference, the property "visible" can be used.

Now i want to change the visual behavior to become more "smooth" and user friendly, i.e. these buttons should fade out or fade in according to visibility state (by calling a method on this panel references which starts the animation and changes its own visible flag).

My question 1: How can i change the "opacity" of a panel reference?
My question 2: If this is not directly possible, how can i change opacity of a rectangle using a gradient?

I am able to change the "foreCol" property of a text (and it works as expected). But i have no idea how to animate a fill property of a rectangle.

Any proposals?

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: How to change element symbol opacity?

Post by mkoller »

ad 1) you can't. A panelRef itself has no graphical attributes like color or filltype
ad 2) Qt does not implement a QGradient interpolation and we did not add one either. So currently you can't.
We could probably add one when certain rules are followed, e.g. the start and end gradient need to have the same number of stop points so we can interpolate each color separately

flindecke
Posts:69
Joined: Wed Jun 24, 2015 1:54 pm

Re: How to change element symbol opacity?

Post by flindecke »

Hello Martin,

i guessed it. So a panelRef is "just" a logical container for graphical primitives.
Calculating the desired target gradient using the same stop points might be possible, because it only need to manipulate the alpha value of the colors. So the missing point is the animation of the gradient itself.

Thanks for the clarification.

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: How to change element symbol opacity?

Post by mkoller »

Since I'm on holiday and have some time and since it was a fun task, I implemented this now for 3.16

flindecke
Posts:69
Joined: Wed Jun 24, 2015 1:54 pm

Re: How to change element symbol opacity?

Post by flindecke »

I did not hear it... you are on holiday! Recreation!
But i do not want to complain and looking forward for your proposed implementation ;-)

nmnogueira
Posts:125
Joined: Thu May 05, 2011 12:59 pm

Re: How to change element symbol opacity?

Post by nmnogueira »

You can access elements within an object by using the "." notation.
e.g. if you have a button with name BUTTON inside an object with name REF, you can change it's backcolor using:

Code: Select all

setValue("REF.BUTTON","backCol","_Transparent");

flindecke
Posts:69
Joined: Wed Jun 24, 2015 1:54 pm

Re: How to change element symbol opacity?

Post by flindecke »

I know how to access an object using "." notation.
My problem is, that i want to "fade out" a symbol (which is constructed with a rectangle for a background, an optional rectangle for an icon and a text).
The background of the symbol uses a gradient.
Fading the text is simple by animating its "foreCol". But i have no API for animating a gradient (using the "fill" property).

I cannot use the default button implementation, because i need a special layout and visualization which cannot be achieved by using CSS (which is not really CSS as known in HTML, but QT CSS which is more restricted).

Nevertheless i will wait for 3.16 implementation of Martin and take a look in the future.

nmnogueira
Posts:125
Joined: Thu May 05, 2011 12:59 pm

Re: How to change element symbol opacity?

Post by nmnogueira »

Have you tried changing the fill property? You can include a transparency in the field. The string would be something like

Code: Select all

[gradient,[linear,pad,0,0,1,1,0,{0,0,0,TRANSP},1,{255,255,255,TRANSP}]]
where TRANSP is the transparency value for the start and end colors.

flindecke
Posts:69
Joined: Wed Jun 24, 2015 1:54 pm

Re: How to change element symbol opacity?

Post by flindecke »

Thanks for your proposal.

My problem is not setting the gradient, but using the animate API of WinCC OA, which is not able to animate the fill property.
I want to change a visual property over time. I can do it in control, but this is not very ... hmh... smooth in the visual result. It would be nicer to let WinCC OA do it via the animate API.

kilianvp
Posts:443
Joined: Fri Jan 16, 2015 10:29 am

Re: How to change element symbol opacity?

Post by kilianvp »

you want fadeIn ( opacity 0 -> 1 ) or fadeOut ( opacity 1 ->0) ?

11 posts • Page 1 of 2