@ -1743,7 +1743,7 @@ static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
window - > DC . CursorPosPrevLine . y = window - > DC . CursorPos . y - line_height ; // Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage.
window - > DC . PrevLineHeight = ( line_height - GImGui - > Style . ItemSpacing . y ) ; // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
if ( window - > DC . ColumnsSet )
window - > DC . ColumnsSet - > C olumnsC ellMinY = window - > DC . CursorPos . y ; // Setting this so that cell Y position are set properly
window - > DC . ColumnsSet - > C ellMinY = window - > DC . CursorPos . y ; // Setting this so that cell Y position are set properly
}
// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1
@ -5731,7 +5731,7 @@ ImVec2 ImGui::GetContentRegionMax()
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
ImVec2 mx = window - > ContentsRegionRect . Max ;
if ( window - > DC . ColumnsSet )
mx . x = GetColumnOffset ( window - > DC . ColumnsSet - > C olumnsC urrent + 1 ) - window - > WindowPadding . x ;
mx . x = GetColumnOffset ( window - > DC . ColumnsSet - > C urrent + 1 ) - window - > WindowPadding . x ;
return mx ;
}
@ -10571,7 +10571,7 @@ void ImGui::Separator()
if ( window - > DC . ColumnsSet )
{
PushColumnClipRect ( ) ;
window - > DC . ColumnsSet - > C olumnsC ellMinY = window - > DC . CursorPos . y ;
window - > DC . ColumnsSet - > C ellMinY = window - > DC . CursorPos . y ;
}
}
@ -10792,22 +10792,22 @@ void ImGui::NextColumn()
PopClipRect ( ) ;
ImGuiColumnsSet * columns = window - > DC . ColumnsSet ;
columns - > C olumnsC ellMaxY = ImMax ( columns - > Columns CellMaxY, window - > DC . CursorPos . y ) ;
if ( + + columns - > C olumnsC urrent < columns - > Columns Count)
columns - > C ellMaxY = ImMax ( columns - > CellMaxY, window - > DC . CursorPos . y ) ;
if ( + + columns - > C urrent < columns - > Count)
{
// Columns 1+ cancel out IndentX
window - > DC . ColumnsOffsetX = GetColumnOffset ( columns - > C olumnsC urrent) - window - > DC . IndentX + g . Style . ItemSpacing . x ;
window - > DrawList - > ChannelsSetCurrent ( columns - > C olumnsC urrent) ;
window - > DC . ColumnsOffsetX = GetColumnOffset ( columns - > C urrent) - window - > DC . IndentX + g . Style . ItemSpacing . x ;
window - > DrawList - > ChannelsSetCurrent ( columns - > C urrent) ;
}
else
{
window - > DC . ColumnsOffsetX = 0.0f ;
columns - > C olumnsC urrent = 0 ;
columns - > C olumnsC ellMinY = columns - > Columns CellMaxY;
columns - > C urrent = 0 ;
columns - > C ellMinY = columns - > CellMaxY;
window - > DrawList - > ChannelsSetCurrent ( 0 ) ;
}
window - > DC . CursorPos . x = ( float ) ( int ) ( window - > Pos . x + window - > DC . IndentX + window - > DC . ColumnsOffsetX ) ;
window - > DC . CursorPos . y = columns - > C olumnsC ellMinY;
window - > DC . CursorPos . y = columns - > C ellMinY;
window - > DC . CurrentLineHeight = 0.0f ;
window - > DC . CurrentLineTextBaseOffset = 0.0f ;
@ -10818,23 +10818,23 @@ void ImGui::NextColumn()
int ImGui : : GetColumnIndex ( )
{
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
return window - > DC . ColumnsSet ? window - > DC . ColumnsSet - > C olumnsC urrent : 0 ;
return window - > DC . ColumnsSet ? window - > DC . ColumnsSet - > C urrent : 0 ;
}
int ImGui : : GetColumnsCount ( )
{
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
return window - > DC . ColumnsSet ? window - > DC . ColumnsSet - > Co lumnsCo unt : 1 ;
return window - > DC . ColumnsSet ? window - > DC . ColumnsSet - > Co unt : 1 ;
}
static float OffsetNormToPixels ( const ImGuiColumnsSet * columns , float offset_norm )
{
return offset_norm * ( columns - > Columns MaxX - columns - > Columns MinX) ;
return offset_norm * ( columns - > MaxX - columns - > MinX) ;
}
static float PixelsToOffsetNorm ( const ImGuiColumnsSet * columns , float offset )
{
return ( offset - columns - > Columns MinX) / ( columns - > Columns MaxX - columns - > Columns MinX) ;
return ( offset - columns - > MinX) / ( columns - > MaxX - columns - > MinX) ;
}
static float GetDraggedColumnOffset ( ImGuiColumnsSet * columns , int column_index )
@ -10844,11 +10844,11 @@ static float GetDraggedColumnOffset(ImGuiColumnsSet* columns, int column_index)
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
IM_ASSERT ( column_index > 0 ) ; // We cannot drag column 0. If you get this assert you may have a conflict between the ID of your columns and another widgets.
IM_ASSERT ( g . ActiveId = = columns - > ColumnsSetId + ImGuiID ( column_index ) ) ;
IM_ASSERT ( g . ActiveId = = columns - > ID + ImGuiID ( column_index ) ) ;
float x = g . IO . MousePos . x - g . ActiveIdClickOffset . x - window - > Pos . x ;
x = ImMax ( x , ImGui : : GetColumnOffset ( column_index - 1 ) + g . Style . ColumnsMinSpacing ) ;
if ( ( columns - > Columns Flags & ImGuiColumnsFlags_NoPreserveWidths ) )
if ( ( columns - > Flags & ImGuiColumnsFlags_NoPreserveWidths ) )
x = ImMin ( x , ImGui : : GetColumnOffset ( column_index + 1 ) - g . Style . ColumnsMinSpacing ) ;
return x ;
@ -10861,7 +10861,7 @@ float ImGui::GetColumnOffset(int column_index)
IM_ASSERT ( columns ! = NULL ) ;
if ( column_index < 0 )
column_index = columns - > C olumnsC urrent;
column_index = columns - > C urrent;
/*
if ( g . ActiveId )
@ -10873,9 +10873,9 @@ float ImGui::GetColumnOffset(int column_index)
}
*/
IM_ASSERT ( column_index < columns - > Columns Data . Size ) ;
const float t = columns - > Columns Data [ column_index ] . OffsetNorm ;
const float x_offset = ImLerp ( columns - > Columns MinX, columns - > Columns MaxX, t ) ;
IM_ASSERT ( column_index < columns - > Columns . Size ) ;
const float t = columns - > Columns [ column_index ] . OffsetNorm ;
const float x_offset = ImLerp ( columns - > MinX, columns - > MaxX, t ) ;
return x_offset ;
}
@ -10887,20 +10887,20 @@ void ImGui::SetColumnOffset(int column_index, float offset)
IM_ASSERT ( columns ! = NULL ) ;
if ( column_index < 0 )
column_index = columns - > C olumnsC urrent;
column_index = columns - > C urrent;
IM_ASSERT ( column_index < columns - > Columns Data . Size ) ;
IM_ASSERT ( column_index < columns - > Columns . Size ) ;
const bool preserve_width = ! ( columns - > Columns Flags & ImGuiColumnsFlags_NoPreserveWidths ) & & ( column_index < columns - > Columns Count- 1 ) ;
const bool preserve_width = ! ( columns - > Flags & ImGuiColumnsFlags_NoPreserveWidths ) & & ( column_index < columns - > Count- 1 ) ;
const float width = preserve_width ? GetColumnWidth ( column_index ) : 0.0f ;
if ( ! ( columns - > Columns Flags & ImGuiColumnsFlags_NoForceWithinWindow ) )
offset = ImMin ( offset , columns - > Columns MaxX - g . Style . ColumnsMinSpacing * ( columns - > Columns Count - column_index ) ) ;
if ( ! ( columns - > Flags & ImGuiColumnsFlags_NoForceWithinWindow ) )
offset = ImMin ( offset , columns - > MaxX - g . Style . ColumnsMinSpacing * ( columns - > Count - column_index ) ) ;
const float offset_norm = PixelsToOffsetNorm ( columns , offset ) ;
const ImGuiID column_id = columns - > ColumnsSetId + ImGuiID ( column_index ) ;
const ImGuiID column_id = columns - > ID + ImGuiID ( column_index ) ;
window - > DC . StateStorage - > SetFloat ( column_id , offset_norm ) ;
columns - > Columns Data [ column_index ] . OffsetNorm = offset_norm ;
columns - > Columns [ column_index ] . OffsetNorm = offset_norm ;
if ( preserve_width )
SetColumnOffset ( column_index + 1 , offset + ImMax ( g . Style . ColumnsMinSpacing , width ) ) ;
@ -10913,8 +10913,8 @@ float ImGui::GetColumnWidth(int column_index)
IM_ASSERT ( columns ! = NULL ) ;
if ( column_index < 0 )
column_index = columns - > C olumnsC urrent;
return OffsetNormToPixels ( columns , columns - > Columns Data [ column_index + 1 ] . OffsetNorm - columns - > Columns Data [ column_index ] . OffsetNorm ) ;
column_index = columns - > C urrent;
return OffsetNormToPixels ( columns , columns - > Columns [ column_index + 1 ] . OffsetNorm - columns - > Columns [ column_index ] . OffsetNorm ) ;
}
void ImGui : : SetColumnWidth ( int column_index , float width )
@ -10924,7 +10924,7 @@ void ImGui::SetColumnWidth(int column_index, float width)
IM_ASSERT ( columns ! = NULL ) ;
if ( column_index < 0 )
column_index = columns - > C olumnsC urrent;
column_index = columns - > C urrent;
SetColumnOffset ( column_index + 1 , GetColumnOffset ( column_index ) + width ) ;
}
@ -10933,20 +10933,20 @@ void ImGui::PushColumnClipRect(int column_index)
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
ImGuiColumnsSet * columns = window - > DC . ColumnsSet ;
if ( column_index < 0 )
column_index = columns - > C olumnsC urrent;
column_index = columns - > C urrent;
PushClipRect ( columns - > Columns Data [ column_index ] . ClipRect . Min , columns - > Columns Data [ column_index ] . ClipRect . Max , false ) ;
PushClipRect ( columns - > Columns [ column_index ] . ClipRect . Min , columns - > Columns [ column_index ] . ClipRect . Max , false ) ;
}
static ImGuiColumnsSet * FindOrAddColumnsSet ( ImGuiWindow * window , ImGuiID id )
{
for ( int n = 0 ; n < window - > DC . ColumnsSets . Size ; n + + )
if ( window - > DC . ColumnsSets [ n ] . ColumnsSetId = = id )
if ( window - > DC . ColumnsSets [ n ] . ID = = id )
return & window - > DC . ColumnsSets [ n ] ;
window - > DC . ColumnsSets . push_back ( ImGuiColumnsSet ( ) ) ;
ImGuiColumnsSet * columns = & window - > DC . ColumnsSets . back ( ) ;
columns - > ColumnsSetId = id ;
columns - > ID = id ;
return columns ;
}
@ -10965,35 +10965,35 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
PopID ( ) ;
ImGuiColumnsSet * columns = FindOrAddColumnsSet ( window , id ) ;
IM_ASSERT ( columns - > ColumnsSetId = = id ) ;
IM_ASSERT ( columns - > ID = = id ) ;
window - > DC . ColumnsSet = columns ;
// Set state for first column
columns - > C olumnsC urrent = 0 ;
columns - > Co lumnsCo unt = columns_count ;
columns - > Columns Flags = flags ;
columns - > C urrent = 0 ;
columns - > Co unt = columns_count ;
columns - > Flags = flags ;
const float content_region_width = ( window - > SizeContentsExplicit . x ! = 0.0f ) ? ( window - > SizeContentsExplicit . x ) : ( window - > Size . x - window - > ScrollbarSizes . x ) ;
columns - > Columns MinX = window - > DC . IndentX - g . Style . ItemSpacing . x ; // Lock our horizontal range
columns - > MinX = window - > DC . IndentX - g . Style . ItemSpacing . x ; // Lock our horizontal range
//column->ColumnsMaxX = content_region_width - window->Scroll.x -((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x;
columns - > Columns MaxX = content_region_width - window - > Scroll . x ;
columns - > Columns StartPosY = window - > DC . CursorPos . y ;
columns - > Columns StartMaxPosX = window - > DC . CursorMaxPos . x ;
columns - > C olumnsC ellMinY = columns - > Columns CellMaxY = window - > DC . CursorPos . y ;
columns - > MaxX = content_region_width - window - > Scroll . x ;
columns - > StartPosY = window - > DC . CursorPos . y ;
columns - > StartMaxPosX = window - > DC . CursorMaxPos . x ;
columns - > C ellMinY = columns - > CellMaxY = window - > DC . CursorPos . y ;
window - > DC . ColumnsOffsetX = 0.0f ;
window - > DC . CursorPos . x = ( float ) ( int ) ( window - > Pos . x + window - > DC . IndentX + window - > DC . ColumnsOffsetX ) ;
// Cache column offsets
columns - > Columns Data . resize ( columns_count + 1 ) ;
columns - > Columns . resize ( columns_count + 1 ) ;
for ( int column_index = 0 ; column_index < columns_count + 1 ; column_index + + )
{
const ImGuiID column_id = columns - > ColumnsSetId + ImGuiID ( column_index ) ;
const ImGuiID column_id = columns - > ID + ImGuiID ( column_index ) ;
KeepAliveID ( column_id ) ;
const float default_t = column_index / ( float ) columns_count ;
float t = window - > DC . StateStorage - > GetFloat ( column_id , default_t ) ;
if ( ! ( columns - > Columns Flags & ImGuiColumnsFlags_NoForceWithinWindow ) )
t = ImMin ( t , PixelsToOffsetNorm ( columns , columns - > Columns MaxX - g . Style . ColumnsMinSpacing * ( columns - > Columns Count - column_index ) ) ) ;
columns - > Columns Data [ column_index ] . OffsetNorm = t ;
if ( ! ( columns - > Flags & ImGuiColumnsFlags_NoForceWithinWindow ) )
t = ImMin ( t , PixelsToOffsetNorm ( columns , columns - > MaxX - g . Style . ColumnsMinSpacing * ( columns - > Count - column_index ) ) ) ;
columns - > Columns [ column_index ] . OffsetNorm = t ;
}
// Cache clipping rectangles
@ -11001,11 +11001,11 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
{
float clip_x1 = ImFloor ( 0.5f + window - > Pos . x + GetColumnOffset ( column_index ) - 1.0f ) ;
float clip_x2 = ImFloor ( 0.5f + window - > Pos . x + GetColumnOffset ( column_index + 1 ) - 1.0f ) ;
columns - > Columns Data [ column_index ] . ClipRect = ImRect ( clip_x1 , - FLT_MAX , clip_x2 , + FLT_MAX ) ;
columns - > Columns Data [ column_index ] . ClipRect . ClipWith ( window - > ClipRect ) ;
columns - > Columns [ column_index ] . ClipRect = ImRect ( clip_x1 , - FLT_MAX , clip_x2 , + FLT_MAX ) ;
columns - > Columns [ column_index ] . ClipRect . ClipWith ( window - > ClipRect ) ;
}
window - > DrawList - > ChannelsSplit ( columns - > Co lumnsCo unt) ;
window - > DrawList - > ChannelsSplit ( columns - > Co unt) ;
PushColumnClipRect ( ) ;
PushItemWidth ( GetColumnWidth ( ) * 0.65f ) ;
}
@ -11021,28 +11021,28 @@ void ImGui::EndColumns()
PopClipRect ( ) ;
window - > DrawList - > ChannelsMerge ( ) ;
columns - > C olumnsC ellMaxY = ImMax ( columns - > Columns CellMaxY, window - > DC . CursorPos . y ) ;
window - > DC . CursorPos . y = columns - > C olumnsC ellMaxY;
if ( ! ( columns - > Columns Flags & ImGuiColumnsFlags_GrowParentContentsSize ) )
window - > DC . CursorMaxPos . x = ImMax ( columns - > Columns StartMaxPosX, columns - > Columns MaxX) ; // Restore cursor max pos, as columns don't grow parent
columns - > C ellMaxY = ImMax ( columns - > CellMaxY, window - > DC . CursorPos . y ) ;
window - > DC . CursorPos . y = columns - > C ellMaxY;
if ( ! ( columns - > Flags & ImGuiColumnsFlags_GrowParentContentsSize ) )
window - > DC . CursorMaxPos . x = ImMax ( columns - > StartMaxPosX, columns - > MaxX) ; // Restore cursor max pos, as columns don't grow parent
// Draw columns borders and handle resize
if ( ! ( columns - > Columns Flags & ImGuiColumnsFlags_NoBorder ) & & ! window - > SkipItems )
if ( ! ( columns - > Flags & ImGuiColumnsFlags_NoBorder ) & & ! window - > SkipItems )
{
const float y1 = columns - > Columns StartPosY;
const float y1 = columns - > StartPosY;
const float y2 = window - > DC . CursorPos . y ;
int dragging_column = - 1 ;
for ( int i = 1 ; i < columns - > Co lumnsCo unt; i + + )
for ( int i = 1 ; i < columns - > Co unt; i + + )
{
float x = window - > Pos . x + GetColumnOffset ( i ) ;
const ImGuiID column_id = columns - > ColumnsSetId + ImGuiID ( i ) ;
const ImGuiID column_id = columns - > ID + ImGuiID ( i ) ;
const float column_hw = 4.0f ; // Half-width for interaction
const ImRect column_rect ( ImVec2 ( x - column_hw , y1 ) , ImVec2 ( x + column_hw , y2 ) ) ;
if ( IsClippedEx ( column_rect , column_id , false ) )
continue ;
bool hovered = false , held = false ;
if ( ! ( columns - > Columns Flags & ImGuiColumnsFlags_NoResize ) )
if ( ! ( columns - > Flags & ImGuiColumnsFlags_NoResize ) )
{
ButtonBehavior ( column_rect , column_id , & hovered , & held ) ;
if ( hovered | | held )
@ -11068,7 +11068,7 @@ void ImGui::EndColumns()
}
}
columns - > Columns Data . resize ( 0 ) ;
columns - > Columns . resize ( 0 ) ;
window - > DC . ColumnsSet = NULL ;
window - > DC . ColumnsOffsetX = 0.0f ;
window - > DC . CursorPos . x = ( float ) ( int ) ( window - > Pos . x + window - > DC . IndentX + window - > DC . ColumnsOffsetX ) ;
@ -11080,7 +11080,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
ImGuiWindow * window = GetCurrentWindow ( ) ;
IM_ASSERT ( columns_count > = 1 ) ;
if ( window - > DC . ColumnsSet ! = NULL & & window - > DC . ColumnsSet - > Co lumnsCo unt ! = columns_count )
if ( window - > DC . ColumnsSet ! = NULL & & window - > DC . ColumnsSet - > Co unt ! = columns_count )
EndColumns ( ) ;
ImGuiColumnsFlags flags = ( border ? 0 : ImGuiColumnsFlags_NoBorder ) ;