On Thu, 11 Oct 2007 20:08:27 -0400
James Chandler Jr <[EMAIL PROTECTED]> wrote:
>[...]
> On Oct 11, 2007, at 6:25 PM, Mattias Gaertner wrote:
> > On Thu, 11 Oct 2007 08:53:35 -0700
> > Peter Gannon <[EMAIL PROTECTED]> wrote:
> >> [snip]Most programs do some kind of
> >> direct painting at some stage[...]
> >
> > Most programs? Can you give some examples?
>
> Hi Mattias
>
> 1- On PC Delphi, screen flashing on heavy updates can occur. What I
> think is probably a common workaround (though perhaps I'm the only
> Delphi programmer who ever did this)--
>
> Rather than calling Invalidate and letting the OnPaint draw
> everything, in some cases you just call OnPaint, which 'draws over'
> the stuff already there, giving a quick clean visible change of only
> the parts which have changed. The parts of the image that are the
> same do not flicker, because you are just 'drawing over' what was
> already onscreen.
Flickering:
a) Disable 'erase background', then OnPaint will only paint over.
This should be possible under carbon too. TCustomControl descendants
like TSynEdit and TPropertyGrid use this.
b) use double buffering. AFAIK this is default for win32/64, gtk2, qt. I
don't know carbon's double buffering.
>[...]
> 2. I use direct drawing a lot in a MIDI Piano Roll editor on PC. I
> draw the 'marching ants' XOR rectangle if the user click-drags on
> open space to select a group of notes.
Yes, for smooth interactive effects it is a problem when the OnPaint of
the underlying control is slow. Here you need to disable the
painting of the control. Can be done with TCustomControl, but the
rubberband should probably work on arbitrary controls.
>[...]
> 3. LED Audio VU Meters-- These things look best when they update
> pretty frequently. It is typically done by having rectangular
> bitmaps of the VU Meter 'All Off', and another bitmap of the VU Meter
> 'All On'. Depending on the audio instantaneous level, you blit a
> percentage of the 'All On' image to the bottom of the VU Meter and
> then blit a percentage of the 'All Off' image to the top of the VU
> Meter.
Make the LEDs controls.
> 4. On a Music Notation window-- All the Staves, barlines, and notes
> are drawn with the OnPaint event. And then during playback the task
> is to draw individual notes in Red when the sequencer starts each
> note, and then redraw each note in Black when the sequencer stops
> each note. So you want to (quickly) only update little pieces of the
> notation with spots of Red or Black.
Use a TCustomControl descendant.
> 5.[...]lot of mouse-tracking would probably be easier with some kind of
> direct-draw mechanism.
Direct drawing with XOR is only easy if no OnPaint happens
between.
>[...]
For small smooth effects you need drawing without drawing the
underlying control(s). Direct drawing is only one such possibility. And afaik
it is not easy to implement such
effects properly. Not in the application code, and not in the
widgetsets.
Mattias
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives