Thinking Hierarchically #

Things are improving. I've greatly simplified my activating and deactivating functions, because I figured out how to use the control hierarchy properly. Instead of having to (de)activate each control by hand, I can just toggle the state of the root control, and the rest of the controls within the window will follow suit. I've also fixed most of the refreshing problems, windows now draw properly in the background. I was passing NULL to the control clipping region, but instead of I was supposed to pass the clipping region of the parent window. Also, the icon finally displays properly when first opening it (which was the main reason why I rewrote my control refreshing). The only glitch remaining is that the icon view does not refresh properly when I activate it. It simply refuses to draw inside the area that has been newly revealed. Hopefully I can solve this tonight, and be able to start moving forward again.

(a bit later)

Weirdly enough that was fixed by calling EndUpdate (in between BeginUpdate/EndUpdate the drawing is restricted to the region that needs to be updated) before I called the icon drawing function. But this is a kludge, so I'm going to try a solution that makes more sense; I'm going to call InvalidateRect (with the rectangle of the icon display region as a parameter) when I have an activate event. If it works then the solution will make more sense.....That didn't work. I'll leave it as it is for now, and fix it later (hopefully this won't cause any bugs that take manifest themselves in extremely weird ways and take me a week to track down back to this).

I've finally added file saving (I already had saving, because I needed this when I first wrote the icnsClass, I only had to add a wrapper around it). I've also enhanced the speed of the refreshing by not redrawing if the user's mouse hasn't moved to a new position.

Eventually I'll have to redo the whole "redrawing as the user's button is down" architecture. Right now I have a while(Button()) loop, in which I get the position, set the pixel and refresh the display. However, if the user moves the mouse really fast, I might miss some position while I'm refreshing. But real drawing applications do not behave this way. What I need to do is have an asynchronous refreshing algorithm. This way I can keep sampling the mouse and setting the pixel, and refresh only when I have enough time to do so (this is visible in Photoshop, where if you draw with a really large brush you can see that the updating of the screen lags behind the movements of the mouse).

Post a Comment