admin 发表于 2023-4-7 21:32:35

015-imGui窗口中的菜单TreeNode






郁金香灬外挂技术
       
        https://www.yjxsoft.com/
       
        本教程视频1920*1080分辩率下观看最佳
        VS2017+win10 64位 环境
        郁金香老师:扣扣 150330575
        欢迎大家参加 郁金香灬技术 游戏安全与外挂的研究学习。
       
        兴趣是我们最好的老师
        成长需要过程与循序渐进        
        兴趣+坚持+时间+优秀的教程会帮助你快速成功
   
    交流扣扣群 29817979,9569245


学习目标:
   树状节点控件
   TreeNode
   TreePop
   字体高度
   
   
    // ~ FontSize
    IMGUI_API float         GetTextLineHeight();                                          
          
       // - TreeNode functions return true when the node is open,
           //in which case you need to also call TreePop()
           //when you are finished displaying the tree node contents.
    IMGUI_API bool          TreeNode(const char* label);
    IMGUI_API bool          TreeNode(const char* str_id,
        const char* fmt, ...) IM_FMTARGS(2);   
        // helper variation to easily decorelate the id from the displayed string.
        //Read the FAQ about why and how to use ID.
        //to align arbitrary text at the same level as a TreeNode() you can use Bullet().
       
    IMGUI_API bool          TreeNode(const void* ptr_id,
        const char* fmt, ...) IM_FMTARGS(2);   // "



void testlistbox2()
{
    ImGui::Begin("testlistbox2");
   // IMGUI_DEMO_MARKER("Widgets/List Boxes");
    if (ImGui::TreeNode("List boxes"))
    {
      // Using the generic BeginListBox() API, you have full control over how to display the combo contents.
      // (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively
      // stored in the object itself, etc.)
      const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
      static int item_current_idx = 0; // Here we store our selection data as an index.
      ImGui::Text("listbox1:");
      if (ImGui::BeginListBox("##listbox 1", ImVec2(-2,100)))
      {
            for (int n = 0; n < IM_ARRAYSIZE(items); n++)
            {
                const bool is_selected = (item_current_idx == n);
                if (ImGui::Selectable(items, is_selected))
                  item_current_idx = n;

                // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
                if (is_selected)
                  ImGui::SetItemDefaultFocus();
            }
            ImGui::EndListBox();
    }

      // Custom size: use all width, 5 items tall
      ImGui::Text("listbox2:");
      if (ImGui::BeginListBox("##listbox 2", ImVec2(-FLT_MIN, 5 * ImGui::GetTextLineHeightWithSpacing())))
      {
            for (int n = 0; n < IM_ARRAYSIZE(items); n++)
            {
                const bool is_selected = (item_current_idx == n);
                if (ImGui::Selectable(items, is_selected))
                  item_current_idx = n;

                // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
                if (is_selected)
                  ImGui::SetItemDefaultFocus();
            }
            ImGui::EndListBox();
      }

      ImGui::TreePop();
}

    ImGui::End();
}
       
       
                if (ImGui::TreeNode("Style"))
      {
            HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function.");
            //BeginListBox EndListBox
            ImGui::TreePop();
            ImGui::Spacing();
      }
               
               
        //--------------+++++++++++++++++++----------------
void testTreeNode()
{
      ImGui::Begin("testTreeNode");
      if (ImGui::TreeNode("List boxes"))
      {
          {
            if (ImGui::TreeNode("List boxes1"))
            {
                  if (ImGui::TreeNode("List boxes2"))
                  {
                      if (ImGui::TreeNode("List boxes3"))
                      {
                        ImGui::TreePop();
                      }
                      ImGui::TreePop();
                  }
                  ImGui::TreePop();

            }
            
          }

          {
            if (ImGui::TreeNode("List boxesa1"))
            {
                  if (ImGui::TreeNode("List boxesa2a"))
                  {
                      if (ImGui::TreeNode("List boxesa3"))
                      {
                        ImGui::TreePop();
                      }
                      ImGui::TreePop();
                  }
                  ImGui::TreePop();

            }
            
          }

          {
            if (ImGui::TreeNode("List boxes11"))
            {
                  if (ImGui::TreeNode("List boxes22"))
                  {
                      if (ImGui::TreeNode("List boxes33"))
                      {
                        ImGui::TreePop();
                      }
                      ImGui::TreePop();
                  }
                  ImGui::TreePop();

            }
            
          }
          ImGui::TreePop();
      }
      ImGui::End();
};

       
               
               
       
          void testTreeNode2()
{
      ImGui::Begin("testTreeNode");
      if (ImGui::TreeNode("listId1","item>%d",__LINE__))
      {
          if (ImGui::TreeNode("listId1", "item>%d", __LINE__))
          {
            ImGui::TreePop();
          }
          if (ImGui::TreeNode("listId1", "item>%d", __LINE__))
          {
            ImGui::TreePop();
          }
          if (ImGui::TreeNode("listId2", "item>%d", __LINE__))
          {
            ImGui::TreePop();
          }

          ImGui::TreePop();
      }
      ImGui::End();
};



页: [1]
查看完整版本: 015-imGui窗口中的菜单TreeNode