Essentially this article explored the ability to do some fashionable (read iPhone-like) view transitions using child views implemented as regular Win32 controls (such as a tree view, a list view or even a dialog). The view transitions were implemented using a very simple mechanism:
- Capture the existing view as a bitmap;
- Remove the from the frame container;
- Paint the view bitmap on the frame client area;
- Create the new child view window off screen;
- Enter a loop where the bitmap is scrolled to the requested direction a few pixels;
- Every time the bitmap is scrolled, move the new child window to the contiguous position thus creating the illusion that both windows are moving in lockstep.
Now that we are rendering the touch windows and lists directly on a memory DC, there is a better chance to improve on the original algorithm and implement a smoother view transition algorithm. This is what you will find in the sample code (see below).
The major change I made to the code was to CChildViewBase where you can now see a GetBitmap virtual method. If this method returns NULL, then the child view is not able to render itself on a bitmap and the old brute-force method will be used. If, on the other hand, the child view is able to render itself to a bitmap it must do so here. Note how this is implemented in the CCrypSafeView class: the painting engine is called directly and a new HBITMAP is returned for the child view manager to paint.
The results are here for you to see: acceptable on some devices, way too fast on others and slower on older devices. What we need to do here is quite simple: use the same kinematics equations to control the view transition motion and leave nothing to chance.
Comments and suggestions are welcome!
Sample code: CrypSafe05.zip (349 KB)
6 comments:
Hi,
some remarks, oledbclient project is still using complete path instead of relative ones and get a missing header :
Error 1 fatal error C1083: Cannot open include file: 'BlobStream.h': No such file or directory c:\downloads\CrypSafe05\OleDbClient\Rowset.cpp 5
Yikes! Sorry! I will correct that in the next post.
I have tested and I am not really convinced at all. Transitions are eithier too fast or inexistent.
And I think that previous scrolling behavior was better ...
I will change the view transition behavior in order to bring it under control. As for the scrolling behavior, I also have mixed feelings. On some (older) devices it does work well, but on my HTC Touch Pro I still see some "fluctuations". I will go back to the timed approach (maybe consider both).
Thank you for your input!
I suppose you already read this :
http://blogs.msdn.com/marcpe/default.aspx
very interesting
Indeed. My work here is getting more irrelevant each passing day.
Post a Comment