theunreplicated / nvidia-widgets

Automatically exported from code.google.com/p/nvidia-widgets
0 stars 0 forks source link

unbalanced grouping & panels #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Because
void UIContext::endPanel()
{
    endFrame();
    endGroup();
}
assumes both are on stack but UIContext::beginPanel does
        if (isUnfold && *isUnfold)
        {
            beginFrame( flags, Rect(0, 0, r.w, r.h) ); 
            return true;
        }
        else
        {
            endGroup();
            return false;
        }
said stack is smashed.
My simple solution was to define GroupFlags_InternalSkipFrame = 0x10000, 
        if (isUnfold && *isUnfold) {
            beginFrame(flags, Rect(0, 0, r.w, r.h));
            return true;
        }
        else {
            beginFrame(flags | GroupFlags_InternalSkipFrame, Rect(0, 0, 0, 0));
            return false;
        }
then have that flag propagated through UIContext::beginGroup and finally
void UIContext::endFrame()
{
    endGroup();
    if (!(m_groupStack[m_groupIndex + 1].flags &
GroupFlags_InternalSkipFrame)) 
        m_painter->drawFrame( m_groupStack[m_groupIndex + 1].bounds,
m_groupStack[m_groupIndex + 1].margin, 0);
}
so that no residual frame would get drawn when panel is collapsed.

Original issue reported on code.google.com by tbptbp@gmail.com on 14 Jan 2009 at 1:35

GoogleCodeExporter commented 9 years ago
Hi Thierry,

Thanks for the catch.
After looking at the issue closer, I think it's just a problem of documentation 
for
the Panel.
This is the way I designed the panel calls:

static bool isUnfold = true;
if ( ui.beginPanel( Rect, "The panel Name", &isUnfold ) )
{
     // Do some stuff in the unfold panel

     // End the panel since it is unfold
     ui.endPanel();
}
// if the Panel is not unfold, there is nothing to do

And then it works just fine.

I suspect you are doing always the calls beginPanel / endPanel no matter the 
panel is
unfold or not.

I agree that there is a naming issue here, a good documentation would be a 
minimum

What's your opinion ?

Thanks,

Sam

Original comment by samuel.g...@gmail.com on 23 Jan 2009 at 7:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ok, i wasn't thinking straight. It indeed does the trick.
On top of a bit of documentation, a feedback mechanism of some sort (in debug 
builds)
about whether the stack is clear or not on end() would definitely help the 
end-user
to catch such mistakes.

Original comment by tbptbp@gmail.com on 24 Jan 2009 at 1:44