Flushing component display


#1

Hi,

In most case we can the classic message-based redraw of the user interface is fine. However, sometimes (for activity led-type) I would like to be able to force the redraw of a bitmap component so it goes in sync with the process.

Something like

activityComponent->SetActive(true) ;
activityComponent->repaint() ;

// process here activity… fairely short

activityComponent->SetActive(false) ;
activityComponent->repaint() ;

Since I do this type of scheme from the main thread (it’s based on user action), by the time juce get back to process messages, the activityComponent never shows as active. doing it from a side thread would make everything really complicated.

What is the correct way to handle this type of scheme ?

Thanks.


#2

Well, the correct way would be to use a thread to do the work rather than blocking the main event thread.

A more hacky approach would be to do your work on the main thread, but to intersperse it with frequent calls to MessageManager::getInstance()->runDispatchLoopUntil (2), to keep the events getting pumped through. Not a great approach, and it has its problems, but it’ll work, and seems to be what you’re going for here. You’d probably need to use a modal component too, to stop events hitting your UI while it runs.