@ -542,13 +542,10 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui : : TreePop ( ) ;
}
static bool my_toggle = false ;
static int clicked = 0 ;
if ( ImGui : : Button ( " Button " ) )
{
printf ( " Clicked \n " ) ;
my_toggle = ! my_toggle ;
}
if ( my_toggle )
clicked + + ;
if ( clicked & 1 )
{
ImGui : : SameLine ( ) ;
ImGui : : Text ( " Thanks for clicking me! " ) ;
@ -902,7 +899,7 @@ void ImGui::ShowTestWindow(bool* p_open)
}
}
if ( ImGui : : CollapsingHeader ( " Graph s widgets" ) )
if ( ImGui : : CollapsingHeader ( " Plot s widgets" ) )
{
static bool animate = true ;
ImGui : : Checkbox ( " Animate " , & animate ) ;
@ -914,16 +911,16 @@ void ImGui::ShowTestWindow(bool* p_open)
// Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float and the sizeof() of your structure in the Stride parameter.
static float values [ 90 ] = { 0 } ;
static int values_offset = 0 ;
if ( animate )
static float refresh_time = 0.0f ;
if ( ! animate | | refresh_time = = 0.0f )
refresh_time = ImGui : : GetTime ( ) ;
while ( 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 )
{
static float phase = 0.0f ;
values [ values_offset ] = cosf ( phase ) ;
values_offset = ( values_offset + 1 ) % IM_ARRAYSIZE ( values ) ;
phase + = 0.10f * values_offset ;
}
static float phase = 0.0f ;
values [ values_offset ] = cosf ( phase ) ;
values_offset = ( values_offset + 1 ) % IM_ARRAYSIZE ( values ) ;
phase + = 0.10f * values_offset ;
refresh_time + = 1.0f / 60.0f ;
}
ImGui : : PlotLines ( " Lines " , values , IM_ARRAYSIZE ( values ) , values_offset , " avg 0.0 " , - 1.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
ImGui : : PlotHistogram ( " Histogram " , arr , IM_ARRAYSIZE ( arr ) , 0 , NULL , 0.0f , 1.0f , ImVec2 ( 0 , 80 ) ) ;
@ -933,7 +930,7 @@ void ImGui::ShowTestWindow(bool* p_open)
struct Funcs
{
static float Sin ( void * , int i ) { return sinf ( i * 0.1f ) ; }
static float Saw ( void * , int i ) { return ( i & 1 ) ? 1.0f : 0 .0f; }
static float Saw ( void * , int i ) { return ( i & 1 ) ? 1.0f : - 1 .0f; }
} ;
static int func_type = 0 , display_count = 70 ;
ImGui : : Separator ( ) ;
@ -1458,9 +1455,11 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui : : OpenPopup ( " Stacked 1 " ) ;
if ( ImGui : : BeginPopupModal ( " Stacked 1 " ) )
{
ImGui : : Text ( " Hello from Stacked The First " ) ;
ImGui : : Text ( " Hello from Stacked The First \n Using style.Colors[ImGuiCol_ModalWindowDarkening] for darkening. " ) ;
static int item = 1 ;
ImGui : : Combo ( " Combo " , & item , " aaaa \0 bbbb \0 cccc \0 dddd \0 eeee \0 \0 " ) ;
if ( ImGui : : Button ( " Another one.. " ) )
if ( ImGui : : Button ( " A dd another modal .." ) )
ImGui : : OpenPopup ( " Stacked 2 " ) ;
if ( ImGui : : BeginPopupModal ( " Stacked 2 " ) )
{
@ -1617,7 +1616,7 @@ void ImGui::ShowTestWindow(bool* p_open)
}
bool node_open = ImGui : : TreeNode ( " Tree within single cell " ) ;
ImGui : : SameLine ( ) ; ShowHelpMarker ( " NB: Tree node must be poped before ending the cell. \n There's no storage of state per-cell." ) ;
ImGui : : SameLine ( ) ; ShowHelpMarker ( " NB: Tree node must be poped before ending the cell. There's no storage of state per-cell." ) ;
if ( node_open )
{
ImGui : : Columns ( 2 , " tree items " ) ;
@ -1645,8 +1644,42 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui : : BulletText ( " %s " , lines [ i ] ) ;
}
if ( ImGui : : CollapsingHeader ( " Keyboard, Mouse & Focus" ) )
if ( ImGui : : CollapsingHeader ( " Inputs & Focus" ) )
{
ImGuiIO & io = ImGui : : GetIO ( ) ;
ImGui : : Checkbox ( " io.MouseDrawCursor " , & io . MouseDrawCursor ) ;
ImGui : : SameLine ( ) ; ShowHelpMarker ( " Request ImGui to render a mouse cursor for you in software. Note that a mouse cursor rendered via regular GPU rendering will feel more laggy than hardware cursor, but will be more in sync with your other visuals. " ) ;
ImGui : : Text ( " WantCaptureMouse: %d " , io . WantCaptureMouse ) ;
ImGui : : Text ( " WantCaptureKeyboard: %d " , io . WantCaptureKeyboard ) ;
ImGui : : Text ( " WantTextInput: %d " , io . WantTextInput ) ;
if ( ImGui : : TreeNode ( " Keyboard & Mouse State " ) )
{
ImGui : : Text ( " Mouse pos: (%g, %g) " , io . MousePos . x , io . MousePos . y ) ;
ImGui : : Text ( " Mouse down: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + ) if ( io . MouseDownDuration [ i ] > = 0.0f ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " b%d (%.02f secs) " , i , io . MouseDownDuration [ i ] ) ; }
ImGui : : Text ( " Mouse clicked: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + ) if ( ImGui : : IsMouseClicked ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " b%d " , i ) ; }
ImGui : : Text ( " Mouse dbl-clicked: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + ) if ( ImGui : : IsMouseDoubleClicked ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " b%d " , i ) ; }
ImGui : : Text ( " Mouse released: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + ) if ( ImGui : : IsMouseReleased ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " b%d " , i ) ; }
ImGui : : Text ( " Mouse wheel: %.1f " , io . MouseWheel ) ;
ImGui : : Text ( " Keys down: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . KeysDown ) ; i + + ) if ( io . KeysDownDuration [ i ] > = 0.0f ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " %d (%.02f secs) " , i , io . KeysDownDuration [ i ] ) ; }
ImGui : : Text ( " Keys pressed: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . KeysDown ) ; i + + ) if ( ImGui : : IsKeyPressed ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " %d " , i ) ; }
ImGui : : Text ( " Keys release: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . KeysDown ) ; i + + ) if ( ImGui : : IsKeyReleased ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " %d " , i ) ; }
ImGui : : Text ( " Keys mods: %s%s%s%s " , io . KeyCtrl ? " CTRL " : " " , io . KeyShift ? " SHIFT " : " " , io . KeyAlt ? " ALT " : " " , io . KeySuper ? " SUPER " : " " ) ;
ImGui : : Button ( " Hovering me sets the \n keyboard capture flag " ) ;
if ( ImGui : : IsItemHovered ( ) )
ImGui : : CaptureKeyboardFromApp ( true ) ;
ImGui : : SameLine ( ) ;
ImGui : : Button ( " Holding me clears the \n the keyboard capture flag " ) ;
if ( ImGui : : IsItemActive ( ) )
ImGui : : CaptureKeyboardFromApp ( false ) ;
ImGui : : TreePop ( ) ;
}
if ( ImGui : : TreeNode ( " Tabbing " ) )
{
ImGui : : Text ( " Use TAB/SHIFT+TAB to cycle through keyboard editable fields. " ) ;
@ -1700,52 +1733,20 @@ void ImGui::ShowTestWindow(bool* p_open)
// Draw a line between the button and the mouse cursor
ImDrawList * draw_list = ImGui : : GetWindowDrawList ( ) ;
draw_list - > PushClipRectFullScreen ( ) ;
draw_list - > AddLine ( ImGui : : CalcItemRectClosestPoint ( ImGui: : GetIO ( ) . MousePos , true , - 2.0f ) , ImGui: : GetIO ( ) . MousePos , ImColor ( ImGui : : GetStyle ( ) . Colors [ ImGuiCol_Button ] ) , 4.0f ) ;
draw_list - > AddLine ( ImGui : : CalcItemRectClosestPoint ( io . MousePos , true , - 2.0f ) , io . MousePos , ImColor ( ImGui : : GetStyle ( ) . Colors [ ImGuiCol_Button ] ) , 4.0f ) ;
draw_list - > PopClipRect ( ) ;
ImVec2 value_raw = ImGui : : GetMouseDragDelta ( 0 , 0.0f ) ;
ImVec2 value_with_lock_threshold = ImGui : : GetMouseDragDelta ( 0 ) ;
ImVec2 mouse_delta = ImGui: : GetIO ( ) . MouseDelta ;
ImVec2 mouse_delta = io . MouseDelta ;
ImGui : : SameLine ( ) ; ImGui : : Text ( " Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f), MouseDelta (%.1f, %.1f) " , value_raw . x , value_raw . y , value_with_lock_threshold . x , value_with_lock_threshold . y , mouse_delta . x , mouse_delta . y ) ;
}
ImGui : : TreePop ( ) ;
}
if ( ImGui : : TreeNode ( " Keyboard & Mouse State " ) )
{
ImGuiIO & io = ImGui : : GetIO ( ) ;
ImGui : : Text ( " MousePos: (%g, %g) " , io . MousePos . x , io . MousePos . y ) ;
ImGui : : Text ( " Mouse down: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + ) if ( io . MouseDownDuration [ i ] > = 0.0f ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " b%d (%.02f secs) " , i , io . MouseDownDuration [ i ] ) ; }
ImGui : : Text ( " Mouse clicked: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + ) if ( ImGui : : IsMouseClicked ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " b%d " , i ) ; }
ImGui : : Text ( " Mouse dbl-clicked: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + ) if ( ImGui : : IsMouseDoubleClicked ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " b%d " , i ) ; }
ImGui : : Text ( " Mouse released: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + ) if ( ImGui : : IsMouseReleased ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " b%d " , i ) ; }
ImGui : : Text ( " MouseWheel: %.1f " , io . MouseWheel ) ;
ImGui : : Text ( " Keys down: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . KeysDown ) ; i + + ) if ( io . KeysDownDuration [ i ] > = 0.0f ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " %d (%.02f secs) " , i , io . KeysDownDuration [ i ] ) ; }
ImGui : : Text ( " Keys pressed: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . KeysDown ) ; i + + ) if ( ImGui : : IsKeyPressed ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " %d " , i ) ; }
ImGui : : Text ( " Keys release: " ) ; for ( int i = 0 ; i < IM_ARRAYSIZE ( io . KeysDown ) ; i + + ) if ( ImGui : : IsKeyReleased ( i ) ) { ImGui : : SameLine ( ) ; ImGui : : Text ( " %d " , i ) ; }
ImGui : : Text ( " KeyMods: %s%s%s%s " , io . KeyCtrl ? " CTRL " : " " , io . KeyShift ? " SHIFT " : " " , io . KeyAlt ? " ALT " : " " , io . KeySuper ? " SUPER " : " " ) ;
ImGui : : Text ( " WantCaptureMouse: %s " , io . WantCaptureMouse ? " true " : " false " ) ;
ImGui : : Text ( " WantCaptureKeyboard: %s " , io . WantCaptureKeyboard ? " true " : " false " ) ;
ImGui : : Text ( " WantTextInput: %s " , io . WantTextInput ? " true " : " false " ) ;
ImGui : : Button ( " Hovering me sets the \n keyboard capture flag " ) ;
if ( ImGui : : IsItemHovered ( ) )
ImGui : : CaptureKeyboardFromApp ( true ) ;
ImGui : : SameLine ( ) ;
ImGui : : Button ( " Holding me clears the \n the keyboard capture flag " ) ;
if ( ImGui : : IsItemActive ( ) )
ImGui : : CaptureKeyboardFromApp ( false ) ;
ImGui : : TreePop ( ) ;
}
if ( ImGui : : TreeNode ( " Mouse cursors " ) )
{
ImGui : : TextWrapped ( " Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. You can also set io.MouseDrawCursor to ask ImGui to render the cursor for you in software. " ) ;
ImGui : : Checkbox ( " io.MouseDrawCursor " , & ImGui : : GetIO ( ) . MouseDrawCursor ) ;
ImGui : : Text ( " Hover to see mouse cursors: " ) ;
ImGui : : SameLine ( ) ; ShowHelpMarker ( " Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. If software cursor rendering (io.MouseDrawCursor) is set ImGui will draw the right cursor for you, otherwise your backend needs to handle it. " ) ;
for ( int i = 0 ; i < ImGuiMouseCursor_Count_ ; i + + )
{
char label [ 32 ] ;
@ -2014,9 +2015,11 @@ static void ShowExampleMenuFile()
ImGui : : EndChild ( ) ;
static float f = 0.5f ;
static int n = 0 ;
static bool b = true ;
ImGui : : SliderFloat ( " Value " , & f , 0.0f , 1.0f ) ;
ImGui : : InputFloat ( " Input " , & f , 0.1f ) ;
ImGui : : Combo ( " Combo " , & n , " Yes \0 No \0 Maybe \0 \0 " ) ;
ImGui : : Checkbox ( " Check " , & b ) ;
ImGui : : EndMenu ( ) ;
}
if ( ImGui : : BeginMenu ( " Colors " ) )