Wish [Denied] SetVisibleAnimated Sleep

mmieher

Active Member
Licensed User
Longtime User
Maybe put a Sleep duration parameter in SetVisibleAnimated?

B4X:
   '  xPage.SetVisibleAnimated(100,True)
    ' Sleep(120)

    xPage.SetVisibleAnimated(100, True, 120)
 

mmieher

Active Member
Licensed User
Longtime User
Maybe I have misunderstood something? Is not the Sleep necessary to see the animated effect?
 

Sagenut

Expert
Licensed User
Longtime User
The idea of the opening post has a logic, but considering that the Sleep command (even Sleep(0) ) will give back the flow to the calling point.............. maybe it's better to have it separated as now to better manage it.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. It is not possible to add parameters to existing methods. You can request to add another method SetVisibleAnimated2 with the sleep parameter.
2. As I see it, adding such a method is a huge mistake. There are many SetXXXAnimated methods. There is no sense in adding this parameter to SetVisibleAnimated and not the others.
It also leads developers to the wrong conclusion that a sleep is required after calling a "set animated" method. The only case where it is required is if you want to do something only after the animated ends. This is not 90% of the cases. It is maybe 1% of the cases.

Bottom line: it will not happen :)
 

LucaMs

Expert
Licensed User
Longtime User
.... or create your own B4XLib, with version 2 of all the default animation methods.
I wrote this class (and test project) in just a few minutes (just because it's very easy and it's even easier thanks to B4X :) ), so I put in the first animations I found, without thinking too much.

The main reason was... to avoid doing more important and urgent things ?:confused:

As I wrote, you could make a B4Xlib library out of it.
 

Attachments

  • Anim.zip
    14.3 KB · Views: 155

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is an opportunity here to explain a bit about resumable subs and why it is not really possible to create a simple SetVisibleAnimatedAndSleep method. It is possible with ugly compiler changes or by calling it with: Wait For (v.SetVisibleAnimatedAndSleep(...)) Complete
I will leave the explanation task for @agraham.

This got me thinking that I should have suggested that you create such a sub yourself:
B4X:
Public Sub SetVisibleAnimatedAndSleep(v As B4XView, Visible As Boolean, Duration) As ResumableSub
 v.SetVisibleAnimated(Visible, Duration)
 Sleep(Duration)
 Return True
End Sub

'use it:
Wait For (Utils.SetVisibleAnimatedAndSleep(xPage, True, 1000)) Complete (Unused As Boolean)
 

LucaMs

Expert
Licensed User
Longtime User
There is an opportunity here to explain a bit about resumable subs and why it is not really possible to create a simple SetVisibleAnimatedAndSleep method. It is possible with ugly compiler changes or by calling it with: Wait For (v.SetVisibleAnimatedAndSleep(...)) Complete
I will leave the explanation task for @agraham.

This got me thinking that I should have suggested that you create such a sub yourself:
B4X:
Public Sub SetVisibleAnimatedAndSleep(v As B4XView, Visible As Boolean, Duration) As ResumableSub
 v.SetVisibleAnimated(Visible, Duration)
 Sleep(Duration)
 Return True
End Sub

'use it:
Wait For (Utils.SetVisibleAnimatedAndSleep(xPage, True, 1000)) Complete (Unused As Boolean)
It is evident that you have not downloaded the project I have attached, Erel :)

It is exactly as you wrote, but in a class.
But it's not really worth it: writing that Wait For is more "complicated" than adding a Sleep every time.
 

mmieher

Active Member
Licensed User
Longtime User
There is an opportunity here to explain a bit about resumable subs and why it is not really possible to create a simple SetVisibleAnimatedAndSleep method. It is possible with ugly compiler changes or by calling it with: Wait For (v.SetVisibleAnimatedAndSleep(...)) Complete
I will leave the explanation task for @agraham.

This got me thinking that I should have suggested that you create such a sub yourself:
B4X:
Public Sub SetVisibleAnimatedAndSleep(v As B4XView, Visible As Boolean, Duration) As ResumableSub
 v.SetVisibleAnimated(Visible, Duration)
 Sleep(Duration)
 Return True
End Sub

'use it:
Wait For (Utils.SetVisibleAnimatedAndSleep(xPage, True, 1000)) Complete (Unused As Boolean)
Thanks, Erel(s). I did something similar. I am going for the "movie credit" effect and could not find something like that. I also want the Star Wars Intro scrolling, shrinking, leaving the display, text.
 
Top