PDA

View Full Version : GUI Component Constant Repaint



rombust
10-07-2010, 07:14 AM
I have a question regarding the gui component constant repaint.

This is set using CL_GUIComponent::set_constant_repaint()

When enabled the GUI will constantly repaint this component when there are no other messages to process.

Internally, the GUI_Manager calls via the exec() calls: impl->invalidate_constant_repaint_components()

That function iterates recursively all components checking for the "CL_GUIComponent::get_constant_repaint()" flag.

If any child component contains the flag, the root component calls request_repaint()

The recent addition the clanGUI API adds: CL_GUIWindowManagerTexture::process() that updates the GUI.

But it does not check the constant_repaint flag of any components.

This was intentional at the time, but I am not sure is that is correct.

Some examples:
If you create an animating component using the GUI texture window manager, these are the possible methods.


...
CL_DisplayWindow window(desc);
...
CL_GUIWindowManagerTexture wm(window);
CL_GUIManager gui(wm, "../../../Resources/GUIThemeAero");

while (!quit)
{
Draw_The_Scene();
for each component
{
component->Animate();
if (component->FrameChanged())
component->request_repaint();
}

wm.process();
wm.draw_windows(gc);

window.flip(1);
CL_KeepAlive::process();
}

OR


...
CL_DisplayWindow window(desc);
...
CL_GUIWindowManagerTexture wm(window);
CL_GUIManager gui(wm, "../../../Resources/GUIThemeAero");

while (!quit)
{
Draw_The_Scene();
for each component
{
component->Animate();
component->set_constant_repaint(true);
}

wm.process(); // ** Will not work, because it does not look at the constant repaint flag
wm.draw_windows(gc);

window.flip(1);
CL_KeepAlive::process();
}

Should wm.process() check for constant repaint components automatically?
Or otherwise?

I do not know

Magnus Norddahl
10-07-2010, 05:55 PM
I would say yes. Your manual game loop should cause the same GUI to react the same way as if you called exec(), except for how it presents the textures.

The constant repaint feature is meant for situations where something is constantly animating. The feature could probably use some improvements (such as specifying a desired/max fps), but no matter what its absolutely required for those situations where a game runs itself in a "GameView" component. In such situations its not unlikely that the game may eventually want to customize the presentation of the textures to apply post-processing effects or other effects related to window management.

rombust
10-14-2010, 07:29 AM
Applied to ClanLib 2.2 and 2.3 SVN: "Check for constant repaint when using CL_GUIWindowManagerProvider_Texture::process()"

The contant repaint issue will need looking at again in the future

At the moment, it calls request_repaint() on the root component, if any child components contain a constant repaint request.

I would have thought it would be preferable to ONLY call request_repaint() on the component that contain a constant repaint request.

That way you will not be redrawing components that do not require it.