TreeNode no arrow draw flag #9547

Open
opened 2026-09-17 16:35:16 +00:00 by izecheru · 0 comments
izecheru commented 2026-09-17 16:35:16 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version 1.92.7, Branch: docking

Back-ends:

imgui_impl_sdl2.cpp + imgui_impl_vulkan.cpp

Compiler, OS:

Windows 11 + MSVC 2022

Full config/build information:

No response

Details:

This is rather a request since i can't seem to find a way to edit imgui source efficiently without formatting the code with my clang-format tool and make a PR myself.

I am using TreeNodeEx for my file explorer in the game engine that i'm building and did not like the arrows so I made some tiny changes.

All i've changed is added an ImGuiTreeNodeFlags_NoArrowDraw flag and skip the RenderBullet/ RenderArrow calls in the TreeNodeBehavior, and if this flag is found subtract the text_offset_x value from text_pos.x

Screenshots/Video:

Image

Minimal, Complete and Verifiable Example code:


   // this is the if(display_frame) body
{
      // Framed type
      const ImU32 bg_col = GetColorU32( ( held && hovered ) ? ImGuiCol_HeaderActive
                                        : hovered           ? ImGuiCol_HeaderHovered
                                                            : ImGuiCol_Header );
      RenderFrame( frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding );
      RenderNavCursor( frame_bb, id, nav_render_cursor_flags );
      if ( span_all_columns && !span_all_columns_label )
        TablePopBackgroundChannel();
      if ( !( flags & ImGuiTreeNodeFlags_NoArrowDraw ) )
      {
        if ( flags & ImGuiTreeNodeFlags_Bullet )
          RenderBullet(
            window->DrawList, ImVec2( text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f ), text_col );
        else if ( !is_leaf )
          RenderArrow( window->DrawList,
                       ImVec2( text_pos.x - text_offset_x + padding.x, text_pos.y ),
                       text_col,
                       is_open ? ( ( flags & ImGuiTreeNodeFlags_UpsideDownArrow ) ? ImGuiDir_Up : ImGuiDir_Down )
                               : ImGuiDir_Right,
                       1.0f );
        else // Leaf without bullet, left-adjusted text
          text_pos.x -= text_offset_x - padding.x;
      }
      if ( flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton )
        frame_bb.Max.x -= g.FontSize + style.FramePadding.x;
      if ( g.LogEnabled )
        LogSetNextTextDecoration( "###", "###" );

}

   // shift text back since there's no arrow drawn
   if ( flags & ImGuiTreeNodeFlags_NoArrowDraw )
     text_pos.x -= text_offset_x;

   // Label
   if ( display_frame )
     RenderTextClipped( text_pos, frame_bb.Max, label, label_end, &label_size );
   else
     RenderText( text_pos, label, label_end, false );

### Version/Branch of Dear ImGui: Version 1.92.7, Branch: docking ### Back-ends: imgui_impl_sdl2.cpp + imgui_impl_vulkan.cpp ### Compiler, OS: Windows 11 + MSVC 2022 ### Full config/build information: _No response_ ### Details: This is rather a request since i can't seem to find a way to edit imgui source efficiently without formatting the code with my clang-format tool and make a PR myself. I am using TreeNodeEx for my file explorer in the game engine that i'm building and did not like the arrows so I made some tiny changes. All i've changed is added an ImGuiTreeNodeFlags_NoArrowDraw flag and skip the RenderBullet/ RenderArrow calls in the TreeNodeBehavior, and if this flag is found subtract the text_offset_x value from text_pos.x ### Screenshots/Video: <img width="352" height="181" alt="Image" src="https://github.com/user-attachments/assets/d8ef6bbe-7589-4257-b2bb-aa424e300517" /> ### Minimal, Complete and Verifiable Example code: ```cpp // this is the if(display_frame) body { // Framed type const ImU32 bg_col = GetColorU32( ( held && hovered ) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header ); RenderFrame( frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding ); RenderNavCursor( frame_bb, id, nav_render_cursor_flags ); if ( span_all_columns && !span_all_columns_label ) TablePopBackgroundChannel(); if ( !( flags & ImGuiTreeNodeFlags_NoArrowDraw ) ) { if ( flags & ImGuiTreeNodeFlags_Bullet ) RenderBullet( window->DrawList, ImVec2( text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f ), text_col ); else if ( !is_leaf ) RenderArrow( window->DrawList, ImVec2( text_pos.x - text_offset_x + padding.x, text_pos.y ), text_col, is_open ? ( ( flags & ImGuiTreeNodeFlags_UpsideDownArrow ) ? ImGuiDir_Up : ImGuiDir_Down ) : ImGuiDir_Right, 1.0f ); else // Leaf without bullet, left-adjusted text text_pos.x -= text_offset_x - padding.x; } if ( flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton ) frame_bb.Max.x -= g.FontSize + style.FramePadding.x; if ( g.LogEnabled ) LogSetNextTextDecoration( "###", "###" ); } // shift text back since there's no arrow drawn if ( flags & ImGuiTreeNodeFlags_NoArrowDraw ) text_pos.x -= text_offset_x; // Label if ( display_frame ) RenderTextClipped( text_pos, frame_bb.Max, label, label_end, &label_size ); else RenderText( text_pos, label, label_end, false ); ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#9547
No description provided.