Hoping some of you out there will be able to point me in the right direction to handle flickering/tearing/redrawing issues when I 'animate' some components in an application.
I have to preface this by saying that the 'animations' seem to work correctly (no flickering etc) when not in full screen mode - i.e. 1024*768, borderstyle=bsSingle. It's when the application takes over the full monitor and the borderstyle becomes bsNone, that this issue becomes more than apparent.
There are 2 'animations':
1 - Panels scrolling left to right using the Winapi AnimateWindow method
2 - TmsAdvPolyPager stepping through each one of its items and subsequently showing its 'page'
When scrolling the panels, the panel that is 'exiting' leaves a 'trail' and the animation seems to shudder, it's no longer smooth.
When stepping through the TmsAdvPolyPager items, the next item will sometimes not become highlighted and the page it shows often has 'residuals' from the previous panel.
Both animations are triggered by a timer - the AnimateWindow is in it's own thread, the PolyPager stepping is not.
So, basically - any thoughts on how to smooth out these animations and force a correct redrawing of the TmsAdvPolyPager component? First time trying this kind of stuff, so not totally sure what to look into it.
As always, help is much appreciated!
TPaintBox is what you need, possibly on a TScroller.
Dump the Panels and draw to rectangles on the TPaintbox canvas.
You have obviously written 99% of this code already so moving to defined rectangles shouldn't be a problem :)
Related
I have an NSTextView that users can type into. What's different is that I often make changes to the TextStorage while the user is typing in it (i.e. some information comes in over the network, and I need to represent that into the NSTextView by merging in these changes).
I can do that successfully - I've created a MovableCursor which keeps track of SelectedRange even when changes are happening behind the scenes.
I have this code working on iOS (UITextView) and the Mac (NSTextView). The problem is, on the Mac, the NSTextView usually jumps in the Scroller (i.e. the visible position in the View changes). It does not move at all on the UITextView - everything works perfectly, the cursor doesn't move in the window even though changes have happened to the TextStorage.
Simply using ScrollRangeToVisible doesn't work - it may make the Selection visible, but it necessarily make it visible in the same place.
I've tried grabbing the Scroller's VerticalScroller position, and then reapply it after making changes.
var scroll_pos = contentViewScroller.VerticalScroller.FloatValue;
...make changes...
contentViewScroller.VerticalScroller.FloatValue = scroll_pos;
Well, I can see the scrollbar doesn't move (expected), but the text still does. Somehow the scroller gets out of alignment with its position through the NSTextView. When I start moving the scrollbar, it seems to "flick" a little and get back in alignment.
So... Any thoughts on how I can make changes to an NSTextView's TextStorage, while keeping the Cursor (or SelectedRange) fixed in the same position on the screen.
[Note: of course there are times when this immobility is not possible - for example if everything before the cursor was erased, then the cursor must move to the top. That's ok.]
Many thanks.
I have aUIViewController, which has inside a UIView in which I add a UIPageViewController with the UIViewController as the delegate. The thing is that the UIPageControl of the UIPageViewController is not working as I had expected regarding the dots selection.
I was expecting that if I selected the dot 4, it would take me to the dot 4, yet, It doesn't work like that. It always goes to the following page if I select the right half of the UIPageControl (inside the blue square of the image), and goes to the previous page if I select the left half of the UIPageControl (inside the red square of the image). So, If im in page 2 and select around the second dot, it goes to page 1 (instead of staying on page 2)
Moreover, If I click exactly inside one of the dots (any of the dots), the click is ignored, although im not sure how this works on device (since in the device is more difficult to click exactly inside one dot).
My questions:
1 - Is ignoring exactly inside the dots behavior normal (by exactly inside the dots, I mean not around them)?
2 - Is two halves selection of the UIPageController to move between pages behavior normal?
3 - How can I make it so that if I press the dot X, it takes me to page X (instead of the current two halves behavior)?
Note: I prefer swift
1 - Is ignoring exactly inside the dots behavior normal (by exactly inside the dots, I mean not around them)?
I've never encountered this. I would say its not normal. Something may be overriding it.
2 - Is two halves selection of the UIPageController to move between pages behavior normal?
Yes this is the default behavior for UIPageController.
3 - How can I make it so that if I press the dot X, it takes me to page X (instead of the current two halves behavior)?
I would recommend not doing this. The reason that it isn't this way by default is the touch space is too small (when using a finger not a mouse). So it makes sense to only go forward and back. You'd have to create a custom UIControl to be able to do this if you really need to for some reason.
I would suggest you to use external library for that, as this problem was more or less solved. It is quite complicated to do by subclassing native page control but you can probably find implementation somewhere.
This library does exactly what you want (jump to page) :
https://github.com/Spaceman-Labs/SMPageControl
In the documentation, look for section "Direct Page Selection"
Hope it helps!
Edit: Few more libraries to look into:
https://github.com/TanguyAladenise/TAPageControl
https://github.com/nicklockwood/FXPageControl (very extensive, probably too much)
I don't know how, but after moving two of my UIViews, they are moving back to their starting x/y position every so often. I've checked the code and I'm not moving them back to their starting positions directly, but they are going back there somehow.
What technique would you suggest to find which bit of code is moving them?
(I am 'hiding' them at one point (alpha=0.5, userInteractionEnabled=NO) and then re-showing them. That couldn't be it could it?)
One of my views freezes up for several seconds when I tap the back button.
In addition, when I tap on one of the items in this view, it shows a popup (custom, not a UIPopoverController). This popup appears quite fast, but when I "flip" the popup to see it's back side, the same long delay occurs.
I suspect the reason has something to do with the complexity of the view. As you can see in the screenshot below, it's a collection view, it has a background and some of the subviews are rotated (UIViewEdgeAntialiasing is on).
I used the Time Profiler in Instruments to figure out what's going on, but I'm stuck.
I don't see anything useful unless I deselect "Hide System Libraries":
If I look at the method names, I think they are related to auto layout. That suggests that it's trying to render something during the segue. But methods such as cellForItemAtIndexPath are not called.
There is also an iPhone version of this app where I don't experience this problem at all. It uses a tableview in stead of a collectionview. It also has a background and rotated pictures.
I took these measurements using the simulator; on my iPad Mini the situation is worse; it can take up to 20 seconds before the animation starts.
Update - Things I've tried thanks to your answers:
turn off UIViewEdgeAntialiasing : no effect on performance
I think this might be due to the UIViewEdgeAntialiasing flag. It seems that your main view (the one with lots of slightly rotated pictures) have lots of antialiased edges and hence is very taxing on the iPad's GPU. The fact that the drawing performance slows down when your popover is spinning (ie when the background is showing again) gives this some credence.
Try turning it off and see if the performance improves. How does it look like?
Rotation was the bad guy here. Each UICollectionViewCell has a UIView as a container view and within that is a UIImageView. I rotate it like this:
container.transform = CGAffineTransformMakeRotation(M_PI * someRandomFloat);
Remove that line and everything is snappy.
I use the same technique on the iPhone, but apparently this kind of rotation has less of a performance impact in UITableViewCell than in UICollectionViewCell.
I tried subclassing UICollectionViewFlowLayout to rotate cell itself in stead of one subview. Unfortunately that causes a similar performance issue.
Suppose I have a VFM full of both focusable and non-focusable fields. Since most of them are spread out far apart, the movement from one focused field to another is jerky at best, even with NullFields in between. In other words, it just sets the current y position to the next focused field without smoothly scrolling the screen.
What I want to achieve is to be able to scroll at a fixed rate between fields, so it it doesn't just focus from one to another that instantaneously. After reading up on how to do this, it is a matter of overriding moveFocus and setting it via a TimerTask from an accessor method to set moveFocus, as per this link. However, I haven't seen a practical implementation of how to do this, complete with the routines that are called in the TimerTask's thread.
Is there any way to achieve this type of behavior?