@ -2999,15 +2999,7 @@ void ImGui::PopStyleColor(int count)
}
}
struct ImGuiStyleVarInfo
{
ImGuiDataType Type ;
ImU32 Count ;
ImU32 Offset ;
void * GetVarPtr ( ImGuiStyle * style ) const { return ( void * ) ( ( unsigned char * ) style + Offset ) ; }
} ;
static const ImGuiStyleVarInfo GStyleVarInfo [ ] =
static const ImGuiDataVarInfo GStyleVarInfo [ ] =
{
{ ImGuiDataType_Float , 1 , ( ImU32 ) IM_OFFSETOF ( ImGuiStyle , Alpha ) } , // ImGuiStyleVar_Alpha
{ ImGuiDataType_Float , 1 , ( ImU32 ) IM_OFFSETOF ( ImGuiStyle , DisabledAlpha ) } , // ImGuiStyleVar_DisabledAlpha
@ -3039,39 +3031,39 @@ static const ImGuiStyleVarInfo GStyleVarInfo[] =
{ ImGuiDataType_Float , 2 , ( ImU32 ) IM_OFFSETOF ( ImGuiStyle , SeparatorTextPadding ) } , // ImGuiStyleVar_SeparatorTextPadding
} ;
static const ImGuiStyleVarInfo * GetStyleVarInfo ( ImGuiStyleVar idx )
const ImGuiDataVarInfo * ImGui : : GetStyleVarInfo ( ImGuiStyleVar idx )
{
IM_ASSERT ( idx > = 0 & & idx < ImGuiStyleVar_COUNT ) ;
IM_ASSERT ( IM_ARRAYSIZE ( GStyleVarInfo ) = = ImGuiStyleVar_COUNT ) ;
IM_STATIC_ ASSERT ( IM_ARRAYSIZE ( GStyleVarInfo ) = = ImGuiStyleVar_COUNT ) ;
return & GStyleVarInfo [ idx ] ;
}
void ImGui : : PushStyleVar ( ImGuiStyleVar idx , float val )
{
const ImGuiStyleVarInfo * var_info = GetStyleVarInfo ( idx ) ;
ImGuiContext & g = * GImGui ;
const ImGuiDataVarInfo * var_info = GetStyleVarInfo ( idx ) ;
if ( var_info - > Type = = ImGuiDataType_Float & & var_info - > Count = = 1 )
{
ImGuiContext & g = * GImGui ;
float * pvar = ( float * ) var_info - > GetVarPtr ( & g . Style ) ;
g . StyleVarStack . push_back ( ImGuiStyleMod ( idx , * pvar ) ) ;
* pvar = val ;
return ;
}
IM_ASSERT ( 0 & & " Called PushStyleVar() float variant but variable is not a float ! " ) ;
IM_ASSERT_USER_ERROR ( 0 , " Called PushStyleVar() variant with wrong type !" ) ;
}
void ImGui : : PushStyleVar ( ImGuiStyleVar idx , const ImVec2 & val )
{
const ImGuiStyleVarInfo * var_info = GetStyleVarInfo ( idx ) ;
ImGuiContext & g = * GImGui ;
const ImGuiDataVarInfo * var_info = GetStyleVarInfo ( idx ) ;
if ( var_info - > Type = = ImGuiDataType_Float & & var_info - > Count = = 2 )
{
ImGuiContext & g = * GImGui ;
ImVec2 * pvar = ( ImVec2 * ) var_info - > GetVarPtr ( & g . Style ) ;
g . StyleVarStack . push_back ( ImGuiStyleMod ( idx , * pvar ) ) ;
* pvar = val ;
return ;
}
IM_ASSERT ( 0 & & " Called PushStyleVar() ImVec2 variant but variable is not a ImVec2 ! " ) ;
IM_ASSERT_USER_ERROR ( 0 , " Called PushStyleVar() variant with wrong type !" ) ;
}
void ImGui : : PopStyleVar ( int count )
@ -3086,7 +3078,7 @@ void ImGui::PopStyleVar(int count)
{
// We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it.
ImGuiStyleMod & backup = g . StyleVarStack . back ( ) ;
const ImGuiStyle VarInfo * info = GetStyleVarInfo ( backup . VarIdx ) ;
const ImGuiData VarInfo * info = GetStyleVarInfo ( backup . VarIdx ) ;
void * data = info - > GetVarPtr ( & g . Style ) ;
if ( info - > Type = = ImGuiDataType_Float & & info - > Count = = 1 ) { ( ( float * ) data ) [ 0 ] = backup . BackupFloat [ 0 ] ; }
else if ( info - > Type = = ImGuiDataType_Float & & info - > Count = = 2 ) { ( ( float * ) data ) [ 0 ] = backup . BackupFloat [ 0 ] ; ( ( float * ) data ) [ 1 ] = backup . BackupFloat [ 1 ] ; }
@ -14223,7 +14215,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
SameLine ( ) ; CheckboxFlags ( " Focus " , & g . DebugLogFlags , ImGuiDebugLogFlags_EventFocus ) ;
SameLine ( ) ; CheckboxFlags ( " Popup " , & g . DebugLogFlags , ImGuiDebugLogFlags_EventPopup ) ;
SameLine ( ) ; CheckboxFlags ( " Nav " , & g . DebugLogFlags , ImGuiDebugLogFlags_EventNav ) ;
SameLine ( ) ; if ( CheckboxFlags ( " Clipper " , & g . DebugLogFlags , ImGuiDebugLogFlags_EventClipper ) ) { g . DebugLogClipperAutoDisableFrames = 2 ; } ; if ( IsItemHovered ( ) ) SetTooltip ( " Clipper log auto-disabled after 2 frames " ) ;
SameLine ( ) ; if ( CheckboxFlags ( " Clipper " , & g . DebugLogFlags , ImGuiDebugLogFlags_EventClipper ) ) { g . DebugLogClipperAutoDisableFrames = 2 ; } if ( IsItemHovered ( ) ) SetTooltip ( " Clipper log auto-disabled after 2 frames " ) ;
SameLine ( ) ; CheckboxFlags ( " IO " , & g . DebugLogFlags , ImGuiDebugLogFlags_EventIO ) ;
if ( SmallButton ( " Clear " ) )