@ -3193,6 +3193,32 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFl
}
}
}
}
void ImGui : : RenderMouseCursor ( ImVec2 base_pos , float base_scale , ImGuiMouseCursor mouse_cursor , ImU32 col_fill , ImU32 col_border , ImU32 col_shadow )
{
ImGuiContext & g = * GImGui ;
IM_ASSERT ( mouse_cursor > ImGuiMouseCursor_None & & mouse_cursor < ImGuiMouseCursor_COUNT ) ;
for ( int n = 0 ; n < g . Viewports . Size ; n + + )
{
ImGuiViewportP * viewport = g . Viewports [ n ] ;
ImDrawList * draw_list = GetForegroundDrawList ( viewport ) ;
ImFontAtlas * font_atlas = draw_list - > _Data - > Font - > ContainerAtlas ;
ImVec2 offset , size , uv [ 4 ] ;
if ( font_atlas - > GetMouseCursorTexData ( mouse_cursor , & offset , & size , & uv [ 0 ] , & uv [ 2 ] ) )
{
const ImVec2 pos = base_pos - offset ;
const float scale = base_scale ;
ImTextureID tex_id = font_atlas - > TexID ;
draw_list - > PushTextureID ( tex_id ) ;
draw_list - > AddImage ( tex_id , pos + ImVec2 ( 1 , 0 ) * scale , pos + ( ImVec2 ( 1 , 0 ) + size ) * scale , uv [ 2 ] , uv [ 3 ] , col_shadow ) ;
draw_list - > AddImage ( tex_id , pos + ImVec2 ( 2 , 0 ) * scale , pos + ( ImVec2 ( 2 , 0 ) + size ) * scale , uv [ 2 ] , uv [ 3 ] , col_shadow ) ;
draw_list - > AddImage ( tex_id , pos , pos + size * scale , uv [ 2 ] , uv [ 3 ] , col_border ) ;
draw_list - > AddImage ( tex_id , pos , pos + size * scale , uv [ 0 ] , uv [ 1 ] , col_fill ) ;
draw_list - > PopTextureID ( ) ;
}
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@ -4888,6 +4914,10 @@ void ImGui::Render()
if ( windows_to_render_top_most [ n ] & & IsWindowActiveAndVisible ( windows_to_render_top_most [ n ] ) ) // NavWindowingTarget is always temporarily displayed as the top-most window
if ( windows_to_render_top_most [ n ] & & IsWindowActiveAndVisible ( windows_to_render_top_most [ n ] ) ) // NavWindowingTarget is always temporarily displayed as the top-most window
AddRootWindowToDrawData ( windows_to_render_top_most [ n ] ) ;
AddRootWindowToDrawData ( windows_to_render_top_most [ n ] ) ;
// Draw software mouse cursor if requested by io.MouseDrawCursor flag
if ( g . IO . MouseDrawCursor & & first_render_of_frame & & g . MouseCursor ! = ImGuiMouseCursor_None )
RenderMouseCursor ( g . IO . MousePos , g . Style . MouseCursorScale , g . MouseCursor , IM_COL32_WHITE , IM_COL32_BLACK , IM_COL32 ( 0 , 0 , 0 , 48 ) ) ;
// Setup ImDrawData structures for end-user
// Setup ImDrawData structures for end-user
g . IO . MetricsRenderVertices = g . IO . MetricsRenderIndices = 0 ;
g . IO . MetricsRenderVertices = g . IO . MetricsRenderIndices = 0 ;
for ( int n = 0 ; n < g . Viewports . Size ; n + + )
for ( int n = 0 ; n < g . Viewports . Size ; n + + )
@ -4895,10 +4925,6 @@ void ImGui::Render()
ImGuiViewportP * viewport = g . Viewports [ n ] ;
ImGuiViewportP * viewport = g . Viewports [ n ] ;
viewport - > DrawDataBuilder . FlattenIntoSingleLayer ( ) ;
viewport - > DrawDataBuilder . FlattenIntoSingleLayer ( ) ;
// Draw software mouse cursor if requested by io.MouseDrawCursor flag
if ( g . IO . MouseDrawCursor & & first_render_of_frame )
RenderMouseCursor ( GetForegroundDrawList ( viewport ) , g . IO . MousePos , g . Style . MouseCursorScale , g . MouseCursor , IM_COL32_WHITE , IM_COL32_BLACK , IM_COL32 ( 0 , 0 , 0 , 48 ) ) ;
// Add foreground ImDrawList (for each active viewport)
// Add foreground ImDrawList (for each active viewport)
if ( viewport - > DrawLists [ 1 ] ! = NULL )
if ( viewport - > DrawLists [ 1 ] ! = NULL )
AddDrawListToDrawData ( & viewport - > DrawDataBuilder . Layers [ 0 ] , GetForegroundDrawList ( viewport ) ) ;
AddDrawListToDrawData ( & viewport - > DrawDataBuilder . Layers [ 0 ] , GetForegroundDrawList ( viewport ) ) ;