@ -1240,31 +1240,31 @@ ImGuiStyle::ImGuiStyle()
// Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times.
void ImGuiStyle : : ScaleAllSizes ( float scale_factor )
{
WindowPadding = ImFloor ( WindowPadding * scale_factor ) ;
WindowRounding = ImFloor ( WindowRounding * scale_factor ) ;
WindowMinSize = ImFloor ( WindowMinSize * scale_factor ) ;
ChildRounding = ImFloor ( ChildRounding * scale_factor ) ;
PopupRounding = ImFloor ( PopupRounding * scale_factor ) ;
FramePadding = ImFloor ( FramePadding * scale_factor ) ;
FrameRounding = ImFloor ( FrameRounding * scale_factor ) ;
ItemSpacing = ImFloor ( ItemSpacing * scale_factor ) ;
ItemInnerSpacing = ImFloor ( ItemInnerSpacing * scale_factor ) ;
CellPadding = ImFloor ( CellPadding * scale_factor ) ;
TouchExtraPadding = ImFloor ( TouchExtraPadding * scale_factor ) ;
IndentSpacing = ImFloor ( IndentSpacing * scale_factor ) ;
ColumnsMinSpacing = ImFloor ( ColumnsMinSpacing * scale_factor ) ;
ScrollbarSize = ImFloor ( ScrollbarSize * scale_factor ) ;
ScrollbarRounding = ImFloor ( ScrollbarRounding * scale_factor ) ;
GrabMinSize = ImFloor ( GrabMinSize * scale_factor ) ;
GrabRounding = ImFloor ( GrabRounding * scale_factor ) ;
LogSliderDeadzone = ImFloor ( LogSliderDeadzone * scale_factor ) ;
TabRounding = ImFloor ( TabRounding * scale_factor ) ;
TabMinWidthForCloseButton = ( TabMinWidthForCloseButton ! = FLT_MAX ) ? ImFloor ( TabMinWidthForCloseButton * scale_factor ) : FLT_MAX ;
SeparatorTextPadding = ImFloor ( SeparatorTextPadding * scale_factor ) ;
DockingSeparatorSize = ImFloor ( DockingSeparatorSize * scale_factor ) ;
DisplayWindowPadding = ImFloor ( DisplayWindowPadding * scale_factor ) ;
DisplaySafeAreaPadding = ImFloor ( DisplaySafeAreaPadding * scale_factor ) ;
MouseCursorScale = ImFloor ( MouseCursorScale * scale_factor ) ;
WindowPadding = ImTrunc ( WindowPadding * scale_factor ) ;
WindowRounding = ImTrunc ( WindowRounding * scale_factor ) ;
WindowMinSize = ImTrunc ( WindowMinSize * scale_factor ) ;
ChildRounding = ImTrunc ( ChildRounding * scale_factor ) ;
PopupRounding = ImTrunc ( PopupRounding * scale_factor ) ;
FramePadding = ImTrunc ( FramePadding * scale_factor ) ;
FrameRounding = ImTrunc ( FrameRounding * scale_factor ) ;
ItemSpacing = ImTrunc ( ItemSpacing * scale_factor ) ;
ItemInnerSpacing = ImTrunc ( ItemInnerSpacing * scale_factor ) ;
CellPadding = ImTrunc ( CellPadding * scale_factor ) ;
TouchExtraPadding = ImTrunc ( TouchExtraPadding * scale_factor ) ;
IndentSpacing = ImTrunc ( IndentSpacing * scale_factor ) ;
ColumnsMinSpacing = ImTrunc ( ColumnsMinSpacing * scale_factor ) ;
ScrollbarSize = ImTrunc ( ScrollbarSize * scale_factor ) ;
ScrollbarRounding = ImTrunc ( ScrollbarRounding * scale_factor ) ;
GrabMinSize = ImTrunc ( GrabMinSize * scale_factor ) ;
GrabRounding = ImTrunc ( GrabRounding * scale_factor ) ;
LogSliderDeadzone = ImTrunc ( LogSliderDeadzone * scale_factor ) ;
TabRounding = ImTrunc ( TabRounding * scale_factor ) ;
TabMinWidthForCloseButton = ( TabMinWidthForCloseButton ! = FLT_MAX ) ? ImTrunc ( TabMinWidthForCloseButton * scale_factor ) : FLT_MAX ;
SeparatorTextPadding = ImTrunc ( SeparatorTextPadding * scale_factor ) ;
DockingSeparatorSize = ImTrunc ( DockingSeparatorSize * scale_factor ) ;
DisplayWindowPadding = ImTrunc ( DisplayWindowPadding * scale_factor ) ;
DisplaySafeAreaPadding = ImTrunc ( DisplaySafeAreaPadding * scale_factor ) ;
MouseCursorScale = ImTrunc ( MouseCursorScale * scale_factor ) ;
}
ImGuiIO : : ImGuiIO ( )
@ -1565,7 +1565,7 @@ void ImGuiIO::AddMousePosEvent(float x, float y)
return ;
// Apply same flooring as UpdateMouseInputs()
ImVec2 pos ( ( x > - FLT_MAX ) ? ImFloorSigned ( x ) : x , ( y > - FLT_MAX ) ? ImFloorSigned ( y ) : y ) ;
ImVec2 pos ( ( x > - FLT_MAX ) ? ImFloor ( x ) : x , ( y > - FLT_MAX ) ? ImFloor ( y ) : y ) ;
// Filter duplicate
const ImGuiInputEvent * latest_event = FindLatestInputEvent ( & g , ImGuiInputEventType_MousePos ) ;
@ -1977,21 +1977,9 @@ int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args)
void ImFormatStringToTempBuffer ( const char * * out_buf , const char * * out_buf_end , const char * fmt , . . . )
{
ImGuiContext & g = * GImGui ;
va_list args ;
va_start ( args , fmt ) ;
if ( fmt [ 0 ] = = ' % ' & & fmt [ 1 ] = = ' s ' & & fmt [ 2 ] = = 0 )
{
const char * buf = va_arg ( args , const char * ) ; // Skip formatting when using "%s"
* out_buf = buf ;
if ( out_buf_end ) { * out_buf_end = buf + strlen ( buf ) ; }
}
else
{
int buf_len = ImFormatStringV ( g . TempBuffer . Data , g . TempBuffer . Size , fmt , args ) ;
* out_buf = g . TempBuffer . Data ;
if ( out_buf_end ) { * out_buf_end = g . TempBuffer . Data + buf_len ; }
}
ImFormatStringToTempBufferV ( out_buf , out_buf_end , fmt , args ) ;
va_end ( args ) ;
}
@ -2004,6 +1992,13 @@ void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end,
* out_buf = buf ;
if ( out_buf_end ) { * out_buf_end = buf + strlen ( buf ) ; }
}
else if ( fmt [ 0 ] = = ' % ' & & fmt [ 1 ] = = ' . ' & & fmt [ 2 ] = = ' * ' & & fmt [ 3 ] = = ' s ' & & fmt [ 4 ] = = 0 )
{
int buf_len = va_arg ( args , int ) ; // Skip formatting when using "%.*s"
const char * buf = va_arg ( args , const char * ) ;
* out_buf = buf ;
* out_buf_end = buf + buf_len ; // Disallow not passing 'out_buf_end' here. User is expected to use it.
}
else
{
int buf_len = ImFormatStringV ( g . TempBuffer . Data , g . TempBuffer . Size , fmt , args ) ;
@ -2096,8 +2091,9 @@ ImFileHandle ImFileOpen(const char* filename, const char* mode)
// Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32!
const int filename_wsize = : : MultiByteToWideChar ( CP_UTF8 , 0 , filename , - 1 , NULL , 0 ) ;
const int mode_wsize = : : MultiByteToWideChar ( CP_UTF8 , 0 , mode , - 1 , NULL , 0 ) ;
ImVector < wchar_t > buf ;
buf . resize ( filename_wsize + mode_wsize ) ;
ImGuiContext & g = * GImGui ;
g . TempBuffer . reserve ( ( filename_wsize + mode_wsize ) * sizeof ( wchar_t ) ) ;
wchar_t * buf = ( wchar_t * ) ( void * ) g . TempBuffer . Data ;
: : MultiByteToWideChar ( CP_UTF8 , 0 , filename , - 1 , ( wchar_t * ) & buf [ 0 ] , filename_wsize ) ;
: : MultiByteToWideChar ( CP_UTF8 , 0 , mode , - 1 , ( wchar_t * ) & buf [ filename_wsize ] , mode_wsize ) ;
return : : _wfopen ( ( const wchar_t * ) & buf [ 0 ] , ( const wchar_t * ) & buf [ filename_wsize ] ) ;
@ -3491,7 +3487,7 @@ void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, con
// Render text, render ellipsis
RenderTextClippedEx ( draw_list , pos_min , ImVec2 ( clip_max_x , pos_max . y ) , text , text_end_ellipsis , & text_size , ImVec2 ( 0.0f , 0.0f ) ) ;
ImVec2 ellipsis_pos = ImFloor ( ImVec2 ( pos_min . x + text_size_clipped_x , pos_min . y ) ) ;
ImVec2 ellipsis_pos = ImTrunc ( ImVec2 ( pos_min . x + text_size_clipped_x , pos_min . y ) ) ;
if ( ellipsis_pos . x + ellipsis_width < = ellipsis_max_x )
for ( int i = 0 ; i < font - > EllipsisCharCount ; i + + , ellipsis_pos . x + = font - > EllipsisCharStep * font_scale )
font - > RenderChar ( draw_list , font_size , ellipsis_pos , GetColorU32 ( ImGuiCol_Text ) , font - > EllipsisChar ) ;
@ -4323,17 +4319,24 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
// IM_ALLOC() == ImGui::MemAlloc()
void * ImGui : : MemAlloc ( size_t size )
{
void * ptr = ( * GImAllocatorAllocFunc ) ( size , GImAllocatorUserData ) ;
if ( ImGuiContext * ctx = GImGui )
{
ctx - > IO . MetricsActiveAllocations + + ;
return ( * GImAllocatorAllocFunc ) ( size , GImAllocatorUserData ) ;
//printf("[%05d] MemAlloc(%d) -> 0x%p\n", ctx->FrameCount, size, ptr);
}
return ptr ;
}
// IM_FREE() == ImGui::MemFree()
void ImGui : : MemFree ( void * ptr )
{
if ( ptr )
if ( ptr ! = NULL )
if ( ImGuiContext * ctx = GImGui )
{
ctx - > IO . MetricsActiveAllocations - - ;
//printf("[%05d] MemFree(0x%p)\n", ctx->FrameCount, ptr);
}
return ( * GImAllocatorFreeFunc ) ( ptr , GImAllocatorUserData ) ;
}
@ -4624,9 +4627,9 @@ static void ScaleWindow(ImGuiWindow* window, float scale)
{
ImVec2 origin = window - > Viewport - > Pos ;
window - > Pos = ImFloor ( ( window - > Pos - origin ) * scale + origin ) ;
window - > Size = ImFloor ( window - > Size * scale ) ;
window - > SizeFull = ImFloor ( window - > SizeFull * scale ) ;
window - > ContentSize = ImFloor ( window - > ContentSize * scale ) ;
window - > Size = ImTrunc ( window - > Size * scale ) ;
window - > SizeFull = ImTrunc ( window - > SizeFull * scale ) ;
window - > ContentSize = ImTrunc ( window - > ContentSize * scale ) ;
}
static bool IsWindowActiveAndVisible ( ImGuiWindow * window )
@ -5337,6 +5340,7 @@ void ImGui::EndFrame()
g . IO . Fonts - > Locked = false ;
// Clear Input data for next frame
g . IO . MousePosPrev = g . IO . MousePos ;
g . IO . AppFocusLost = false ;
g . IO . MouseWheel = g . IO . MouseWheelH = 0.0f ;
g . IO . InputQueueCharacters . resize ( 0 ) ;
@ -5436,7 +5440,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
// FIXME: Investigate using ceilf or e.g.
// - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c
// - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html
text_size . x = IM_FLOOR ( text_size . x + 0.99999f ) ;
text_size . x = IM_TRUNC ( text_size . x + 0.99999f ) ;
return text_size ;
}
@ -5671,7 +5675,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
// Size
const ImVec2 content_avail = GetContentRegionAvail ( ) ;
ImVec2 size = ImFloor ( size_arg ) ;
ImVec2 size = ImTrunc ( size_arg ) ;
const int auto_fit_axises = ( ( size . x = = 0.0f ) ? ( 1 < < ImGuiAxis_X ) : 0x00 ) | ( ( size . y = = 0.0f ) ? ( 1 < < ImGuiAxis_Y ) : 0x00 ) ;
if ( size . x < = 0.0f )
size . x = ImMax ( content_avail . x + size . x , 4.0f ) ; // Arbitrary minimum child size (0.0f causing too many issues)
@ -5827,9 +5831,9 @@ static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settin
window - > ViewportId = settings - > ViewportId ;
window - > ViewportPos = ImVec2 ( settings - > ViewportPos . x , settings - > ViewportPos . y ) ;
}
window - > Pos = ImFloor ( ImVec2 ( settings - > Pos . x + window - > ViewportPos . x , settings - > Pos . y + window - > ViewportPos . y ) ) ;
window - > Pos = ImTrunc ( ImVec2 ( settings - > Pos . x + window - > ViewportPos . x , settings - > Pos . y + window - > ViewportPos . y ) ) ;
if ( settings - > Size . x > 0 & & settings - > Size . y > 0 )
window - > Size = window - > SizeFull = ImFloor ( ImVec2 ( settings - > Size . x , settings - > Size . y ) ) ;
window - > Size = window - > SizeFull = ImTrunc ( ImVec2 ( settings - > Size . x , settings - > Size . y ) ) ;
window - > Collapsed = settings - > Collapsed ;
window - > DockId = settings - > DockId ;
window - > DockOrder = settings - > DockOrder ;
@ -5944,8 +5948,8 @@ static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& s
g . NextWindowData . SizeCallback ( & data ) ;
new_size = data . DesiredSize ;
}
new_size . x = IM_FLOOR ( new_size . x ) ;
new_size . y = IM_FLOOR ( new_size . y ) ;
new_size . x = IM_TRUNC ( new_size . x ) ;
new_size . y = IM_TRUNC ( new_size . y ) ;
}
// Minimum size
@ -5973,10 +5977,10 @@ static void CalcWindowContentSizes(ImGuiWindow* window, ImVec2* content_size_cur
return ;
}
content_size_current - > x = ( window - > ContentSizeExplicit . x ! = 0.0f ) ? window - > ContentSizeExplicit . x : IM_FLOOR ( window - > DC . CursorMaxPos . x - window - > DC . CursorStartPos . x ) ;
content_size_current - > y = ( window - > ContentSizeExplicit . y ! = 0.0f ) ? window - > ContentSizeExplicit . y : IM_FLOOR ( window - > DC . CursorMaxPos . y - window - > DC . CursorStartPos . y ) ;
content_size_ideal - > x = ( window - > ContentSizeExplicit . x ! = 0.0f ) ? window - > ContentSizeExplicit . x : IM_FLOOR ( ImMax ( window - > DC . CursorMaxPos . x , window - > DC . IdealMaxPos . x ) - window - > DC . CursorStartPos . x ) ;
content_size_ideal - > y = ( window - > ContentSizeExplicit . y ! = 0.0f ) ? window - > ContentSizeExplicit . y : IM_FLOOR ( ImMax ( window - > DC . CursorMaxPos . y , window - > DC . IdealMaxPos . y ) - window - > DC . CursorStartPos . y ) ;
content_size_current - > x = ( window - > ContentSizeExplicit . x ! = 0.0f ) ? window - > ContentSizeExplicit . x : IM_TRUNC ( window - > DC . CursorMaxPos . x - window - > DC . CursorStartPos . x ) ;
content_size_current - > y = ( window - > ContentSizeExplicit . y ! = 0.0f ) ? window - > ContentSizeExplicit . y : IM_TRUNC ( window - > DC . CursorMaxPos . y - window - > DC . CursorStartPos . y ) ;
content_size_ideal - > x = ( window - > ContentSizeExplicit . x ! = 0.0f ) ? window - > ContentSizeExplicit . x : IM_TRUNC ( ImMax ( window - > DC . CursorMaxPos . x , window - > DC . IdealMaxPos . x ) - window - > DC . CursorStartPos . x ) ;
content_size_ideal - > y = ( window - > ContentSizeExplicit . y ! = 0.0f ) ? window - > ContentSizeExplicit . y : IM_TRUNC ( ImMax ( window - > DC . CursorMaxPos . y , window - > DC . IdealMaxPos . y ) - window - > DC . CursorStartPos . y ) ;
}
static ImVec2 CalcWindowAutoFitSize ( ImGuiWindow * window , const ImVec2 & size_contents )
@ -6133,8 +6137,8 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
bool ret_auto_fit = false ;
const int resize_border_count = g . IO . ConfigWindowsResizeFromEdges ? 4 : 0 ;
const float grip_draw_size = IM_FLOOR ( ImMax ( g . FontSize * 1.35f , window - > WindowRounding + 1.0f + g . FontSize * 0.2f ) ) ;
const float grip_hover_inner_size = IM_FLOOR ( grip_draw_size * 0.75f ) ;
const float grip_draw_size = IM_TRUNC ( ImMax ( g . FontSize * 1.35f , window - > WindowRounding + 1.0f + g . FontSize * 0.2f ) ) ;
const float grip_hover_inner_size = IM_TRUNC ( grip_draw_size * 0.75f ) ;
const float grip_hover_outer_size = g . IO . ConfigWindowsResizeFromEdges ? WINDOWS_HOVER_PADDING : 0.0f ;
ImRect clamp_rect = visibility_rect ;
@ -6250,7 +6254,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
g . NavWindowingToggleLayer = false ;
g . NavDisableMouseHover = true ;
resize_grip_col [ 0 ] = GetColorU32 ( ImGuiCol_ResizeGripActive ) ;
ImVec2 accum_floored = ImFloor ( g . NavWindowingAccumDeltaSize ) ;
ImVec2 accum_floored = ImTrunc ( g . NavWindowingAccumDeltaSize ) ;
if ( accum_floored . x ! = 0.0f | | accum_floored . y ! = 0.0f )
{
// FIXME-NAV: Should store and accumulate into a separate size buffer to handle sizing constraints properly, right now a constraint will make us stuck.
@ -6268,7 +6272,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
}
if ( pos_target . x ! = FLT_MAX )
{
window - > Pos = ImFloor ( pos_target ) ;
window - > Pos = ImTrunc ( pos_target ) ;
MarkIniSettingsDirty ( window ) ;
}
@ -6408,8 +6412,8 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
ImGuiDockNode * node = window - > DockNode ;
if ( window - > DockIsActive & & node - > IsHiddenTabBar ( ) & & ! node - > IsNoTabBar ( ) )
{
float unhide_sz_draw = ImFloor ( g . FontSize * 0.70f ) ;
float unhide_sz_hit = ImFloor ( g . FontSize * 0.55f ) ;
float unhide_sz_draw = ImTrunc ( g . FontSize * 0.70f ) ;
float unhide_sz_hit = ImTrunc ( g . FontSize * 0.55f ) ;
ImVec2 p = node - > Pos ;
ImRect r ( p , p + ImVec2 ( unhide_sz_hit , unhide_sz_hit ) ) ;
ImGuiID unhide_id = window - > GetID ( " #UNHIDE " ) ;
@ -7032,7 +7036,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
ClampWindowPos ( window , visibility_rect ) ;
}
}
window - > Pos = ImFloor ( window - > Pos ) ;
window - > Pos = ImTrunc ( window - > Pos ) ;
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
// Large values tend to lead to variety of artifacts and are not recommended.
@ -7074,7 +7078,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
int border_held = - 1 ;
ImU32 resize_grip_col [ 4 ] = { } ;
const int resize_grip_count = g . IO . ConfigWindowsResizeFromEdges ? 2 : 1 ; // Allow resize from lower-left if we have the mouse cursor feedback for it.
const float resize_grip_draw_size = IM_FLOOR ( ImMax ( g . FontSize * 1.10f , window - > WindowRounding + 1.0f + g . FontSize * 0.2f ) ) ;
const float resize_grip_draw_size = IM_TRUNC ( ImMax ( g . FontSize * 1.10f , window - > WindowRounding + 1.0f + g . FontSize * 0.2f ) ) ;
if ( handle_borders_and_resize_grips & & ! window - > Collapsed )
if ( UpdateWindowManualResize ( window , size_auto_fit , & border_held , resize_grip_count , & resize_grip_col [ 0 ] , visibility_rect ) )
use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y = true ;
@ -7155,17 +7159,17 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Affected by window/frame border size. Used by:
// - Begin() initial clip rect
float top_border_size = ( ( ( flags & ImGuiWindowFlags_MenuBar ) | | ! ( flags & ImGuiWindowFlags_NoTitleBar ) ) ? style . FrameBorderSize : window - > WindowBorderSize ) ;
window - > InnerClipRect . Min . x = ImFloorSigned ( 0.5f + window - > InnerRect . Min . x + ImMax ( ImFloor ( window - > WindowPadding . x * 0.5f ) , window - > WindowBorderSize ) ) ;
window - > InnerClipRect . Min . y = ImFloorSigned ( 0.5f + window - > InnerRect . Min . y + top_border_size ) ;
window - > InnerClipRect . Max . x = ImFloorSigned ( 0.5f + window - > InnerRect . Max . x - ImMax ( ImFloor ( window - > WindowPadding . x * 0.5f ) , window - > WindowBorderSize ) ) ;
window - > InnerClipRect . Max . y = ImFloorSigned ( 0.5f + window - > InnerRect . Max . y - window - > WindowBorderSize ) ;
window - > InnerClipRect . Min . x = ImFloor ( 0.5f + window - > InnerRect . Min . x + ImMax ( ImTrunc ( window - > WindowPadding . x * 0.5f ) , window - > WindowBorderSize ) ) ;
window - > InnerClipRect . Min . y = ImFloor ( 0.5f + window - > InnerRect . Min . y + top_border_size ) ;
window - > InnerClipRect . Max . x = ImFloor ( 0.5f + window - > InnerRect . Max . x - ImMax ( ImTrunc ( window - > WindowPadding . x * 0.5f ) , window - > WindowBorderSize ) ) ;
window - > InnerClipRect . Max . y = ImFloor ( 0.5f + window - > InnerRect . Max . y - window - > WindowBorderSize ) ;
window - > InnerClipRect . ClipWithFull ( host_rect ) ;
// Default item width. Make it proportional to window size if window manually resizes
if ( window - > Size . x > 0.0f & & ! ( flags & ImGuiWindowFlags_Tooltip ) & & ! ( flags & ImGuiWindowFlags_AlwaysAutoResize ) )
window - > ItemWidthDefault = ImFloor ( window - > Size . x * 0.65f ) ;
window - > ItemWidthDefault = ImTrunc ( window - > Size . x * 0.65f ) ;
else
window - > ItemWidthDefault = ImFloor ( g . FontSize * 16.0f ) ;
window - > ItemWidthDefault = ImTrunc ( g . FontSize * 16.0f ) ;
// SCROLLING
@ -7227,8 +7231,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
const bool allow_scrollbar_y = ! ( flags & ImGuiWindowFlags_NoScrollbar ) ;
const float work_rect_size_x = ( window - > ContentSizeExplicit . x ! = 0.0f ? window - > ContentSizeExplicit . x : ImMax ( allow_scrollbar_x ? window - > ContentSize . x : 0.0f , window - > Size . x - window - > WindowPadding . x * 2.0f - ( window - > DecoOuterSizeX1 + window - > DecoOuterSizeX2 ) ) ) ;
const float work_rect_size_y = ( window - > ContentSizeExplicit . y ! = 0.0f ? window - > ContentSizeExplicit . y : ImMax ( allow_scrollbar_y ? window - > ContentSize . y : 0.0f , window - > Size . y - window - > WindowPadding . y * 2.0f - ( window - > DecoOuterSizeY1 + window - > DecoOuterSizeY2 ) ) ) ;
window - > WorkRect . Min . x = ImFloor ( window - > InnerRect . Min . x - window - > Scroll . x + ImMax ( window - > WindowPadding . x , window - > WindowBorderSize ) ) ;
window - > WorkRect . Min . y = ImFloor ( window - > InnerRect . Min . y - window - > Scroll . y + ImMax ( window - > WindowPadding . y , window - > WindowBorderSize ) ) ;
window - > WorkRect . Min . x = ImTrunc ( window - > InnerRect . Min . x - window - > Scroll . x + ImMax ( window - > WindowPadding . x , window - > WindowBorderSize ) ) ;
window - > WorkRect . Min . y = ImTrunc ( window - > InnerRect . Min . y - window - > Scroll . y + ImMax ( window - > WindowPadding . y , window - > WindowBorderSize ) ) ;
window - > WorkRect . Max . x = window - > WorkRect . Min . x + work_rect_size_x ;
window - > WorkRect . Max . y = window - > WorkRect . Min . y + work_rect_size_y ;
window - > ParentWorkRect = window - > WorkRect ;
@ -7991,7 +7995,7 @@ void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
// Set
const ImVec2 old_pos = window - > Pos ;
window - > Pos = ImFloor ( pos ) ;
window - > Pos = ImTrunc ( pos ) ;
ImVec2 offset = window - > Pos - old_pos ;
if ( offset . x = = 0.0f & & offset . y = = 0.0f )
return ;
@ -8037,11 +8041,11 @@ void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
if ( size . x < = 0.0f )
window - > AutoFitOnlyGrows = false ;
else
window - > SizeFull . x = IM_FLOOR ( size . x ) ;
window - > SizeFull . x = IM_TRUNC ( size . x ) ;
if ( size . y < = 0.0f )
window - > AutoFitOnlyGrows = false ;
else
window - > SizeFull . y = IM_FLOOR ( size . y ) ;
window - > SizeFull . y = IM_TRUNC ( size . y ) ;
if ( old_size . x ! = window - > SizeFull . x | | old_size . y ! = window - > SizeFull . y )
MarkIniSettingsDirty ( window ) ;
}
@ -8157,7 +8161,7 @@ void ImGui::SetNextWindowContentSize(const ImVec2& size)
{
ImGuiContext & g = * GImGui ;
g . NextWindowData . Flags | = ImGuiNextWindowDataFlags_HasContentSize ;
g . NextWindowData . ContentSizeVal = ImFloor ( size ) ;
g . NextWindowData . ContentSizeVal = ImTrunc ( size ) ;
}
void ImGui : : SetNextWindowScroll ( const ImVec2 & scroll )
@ -9256,7 +9260,7 @@ static void ImGui::UpdateMouseInputs()
// Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well)
if ( IsMousePosValid ( & io . MousePos ) )
io . MousePos = g . MouseLastValidPos = ImFloorSigned ( io . MousePos ) ;
io . MousePos = g . MouseLastValidPos = ImFloor ( io . MousePos ) ;
// If mouse just appeared or disappeared (usually denoted by -FLT_MAX components) we cancel out movement in MouseDelta
if ( IsMousePosValid ( & io . MousePos ) & & IsMousePosValid ( & io . MousePosPrev ) )
@ -9275,7 +9279,6 @@ static void ImGui::UpdateMouseInputs()
if ( io . MouseDelta . x ! = 0.0f | | io . MouseDelta . y ! = 0.0f )
g . NavDisableMouseHover = false ;
io . MousePosPrev = io . MousePos ;
for ( int i = 0 ; i < IM_ARRAYSIZE ( io . MouseDown ) ; i + + )
{
io . MouseClicked [ i ] = io . MouseDown [ i ] & & io . MouseDownDuration [ i ] < 0.0f ;
@ -9415,8 +9418,8 @@ void ImGui::UpdateMouseWheel()
{
const ImVec2 offset = window - > Size * ( 1.0f - scale ) * ( g . IO . MousePos - window - > Pos ) / window - > Size ;
SetWindowPos ( window , window - > Pos + offset , 0 ) ;
window - > Size = ImFloor ( window - > Size * scale ) ;
window - > SizeFull = ImFloor ( window - > SizeFull * scale ) ;
window - > Size = ImTrunc ( window - > Size * scale ) ;
window - > SizeFull = ImTrunc ( window - > SizeFull * scale ) ;
}
return ;
}
@ -9452,14 +9455,14 @@ void ImGui::UpdateMouseWheel()
{
LockWheelingWindow ( window , wheel . x ) ;
float max_step = window - > InnerRect . GetWidth ( ) * 0.67f ;
float scroll_step = ImFloor ( ImMin ( 2 * window - > CalcFontSize ( ) , max_step ) ) ;
float scroll_step = ImTrunc ( ImMin ( 2 * window - > CalcFontSize ( ) , max_step ) ) ;
SetScrollX ( window , window - > Scroll . x - wheel . x * scroll_step ) ;
}
if ( do_scroll [ ImGuiAxis_Y ] )
{
LockWheelingWindow ( window , wheel . y ) ;
float max_step = window - > InnerRect . GetHeight ( ) * 0.67f ;
float scroll_step = ImFloor ( ImMin ( 5 * window - > CalcFontSize ( ) , max_step ) ) ;
float scroll_step = ImTrunc ( ImMin ( 5 * window - > CalcFontSize ( ) , max_step ) ) ;
SetScrollY ( window , window - > Scroll . y - wheel . y * scroll_step ) ;
}
}
@ -10133,8 +10136,8 @@ void ImGui::ItemSize(const ImVec2& size, float text_baseline_y)
//if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
window - > DC . CursorPosPrevLine . x = window - > DC . CursorPos . x + size . x ;
window - > DC . CursorPosPrevLine . y = line_y1 ;
window - > DC . CursorPos . x = IM_FLOOR ( window - > Pos . x + window - > DC . Indent . x + window - > DC . ColumnsOffset . x ) ; // Next line
window - > DC . CursorPos . y = IM_FLOOR ( line_y1 + line_height + g . Style . ItemSpacing . y ) ; // Next line
window - > DC . CursorPos . x = IM_TRUNC ( window - > Pos . x + window - > DC . Indent . x + window - > DC . ColumnsOffset . x ) ; // Next line
window - > DC . CursorPos . y = IM_TRUNC ( line_y1 + line_height + g . Style . ItemSpacing . y ) ; // Next line
window - > DC . CursorMaxPos . x = ImMax ( window - > DC . CursorMaxPos . x , window - > DC . CursorPosPrevLine . x ) ;
window - > DC . CursorMaxPos . y = ImMax ( window - > DC . CursorMaxPos . y , window - > DC . CursorPos . y - g . Style . ItemSpacing . y ) ;
//if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG]
@ -10365,8 +10368,8 @@ void ImGui::PushMultiItemsWidths(int components, float w_full)
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
const ImGuiStyle & style = g . Style ;
const float w_item_one = ImMax ( 1.0f , IM_FLOOR ( ( w_full - ( style . ItemInnerSpacing . x ) * ( components - 1 ) ) / ( float ) components ) ) ;
const float w_item_last = ImMax ( 1.0f , IM_FLOOR ( w_full - ( w_item_one + style . ItemInnerSpacing . x ) * ( components - 1 ) ) ) ;
const float w_item_one = ImMax ( 1.0f , IM_TRUNC ( ( w_full - ( style . ItemInnerSpacing . x ) * ( components - 1 ) ) / ( float ) components ) ) ;
const float w_item_last = ImMax ( 1.0f , IM_TRUNC ( w_full - ( w_item_one + style . ItemInnerSpacing . x ) * ( components - 1 ) ) ) ;
window - > DC . ItemWidthStack . push_back ( window - > DC . ItemWidth ) ; // Backup current width
window - > DC . ItemWidthStack . push_back ( w_item_last ) ;
for ( int i = 0 ; i < components - 2 ; i + + )
@ -10398,7 +10401,7 @@ float ImGui::CalcItemWidth()
float region_max_x = GetContentRegionMaxAbs ( ) . x ;
w = ImMax ( 1.0f , region_max_x - window - > DC . CursorPos . x + w ) ;
}
w = IM_FLOOR ( w ) ;
w = IM_TRUNC ( w ) ;
return w ;
}
@ -10620,7 +10623,7 @@ static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window)
}
scroll [ axis ] = scroll_target - center_ratio * ( window - > SizeFull [ axis ] - decoration_size [ axis ] ) ;
}
scroll [ axis ] = IM_FLOOR ( ImMax ( scroll [ axis ] , 0.0f ) ) ;
scroll [ axis ] = IM_TRUNC ( ImMax ( scroll [ axis ] , 0.0f ) ) ;
if ( ! window - > Collapsed & & ! window - > SkipItems )
scroll [ axis ] = ImMin ( scroll [ axis ] , window - > ScrollMax [ axis ] ) ;
}
@ -10675,7 +10678,7 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui
else if ( ( ( flags & ImGuiScrollFlags_KeepVisibleCenterX ) & & ! fully_visible_x ) | | ( flags & ImGuiScrollFlags_AlwaysCenterX ) )
{
if ( can_be_fully_visible_x )
SetScrollFromPosX ( window , ImFloor ( ( item_rect . Min . x + item_rect . Max . x ) * 0.5f ) - window - > Pos . x , 0.5f ) ;
SetScrollFromPosX ( window , ImTrunc ( ( item_rect . Min . x + item_rect . Max . x ) * 0.5f ) - window - > Pos . x , 0.5f ) ;
else
SetScrollFromPosX ( window , item_rect . Min . x - window - > Pos . x , 0.0f ) ;
}
@ -10690,7 +10693,7 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui
else if ( ( ( flags & ImGuiScrollFlags_KeepVisibleCenterY ) & & ! fully_visible_y ) | | ( flags & ImGuiScrollFlags_AlwaysCenterY ) )
{
if ( can_be_fully_visible_y )
SetScrollFromPosY ( window , ImFloor ( ( item_rect . Min . y + item_rect . Max . y ) * 0.5f ) - window - > Pos . y , 0.5f ) ;
SetScrollFromPosY ( window , ImTrunc ( ( item_rect . Min . y + item_rect . Max . y ) * 0.5f ) - window - > Pos . y , 0.5f ) ;
else
SetScrollFromPosY ( window , item_rect . Min . y - window - > Pos . y , 0.0f ) ;
}
@ -10775,7 +10778,7 @@ void ImGui::SetScrollY(float scroll_y)
void ImGui : : SetScrollFromPosX ( ImGuiWindow * window , float local_x , float center_x_ratio )
{
IM_ASSERT ( center_x_ratio > = 0.0f & & center_x_ratio < = 1.0f ) ;
window - > ScrollTarget . x = IM_FLOOR ( local_x - window - > DecoOuterSizeX1 - window - > DecoInnerSizeX1 + window - > Scroll . x ) ; // Convert local position to scroll offset
window - > ScrollTarget . x = IM_TRUNC ( local_x - window - > DecoOuterSizeX1 - window - > DecoInnerSizeX1 + window - > Scroll . x ) ; // Convert local position to scroll offset
window - > ScrollTargetCenterRatio . x = center_x_ratio ;
window - > ScrollTargetEdgeSnapDist . x = 0.0f ;
}
@ -10783,7 +10786,7 @@ void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x
void ImGui : : SetScrollFromPosY ( ImGuiWindow * window , float local_y , float center_y_ratio )
{
IM_ASSERT ( center_y_ratio > = 0.0f & & center_y_ratio < = 1.0f ) ;
window - > ScrollTarget . y = IM_FLOOR ( local_y - window - > DecoOuterSizeY1 - window - > DecoInnerSizeY1 + window - > Scroll . y ) ; // Convert local position to scroll offset
window - > ScrollTarget . y = IM_TRUNC ( local_y - window - > DecoOuterSizeY1 - window - > DecoInnerSizeY1 + window - > Scroll . y ) ; // Convert local position to scroll offset
window - > ScrollTargetCenterRatio . y = center_y_ratio ;
window - > ScrollTargetEdgeSnapDist . y = 0.0f ;
}
@ -12063,7 +12066,7 @@ static ImVec2 ImGui::NavCalcPreferredRefPos()
}
ImVec2 pos = ImVec2 ( rect_rel . Min . x + ImMin ( g . Style . FramePadding . x * 4 , rect_rel . GetWidth ( ) ) , rect_rel . Max . y - ImMin ( g . Style . FramePadding . y , rect_rel . GetHeight ( ) ) ) ;
ImGuiViewport * viewport = window - > Viewport ;
return ImFloor ( ImClamp ( pos , viewport - > Pos , viewport - > Pos + viewport - > Size ) ) ; // ImFloor () is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta.
return ImTrunc ( ImClamp ( pos , viewport - > Pos , viewport - > Pos + viewport - > Size ) ) ; // ImTrunc () is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta.
}
}
@ -12206,9 +12209,9 @@ static void ImGui::NavUpdate()
if ( window - > DC . NavLayersActiveMask = = 0x00 & & window - > DC . NavWindowHasScrollY & & move_dir ! = ImGuiDir_None )
{
if ( move_dir = = ImGuiDir_Left | | move_dir = = ImGuiDir_Right )
SetScrollX ( window , ImFloor ( window - > Scroll . x + ( ( move_dir = = ImGuiDir_Left ) ? - 1.0f : + 1.0f ) * scroll_speed ) ) ;
SetScrollX ( window , ImTrunc ( window - > Scroll . x + ( ( move_dir = = ImGuiDir_Left ) ? - 1.0f : + 1.0f ) * scroll_speed ) ) ;
if ( move_dir = = ImGuiDir_Up | | move_dir = = ImGuiDir_Down )
SetScrollY ( window , ImFloor ( window - > Scroll . y + ( ( move_dir = = ImGuiDir_Up ) ? - 1.0f : + 1.0f ) * scroll_speed ) ) ;
SetScrollY ( window , ImTrunc ( window - > Scroll . y + ( ( move_dir = = ImGuiDir_Up ) ? - 1.0f : + 1.0f ) * scroll_speed ) ) ;
}
// *Normal* Manual scroll with LStick
@ -12218,9 +12221,9 @@ static void ImGui::NavUpdate()
const ImVec2 scroll_dir = GetKeyMagnitude2d ( ImGuiKey_GamepadLStickLeft , ImGuiKey_GamepadLStickRight , ImGuiKey_GamepadLStickUp , ImGuiKey_GamepadLStickDown ) ;
const float tweak_factor = IsKeyDown ( ImGuiKey_NavGamepadTweakSlow ) ? 1.0f / 10.0f : IsKeyDown ( ImGuiKey_NavGamepadTweakFast ) ? 10.0f : 1.0f ;
if ( scroll_dir . x ! = 0.0f & & window - > ScrollbarX )
SetScrollX ( window , ImFloor ( window - > Scroll . x + scroll_dir . x * scroll_speed * tweak_factor ) ) ;
SetScrollX ( window , ImTrunc ( window - > Scroll . x + scroll_dir . x * scroll_speed * tweak_factor ) ) ;
if ( scroll_dir . y ! = 0.0f )
SetScrollY ( window , ImFloor ( window - > Scroll . y + scroll_dir . y * scroll_speed * tweak_factor ) ) ;
SetScrollY ( window , ImTrunc ( window - > Scroll . y + scroll_dir . y * scroll_speed * tweak_factor ) ) ;
}
}
@ -12912,7 +12915,7 @@ static void ImGui::NavUpdateWindowing()
const float move_step = NAV_MOVE_SPEED * io . DeltaTime * ImMin ( io . DisplayFramebufferScale . x , io . DisplayFramebufferScale . y ) ;
g . NavWindowingAccumDeltaPos + = nav_move_dir * move_step ;
g . NavDisableMouseHover = true ;
ImVec2 accum_floored = ImFloor ( g . NavWindowingAccumDeltaPos ) ;
ImVec2 accum_floored = ImTrunc ( g . NavWindowingAccumDeltaPos ) ;
if ( accum_floored . x ! = 0.0f | | accum_floored . y ! = 0.0f )
{
ImGuiWindow * moving_window = g . NavWindowingTarget - > RootWindowDockTree ;
@ -14343,7 +14346,7 @@ static void ImGui::UpdateViewportsNewFrame()
// FIXME-VIEWPORT: This currently creates a resizing feedback loop when a window is straddling a DPI transition border.
// (Minor: since our sizes do not perfectly linearly scale, deferring the click offset scale until we know the actual window scale ratio may get us slightly more precise mouse positioning.)
//if (g.MovingWindow != NULL && g.MovingWindow->Viewport == viewport)
// g.ActiveIdClickOffset = ImFloor (g.ActiveIdClickOffset * scale_factor);
// g.ActiveIdClickOffset = ImTrunc (g.ActiveIdClickOffset * scale_factor);
}
viewport - > DpiScale = new_dpi_scale ;
}
@ -15744,11 +15747,11 @@ static ImVec2 FixLargeWindowsWhenUndocking(const ImVec2& size, ImGuiViewport* re
return size ;
ImGuiContext & g = * GImGui ;
ImVec2 max_size = ImFloor ( ref_viewport - > WorkSize * 0.90f ) ;
ImVec2 max_size = ImTrunc ( ref_viewport - > WorkSize * 0.90f ) ;
if ( g . ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable )
{
const ImGuiPlatformMonitor * monitor = ImGui : : GetViewportPlatformMonitor ( ref_viewport ) ;
max_size = ImFloor ( monitor - > WorkSize * 0.90f ) ;
max_size = ImTrunc ( monitor - > WorkSize * 0.90f ) ;
}
return ImMin ( size , max_size ) ;
}
@ -17115,12 +17118,12 @@ void ImGui::DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& po
if ( size_new_desired [ axis ] > 0.0f & & size_new_desired [ axis ] < = w_avail * 0.5f )
{
size_new [ axis ] = size_new_desired [ axis ] ;
size_old [ axis ] = IM_FLOOR ( w_avail - size_new [ axis ] ) ;
size_old [ axis ] = IM_TRUNC ( w_avail - size_new [ axis ] ) ;
}
else
{
size_new [ axis ] = IM_FLOOR ( w_avail * 0.5f ) ;
size_old [ axis ] = IM_FLOOR ( w_avail - size_new [ axis ] ) ;
size_new [ axis ] = IM_TRUNC ( w_avail * 0.5f ) ;
size_old [ axis ] = IM_TRUNC ( w_avail - size_new [ axis ] ) ;
}
// Position each node
@ -17147,21 +17150,21 @@ bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir
ImVec2 off ; // Distance from edge or center
if ( outer_docking )
{
//hs_w = ImFloor (ImClamp(parent_smaller_axis - hs_for_central_nodes * 4.0f, g.FontSize * 0.5f, g.FontSize * 8.0f));
//hs_h = ImFloor (hs_w * 0.15f);
//off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h), ImFloor (parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h));
hs_w = ImFloor ( hs_for_central_nodes * 1.50f ) ;
hs_h = ImFloor ( hs_for_central_nodes * 0.80f ) ;
off = ImVec2 ( ImFloor ( parent . GetWidth ( ) * 0.5f - hs_h ) , ImFloor ( parent . GetHeight ( ) * 0.5f - hs_h ) ) ;
//hs_w = ImTrunc (ImClamp(parent_smaller_axis - hs_for_central_nodes * 4.0f, g.FontSize * 0.5f, g.FontSize * 8.0f));
//hs_h = ImTrunc (hs_w * 0.15f);
//off = ImVec2(ImTrunc(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h), ImTrunc (parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h));
hs_w = ImTrunc ( hs_for_central_nodes * 1.50f ) ;
hs_h = ImTrunc ( hs_for_central_nodes * 0.80f ) ;
off = ImTrunc ( ImVec2 ( parent . GetWidth ( ) * 0.5f - hs_h , parent . GetHeight ( ) * 0.5f - hs_h ) ) ;
}
else
{
hs_w = ImFloor ( hs_for_central_nodes ) ;
hs_h = ImFloor ( hs_for_central_nodes * 0.90f ) ;
off = ImVec2 ( ImFloor ( hs_w * 2.40f ) , ImFloor ( hs_w * 2.40f ) ) ;
hs_w = ImTrunc ( hs_for_central_nodes ) ;
hs_h = ImTrunc ( hs_for_central_nodes * 0.90f ) ;
off = ImTrunc ( ImVec2 ( hs_w * 2.40f , hs_w * 2.40f ) ) ;
}
ImVec2 c = ImFloor ( parent . GetCenter ( ) ) ;
ImVec2 c = ImTrunc ( parent . GetCenter ( ) ) ;
if ( dir = = ImGuiDir_None ) { out_r = ImRect ( c . x - hs_w , c . y - hs_w , c . x + hs_w , c . y + hs_w ) ; }
else if ( dir = = ImGuiDir_Up ) { out_r = ImRect ( c . x - hs_w , c . y - off . y - hs_h , c . x + hs_w , c . y - off . y + hs_h ) ; }
else if ( dir = = ImGuiDir_Down ) { out_r = ImRect ( c . x - hs_w , c . y + off . y - hs_h , c . x + hs_w , c . y + off . y + hs_h ) ; }
@ -17175,7 +17178,7 @@ bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir
if ( ! outer_docking )
{
// Custom hit testing for the 5-way selection, designed to reduce flickering when moving diagonally between sides
hit_r . Expand ( ImFloor ( hs_w * 0.30f ) ) ;
hit_r . Expand ( ImTrunc ( hs_w * 0.30f ) ) ;
ImVec2 mouse_delta = ( * test_mouse_pos - c ) ;
float mouse_delta_len2 = ImLengthSqr ( mouse_delta ) ;
float r_threshold_center = hs_w * 1.4f ;
@ -17428,8 +17431,8 @@ void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG
size_avail = ImMax ( size_avail , g . Style . WindowMinSize [ split_axis ] * 2.0f ) ;
IM_ASSERT ( size_avail > 0.0f ) ; // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
child_0 - > SizeRef = child_1 - > SizeRef = parent_node - > Size ;
child_0 - > SizeRef [ split_axis ] = ImFloor ( size_avail * split_ratio ) ;
child_1 - > SizeRef [ split_axis ] = ImFloor ( size_avail - child_0 - > SizeRef [ split_axis ] ) ;
child_0 - > SizeRef [ split_axis ] = ImTrunc ( size_avail * split_ratio ) ;
child_1 - > SizeRef [ split_axis ] = ImTrunc ( size_avail - child_0 - > SizeRef [ split_axis ] ) ;
DockNodeMoveWindows ( parent_node - > ChildNodes [ split_inheritor_child_idx ] , parent_node ) ;
DockSettingsRenameNodeReferences ( parent_node - > ID , parent_node - > ChildNodes [ split_inheritor_child_idx ] - > ID ) ;
@ -17534,10 +17537,10 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
// Size allocation policy
// 1) The first 0..WindowMinSize[axis]*2 are allocated evenly to both windows.
const float size_min_each = ImFloor ( ImMin ( size_avail , g . Style . WindowMinSize [ axis ] * 2.0f ) * 0.5f ) ;
const float size_min_each = ImTrunc ( ImMin ( size_avail , g . Style . WindowMinSize [ axis ] * 2.0f ) * 0.5f ) ;
// FIXME: Blocks 2) and 3) are essentially doing nearly the same thing.
// Difference are: write-back to SizeRef; application of a minimum size; rounding before ImFloor ()
// Difference are: write-back to SizeRef; application of a minimum size; rounding before ImTrunc ()
// Clarify and rework differences between Size & SizeRef and purpose of WantLockSizeOnce
// 2) Process locked absolute size (during a splitter resize we preserve the child of nodes not touching the splitter edge)
@ -17558,7 +17561,7 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
// FIXME-DOCK: We cannot honor the requested size, so apply ratio.
// Currently this path will only be taken if code programmatically sets WantLockSizeOnce
float split_ratio = child_0_size [ axis ] / ( child_0_size [ axis ] + child_1_size [ axis ] ) ;
child_0_size [ axis ] = child_0 - > SizeRef [ axis ] = ImFloor ( size_avail * split_ratio ) ;
child_0_size [ axis ] = child_0 - > SizeRef [ axis ] = ImTrunc ( size_avail * split_ratio ) ;
child_1_size [ axis ] = child_1 - > SizeRef [ axis ] = ( size_avail - child_0_size [ axis ] ) ;
IM_ASSERT ( child_0 - > SizeRef [ axis ] > 0.0f & & child_1 - > SizeRef [ axis ] > 0.0f ) ;
}
@ -17578,7 +17581,7 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
{
// 4) Otherwise distribute according to the relative ratio of each SizeRef value
float split_ratio = child_0 - > SizeRef [ axis ] / ( child_0 - > SizeRef [ axis ] + child_1 - > SizeRef [ axis ] ) ;
child_0_size [ axis ] = ImMax ( size_min_each , ImFloor ( size_avail * split_ratio + 0.5f ) ) ;
child_0_size [ axis ] = ImMax ( size_min_each , ImTrunc ( size_avail * split_ratio + 0.5f ) ) ;
child_1_size [ axis ] = ( size_avail - child_0_size [ axis ] ) ;
}
@ -17860,7 +17863,7 @@ ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags
}
const ImVec2 content_avail = GetContentRegionAvail ( ) ;
ImVec2 size = ImFloor ( size_arg ) ;
ImVec2 size = ImTrunc ( size_arg ) ;
if ( size . x < = 0.0f )
size . x = ImMax ( content_avail . x + size . x , 4.0f ) ; // Arbitrary minimum child size (0.0f causing too much issues)
if ( size . y < = 0.0f )
@ -19131,8 +19134,8 @@ void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP*
ImRect thumb_r = thumb_window - > Rect ( ) ;
ImRect title_r = thumb_window - > TitleBarRect ( ) ;
thumb_r = ImRect ( ImFloor ( off + thumb_r . Min * scale ) , ImFloor ( off + thumb_r . Max * scale ) ) ;
title_r = ImRect ( ImFloor ( off + title_r . Min * scale ) , ImFloor ( off + ImVec2 ( title_r . Max . x , title_r . Min . y ) * scale ) + ImVec2 ( 0 , 5 ) ) ; // Exaggerate title bar height
thumb_r = ImRect ( ImTrunc ( off + thumb_r . Min * scale ) , ImTrunc ( off + thumb_r . Max * scale ) ) ;
title_r = ImRect ( ImTrunc ( off + title_r . Min * scale ) , ImTrunc ( off + ImVec2 ( title_r . Max . x , title_r . Min . y ) * scale ) + ImVec2 ( 0 , 5 ) ) ; // Exaggerate title bar height
thumb_r . ClipWithFull ( bb ) ;
title_r . ClipWithFull ( bb ) ;
const bool window_is_focused = ( g . NavWindow & & thumb_window - > RootWindowForTitleBarHighlight = = g . NavWindow - > RootWindowForTitleBarHighlight ) ;
@ -20126,8 +20129,8 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
// Draw bounding boxes
if ( show_aabb )
{
out_draw_list - > AddRect ( ImFloor ( clip_rect . Min ) , ImFloor ( clip_rect . Max ) , IM_COL32 ( 255 , 0 , 255 , 255 ) ) ; // In pink: clipping rectangle submitted to GPU
out_draw_list - > AddRect ( ImFloor ( vtxs_rect . Min ) , ImFloor ( vtxs_rect . Max ) , IM_COL32 ( 0 , 255 , 255 , 255 ) ) ; // In cyan: bounding box of triangles
out_draw_list - > AddRect ( ImTrunc ( clip_rect . Min ) , ImTrunc ( clip_rect . Max ) , IM_COL32 ( 255 , 0 , 255 , 255 ) ) ; // In pink: clipping rectangle submitted to GPU
out_draw_list - > AddRect ( ImTrunc ( vtxs_rect . Min ) , ImTrunc ( vtxs_rect . Max ) , IM_COL32 ( 0 , 255 , 255 , 255 ) ) ; // In cyan: bounding box of triangles
}
out_draw_list - > Flags = backup_flags ;
}