Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!apple!bionet!agate!shelby!polya!ali From: ali@polya.Stanford.EDU (Ali T. Ozer) Newsgroups: comp.sys.amiga.tech Subject: Re: How Does Workbench Do Dragging? Message-ID: <10035@polya.Stanford.EDU> Date: 15 Jun 89 15:29:39 GMT References: <927G02a733mv01@amdahl.uts.amdahl.com> Sender: Ali T. Ozer Reply-To: aozer@NeXT.com (Ali Ozer) Organization: . Lines: 41 >Mike Robinson asks, through Kim DeVaughn: > > I am trying to write what I thought was going to be a very simple > Solitaire program which uses the mouse. That is, by pressing the left > mouse button you will appear to "pick up" a set of cards, "drag" them > around the screen and, by releasing the button, "drop" them. Trouble is, > I cannot perfect the dragging. ... > I'd be *extremely* grateful if someone could tell me, briefly, how > Workbench does it. Window-type, flag settings, what library call, etc. > If I could achieve dragging as well as Workbench does, for comparably > sized images, I'd be delighted. Thanks in advance for your help. Well, whatever the Workbench does isn't perfect either --- just drag several good sized icons simultaneously and you will get a good amount of flicker. What'll work well in your case is some sort of (fake) double buffering --- Create all your images in offscreen bitmaps or a secondary screen and blit them in. If the largest piece you are moving is 100x100, create a 200x200 bitmap. If the user moves the piece by a distance of 30,30, say, all you need to do is recreate the 130x130 area in this bitmap by first drawing the background, any other pieces that appear, and finally your piece in its new location in this offscreen bitmap. Then blit this 130x130 area into your actual window. If the user moves the piece by more than 100,100 (so the new image doesn't overlap the previous one), then you can do the above just for the two 100x100 areas individually (old and new locations). Using this method you might end up drawing less frames/second, but because there's no flicker it'll probably look much better. I used this method in a small program I was working on. I just used a secondary screen to do my temporary drawing; this allows you to see both the "offscreen" and onscreen versions at the same time and makes debugging easier. You probably can also use a offscreen bitmap with an appropriate rastport; I don't see why it shouldn't work. Ali Ozer