How to actually use paintOverChildren?

#1

So I keep asking how to draw a moving vertical playhead without redrawing everything in the parent class and all the children but nobody seems to know. I think I may have found the answer with paintOverChildren(). I overrode it in the top level parent class and it draws the moving yellow line. However, how can I call this function?

paintOverChildren(Graphics & g)

I want it in a timer callback drawn every 30 ms. How do I get “g” to draw it? Or am I using it wrong? Is what I’m doing impossible? How come every DAW out there can draw a moving yellow vertical line without using 100+ percent CPU to draw everything?

0 Likes

#2

You don’t call that function. It is called by the framework as part of the painting scheme. Here is the calling order:

  1. Component::paint()
  2. All child Component::paint()'s
  3. Component::paintOverChildren()
0 Likes

#3

With DrawableRectangle and reseting it’s position on timer…
Check this https://github.com/jonathonracz/AudioFilePlayerPlugin

1 Like

#4

YES! This worked, thanks so much! I didn’t realize things like DrawableRectangle were drawn independent of paint().

0 Likes