@ -707,13 +707,15 @@ void ImGui::ShowTestWindow(bool* p_opened)
if ( ImGui : : CollapsingHeader ( " Graphs widgets " ) )
if ( ImGui : : CollapsingHeader ( " Graphs widgets " ) )
{
{
static bool animate = true ;
ImGui : : Checkbox ( " Animate " , & animate ) ;
static float arr [ ] = { 0.6f , 0.1f , 1.0f , 0.5f , 0.92f , 0.1f , 0.2f } ;
static float arr [ ] = { 0.6f , 0.1f , 1.0f , 0.5f , 0.92f , 0.1f , 0.2f } ;
ImGui : : PlotLines ( " Frame Times " , arr , IM_ARRAYSIZE ( arr ) ) ;
ImGui : : PlotLines ( " Frame Times " , arr , IM_ARRAYSIZE ( arr ) ) ;
static bool pause ;
static ImVector < float > values ; if ( values . empty ( ) ) { values . resize ( 90 ) ; memset ( values . Data , 0 , values . Size * sizeof ( float ) ) ; }
static ImVector < float > values ; if ( values . empty ( ) ) { values . resize ( 90 ) ; memset ( values . Data , 0 , values . Size * sizeof ( float ) ) ; }
static int values_offset = 0 ;
static int values_offset = 0 ;
if ( ! paus e)
if ( animat e)
{
{
static float refresh_time = ImGui : : GetTime ( ) ; // Create dummy data at fixed 60 hz rate for the demo
static float refresh_time = ImGui : : GetTime ( ) ; // Create dummy data at fixed 60 hz rate for the demo
for ( ; ImGui : : GetTime ( ) > refresh_time + 1.0f / 60.0f ; refresh_time + = 1.0f / 60.0f )
for ( ; ImGui : : GetTime ( ) > refresh_time + 1.0f / 60.0f ; refresh_time + = 1.0f / 60.0f )
@ -724,12 +726,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
phase + = 0.10f * values_offset ;
phase + = 0.10f * values_offset ;
}
}
}
}
ImGui : : PlotLines ( " ##Lines " , values . Data , values . Size , values_offset , " avg 0.0 " , - 1.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
ImGui : : PlotLines ( " Lines " , values . Data , values . Size , values_offset , " avg 0.0 " , - 1.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
ImGui : : SameLine ( 0 , ImGui : : GetStyle ( ) . ItemInnerSpacing . x ) ;
ImGui : : BeginGroup ( ) ;
ImGui : : Text ( " Lines " ) ;
ImGui : : Checkbox ( " pause " , & pause ) ;
ImGui : : EndGroup ( ) ;
ImGui : : PlotHistogram ( " Histogram " , arr , IM_ARRAYSIZE ( arr ) , 0 , NULL , 0.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
ImGui : : PlotHistogram ( " Histogram " , arr , IM_ARRAYSIZE ( arr ) , 0 , NULL , 0.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
// Use functions to generate output
// Use functions to generate output
@ -747,6 +744,26 @@ void ImGui::ShowTestWindow(bool* p_opened)
float ( * func ) ( void * , int ) = ( func_type = = 0 ) ? Funcs : : Sin : Funcs : : Saw ;
float ( * func ) ( void * , int ) = ( func_type = = 0 ) ? Funcs : : Sin : Funcs : : Saw ;
ImGui : : PlotLines ( " Lines " , func , NULL , display_count , 0 , NULL , - 1.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
ImGui : : PlotLines ( " Lines " , func , NULL , display_count , 0 , NULL , - 1.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
ImGui : : PlotHistogram ( " Histogram " , func , NULL , display_count , 0 , NULL , - 1.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
ImGui : : PlotHistogram ( " Histogram " , func , NULL , display_count , 0 , NULL , - 1.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
ImGui : : Separator ( ) ;
// Animate a simple progress bar
static float progress = 0.0f , progress_dir = 1.0f ;
if ( animate )
{
progress + = progress_dir * 0.4f * ImGui : : GetIO ( ) . DeltaTime ;
if ( progress > = + 1.1f ) { progress = + 1.1f ; progress_dir * = - 1.0f ; }
if ( progress < = - 0.1f ) { progress = - 0.1f ; progress_dir * = - 1.0f ; }
}
// Typically we would use ImVec2(-1.0f,0.0f) to use all available width, or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
ImGui : : ProgressBar ( progress , ImVec2 ( 0.0f , 0.0f ) ) ;
ImGui : : SameLine ( 0.0f , ImGui : : GetStyle ( ) . ItemInnerSpacing . x ) ;
ImGui : : Text ( " Progress Bar " ) ;
float progress_saturated = ( progress < 0.0f ) ? 0.0f : ( progress > 1.0f ) ? 1.0f : progress ;
char buf [ 32 ] ;
sprintf ( buf , " %d/%d " , ( int ) ( progress_saturated * 1753 ) , 1753 ) ;
ImGui : : ProgressBar ( progress , ImVec2 ( 0.f , 0.f ) , buf ) ;
}
}
if ( ImGui : : CollapsingHeader ( " Layout " ) )
if ( ImGui : : CollapsingHeader ( " Layout " ) )