> You are welcome! I also get some help from people here so its nice to give > something in return :).
It does give that warm fuzzy feeling, doesn't it :) > Are you sure you need a container and various child widgets? No I'm not sure. To me it also felt very strange, as I just need place to draw with the cairo, but I don't know whether I can pass the expose events to other widgets that are not child widgets. > Can you instead use only a GtkDrawingArea? I'll look into that. >> Let's imagine the surfaces as two identical playing cards. If small area on >> the center of the card needs to be redrawn, I just place the new card on >> top of the old one and draw the needed area from the new card, while other >> areas in the old card remain untouched. If I put nonzero values to >> startPosH/V the cards are no longer aligned and yields to incorrect result. >> > You are right. > Though, I don't understand: the new card and the old card are two cards or > are the same card but you just want to modify a portion of it? I was a bit unclear. If some part of the first card gets dirty, I just copy the same part from the 'clean' card and patch it over the first one, instead of placing the whole card on top of the dirty one. > You can tell Cairo what to draw and what to skip with: > gdk_cairo_region( myCairo_t, myGdkEventExpose->region ); > cairo_clip( myCairo_t ); > That speeds things up because Cairo doesn't draw things that it doesn't > need, though AFAIK Cairo needs to be more smart about it and optimize things > more, but at least it already do some things and likely it will just improve > with time :). You can help it though: there are gdk_cairo_* functions to find > out if a point is inside the region or not, you can use that for two things: > one is to avoid bothering Cairo and another is to avoid doing some unecessary > computations in your own application too. Ok, sounds good. I kind of already know how to decide what needs to be done when some area gets dirty. >> I'm not quite sure how to copy a small part of previously stored surface to >> current surface at the same position, or if I do scrolling I just copy most >> of the stored surface to slightly different position and draw the new >> information. >> > It depends on your performance needs. > You can do things smart (and more complex) by getting the contents of the > drawable and slide it according to the scroll size and then draw only the > remaining part; or you can do things more easily: just draw everything again > with the new offsets or different translation in your transformation matrix. Well, I have most of the contents already stored in the cached surface, so the former would be the way to go. > I suggest to follow the examples, there is a Clock Widget done using Cairo > (http://www.gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28) > > and is a good example for a lot of things and a good start, though instead of > using the cairo_rectangle for clipping just use the gdk_cairo_region for > clipping, that gives better performance, thats the only thing that I would > change to that tutorial. :) This is exactly the one I have been following. I even created my current test widgets just by modifying the example (and I still have the same function names haunting me all over the code, never bothered to rename them) > Hope this helps. > Happy coding! :) Thanks! Tommi _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list