How does UIApplication.shared.requestSceneSessionRefresh actually work? - ipados

I'm having a hard time understanding how UIApplication.shared.requestSceneSessionRefresh actually works. According to Apple, this is used to update scenes that are in background. But does the API call something in your background scene to allow the UI to update or is it assumed that you've updated your background scene and this call will just capture your UI?

Related

What Qt widgets should be used for sprite animation viewer

I'm looking to make a sprite animation editor. I have the loading of my custom animation file done but now need to get the actual ui started. I'm really just stuck on what widgets I would use to actually play my animation. I need to be able to go to certain frame, play, pause, loop, etc. Once I'm done with the viewing portion I plan on adding in the editing.
I've seen AnimatedSprite in qt docs but that seems to only allow playback of sprites in the same file. In my situation sprites can be from multiple image files and sometimes doesn't follow a grid like sprite cutter.
First of all, you should decide whether you want to use QML or Widgets. AnimatedSprite is QML related class. All widget-related classes starts with "Q" letter.
If you decide to use Qt Widgets, I would recommend to take a look at Qt Animation Framework in combination with Qt Graphics View Framework. Most likely it will not let you do everything you want out of box, but it should provide you with a rich set of useful tools.
If you need here are some examples.
Hope it helps.
Have a look at QMovie. This class may provide all the methods you need, as long as you only want to use it for viewing. The QMovie can be passed to a QLabel to show the animation.
QMovie however supports only gif out of the box (and there is a third party plugin for apng files). You would probably have to create your own image handle plugin to support your format.
If thats not applicable or to complicated, you will most likely have to create your own custom widget. Have a look at the painter example. Playing an animation is not that hard if you have all the frames. A simple QTimer to change the image to be drawn in a constant rate should work.

How to display smooth video in FireMonkey (FMX, FM3)?

Has anyone figured out how to display smooth video (i.e. a series of bitmaps) in a FireMonkey application, HD or 3D? In VCL you could write to a canvas from a thread and this would work perfectly, but this does not work in FMX. To make things worse, the apparently only reliable way is to use TImage, and that seems to be updated from the main thread (open a menu and video freezes temporarily). All EMB examples I could find all either write to TImage from the main thread, or use Synchronize(). These limitations make FMX unusable for decent video display so I am looking for a hack or possibly bypass of FMX. I use XE5/C++ but welcome any suggestions. Target OS is both Windows 7+ & OS X. Thanks!
How about putting a TPaintbox on your form to hold the video. In the OnPaint method you simply draw the next frame to the paintbox canvas. Now put a TTimer on the form, set the interval to the frame rate required. In the OnTimer event for the timer just write paintbox1.repaint
This should give you regular frames no matter what else the program is doing.
For extra safety, you could increment a frame number in the OnTimer event. Now in the paintbox paint method you know which frame to paint. This means you won't jump frames if something else calls the paint method as well as the timer - you will just end up repainting the same frame for the extra call to OnPaint.
I use this for marching ants selections although I go one step further and use an overlaid canvas so I can draw independently to the selection and the underlying paintbox canvas to remove the need to repaint the main canvas when the selection changes. That requires calls to API but I guess you won't need it unless you are doing videos with a transparent colour.
Further research, including some talks with the Itinerant developer, has unfortunately made it clear that, due to concurrency restrictions, FM has been designed so that all GPU access goes through the main thread and therefore painting will always be limited. As a result I have decided FM is not suitable for my needs and I am re-evaluating my options.

How do I create a slider in the GDK?

Programming the GDK a few weeks now, the CardScrollView is a pretty nice interface for displaying cards. However one issue with the UI is showing the user how far along they are in the card stack. In the Mirror API, this is nicely handled by the Slider view at the bottom of the screen as described on the Glass Design page:
https://developers.google.com/glass/design/style/metrics-grids
Unfortunately, I have not been able to get this Slider object to display on the CardScrollView and instead have resorted to a klugey 1 of n text.
Is there any way to get this Slider view to display in the GDK?
This is not yet supported by our API but is currently tracked with Issue #256.
For future reference, this feature has been already implemented as described in the original issue.
You can use the method setHorizontalScrollBarEnabled to show the bar, e.g.
mCardScrollView.setHorizontalScrollBarEnabled(true);

How to make sure Qt Widget.repaint has finished running?

I am currently having a problem with Qt graphics view framework namely, I want to clear my QGraphicScene background color and then run a function to take a webcam picture. So far when I use QWidget.repaint the screen only got repaint after about 1 second and by then the camera function has been called and the image captured is always off. Here is how my code currently look like.
//Scene is a QGraphicScene
//View is a QGraphicView
//Camera is a camera object
Scene.setBackgroundBrush(Qt::Blue)
View.repaint()
Camera.Capture()
I have tried wrapping the repaint() call with another function and use signal and slot call but it still fail. I want to know if there is a way to pause the program until the screen has been refreshed.
A QGraphicsView has a bit more going on than most QWidget subclasses and I'm not familiar enough with it to say what is going on for sure but I might venture a guess that your problem is related to the fact that the scene is actually rendered onto the view port widget. Perhaps calling viewport->repaint() will give you the results you are looking for?
Also, unless you really need to be using the webcam in this scenario, you could call ::render() on your scene and pass it a QImage which you could save directly to a file.

Strange winAPI behaviour

I have sub classed a tab control to give it a background. I have used the clipping functions to clip the drawing area to the update region. This works, except for when I move the window of the screen and back again.
When it does this, it occasionally sets the clipping region to the whole screen. This is fine except that none of the controls redraw and end up hidden behind the background. How do I know whether or not to redraw the background when I get this update region. It would be 100x easier to develop this if I saw the source code for the tab control, but that isn't going to happen.
All help or suggestions welcome, but I really do need a straight-forward answer.
By "clipping region" I assume you mean the area that has to be redrawn that windows passes to you.
Try this: The paint message handler should bitblit the area of the background image that corresponds to the part of the window that needs to be refreshed (so you don't draw over things that don't need updating). Then let the base class handle the rest.
If it's setting the repaint region to the entire window the tab control code should redraw everything after you've painted the background.
Having code to look at would help