@ -325,7 +325,7 @@ void ImGui::LabelTextV(const char* label, const char* fmt, va_list args)
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
const ImGuiStyle & style = g . Style ;
const ImGuiStyle & style = g . Style ;
const float w = Calc ItemWidth( ) ;
const float w = GetNext ItemWidth( ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImRect value_bb ( window - > DC . CursorPos , window - > DC . CursorPos + ImVec2 ( w , label_size . y + style . FramePadding . y * 2 ) ) ;
const ImRect value_bb ( window - > DC . CursorPos , window - > DC . CursorPos + ImVec2 ( w , label_size . y + style . FramePadding . y * 2 ) ) ;
@ -1089,7 +1089,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
const ImGuiStyle & style = g . Style ;
const ImGuiStyle & style = g . Style ;
ImVec2 pos = window - > DC . CursorPos ;
ImVec2 pos = window - > DC . CursorPos ;
ImVec2 size = CalcItemSize ( size_arg , Calc ItemWidth( ) , g . FontSize + style . FramePadding . y * 2.0f ) ;
ImVec2 size = CalcItemSize ( size_arg , GetNext ItemWidth( ) , g . FontSize + style . FramePadding . y * 2.0f ) ;
ImRect bb ( pos , pos + size ) ;
ImRect bb ( pos , pos + size ) ;
ItemSize ( size , style . FramePadding . y ) ;
ItemSize ( size , style . FramePadding . y ) ;
if ( ! ItemAdd ( bb , 0 ) )
if ( ! ItemAdd ( bb , 0 ) )
@ -1353,7 +1353,8 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
const float arrow_size = ( flags & ImGuiComboFlags_NoArrowButton ) ? 0.0f : GetFrameHeight ( ) ;
const float arrow_size = ( flags & ImGuiComboFlags_NoArrowButton ) ? 0.0f : GetFrameHeight ( ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const float w = ( flags & ImGuiComboFlags_NoPreview ) ? arrow_size : CalcItemWidth ( ) ;
const float expected_w = GetNextItemWidth ( ) ;
const float w = ( flags & ImGuiComboFlags_NoPreview ) ? arrow_size : expected_w ;
const ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + ImVec2 ( w , label_size . y + style . FramePadding . y * 2.0f ) ) ;
const ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + ImVec2 ( w , label_size . y + style . FramePadding . y * 2.0f ) ) ;
const ImRect total_bb ( frame_bb . Min , frame_bb . Max + ImVec2 ( label_size . x > 0.0f ? style . ItemInnerSpacing . x + label_size . x : 0.0f , 0.0f ) ) ;
const ImRect total_bb ( frame_bb . Min , frame_bb . Max + ImVec2 ( label_size . x > 0.0f ? style . ItemInnerSpacing . x + label_size . x : 0.0f , 0.0f ) ) ;
ItemSize ( total_bb , style . FramePadding . y ) ;
ItemSize ( total_bb , style . FramePadding . y ) ;
@ -1978,7 +1979,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
const ImGuiStyle & style = g . Style ;
const ImGuiStyle & style = g . Style ;
const ImGuiID id = window - > GetID ( label ) ;
const ImGuiID id = window - > GetID ( label ) ;
const float w = Calc ItemWidth( ) ;
const float w = GetNext ItemWidth( ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + ImVec2 ( w , label_size . y + style . FramePadding . y * 2.0f ) ) ;
const ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + ImVec2 ( w , label_size . y + style . FramePadding . y * 2.0f ) ) ;
@ -2052,7 +2053,7 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* v, int
bool value_changed = false ;
bool value_changed = false ;
BeginGroup ( ) ;
BeginGroup ( ) ;
PushID ( label ) ;
PushID ( label ) ;
PushMultiItemsWidths ( components );
PushMultiItemsWidths ( components , GetNextItemWidth ( ) );
size_t type_size = GDataTypeInfo [ data_type ] . Size ;
size_t type_size = GDataTypeInfo [ data_type ] . Size ;
for ( int i = 0 ; i < components ; i + + )
for ( int i = 0 ; i < components ; i + + )
{
{
@ -2099,7 +2100,7 @@ bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_cu
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
PushID ( label ) ;
PushID ( label ) ;
BeginGroup ( ) ;
BeginGroup ( ) ;
PushMultiItemsWidths ( 2 );
PushMultiItemsWidths ( 2 , GetNextItemWidth ( ) );
bool value_changed = DragFloat ( " ##min " , v_current_min , v_speed , ( v_min > = v_max ) ? - FLT_MAX : v_min , ( v_min > = v_max ) ? * v_current_max : ImMin ( v_max , * v_current_max ) , format , power ) ;
bool value_changed = DragFloat ( " ##min " , v_current_min , v_speed , ( v_min > = v_max ) ? - FLT_MAX : v_min , ( v_min > = v_max ) ? * v_current_max : ImMin ( v_max , * v_current_max ) , format , power ) ;
PopItemWidth ( ) ;
PopItemWidth ( ) ;
@ -2144,7 +2145,7 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
PushID ( label ) ;
PushID ( label ) ;
BeginGroup ( ) ;
BeginGroup ( ) ;
PushMultiItemsWidths ( 2 );
PushMultiItemsWidths ( 2 , GetNextItemWidth ( ) );
bool value_changed = DragInt ( " ##min " , v_current_min , v_speed , ( v_min > = v_max ) ? INT_MIN : v_min , ( v_min > = v_max ) ? * v_current_max : ImMin ( v_max , * v_current_max ) , format ) ;
bool value_changed = DragInt ( " ##min " , v_current_min , v_speed , ( v_min > = v_max ) ? INT_MIN : v_min , ( v_min > = v_max ) ? * v_current_max : ImMin ( v_max , * v_current_max ) , format ) ;
PopItemWidth ( ) ;
PopItemWidth ( ) ;
@ -2422,7 +2423,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, co
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
const ImGuiStyle & style = g . Style ;
const ImGuiStyle & style = g . Style ;
const ImGuiID id = window - > GetID ( label ) ;
const ImGuiID id = window - > GetID ( label ) ;
const float w = Calc ItemWidth( ) ;
const float w = GetNext ItemWidth( ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + ImVec2 ( w , label_size . y + style . FramePadding . y * 2.0f ) ) ;
const ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + ImVec2 ( w , label_size . y + style . FramePadding . y * 2.0f ) ) ;
@ -2501,7 +2502,7 @@ bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, i
bool value_changed = false ;
bool value_changed = false ;
BeginGroup ( ) ;
BeginGroup ( ) ;
PushID ( label ) ;
PushID ( label ) ;
PushMultiItemsWidths ( components );
PushMultiItemsWidths ( components , GetNextItemWidth ( ) );
size_t type_size = GDataTypeInfo [ data_type ] . Size ;
size_t type_size = GDataTypeInfo [ data_type ] . Size ;
for ( int i = 0 ; i < components ; i + + )
for ( int i = 0 ; i < components ; i + + )
{
{
@ -2790,10 +2791,9 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p
BeginGroup ( ) ; // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
BeginGroup ( ) ; // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
PushID ( label ) ;
PushID ( label ) ;
PushItemWidth( ImMax ( 1.0f , Calc ItemWidth( ) - ( button_size + style . ItemInnerSpacing . x ) * 2 ) ) ;
SetNextItemWidth( ImMax ( 1.0f , GetNext ItemWidth( ) - ( button_size + style . ItemInnerSpacing . x ) * 2 ) ) ;
if ( InputText ( " " , buf , IM_ARRAYSIZE ( buf ) , flags ) ) // PushId(label) + "" gives us the expected ID from outside point of view
if ( InputText ( " " , buf , IM_ARRAYSIZE ( buf ) , flags ) ) // PushId(label) + "" gives us the expected ID from outside point of view
value_changed = DataTypeApplyOpFromText ( buf , g . InputTextState . InitialTextA . Data , data_type , data_ptr , format ) ;
value_changed = DataTypeApplyOpFromText ( buf , g . InputTextState . InitialTextA . Data , data_type , data_ptr , format ) ;
PopItemWidth ( ) ;
// Step buttons
// Step buttons
const ImVec2 backup_frame_padding = style . FramePadding ;
const ImVec2 backup_frame_padding = style . FramePadding ;
@ -2839,7 +2839,7 @@ bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* v, in
bool value_changed = false ;
bool value_changed = false ;
BeginGroup ( ) ;
BeginGroup ( ) ;
PushID ( label ) ;
PushID ( label ) ;
PushMultiItemsWidths ( components );
PushMultiItemsWidths ( components , GetNextItemWidth ( ) );
size_t type_size = GDataTypeInfo [ data_type ] . Size ;
size_t type_size = GDataTypeInfo [ data_type ] . Size ;
for ( int i = 0 ; i < components ; i + + )
for ( int i = 0 ; i < components ; i + + )
{
{
@ -3289,7 +3289,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
BeginGroup ( ) ;
BeginGroup ( ) ;
const ImGuiID id = window - > GetID ( label ) ;
const ImGuiID id = window - > GetID ( label ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
ImVec2 size = CalcItemSize ( size_arg , Calc ItemWidth( ) , ( is_multiline ? GetTextLineHeight ( ) * 8.0f : label_size . y ) + style . FramePadding . y * 2.0f ) ; // Arbitrary default of 8 lines high for multi-line
ImVec2 size = CalcItemSize ( size_arg , GetNext ItemWidth( ) , ( is_multiline ? GetTextLineHeight ( ) * 8.0f : label_size . y ) + style . FramePadding . y * 2.0f ) ; // Arbitrary default of 8 lines high for multi-line
const ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + size ) ;
const ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + size ) ;
const ImRect total_bb ( frame_bb . Min , frame_bb . Max + ImVec2 ( label_size . x > 0.0f ? ( style . ItemInnerSpacing . x + label_size . x ) : 0.0f , 0.0f ) ) ;
const ImRect total_bb ( frame_bb . Min , frame_bb . Max + ImVec2 ( label_size . x > 0.0f ? ( style . ItemInnerSpacing . x + label_size . x ) : 0.0f , 0.0f ) ) ;
@ -4047,7 +4047,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
const ImGuiStyle & style = g . Style ;
const ImGuiStyle & style = g . Style ;
const float square_sz = GetFrameHeight ( ) ;
const float square_sz = GetFrameHeight ( ) ;
const float w_extra = ( flags & ImGuiColorEditFlags_NoSmallPreview ) ? 0.0f : ( square_sz + style . ItemInnerSpacing . x ) ;
const float w_extra = ( flags & ImGuiColorEditFlags_NoSmallPreview ) ? 0.0f : ( square_sz + style . ItemInnerSpacing . x ) ;
const float w_items_all = Calc ItemWidth( ) - w_extra ;
const float w_items_all = GetNext ItemWidth( ) - w_extra ;
const char * label_display_end = FindRenderedTextEnd ( label ) ;
const char * label_display_end = FindRenderedTextEnd ( label ) ;
BeginGroup ( ) ;
BeginGroup ( ) ;
@ -4112,13 +4112,11 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
} ;
} ;
const int fmt_idx = hide_prefix ? 0 : ( flags & ImGuiColorEditFlags_DisplayHSV ) ? 2 : 1 ;
const int fmt_idx = hide_prefix ? 0 : ( flags & ImGuiColorEditFlags_DisplayHSV ) ? 2 : 1 ;
PushItemWidth ( w_item_one ) ;
for ( int n = 0 ; n < components ; n + + )
for ( int n = 0 ; n < components ; n + + )
{
{
if ( n > 0 )
if ( n > 0 )
SameLine ( 0 , style . ItemInnerSpacing . x ) ;
SameLine ( 0 , style . ItemInnerSpacing . x ) ;
if ( n + 1 = = components )
SetNextItemWidth ( ( n + 1 < components ) ? w_item_one : w_item_last ) ;
PushItemWidth ( w_item_last ) ;
if ( flags & ImGuiColorEditFlags_Float )
if ( flags & ImGuiColorEditFlags_Float )
{
{
value_changed | = DragFloat ( ids [ n ] , & f [ n ] , 1.0f / 255.0f , 0.0f , hdr ? 0.0f : 1.0f , fmt_table_float [ fmt_idx ] [ n ] ) ;
value_changed | = DragFloat ( ids [ n ] , & f [ n ] , 1.0f / 255.0f , 0.0f , hdr ? 0.0f : 1.0f , fmt_table_float [ fmt_idx ] [ n ] ) ;
@ -4131,8 +4129,6 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
if ( ! ( flags & ImGuiColorEditFlags_NoOptions ) )
if ( ! ( flags & ImGuiColorEditFlags_NoOptions ) )
OpenPopupOnItemClick ( " context " ) ;
OpenPopupOnItemClick ( " context " ) ;
}
}
PopItemWidth ( ) ;
PopItemWidth ( ) ;
}
}
else if ( ( flags & ImGuiColorEditFlags_DisplayHex ) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 )
else if ( ( flags & ImGuiColorEditFlags_DisplayHex ) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 )
{
{
@ -4142,7 +4138,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
ImFormatString ( buf , IM_ARRAYSIZE ( buf ) , " #%02X%02X%02X%02X " , ImClamp ( i [ 0 ] , 0 , 255 ) , ImClamp ( i [ 1 ] , 0 , 255 ) , ImClamp ( i [ 2 ] , 0 , 255 ) , ImClamp ( i [ 3 ] , 0 , 255 ) ) ;
ImFormatString ( buf , IM_ARRAYSIZE ( buf ) , " #%02X%02X%02X%02X " , ImClamp ( i [ 0 ] , 0 , 255 ) , ImClamp ( i [ 1 ] , 0 , 255 ) , ImClamp ( i [ 2 ] , 0 , 255 ) , ImClamp ( i [ 3 ] , 0 , 255 ) ) ;
else
else
ImFormatString ( buf , IM_ARRAYSIZE ( buf ) , " #%02X%02X%02X " , ImClamp ( i [ 0 ] , 0 , 255 ) , ImClamp ( i [ 1 ] , 0 , 255 ) , ImClamp ( i [ 2 ] , 0 , 255 ) ) ;
ImFormatString ( buf , IM_ARRAYSIZE ( buf ) , " #%02X%02X%02X " , ImClamp ( i [ 0 ] , 0 , 255 ) , ImClamp ( i [ 1 ] , 0 , 255 ) , ImClamp ( i [ 2 ] , 0 , 255 ) ) ;
Push ItemWidth( w_items_all ) ;
SetNext ItemWidth( w_items_all ) ;
if ( InputText ( " ##Text " , buf , IM_ARRAYSIZE ( buf ) , ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase ) )
if ( InputText ( " ##Text " , buf , IM_ARRAYSIZE ( buf ) , ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase ) )
{
{
value_changed = true ;
value_changed = true ;
@ -4157,7 +4153,6 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
}
}
if ( ! ( flags & ImGuiColorEditFlags_NoOptions ) )
if ( ! ( flags & ImGuiColorEditFlags_NoOptions ) )
OpenPopupOnItemClick ( " context " ) ;
OpenPopupOnItemClick ( " context " ) ;
PopItemWidth ( ) ;
}
}
ImGuiWindow * picker_active_window = NULL ;
ImGuiWindow * picker_active_window = NULL ;
@ -4190,9 +4185,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
}
}
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar ;
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar ;
ImGuiColorEditFlags picker_flags = ( flags_untouched & picker_flags_to_forward ) | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf ;
ImGuiColorEditFlags picker_flags = ( flags_untouched & picker_flags_to_forward ) | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf ;
Push ItemWidth( square_sz * 12.0f ) ; // Use 256 + bar sizes?
SetNext ItemWidth( square_sz * 12.0f ) ; // Use 256 + bar sizes?
value_changed | = ColorPicker4 ( " ##picker " , col , picker_flags , & g . ColorPickerRef . x ) ;
value_changed | = ColorPicker4 ( " ##picker " , col , picker_flags , & g . ColorPickerRef . x ) ;
PopItemWidth ( ) ;
EndPopup ( ) ;
EndPopup ( ) ;
}
}
}
}
@ -4360,7 +4354,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
ImVec2 picker_pos = window - > DC . CursorPos ;
ImVec2 picker_pos = window - > DC . CursorPos ;
float square_sz = GetFrameHeight ( ) ;
float square_sz = GetFrameHeight ( ) ;
float bars_width = square_sz ; // Arbitrary smallish width of Hue/Alpha picking bars
float bars_width = square_sz ; // Arbitrary smallish width of Hue/Alpha picking bars
float sv_picker_size = ImMax ( bars_width * 1 , Calc ItemWidth( ) - ( alpha_bar ? 2 : 1 ) * ( bars_width + style . ItemInnerSpacing . x ) ) ; // Saturation/Value picking box
float sv_picker_size = ImMax ( bars_width * 1 , GetNext ItemWidth( ) - ( alpha_bar ? 2 : 1 ) * ( bars_width + style . ItemInnerSpacing . x ) ) ; // Saturation/Value picking box
float bar0_pos_x = picker_pos . x + sv_picker_size + style . ItemInnerSpacing . x ;
float bar0_pos_x = picker_pos . x + sv_picker_size + style . ItemInnerSpacing . x ;
float bar1_pos_x = bar0_pos_x + bars_width + style . ItemInnerSpacing . x ;
float bar1_pos_x = bar0_pos_x + bars_width + style . ItemInnerSpacing . x ;
float bars_triangles_half_sz = ( float ) ( int ) ( bars_width * 0.20f ) ;
float bars_triangles_half_sz = ( float ) ( int ) ( bars_width * 0.20f ) ;
@ -5458,7 +5452,7 @@ bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg)
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
// Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar.
// Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar.
ImVec2 size = CalcItemSize ( size_arg , Calc ItemWidth( ) , GetTextLineHeightWithSpacing ( ) * 7.4f + style . ItemSpacing . y ) ;
ImVec2 size = CalcItemSize ( size_arg , GetNext ItemWidth( ) , GetTextLineHeightWithSpacing ( ) * 7.4f + style . ItemSpacing . y ) ;
ImVec2 frame_size = ImVec2 ( size . x , ImMax ( size . y , label_size . y ) ) ;
ImVec2 frame_size = ImVec2 ( size . x , ImMax ( size . y , label_size . y ) ) ;
ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + frame_size ) ;
ImRect frame_bb ( window - > DC . CursorPos , window - > DC . CursorPos + frame_size ) ;
ImRect bb ( frame_bb . Min , frame_bb . Max + ImVec2 ( label_size . x > 0.0f ? style . ItemInnerSpacing . x + label_size . x : 0.0f , 0.0f ) ) ;
ImRect bb ( frame_bb . Min , frame_bb . Max + ImVec2 ( label_size . x > 0.0f ? style . ItemInnerSpacing . x + label_size . x : 0.0f , 0.0f ) ) ;
@ -5575,7 +5569,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
const ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
if ( frame_size . x = = 0.0f )
if ( frame_size . x = = 0.0f )
frame_size . x = Calc ItemWidth( ) ;
frame_size . x = GetNext ItemWidth( ) ;
if ( frame_size . y = = 0.0f )
if ( frame_size . y = = 0.0f )
frame_size . y = label_size . y + ( style . FramePadding . y * 2 ) ;
frame_size . y = label_size . y + ( style . FramePadding . y * 2 ) ;